@coze-arch/cli 0.0.14-alpha.e0ee3f → 0.0.15
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,4 +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
|
-
|
|
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
|
|
@@ -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,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.14
|
|
2110
|
+
var version = "0.0.14";
|
|
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')
|
|
@@ -6802,7 +6802,7 @@ const executePatch = async (
|
|
|
6802
6802
|
}
|
|
6803
6803
|
};
|
|
6804
6804
|
|
|
6805
|
-
const registerCommand$
|
|
6805
|
+
const registerCommand$4 = program => {
|
|
6806
6806
|
program
|
|
6807
6807
|
.command('patch')
|
|
6808
6808
|
.description('Apply template patches for existing projects')
|
|
@@ -7073,7 +7073,7 @@ const executeRun = async (
|
|
|
7073
7073
|
/**
|
|
7074
7074
|
* 注册 dev/build/start 命令到 program
|
|
7075
7075
|
*/
|
|
7076
|
-
const registerCommand$
|
|
7076
|
+
const registerCommand$3 = program => {
|
|
7077
7077
|
// dev 命令
|
|
7078
7078
|
program
|
|
7079
7079
|
.command('dev')
|
|
@@ -7980,7 +7980,7 @@ const executeRoutes = async (
|
|
|
7980
7980
|
/**
|
|
7981
7981
|
* Register routes command to program
|
|
7982
7982
|
*/
|
|
7983
|
-
const registerCommand$
|
|
7983
|
+
const registerCommand$2 = program => {
|
|
7984
7984
|
program
|
|
7985
7985
|
.command('routes')
|
|
7986
7986
|
.description('Generate routes manifest for the current project')
|
|
@@ -7997,6 +7997,103 @@ const registerCommand$1 = program => {
|
|
|
7997
7997
|
});
|
|
7998
7998
|
};
|
|
7999
7999
|
|
|
8000
|
+
const checkBins = async (cwd, fix) => {
|
|
8001
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
8002
|
+
const pkgJson = safeJsonParse
|
|
8003
|
+
|
|
8004
|
+
|
|
8005
|
+
(await fs$1.readFile(path.join(cwd, 'package.json'), 'utf8'), {});
|
|
8006
|
+
|
|
8007
|
+
const allDeps = Object.keys({
|
|
8008
|
+
...pkgJson.dependencies,
|
|
8009
|
+
...pkgJson.devDependencies,
|
|
8010
|
+
});
|
|
8011
|
+
|
|
8012
|
+
const binDir = path.join(cwd, 'node_modules', '.bin');
|
|
8013
|
+
const missing = [];
|
|
8014
|
+
|
|
8015
|
+
await Promise.all(
|
|
8016
|
+
allDeps.map(async depName => {
|
|
8017
|
+
let rawContent;
|
|
8018
|
+
try {
|
|
8019
|
+
rawContent = await fs$1.readFile(
|
|
8020
|
+
path.join(cwd, 'node_modules', depName, 'package.json'),
|
|
8021
|
+
'utf8',
|
|
8022
|
+
);
|
|
8023
|
+
} catch (e) {
|
|
8024
|
+
return;
|
|
8025
|
+
}
|
|
8026
|
+
const depPkg = safeJsonParse(
|
|
8027
|
+
rawContent,
|
|
8028
|
+
);
|
|
8029
|
+
if (!depPkg) {
|
|
8030
|
+
return;
|
|
8031
|
+
}
|
|
8032
|
+
|
|
8033
|
+
if (!depPkg.bin) {
|
|
8034
|
+
return;
|
|
8035
|
+
}
|
|
8036
|
+
|
|
8037
|
+
const bins =
|
|
8038
|
+
typeof depPkg.bin === 'string'
|
|
8039
|
+
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
8040
|
+
{ [depName.split('/').pop()]: depPkg.bin }
|
|
8041
|
+
: depPkg.bin;
|
|
8042
|
+
|
|
8043
|
+
await Promise.all(
|
|
8044
|
+
Object.keys(bins).map(async binName => {
|
|
8045
|
+
try {
|
|
8046
|
+
await fs$1.access(path.join(binDir, binName));
|
|
8047
|
+
} catch (e2) {
|
|
8048
|
+
missing.push({ dep: depName, bin: binName });
|
|
8049
|
+
}
|
|
8050
|
+
}),
|
|
8051
|
+
);
|
|
8052
|
+
}),
|
|
8053
|
+
);
|
|
8054
|
+
|
|
8055
|
+
if (missing.length === 0) {
|
|
8056
|
+
logger.success(
|
|
8057
|
+
'check-bins: all bin entries present, skipping force install.',
|
|
8058
|
+
);
|
|
8059
|
+
return;
|
|
8060
|
+
}
|
|
8061
|
+
|
|
8062
|
+
logger.warn('check-bins: missing bin entries detected:');
|
|
8063
|
+
for (const { dep, bin } of missing) {
|
|
8064
|
+
logger.warn(` ${dep} -> .bin/${bin}`);
|
|
8065
|
+
}
|
|
8066
|
+
|
|
8067
|
+
if (!fix) {
|
|
8068
|
+
logger.error(
|
|
8069
|
+
'check-bins: missing bin entries found, run with --fix to repair.',
|
|
8070
|
+
);
|
|
8071
|
+
process.exit(1);
|
|
8072
|
+
}
|
|
8073
|
+
|
|
8074
|
+
logger.info('check-bins: running pnpm i --force to fix...');
|
|
8075
|
+
child_process.execSync('pnpm i --force', { stdio: 'inherit', cwd });
|
|
8076
|
+
};
|
|
8077
|
+
|
|
8078
|
+
const registerCommand$1 = program => {
|
|
8079
|
+
program
|
|
8080
|
+
.command('check-bins')
|
|
8081
|
+
.description(
|
|
8082
|
+
'Verify all bin entries from dependencies exist in node_modules/.bin, run pnpm i --force if any are missing',
|
|
8083
|
+
)
|
|
8084
|
+
.option('-c, --cwd <path>', 'Working directory to check', process.cwd())
|
|
8085
|
+
.option('--fix', 'Run pnpm i --force to repair missing bin entries', false)
|
|
8086
|
+
.action(async (options) => {
|
|
8087
|
+
try {
|
|
8088
|
+
await checkBins(options.cwd, options.fix);
|
|
8089
|
+
} catch (err) {
|
|
8090
|
+
logger.warn(
|
|
8091
|
+
`check-bins: skipped due to error: ${err instanceof Error ? err.message : String(err)}`,
|
|
8092
|
+
);
|
|
8093
|
+
}
|
|
8094
|
+
});
|
|
8095
|
+
};
|
|
8096
|
+
|
|
8000
8097
|
/**
|
|
8001
8098
|
* 在后台启动一个独立的子进程
|
|
8002
8099
|
* 类似于 `setsid command args >/dev/null 2>&1 &`
|
|
@@ -9324,10 +9421,11 @@ const registerCommand = program => {
|
|
|
9324
9421
|
|
|
9325
9422
|
const commands = [
|
|
9326
9423
|
registerCommand,
|
|
9327
|
-
registerCommand$2,
|
|
9328
|
-
registerCommand$5,
|
|
9329
9424
|
registerCommand$3,
|
|
9425
|
+
registerCommand$6,
|
|
9330
9426
|
registerCommand$4,
|
|
9427
|
+
registerCommand$5,
|
|
9428
|
+
registerCommand$2,
|
|
9331
9429
|
registerCommand$1,
|
|
9332
9430
|
];
|
|
9333
9431
|
|
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
|
-
});
|