@coze-arch/cli 0.0.14 → 0.0.15-alpha.0f8aee

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,9 @@ cd "${COZE_WORKSPACE_PATH}"
7
7
 
8
8
  echo "Installing dependencies..."
9
9
  pnpm install --prefer-frozen-lockfile --prefer-offline
10
+ if command -v coze > /dev/null 2>&1 && coze check-bins --help > /dev/null 2>&1; then
11
+ coze check-bins --fix
12
+ fi
10
13
 
11
14
  echo "Preparing Nuxt project..."
12
15
  pnpm exec nuxt prepare
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
5
+
6
+ cd "${COZE_WORKSPACE_PATH}"
7
+
8
+ echo "🔍 Running validate..."
9
+ pnpm validate
10
+ echo "✅ Validate passed!"
@@ -7,6 +7,7 @@ build = ["bash", ".cozeproj/scripts/dev_build.sh"]
7
7
  run = ["bash", ".cozeproj/scripts/dev_run.sh"]
8
8
  deps = ["git"] # -> apt install git
9
9
  pack = ["bash", ".cozeproj/scripts/pack.sh"]
10
+ validate = ["bash", ".cozeproj/scripts/validate.sh"]
10
11
 
11
12
  [deploy]
12
13
  build = ["bash", ".cozeproj/scripts/deploy_build.sh"]
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ cd "${COZE_WORKSPACE_PATH}"
5
+
6
+ echo "🔍 Running validate..."
7
+ pnpm validate
8
+ echo "✅ Validate passed!"
@@ -19,7 +19,7 @@
19
19
  "postinstall": "weapp-tw patch",
20
20
  "kill:all": "pkill -9 -f 'concurrently' 2>/dev/null || true; pkill -9 -f 'nest start' 2>/dev/null || true; pkill -9 -f 'taro build' 2>/dev/null || true; pkill -9 -f 'node.*dev' 2>/dev/null || true; echo 'All dev processes cleaned'",
21
21
  "lint": "eslint \"src/**/*.{js,jsx,ts,tsx,css}\"",
22
- "lint:build": "eslint \"src/**/*.{js,jsx,ts,tsx,css}\" --max-warnings=0",
22
+ "lint:build": "eslint \"src/**/*.{js,jsx,ts,tsx,css}\" --max-warnings=0 --quiet",
23
23
  "lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx,css}\" --fix",
24
24
  "new": "taro new",
25
25
  "preview:tt": "taro build --type tt --preview",
@@ -197,9 +197,6 @@ importers:
197
197
  '@supabase/supabase-js':
198
198
  specifier: 2.95.3
199
199
  version: 2.95.3
200
- better-sqlite3:
201
- specifier: ^11.9.1
202
- version: 11.10.0
203
200
  coze-coding-dev-sdk:
204
201
  specifier: ^0.7.16
205
202
  version: 0.7.16(openai@6.16.0(ws@8.19.0)(zod@4.3.5))(ws@8.19.0)
@@ -234,9 +231,6 @@ importers:
234
231
  '@nestjs/schematics':
235
232
  specifier: ^10.2.3
236
233
  version: 10.2.3(chokidar@3.6.0)(typescript@5.9.3)
237
- '@types/better-sqlite3':
238
- specifier: ^7.6.13
239
- version: 7.6.13
240
234
  '@types/express':
241
235
  specifier: 5.0.6
242
236
  version: 5.0.6
@@ -15586,6 +15580,7 @@ snapshots:
15586
15580
  '@types/better-sqlite3@7.6.13':
15587
15581
  dependencies:
15588
15582
  '@types/node': 22.19.6
15583
+ optional: true
15589
15584
 
15590
15585
  '@types/body-parser@1.19.6':
15591
15586
  dependencies:
@@ -16921,6 +16916,7 @@ snapshots:
16921
16916
  dependencies:
16922
16917
  bindings: 1.5.0
16923
16918
  prebuild-install: 7.1.3
16919
+ optional: true
16924
16920
 
16925
16921
  big-integer@1.6.52: {}
16926
16922
 
@@ -16936,6 +16932,7 @@ snapshots:
16936
16932
  bindings@1.5.0:
16937
16933
  dependencies:
16938
16934
  file-uri-to-path: 1.0.0
16935
+ optional: true
16939
16936
 
16940
16937
  bl@1.2.3:
16941
16938
  dependencies:
@@ -17239,7 +17236,8 @@ snapshots:
17239
17236
  dependencies:
17240
17237
  readdirp: 5.0.0
17241
17238
 
17242
- chownr@1.1.4: {}
17239
+ chownr@1.1.4:
17240
+ optional: true
17243
17241
 
17244
17242
  chroma-js@2.6.0: {}
17245
17243
 
@@ -17735,6 +17733,7 @@ snapshots:
17735
17733
  decompress-response@6.0.0:
17736
17734
  dependencies:
17737
17735
  mimic-response: 3.1.0
17736
+ optional: true
17738
17737
 
17739
17738
  decompress-tar@4.1.1:
17740
17739
  dependencies:
@@ -18491,7 +18490,8 @@ snapshots:
18491
18490
 
18492
18491
  exif-parser@0.1.12: {}
18493
18492
 
18494
- expand-template@2.0.3: {}
18493
+ expand-template@2.0.3:
18494
+ optional: true
18495
18495
 
18496
18496
  express@4.21.2:
18497
18497
  dependencies:
@@ -18679,7 +18679,8 @@ snapshots:
18679
18679
 
18680
18680
  file-type@8.1.0: {}
18681
18681
 
18682
- file-uri-to-path@1.0.0: {}
18682
+ file-uri-to-path@1.0.0:
18683
+ optional: true
18683
18684
 
18684
18685
  filename-reserved-regex@2.0.0: {}
18685
18686
 
@@ -18963,7 +18964,8 @@ snapshots:
18963
18964
 
18964
18965
  git-clone@0.1.0: {}
18965
18966
 
18966
- github-from-package@0.0.0: {}
18967
+ github-from-package@0.0.0:
18968
+ optional: true
18967
18969
 
18968
18970
  glob-parent@5.1.2:
18969
18971
  dependencies:
@@ -20214,7 +20216,8 @@ snapshots:
20214
20216
 
20215
20217
  mimic-response@1.0.1: {}
20216
20218
 
20217
- mimic-response@3.1.0: {}
20219
+ mimic-response@3.1.0:
20220
+ optional: true
20218
20221
 
20219
20222
  min-document@2.19.2:
20220
20223
  dependencies:
@@ -20446,7 +20449,8 @@ snapshots:
20446
20449
 
20447
20450
  mkdir-p@0.0.7: {}
20448
20451
 
20449
- mkdirp-classic@0.5.3: {}
20452
+ mkdirp-classic@0.5.3:
20453
+ optional: true
20450
20454
 
20451
20455
  mkdirp@0.5.6:
20452
20456
  dependencies:
@@ -20503,7 +20507,8 @@ snapshots:
20503
20507
 
20504
20508
  nanoid@3.3.11: {}
20505
20509
 
20506
- napi-build-utils@2.0.0: {}
20510
+ napi-build-utils@2.0.0:
20511
+ optional: true
20507
20512
 
20508
20513
  natural-compare@1.4.0: {}
20509
20514
 
@@ -20545,6 +20550,7 @@ snapshots:
20545
20550
  node-abi@3.87.0:
20546
20551
  dependencies:
20547
20552
  semver: 7.7.4
20553
+ optional: true
20548
20554
 
20549
20555
  node-abort-controller@3.1.1: {}
20550
20556
 
@@ -21505,6 +21511,7 @@ snapshots:
21505
21511
  simple-get: 4.0.1
21506
21512
  tar-fs: 2.1.4
21507
21513
  tunnel-agent: 0.6.0
21514
+ optional: true
21508
21515
 
21509
21516
  prelude-ls@1.2.1: {}
21510
21517
 
@@ -22232,13 +22239,15 @@ snapshots:
22232
22239
 
22233
22240
  signal-exit@4.1.0: {}
22234
22241
 
22235
- simple-concat@1.0.1: {}
22242
+ simple-concat@1.0.1:
22243
+ optional: true
22236
22244
 
22237
22245
  simple-get@4.0.1:
22238
22246
  dependencies:
22239
22247
  decompress-response: 6.0.0
22240
22248
  once: 1.4.0
22241
22249
  simple-concat: 1.0.1
22250
+ optional: true
22242
22251
 
22243
22252
  simple-plist@1.3.1:
22244
22253
  dependencies:
@@ -22650,6 +22659,7 @@ snapshots:
22650
22659
  mkdirp-classic: 0.5.3
22651
22660
  pump: 3.0.3
22652
22661
  tar-stream: 2.2.0
22662
+ optional: true
22653
22663
 
22654
22664
  tar-stream@1.6.2:
22655
22665
  dependencies:
@@ -17,7 +17,6 @@
17
17
  "@nestjs/core": "^10.4.15",
18
18
  "@nestjs/platform-express": "^10.4.15",
19
19
  "@supabase/supabase-js": "2.95.3",
20
- "better-sqlite3": "^11.9.1",
21
20
  "coze-coding-dev-sdk": "^0.7.16",
22
21
  "dotenv": "^17.2.3",
23
22
  "drizzle-kit": "^0.31.8",
@@ -31,7 +30,6 @@
31
30
  "devDependencies": {
32
31
  "@nestjs/cli": "^10.4.9",
33
32
  "@nestjs/schematics": "^10.2.3",
34
- "@types/better-sqlite3": "^7.6.13",
35
33
  "@types/express": "5.0.6",
36
34
  "@types/node": "^22.10.2",
37
35
  "drizzle-kit": "^0.31.8",
@@ -4,6 +4,7 @@ requires = ["nodejs-24"]
4
4
  [dev]
5
5
  build = ["bash", "./scripts/prepare.sh"]
6
6
  run = ["bash", "./scripts/dev.sh"]
7
+ validate = ["bash", "./scripts/validate.sh"]
7
8
  deps = ["git"] # -> apt install git
8
9
 
9
10
  [deploy]
@@ -7,8 +7,10 @@
7
7
  "dev": "bash ./scripts/dev.sh",
8
8
  "preinstall": "npx only-allow pnpm",
9
9
  "lint": "eslint",
10
+ "lint:build": "eslint . --quiet",
10
11
  "start": "bash ./scripts/start.sh",
11
- "ts-check": "tsc -p tsconfig.json"
12
+ "ts-check": "tsc -p tsconfig.json",
13
+ "validate": "pnpm run --parallel '/^(ts-check|lint:build)$/'"
12
14
  },
13
15
  "dependencies": {
14
16
  "@supabase/supabase-js": "2.95.3",
@@ -7,3 +7,6 @@ cd "${COZE_WORKSPACE_PATH}"
7
7
 
8
8
  echo "Installing dependencies..."
9
9
  pnpm install --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
10
+ if command -v coze > /dev/null 2>&1 && coze check-bins --help > /dev/null 2>&1; then
11
+ coze check-bins --fix
12
+ fi
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
5
+
6
+ cd "${COZE_WORKSPACE_PATH}"
7
+
8
+ echo "🔍 Running validate..."
9
+ pnpm validate
10
+ echo "✅ Validate passed!"
package/lib/cli.js CHANGED
@@ -2107,7 +2107,7 @@ const EventBuilder = {
2107
2107
  };
2108
2108
 
2109
2109
  var name = "@coze-arch/cli";
2110
- var version = "0.0.14";
2110
+ var version = "0.0.15-alpha.0f8aee";
2111
2111
  var description = "coze coding devtools cli";
2112
2112
  var license = "MIT";
2113
2113
  var author = "fanwenjie.fe@bytedance.com";
@@ -2839,7 +2839,7 @@ const executeWarmup = async (options) => {
2839
2839
  /**
2840
2840
  * 注册 warmup 命令到 program
2841
2841
  */
2842
- const registerCommand$5 = program => {
2842
+ const registerCommand$6 = program => {
2843
2843
  program
2844
2844
  .command('warmup')
2845
2845
  .description('Pre-install dependencies for templates to speed up init')
@@ -3251,7 +3251,7 @@ const executeUpdate = (
3251
3251
  /**
3252
3252
  * 注册 update 命令到 program
3253
3253
  */
3254
- const registerCommand$4 = program => {
3254
+ const registerCommand$5 = program => {
3255
3255
  program
3256
3256
  .command('update <package>')
3257
3257
  .description('Update a package dependency')
@@ -5985,7 +5985,6 @@ const getCommandConfig = (
5985
5985
  ) => {
5986
5986
  let commandConfig;
5987
5987
 
5988
- // 根据命令名称映射到配置路径
5989
5988
  switch (commandName) {
5990
5989
  case 'dev':
5991
5990
  commandConfig = _optionalChain$4([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
@@ -5996,6 +5995,9 @@ const getCommandConfig = (
5996
5995
  case 'start':
5997
5996
  commandConfig = _optionalChain$4([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
5998
5997
  break;
5998
+ case 'validate':
5999
+ commandConfig = _optionalChain$4([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
6000
+ break;
5999
6001
  default:
6000
6002
  throw new Error(`Unknown command: ${commandName}`);
6001
6003
  }
@@ -6802,7 +6804,7 @@ const executePatch = async (
6802
6804
  }
6803
6805
  };
6804
6806
 
6805
- const registerCommand$3 = program => {
6807
+ const registerCommand$4 = program => {
6806
6808
  program
6807
6809
  .command('patch')
6808
6810
  .description('Apply template patches for existing projects')
@@ -7073,7 +7075,7 @@ const executeRun = async (
7073
7075
  /**
7074
7076
  * 注册 dev/build/start 命令到 program
7075
7077
  */
7076
- const registerCommand$2 = program => {
7078
+ const registerCommand$3 = program => {
7077
7079
  // dev 命令
7078
7080
  program
7079
7081
  .command('dev')
@@ -7100,6 +7102,15 @@ const registerCommand$2 = program => {
7100
7102
  .action(async options => {
7101
7103
  await executeRun('start', options);
7102
7104
  });
7105
+
7106
+ // validate 命令
7107
+ program
7108
+ .command('validate')
7109
+ .description('Validate project (lint + type check)')
7110
+ .option('--log-file <path>', 'Log file path')
7111
+ .action(async options => {
7112
+ await executeRun('validate', options);
7113
+ });
7103
7114
  };
7104
7115
 
7105
7116
  // ABOUTME: Nuxt route scanner
@@ -7980,7 +7991,7 @@ const executeRoutes = async (
7980
7991
  /**
7981
7992
  * Register routes command to program
7982
7993
  */
7983
- const registerCommand$1 = program => {
7994
+ const registerCommand$2 = program => {
7984
7995
  program
7985
7996
  .command('routes')
7986
7997
  .description('Generate routes manifest for the current project')
@@ -7997,6 +8008,131 @@ const registerCommand$1 = program => {
7997
8008
  });
7998
8009
  };
7999
8010
 
8011
+ const d = debug('coze-init-cli:check-bins');
8012
+
8013
+
8014
+
8015
+
8016
+
8017
+
8018
+
8019
+ const checkBins = async (cwd, fix) => {
8020
+ d('starting check, cwd=%s fix=%s', cwd, fix);
8021
+
8022
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- fallback {} ensures non-null
8023
+ const pkgJson = safeJsonParse
8024
+
8025
+
8026
+ (await fs$1.readFile(path.join(cwd, 'package.json'), 'utf8'), {});
8027
+
8028
+ const allDeps = Object.keys({
8029
+ ...pkgJson.dependencies,
8030
+ ...pkgJson.devDependencies,
8031
+ });
8032
+
8033
+ d('found %d total dependencies to scan', allDeps.length);
8034
+
8035
+ const binDir = path.join(cwd, 'node_modules', '.bin');
8036
+ d('bin directory: %s', binDir);
8037
+ const missing = [];
8038
+
8039
+ await Promise.all(
8040
+ allDeps.map(async depName => {
8041
+ let rawContent;
8042
+ try {
8043
+ rawContent = await fs$1.readFile(
8044
+ path.join(cwd, 'node_modules', depName, 'package.json'),
8045
+ 'utf8',
8046
+ );
8047
+ } catch (err) {
8048
+ d('dep %s not found in node_modules: %s', depName, err);
8049
+ missing.push({ dep: depName, bin: '', reason: 'missing-package' });
8050
+ return;
8051
+ }
8052
+ const depPkg = safeJsonParse(
8053
+ rawContent,
8054
+ );
8055
+ if (!depPkg) {
8056
+ d('skipping %s: failed to parse package.json', depName);
8057
+ return;
8058
+ }
8059
+
8060
+ if (!depPkg.bin) {
8061
+ return;
8062
+ }
8063
+
8064
+ const bins =
8065
+ typeof depPkg.bin === 'string'
8066
+ ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- split always has ≥1 element
8067
+ { [depName.split('/').pop()]: depPkg.bin }
8068
+ : depPkg.bin;
8069
+
8070
+ d('%s declares bins: %o', depName, Object.keys(bins));
8071
+
8072
+ await Promise.all(
8073
+ Object.keys(bins).map(async binName => {
8074
+ try {
8075
+ await fs$1.access(path.join(binDir, binName));
8076
+ d('bin present: %s', binName);
8077
+ } catch (err) {
8078
+ d('bin missing: %s (from %s): %s', binName, depName, err);
8079
+ missing.push({ dep: depName, bin: binName, reason: 'missing-bin' });
8080
+ }
8081
+ }),
8082
+ );
8083
+ }),
8084
+ );
8085
+
8086
+ d('scan complete, missing=%d', missing.length);
8087
+
8088
+ if (missing.length === 0) {
8089
+ logger.success(
8090
+ 'check-bins: all bin entries present, skipping force install.',
8091
+ );
8092
+ return;
8093
+ }
8094
+
8095
+ logger.warn('check-bins: missing or broken dependencies detected:');
8096
+ for (const { dep, bin, reason } of missing) {
8097
+ if (reason === 'missing-package') {
8098
+ logger.warn(` ${dep} -> (package not found in node_modules)`);
8099
+ } else {
8100
+ logger.warn(` ${dep} -> .bin/${bin}`);
8101
+ }
8102
+ }
8103
+
8104
+ if (!fix) {
8105
+ logger.error(
8106
+ 'check-bins: missing bin entries found, run with --fix to repair.',
8107
+ );
8108
+ process.exit(1);
8109
+ }
8110
+
8111
+ logger.info('check-bins: running pnpm i --force to fix...');
8112
+ d('executing: pnpm i --force');
8113
+ child_process.execSync('pnpm i --force', { stdio: 'inherit', cwd });
8114
+ d('pnpm i --force completed');
8115
+ };
8116
+
8117
+ const registerCommand$1 = program => {
8118
+ program
8119
+ .command('check-bins')
8120
+ .description(
8121
+ 'Verify all bin entries from dependencies exist in node_modules/.bin, run pnpm i --force if any are missing',
8122
+ )
8123
+ .option('-c, --cwd <path>', 'Working directory to check', process.cwd())
8124
+ .option('--fix', 'Run pnpm i --force to repair missing bin entries', false)
8125
+ .action(async (options) => {
8126
+ try {
8127
+ await checkBins(options.cwd, options.fix);
8128
+ } catch (err) {
8129
+ logger.warn(
8130
+ `check-bins: skipped due to error: ${err instanceof Error ? err.message : String(err)}`,
8131
+ );
8132
+ }
8133
+ });
8134
+ };
8135
+
8000
8136
  /**
8001
8137
  * 在后台启动一个独立的子进程
8002
8138
  * 类似于 `setsid command args >/dev/null 2>&1 &`
@@ -9324,10 +9460,11 @@ const registerCommand = program => {
9324
9460
 
9325
9461
  const commands = [
9326
9462
  registerCommand,
9327
- registerCommand$2,
9328
- registerCommand$5,
9329
9463
  registerCommand$3,
9464
+ registerCommand$6,
9330
9465
  registerCommand$4,
9466
+ registerCommand$5,
9467
+ registerCommand$2,
9331
9468
  registerCommand$1,
9332
9469
  ];
9333
9470
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze-arch/cli",
3
- "version": "0.0.14",
3
+ "version": "0.0.15-alpha.0f8aee",
4
4
  "private": false,
5
5
  "description": "coze coding devtools cli",
6
6
  "license": "MIT",