feat: init package cli (#1646)

This commit is contained in:
Himself65 2023-03-21 17:39:13 -05:00 committed by GitHub
parent 33320bd38e
commit a8540cceae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 125 additions and 2 deletions

View File

@ -14,6 +14,7 @@
"@affine/debug": "workspace:*",
"@affine/env": "workspace:*",
"@affine/i18n": "workspace:*",
"@affine/templates": "workspace:*",
"@blocksuite/blocks": "0.5.0-20230320164115-e612d17",
"@blocksuite/editor": "0.5.0-20230320164115-e612d17",
"@blocksuite/icons": "2.0.23",

View File

@ -9,7 +9,7 @@
"packages/*"
],
"scripts": {
"dev": "yarn workspace @affine/app dev",
"dev": "dev-web",
"dev:ac": "NODE_API_SERVER=ac yarn workspace @affine/app dev",
"dev:local": "NODE_API_SERVER=local yarn workspace @affine/app dev",
"dev:app": "yarn workspace @affine/electron dev:app",
@ -34,6 +34,7 @@
"*.{ts,tsx,js,jsx}": "eslint --cache --fix"
},
"devDependencies": {
"@affine/cli": "workspace:*",
"@perfsee/sdk": "^1.5.1",
"@playwright/test": "^1.31.2",
"@testing-library/react": "^14.0.0",

15
packages/cli/package.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "@affine/cli",
"type": "module",
"private": true,
"bin": {
"dev-web": "./src/dev.mjs"
},
"scripts": {
"start": "node ./src/dev.mjs"
},
"devDependencies": {
"@clack/core": "^0.3.2",
"@clack/prompts": "^0.6.3"
}
}

58
packages/cli/src/dev.mjs Normal file
View File

@ -0,0 +1,58 @@
#!/usr/bin/env node
import { spawn } from 'node:child_process';
import * as path from 'node:path';
import { fileURLToPath } from 'node:url';
import * as p from '@clack/prompts';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const dev = await p.group(
{
server: () =>
p.select({
message: `Select dev server`,
initialValue: 'local',
options: [
{
value: 'local',
label: 'local - 127.0.0.1:3000',
hint: 'recommend',
},
{ value: 'dev', label: 'dev - 100.84.105.99:11001' },
{
value: 'ac',
label: 'ac - 100.85.73.88:12001',
},
{
value: 'test',
label: 'test - 100.84.105.99:11001',
},
],
}),
},
{
onCancel: () => {
p.cancel('Operation cancelled.');
process.exit(0);
},
}
);
if (dev.server === 'local') {
console.log('You might need setup OctoBase dev server first.');
}
const env = {
NODE_API_SERVER: dev.server,
};
const cwd = path.resolve(__dirname, '..', '..', '..', 'apps', 'web');
const process = spawn('yarn', ['dev'], {
env,
cwd,
stdio: 'inherit',
shell: true,
});

View File

@ -50,6 +50,12 @@
},
{
"path": "./packages/env"
},
{
"path": "./packages/debug"
},
{
"path": "./packages/cli"
}
],
"files": [],

View File

@ -21,6 +21,7 @@ __metadata:
"@affine/debug": "workspace:*"
"@affine/env": "workspace:*"
"@affine/i18n": "workspace:*"
"@affine/templates": "workspace:*"
"@blocksuite/blocks": 0.5.0-20230320164115-e612d17
"@blocksuite/editor": 0.5.0-20230320164115-e612d17
"@blocksuite/icons": 2.0.23
@ -66,6 +67,17 @@ __metadata:
languageName: unknown
linkType: soft
"@affine/cli@workspace:*, @affine/cli@workspace:packages/cli":
version: 0.0.0-use.local
resolution: "@affine/cli@workspace:packages/cli"
dependencies:
"@clack/core": ^0.3.2
"@clack/prompts": ^0.6.3
bin:
dev-web: ./src/dev.mjs
languageName: unknown
linkType: soft
"@affine/client-app@workspace:apps/desktop":
version: 0.0.0-use.local
resolution: "@affine/client-app@workspace:apps/desktop"
@ -229,7 +241,7 @@ __metadata:
languageName: unknown
linkType: soft
"@affine/templates@workspace:packages/templates":
"@affine/templates@workspace:*, @affine/templates@workspace:packages/templates":
version: 0.0.0-use.local
resolution: "@affine/templates@workspace:packages/templates"
languageName: unknown
@ -1850,6 +1862,28 @@ __metadata:
languageName: node
linkType: hard
"@clack/core@npm:^0.3.2":
version: 0.3.2
resolution: "@clack/core@npm:0.3.2"
dependencies:
picocolors: ^1.0.0
sisteransi: ^1.0.5
checksum: a4b6708d47b9df9d2899f5ec60e34b4ae7831e951da136dadb690ccc8d21ba5c8465e24fb6d9c2c510ef388774d509dcf44f3d5ff9a1c28b9474a541ac07efce
languageName: node
linkType: hard
"@clack/prompts@npm:^0.6.3":
version: 0.6.3
resolution: "@clack/prompts@npm:0.6.3"
dependencies:
"@clack/core": ^0.3.2
is-unicode-supported: "*"
picocolors: ^1.0.0
sisteransi: ^1.0.5
checksum: 6943e46b4c37c62ca7734459f68b60f819db0c3da6dfdfacfadbf8f4abefc22b177884469c6f2b6a2906ac2d03baff59b72fc9c0802f34255e29ab541111e6d9
languageName: node
linkType: hard
"@colors/colors@npm:1.5.0":
version: 1.5.0
resolution: "@colors/colors@npm:1.5.0"
@ -7350,6 +7384,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "AFFiNE@workspace:."
dependencies:
"@affine/cli": "workspace:*"
"@perfsee/sdk": ^1.5.1
"@playwright/test": ^1.31.2
"@testing-library/react": ^14.0.0
@ -13225,6 +13260,13 @@ __metadata:
languageName: node
linkType: hard
"is-unicode-supported@npm:*":
version: 1.3.0
resolution: "is-unicode-supported@npm:1.3.0"
checksum: 20a1fc161afafaf49243551a5ac33b6c4cf0bbcce369fcd8f2951fbdd000c30698ce320de3ee6830497310a8f41880f8066d440aa3eb0a853e2aa4836dd89abc
languageName: node
linkType: hard
"is-unicode-supported@npm:^0.1.0":
version: 0.1.0
resolution: "is-unicode-supported@npm:0.1.0"