@coze-arch/cli 0.0.14-alpha.e0ee3f → 0.0.15-alpha.76f8e3

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",
@@ -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-alpha.e0ee3f";
2110
+ var version = "0.0.15-alpha.76f8e3";
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,103 @@ const registerCommand$1 = program => {
7997
8008
  });
7998
8009
  };
7999
8010
 
8011
+ const checkBins = async (cwd, fix) => {
8012
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8013
+ const pkgJson = safeJsonParse
8014
+
8015
+
8016
+ (await fs$1.readFile(path.join(cwd, 'package.json'), 'utf8'), {});
8017
+
8018
+ const allDeps = Object.keys({
8019
+ ...pkgJson.dependencies,
8020
+ ...pkgJson.devDependencies,
8021
+ });
8022
+
8023
+ const binDir = path.join(cwd, 'node_modules', '.bin');
8024
+ const missing = [];
8025
+
8026
+ await Promise.all(
8027
+ allDeps.map(async depName => {
8028
+ let rawContent;
8029
+ try {
8030
+ rawContent = await fs$1.readFile(
8031
+ path.join(cwd, 'node_modules', depName, 'package.json'),
8032
+ 'utf8',
8033
+ );
8034
+ } catch (e) {
8035
+ return;
8036
+ }
8037
+ const depPkg = safeJsonParse(
8038
+ rawContent,
8039
+ );
8040
+ if (!depPkg) {
8041
+ return;
8042
+ }
8043
+
8044
+ if (!depPkg.bin) {
8045
+ return;
8046
+ }
8047
+
8048
+ const bins =
8049
+ typeof depPkg.bin === 'string'
8050
+ ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8051
+ { [depName.split('/').pop()]: depPkg.bin }
8052
+ : depPkg.bin;
8053
+
8054
+ await Promise.all(
8055
+ Object.keys(bins).map(async binName => {
8056
+ try {
8057
+ await fs$1.access(path.join(binDir, binName));
8058
+ } catch (e2) {
8059
+ missing.push({ dep: depName, bin: binName });
8060
+ }
8061
+ }),
8062
+ );
8063
+ }),
8064
+ );
8065
+
8066
+ if (missing.length === 0) {
8067
+ logger.success(
8068
+ 'check-bins: all bin entries present, skipping force install.',
8069
+ );
8070
+ return;
8071
+ }
8072
+
8073
+ logger.warn('check-bins: missing bin entries detected:');
8074
+ for (const { dep, bin } of missing) {
8075
+ logger.warn(` ${dep} -> .bin/${bin}`);
8076
+ }
8077
+
8078
+ if (!fix) {
8079
+ logger.error(
8080
+ 'check-bins: missing bin entries found, run with --fix to repair.',
8081
+ );
8082
+ process.exit(1);
8083
+ }
8084
+
8085
+ logger.info('check-bins: running pnpm i --force to fix...');
8086
+ child_process.execSync('pnpm i --force', { stdio: 'inherit', cwd });
8087
+ };
8088
+
8089
+ const registerCommand$1 = program => {
8090
+ program
8091
+ .command('check-bins')
8092
+ .description(
8093
+ 'Verify all bin entries from dependencies exist in node_modules/.bin, run pnpm i --force if any are missing',
8094
+ )
8095
+ .option('-c, --cwd <path>', 'Working directory to check', process.cwd())
8096
+ .option('--fix', 'Run pnpm i --force to repair missing bin entries', false)
8097
+ .action(async (options) => {
8098
+ try {
8099
+ await checkBins(options.cwd, options.fix);
8100
+ } catch (err) {
8101
+ logger.warn(
8102
+ `check-bins: skipped due to error: ${err instanceof Error ? err.message : String(err)}`,
8103
+ );
8104
+ }
8105
+ });
8106
+ };
8107
+
8000
8108
  /**
8001
8109
  * 在后台启动一个独立的子进程
8002
8110
  * 类似于 `setsid command args >/dev/null 2>&1 &`
@@ -9324,10 +9432,11 @@ const registerCommand = program => {
9324
9432
 
9325
9433
  const commands = [
9326
9434
  registerCommand,
9327
- registerCommand$2,
9328
- registerCommand$5,
9329
9435
  registerCommand$3,
9436
+ registerCommand$6,
9330
9437
  registerCommand$4,
9438
+ registerCommand$5,
9439
+ registerCommand$2,
9331
9440
  registerCommand$1,
9332
9441
  ];
9333
9442
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze-arch/cli",
3
- "version": "0.0.14-alpha.e0ee3f",
3
+ "version": "0.0.15-alpha.76f8e3",
4
4
  "private": false,
5
5
  "description": "coze coding devtools cli",
6
6
  "license": "MIT",
@@ -1,73 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- const fs = require('fs/promises');
5
- const path = require('path');
6
- const { execSync } = require('child_process');
7
-
8
- async function checkBins() {
9
- const cwd = path.join(__dirname, '..');
10
-
11
- const pkgJson = JSON.parse(
12
- await fs.readFile(path.join(cwd, 'package.json'), 'utf8'),
13
- );
14
- const allDeps = Object.keys({
15
- ...pkgJson.dependencies,
16
- ...pkgJson.devDependencies,
17
- });
18
-
19
- const binDir = path.join(cwd, 'node_modules', '.bin');
20
- const missing = [];
21
-
22
- await Promise.all(
23
- allDeps.map(async depName => {
24
- const depPkgPath = path.join(
25
- cwd,
26
- 'node_modules',
27
- depName,
28
- 'package.json',
29
- );
30
-
31
- let depPkg;
32
- try {
33
- depPkg = JSON.parse(await fs.readFile(depPkgPath, 'utf8'));
34
- } catch {
35
- return;
36
- }
37
-
38
- if (!depPkg.bin) return;
39
-
40
- // bin can be a string (single binary named after the package) or an object
41
- const bins =
42
- typeof depPkg.bin === 'string'
43
- ? { [depName.split('/').pop()]: depPkg.bin }
44
- : depPkg.bin;
45
-
46
- await Promise.all(
47
- Object.keys(bins).map(async binName => {
48
- try {
49
- await fs.access(path.join(binDir, binName));
50
- } catch {
51
- missing.push({ dep: depName, bin: binName });
52
- }
53
- }),
54
- );
55
- }),
56
- );
57
-
58
- if (missing.length === 0) {
59
- console.log('check-bins: all bin entries present, skipping force install.');
60
- return;
61
- }
62
-
63
- console.log('check-bins: missing bin entries detected:');
64
- for (const { dep, bin } of missing) {
65
- console.log(` ${dep} -> .bin/${bin}`);
66
- }
67
- console.log('check-bins: running pnpm i --force to fix...');
68
- execSync('pnpm i --force', { stdio: 'inherit', cwd });
69
- }
70
-
71
- checkBins().catch(err => {
72
- console.warn('check-bins: skipped due to error:', err.message);
73
- });