Merge branch 'main' into add-env-for-mastodon
This commit is contained in:
commit
8a972c591f
|
|
@ -2,12 +2,22 @@
|
|||
# any half-built stuff in the build context as a pre-caution (also saves copying
|
||||
# 180k files in node_modules that isn't used!).
|
||||
**/node_modules
|
||||
node_modules/*
|
||||
node_modules
|
||||
docker-data/*
|
||||
dist
|
||||
.nx
|
||||
/apps/frontend/.next
|
||||
/apps/backend/dist
|
||||
/apps/workers/dist
|
||||
/apps/cron/dist
|
||||
/apps/commands/dist
|
||||
.devcontainer
|
||||
**/.git
|
||||
**/dist
|
||||
**/*.md
|
||||
**/LICENSE
|
||||
**/npm-debug.log
|
||||
**/*.vscode
|
||||
.git
|
||||
.github
|
||||
reports
|
||||
22
.env.example
22
.env.example
|
|
@ -1,6 +1,6 @@
|
|||
# Configuration reference: http://docs.postiz.com/configuration/reference
|
||||
|
||||
# === Required Settings
|
||||
# === Required Settings
|
||||
DATABASE_URL="postgresql://postiz-user:postiz-password@localhost:5432/postiz-db-local"
|
||||
REDIS_URL="redis://localhost:6379"
|
||||
JWT_SECRET="random string for your JWT secret, make it long"
|
||||
|
|
@ -20,7 +20,6 @@ CLOUDFLARE_BUCKETNAME="your-bucket-name"
|
|||
CLOUDFLARE_BUCKET_URL="https://your-bucket-url.r2.cloudflarestorage.com/"
|
||||
CLOUDFLARE_REGION="auto"
|
||||
|
||||
|
||||
# === Common optional Settings
|
||||
|
||||
## This is a dummy key, you must create your own from Resend.
|
||||
|
|
@ -32,7 +31,7 @@ CLOUDFLARE_REGION="auto"
|
|||
#DISABLE_REGISTRATION=false
|
||||
|
||||
# Where will social media icons be saved - local or cloudflare.
|
||||
STORAGE_PROVIDER="local"
|
||||
STORAGE_PROVIDER="local"
|
||||
|
||||
# Your upload directory path if you host your files locally, otherwise Cloudflare will be used.
|
||||
#UPLOAD_DIRECTORY=""
|
||||
|
|
@ -40,7 +39,6 @@ STORAGE_PROVIDER="local"
|
|||
# Your upload directory path if you host your files locally, otherwise Cloudflare will be used.
|
||||
#NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY=""
|
||||
|
||||
|
||||
# Social Media API Settings
|
||||
X_API_KEY=""
|
||||
X_API_SECRET=""
|
||||
|
|
@ -81,6 +79,7 @@ OPENAI_API_KEY=""
|
|||
NEXT_PUBLIC_DISCORD_SUPPORT=""
|
||||
NEXT_PUBLIC_POLOTNO=""
|
||||
NOT_SECURED=false
|
||||
API_LIMIT=30 # The limit of the public API hour limit
|
||||
|
||||
# Payment settings
|
||||
FEE_AMOUNT=0.05
|
||||
|
|
@ -92,3 +91,18 @@ STRIPE_SIGNING_KEY_CONNECT=""
|
|||
# Developer Settings
|
||||
NX_ADD_PLUGINS=false
|
||||
IS_GENERAL="true" # required for now
|
||||
NEXT_PUBLIC_POSTIZ_OAUTH_DISPLAY_NAME="Authentik"
|
||||
NEXT_PUBLIC_POSTIZ_OAUTH_LOGO_URL="https://raw.githubusercontent.com/walkxcode/dashboard-icons/master/png/authentik.png"
|
||||
POSTIZ_GENERIC_OAUTH="false"
|
||||
POSTIZ_OAUTH_URL="https://auth.example.com"
|
||||
POSTIZ_OAUTH_AUTH_URL="https://auth.example.com/application/o/authorize"
|
||||
POSTIZ_OAUTH_TOKEN_URL="https://auth.example.com/application/o/token"
|
||||
POSTIZ_OAUTH_USERINFO_URL="https://authentik.example.com/application/o/userinfo"
|
||||
POSTIZ_OAUTH_CLIENT_ID=""
|
||||
POSTIZ_OAUTH_CLIENT_SECRET=""
|
||||
# POSTIZ_OAUTH_SCOPE="openid profile email" # default values
|
||||
|
||||
# Short Link Service Settings
|
||||
# DUB_TOKEN="" # Your self-hosted Dub API token
|
||||
# DUB_API_ENDPOINT="https://api.dub.co" # Your self-hosted Dub API endpoint
|
||||
# DUB_SHORT_LINK_DOMAIN="dub.sh" # Your self-hosted Dub domain
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
"root": true,
|
||||
"ignorePatterns": ["**/*"],
|
||||
"plugins": ["@nx"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||
"rules": {
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["*.ts", "*.tsx"],
|
||||
"extends": ["plugin:@nx/typescript"],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
"react/display-name": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["*.js", "*.jsx"],
|
||||
"extends": ["plugin:@nx/javascript"],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
name: Build Extension
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
submit:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Zip extensions
|
||||
run: FRONTEND_URL=https://platform.postiz.com pnpm run build:extension
|
||||
|
||||
- name: Upload to Nextcloud
|
||||
env:
|
||||
NEXTCLOUD_URL: ${{ secrets.NEXTCLOUD_URL }}
|
||||
NEXTCLOUD_USERNAME: ${{ secrets.NEXTCLOUD_USERNAME }}
|
||||
NEXTCLOUD_PASSWORD: ${{ secrets.NEXTCLOUD_PASSWORD }}
|
||||
run: |
|
||||
curl -T apps/extension/extension.zip \
|
||||
-u "$NEXTCLOUD_USERNAME:$NEXTCLOUD_PASSWORD" \
|
||||
"$NEXTCLOUD_URL/extension.zip"
|
||||
|
|
@ -3,8 +3,7 @@ name: Build
|
|||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
|
@ -21,20 +20,30 @@ jobs:
|
|||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
cache-dependency-path: |
|
||||
**/package-lock.json
|
||||
|
||||
# https://nextjs.org/docs/pages/building-your-application/deploying/ci-build-caching#github-actions
|
||||
- uses: actions/cache@v4
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 8
|
||||
run_install: false
|
||||
|
||||
- name: Get pnpm store directory
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- name: Setup pnpm cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.npm
|
||||
${{ env.STORE_PATH }}
|
||||
${{ github.workspace }}/.next/cache
|
||||
|
||||
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
|
||||
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
|
||||
${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}-
|
||||
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build
|
||||
run: pnpm run build
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ jobs:
|
|||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
username: egelhaus
|
||||
password: ${{ github.token }}
|
||||
|
||||
- name: Set image tag
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
name: Publish Extension
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
submit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Zip extensions
|
||||
run: FRONTEND_URL=https://platform.postiz.com pnpm run build:extension
|
||||
|
||||
- name: Publish to Chrome Web Store
|
||||
uses: mnao305/chrome-extension-upload@v5.0.0
|
||||
with:
|
||||
extension-id: ${{ secrets.CHROME_EXTENSION_ID }}
|
||||
client-id: ${{ secrets.CHROME_CLIENT_ID }}
|
||||
client-secret: ${{ secrets.CHROME_CLIENT_SECRET }}
|
||||
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }}
|
||||
file-path: apps/extension/extension.zip
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
name: Close inactive issues
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "*/30 * * * *"
|
||||
|
||||
jobs:
|
||||
close-issues:
|
||||
if: github.repository == 'gitroomhq/postiz-app'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
days-before-issue-stale: 90
|
||||
days-before-issue-close: 7
|
||||
stale-issue-label: "stale"
|
||||
stale-issue-message: "This issue is stale because it has been open for 90 days with no activity."
|
||||
close-issue-message: "This issue was closed because it has been inactive for 7 days since being marked as stale."
|
||||
exempt-issue-labels: "no-stale-bot"
|
||||
|
||||
days-before-pr-stale: 90
|
||||
days-before-pr-close: 7
|
||||
stale-pr-label: "stale"
|
||||
stale-pr-message: "This PR is stale because it has been open for 90 days with no activity."
|
||||
close-pr-message: "This PR was closed because it has been inactive for 7 days since being marked as stale."
|
||||
exempt-pr-label: "no-stale-bot"
|
||||
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
operations-per-run: 180
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
ignore-workspace-root-check=true
|
||||
node-linker=hoisted
|
||||
restrict-manifest-changes=true
|
||||
sync-injected-deps-after-scripts[]=build
|
||||
inject-workspace-packages=true
|
||||
|
|
@ -1,78 +1,19 @@
|
|||
# This Dockerfile is used for producing 3 container images.
|
||||
#
|
||||
# base - which is thrown away, that contains node and the basic infrastructure.
|
||||
# devcontainer - which is used for development, and contains the source code and the node_modules.
|
||||
# dist - which is used for production, and contains the built source code and the node_modules.
|
||||
|
||||
ARG NODE_VERSION="20.17"
|
||||
|
||||
# Base image
|
||||
FROM docker.io/node:${NODE_VERSION}-alpine3.19 AS base
|
||||
|
||||
## Just reduce unccessary noise in the logs.
|
||||
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
RUN apk add --no-cache \
|
||||
caddy \
|
||||
bash=5.2.21-r0 \
|
||||
supervisor=4.2.5-r4
|
||||
FROM node:20-alpine3.19
|
||||
RUN apk add --no-cache g++ make py3-pip supervisor bash caddy
|
||||
RUN npm --no-update-notifier --no-fund --global install pnpm@10.6.1 pm2
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
EXPOSE 3000
|
||||
EXPOSE 4200
|
||||
EXPOSE 5000
|
||||
|
||||
COPY var/docker/entrypoint.sh /app/entrypoint.sh
|
||||
COPY . /app
|
||||
COPY var/docker/supervisord.conf /etc/supervisord.conf
|
||||
COPY var/docker/supervisord /app/supervisord_available_configs/
|
||||
COPY var/docker/Caddyfile /app/Caddyfile
|
||||
COPY .env.example /config/postiz.env
|
||||
COPY var/docker/entrypoint.sh /app/entrypoint.sh
|
||||
COPY var/docker/supervisord/caddy.conf /etc/supervisor.d/caddy.conf
|
||||
RUN chmod +x /app/entrypoint.sh
|
||||
|
||||
VOLUME /config
|
||||
VOLUME /uploads
|
||||
RUN pnpm install
|
||||
RUN pnpm run build
|
||||
|
||||
LABEL org.opencontainers.image.source=https://github.com/gitroomhq/postiz-app
|
||||
EXPOSE 4200
|
||||
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
|
||||
# Builder image
|
||||
FROM base AS devcontainer
|
||||
|
||||
RUN apk add --no-cache \
|
||||
pkgconfig \
|
||||
gcc \
|
||||
pixman-dev \
|
||||
cairo-dev \
|
||||
pango-dev \
|
||||
make \
|
||||
build-base
|
||||
|
||||
COPY nx.json tsconfig.base.json package.json package-lock.json build.plugins.js /app/
|
||||
COPY apps /app/apps/
|
||||
COPY libraries /app/libraries/
|
||||
|
||||
RUN npm ci --no-fund && npx nx run-many --target=build --projects=frontend,backend,workers,cron
|
||||
|
||||
VOLUME /config
|
||||
VOLUME /uploads
|
||||
|
||||
LABEL org.opencontainers.image.title="Postiz App (DevContainer)"
|
||||
|
||||
# Output image
|
||||
FROM base AS dist
|
||||
|
||||
COPY --from=devcontainer /app/node_modules/ /app/node_modules/
|
||||
COPY --from=devcontainer /app/dist/ /app/dist/
|
||||
|
||||
# Required for prisma
|
||||
COPY --from=devcontainer /app/libraries/ /app/libraries/
|
||||
|
||||
COPY package.json nx.json /app/
|
||||
|
||||
VOLUME /config
|
||||
VOLUME /uploads
|
||||
|
||||
## Labels at the bottom, because CI will eventually add dates, commit hashes, etc.
|
||||
LABEL org.opencontainers.image.title="Postiz App (Production)"
|
||||
CMD ["pnpm", "run", "pm2"]
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@
|
|||
<a href="https://docs.postiz.com" rel="dofollow"><strong>Explore the docs »</strong></a>
|
||||
<br />
|
||||
|
||||
<br />
|
||||
<a href="https://youtube.com/@postizofficial" rel="dofollow"><strong>Watch the YouTube Tutorials»</strong></a>
|
||||
<br />
|
||||
|
||||
<br/>
|
||||
<a href="https://platform.postiz.com">Register</a>
|
||||
·
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"extends": ["../../.eslintrc.json"],
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.ts", "*.tsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
dist/
|
||||
node_modules/
|
||||
[._]*.s[a-v][a-z]
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-rt-v][a-z]
|
||||
[._]ss[a-gi-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
/* eslint-disable */
|
||||
export default {
|
||||
displayName: 'backend',
|
||||
preset: '../../jest.preset.js',
|
||||
testEnvironment: 'node',
|
||||
transform: {
|
||||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
||||
},
|
||||
moduleFileExtensions: ['ts', 'js', 'html'],
|
||||
coverageDirectory: '../../coverage/apps/backend',
|
||||
};
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/nest-cli",
|
||||
"collection": "@nestjs/schematics",
|
||||
"monorepo": false,
|
||||
"sourceRoot": "src",
|
||||
"entryFile": "../../dist/backend/apps/backend/src/main",
|
||||
"language": "ts",
|
||||
"generateOptions": {
|
||||
"spec": false
|
||||
},
|
||||
"compilerOptions": {
|
||||
"manualRestart": true,
|
||||
"tsConfigPath": "./tsconfig.build.json",
|
||||
"webpack": false,
|
||||
"deleteOutDir": true,
|
||||
"assets": [],
|
||||
"watchAssets": false,
|
||||
"plugins": []
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "postiz-backend",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"dev": "dotenv -e ../../.env -- nest start --watch --entryFile=./apps/backend/src/main",
|
||||
"build": "NODE_ENV=production nest build",
|
||||
"start": "dotenv -e ../../.env -- node ./dist/apps/backend/src/main.js",
|
||||
"pm2": "pm2 start pnpm --name backend -- start"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
{
|
||||
"name": "backend",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "apps/backend/src",
|
||||
"projectType": "application",
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@nx/webpack:webpack",
|
||||
"outputs": ["{options.outputPath}"],
|
||||
"defaultConfiguration": "production",
|
||||
"options": {
|
||||
"target": "node",
|
||||
"compiler": "tsc",
|
||||
"outputPath": "dist/apps/backend",
|
||||
"main": "apps/backend/src/main.ts",
|
||||
"tsConfig": "apps/backend/tsconfig.app.json",
|
||||
"assets": ["apps/backend/src/assets"],
|
||||
"webpackConfig": "apps/backend/webpack.config.js",
|
||||
"transformers": [
|
||||
{
|
||||
"name": "@nestjs/swagger/plugin",
|
||||
"options": {
|
||||
"dtoFileNameSuffix": [".dto.ts"],
|
||||
"controllerFileNameSuffix": [".controller.ts"],
|
||||
"introspectComments": true,
|
||||
"classValidatorShim": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"configurations": {
|
||||
"development": {},
|
||||
"production": {}
|
||||
}
|
||||
},
|
||||
"serve": {
|
||||
"executor": "@nx/js:node",
|
||||
"defaultConfiguration": "development",
|
||||
"options": {
|
||||
"buildTarget": "backend:build",
|
||||
"inspect": false
|
||||
},
|
||||
"configurations": {
|
||||
"development": {
|
||||
"buildTarget": "backend:build:development"
|
||||
},
|
||||
"production": {
|
||||
"buildTarget": "backend:build:production"
|
||||
}
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/eslint:lint",
|
||||
"outputs": ["{options.outputFile}"]
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nx/jest:jest",
|
||||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
||||
"options": {
|
||||
"jestConfig": "apps/backend/jest.config.ts"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
|
|
@ -33,7 +33,6 @@ import { SignatureController } from '@gitroom/backend/api/routes/signature.contr
|
|||
import { AutopostController } from '@gitroom/backend/api/routes/autopost.controller';
|
||||
import { McpService } from '@gitroom/nestjs-libraries/mcp/mcp.service';
|
||||
import { McpController } from '@gitroom/backend/api/routes/mcp.controller';
|
||||
import { McpSettings } from '@gitroom/nestjs-libraries/mcp/mcp.settings';
|
||||
|
||||
const authenticatedController = [
|
||||
UsersController,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Ip,
|
||||
Param,
|
||||
Post,
|
||||
Query,
|
||||
|
|
@ -103,7 +102,7 @@ export class AuthController {
|
|||
response.status(200).json({
|
||||
register: true,
|
||||
});
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
response.status(400).send(e.message);
|
||||
}
|
||||
}
|
||||
|
|
@ -167,7 +166,7 @@ export class AuthController {
|
|||
response.status(200).json({
|
||||
login: true,
|
||||
});
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
response.status(400).send(e.message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export class CopilotController {
|
|||
req?.body?.variables?.data?.metadata?.requestType ===
|
||||
'TextareaCompletion'
|
||||
? 'gpt-4o-mini'
|
||||
: 'gpt-4o-2024-08-06',
|
||||
: 'gpt-4.1',
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ export class PostsController {
|
|||
return { ask: this._shortLinkService.askShortLinkedin(body.messages) };
|
||||
}
|
||||
|
||||
@Get('/marketplace/:id?')
|
||||
@Get('/marketplace/:id')
|
||||
async getMarketplacePosts(
|
||||
@GetOrgFromRequest() org: Organization,
|
||||
@Param('id') id: string
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {
|
|||
Controller,
|
||||
Get,
|
||||
Header,
|
||||
HttpException,
|
||||
Param,
|
||||
Post,
|
||||
RawBodyRequest,
|
||||
|
|
@ -52,27 +53,34 @@ export class StripeController {
|
|||
);
|
||||
|
||||
// Maybe it comes from another stripe webhook
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
if (event?.data?.object?.metadata?.service !== 'gitroom' && event.type !== 'invoice.payment_succeeded') {
|
||||
if (
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
event?.data?.object?.metadata?.service !== 'gitroom' &&
|
||||
event.type !== 'invoice.payment_succeeded'
|
||||
) {
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
switch (event.type) {
|
||||
case 'invoice.payment_succeeded':
|
||||
return this._stripeService.paymentSucceeded(event);
|
||||
case 'checkout.session.completed':
|
||||
return this._stripeService.updateOrder(event);
|
||||
case 'account.updated':
|
||||
return this._stripeService.updateAccount(event);
|
||||
case 'customer.subscription.created':
|
||||
return this._stripeService.createSubscription(event);
|
||||
case 'customer.subscription.updated':
|
||||
return this._stripeService.updateSubscription(event);
|
||||
case 'customer.subscription.deleted':
|
||||
return this._stripeService.deleteSubscription(event);
|
||||
default:
|
||||
return { ok: true };
|
||||
try {
|
||||
switch (event.type) {
|
||||
case 'invoice.payment_succeeded':
|
||||
return this._stripeService.paymentSucceeded(event);
|
||||
case 'checkout.session.completed':
|
||||
return this._stripeService.updateOrder(event);
|
||||
case 'account.updated':
|
||||
return this._stripeService.updateAccount(event);
|
||||
case 'customer.subscription.created':
|
||||
return this._stripeService.createSubscription(event);
|
||||
case 'customer.subscription.updated':
|
||||
return this._stripeService.updateSubscription(event);
|
||||
case 'customer.subscription.deleted':
|
||||
return this._stripeService.deleteSubscription(event);
|
||||
default:
|
||||
return { ok: true };
|
||||
}
|
||||
} catch (e) {
|
||||
throw new HttpException(e, 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import { McpModule } from '@gitroom/backend/mcp/mcp.module';
|
|||
ThrottlerModule.forRoot([
|
||||
{
|
||||
ttl: 3600000,
|
||||
limit: 30,
|
||||
limit: process.env.API_LIMIT ? Number(process.env.API_LIMIT) : 30,
|
||||
},
|
||||
]),
|
||||
],
|
||||
|
|
@ -40,8 +40,15 @@ import { McpModule } from '@gitroom/backend/mcp/mcp.module';
|
|||
useClass: PoliciesGuard,
|
||||
},
|
||||
],
|
||||
get exports() {
|
||||
return [...this.imports];
|
||||
},
|
||||
exports: [
|
||||
BullMqModule,
|
||||
DatabaseModule,
|
||||
ApiModule,
|
||||
PluginModule,
|
||||
PublicApiModule,
|
||||
AgentModule,
|
||||
McpModule,
|
||||
ThrottlerModule,
|
||||
],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,103 @@
|
|||
import { ProvidersInterface } from '@gitroom/backend/services/auth/providers.interface';
|
||||
|
||||
export class OauthProvider implements ProvidersInterface {
|
||||
private readonly authUrl: string;
|
||||
private readonly baseUrl: string;
|
||||
private readonly clientId: string;
|
||||
private readonly clientSecret: string;
|
||||
private readonly frontendUrl: string;
|
||||
private readonly tokenUrl: string;
|
||||
private readonly userInfoUrl: string;
|
||||
|
||||
constructor() {
|
||||
const {
|
||||
POSTIZ_OAUTH_AUTH_URL,
|
||||
POSTIZ_OAUTH_CLIENT_ID,
|
||||
POSTIZ_OAUTH_CLIENT_SECRET,
|
||||
POSTIZ_OAUTH_TOKEN_URL,
|
||||
POSTIZ_OAUTH_URL,
|
||||
POSTIZ_OAUTH_USERINFO_URL,
|
||||
FRONTEND_URL,
|
||||
} = process.env;
|
||||
|
||||
if (!POSTIZ_OAUTH_USERINFO_URL)
|
||||
throw new Error(
|
||||
'POSTIZ_OAUTH_USERINFO_URL environment variable is not set'
|
||||
);
|
||||
if (!POSTIZ_OAUTH_URL)
|
||||
throw new Error('POSTIZ_OAUTH_URL environment variable is not set');
|
||||
if (!POSTIZ_OAUTH_TOKEN_URL)
|
||||
throw new Error('POSTIZ_OAUTH_TOKEN_URL environment variable is not set');
|
||||
if (!POSTIZ_OAUTH_CLIENT_ID)
|
||||
throw new Error('POSTIZ_OAUTH_CLIENT_ID environment variable is not set');
|
||||
if (!POSTIZ_OAUTH_CLIENT_SECRET)
|
||||
throw new Error(
|
||||
'POSTIZ_OAUTH_CLIENT_SECRET environment variable is not set'
|
||||
);
|
||||
if (!POSTIZ_OAUTH_AUTH_URL)
|
||||
throw new Error('POSTIZ_OAUTH_AUTH_URL environment variable is not set');
|
||||
if (!FRONTEND_URL)
|
||||
throw new Error('FRONTEND_URL environment variable is not set');
|
||||
|
||||
this.authUrl = POSTIZ_OAUTH_AUTH_URL;
|
||||
this.baseUrl = POSTIZ_OAUTH_URL;
|
||||
this.clientId = POSTIZ_OAUTH_CLIENT_ID;
|
||||
this.clientSecret = POSTIZ_OAUTH_CLIENT_SECRET;
|
||||
this.frontendUrl = FRONTEND_URL;
|
||||
this.tokenUrl = POSTIZ_OAUTH_TOKEN_URL;
|
||||
this.userInfoUrl = POSTIZ_OAUTH_USERINFO_URL;
|
||||
}
|
||||
|
||||
generateLink(): string {
|
||||
const params = new URLSearchParams({
|
||||
client_id: this.clientId,
|
||||
scope: 'openid profile email',
|
||||
response_type: 'code',
|
||||
redirect_uri: `${this.frontendUrl}/settings`,
|
||||
});
|
||||
|
||||
return `${this.authUrl}/?${params.toString()}`;
|
||||
}
|
||||
|
||||
async getToken(code: string): Promise<string> {
|
||||
const response = await fetch(`${this.tokenUrl}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
Accept: 'application/json',
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
grant_type: 'authorization_code',
|
||||
client_id: this.clientId,
|
||||
client_secret: this.clientSecret,
|
||||
code,
|
||||
redirect_uri: `${this.frontendUrl}/settings`,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.text();
|
||||
throw new Error(`Token request failed: ${error}`);
|
||||
}
|
||||
|
||||
const { access_token } = await response.json();
|
||||
return access_token;
|
||||
}
|
||||
|
||||
async getUser(access_token: string): Promise<{ email: string; id: string }> {
|
||||
const response = await fetch(`${this.userInfoUrl}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${access_token}`,
|
||||
Accept: 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.text();
|
||||
throw new Error(`User info request failed: ${error}`);
|
||||
}
|
||||
|
||||
const { email, sub: id } = await response.json();
|
||||
return { email, id };
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import { ProvidersInterface } from '@gitroom/backend/services/auth/providers.int
|
|||
import { GoogleProvider } from '@gitroom/backend/services/auth/providers/google.provider';
|
||||
import { FarcasterProvider } from '@gitroom/backend/services/auth/providers/farcaster.provider';
|
||||
import { WalletProvider } from '@gitroom/backend/services/auth/providers/wallet.provider';
|
||||
import { OauthProvider } from '@gitroom/backend/services/auth/providers/oauth.provider';
|
||||
|
||||
export class ProvidersFactory {
|
||||
static loadProvider(provider: Provider): ProvidersInterface {
|
||||
|
|
@ -16,6 +17,8 @@ export class ProvidersFactory {
|
|||
return new FarcasterProvider();
|
||||
case Provider.WALLET:
|
||||
return new WalletProvider();
|
||||
case Provider.GENERIC:
|
||||
return new OauthProvider();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"module": "commonjs",
|
||||
"types": ["node", "multer"],
|
||||
"emitDecoratorMetadata": true,
|
||||
"target": "es2021"
|
||||
},
|
||||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"],
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS",
|
||||
"resolveJsonModule": true,
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"incremental": true,
|
||||
"skipLibCheck": true,
|
||||
"strictNullChecks": false,
|
||||
"noImplicitAny": false,
|
||||
"strictBindCallApply": false,
|
||||
"forceConsistentCasingInFileNames": false,
|
||||
"noFallthroughCasesInSwitch": false,
|
||||
"outDir": "./dist"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +1,12 @@
|
|||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.app.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.spec.json"
|
||||
}
|
||||
],
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "es2017",
|
||||
"sourceMap": true,
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"module": "commonjs",
|
||||
"types": ["jest", "node"]
|
||||
},
|
||||
"include": [
|
||||
"jest.config.ts",
|
||||
"src/**/*.test.ts",
|
||||
"src/**/*.spec.ts",
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
const { composePlugins, withNx } = require('@nx/webpack');
|
||||
|
||||
// Nx plugins for webpack.
|
||||
module.exports = composePlugins(
|
||||
withNx({
|
||||
target: 'node',
|
||||
}),
|
||||
(config) => {
|
||||
// Update the webpack config as needed here.
|
||||
// e.g. `config.plugins.push(new MyPlugin())`
|
||||
return config;
|
||||
}
|
||||
);
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"extends": ["../../.eslintrc.json"],
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.ts", "*.tsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
dist/
|
||||
node_modules/
|
||||
[._]*.s[a-v][a-z]
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-rt-v][a-z]
|
||||
[._]ss[a-gi-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
/* eslint-disable */
|
||||
export default {
|
||||
displayName: 'consumers',
|
||||
preset: '../../jest.preset.js',
|
||||
testEnvironment: 'node',
|
||||
transform: {
|
||||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
||||
},
|
||||
moduleFileExtensions: ['ts', 'js', 'html'],
|
||||
coverageDirectory: '../../coverage/apps/consumers',
|
||||
};
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/nest-cli",
|
||||
"collection": "@nestjs/schematics",
|
||||
"monorepo": false,
|
||||
"sourceRoot": "src",
|
||||
"entryFile": "../../dist/commands/apps/commands/src/main",
|
||||
"language": "ts",
|
||||
"generateOptions": {
|
||||
"spec": false
|
||||
},
|
||||
"compilerOptions": {
|
||||
"manualRestart": true,
|
||||
"tsConfigPath": "./tsconfig.build.json",
|
||||
"webpack": false,
|
||||
"deleteOutDir": true,
|
||||
"assets": [],
|
||||
"watchAssets": false,
|
||||
"plugins": []
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "postiz-command",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"dev": "dotenv -e ../../.env -- nest start --watch --entryFile=./apps/command/src/main",
|
||||
"build": "NODE_ENV=production nest build",
|
||||
"start": "node ./dist/apps/command/src/main.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
{
|
||||
"name": "commands",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "apps/commands/src",
|
||||
"projectType": "application",
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@nx/webpack:webpack",
|
||||
"outputs": ["{options.outputPath}"],
|
||||
"defaultConfiguration": "production",
|
||||
"options": {
|
||||
"target": "node",
|
||||
"compiler": "tsc",
|
||||
"outputPath": "dist/apps/commands",
|
||||
"main": "apps/commands/src/main.ts",
|
||||
"tsConfig": "apps/commands/tsconfig.app.json",
|
||||
"webpackConfig": "apps/commands/webpack.config.js"
|
||||
},
|
||||
"configurations": {
|
||||
"development": {},
|
||||
"production": {}
|
||||
}
|
||||
},
|
||||
"command": {
|
||||
"executor": "nx:run-commands",
|
||||
"defaultConfiguration": "development",
|
||||
"options": {
|
||||
"command": "cd dist/apps/commands && node main.js"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/linter:eslint",
|
||||
"outputs": ["{options.outputFile}"],
|
||||
"options": {
|
||||
"lintFilePatterns": ["apps/commands/**/*.ts"]
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nx/jest:jest",
|
||||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
||||
"options": {
|
||||
"jestConfig": "apps/commands/jest.config.ts",
|
||||
"passWithNoTests": true
|
||||
},
|
||||
"configurations": {
|
||||
"ci": {
|
||||
"ci": true,
|
||||
"codeCoverage": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"module": "commonjs",
|
||||
"types": ["node"],
|
||||
"emitDecoratorMetadata": true,
|
||||
"target": "es2021"
|
||||
},
|
||||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"],
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS",
|
||||
"resolveJsonModule": true,
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"incremental": true,
|
||||
"skipLibCheck": true,
|
||||
"strictNullChecks": false,
|
||||
"noImplicitAny": false,
|
||||
"strictBindCallApply": false,
|
||||
"forceConsistentCasingInFileNames": false,
|
||||
"noFallthroughCasesInSwitch": false,
|
||||
"outDir": "./dist"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,12 @@
|
|||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.app.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.spec.json"
|
||||
}
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "es2017",
|
||||
"sourceMap": true,
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"module": "commonjs",
|
||||
"types": ["jest", "node"]
|
||||
},
|
||||
"include": [
|
||||
"jest.config.ts",
|
||||
"src/**/*.test.ts",
|
||||
"src/**/*.spec.ts",
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
const { composePlugins, withNx } = require('@nx/webpack');
|
||||
|
||||
// Nx plugins for webpack.
|
||||
module.exports = composePlugins(
|
||||
withNx({
|
||||
target: 'node',
|
||||
}),
|
||||
(config) => {
|
||||
// Update the webpack config as needed here.
|
||||
// e.g. `config.plugins.push(new MyPlugin())`
|
||||
return config;
|
||||
}
|
||||
);
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"extends": ["../../.eslintrc.json"],
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.ts", "*.tsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
dist/
|
||||
node_modules/
|
||||
[._]*.s[a-v][a-z]
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-rt-v][a-z]
|
||||
[._]ss[a-gi-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
/* eslint-disable */
|
||||
export default {
|
||||
displayName: 'consumers',
|
||||
preset: '../../jest.preset.js',
|
||||
testEnvironment: 'node',
|
||||
transform: {
|
||||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
||||
},
|
||||
moduleFileExtensions: ['ts', 'js', 'html'],
|
||||
coverageDirectory: '../../coverage/apps/consumers',
|
||||
};
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/nest-cli",
|
||||
"collection": "@nestjs/schematics",
|
||||
"monorepo": false,
|
||||
"sourceRoot": "src",
|
||||
"entryFile": "../../dist/cron/apps/cron/src/main",
|
||||
"language": "ts",
|
||||
"generateOptions": {
|
||||
"spec": false
|
||||
},
|
||||
"compilerOptions": {
|
||||
"manualRestart": true,
|
||||
"tsConfigPath": "./tsconfig.build.json",
|
||||
"webpack": false,
|
||||
"deleteOutDir": true,
|
||||
"assets": [],
|
||||
"watchAssets": false,
|
||||
"plugins": []
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "postiz-cron",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"dev": "dotenv -e ../../.env -- nest start --watch --entryFile=./apps/cron/src/main",
|
||||
"build": "NODE_ENV=production nest build",
|
||||
"start": "dotenv -e ../../.env -- node ./dist/apps/cron/src/main.js",
|
||||
"pm2": "pm2 start pnpm --name cron -- start"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
{
|
||||
"name": "cron",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "apps/cron/src",
|
||||
"projectType": "application",
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@nx/webpack:webpack",
|
||||
"outputs": ["{options.outputPath}"],
|
||||
"defaultConfiguration": "production",
|
||||
"options": {
|
||||
"target": "node",
|
||||
"compiler": "tsc",
|
||||
"outputPath": "dist/apps/cron",
|
||||
"main": "apps/cron/src/main.ts",
|
||||
"tsConfig": "apps/cron/tsconfig.app.json",
|
||||
"webpackConfig": "apps/cron/webpack.config.js"
|
||||
},
|
||||
"configurations": {
|
||||
"development": {},
|
||||
"production": {}
|
||||
}
|
||||
},
|
||||
"serve": {
|
||||
"executor": "@nx/js:node",
|
||||
"defaultConfiguration": "development",
|
||||
"options": {
|
||||
"buildTarget": "cron:build"
|
||||
},
|
||||
"configurations": {
|
||||
"development": {
|
||||
"buildTarget": "cron:build:development"
|
||||
},
|
||||
"production": {
|
||||
"buildTarget": "cron:build:production"
|
||||
}
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/linter:eslint",
|
||||
"outputs": ["{options.outputFile}"],
|
||||
"options": {
|
||||
"lintFilePatterns": ["apps/cron/**/*.ts"]
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nx/jest:jest",
|
||||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
||||
"options": {
|
||||
"jestConfig": "apps/cron/jest.config.ts",
|
||||
"passWithNoTests": true
|
||||
},
|
||||
"configurations": {
|
||||
"ci": {
|
||||
"ci": true,
|
||||
"codeCoverage": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"module": "commonjs",
|
||||
"types": ["node"],
|
||||
"emitDecoratorMetadata": true,
|
||||
"target": "es2021"
|
||||
},
|
||||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"],
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS",
|
||||
"resolveJsonModule": true,
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"incremental": true,
|
||||
"skipLibCheck": true,
|
||||
"strictNullChecks": false,
|
||||
"noImplicitAny": false,
|
||||
"strictBindCallApply": false,
|
||||
"forceConsistentCasingInFileNames": false,
|
||||
"noFallthroughCasesInSwitch": false,
|
||||
"outDir": "./dist"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,12 @@
|
|||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.app.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.spec.json"
|
||||
}
|
||||
],
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"noLib": false,
|
||||
"target": "ES2021",
|
||||
"sourceMap": true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"module": "commonjs",
|
||||
"types": ["jest", "node"]
|
||||
},
|
||||
"include": [
|
||||
"jest.config.ts",
|
||||
"src/**/*.test.ts",
|
||||
"src/**/*.spec.ts",
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
const { composePlugins, withNx } = require('@nx/webpack');
|
||||
|
||||
// Nx plugins for webpack.
|
||||
module.exports = composePlugins(
|
||||
withNx({
|
||||
target: 'node',
|
||||
}),
|
||||
(config) => {
|
||||
// Update the webpack config as needed here.
|
||||
// e.g. `config.plugins.push(new MyPlugin())`
|
||||
return config;
|
||||
}
|
||||
);
|
||||
|
|
@ -0,0 +1,385 @@
|
|||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/webstorm+all,visualstudiocode,sublimetext,node,react,windows,macos,linux
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=webstorm+all,visualstudiocode,sublimetext,node,react,windows,macos,linux
|
||||
|
||||
### Linux ###
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
### macOS ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### macOS Patch ###
|
||||
# iCloud generated files
|
||||
*.icloud
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
### Node Patch ###
|
||||
# Serverless Webpack directories
|
||||
.webpack/
|
||||
|
||||
# Optional stylelint cache
|
||||
|
||||
# SvelteKit build / generate output
|
||||
.svelte-kit
|
||||
|
||||
### react ###
|
||||
.DS_*
|
||||
**/*.backup.*
|
||||
**/*.back.*
|
||||
|
||||
node_modules
|
||||
|
||||
*.sublime*
|
||||
|
||||
psd
|
||||
thumb
|
||||
sketch
|
||||
|
||||
### SublimeText ###
|
||||
# Cache files for Sublime Text
|
||||
*.tmlanguage.cache
|
||||
*.tmPreferences.cache
|
||||
*.stTheme.cache
|
||||
|
||||
# Workspace files are user-specific
|
||||
*.sublime-workspace
|
||||
|
||||
# Project files should be checked into the repository, unless a significant
|
||||
# proportion of contributors will probably not be using Sublime Text
|
||||
# *.sublime-project
|
||||
|
||||
# SFTP configuration file
|
||||
sftp-config.json
|
||||
sftp-config-alt*.json
|
||||
|
||||
# Package control specific files
|
||||
Package Control.last-run
|
||||
Package Control.ca-list
|
||||
Package Control.ca-bundle
|
||||
Package Control.system-ca-bundle
|
||||
Package Control.cache/
|
||||
Package Control.ca-certs/
|
||||
Package Control.merged-ca-bundle
|
||||
Package Control.user-ca-bundle
|
||||
oscrypto-ca-bundle.crt
|
||||
bh_unicode_properties.cache
|
||||
|
||||
# Sublime-github package stores a github token in this file
|
||||
# https://packagecontrol.io/packages/sublime-github
|
||||
GitHub.sublime-settings
|
||||
|
||||
### VisualStudioCode ###
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
### VisualStudioCode Patch ###
|
||||
# Ignore all local history of files
|
||||
.history
|
||||
.ionide
|
||||
|
||||
# Support for Project snippet scope
|
||||
|
||||
### WebStorm+all ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### WebStorm+all Patch ###
|
||||
# Ignore everything but code style settings and run configurations
|
||||
# that are supposed to be shared within teams.
|
||||
|
||||
.idea/*
|
||||
|
||||
!.idea/codeStyles
|
||||
!.idea/runConfigurations
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/webstorm+all,visualstudiocode,sublimetext,node,react,windows,macos,linux
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# etc
|
||||
.idea
|
||||
|
||||
#generated manifest
|
||||
public/manifest.json
|
||||
|
||||
extension.zip
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
import fs from 'fs';
|
||||
import { resolve } from 'path';
|
||||
import type { PluginOption } from 'vite';
|
||||
|
||||
// plugin to remove dev icons from prod build
|
||||
export function stripDevIcons (isDev: boolean) {
|
||||
if (isDev) return null
|
||||
|
||||
return {
|
||||
name: 'strip-dev-icons',
|
||||
resolveId (source: string) {
|
||||
return source === 'virtual-module' ? source : null
|
||||
},
|
||||
renderStart (outputOptions: any, inputOptions: any) {
|
||||
const outDir = outputOptions.dir
|
||||
fs.rm(resolve(outDir, 'dev-icon-32.png'), () => console.log(`Deleted dev-icon-32.png from prod build`))
|
||||
fs.rm(resolve(outDir, 'dev-icon-128.png'), () => console.log(`Deleted dev-icon-128.png from prod build`))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// plugin to support i18n
|
||||
export function crxI18n (options: { localize: boolean, src: string }): PluginOption {
|
||||
if (!options.localize) return null
|
||||
|
||||
const getJsonFiles = (dir: string): Array<string> => {
|
||||
const files = fs.readdirSync(dir, {recursive: true}) as string[]
|
||||
return files.filter(file => !!file && file.endsWith('.json'))
|
||||
}
|
||||
const entry = resolve(__dirname, options.src)
|
||||
const localeFiles = getJsonFiles(entry)
|
||||
const files = localeFiles.map(file => {
|
||||
return {
|
||||
id: '',
|
||||
fileName: file,
|
||||
source: fs.readFileSync(resolve(entry, file))
|
||||
}
|
||||
})
|
||||
return {
|
||||
name: 'crx-i18n',
|
||||
enforce: 'pre',
|
||||
buildStart: {
|
||||
order: 'post',
|
||||
handler() {
|
||||
files.forEach((file) => {
|
||||
const refId = this.emitFile({
|
||||
type: 'asset',
|
||||
source: file.source,
|
||||
fileName: '_locales/'+file.fileName
|
||||
})
|
||||
file.id = refId
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"action": {
|
||||
"default_icon": "public/dev-icon-32.png",
|
||||
"default_popup": "src/pages/popup/index.html"
|
||||
},
|
||||
"icons": {
|
||||
"128": "public/dev-icon-128.png"
|
||||
},
|
||||
"web_accessible_resources": [
|
||||
{
|
||||
"resources": [
|
||||
"contentStyle.css",
|
||||
"dev-icon-128.png",
|
||||
"dev-icon-32.png"
|
||||
],
|
||||
"matches": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"manifest_version": 3,
|
||||
"name": "Postiz",
|
||||
"description": "Your ultimate social media scheduling tool",
|
||||
"options_ui": {
|
||||
"page": "src/pages/options/index.html"
|
||||
},
|
||||
"action": {
|
||||
"default_popup": "src/pages/popup/index.html",
|
||||
"default_icon": {
|
||||
"32": "icon-32.png"
|
||||
}
|
||||
},
|
||||
"icons": {
|
||||
"128": "icon-128.png"
|
||||
},
|
||||
"permissions": ["activeTab", "cookies", "tabs"],
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["http://*/*", "https://*/*", "<all_urls>"],
|
||||
"js": ["src/pages/content/index.tsx"],
|
||||
"css": ["contentStyle.css"]
|
||||
}
|
||||
],
|
||||
"web_accessible_resources": [
|
||||
{
|
||||
"resources": ["contentStyle.css", "icon-128.png", "icon-32.png"],
|
||||
"matches": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"env": {
|
||||
"__DEV__": "true"
|
||||
},
|
||||
"watch": [
|
||||
"src",
|
||||
"utils",
|
||||
"vite.config.base.ts",
|
||||
"vite.config.chrome.ts",
|
||||
"manifest.json",
|
||||
"manifest.dev.json"
|
||||
],
|
||||
"ext": "tsx,css,html,ts,json",
|
||||
"ignore": [
|
||||
"src/**/*.spec.ts"
|
||||
],
|
||||
"exec": "vite build --config vite.config.chrome.ts --mode development"
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"env": {
|
||||
"__DEV__": "true"
|
||||
},
|
||||
"watch": [
|
||||
"src",
|
||||
"utils",
|
||||
"vite.config.base.ts",
|
||||
"vite.config.firefox.ts",
|
||||
"manifest.json",
|
||||
"manifest.dev.json"
|
||||
],
|
||||
"ext": "tsx,css,html,ts,json",
|
||||
"ignore": [
|
||||
"src/**/*.spec.ts"
|
||||
],
|
||||
"exec": "vite build --config vite.config.firefox.ts --mode development"
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "postiz-extension",
|
||||
"version": "1.0.3",
|
||||
"description": "A simple chrome & firefox extension template with Vite, React, TypeScript and Tailwind CSS.",
|
||||
"scripts": {
|
||||
"build": "rm -rf dist && vite build --config vite.config.chrome.ts && zip -r extension.zip dist",
|
||||
"build:chrome": "vite build --config vite.config.chrome.ts",
|
||||
"build:firefox": "vite build --config vite.config.firefox.ts",
|
||||
"dev": "rm -rf dist && dotenv -e ../../.env -- vite build --config vite.config.chrome.ts --mode development --watch",
|
||||
"dev:chrome": "nodemon --config nodemon.chrome.json",
|
||||
"dev:firefox": "nodemon --config nodemon.firefox.json"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
|
|
@ -0,0 +1,7 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
|
||||
<g fill="#61DAFB">
|
||||
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
|
||||
<circle cx="420.9" cy="296.5" r="45.7"/>
|
||||
<path d="M520.5 78.1z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
|
|
@ -0,0 +1,13 @@
|
|||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
@theme {
|
||||
--animate-spin-slow: spin 20s linear infinite;
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
declare module '*.svg' {
|
||||
import React = require('react');
|
||||
export const ReactComponent: React.SFC<React.SVGProps<SVGSVGElement>>;
|
||||
const src: string;
|
||||
export default src;
|
||||
}
|
||||
|
||||
declare module '*.json' {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"extName": {
|
||||
"message": "name in src/locales/en/messages.json",
|
||||
"description": "Extension name"
|
||||
},
|
||||
"extDescription": {
|
||||
"message": "description in src/locales/en/messages.json",
|
||||
"description": "Extension description"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
import { fetchRequestUtil } from "@gitroom/extension/utils/request.util";
|
||||
|
||||
const isDevelopment = process.env.NODE_ENV === "development";
|
||||
|
||||
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
|
||||
if (request.action === "makeHttpRequest") {
|
||||
fetchRequestUtil(request).then((response) => {
|
||||
sendResponse(response);
|
||||
});
|
||||
}
|
||||
|
||||
if (request.action === "loadStorage") {
|
||||
chrome.storage.local.get([request.key],
|
||||
function (storage) {
|
||||
sendResponse(storage[request.key]);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if (request.action === "saveStorage") {
|
||||
chrome.storage.local.set(
|
||||
{ [request.key]: request.value },
|
||||
function () {
|
||||
sendResponse({ success: true });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (request.action === "loadCookie") {
|
||||
chrome.cookies.get(
|
||||
{
|
||||
url: import.meta.env?.FRONTEND_URL || process?.env?.FRONTEND_URL,
|
||||
name: request.cookieName,
|
||||
},
|
||||
function (cookies) {
|
||||
sendResponse(cookies?.value);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
import { FC, memo, useCallback, useEffect, useState } from 'react';
|
||||
import { ProviderInterface } from '@gitroom/extension/providers/provider.interface';
|
||||
import { fetchCookie } from '@gitroom/extension/utils/load.cookie';
|
||||
|
||||
const Comp: FC<{ removeModal: () => void; platform: string; style: string }> = (
|
||||
props
|
||||
) => {
|
||||
const load = async () => {
|
||||
const cookie = await fetchCookie(`auth`);
|
||||
if (document.querySelector('iframe#modal-postiz')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const div = document.createElement('div');
|
||||
div.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
|
||||
div.style.position = 'fixed';
|
||||
div.style.top = '0';
|
||||
div.style.left = '0';
|
||||
div.style.zIndex = '9999';
|
||||
div.style.width = '100%';
|
||||
div.style.height = '100%';
|
||||
div.style.border = 'none';
|
||||
div.style.overflow = 'hidden';
|
||||
document.body.appendChild(div);
|
||||
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.style.backgroundColor = 'transparent';
|
||||
// @ts-ignore
|
||||
iframe.allowTransparency = 'true';
|
||||
iframe.src =
|
||||
(import.meta.env?.FRONTEND_URL || process?.env?.FRONTEND_URL) +
|
||||
`/modal/${props.style}/${props.platform}?loggedAuth=${cookie}`;
|
||||
iframe.id = 'modal-postiz';
|
||||
iframe.style.width = '100%';
|
||||
iframe.style.height = '100%';
|
||||
iframe.style.position = 'fixed';
|
||||
iframe.style.top = '0';
|
||||
iframe.style.left = '0';
|
||||
iframe.style.zIndex = '9999';
|
||||
iframe.style.border = 'none';
|
||||
div.appendChild(iframe);
|
||||
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event.data.action === 'closeIframe') {
|
||||
const iframe = document.querySelector('iframe#modal-postiz');
|
||||
if (iframe) {
|
||||
props.removeModal();
|
||||
div.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
useEffect(() => {
|
||||
load();
|
||||
}, []);
|
||||
return <></>;
|
||||
};
|
||||
export const ActionComponent: FC<{
|
||||
target: Node;
|
||||
keyIndex: number;
|
||||
actionType: string;
|
||||
provider: ProviderInterface;
|
||||
wrap: boolean;
|
||||
selector: string;
|
||||
}> = memo((props) => {
|
||||
const { wrap, provider, selector, target, actionType } = props;
|
||||
const [modal, showModal] = useState(false);
|
||||
const handle = useCallback(async (e: any) => {
|
||||
showModal(true);
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const blockingDiv = document.createElement('div');
|
||||
if (document.querySelector(`.${selector}`)) {
|
||||
console.log('already exists');
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
// @ts-ignore
|
||||
const targetInformation = target.getBoundingClientRect();
|
||||
blockingDiv.style.position = 'absolute';
|
||||
blockingDiv.id = 'blockingDiv';
|
||||
blockingDiv.style.cursor = 'pointer';
|
||||
blockingDiv.style.top = `${targetInformation.top}px`;
|
||||
blockingDiv.style.left = `${targetInformation.left}px`;
|
||||
blockingDiv.style.width = `${targetInformation.width}px`;
|
||||
blockingDiv.style.height = `${targetInformation.height}px`;
|
||||
blockingDiv.style.zIndex = '9999';
|
||||
blockingDiv.className = selector;
|
||||
|
||||
document.body.appendChild(blockingDiv);
|
||||
blockingDiv.addEventListener('click', handle);
|
||||
}, 1000);
|
||||
return () => {
|
||||
blockingDiv.removeEventListener('click', handle);
|
||||
blockingDiv.remove();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="g-wrapper" style={{ position: 'relative' }}>
|
||||
<div className="absolute left-0 top-0 z-[9999] w-full h-full" />
|
||||
{modal && (
|
||||
<Comp
|
||||
platform={provider.identifier}
|
||||
style={provider.style}
|
||||
removeModal={() => showModal(false)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import { createRoot } from "react-dom/client";
|
||||
import "./style.css";
|
||||
import { MainContent } from "@gitroom/extension/pages/content/main.content";
|
||||
const div = document.createElement("div");
|
||||
div.id = "__root";
|
||||
document.body.appendChild(div);
|
||||
|
||||
const rootContainer = document.querySelector("#__root");
|
||||
if (!rootContainer) throw new Error("Can't find Content root element");
|
||||
const root = createRoot(rootContainer);
|
||||
root.render(<MainContent />);
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
import {
|
||||
FC,
|
||||
Fragment,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { ProviderList } from '@gitroom/extension/providers/provider.list';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { ActionComponent } from '@gitroom/extension/pages/content/elements/action.component';
|
||||
|
||||
// Define a type to track elements with their action types
|
||||
interface ActionElement {
|
||||
element: HTMLElement;
|
||||
actionType: string;
|
||||
}
|
||||
|
||||
export const MainContent: FC = () => {
|
||||
return <MainContentInner />;
|
||||
};
|
||||
|
||||
export const MainContentInner: FC = (props) => {
|
||||
const [actionElements, setActionElements] = useState<ActionElement[]>([]);
|
||||
const actionSetRef = useRef(new Map<HTMLElement, string>());
|
||||
const provider = useMemo(() => {
|
||||
return ProviderList.find((p) => {
|
||||
return p.baseUrl.indexOf(new URL(window.location.href).hostname) > -1;
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!provider) return;
|
||||
|
||||
// Helper to scan DOM for existing matching elements
|
||||
const scanDOMForExistingMatches = () => {
|
||||
const action = { selector: provider.element, type: 'post' };
|
||||
const matches = document.querySelectorAll(action.selector);
|
||||
matches.forEach((match) => {
|
||||
const htmlMatch = match as HTMLElement;
|
||||
if (!actionSetRef.current.has(htmlMatch)) {
|
||||
actionSetRef.current.set(htmlMatch, action.type);
|
||||
}
|
||||
});
|
||||
|
||||
// Update state
|
||||
const elements: ActionElement[] = [];
|
||||
actionSetRef.current.forEach((actionType, element) => {
|
||||
elements.push({ element, actionType });
|
||||
});
|
||||
setActionElements(elements);
|
||||
};
|
||||
|
||||
// Initial scan before observing
|
||||
scanDOMForExistingMatches();
|
||||
|
||||
const observer = new MutationObserver((mutationsList) => {
|
||||
let addedSomething = false;
|
||||
let removedSomething = false;
|
||||
|
||||
for (const mutation of mutationsList) {
|
||||
if (mutation.type === 'childList') {
|
||||
for (const node of mutation.addedNodes) {
|
||||
if (node.nodeType === Node.ELEMENT_NODE) {
|
||||
const el = node as HTMLElement;
|
||||
|
||||
const action = { selector: provider.element, type: 'post' };
|
||||
if (
|
||||
el.matches?.(action.selector) &&
|
||||
!actionSetRef.current.has(el)
|
||||
) {
|
||||
actionSetRef.current.set(el, action.type);
|
||||
addedSomething = true;
|
||||
}
|
||||
|
||||
if (el.querySelectorAll) {
|
||||
const matches = el.querySelectorAll(action.selector);
|
||||
matches.forEach((match) => {
|
||||
const htmlMatch = match as HTMLElement;
|
||||
if (!actionSetRef.current.has(htmlMatch)) {
|
||||
actionSetRef.current.set(htmlMatch, action.type);
|
||||
addedSomething = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const node of mutation.removedNodes) {
|
||||
if (node.nodeType === Node.ELEMENT_NODE) {
|
||||
const el = node as HTMLElement;
|
||||
|
||||
if (actionSetRef.current.has(el)) {
|
||||
actionSetRef.current.delete(el);
|
||||
removedSomething = true;
|
||||
}
|
||||
|
||||
const action = { selector: provider.element, type: 'post' };
|
||||
if (el.querySelectorAll) {
|
||||
const matches = el.querySelectorAll(action.selector);
|
||||
matches.forEach((match) => {
|
||||
const htmlMatch = match as HTMLElement;
|
||||
if (actionSetRef.current.has(htmlMatch)) {
|
||||
actionSetRef.current.delete(htmlMatch);
|
||||
removedSomething = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mutation.type === 'attributes') {
|
||||
const el = mutation.target;
|
||||
if (el instanceof HTMLElement) {
|
||||
const action = { selector: provider.element, type: 'post' };
|
||||
const matchesNow = el.matches(action.selector);
|
||||
const wasTracked = actionSetRef.current.has(el);
|
||||
|
||||
if (matchesNow && !wasTracked) {
|
||||
actionSetRef.current.set(el, action.type);
|
||||
addedSomething = true;
|
||||
} else if (!matchesNow && wasTracked) {
|
||||
actionSetRef.current.delete(el);
|
||||
removedSomething = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addedSomething || removedSomething) {
|
||||
const elements: ActionElement[] = [];
|
||||
actionSetRef.current.forEach((actionType, element) => {
|
||||
elements.push({ element, actionType });
|
||||
});
|
||||
setActionElements(elements);
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
attributes: true,
|
||||
attributeOldValue: true,
|
||||
});
|
||||
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
|
||||
return actionElements.map((actionEl, index) => (
|
||||
<Fragment key={index}>
|
||||
{createPortal(
|
||||
<ActionComponent
|
||||
target={actionEl.element}
|
||||
keyIndex={index}
|
||||
actionType={actionEl.actionType}
|
||||
provider={provider}
|
||||
wrap={true}
|
||||
selector={stringToABC(provider.element.split(',').map(z => z.trim()).find(p => actionEl.element.matches(p)) || '')}
|
||||
/>,
|
||||
actionEl.element
|
||||
)}
|
||||
</Fragment>
|
||||
));
|
||||
};
|
||||
|
||||
function stringToABC(text: string, length = 8) {
|
||||
// Simple DJB2-like hash (non-cryptographic!)
|
||||
let hash = 5381;
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
hash = (hash * 33) ^ text.charCodeAt(i);
|
||||
}
|
||||
|
||||
hash = Math.abs(hash);
|
||||
|
||||
// Convert to base-26 string using a–z
|
||||
const alphabet = 'abcdefghijklmnopqrstuvwxyz';
|
||||
let result = '';
|
||||
while (result.length < length) {
|
||||
result = alphabet[hash % 26] + result;
|
||||
hash = Math.floor(hash / 26);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
.my-wrapper {
|
||||
left: 0 !important;
|
||||
top: 0 !important;
|
||||
position: fixed !important;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
z-index: 999999 !important;
|
||||
display: flex !important;
|
||||
justify-content: center !important;
|
||||
background: rgba(0, 0, 0, 0.5) !important;
|
||||
}
|
||||
|
||||
.my-wrapper > div {
|
||||
background: white !important;
|
||||
width: 600px !important;
|
||||
height: 300px !important;
|
||||
border-radius: 10px !important;
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
justify-items: center !important;
|
||||
margin-top: 100px !important;
|
||||
color: black !important;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
.container {
|
||||
width: 100%;
|
||||
height: 50vh;
|
||||
font-size: 2rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import React from 'react';
|
||||
import '@gitroom/extension/pages/options/Options.css';
|
||||
|
||||
export default function Options() {
|
||||
return <div className="container">Options</div>;
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Options</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="__root"></div>
|
||||
<script type="module" src="./index.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import React from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import '@gitroom/extension/pages/options/index.css';
|
||||
import Options from "@gitroom/extension/pages/options/Options";
|
||||
|
||||
function init() {
|
||||
const rootContainer = document.querySelector("#__root");
|
||||
if (!rootContainer) throw new Error("Can't find Options root element");
|
||||
const root = createRoot(rootContainer);
|
||||
root.render(<Options />);
|
||||
}
|
||||
|
||||
init();
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
body {
|
||||
background-color: #242424;
|
||||
}
|
||||
|
||||
.container {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import React from 'react';
|
||||
import '@pages/panel/Panel.css';
|
||||
|
||||
export default function Panel() {
|
||||
return (
|
||||
<div className="container">
|
||||
<h1>Side Panel</h1>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Devtools Panel</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="__root"></div>
|
||||
<script type="module" src="./index.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import React from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import Panel from '@pages/panel/Panel';
|
||||
import '@pages/panel/index.css';
|
||||
import '@assets/styles/tailwind.css';
|
||||
|
||||
function init() {
|
||||
const rootContainer = document.querySelector("#__root");
|
||||
if (!rootContainer) throw new Error("Can't find Panel root element");
|
||||
const root = createRoot(rootContainer);
|
||||
root.render(<Panel />);
|
||||
}
|
||||
|
||||
init();
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
import React, { FC, useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { ProviderList } from "@gitroom/extension/providers/provider.list";
|
||||
import { fetchCookie } from "@gitroom/extension/utils/load.cookie";
|
||||
|
||||
export const PopupContainerContainer: FC = () => {
|
||||
const [url, setUrl] = useState<string | null>(null);
|
||||
useEffect(() => {
|
||||
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
|
||||
setUrl(tabs[0]?.url);
|
||||
});
|
||||
}, []);
|
||||
|
||||
if (!url) {
|
||||
return <div className="text-4xl">This website is not supported by Postiz</div>;
|
||||
}
|
||||
|
||||
return <PopupContainer url={url} />;
|
||||
};
|
||||
|
||||
export const PopupContainer: FC<{ url: string }> = (props) => {
|
||||
const { url } = props;
|
||||
const [isLoggedIn, setIsLoggedIn] = useState<false | string>(false);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const provider = useMemo(() => {
|
||||
return ProviderList.find((p) => {
|
||||
return p.baseUrl.indexOf(new URL(url).hostname) > -1;
|
||||
});
|
||||
}, [url]);
|
||||
|
||||
const loadCookie = useCallback(async () => {
|
||||
try {
|
||||
if (!provider) {
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
const auth = await fetchCookie(`auth`);
|
||||
|
||||
if (auth) {
|
||||
setIsLoggedIn(auth);
|
||||
}
|
||||
|
||||
setIsLoading(false);
|
||||
} catch (e) {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
loadCookie();
|
||||
}, []);
|
||||
|
||||
if (isLoading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!provider) {
|
||||
return <div className="text-4xl">This website is not supported by Postiz</div>;
|
||||
}
|
||||
|
||||
if (!isLoggedIn) {
|
||||
return <div className="text-4xl">You are not logged in to Postiz</div>;
|
||||
}
|
||||
|
||||
return <div />;
|
||||
};
|
||||
|
||||
export default function Popup() {
|
||||
return (
|
||||
<div className="flex justify-center items-center h-screen">
|
||||
<PopupContainerContainer />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
body {
|
||||
width: 300px;
|
||||
height: 260px;
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
|
||||
position: relative;
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Popup</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="__root"></div>
|
||||
<script type="module" src="./index.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import React from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import './index.css';
|
||||
import '@gitroom/extension/assets/styles/tailwind.css';
|
||||
import Popup from "@gitroom/extension/pages/popup/Popup";
|
||||
|
||||
function init() {
|
||||
const rootContainer = document.querySelector("#__root");
|
||||
if (!rootContainer) throw new Error("Can't find Popup root element");
|
||||
const root = createRoot(rootContainer);
|
||||
root.render(<Popup />);
|
||||
}
|
||||
|
||||
init();
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
import { ProviderInterface } from "@gitroom/extension/providers/provider.interface";
|
||||
|
||||
export class LinkedinProvider implements ProviderInterface {
|
||||
identifier = "linkedin";
|
||||
baseUrl = "https://www.linkedin.com";
|
||||
element = `.share-box-feed-entry__closed-share-box`;
|
||||
attachTo = `[role="main"]`;
|
||||
style = "light" as "light";
|
||||
findIdentifier = (element: HTMLElement) => {
|
||||
return element.closest('[data-urn]').getAttribute("data-urn");
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
import { ProviderInterface } from '@gitroom/extension/providers/provider.interface';
|
||||
|
||||
export class XProvider implements ProviderInterface {
|
||||
identifier = 'x';
|
||||
baseUrl = 'https://x.com';
|
||||
element = `[data-testid="primaryColumn"]:has([data-testid="toolBar"]) [data-testid="tweetTextarea_0_label"], [data-testid="SideNav_NewTweet_Button"]`;
|
||||
attachTo = `#react-root`;
|
||||
style = "dark" as "dark";
|
||||
findIdentifier = (element: HTMLElement) => {
|
||||
return (
|
||||
Array.from(
|
||||
(
|
||||
element?.closest('article') ||
|
||||
element?.closest(`[aria-labelledby="modal-header"]`)
|
||||
)?.querySelectorAll('a') || []
|
||||
)
|
||||
?.find((p) => {
|
||||
return p?.getAttribute('href')?.includes('/status/');
|
||||
})
|
||||
?.getAttribute('href')
|
||||
?.split('/status/')?.[1] || window.location.href.split('/status/')?.[1]
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
export interface ProviderInterface {
|
||||
identifier: string;
|
||||
baseUrl: string;
|
||||
element: string;
|
||||
findIdentifier: (element: HTMLElement) => string;
|
||||
attachTo: string;
|
||||
style: 'dark' | 'light';
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import { XProvider } from './list/x.provider';
|
||||
import { ProviderInterface } from './provider.interface';
|
||||
import { LinkedinProvider } from './list/linkedin.provider';
|
||||
|
||||
export const ProviderList = [
|
||||
new XProvider(),
|
||||
new LinkedinProvider(),
|
||||
] satisfies ProviderInterface[] as ProviderInterface[];
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
export const fetchCookie = (cookieName: string) => {
|
||||
return chrome.runtime.sendMessage({
|
||||
action: "loadCookie",
|
||||
cookieName,
|
||||
});
|
||||
};
|
||||
|
||||
export const getCookie = async (
|
||||
cookies: chrome.cookies.Cookie[],
|
||||
cookie: string,
|
||||
) => {
|
||||
// return cookies.find((c) => c.name === cookie).value;
|
||||
};
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
export const fetchStorage = (key: string) => {
|
||||
return chrome.runtime.sendMessage({
|
||||
action: "loadStorage",
|
||||
key,
|
||||
});
|
||||
};
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
const isDev = process.env.NODE_ENV === "development";
|
||||
export const sendRequest = (
|
||||
auth: string,
|
||||
url: string,
|
||||
method: "GET" | "POST",
|
||||
body?: string,
|
||||
) => {
|
||||
return chrome.runtime.sendMessage({
|
||||
action: "makeHttpRequest",
|
||||
url,
|
||||
method,
|
||||
body,
|
||||
auth,
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchRequestUtil = async (request: any) => {
|
||||
return (
|
||||
await fetch(
|
||||
(import.meta.env?.FRONTEND_URL || process?.env?.FRONTEND_URL) + request.url,
|
||||
{
|
||||
method: request.method || "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: request.auth,
|
||||
// Add any auth headers here if needed
|
||||
},
|
||||
...(request.body ? { body: request.body } : {}),
|
||||
},
|
||||
)
|
||||
).json();
|
||||
};
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
export const saveStorage = (key: string, value: any) => {
|
||||
return chrome.runtime.sendMessage({
|
||||
action: "saveStorage",
|
||||
key,
|
||||
value,
|
||||
});
|
||||
};
|
||||
|
|
@ -0,0 +1 @@
|
|||
/// <reference types="vite/client" />
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"types": ["vite/client", "node", "chrome"],
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": false,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
},
|
||||
"include": [
|
||||
"src",
|
||||
"utils",
|
||||
"vite.config.base.ts",
|
||||
"vite.config.chrome.ts",
|
||||
"vite.config.firefox.ts"
|
||||
],
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
import react from "@vitejs/plugin-react";
|
||||
import { resolve } from "path";
|
||||
import { ManifestV3Export } from "@crxjs/vite-plugin";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { defineConfig, BuildOptions } from "vite";
|
||||
import tsconfigPaths from "vite-tsconfig-paths";
|
||||
import { stripDevIcons, crxI18n } from "./custom-vite-plugins";
|
||||
import manifest from "./manifest.json";
|
||||
import devManifest from "./manifest.dev.json";
|
||||
import pkg from "./package.json";
|
||||
import { ProviderList } from "./src/providers/provider.list";
|
||||
|
||||
const isDev = process.env.NODE_ENV === "development";
|
||||
// set this flag to true, if you want localization support
|
||||
const localize = false;
|
||||
|
||||
const merge = isDev ? devManifest : ({} as ManifestV3Export);
|
||||
const { matches, ...rest } = manifest?.content_scripts?.[0] || {};
|
||||
|
||||
export const baseManifest = {
|
||||
...manifest,
|
||||
host_permissions: [
|
||||
...ProviderList.map((p) => p.baseUrl + "/"),
|
||||
import.meta.env?.FRONTEND_URL || process?.env?.FRONTEND_URL + '/*',
|
||||
],
|
||||
permissions: [...(manifest.permissions || [])],
|
||||
content_scripts: [
|
||||
{
|
||||
matches: ProviderList.reduce(
|
||||
(all, p) => [...all, p.baseUrl + "/*"],
|
||||
[
|
||||
import.meta.env?.FRONTEND_URL || process?.env?.FRONTEND_URL + '/*',
|
||||
],
|
||||
),
|
||||
...rest,
|
||||
},
|
||||
],
|
||||
version: pkg.version,
|
||||
...merge,
|
||||
...(localize
|
||||
? {
|
||||
name: "__MSG_extName__",
|
||||
description: "__MSG_extDescription__",
|
||||
default_locale: "en",
|
||||
}
|
||||
: {}),
|
||||
} as ManifestV3Export;
|
||||
|
||||
export const baseBuildOptions: BuildOptions = {
|
||||
sourcemap: isDev,
|
||||
emptyOutDir: !isDev,
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
envPrefix: ["NEXT_PUBLIC_", "FRONTEND_URL"],
|
||||
plugins: [
|
||||
tailwindcss(),
|
||||
tsconfigPaths(),
|
||||
react(),
|
||||
stripDevIcons(isDev),
|
||||
crxI18n({ localize, src: "./src/locales" }),
|
||||
],
|
||||
publicDir: resolve(__dirname, "public"),
|
||||
});
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
import { resolve } from "path";
|
||||
import { mergeConfig, defineConfig } from "vite";
|
||||
import { crx, ManifestV3Export } from "@crxjs/vite-plugin";
|
||||
import baseConfig, { baseManifest, baseBuildOptions } from "./vite.config.base";
|
||||
import hotReloadExtension from "hot-reload-extension-vite";
|
||||
|
||||
const outDir = resolve(__dirname, "dist");
|
||||
const isDev = process.env.NODE_ENV === "development";
|
||||
|
||||
export default mergeConfig(
|
||||
baseConfig,
|
||||
defineConfig({
|
||||
plugins: [
|
||||
crx({
|
||||
manifest: {
|
||||
...baseManifest,
|
||||
background: {
|
||||
service_worker: "src/pages/background/index.ts",
|
||||
type: "module",
|
||||
},
|
||||
} as ManifestV3Export,
|
||||
browser: "chrome",
|
||||
contentScripts: {
|
||||
injectCss: true,
|
||||
},
|
||||
}),
|
||||
...(isDev
|
||||
? [
|
||||
hotReloadExtension({
|
||||
log: true,
|
||||
backgroundPath: "src/pages/background/index.ts",
|
||||
}),
|
||||
]
|
||||
: []),
|
||||
],
|
||||
build: {
|
||||
...baseBuildOptions,
|
||||
outDir,
|
||||
...(isDev
|
||||
? {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
entryFileNames: "assets/[name].js",
|
||||
chunkFileNames: "assets/[name].js",
|
||||
assetFileNames: "assets/[name][extname]",
|
||||
},
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
import { resolve } from 'path';
|
||||
import { mergeConfig, defineConfig } from 'vite';
|
||||
import { crx, ManifestV3Export } from '@crxjs/vite-plugin';
|
||||
import baseConfig, { baseManifest, baseBuildOptions } from './vite.config.base'
|
||||
|
||||
const outDir = resolve(__dirname, 'dist_firefox');
|
||||
|
||||
export default mergeConfig(
|
||||
baseConfig,
|
||||
defineConfig({
|
||||
plugins: [
|
||||
crx({
|
||||
manifest: {
|
||||
...baseManifest,
|
||||
background: {
|
||||
scripts: [ 'src/pages/background/index.ts' ]
|
||||
},
|
||||
} as ManifestV3Export,
|
||||
browser: 'firefox',
|
||||
contentScripts: {
|
||||
injectCss: true,
|
||||
}
|
||||
})
|
||||
],
|
||||
build: {
|
||||
...baseBuildOptions,
|
||||
outDir
|
||||
},
|
||||
publicDir: resolve(__dirname, 'public'),
|
||||
})
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue