Skip to content

Commit

Permalink
chore: add monorepo tools
Browse files Browse the repository at this point in the history
  • Loading branch information
forehalo committed Dec 18, 2024
1 parent e13f9d3 commit ad3f492
Show file tree
Hide file tree
Showing 65 changed files with 1,895 additions and 879 deletions.
7 changes: 0 additions & 7 deletions .env.template

This file was deleted.

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,9 @@ apps/web/next-routes.conf

packages/frontend/templates/edgeless
packages/frontend/core/public/static/templates

# new dist folder
tsbuild/
# script
af
affine
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export default tseslint.config(
},
},
{
files: ['packages/**/*.{ts,tsx}', 'tools/cli/**/*.{ts,tsx}'],
files: ['packages/**/*.{ts,tsx}', 'tools/**/*.ts'],
rules: {
'@typescript-eslint/no-floating-promises': [
'error',
Expand Down
5 changes: 3 additions & 2 deletions oxlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"correctness": "error",
"perf": "error"
},
"ignorePatterns": ["tools/cli/src/webpack/error-handler.js"],
"ignorePatterns": ["tools/scripts/src/webpack/error-handler.js"],
"rules": {
"import/named": "allow",
"no-await-in-loop": "allow",
Expand Down Expand Up @@ -167,7 +167,8 @@
"files": [
"*.{spec,test,e2e,stories}.{ts,tsx}",
"tests/**/*.ts",
"packages/backend/server/tests/**/*.ts"
"packages/backend/server/tests/**/*.ts",
"tools/**.*"
],
"rules": {
"typescript/no-non-null-assertion": "off",
Expand Down
17 changes: 7 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
"node": "<21.0.0"
},
"scripts": {
"dev": "yarn workspace @affine/cli dev",
"build": "yarn workspace @affine/cli bundle",
"dev:electron": "yarn workspace @affine/electron dev",
"build:electron": "yarn nx build @affine/electron",
"build:server-native": "yarn nx run-many -t build -p @affine/server-native",
"start:web-static": "yarn workspace @affine/web static-server",
"affine": "yarn workspace @affine-tools/scripts affine",
"af": "yarn workspace @affine-tools/scripts af",
"dev": "yarn affine dev",
"build": "yarn affine build",
"lint:eslint": "cross-env NODE_OPTIONS=\"--max-old-space-size=8192\" eslint --report-unused-disable-directives-severity=off . --cache",
"lint:eslint:fix": "yarn lint:eslint --fix",
"lint:prettier": "prettier --ignore-unknown --cache --check .",
Expand All @@ -33,9 +31,8 @@
"test": "vitest --run",
"test:ui": "vitest --ui",
"test:coverage": "vitest run --coverage",
"typecheck": "tsc -b tsconfig.json",
"postinstall": "node ./scripts/check-version.mjs && yarn workspace @affine/i18n i18n-codegen gen && yarn husky install",
"prepare": "husky"
"typecheck": "tsc -b tsconfig.project.json --verbose",
"postinstall": "yarn affine codegen && yarn husky"
},
"lint-staged": {
"*": "prettier --write --ignore-unknown --cache",
Expand All @@ -51,7 +48,7 @@
]
},
"devDependencies": {
"@affine/cli": "workspace:*",
"@affine-tools/scripts": "workspace:*",
"@capacitor/cli": "^6.2.0",
"@eslint/js": "^9.16.0",
"@faker-js/faker": "^9.3.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"tailwindcss-animate": "^1.0.7"
},
"scripts": {
"build": "cross-env DISTRIBUTION=admin yarn workspace @affine/cli bundle",
"build": "affine bundle",
"dev": "affine bundle --dev",
"update-shadcn": "shadcn-ui add -p src/components/ui"
},
"exports": {
Expand Down
5 changes: 2 additions & 3 deletions packages/frontend/apps/android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"private": true,
"browser": "src/index.tsx",
"scripts": {
"build": "cross-env DISTRIBUTION=android yarn workspace @affine/cli bundle",
"dev": "yarn workspace @affine/cli dev",
"static-server": "cross-env DISTRIBUTION=android yarn workspace @affine/cli dev --static"
"build": "affine bundle",
"dev": "affine bundle --dev"
},
"dependencies": {
"@affine/component": "workspace:*",
Expand Down
19 changes: 10 additions & 9 deletions packages/frontend/apps/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@
"homepage": "https://github.com/toeverything/AFFiNE",
"scripts": {
"start": "electron .",
"dev": "DEV_SERVER_URL=http://localhost:8080 node --loader ts-node/esm/transpile-only ./scripts/dev.ts",
"dev:prod": "yarn node --loader ts-node/esm/transpile-only scripts/dev.ts",
"build": "NODE_ENV=production node --loader ts-node/esm/transpile-only scripts/build-layers.ts",
"build:dev": "NODE_ENV=development node --loader ts-node/esm/transpile-only scripts/build-layers.ts",
"generate-assets": "node --loader ts-node/esm/transpile-only scripts/generate-assets.ts",
"package": "cross-env NODE_OPTIONS=\"--loader ts-node/esm/transpile-only\" electron-forge package",
"make": "cross-env NODE_OPTIONS=\"--loader ts-node/esm/transpile-only\" electron-forge make",
"make-squirrel": "node --loader ts-node/esm/transpile-only scripts/make-squirrel.ts",
"make-nsis": "node --loader ts-node/esm/transpile-only scripts/make-nsis.ts"
"dev": "cross-env DEV_SERVER_URL=http://localhost:8080 node ./scripts/dev.ts",
"dev:prod": "node ./scripts/dev.ts",
"build": "cross-env NODE_ENV=production node ./scripts/build-layers.ts",
"build:dev": "node ./scripts/build-layers.ts",
"generate-assets": "node ./scripts/generate-assets.ts",
"package": "electron-forge package",
"make": "electron-forge make",
"make-squirrel": "node ./scripts/make-squirrel.ts",
"make-nsis": "node ./scripts/make-nsis.ts"
},
"main": "./dist/main.js",
"devDependencies": {
"@affine-test/kit": "workspace:*",
"@affine-tools/utils": "workspace:*",
"@affine/component": "workspace:*",
"@affine/core": "workspace:*",
"@affine/electron-api": "workspace:*",
Expand Down
10 changes: 4 additions & 6 deletions packages/frontend/apps/electron/scripts/common.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { getBuildConfig } from '@affine/cli/src/webpack/runtime-config';
import { getBuildConfig } from '@affine-tools/utils/build-config';
import { Workspace } from '@affine-tools/utils/workspace';
import { sentryEsbuildPlugin } from '@sentry/esbuild-plugin';
import type { BuildOptions, Plugin } from 'esbuild';

Expand All @@ -24,12 +24,10 @@ export const config = (): BuildOptions => {
'process.env.NODE_ENV': process.env.NODE_ENV,
REPLACE_ME_BUILD_ENV: process.env.BUILD_TYPE ?? 'stable',
...Object.entries(
getBuildConfig({
channel: (process.env.BUILD_TYPE as any) ?? 'canary',
distribution: 'desktop',
getBuildConfig(new Workspace().getPackage('@affine/electron'), {
mode:
process.env.NODE_ENV === 'production' ? 'production' : 'development',
static: false,
channel: (process.env.BUILD_TYPE as any) ?? 'canary',
})
).reduce(
(def, [key, val]) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/apps/electron/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
},
{
"path": "../../../../tests/kit"
},
{
"path": "../../../../tools/utils"
}
],
"ts-node": {
Expand Down
9 changes: 7 additions & 2 deletions packages/frontend/apps/electron/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"target": "ESNext",
"module": "ESNext",
"resolveJsonModule": true,
"moduleResolution": "Node",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"noEmit": false,
"outDir": "./lib/scripts",
Expand All @@ -17,5 +17,10 @@
"ts-node": {
"esm": true,
"experimentalSpecifierResolution": "node"
}
},
"references": [
{
"path": "../../../../tools/utils"
}
]
}
7 changes: 3 additions & 4 deletions packages/frontend/apps/ios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
"private": true,
"browser": "src/index.tsx",
"scripts": {
"build": "cross-env DISTRIBUTION=ios yarn workspace @affine/cli bundle",
"dev": "yarn workspace @affine/cli dev",
"build": "affine bundle",
"dev": "affine bundle --dev",
"sync": "yarn cap sync",
"sync:dev": "CAP_SERVER_URL=http://localhost:8080 yarn cap sync",
"static-server": "cross-env DISTRIBUTION=ios yarn workspace @affine/cli dev --static"
"sync:dev": "CAP_SERVER_URL=http://localhost:8080 yarn cap sync"
},
"dependencies": {
"@affine/component": "workspace:*",
Expand Down
5 changes: 2 additions & 3 deletions packages/frontend/apps/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"private": true,
"browser": "src/index.tsx",
"scripts": {
"build": "cross-env DISTRIBUTION=mobile yarn workspace @affine/cli bundle",
"dev": "yarn workspace @affine/cli dev",
"static-server": "cross-env DISTRIBUTION=mobile yarn workspace @affine/cli dev --static"
"build": "affine bundle",
"dev": "affine bundle --dev"
},
"dependencies": {
"@affine/component": "workspace:*",
Expand Down
5 changes: 2 additions & 3 deletions packages/frontend/apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"private": true,
"browser": "src/index.tsx",
"scripts": {
"build": "cross-env DISTRIBUTION=web yarn workspace @affine/cli bundle",
"dev": "yarn workspace @affine/cli dev",
"static-server": "yarn workspace @affine/cli dev --static"
"build": "affine bundle",
"dev": "affine bundle --dev"
},
"dependencies": {
"@affine/component": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/component/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StorybookConfig } from '@storybook/react-vite';
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
import swc from 'unplugin-swc';
import { mergeConfig } from 'vite';
import { getBuildConfig } from '@affine/cli/src/webpack/runtime-config';
import { getBuildConfig } from '@affine-tools/scripts/src/webpack/runtime-config';

export default {
stories: ['../src/ui/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'],
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"react-dom": "^19.0.0"
},
"dependencies": {
"@affine/cli": "workspace:*",
"@affine-tools/scripts": "workspace:*",
"@affine/debug": "workspace:*",
"@affine/electron-api": "workspace:*",
"@affine/graphql": "workspace:*",
Expand Down
3 changes: 0 additions & 3 deletions packages/frontend/core/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
},
"include": [".webpack/*.ts"],
"references": [
{
"path": "../../../tools/cli"
},
{
"path": "../../common/env"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"vitest": "2.1.8"
},
"scripts": {
"postinstall": "gql-gen --errors-only"
"build": "gql-gen --errors-only"
},
"dependencies": {
"@affine/env": "workspace:*",
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"sideEffect": false,
"version": "0.18.0",
"scripts": {
"postinstall": "node ./build-edgeless.mjs && node ./build-stickers.mjs"
"build": "node ./build-edgeless.mjs && node ./build-stickers.mjs",
"postinstall": "yarn build"
},
"type": "module",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup/global.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getBuildConfig } from '@affine/cli/src/webpack/runtime-config';
import { setupGlobal } from '@affine/env/global';
import { getBuildConfig } from '@affine-tools/scripts/src/webpack/runtime-config';

globalThis.BUILD_CONFIG = getBuildConfig({
distribution: 'web',
Expand Down
66 changes: 0 additions & 66 deletions tools/cli/src/bin/build.ts

This file was deleted.

Loading

0 comments on commit ad3f492

Please sign in to comment.