@coze-arch/cli 0.0.14-alpha.e0ee3f → 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.
- package/lib/__templates__/expo/.coze +1 -0
- package/lib/__templates__/expo/.cozeproj/scripts/validate.sh +8 -0
- package/lib/__templates__/expo/package.json +2 -1
- package/lib/__templates__/nextjs/.coze +1 -0
- package/lib/__templates__/nextjs/package.json +3 -1
- package/lib/__templates__/nextjs/scripts/prepare.sh +3 -1
- package/lib/__templates__/nextjs/scripts/validate.sh +10 -0
- package/lib/__templates__/nuxt-vue/.coze +1 -0
- package/lib/__templates__/nuxt-vue/eslint.config.mjs +25 -0
- package/lib/__templates__/nuxt-vue/package.json +9 -2
- package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +790 -10
- package/lib/__templates__/nuxt-vue/scripts/prepare.sh +3 -0
- package/lib/__templates__/nuxt-vue/scripts/validate.sh +10 -0
- package/lib/__templates__/taro/.coze +1 -0
- package/lib/__templates__/taro/.cozeproj/scripts/validate.sh +8 -0
- package/lib/__templates__/taro/package.json +1 -1
- package/lib/__templates__/vite/.coze +1 -0
- package/lib/__templates__/vite/package.json +3 -1
- package/lib/__templates__/vite/scripts/prepare.sh +3 -0
- package/lib/__templates__/vite/scripts/validate.sh +10 -0
- package/lib/cli.js +146 -9
- package/package.json +1 -1
- package/lib/__templates__/nextjs/scripts/check-bins.js +0 -73
|
@@ -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
|
|
@@ -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"]
|
|
@@ -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",
|
|
@@ -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
|
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.
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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,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
|
-
});
|