@coze-arch/cli 0.0.30-alpha.37325a → 0.0.31-alpha.87aef4
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/.cozeproj/scripts/validate.sh +1 -1
- package/lib/__templates__/expo/package.json +1 -1
- package/lib/__templates__/nextjs/package.json +1 -1
- package/lib/__templates__/nextjs/scripts/prepare.sh +2 -2
- package/lib/__templates__/nextjs/scripts/validate.sh +1 -1
- package/lib/__templates__/nuxt-vue/package.json +1 -1
- package/lib/__templates__/nuxt-vue/scripts/prepare.sh +2 -2
- package/lib/__templates__/nuxt-vue/scripts/validate.sh +1 -1
- package/lib/__templates__/vite/package.json +1 -1
- package/lib/__templates__/vite/scripts/prepare.sh +2 -2
- package/lib/__templates__/vite/scripts/validate.sh +1 -1
- package/lib/cli.js +574 -371
- package/package.json +5 -3
package/lib/cli.js
CHANGED
|
@@ -1628,7 +1628,7 @@ function createNodeTransport() {
|
|
|
1628
1628
|
};
|
|
1629
1629
|
}
|
|
1630
1630
|
|
|
1631
|
-
function _nullishCoalesce$
|
|
1631
|
+
function _nullishCoalesce$c(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$v(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
|
|
1632
1632
|
* Slardar CLI Reporter 主类
|
|
1633
1633
|
* 封装 @slardar/base 的初始化和上报逻辑
|
|
1634
1634
|
*/
|
|
@@ -1685,7 +1685,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1685
1685
|
release: config.release,
|
|
1686
1686
|
env: config.env,
|
|
1687
1687
|
name: config.name,
|
|
1688
|
-
useLocalConfig: _nullishCoalesce$
|
|
1688
|
+
useLocalConfig: _nullishCoalesce$c(config.useLocalConfig, () => ( false)), // 默认使用服务端配置
|
|
1689
1689
|
domain: config.domain,
|
|
1690
1690
|
// 设置本地采样率为 100%,确保事件不被过滤
|
|
1691
1691
|
sample: {
|
|
@@ -1700,7 +1700,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1700
1700
|
this.client.on('send', (ev) => {
|
|
1701
1701
|
log$6(
|
|
1702
1702
|
'send hook called for event: %s',
|
|
1703
|
-
(_optionalChain$
|
|
1703
|
+
(_optionalChain$v([ev, 'optionalAccess', _ => _.ev_type]) ) || 'unknown',
|
|
1704
1704
|
);
|
|
1705
1705
|
});
|
|
1706
1706
|
|
|
@@ -1758,7 +1758,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1758
1758
|
)
|
|
1759
1759
|
: undefined;
|
|
1760
1760
|
|
|
1761
|
-
_optionalChain$
|
|
1761
|
+
_optionalChain$v([this, 'access', _2 => _2.client, 'access', _3 => _3.sendEvent, 'optionalCall', _4 => _4({
|
|
1762
1762
|
name,
|
|
1763
1763
|
metrics: cleanMetrics ,
|
|
1764
1764
|
categories: cleanCategories ,
|
|
@@ -1829,7 +1829,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1829
1829
|
log$6('Reporting JS error:', {
|
|
1830
1830
|
name: error.name,
|
|
1831
1831
|
message: error.message.slice(0, 100),
|
|
1832
|
-
stack: _optionalChain$
|
|
1832
|
+
stack: _optionalChain$v([error, 'access', _5 => _5.stack, 'optionalAccess', _6 => _6.slice, 'call', _7 => _7(0, 200)]),
|
|
1833
1833
|
extra,
|
|
1834
1834
|
source,
|
|
1835
1835
|
});
|
|
@@ -1849,7 +1849,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1849
1849
|
if (!this.ensureInitialized()) {
|
|
1850
1850
|
return;
|
|
1851
1851
|
}
|
|
1852
|
-
_optionalChain$
|
|
1852
|
+
_optionalChain$v([this, 'access', _8 => _8.client, 'access', _9 => _9.context, 'optionalAccess', _10 => _10.set, 'call', _11 => _11(key, value)]);
|
|
1853
1853
|
}
|
|
1854
1854
|
|
|
1855
1855
|
/**
|
|
@@ -1860,7 +1860,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1860
1860
|
return;
|
|
1861
1861
|
}
|
|
1862
1862
|
log$6('Merging context:', context);
|
|
1863
|
-
_optionalChain$
|
|
1863
|
+
_optionalChain$v([this, 'access', _12 => _12.client, 'access', _13 => _13.context, 'optionalAccess', _14 => _14.merge, 'call', _15 => _15(context)]);
|
|
1864
1864
|
}
|
|
1865
1865
|
|
|
1866
1866
|
/**
|
|
@@ -1870,7 +1870,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1870
1870
|
if (!this.ensureInitialized()) {
|
|
1871
1871
|
return;
|
|
1872
1872
|
}
|
|
1873
|
-
_optionalChain$
|
|
1873
|
+
_optionalChain$v([this, 'access', _16 => _16.client, 'access', _17 => _17.context, 'optionalAccess', _18 => _18.delete, 'call', _19 => _19(key)]);
|
|
1874
1874
|
}
|
|
1875
1875
|
|
|
1876
1876
|
/**
|
|
@@ -1880,7 +1880,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1880
1880
|
if (!this.ensureInitialized()) {
|
|
1881
1881
|
return;
|
|
1882
1882
|
}
|
|
1883
|
-
_optionalChain$
|
|
1883
|
+
_optionalChain$v([this, 'access', _20 => _20.client, 'access', _21 => _21.context, 'optionalAccess', _22 => _22.clear, 'call', _23 => _23()]);
|
|
1884
1884
|
}
|
|
1885
1885
|
|
|
1886
1886
|
/**
|
|
@@ -1917,7 +1917,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1917
1917
|
return;
|
|
1918
1918
|
}
|
|
1919
1919
|
log$6('Flushing Slardar data...');
|
|
1920
|
-
_optionalChain$
|
|
1920
|
+
_optionalChain$v([this, 'access', _24 => _24.client, 'access', _25 => _25.getSender, 'optionalCall', _26 => _26(), 'optionalAccess', _27 => _27.flush, 'call', _28 => _28()]);
|
|
1921
1921
|
log$6('Waiting %dms for events to be sent...', waitMs);
|
|
1922
1922
|
await new Promise(resolve => setTimeout(resolve, waitMs));
|
|
1923
1923
|
log$6('Slardar data flushed');
|
|
@@ -1936,7 +1936,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1936
1936
|
*/
|
|
1937
1937
|
const reporter = new SlardarCLIReporter();
|
|
1938
1938
|
|
|
1939
|
-
function _optionalChain$
|
|
1939
|
+
function _optionalChain$u(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1940
1940
|
|
|
1941
1941
|
|
|
1942
1942
|
|
|
@@ -1996,11 +1996,11 @@ const EventBuilder = {
|
|
|
1996
1996
|
name: CLI_EVENTS.CLI_COMMAND,
|
|
1997
1997
|
categories: {
|
|
1998
1998
|
command,
|
|
1999
|
-
args: _optionalChain$
|
|
1999
|
+
args: _optionalChain$u([options, 'optionalAccess', _ => _.args]),
|
|
2000
2000
|
status: 'running' ,
|
|
2001
|
-
..._optionalChain$
|
|
2001
|
+
..._optionalChain$u([options, 'optionalAccess', _2 => _2.categories]),
|
|
2002
2002
|
},
|
|
2003
|
-
metrics: _optionalChain$
|
|
2003
|
+
metrics: _optionalChain$u([options, 'optionalAccess', _3 => _3.metrics]),
|
|
2004
2004
|
};
|
|
2005
2005
|
},
|
|
2006
2006
|
|
|
@@ -2021,13 +2021,13 @@ const EventBuilder = {
|
|
|
2021
2021
|
name: CLI_EVENTS.CLI_COMMAND_COMPLETE,
|
|
2022
2022
|
categories: {
|
|
2023
2023
|
command,
|
|
2024
|
-
args: _optionalChain$
|
|
2024
|
+
args: _optionalChain$u([options, 'optionalAccess', _4 => _4.args]),
|
|
2025
2025
|
status: success ? ('success' ) : ('fail' ),
|
|
2026
|
-
..._optionalChain$
|
|
2026
|
+
..._optionalChain$u([options, 'optionalAccess', _5 => _5.categories]),
|
|
2027
2027
|
},
|
|
2028
2028
|
metrics: {
|
|
2029
2029
|
duration,
|
|
2030
|
-
...(_optionalChain$
|
|
2030
|
+
...(_optionalChain$u([options, 'optionalAccess', _6 => _6.errorCode]) && { errorCode: options.errorCode }),
|
|
2031
2031
|
},
|
|
2032
2032
|
};
|
|
2033
2033
|
},
|
|
@@ -2048,12 +2048,12 @@ const EventBuilder = {
|
|
|
2048
2048
|
name: CLI_EVENTS.NETWORK_REQUEST,
|
|
2049
2049
|
categories: {
|
|
2050
2050
|
url,
|
|
2051
|
-
method: _optionalChain$
|
|
2052
|
-
statusCode: _optionalChain$
|
|
2053
|
-
status: _optionalChain$
|
|
2051
|
+
method: _optionalChain$u([options, 'optionalAccess', _7 => _7.method]) || 'GET',
|
|
2052
|
+
statusCode: _optionalChain$u([options, 'optionalAccess', _8 => _8.statusCode, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]),
|
|
2053
|
+
status: _optionalChain$u([options, 'optionalAccess', _11 => _11.success]) ? ('success' ) : ('fail' ),
|
|
2054
2054
|
},
|
|
2055
2055
|
metrics: {
|
|
2056
|
-
duration: _optionalChain$
|
|
2056
|
+
duration: _optionalChain$u([options, 'optionalAccess', _12 => _12.duration]),
|
|
2057
2057
|
},
|
|
2058
2058
|
};
|
|
2059
2059
|
},
|
|
@@ -2075,11 +2075,11 @@ const EventBuilder = {
|
|
|
2075
2075
|
categories: {
|
|
2076
2076
|
operation,
|
|
2077
2077
|
filePath,
|
|
2078
|
-
status: _optionalChain$
|
|
2078
|
+
status: _optionalChain$u([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
|
|
2079
2079
|
},
|
|
2080
2080
|
metrics: {
|
|
2081
|
-
duration: _optionalChain$
|
|
2082
|
-
fileSize: _optionalChain$
|
|
2081
|
+
duration: _optionalChain$u([options, 'optionalAccess', _14 => _14.duration]),
|
|
2082
|
+
fileSize: _optionalChain$u([options, 'optionalAccess', _15 => _15.fileSize]),
|
|
2083
2083
|
},
|
|
2084
2084
|
};
|
|
2085
2085
|
},
|
|
@@ -2107,14 +2107,15 @@ const EventBuilder = {
|
|
|
2107
2107
|
};
|
|
2108
2108
|
|
|
2109
2109
|
var name = "@coze-arch/cli";
|
|
2110
|
-
var version = "0.0.
|
|
2110
|
+
var version = "0.0.31-alpha.87aef4";
|
|
2111
2111
|
var description = "coze coding devtools cli";
|
|
2112
2112
|
var license = "MIT";
|
|
2113
2113
|
var author = "fanwenjie.fe@bytedance.com";
|
|
2114
2114
|
var maintainers = [
|
|
2115
2115
|
];
|
|
2116
2116
|
var bin = {
|
|
2117
|
-
coze: "bin/main"
|
|
2117
|
+
coze: "bin/main",
|
|
2118
|
+
"coze-dev": "bin/main"
|
|
2118
2119
|
};
|
|
2119
2120
|
var files = [
|
|
2120
2121
|
"lib",
|
|
@@ -2196,7 +2197,8 @@ var publishConfig = {
|
|
|
2196
2197
|
};
|
|
2197
2198
|
var cozePublishConfig = {
|
|
2198
2199
|
bin: {
|
|
2199
|
-
coze: "bin/main"
|
|
2200
|
+
coze: "bin/main",
|
|
2201
|
+
"coze-dev": "bin/main"
|
|
2200
2202
|
}
|
|
2201
2203
|
};
|
|
2202
2204
|
var packageJson = {
|
|
@@ -2216,7 +2218,7 @@ var packageJson = {
|
|
|
2216
2218
|
cozePublishConfig: cozePublishConfig
|
|
2217
2219
|
};
|
|
2218
2220
|
|
|
2219
|
-
function _optionalChain$
|
|
2221
|
+
function _optionalChain$t(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
|
|
2220
2222
|
* Slardar 监控初始化和上报
|
|
2221
2223
|
*/
|
|
2222
2224
|
|
|
@@ -2319,11 +2321,11 @@ const reportCommandComplete = safeRun(
|
|
|
2319
2321
|
,
|
|
2320
2322
|
) => {
|
|
2321
2323
|
const event = EventBuilder.cliCommandComplete(command, success, duration, {
|
|
2322
|
-
args: _optionalChain$
|
|
2323
|
-
errorCode: _optionalChain$
|
|
2324
|
+
args: _optionalChain$t([options, 'optionalAccess', _ => _.args]),
|
|
2325
|
+
errorCode: _optionalChain$t([options, 'optionalAccess', _2 => _2.errorCode]),
|
|
2324
2326
|
categories: {
|
|
2325
|
-
...(_optionalChain$
|
|
2326
|
-
..._optionalChain$
|
|
2327
|
+
...(_optionalChain$t([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
|
|
2328
|
+
..._optionalChain$t([options, 'optionalAccess', _4 => _4.categories]),
|
|
2327
2329
|
},
|
|
2328
2330
|
});
|
|
2329
2331
|
reporter.sendEvent(event.name, event.metrics, event.categories);
|
|
@@ -2382,7 +2384,7 @@ const flushSlardar = safeRun('flushSlardar', async () => {
|
|
|
2382
2384
|
await reporter.flush();
|
|
2383
2385
|
});
|
|
2384
2386
|
|
|
2385
|
-
function _nullishCoalesce$
|
|
2387
|
+
function _nullishCoalesce$b(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$s(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var LogLevel; (function (LogLevel) {
|
|
2386
2388
|
const ERROR = 0; LogLevel[LogLevel["ERROR"] = ERROR] = "ERROR";
|
|
2387
2389
|
const WARN = 1; LogLevel[LogLevel["WARN"] = WARN] = "WARN";
|
|
2388
2390
|
const SUCCESS = 2; LogLevel[LogLevel["SUCCESS"] = SUCCESS] = "SUCCESS";
|
|
@@ -2420,7 +2422,7 @@ class Logger {
|
|
|
2420
2422
|
|
|
2421
2423
|
constructor(options = {}) {
|
|
2422
2424
|
this.level = this.parseLogLevel(options.level);
|
|
2423
|
-
this.useColor = _nullishCoalesce$
|
|
2425
|
+
this.useColor = _nullishCoalesce$b(options.useColor, () => ( this.isColorSupported()));
|
|
2424
2426
|
this.prefix = options.prefix;
|
|
2425
2427
|
}
|
|
2426
2428
|
|
|
@@ -2429,7 +2431,7 @@ class Logger {
|
|
|
2429
2431
|
return level;
|
|
2430
2432
|
}
|
|
2431
2433
|
|
|
2432
|
-
const envLevel = _optionalChain$
|
|
2434
|
+
const envLevel = _optionalChain$s([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
|
|
2433
2435
|
if (envLevel && envLevel in LOG_LEVEL_MAP) {
|
|
2434
2436
|
return LOG_LEVEL_MAP[envLevel];
|
|
2435
2437
|
}
|
|
@@ -2441,7 +2443,7 @@ class Logger {
|
|
|
2441
2443
|
// 简单检测:Node.js 环境且支持 TTY
|
|
2442
2444
|
return (
|
|
2443
2445
|
typeof process !== 'undefined' &&
|
|
2444
|
-
_optionalChain$
|
|
2446
|
+
_optionalChain$s([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
|
|
2445
2447
|
process.env.NO_COLOR === undefined
|
|
2446
2448
|
);
|
|
2447
2449
|
}
|
|
@@ -2466,7 +2468,7 @@ class Logger {
|
|
|
2466
2468
|
|
|
2467
2469
|
const icon = this.colorize(options.icon, options.color);
|
|
2468
2470
|
const prefix = this.prefix ? `${icon} ${this.prefix}` : icon;
|
|
2469
|
-
console.log(prefix, options.message, ...(_nullishCoalesce$
|
|
2471
|
+
console.log(prefix, options.message, ...(_nullishCoalesce$b(options.args, () => ( []))));
|
|
2470
2472
|
}
|
|
2471
2473
|
|
|
2472
2474
|
error(message, ...args) {
|
|
@@ -2598,9 +2600,7 @@ const getTemplatesDir = () => {
|
|
|
2598
2600
|
* @returns 模板配置对象
|
|
2599
2601
|
*/
|
|
2600
2602
|
|
|
2601
|
-
const loadTemplateConfig = async (
|
|
2602
|
-
templatePath,
|
|
2603
|
-
) => {
|
|
2603
|
+
const loadTemplateConfig = async ( templatePath) => {
|
|
2604
2604
|
logger.verbose(`Loading template config from: ${templatePath}`);
|
|
2605
2605
|
|
|
2606
2606
|
const tsConfigPath = path.join(templatePath, 'template.config.ts');
|
|
@@ -2632,15 +2632,12 @@ const loadTemplateConfig = async (
|
|
|
2632
2632
|
} else if (jsExists) {
|
|
2633
2633
|
configPath = jsConfigPath;
|
|
2634
2634
|
} else {
|
|
2635
|
-
throw new Error(
|
|
2636
|
-
`Template config not found in ${templatePath}.\n` +
|
|
2637
|
-
'Expected: template.config.ts or template.config.js',
|
|
2638
|
-
);
|
|
2635
|
+
throw new Error(`Template config not found in ${templatePath}.\n` + 'Expected: template.config.ts or template.config.js');
|
|
2639
2636
|
}
|
|
2640
2637
|
|
|
2641
2638
|
logger.verbose(`Using config file: ${configPath}`);
|
|
2642
2639
|
|
|
2643
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
2640
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports -- Sucrase handles .ts files at runtime, path is validated above
|
|
2644
2641
|
const config = require(configPath);
|
|
2645
2642
|
|
|
2646
2643
|
logger.verbose('Template config loaded successfully');
|
|
@@ -2654,18 +2651,14 @@ const loadTemplateConfig = async (
|
|
|
2654
2651
|
* @param configPath - templates.json 配置文件路径
|
|
2655
2652
|
* @returns 模板列表配置
|
|
2656
2653
|
*/
|
|
2657
|
-
const loadTemplatesConfig = async (
|
|
2658
|
-
configPath,
|
|
2659
|
-
) => {
|
|
2654
|
+
const loadTemplatesConfig = async (configPath) => {
|
|
2660
2655
|
logger.verbose(`Loading templates config from: ${configPath}`);
|
|
2661
2656
|
|
|
2662
2657
|
const content = await fs$1.readFile(configPath, 'utf-8');
|
|
2663
2658
|
// eslint-disable-next-line no-restricted-syntax -- Static config file loaded at build time, safeJsonParse not needed
|
|
2664
2659
|
const config = JSON.parse(content) ;
|
|
2665
2660
|
|
|
2666
|
-
logger.verbose(
|
|
2667
|
-
`Found ${config.templates.length} templates: ${config.templates.map(t => t.name).join(', ')}`,
|
|
2668
|
-
);
|
|
2661
|
+
logger.verbose(`Found ${config.templates.length} templates: ${config.templates.map(t => t.name).join(', ')}`);
|
|
2669
2662
|
|
|
2670
2663
|
return config;
|
|
2671
2664
|
};
|
|
@@ -2677,20 +2670,13 @@ const loadTemplatesConfig = async (
|
|
|
2677
2670
|
* @param templateName - 模板名称
|
|
2678
2671
|
* @returns 模板元信息
|
|
2679
2672
|
*/
|
|
2680
|
-
const findTemplate = (
|
|
2681
|
-
templatesConfig,
|
|
2682
|
-
templateName,
|
|
2683
|
-
) => {
|
|
2673
|
+
const findTemplate = (templatesConfig, templateName) => {
|
|
2684
2674
|
const template = templatesConfig.templates.find(t => t.name === templateName);
|
|
2685
2675
|
|
|
2686
2676
|
if (!template) {
|
|
2687
|
-
const availableTemplates = templatesConfig.templates
|
|
2688
|
-
.map(t => t.name)
|
|
2689
|
-
.join(', ');
|
|
2677
|
+
const availableTemplates = templatesConfig.templates.map(t => t.name).join(', ');
|
|
2690
2678
|
throw new Error(
|
|
2691
|
-
`Template "${templateName}" not found.\n` +
|
|
2692
|
-
`Available templates: ${availableTemplates}\n` +
|
|
2693
|
-
'Use --template <name> to specify a template.',
|
|
2679
|
+
`Template "${templateName}" not found.\n` + `Available templates: ${availableTemplates}\n` + 'Use --template <name> to specify a template.',
|
|
2694
2680
|
);
|
|
2695
2681
|
}
|
|
2696
2682
|
|
|
@@ -2704,10 +2690,7 @@ const findTemplate = (
|
|
|
2704
2690
|
* @param templateMetadata - 模板元信息
|
|
2705
2691
|
* @returns 模板完整路径
|
|
2706
2692
|
*/
|
|
2707
|
-
const getTemplatePath = async (
|
|
2708
|
-
basePath,
|
|
2709
|
-
templateMetadata,
|
|
2710
|
-
) => {
|
|
2693
|
+
const getTemplatePath = async (basePath, templateMetadata) => {
|
|
2711
2694
|
logger.verbose('Resolving template path:');
|
|
2712
2695
|
logger.verbose(` - Base path: ${basePath}`);
|
|
2713
2696
|
logger.verbose(` - Template location: ${templateMetadata.location}`);
|
|
@@ -2722,9 +2705,7 @@ const getTemplatePath = async (
|
|
|
2722
2705
|
logger.verbose(' - Template directory exists: ✓');
|
|
2723
2706
|
} catch (error) {
|
|
2724
2707
|
logger.error(' - Template directory does not exist: ✗');
|
|
2725
|
-
throw new Error(
|
|
2726
|
-
`Template directory not found: ${templatePath} (cause: ${error instanceof Error ? error.message : String(error)})`,
|
|
2727
|
-
);
|
|
2708
|
+
throw new Error(`Template directory not found: ${templatePath} (cause: ${error instanceof Error ? error.message : String(error)})`);
|
|
2728
2709
|
}
|
|
2729
2710
|
|
|
2730
2711
|
return templatePath;
|
|
@@ -2739,7 +2720,6 @@ const warmupTemplate = (templatePath, templateName) => {
|
|
|
2739
2720
|
|
|
2740
2721
|
// 检查是否存在 package.json
|
|
2741
2722
|
const packageJsonPath = node_path.join(templatePath, 'package.json');
|
|
2742
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
2743
2723
|
if (!node_fs.existsSync(packageJsonPath)) {
|
|
2744
2724
|
logger.info(` ⊘ Skipping ${templateName} (no package.json found)`);
|
|
2745
2725
|
return;
|
|
@@ -2791,30 +2771,22 @@ const executeWarmup = async (options) => {
|
|
|
2791
2771
|
const configPath = getTemplatesConfigPath();
|
|
2792
2772
|
const templatesConfig = await loadTemplatesConfig(configPath);
|
|
2793
2773
|
|
|
2794
|
-
logger.verbose(
|
|
2795
|
-
`Found ${templatesConfig.templates.length} templates in config`,
|
|
2796
|
-
);
|
|
2774
|
+
logger.verbose(`Found ${templatesConfig.templates.length} templates in config`);
|
|
2797
2775
|
|
|
2798
2776
|
// 过滤模板
|
|
2799
|
-
const templatesToWarmup = templateFilter
|
|
2800
|
-
? templatesConfig.templates.filter(t => t.name === templateFilter)
|
|
2801
|
-
: templatesConfig.templates;
|
|
2777
|
+
const templatesToWarmup = templateFilter ? templatesConfig.templates.filter(t => t.name === templateFilter) : templatesConfig.templates;
|
|
2802
2778
|
|
|
2803
2779
|
if (templatesToWarmup.length === 0) {
|
|
2804
2780
|
if (templateFilter) {
|
|
2805
2781
|
logger.warn(`Template "${templateFilter}" not found`);
|
|
2806
|
-
logger.info(
|
|
2807
|
-
`Available templates: ${templatesConfig.templates.map(t => t.name).join(', ')}`,
|
|
2808
|
-
);
|
|
2782
|
+
logger.info(`Available templates: ${templatesConfig.templates.map(t => t.name).join(', ')}`);
|
|
2809
2783
|
} else {
|
|
2810
2784
|
logger.warn('No templates found');
|
|
2811
2785
|
}
|
|
2812
2786
|
return;
|
|
2813
2787
|
}
|
|
2814
2788
|
|
|
2815
|
-
logger.info(
|
|
2816
|
-
`\nWill warm up ${templatesToWarmup.length} template(s): ${templatesToWarmup.map(t => t.name).join(', ')}`,
|
|
2817
|
-
);
|
|
2789
|
+
logger.info(`\nWill warm up ${templatesToWarmup.length} template(s): ${templatesToWarmup.map(t => t.name).join(', ')}`);
|
|
2818
2790
|
|
|
2819
2791
|
// 获取模板基础路径
|
|
2820
2792
|
const basePath = configPath.replace(/\/templates\.json$/, '');
|
|
@@ -2827,9 +2799,7 @@ const executeWarmup = async (options) => {
|
|
|
2827
2799
|
}
|
|
2828
2800
|
|
|
2829
2801
|
logger.success('\n✅ All templates warmed up successfully!');
|
|
2830
|
-
logger.info(
|
|
2831
|
-
'\nNext time you run `coze init`, it will be much faster as node_modules are pre-installed.',
|
|
2832
|
-
);
|
|
2802
|
+
logger.info('\nNext time you run `coze init`, it will be much faster as node_modules are pre-installed.');
|
|
2833
2803
|
|
|
2834
2804
|
timer.logTotal();
|
|
2835
2805
|
} catch (error) {
|
|
@@ -2843,7 +2813,7 @@ const executeWarmup = async (options) => {
|
|
|
2843
2813
|
/**
|
|
2844
2814
|
* 注册 warmup 命令到 program
|
|
2845
2815
|
*/
|
|
2846
|
-
const registerCommand$
|
|
2816
|
+
const registerCommand$7 = program => {
|
|
2847
2817
|
program
|
|
2848
2818
|
.command('warmup')
|
|
2849
2819
|
.description('Pre-install dependencies for templates to speed up init')
|
|
@@ -3255,7 +3225,7 @@ const executeUpdate = (
|
|
|
3255
3225
|
/**
|
|
3256
3226
|
* 注册 update 命令到 program
|
|
3257
3227
|
*/
|
|
3258
|
-
const registerCommand$
|
|
3228
|
+
const registerCommand$6 = program => {
|
|
3259
3229
|
program
|
|
3260
3230
|
.command('update <package>')
|
|
3261
3231
|
.description('Update a package dependency')
|
|
@@ -3281,7 +3251,7 @@ const registerCommand$5 = program => {
|
|
|
3281
3251
|
});
|
|
3282
3252
|
};
|
|
3283
3253
|
|
|
3284
|
-
function _optionalChain$
|
|
3254
|
+
function _optionalChain$r(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3285
3255
|
// Safe JSON parsing utilities with type safety and error handling
|
|
3286
3256
|
// Provides fallback values, validation, and error monitoring capabilities
|
|
3287
3257
|
|
|
@@ -3381,12 +3351,12 @@ function safeJsonParse(
|
|
|
3381
3351
|
const parsed = JSON.parse(String(input));
|
|
3382
3352
|
|
|
3383
3353
|
// Optional validation
|
|
3384
|
-
if (_optionalChain$
|
|
3354
|
+
if (_optionalChain$r([options, 'optionalAccess', _ => _.validate])) {
|
|
3385
3355
|
if (options.validate(parsed)) {
|
|
3386
3356
|
return parsed;
|
|
3387
3357
|
} else {
|
|
3388
3358
|
const validationError = new Error('JSON validation failed');
|
|
3389
|
-
_optionalChain$
|
|
3359
|
+
_optionalChain$r([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
|
|
3390
3360
|
|
|
3391
3361
|
if (options.throwOnValidationError) {
|
|
3392
3362
|
throw validationError;
|
|
@@ -3398,10 +3368,10 @@ function safeJsonParse(
|
|
|
3398
3368
|
return parsed;
|
|
3399
3369
|
} catch (error) {
|
|
3400
3370
|
// Re-throw validation errors when throwOnValidationError is true
|
|
3401
|
-
if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$
|
|
3371
|
+
if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$r([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
|
|
3402
3372
|
throw error;
|
|
3403
3373
|
}
|
|
3404
|
-
_optionalChain$
|
|
3374
|
+
_optionalChain$r([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
|
|
3405
3375
|
return defaultValue;
|
|
3406
3376
|
}
|
|
3407
3377
|
}
|
|
@@ -3441,7 +3411,7 @@ function isNode(node) {
|
|
|
3441
3411
|
}
|
|
3442
3412
|
const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
|
|
3443
3413
|
|
|
3444
|
-
function _optionalChain$
|
|
3414
|
+
function _optionalChain$q(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
3445
3415
|
const BREAK = Symbol('break visit');
|
|
3446
3416
|
const SKIP = Symbol('skip children');
|
|
3447
3417
|
const REMOVE = Symbol('remove node');
|
|
@@ -3554,15 +3524,15 @@ function callVisitor(key, node, visitor, path) {
|
|
|
3554
3524
|
if (typeof visitor === 'function')
|
|
3555
3525
|
return visitor(key, node, path);
|
|
3556
3526
|
if (isMap(node))
|
|
3557
|
-
return _optionalChain$
|
|
3527
|
+
return _optionalChain$q([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
|
|
3558
3528
|
if (isSeq(node))
|
|
3559
|
-
return _optionalChain$
|
|
3529
|
+
return _optionalChain$q([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
|
|
3560
3530
|
if (isPair(node))
|
|
3561
|
-
return _optionalChain$
|
|
3531
|
+
return _optionalChain$q([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
|
|
3562
3532
|
if (isScalar(node))
|
|
3563
|
-
return _optionalChain$
|
|
3533
|
+
return _optionalChain$q([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
|
|
3564
3534
|
if (isAlias(node))
|
|
3565
|
-
return _optionalChain$
|
|
3535
|
+
return _optionalChain$q([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
|
|
3566
3536
|
return undefined;
|
|
3567
3537
|
}
|
|
3568
3538
|
function replaceNode(key, path, node) {
|
|
@@ -3653,7 +3623,7 @@ function applyReviver(reviver, obj, key, val) {
|
|
|
3653
3623
|
return reviver.call(obj, key, val);
|
|
3654
3624
|
}
|
|
3655
3625
|
|
|
3656
|
-
function _optionalChain$
|
|
3626
|
+
function _optionalChain$p(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
3657
3627
|
/**
|
|
3658
3628
|
* Recursively convert any node or its contents to native JavaScript
|
|
3659
3629
|
*
|
|
@@ -3683,7 +3653,7 @@ function toJS(value, arg, ctx) {
|
|
|
3683
3653
|
ctx.onCreate(res);
|
|
3684
3654
|
return res;
|
|
3685
3655
|
}
|
|
3686
|
-
if (typeof value === 'bigint' && !_optionalChain$
|
|
3656
|
+
if (typeof value === 'bigint' && !_optionalChain$p([ctx, 'optionalAccess', _ => _.keep]))
|
|
3687
3657
|
return Number(value);
|
|
3688
3658
|
return value;
|
|
3689
3659
|
}
|
|
@@ -3721,7 +3691,7 @@ class NodeBase {
|
|
|
3721
3691
|
}
|
|
3722
3692
|
}
|
|
3723
3693
|
|
|
3724
|
-
function _optionalChain$
|
|
3694
|
+
function _optionalChain$o(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
3725
3695
|
class Alias extends NodeBase {
|
|
3726
3696
|
constructor(source) {
|
|
3727
3697
|
super(ALIAS);
|
|
@@ -3737,10 +3707,10 @@ class Alias extends NodeBase {
|
|
|
3737
3707
|
* instance of the `source` anchor before this node.
|
|
3738
3708
|
*/
|
|
3739
3709
|
resolve(doc, ctx) {
|
|
3740
|
-
if (_optionalChain$
|
|
3710
|
+
if (_optionalChain$o([ctx, 'optionalAccess', _ => _.maxAliasCount]) === 0)
|
|
3741
3711
|
throw new ReferenceError('Alias resolution is disabled');
|
|
3742
3712
|
let nodes;
|
|
3743
|
-
if (_optionalChain$
|
|
3713
|
+
if (_optionalChain$o([ctx, 'optionalAccess', _2 => _2.aliasResolveCache])) {
|
|
3744
3714
|
nodes = ctx.aliasResolveCache;
|
|
3745
3715
|
}
|
|
3746
3716
|
else {
|
|
@@ -3779,7 +3749,7 @@ class Alias extends NodeBase {
|
|
|
3779
3749
|
data = anchors.get(source);
|
|
3780
3750
|
}
|
|
3781
3751
|
/* istanbul ignore if */
|
|
3782
|
-
if (_optionalChain$
|
|
3752
|
+
if (_optionalChain$o([data, 'optionalAccess', _3 => _3.res]) === undefined) {
|
|
3783
3753
|
const msg = 'This should not happen: Alias anchor was not resolved?';
|
|
3784
3754
|
throw new ReferenceError(msg);
|
|
3785
3755
|
}
|
|
@@ -3831,7 +3801,7 @@ function getAliasCount(doc, node, anchors) {
|
|
|
3831
3801
|
return 1;
|
|
3832
3802
|
}
|
|
3833
3803
|
|
|
3834
|
-
function _optionalChain$
|
|
3804
|
+
function _optionalChain$n(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
3835
3805
|
const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
|
|
3836
3806
|
class Scalar extends NodeBase {
|
|
3837
3807
|
constructor(value) {
|
|
@@ -3839,7 +3809,7 @@ class Scalar extends NodeBase {
|
|
|
3839
3809
|
this.value = value;
|
|
3840
3810
|
}
|
|
3841
3811
|
toJSON(arg, ctx) {
|
|
3842
|
-
return _optionalChain$
|
|
3812
|
+
return _optionalChain$n([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
|
|
3843
3813
|
}
|
|
3844
3814
|
toString() {
|
|
3845
3815
|
return String(this.value);
|
|
@@ -3851,17 +3821,17 @@ Scalar.PLAIN = 'PLAIN';
|
|
|
3851
3821
|
Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
|
|
3852
3822
|
Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
|
|
3853
3823
|
|
|
3854
|
-
function _nullishCoalesce$
|
|
3824
|
+
function _nullishCoalesce$a(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$m(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
3855
3825
|
const defaultTagPrefix = 'tag:yaml.org,2002:';
|
|
3856
3826
|
function findTagObject(value, tagName, tags) {
|
|
3857
3827
|
if (tagName) {
|
|
3858
3828
|
const match = tags.filter(t => t.tag === tagName);
|
|
3859
|
-
const tagObj = _nullishCoalesce$
|
|
3829
|
+
const tagObj = _nullishCoalesce$a(match.find(t => !t.format), () => ( match[0]));
|
|
3860
3830
|
if (!tagObj)
|
|
3861
3831
|
throw new Error(`Tag ${tagName} not found`);
|
|
3862
3832
|
return tagObj;
|
|
3863
3833
|
}
|
|
3864
|
-
return tags.find(t => _optionalChain$
|
|
3834
|
+
return tags.find(t => _optionalChain$m([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
|
|
3865
3835
|
}
|
|
3866
3836
|
function createNode(value, tagName, ctx) {
|
|
3867
3837
|
if (isDocument(value))
|
|
@@ -3869,7 +3839,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3869
3839
|
if (isNode(value))
|
|
3870
3840
|
return value;
|
|
3871
3841
|
if (isPair(value)) {
|
|
3872
|
-
const map = _optionalChain$
|
|
3842
|
+
const map = _optionalChain$m([ctx, 'access', _3 => _3.schema, 'access', _4 => _4[MAP], 'access', _5 => _5.createNode, 'optionalCall', _6 => _6(ctx.schema, null, ctx)]);
|
|
3873
3843
|
map.items.push(value);
|
|
3874
3844
|
return map;
|
|
3875
3845
|
}
|
|
@@ -3888,7 +3858,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3888
3858
|
if (aliasDuplicateObjects && value && typeof value === 'object') {
|
|
3889
3859
|
ref = sourceObjects.get(value);
|
|
3890
3860
|
if (ref) {
|
|
3891
|
-
_nullishCoalesce$
|
|
3861
|
+
_nullishCoalesce$a(ref.anchor, () => ( (ref.anchor = onAnchor(value))));
|
|
3892
3862
|
return new Alias(ref.anchor);
|
|
3893
3863
|
}
|
|
3894
3864
|
else {
|
|
@@ -3896,7 +3866,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3896
3866
|
sourceObjects.set(value, ref);
|
|
3897
3867
|
}
|
|
3898
3868
|
}
|
|
3899
|
-
if (_optionalChain$
|
|
3869
|
+
if (_optionalChain$m([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
|
|
3900
3870
|
tagName = defaultTagPrefix + tagName.slice(2);
|
|
3901
3871
|
let tagObj = findTagObject(value, tagName, schema.tags);
|
|
3902
3872
|
if (!tagObj) {
|
|
@@ -3921,9 +3891,9 @@ function createNode(value, tagName, ctx) {
|
|
|
3921
3891
|
onTagObj(tagObj);
|
|
3922
3892
|
delete ctx.onTagObj;
|
|
3923
3893
|
}
|
|
3924
|
-
const node = _optionalChain$
|
|
3894
|
+
const node = _optionalChain$m([tagObj, 'optionalAccess', _9 => _9.createNode])
|
|
3925
3895
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
3926
|
-
: typeof _optionalChain$
|
|
3896
|
+
: typeof _optionalChain$m([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
|
|
3927
3897
|
? tagObj.nodeClass.from(ctx.schema, value, ctx)
|
|
3928
3898
|
: new Scalar(value);
|
|
3929
3899
|
if (tagName)
|
|
@@ -4241,7 +4211,7 @@ function consumeMoreIndentedLines(text, i, indent) {
|
|
|
4241
4211
|
return end;
|
|
4242
4212
|
}
|
|
4243
4213
|
|
|
4244
|
-
function _optionalChain$
|
|
4214
|
+
function _optionalChain$l(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
4245
4215
|
const getFoldOptions = (ctx, isBlock) => ({
|
|
4246
4216
|
indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
|
|
4247
4217
|
lineWidth: ctx.options.lineWidth,
|
|
@@ -4526,9 +4496,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
4526
4496
|
// booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
|
|
4527
4497
|
// and others in v1.1.
|
|
4528
4498
|
if (actualString) {
|
|
4529
|
-
const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$
|
|
4499
|
+
const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$l([tag, 'access', _ => _.test, 'optionalAccess', _2 => _2.test, 'call', _3 => _3(str)]);
|
|
4530
4500
|
const { compat, tags } = ctx.doc.schema;
|
|
4531
|
-
if (tags.some(test) || _optionalChain$
|
|
4501
|
+
if (tags.some(test) || _optionalChain$l([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
|
|
4532
4502
|
return quotedString(value, ctx);
|
|
4533
4503
|
}
|
|
4534
4504
|
return implicitKey
|
|
@@ -4574,7 +4544,7 @@ function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
|
4574
4544
|
return res;
|
|
4575
4545
|
}
|
|
4576
4546
|
|
|
4577
|
-
function _nullishCoalesce$
|
|
4547
|
+
function _nullishCoalesce$9(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$k(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
4578
4548
|
function createStringifyContext(doc, options) {
|
|
4579
4549
|
const opt = Object.assign({
|
|
4580
4550
|
blockQuote: true,
|
|
@@ -4621,27 +4591,27 @@ function getTagObject(tags, item) {
|
|
|
4621
4591
|
if (item.tag) {
|
|
4622
4592
|
const match = tags.filter(t => t.tag === item.tag);
|
|
4623
4593
|
if (match.length > 0)
|
|
4624
|
-
return _nullishCoalesce$
|
|
4594
|
+
return _nullishCoalesce$9(match.find(t => t.format === item.format), () => ( match[0]));
|
|
4625
4595
|
}
|
|
4626
4596
|
let tagObj = undefined;
|
|
4627
4597
|
let obj;
|
|
4628
4598
|
if (isScalar(item)) {
|
|
4629
4599
|
obj = item.value;
|
|
4630
|
-
let match = tags.filter(t => _optionalChain$
|
|
4600
|
+
let match = tags.filter(t => _optionalChain$k([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
|
|
4631
4601
|
if (match.length > 1) {
|
|
4632
4602
|
const testMatch = match.filter(t => t.test);
|
|
4633
4603
|
if (testMatch.length > 0)
|
|
4634
4604
|
match = testMatch;
|
|
4635
4605
|
}
|
|
4636
4606
|
tagObj =
|
|
4637
|
-
_nullishCoalesce$
|
|
4607
|
+
_nullishCoalesce$9(match.find(t => t.format === item.format), () => ( match.find(t => !t.format)));
|
|
4638
4608
|
}
|
|
4639
4609
|
else {
|
|
4640
4610
|
obj = item;
|
|
4641
4611
|
tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
|
|
4642
4612
|
}
|
|
4643
4613
|
if (!tagObj) {
|
|
4644
|
-
const name = _nullishCoalesce$
|
|
4614
|
+
const name = _nullishCoalesce$9(_optionalChain$k([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
|
|
4645
4615
|
throw new Error(`Tag not resolved for ${name} value`);
|
|
4646
4616
|
}
|
|
4647
4617
|
return tagObj;
|
|
@@ -4656,7 +4626,7 @@ function stringifyProps(node, tagObj, { anchors, doc }) {
|
|
|
4656
4626
|
anchors.add(anchor);
|
|
4657
4627
|
props.push(`&${anchor}`);
|
|
4658
4628
|
}
|
|
4659
|
-
const tag = _nullishCoalesce$
|
|
4629
|
+
const tag = _nullishCoalesce$9(node.tag, () => ( (tagObj.default ? null : tagObj.tag)));
|
|
4660
4630
|
if (tag)
|
|
4661
4631
|
props.push(doc.directives.tagString(tag));
|
|
4662
4632
|
return props.join(' ');
|
|
@@ -4667,7 +4637,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
|
|
|
4667
4637
|
if (isAlias(item)) {
|
|
4668
4638
|
if (ctx.doc.directives)
|
|
4669
4639
|
return item.toString(ctx);
|
|
4670
|
-
if (_optionalChain$
|
|
4640
|
+
if (_optionalChain$k([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
|
|
4671
4641
|
throw new TypeError(`Cannot stringify circular structure without alias nodes`);
|
|
4672
4642
|
}
|
|
4673
4643
|
else {
|
|
@@ -4682,10 +4652,10 @@ function stringify(item, ctx, onComment, onChompKeep) {
|
|
|
4682
4652
|
const node = isNode(item)
|
|
4683
4653
|
? item
|
|
4684
4654
|
: ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
|
|
4685
|
-
_nullishCoalesce$
|
|
4655
|
+
_nullishCoalesce$9(tagObj, () => ( (tagObj = getTagObject(ctx.doc.schema.tags, node))));
|
|
4686
4656
|
const props = stringifyProps(node, tagObj, ctx);
|
|
4687
4657
|
if (props.length > 0)
|
|
4688
|
-
ctx.indentAtStart = (_nullishCoalesce$
|
|
4658
|
+
ctx.indentAtStart = (_nullishCoalesce$9(ctx.indentAtStart, () => ( 0))) + props.length + 1;
|
|
4689
4659
|
const str = typeof tagObj.stringify === 'function'
|
|
4690
4660
|
? tagObj.stringify(node, ctx, onComment, onChompKeep)
|
|
4691
4661
|
: isScalar(node)
|
|
@@ -4698,7 +4668,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
|
|
|
4698
4668
|
: `${props}\n${ctx.indent}${str}`;
|
|
4699
4669
|
}
|
|
4700
4670
|
|
|
4701
|
-
function _nullishCoalesce$
|
|
4671
|
+
function _nullishCoalesce$8(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
4702
4672
|
function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
4703
4673
|
const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
|
|
4704
4674
|
let keyComment = (isNode(key) && key.comment) || null;
|
|
@@ -4808,7 +4778,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
4808
4778
|
const vs0 = valueStr[0];
|
|
4809
4779
|
const nl0 = valueStr.indexOf('\n');
|
|
4810
4780
|
const hasNewline = nl0 !== -1;
|
|
4811
|
-
const flow = _nullishCoalesce$
|
|
4781
|
+
const flow = _nullishCoalesce$8(_nullishCoalesce$8(ctx.inFlow, () => ( value.flow)), () => ( value.items.length === 0));
|
|
4812
4782
|
if (hasNewline || !flow) {
|
|
4813
4783
|
let hasPropsLine = false;
|
|
4814
4784
|
if (hasNewline && (vs0 === '&' || vs0 === '!')) {
|
|
@@ -4849,7 +4819,7 @@ function warn(logLevel, warning) {
|
|
|
4849
4819
|
}
|
|
4850
4820
|
}
|
|
4851
4821
|
|
|
4852
|
-
function _optionalChain$
|
|
4822
|
+
function _optionalChain$j(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
4853
4823
|
// If the value associated with a merge key is a single mapping node, each of
|
|
4854
4824
|
// its key/value pairs is inserted into the current mapping, unless the key
|
|
4855
4825
|
// already exists in it. If the value associated with the merge key is a
|
|
@@ -4873,7 +4843,7 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
|
|
|
4873
4843
|
(isScalar(key) &&
|
|
4874
4844
|
(!key.type || key.type === Scalar.PLAIN) &&
|
|
4875
4845
|
merge.identify(key.value))) &&
|
|
4876
|
-
_optionalChain$
|
|
4846
|
+
_optionalChain$j([ctx, 'optionalAccess', _ => _.doc, 'access', _2 => _2.schema, 'access', _3 => _3.tags, 'access', _4 => _4.some, 'call', _5 => _5(tag => tag.tag === merge.tag && tag.default)]);
|
|
4877
4847
|
function addMergeToJSMap(ctx, map, value) {
|
|
4878
4848
|
const source = resolveAliasValue(ctx, value);
|
|
4879
4849
|
if (isSeq(source))
|
|
@@ -4913,7 +4883,7 @@ function resolveAliasValue(ctx, value) {
|
|
|
4913
4883
|
return ctx && isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
|
|
4914
4884
|
}
|
|
4915
4885
|
|
|
4916
|
-
function _optionalChain$
|
|
4886
|
+
function _optionalChain$i(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
4917
4887
|
function addPairToJSMap(ctx, map, { key, value }) {
|
|
4918
4888
|
if (isNode(key) && key.addToJSMap)
|
|
4919
4889
|
key.addToJSMap(ctx, map, value);
|
|
@@ -4950,7 +4920,7 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
4950
4920
|
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
4951
4921
|
if (typeof jsKey !== 'object')
|
|
4952
4922
|
return String(jsKey);
|
|
4953
|
-
if (isNode(key) && _optionalChain$
|
|
4923
|
+
if (isNode(key) && _optionalChain$i([ctx, 'optionalAccess', _ => _.doc])) {
|
|
4954
4924
|
const strCtx = createStringifyContext(ctx.doc, {});
|
|
4955
4925
|
strCtx.anchors = new Set();
|
|
4956
4926
|
for (const node of ctx.anchors.keys())
|
|
@@ -4970,7 +4940,7 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
4970
4940
|
return JSON.stringify(jsKey);
|
|
4971
4941
|
}
|
|
4972
4942
|
|
|
4973
|
-
function _optionalChain$
|
|
4943
|
+
function _optionalChain$h(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
4974
4944
|
function createPair(key, value, ctx) {
|
|
4975
4945
|
const k = createNode(key, undefined, ctx);
|
|
4976
4946
|
const v = createNode(value, undefined, ctx);
|
|
@@ -4991,19 +4961,19 @@ class Pair {
|
|
|
4991
4961
|
return new Pair(key, value);
|
|
4992
4962
|
}
|
|
4993
4963
|
toJSON(_, ctx) {
|
|
4994
|
-
const pair = _optionalChain$
|
|
4964
|
+
const pair = _optionalChain$h([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
|
|
4995
4965
|
return addPairToJSMap(ctx, pair, this);
|
|
4996
4966
|
}
|
|
4997
4967
|
toString(ctx, onComment, onChompKeep) {
|
|
4998
|
-
return _optionalChain$
|
|
4968
|
+
return _optionalChain$h([ctx, 'optionalAccess', _3 => _3.doc])
|
|
4999
4969
|
? stringifyPair(this, ctx, onComment, onChompKeep)
|
|
5000
4970
|
: JSON.stringify(this);
|
|
5001
4971
|
}
|
|
5002
4972
|
}
|
|
5003
4973
|
|
|
5004
|
-
function _nullishCoalesce$
|
|
4974
|
+
function _nullishCoalesce$7(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$g(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
5005
4975
|
function stringifyCollection(collection, ctx, options) {
|
|
5006
|
-
const flow = _nullishCoalesce$
|
|
4976
|
+
const flow = _nullishCoalesce$7(ctx.inFlow, () => ( collection.flow));
|
|
5007
4977
|
const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
|
|
5008
4978
|
return stringify(collection, ctx, options);
|
|
5009
4979
|
}
|
|
@@ -5095,7 +5065,7 @@ function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
|
|
|
5095
5065
|
if (iv.commentBefore)
|
|
5096
5066
|
reqNewline = true;
|
|
5097
5067
|
}
|
|
5098
|
-
else if (item.value == null && _optionalChain$
|
|
5068
|
+
else if (item.value == null && _optionalChain$g([ik, 'optionalAccess', _ => _.comment])) {
|
|
5099
5069
|
comment = ik.comment;
|
|
5100
5070
|
}
|
|
5101
5071
|
}
|
|
@@ -5150,7 +5120,7 @@ function addCommentBefore({ indent, options: { commentString } }, lines, comment
|
|
|
5150
5120
|
}
|
|
5151
5121
|
}
|
|
5152
5122
|
|
|
5153
|
-
function _nullishCoalesce$
|
|
5123
|
+
function _nullishCoalesce$6(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$f(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
5154
5124
|
function findPair(items, key) {
|
|
5155
5125
|
const k = isScalar(key) ? key.value : key;
|
|
5156
5126
|
for (const it of items) {
|
|
@@ -5211,12 +5181,12 @@ class YAMLMap extends Collection {
|
|
|
5211
5181
|
_pair = pair;
|
|
5212
5182
|
else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
|
|
5213
5183
|
// In TypeScript, this never happens.
|
|
5214
|
-
_pair = new Pair(pair, _optionalChain$
|
|
5184
|
+
_pair = new Pair(pair, _optionalChain$f([pair, 'optionalAccess', _2 => _2.value]));
|
|
5215
5185
|
}
|
|
5216
5186
|
else
|
|
5217
5187
|
_pair = new Pair(pair.key, pair.value);
|
|
5218
5188
|
const prev = findPair(this.items, _pair.key);
|
|
5219
|
-
const sortEntries = _optionalChain$
|
|
5189
|
+
const sortEntries = _optionalChain$f([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
|
|
5220
5190
|
if (prev) {
|
|
5221
5191
|
if (!overwrite)
|
|
5222
5192
|
throw new Error(`Key ${_pair.key} already set`);
|
|
@@ -5246,8 +5216,8 @@ class YAMLMap extends Collection {
|
|
|
5246
5216
|
}
|
|
5247
5217
|
get(key, keepScalar) {
|
|
5248
5218
|
const it = findPair(this.items, key);
|
|
5249
|
-
const node = _optionalChain$
|
|
5250
|
-
return _nullishCoalesce$
|
|
5219
|
+
const node = _optionalChain$f([it, 'optionalAccess', _5 => _5.value]);
|
|
5220
|
+
return _nullishCoalesce$6((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
|
|
5251
5221
|
}
|
|
5252
5222
|
has(key) {
|
|
5253
5223
|
return !!findPair(this.items, key);
|
|
@@ -5261,8 +5231,8 @@ class YAMLMap extends Collection {
|
|
|
5261
5231
|
* @returns Instance of Type, Map, or Object
|
|
5262
5232
|
*/
|
|
5263
5233
|
toJSON(_, ctx, Type) {
|
|
5264
|
-
const map = Type ? new Type() : _optionalChain$
|
|
5265
|
-
if (_optionalChain$
|
|
5234
|
+
const map = Type ? new Type() : _optionalChain$f([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
|
|
5235
|
+
if (_optionalChain$f([ctx, 'optionalAccess', _7 => _7.onCreate]))
|
|
5266
5236
|
ctx.onCreate(map);
|
|
5267
5237
|
for (const item of this.items)
|
|
5268
5238
|
addPairToJSMap(ctx, map, item);
|
|
@@ -5287,7 +5257,7 @@ class YAMLMap extends Collection {
|
|
|
5287
5257
|
}
|
|
5288
5258
|
}
|
|
5289
5259
|
|
|
5290
|
-
function _optionalChain$
|
|
5260
|
+
function _optionalChain$e(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
5291
5261
|
class YAMLSeq extends Collection {
|
|
5292
5262
|
static get tagName() {
|
|
5293
5263
|
return 'tag:yaml.org,2002:seq';
|
|
@@ -5350,7 +5320,7 @@ class YAMLSeq extends Collection {
|
|
|
5350
5320
|
}
|
|
5351
5321
|
toJSON(_, ctx) {
|
|
5352
5322
|
const seq = [];
|
|
5353
|
-
if (_optionalChain$
|
|
5323
|
+
if (_optionalChain$e([ctx, 'optionalAccess', _2 => _2.onCreate]))
|
|
5354
5324
|
ctx.onCreate(seq);
|
|
5355
5325
|
let i = 0;
|
|
5356
5326
|
for (const item of this.items)
|
|
@@ -5429,7 +5399,7 @@ function createPairs(schema, iterable, ctx) {
|
|
|
5429
5399
|
return pairs;
|
|
5430
5400
|
}
|
|
5431
5401
|
|
|
5432
|
-
function _optionalChain$
|
|
5402
|
+
function _optionalChain$d(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
5433
5403
|
class YAMLOMap extends YAMLSeq {
|
|
5434
5404
|
constructor() {
|
|
5435
5405
|
super();
|
|
@@ -5448,7 +5418,7 @@ class YAMLOMap extends YAMLSeq {
|
|
|
5448
5418
|
if (!ctx)
|
|
5449
5419
|
return super.toJSON(_);
|
|
5450
5420
|
const map = new Map();
|
|
5451
|
-
if (_optionalChain$
|
|
5421
|
+
if (_optionalChain$d([ctx, 'optionalAccess', _2 => _2.onCreate]))
|
|
5452
5422
|
ctx.onCreate(map);
|
|
5453
5423
|
for (const pair of this.items) {
|
|
5454
5424
|
let key, value;
|
|
@@ -5566,7 +5536,7 @@ const isDirExists = async (file) => {
|
|
|
5566
5536
|
}
|
|
5567
5537
|
};
|
|
5568
5538
|
|
|
5569
|
-
function _optionalChain$
|
|
5539
|
+
function _optionalChain$c(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// ABOUTME: Project type detection utility
|
|
5570
5540
|
|
|
5571
5541
|
/**
|
|
5572
5542
|
* 支持的项目类型枚举
|
|
@@ -5668,7 +5638,7 @@ const collectProjectInfo = async (
|
|
|
5668
5638
|
}
|
|
5669
5639
|
|
|
5670
5640
|
const scripts = Object.entries(
|
|
5671
|
-
(_optionalChain$
|
|
5641
|
+
(_optionalChain$c([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
|
|
5672
5642
|
).reduce((acc, [name, script]) => {
|
|
5673
5643
|
if (typeof script === 'string') {
|
|
5674
5644
|
acc[name] = script;
|
|
@@ -5822,7 +5792,7 @@ const detectProjectType = async (
|
|
|
5822
5792
|
};
|
|
5823
5793
|
};
|
|
5824
5794
|
|
|
5825
|
-
function _optionalChain$
|
|
5795
|
+
function _optionalChain$b(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
5826
5796
|
|
|
5827
5797
|
|
|
5828
5798
|
/**
|
|
@@ -5996,16 +5966,16 @@ const getCommandConfig = (
|
|
|
5996
5966
|
|
|
5997
5967
|
switch (commandName) {
|
|
5998
5968
|
case 'dev':
|
|
5999
|
-
commandConfig = _optionalChain$
|
|
5969
|
+
commandConfig = _optionalChain$b([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
|
|
6000
5970
|
break;
|
|
6001
5971
|
case 'build':
|
|
6002
|
-
commandConfig = _optionalChain$
|
|
5972
|
+
commandConfig = _optionalChain$b([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
|
|
6003
5973
|
break;
|
|
6004
5974
|
case 'start':
|
|
6005
|
-
commandConfig = _optionalChain$
|
|
5975
|
+
commandConfig = _optionalChain$b([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
|
|
6006
5976
|
break;
|
|
6007
5977
|
case 'validate':
|
|
6008
|
-
commandConfig = _optionalChain$
|
|
5978
|
+
commandConfig = _optionalChain$b([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
|
|
6009
5979
|
break;
|
|
6010
5980
|
default:
|
|
6011
5981
|
throw new Error(`Unknown command: ${commandName}`);
|
|
@@ -6156,16 +6126,16 @@ const byFlag = (flag) => {
|
|
|
6156
6126
|
return predicate;
|
|
6157
6127
|
};
|
|
6158
6128
|
|
|
6159
|
-
function _optionalChain$
|
|
6129
|
+
function _optionalChain$a(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
6160
6130
|
|
|
6161
6131
|
|
|
6162
6132
|
|
|
6163
6133
|
|
|
6164
6134
|
|
|
6165
6135
|
|
|
6166
|
-
const PATCH_ID$
|
|
6136
|
+
const PATCH_ID$7 = 'expo/validate@0.0.20';
|
|
6167
6137
|
const PACKAGE_JSON_FILE$4 = 'package.json';
|
|
6168
|
-
const VALIDATE_SCRIPT_FILE$
|
|
6138
|
+
const VALIDATE_SCRIPT_FILE$4 = '.cozeproj/scripts/validate.sh';
|
|
6169
6139
|
const EXPO_VALIDATE_FLAG = 'coding.arch.patch_expo_validate';
|
|
6170
6140
|
const TARGET_VALIDATE$3 = "pnpm run --parallel '/^(lint:client|lint:server)$/'";
|
|
6171
6141
|
const TARGET_VALIDATE_SCRIPT$3 = `#!/bin/bash
|
|
@@ -6187,7 +6157,7 @@ echo "Validate passed!"
|
|
|
6187
6157
|
* @returns
|
|
6188
6158
|
*/
|
|
6189
6159
|
const isCozeValid$3 = (cozeConfig) => {
|
|
6190
|
-
if (_optionalChain$
|
|
6160
|
+
if (_optionalChain$a([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6191
6161
|
logger.info('[patch-expo-validate] NOT APPLY: dev.validate exists');
|
|
6192
6162
|
return false;
|
|
6193
6163
|
}
|
|
@@ -6239,7 +6209,7 @@ const isPackageJsonValid$3 = async (projectFolder) => {
|
|
|
6239
6209
|
* @returns
|
|
6240
6210
|
*/
|
|
6241
6211
|
const isScriptValid$3 = async (projectFolder) => {
|
|
6242
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$
|
|
6212
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$4);
|
|
6243
6213
|
if (await isFileExists(validateScriptPath)) {
|
|
6244
6214
|
logger.info('NOT APPLY: validate.sh already exists');
|
|
6245
6215
|
return false;
|
|
@@ -6273,7 +6243,7 @@ const patchPackageJson$3 = async (projectFolder) => {
|
|
|
6273
6243
|
* @returns
|
|
6274
6244
|
*/
|
|
6275
6245
|
const patchValidateScript$3 = async (projectFolder) => {
|
|
6276
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$
|
|
6246
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$4);
|
|
6277
6247
|
await fs$1.mkdir(path.join(projectFolder, '.cozeproj', 'scripts'), { recursive: true });
|
|
6278
6248
|
await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT$3, 'utf-8');
|
|
6279
6249
|
logger.info('[patch-expo-validate] validate.sh patched');
|
|
@@ -6293,7 +6263,7 @@ const patchCoze$3 = (cozeConfig) => {
|
|
|
6293
6263
|
};
|
|
6294
6264
|
|
|
6295
6265
|
const patchExpoValidate = {
|
|
6296
|
-
id: PATCH_ID$
|
|
6266
|
+
id: PATCH_ID$7,
|
|
6297
6267
|
template: 'expo',
|
|
6298
6268
|
disabled: byFlag(EXPO_VALIDATE_FLAG),
|
|
6299
6269
|
operations: [
|
|
@@ -6304,7 +6274,7 @@ const patchExpoValidate = {
|
|
|
6304
6274
|
},
|
|
6305
6275
|
{
|
|
6306
6276
|
kind: 'create-file',
|
|
6307
|
-
file: VALIDATE_SCRIPT_FILE$
|
|
6277
|
+
file: VALIDATE_SCRIPT_FILE$4,
|
|
6308
6278
|
description: 'Add validate shell script for expo projects',
|
|
6309
6279
|
},
|
|
6310
6280
|
{
|
|
@@ -6326,22 +6296,22 @@ const patchExpoValidate = {
|
|
|
6326
6296
|
|
|
6327
6297
|
return {
|
|
6328
6298
|
applied: true,
|
|
6329
|
-
patchId: PATCH_ID$
|
|
6299
|
+
patchId: PATCH_ID$7,
|
|
6330
6300
|
message: 'expo validate patched',
|
|
6331
6301
|
};
|
|
6332
6302
|
},
|
|
6333
6303
|
};
|
|
6334
6304
|
|
|
6335
|
-
function _optionalChain$
|
|
6305
|
+
function _optionalChain$9(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
6336
6306
|
|
|
6337
6307
|
|
|
6338
6308
|
|
|
6339
6309
|
|
|
6340
6310
|
|
|
6341
6311
|
|
|
6342
|
-
const PATCH_ID$
|
|
6312
|
+
const PATCH_ID$6 = 'nextjs/validate@0.0.20';
|
|
6343
6313
|
const PACKAGE_JSON_FILE$3 = 'package.json';
|
|
6344
|
-
const VALIDATE_SCRIPT_FILE$
|
|
6314
|
+
const VALIDATE_SCRIPT_FILE$3 = 'scripts/validate.sh';
|
|
6345
6315
|
const NEXTJS_VALIDATE_FLAG = 'coding.arch.patch_nextjs_validate';
|
|
6346
6316
|
const TARGET_LINT_BUILD$2 = 'eslint . --quiet';
|
|
6347
6317
|
const TARGET_VALIDATE$2 = "pnpm run --parallel '/^(ts-check|lint:build)$/'";
|
|
@@ -6365,7 +6335,7 @@ echo "Validate passed!"
|
|
|
6365
6335
|
* @returns
|
|
6366
6336
|
*/
|
|
6367
6337
|
const isCozeValid$2 = (cozeConfig) => {
|
|
6368
|
-
if (_optionalChain$
|
|
6338
|
+
if (_optionalChain$9([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6369
6339
|
logger.info('[patch-nextjs-validate] NOT APPLY: dev.validate exists');
|
|
6370
6340
|
return false;
|
|
6371
6341
|
}
|
|
@@ -6413,7 +6383,7 @@ const isPackageJsonValid$2 = async (projectFolder) => {
|
|
|
6413
6383
|
* @returns
|
|
6414
6384
|
*/
|
|
6415
6385
|
const isScriptValid$2 = async (projectFolder) => {
|
|
6416
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$
|
|
6386
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$3);
|
|
6417
6387
|
if (await isFileExists(validateScriptPath)) {
|
|
6418
6388
|
logger.info(
|
|
6419
6389
|
'[patch-nextjs-validate] NOT APPLY: validate.sh already exists',
|
|
@@ -6454,7 +6424,7 @@ const patchPackageJson$2 = async (projectFolder) => {
|
|
|
6454
6424
|
* @returns
|
|
6455
6425
|
*/
|
|
6456
6426
|
const patchValidateScript$2 = async (projectFolder) => {
|
|
6457
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$
|
|
6427
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$3);
|
|
6458
6428
|
await fs$1.mkdir(path.join(projectFolder, 'scripts'), { recursive: true });
|
|
6459
6429
|
await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT$2, 'utf-8');
|
|
6460
6430
|
logger.info('[patch-nextjs-validate] validate.sh patched');
|
|
@@ -6474,7 +6444,7 @@ const patchCoze$2 = (cozeConfig) => {
|
|
|
6474
6444
|
};
|
|
6475
6445
|
|
|
6476
6446
|
const patchNextjsValidate = {
|
|
6477
|
-
id: PATCH_ID$
|
|
6447
|
+
id: PATCH_ID$6,
|
|
6478
6448
|
template: 'nextjs',
|
|
6479
6449
|
disabled: byFlag(NEXTJS_VALIDATE_FLAG),
|
|
6480
6450
|
operations: [
|
|
@@ -6485,7 +6455,7 @@ const patchNextjsValidate = {
|
|
|
6485
6455
|
},
|
|
6486
6456
|
{
|
|
6487
6457
|
kind: 'create-file',
|
|
6488
|
-
file: VALIDATE_SCRIPT_FILE$
|
|
6458
|
+
file: VALIDATE_SCRIPT_FILE$3,
|
|
6489
6459
|
description: 'Add validate shell script for nextjs projects',
|
|
6490
6460
|
},
|
|
6491
6461
|
{
|
|
@@ -6507,22 +6477,22 @@ const patchNextjsValidate = {
|
|
|
6507
6477
|
|
|
6508
6478
|
return {
|
|
6509
6479
|
applied: true,
|
|
6510
|
-
patchId: PATCH_ID$
|
|
6480
|
+
patchId: PATCH_ID$6,
|
|
6511
6481
|
message: 'nextjs validate patched',
|
|
6512
6482
|
};
|
|
6513
6483
|
},
|
|
6514
6484
|
};
|
|
6515
6485
|
|
|
6516
|
-
function _optionalChain$
|
|
6486
|
+
function _optionalChain$8(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
6517
6487
|
|
|
6518
6488
|
|
|
6519
6489
|
|
|
6520
6490
|
|
|
6521
6491
|
|
|
6522
6492
|
|
|
6523
|
-
const PATCH_ID$
|
|
6493
|
+
const PATCH_ID$5 = 'vite/validate@0.0.20';
|
|
6524
6494
|
const PACKAGE_JSON_FILE$2 = 'package.json';
|
|
6525
|
-
const VALIDATE_SCRIPT_FILE$
|
|
6495
|
+
const VALIDATE_SCRIPT_FILE$2 = 'scripts/validate.sh';
|
|
6526
6496
|
const VITE_VALIDATE_FLAG = 'coding.arch.patch_vite_validate';
|
|
6527
6497
|
const TARGET_LINT_BUILD$1 = 'eslint . --quiet';
|
|
6528
6498
|
const TARGET_VALIDATE$1 = "pnpm run --parallel '/^(ts-check|lint:build)$/'";
|
|
@@ -6546,7 +6516,7 @@ echo "Validate passed!"
|
|
|
6546
6516
|
* @returns
|
|
6547
6517
|
*/
|
|
6548
6518
|
const isCozeValid$1 = (cozeConfig) => {
|
|
6549
|
-
if (_optionalChain$
|
|
6519
|
+
if (_optionalChain$8([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6550
6520
|
logger.info('[patch-vite-validate] NOT APPLY: dev.validate exists');
|
|
6551
6521
|
return false;
|
|
6552
6522
|
}
|
|
@@ -6594,7 +6564,7 @@ const isPackageJsonValid$1 = async (projectFolder) => {
|
|
|
6594
6564
|
* @returns
|
|
6595
6565
|
*/
|
|
6596
6566
|
const isScriptValid$1 = async (projectFolder) => {
|
|
6597
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$
|
|
6567
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$2);
|
|
6598
6568
|
if (await isFileExists(validateScriptPath)) {
|
|
6599
6569
|
logger.info('[patch-vite-validate] NOT APPLY: validate.sh already exists');
|
|
6600
6570
|
return false;
|
|
@@ -6632,7 +6602,7 @@ const patchPackageJson$1 = async (projectFolder) => {
|
|
|
6632
6602
|
* @returns
|
|
6633
6603
|
*/
|
|
6634
6604
|
const patchValidateScript$1 = async (projectFolder) => {
|
|
6635
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$
|
|
6605
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$2);
|
|
6636
6606
|
await fs$1.mkdir(path.join(projectFolder, 'scripts'), { recursive: true });
|
|
6637
6607
|
await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT$1, 'utf-8');
|
|
6638
6608
|
logger.info('[patch-vite-validate] validate.sh patched');
|
|
@@ -6652,7 +6622,7 @@ const patchCoze$1 = (cozeConfig) => {
|
|
|
6652
6622
|
};
|
|
6653
6623
|
|
|
6654
6624
|
const patchViteValidate = {
|
|
6655
|
-
id: PATCH_ID$
|
|
6625
|
+
id: PATCH_ID$5,
|
|
6656
6626
|
template: 'vite',
|
|
6657
6627
|
disabled: byFlag(VITE_VALIDATE_FLAG),
|
|
6658
6628
|
operations: [
|
|
@@ -6663,7 +6633,7 @@ const patchViteValidate = {
|
|
|
6663
6633
|
},
|
|
6664
6634
|
{
|
|
6665
6635
|
kind: 'create-file',
|
|
6666
|
-
file: VALIDATE_SCRIPT_FILE$
|
|
6636
|
+
file: VALIDATE_SCRIPT_FILE$2,
|
|
6667
6637
|
description: 'Add validate shell script for vite projects',
|
|
6668
6638
|
},
|
|
6669
6639
|
{
|
|
@@ -6685,22 +6655,22 @@ const patchViteValidate = {
|
|
|
6685
6655
|
|
|
6686
6656
|
return {
|
|
6687
6657
|
applied: true,
|
|
6688
|
-
patchId: PATCH_ID$
|
|
6658
|
+
patchId: PATCH_ID$5,
|
|
6689
6659
|
message: 'vite validate patched',
|
|
6690
6660
|
};
|
|
6691
6661
|
},
|
|
6692
6662
|
};
|
|
6693
6663
|
|
|
6694
|
-
function _optionalChain$
|
|
6664
|
+
function _optionalChain$7(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
6695
6665
|
|
|
6696
6666
|
|
|
6697
6667
|
|
|
6698
6668
|
|
|
6699
6669
|
|
|
6700
6670
|
|
|
6701
|
-
const PATCH_ID$
|
|
6671
|
+
const PATCH_ID$4 = 'taro/validate@0.0.20';
|
|
6702
6672
|
const PACKAGE_JSON_FILE$1 = 'package.json';
|
|
6703
|
-
const VALIDATE_SCRIPT_FILE = '.cozeproj/scripts/validate.sh';
|
|
6673
|
+
const VALIDATE_SCRIPT_FILE$1 = '.cozeproj/scripts/validate.sh';
|
|
6704
6674
|
const TARO_VALIDATE_FLAG = 'coding.arch.patch_taro_validate';
|
|
6705
6675
|
|
|
6706
6676
|
const LEGACY_LINT_BUILD =
|
|
@@ -6728,7 +6698,7 @@ echo "Validate passed!"
|
|
|
6728
6698
|
* @returns
|
|
6729
6699
|
*/
|
|
6730
6700
|
const isCozeValid = (cozeConfig) => {
|
|
6731
|
-
if (_optionalChain$
|
|
6701
|
+
if (_optionalChain$7([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6732
6702
|
logger.info('[patch-taro-validate] NOT APPLY: dev.validate exists');
|
|
6733
6703
|
return false;
|
|
6734
6704
|
}
|
|
@@ -6778,7 +6748,7 @@ const isPackageJsonValid = async (projectFolder) => {
|
|
|
6778
6748
|
* @returns
|
|
6779
6749
|
*/
|
|
6780
6750
|
const isScriptValid = async (projectFolder) => {
|
|
6781
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE);
|
|
6751
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$1);
|
|
6782
6752
|
if (await isFileExists(validateScriptPath)) {
|
|
6783
6753
|
logger.info('[patch-taro-validate] NOT APPLY: validate.sh already exists');
|
|
6784
6754
|
return false;
|
|
@@ -6819,7 +6789,7 @@ const patchPackageJson = async (projectFolder) => {
|
|
|
6819
6789
|
* @returns
|
|
6820
6790
|
*/
|
|
6821
6791
|
const patchValidateScript = async (projectFolder) => {
|
|
6822
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE);
|
|
6792
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$1);
|
|
6823
6793
|
await fs$1.mkdir(path.join(projectFolder, '.cozeproj', 'scripts'), { recursive: true });
|
|
6824
6794
|
await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT, 'utf-8');
|
|
6825
6795
|
logger.info('[patch-taro-validate] validate.sh patched');
|
|
@@ -6839,7 +6809,7 @@ const patchCoze = (cozeConfig) => {
|
|
|
6839
6809
|
};
|
|
6840
6810
|
|
|
6841
6811
|
const patchTaroValidate = {
|
|
6842
|
-
id: PATCH_ID$
|
|
6812
|
+
id: PATCH_ID$4,
|
|
6843
6813
|
template: 'taro',
|
|
6844
6814
|
disabled: byFlag(TARO_VALIDATE_FLAG),
|
|
6845
6815
|
operations: [
|
|
@@ -6851,7 +6821,7 @@ const patchTaroValidate = {
|
|
|
6851
6821
|
},
|
|
6852
6822
|
{
|
|
6853
6823
|
kind: 'create-file',
|
|
6854
|
-
file: VALIDATE_SCRIPT_FILE,
|
|
6824
|
+
file: VALIDATE_SCRIPT_FILE$1,
|
|
6855
6825
|
description: 'Add validate shell script for taro projects',
|
|
6856
6826
|
},
|
|
6857
6827
|
{
|
|
@@ -6871,14 +6841,14 @@ const patchTaroValidate = {
|
|
|
6871
6841
|
|
|
6872
6842
|
return {
|
|
6873
6843
|
applied: true,
|
|
6874
|
-
patchId: PATCH_ID$
|
|
6844
|
+
patchId: PATCH_ID$4,
|
|
6875
6845
|
message: 'taro validate patched',
|
|
6876
6846
|
};
|
|
6877
6847
|
},
|
|
6878
6848
|
};
|
|
6879
6849
|
|
|
6880
|
-
function _optionalChain$
|
|
6881
|
-
const PATCH_ID$
|
|
6850
|
+
function _optionalChain$6(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
6851
|
+
const PATCH_ID$3 = 'taro/update-pack-script-for-tt-build@0.0.13';
|
|
6882
6852
|
const PACKAGE_JSON_FILE = 'package.json';
|
|
6883
6853
|
const PACK_SCRIPT_FILE = '.cozeproj/scripts/pack.sh';
|
|
6884
6854
|
const LEGACY_PACK_SCRIPT_HASHES = new Set([
|
|
@@ -6956,12 +6926,12 @@ const readPackageScripts = async (
|
|
|
6956
6926
|
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6957
6927
|
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
6958
6928
|
|
|
6959
|
-
return _optionalChain$
|
|
6929
|
+
return _optionalChain$6([packageJson, 'optionalAccess', _ => _.scripts]) || null;
|
|
6960
6930
|
};
|
|
6961
6931
|
|
|
6962
6932
|
const hasBuildTtScript = async (projectFolder) => {
|
|
6963
6933
|
const scripts = await readPackageScripts(projectFolder);
|
|
6964
|
-
return typeof _optionalChain$
|
|
6934
|
+
return typeof _optionalChain$6([scripts, 'optionalAccess', _2 => _2['build:tt']]) === 'string';
|
|
6965
6935
|
};
|
|
6966
6936
|
|
|
6967
6937
|
const hasLegacyPackScript = async (projectFolder) => {
|
|
@@ -6975,7 +6945,7 @@ const hasLegacyPackScript = async (projectFolder) => {
|
|
|
6975
6945
|
};
|
|
6976
6946
|
|
|
6977
6947
|
const patchTaroPackScript = {
|
|
6978
|
-
id: PATCH_ID$
|
|
6948
|
+
id: PATCH_ID$3,
|
|
6979
6949
|
template: 'taro',
|
|
6980
6950
|
disabled: byFlag('coding.arch.patch_taro_update_pack_script_for_tt_build'),
|
|
6981
6951
|
operations: [
|
|
@@ -6994,7 +6964,7 @@ const patchTaroPackScript = {
|
|
|
6994
6964
|
if (context.template !== 'taro') {
|
|
6995
6965
|
return {
|
|
6996
6966
|
applied: false,
|
|
6997
|
-
patchId: PATCH_ID$
|
|
6967
|
+
patchId: PATCH_ID$3,
|
|
6998
6968
|
message: 'Only applies to taro projects, skipping',
|
|
6999
6969
|
};
|
|
7000
6970
|
}
|
|
@@ -7002,7 +6972,7 @@ const patchTaroPackScript = {
|
|
|
7002
6972
|
if (!(await hasBuildTtScript(context.projectFolder))) {
|
|
7003
6973
|
return {
|
|
7004
6974
|
applied: false,
|
|
7005
|
-
patchId: PATCH_ID$
|
|
6975
|
+
patchId: PATCH_ID$3,
|
|
7006
6976
|
message: 'package.json does not contain build:tt, skipping',
|
|
7007
6977
|
};
|
|
7008
6978
|
}
|
|
@@ -7010,7 +6980,7 @@ const patchTaroPackScript = {
|
|
|
7010
6980
|
if (!(await hasLegacyPackScript(context.projectFolder))) {
|
|
7011
6981
|
return {
|
|
7012
6982
|
applied: false,
|
|
7013
|
-
patchId: PATCH_ID$
|
|
6983
|
+
patchId: PATCH_ID$3,
|
|
7014
6984
|
message: 'pack.sh does not match legacy template hash, skipping',
|
|
7015
6985
|
};
|
|
7016
6986
|
}
|
|
@@ -7024,13 +6994,13 @@ const patchTaroPackScript = {
|
|
|
7024
6994
|
|
|
7025
6995
|
return {
|
|
7026
6996
|
applied: true,
|
|
7027
|
-
patchId: PATCH_ID$
|
|
6997
|
+
patchId: PATCH_ID$3,
|
|
7028
6998
|
message: 'Updated legacy pack.sh to build weapp and tt targets',
|
|
7029
6999
|
};
|
|
7030
7000
|
},
|
|
7031
7001
|
};
|
|
7032
7002
|
|
|
7033
|
-
const PATCH_ID$
|
|
7003
|
+
const PATCH_ID$2 = 'taro/add-agents-md@0.0.13';
|
|
7034
7004
|
const AGENTS_FILE = 'AGENTS.md';
|
|
7035
7005
|
const getTemplateAgentsPath = () =>
|
|
7036
7006
|
path.join(getTemplatesDir(), 'taro', AGENTS_FILE);
|
|
@@ -7042,7 +7012,7 @@ const readTemplateAgentsContent = async () =>
|
|
|
7042
7012
|
fs$1.readFile(getTemplateAgentsPath(), 'utf-8');
|
|
7043
7013
|
|
|
7044
7014
|
const patchTaroAgentsMd = {
|
|
7045
|
-
id: PATCH_ID$
|
|
7015
|
+
id: PATCH_ID$2,
|
|
7046
7016
|
template: 'taro',
|
|
7047
7017
|
disabled: byFlag('coding.arch.patch_taro_add_agents_md'),
|
|
7048
7018
|
operations: [
|
|
@@ -7060,7 +7030,7 @@ const patchTaroAgentsMd = {
|
|
|
7060
7030
|
if (context.template !== 'taro') {
|
|
7061
7031
|
return {
|
|
7062
7032
|
applied: false,
|
|
7063
|
-
patchId: PATCH_ID$
|
|
7033
|
+
patchId: PATCH_ID$2,
|
|
7064
7034
|
message: 'Only applies to taro projects, skipping',
|
|
7065
7035
|
};
|
|
7066
7036
|
}
|
|
@@ -7069,7 +7039,7 @@ const patchTaroAgentsMd = {
|
|
|
7069
7039
|
if (await isFileExists(targetPath)) {
|
|
7070
7040
|
return {
|
|
7071
7041
|
applied: false,
|
|
7072
|
-
patchId: PATCH_ID$
|
|
7042
|
+
patchId: PATCH_ID$2,
|
|
7073
7043
|
message: 'AGENTS.md already exists, skipping',
|
|
7074
7044
|
};
|
|
7075
7045
|
}
|
|
@@ -7079,12 +7049,160 @@ const patchTaroAgentsMd = {
|
|
|
7079
7049
|
|
|
7080
7050
|
return {
|
|
7081
7051
|
applied: true,
|
|
7082
|
-
patchId: PATCH_ID$
|
|
7052
|
+
patchId: PATCH_ID$2,
|
|
7083
7053
|
message: 'Created AGENTS.md from taro template',
|
|
7084
7054
|
};
|
|
7085
7055
|
},
|
|
7086
7056
|
};
|
|
7087
7057
|
|
|
7058
|
+
function _nullishCoalesce$5(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
7059
|
+
|
|
7060
|
+
|
|
7061
|
+
|
|
7062
|
+
|
|
7063
|
+
|
|
7064
|
+
const OLD_WEB_VALIDATE_WITH_STYLE = "pnpm run --parallel '/^(ts-check|lint:build|lint:style)$/'";
|
|
7065
|
+
const OLD_WEB_VALIDATE_WITHOUT_STYLE = "pnpm run --parallel '/^(ts-check|lint:build)$/'";
|
|
7066
|
+
const JSON_INDENT$1 = 2;
|
|
7067
|
+
|
|
7068
|
+
const OLD_WEB_TEMPLATE_VALIDATE_SCRIPT = `#!/bin/bash
|
|
7069
|
+
set -Eeuo pipefail
|
|
7070
|
+
|
|
7071
|
+
COZE_WORKSPACE_PATH="\${COZE_WORKSPACE_PATH:-$(pwd)}"
|
|
7072
|
+
|
|
7073
|
+
cd "\${COZE_WORKSPACE_PATH}"
|
|
7074
|
+
|
|
7075
|
+
echo "\u{1F50D} Running validate..."
|
|
7076
|
+
pnpm validate
|
|
7077
|
+
echo "\u{2705} Validate passed!"
|
|
7078
|
+
`;
|
|
7079
|
+
|
|
7080
|
+
const OLD_WEB_PATCH_VALIDATE_SCRIPT = `#!/bin/bash
|
|
7081
|
+
set -Eeuo pipefail
|
|
7082
|
+
COZE_WORKSPACE_PATH="\${COZE_WORKSPACE_PATH:-$(pwd)}"
|
|
7083
|
+
cd "\${COZE_WORKSPACE_PATH}"
|
|
7084
|
+
echo "Running validate..."
|
|
7085
|
+
pnpm validate
|
|
7086
|
+
echo "Validate passed!"
|
|
7087
|
+
`;
|
|
7088
|
+
|
|
7089
|
+
const createValidateScript = (parallelArgs) => `#!/bin/bash
|
|
7090
|
+
set -Eeuo pipefail
|
|
7091
|
+
|
|
7092
|
+
COZE_WORKSPACE_PATH="\${COZE_WORKSPACE_PATH:-$(pwd)}"
|
|
7093
|
+
|
|
7094
|
+
cd "\${COZE_WORKSPACE_PATH}"
|
|
7095
|
+
|
|
7096
|
+
echo "Running validate..."
|
|
7097
|
+
coze-dev parallel ${parallelArgs}
|
|
7098
|
+
echo "Validate passed!"
|
|
7099
|
+
`;
|
|
7100
|
+
|
|
7101
|
+
const VALIDATE_SCRIPT_FILE = 'scripts/validate.sh';
|
|
7102
|
+
|
|
7103
|
+
const isKnownOldValidateScript = (content) => [OLD_WEB_TEMPLATE_VALIDATE_SCRIPT, OLD_WEB_PATCH_VALIDATE_SCRIPT].includes(content);
|
|
7104
|
+
|
|
7105
|
+
const loadPackageJson = async (projectFolder) => {
|
|
7106
|
+
const packageJsonPath = path.join(projectFolder, 'package.json');
|
|
7107
|
+
if (!(await isFileExists(packageJsonPath))) {
|
|
7108
|
+
return null;
|
|
7109
|
+
}
|
|
7110
|
+
|
|
7111
|
+
const content = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
7112
|
+
const packageJson = safeJsonParse(content, null);
|
|
7113
|
+
if (!packageJson) {
|
|
7114
|
+
return null;
|
|
7115
|
+
}
|
|
7116
|
+
|
|
7117
|
+
return { path: packageJsonPath, json: packageJson };
|
|
7118
|
+
};
|
|
7119
|
+
|
|
7120
|
+
const getParallelArgs = (packageJson) => {
|
|
7121
|
+
const validate = _optionalChain$5([packageJson, 'optionalAccess', _ => _.scripts, 'optionalAccess', _2 => _2.validate]);
|
|
7122
|
+
if (validate === OLD_WEB_VALIDATE_WITHOUT_STYLE) {
|
|
7123
|
+
return 'ts-check lint:build';
|
|
7124
|
+
}
|
|
7125
|
+
|
|
7126
|
+
if (validate === OLD_WEB_VALIDATE_WITH_STYLE) {
|
|
7127
|
+
return 'ts-check lint:build lint:style';
|
|
7128
|
+
}
|
|
7129
|
+
|
|
7130
|
+
return typeof _optionalChain$5([packageJson, 'optionalAccess', _3 => _3.scripts, 'optionalAccess', _4 => _4['lint:style']]) === 'string' ? 'ts-check lint:build lint:style' : 'ts-check lint:build';
|
|
7131
|
+
};
|
|
7132
|
+
|
|
7133
|
+
const updatePackageValidate = async (packageJsonInfo, parallelArgs) => {
|
|
7134
|
+
if (!_optionalChain$5([packageJsonInfo, 'optionalAccess', _5 => _5.json, 'access', _6 => _6.scripts])) {
|
|
7135
|
+
return false;
|
|
7136
|
+
}
|
|
7137
|
+
|
|
7138
|
+
const oldValidate = packageJsonInfo.json.scripts.validate;
|
|
7139
|
+
const shouldUpdate = oldValidate === OLD_WEB_VALIDATE_WITH_STYLE || oldValidate === OLD_WEB_VALIDATE_WITHOUT_STYLE;
|
|
7140
|
+
|
|
7141
|
+
if (!shouldUpdate) {
|
|
7142
|
+
return false;
|
|
7143
|
+
}
|
|
7144
|
+
|
|
7145
|
+
packageJsonInfo.json.scripts.validate = `coze-dev parallel ${parallelArgs}`;
|
|
7146
|
+
await fs$1.writeFile(packageJsonInfo.path, `${JSON.stringify(packageJsonInfo.json, null, JSON_INDENT$1)}\n`, 'utf-8');
|
|
7147
|
+
return true;
|
|
7148
|
+
};
|
|
7149
|
+
|
|
7150
|
+
const applyValidateRunnerPatch = async (context, patchId) => {
|
|
7151
|
+
const validateScriptPath = path.join(context.projectFolder, VALIDATE_SCRIPT_FILE);
|
|
7152
|
+
const content = await fs$1.readFile(validateScriptPath, 'utf-8');
|
|
7153
|
+
|
|
7154
|
+
if (!isKnownOldValidateScript(content)) {
|
|
7155
|
+
return {
|
|
7156
|
+
applied: false,
|
|
7157
|
+
patchId,
|
|
7158
|
+
message: 'validate.sh content is not a known old version, skipping',
|
|
7159
|
+
};
|
|
7160
|
+
}
|
|
7161
|
+
|
|
7162
|
+
const packageJsonInfo = await loadPackageJson(context.projectFolder);
|
|
7163
|
+
const parallelArgs = getParallelArgs(_nullishCoalesce$5(_optionalChain$5([packageJsonInfo, 'optionalAccess', _7 => _7.json]), () => ( null)));
|
|
7164
|
+
await fs$1.writeFile(validateScriptPath, createValidateScript(parallelArgs), 'utf-8');
|
|
7165
|
+
const packageJsonUpdated = await updatePackageValidate(packageJsonInfo, parallelArgs);
|
|
7166
|
+
|
|
7167
|
+
logger.info(`Patched ${VALIDATE_SCRIPT_FILE}: use coze-dev parallel`);
|
|
7168
|
+
|
|
7169
|
+
return {
|
|
7170
|
+
applied: true,
|
|
7171
|
+
patchId,
|
|
7172
|
+
message: packageJsonUpdated ? 'Updated validate.sh and package validate script' : 'Updated validate.sh',
|
|
7173
|
+
};
|
|
7174
|
+
};
|
|
7175
|
+
|
|
7176
|
+
const PATCH_ID$1 = 'nextjs/validate-runner@0.0.31';
|
|
7177
|
+
|
|
7178
|
+
const patchNextjsValidateRunner = {
|
|
7179
|
+
id: PATCH_ID$1,
|
|
7180
|
+
template: 'nextjs',
|
|
7181
|
+
disabled: byFlag('coding.arch.patch_nextjs_validate_runner'),
|
|
7182
|
+
operations: [
|
|
7183
|
+
{
|
|
7184
|
+
kind: 'file-patch',
|
|
7185
|
+
file: VALIDATE_SCRIPT_FILE,
|
|
7186
|
+
description: 'Update validate shell script to use coze-dev parallel',
|
|
7187
|
+
},
|
|
7188
|
+
{
|
|
7189
|
+
kind: 'file-patch',
|
|
7190
|
+
file: 'package.json',
|
|
7191
|
+
description: 'Update validate package script when it matches old pnpm run form',
|
|
7192
|
+
},
|
|
7193
|
+
],
|
|
7194
|
+
shouldApply: async context => {
|
|
7195
|
+
const validateScriptPath = path.join(context.projectFolder, VALIDATE_SCRIPT_FILE);
|
|
7196
|
+
if (!(await isFileExists(validateScriptPath))) {
|
|
7197
|
+
return false;
|
|
7198
|
+
}
|
|
7199
|
+
|
|
7200
|
+
const content = await fs$1.readFile(validateScriptPath, 'utf-8');
|
|
7201
|
+
return isKnownOldValidateScript(content);
|
|
7202
|
+
},
|
|
7203
|
+
apply: context => applyValidateRunnerPatch(context, PATCH_ID$1),
|
|
7204
|
+
};
|
|
7205
|
+
|
|
7088
7206
|
const SCRIPT_FILES = ['dev.sh', 'build.sh'] ;
|
|
7089
7207
|
const SUPPORTED_TEMPLATES = new Set(['nextjs', 'vite', 'nuxt-vue']);
|
|
7090
7208
|
|
|
@@ -7300,6 +7418,7 @@ const patches = [
|
|
|
7300
7418
|
patchExpoValidate,
|
|
7301
7419
|
replaceNpxWithPnpmPatchNextjs,
|
|
7302
7420
|
patchNextjsValidate,
|
|
7421
|
+
patchNextjsValidateRunner,
|
|
7303
7422
|
replaceNpxWithPnpmPatchVite,
|
|
7304
7423
|
patchViteValidate,
|
|
7305
7424
|
replaceNpxWithPnpmPatchNuxtVue,
|
|
@@ -7309,12 +7428,9 @@ const patches = [
|
|
|
7309
7428
|
patchTaroPackScript,
|
|
7310
7429
|
] ;
|
|
7311
7430
|
|
|
7312
|
-
const getTemplatePatches = (
|
|
7313
|
-
template,
|
|
7314
|
-
) =>
|
|
7315
|
-
patches.filter(patch => patch.template === template);
|
|
7431
|
+
const getTemplatePatches = (template) => patches.filter(patch => patch.template === template);
|
|
7316
7432
|
|
|
7317
|
-
function _nullishCoalesce$
|
|
7433
|
+
function _nullishCoalesce$4(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
7318
7434
|
const DEFAULT_LEGACY_VERSION = 'legacy';
|
|
7319
7435
|
|
|
7320
7436
|
const loadFlagsWithFallback = async () => {
|
|
@@ -7420,7 +7536,7 @@ const getNextPatchState = (
|
|
|
7420
7536
|
|
|
7421
7537
|
) => ({
|
|
7422
7538
|
template,
|
|
7423
|
-
version: _optionalChain$
|
|
7539
|
+
version: _optionalChain$4([config, 'access', _ => _.project, 'optionalAccess', _2 => _2.version]) || DEFAULT_LEGACY_VERSION,
|
|
7424
7540
|
appliedPatches: [...appliedPatches, patchId],
|
|
7425
7541
|
});
|
|
7426
7542
|
|
|
@@ -7444,15 +7560,15 @@ const executePatch = async (
|
|
|
7444
7560
|
}
|
|
7445
7561
|
|
|
7446
7562
|
const template =
|
|
7447
|
-
_optionalChain$
|
|
7563
|
+
_optionalChain$4([config, 'access', _3 => _3.project, 'optionalAccess', _4 => _4.template]) || (await detectTemplateKey(projectFolder));
|
|
7448
7564
|
|
|
7449
7565
|
if (!template) {
|
|
7450
7566
|
logger.info('Patch skipped: template not detected');
|
|
7451
7567
|
return;
|
|
7452
7568
|
}
|
|
7453
7569
|
|
|
7454
|
-
const appliedPatches = [...(_optionalChain$
|
|
7455
|
-
const projectVersion = _optionalChain$
|
|
7570
|
+
const appliedPatches = [...(_optionalChain$4([config, 'access', _5 => _5.project, 'optionalAccess', _6 => _6.appliedPatches]) || [])];
|
|
7571
|
+
const projectVersion = _optionalChain$4([config, 'access', _7 => _7.project, 'optionalAccess', _8 => _8.version]);
|
|
7456
7572
|
const flags = await loadFlagsWithFallback();
|
|
7457
7573
|
|
|
7458
7574
|
const context = {
|
|
@@ -7497,7 +7613,7 @@ const executePatch = async (
|
|
|
7497
7613
|
|
|
7498
7614
|
if (options.dryRun) {
|
|
7499
7615
|
logger.info(`Detected template: ${template}`);
|
|
7500
|
-
logger.info(`Current version: ${_nullishCoalesce$
|
|
7616
|
+
logger.info(`Current version: ${_nullishCoalesce$4(projectVersion, () => ( DEFAULT_LEGACY_VERSION))}`);
|
|
7501
7617
|
logger.info(`Applied patches: ${appliedPatches.join(', ') || '(none)'}`);
|
|
7502
7618
|
logger.info('Matched patches:');
|
|
7503
7619
|
matchedPatches.forEach(patch => {
|
|
@@ -7538,7 +7654,7 @@ const executePatch = async (
|
|
|
7538
7654
|
}
|
|
7539
7655
|
};
|
|
7540
7656
|
|
|
7541
|
-
const registerCommand$
|
|
7657
|
+
const registerCommand$5 = program => {
|
|
7542
7658
|
program
|
|
7543
7659
|
.command('patch')
|
|
7544
7660
|
.description('Apply template patches for existing projects')
|
|
@@ -7555,14 +7671,14 @@ const registerCommand$4 = program => {
|
|
|
7555
7671
|
) => {
|
|
7556
7672
|
await executePatch({
|
|
7557
7673
|
directory,
|
|
7558
|
-
dryRun: _optionalChain$
|
|
7559
|
-
showFlags: _optionalChain$
|
|
7674
|
+
dryRun: _optionalChain$4([command, 'optionalAccess', _9 => _9.dryRun]),
|
|
7675
|
+
showFlags: _optionalChain$4([command, 'optionalAccess', _10 => _10.showFlags]),
|
|
7560
7676
|
});
|
|
7561
7677
|
},
|
|
7562
7678
|
);
|
|
7563
7679
|
};
|
|
7564
7680
|
|
|
7565
|
-
function _nullishCoalesce$
|
|
7681
|
+
function _nullishCoalesce$3(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$3(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
7566
7682
|
const d$1 = debug('coze-init-cli:run');
|
|
7567
7683
|
|
|
7568
7684
|
/**
|
|
@@ -7595,14 +7711,11 @@ const createLogStream = (logFilePath) => {
|
|
|
7595
7711
|
const logDir = path.dirname(logFilePath);
|
|
7596
7712
|
|
|
7597
7713
|
// 确保日志目录存在
|
|
7598
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- resolved from config, not raw user input
|
|
7599
7714
|
if (!fs.existsSync(logDir)) {
|
|
7600
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- resolved from config, not raw user input
|
|
7601
7715
|
fs.mkdirSync(logDir, { recursive: true });
|
|
7602
7716
|
}
|
|
7603
7717
|
|
|
7604
7718
|
// 使用 'w' 标志覆盖之前的日志
|
|
7605
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- resolved from config, not raw user input
|
|
7606
7719
|
return fs.createWriteStream(logFilePath, { flags: 'w' });
|
|
7607
7720
|
};
|
|
7608
7721
|
|
|
@@ -7620,8 +7733,7 @@ const reportFailureAndExit = (
|
|
|
7620
7733
|
|
|
7621
7734
|
,
|
|
7622
7735
|
) => {
|
|
7623
|
-
const { commandName, cmdStartTime, options, categories, errorContext } =
|
|
7624
|
-
context;
|
|
7736
|
+
const { commandName, cmdStartTime, options, categories, errorContext } = context;
|
|
7625
7737
|
reportError(error, { command: commandName, ...errorContext });
|
|
7626
7738
|
reportCommandComplete(commandName, false, Date.now() - cmdStartTime, {
|
|
7627
7739
|
args: JSON.stringify(options),
|
|
@@ -7639,10 +7751,7 @@ const reportFailureAndExit = (
|
|
|
7639
7751
|
};
|
|
7640
7752
|
|
|
7641
7753
|
// eslint-disable-next-line @coze-arch/max-line-per-function, max-lines-per-function -- orchestrates fix+build+reporting
|
|
7642
|
-
const executeRun = async (
|
|
7643
|
-
commandName,
|
|
7644
|
-
options = {},
|
|
7645
|
-
) => {
|
|
7754
|
+
const executeRun = async (commandName, options = {}) => {
|
|
7646
7755
|
const cmdStartTime = Date.now();
|
|
7647
7756
|
let fixDuration = 0;
|
|
7648
7757
|
let buildStartTime = 0;
|
|
@@ -7666,10 +7775,7 @@ const executeRun = async (
|
|
|
7666
7775
|
await executePatch();
|
|
7667
7776
|
} catch (patchError) {
|
|
7668
7777
|
// patch errors are intentionally non-fatal: trace and proceed with the main command
|
|
7669
|
-
d$1(
|
|
7670
|
-
'patch step failed (continuing): %s',
|
|
7671
|
-
patchError instanceof Error ? patchError.message : String(patchError),
|
|
7672
|
-
);
|
|
7778
|
+
d$1('patch step failed (continuing): %s', patchError instanceof Error ? patchError.message : String(patchError));
|
|
7673
7779
|
}
|
|
7674
7780
|
fixDuration = Date.now() - fixStartTime;
|
|
7675
7781
|
logger.info('');
|
|
@@ -7703,12 +7809,12 @@ const executeRun = async (
|
|
|
7703
7809
|
}
|
|
7704
7810
|
|
|
7705
7811
|
// 将输出同时写入控制台和日志文件
|
|
7706
|
-
_optionalChain$
|
|
7812
|
+
_optionalChain$3([childProcess, 'access', _ => _.stdout, 'optionalAccess', _2 => _2.on, 'call', _3 => _3('data', (data) => {
|
|
7707
7813
|
process.stdout.write(data);
|
|
7708
7814
|
logStream.write(data);
|
|
7709
7815
|
})]);
|
|
7710
7816
|
|
|
7711
|
-
_optionalChain$
|
|
7817
|
+
_optionalChain$3([childProcess, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6('data', (data) => {
|
|
7712
7818
|
process.stderr.write(data);
|
|
7713
7819
|
logStream.write(data);
|
|
7714
7820
|
})]);
|
|
@@ -7721,7 +7827,7 @@ const executeRun = async (
|
|
|
7721
7827
|
const buildDuration = Date.now() - buildStartTime;
|
|
7722
7828
|
|
|
7723
7829
|
if (code !== 0) {
|
|
7724
|
-
const errorMessage = `Command exited with code ${_nullishCoalesce$
|
|
7830
|
+
const errorMessage = `Command exited with code ${_nullishCoalesce$3(code, () => ( 'unknown'))}${signal ? ` and signal ${signal}` : ''}`;
|
|
7725
7831
|
logger.error(errorMessage);
|
|
7726
7832
|
logger.error(`Check log file for details: ${logFilePath}`);
|
|
7727
7833
|
|
|
@@ -7733,12 +7839,12 @@ const executeRun = async (
|
|
|
7733
7839
|
categories: {
|
|
7734
7840
|
fixDuration: String(fixDuration),
|
|
7735
7841
|
buildDuration: String(buildDuration),
|
|
7736
|
-
exitCode: String(_nullishCoalesce$
|
|
7842
|
+
exitCode: String(_nullishCoalesce$3(code, () => ( 'unknown'))),
|
|
7737
7843
|
projectType,
|
|
7738
7844
|
},
|
|
7739
7845
|
errorContext: {
|
|
7740
|
-
exitCode: String(_nullishCoalesce$
|
|
7741
|
-
signal: _nullishCoalesce$
|
|
7846
|
+
exitCode: String(_nullishCoalesce$3(code, () => ( 'unknown'))),
|
|
7847
|
+
signal: _nullishCoalesce$3(signal, () => ( 'none')),
|
|
7742
7848
|
logFile: logFilePath,
|
|
7743
7849
|
projectType,
|
|
7744
7850
|
},
|
|
@@ -7814,7 +7920,7 @@ const executeRun = async (
|
|
|
7814
7920
|
/**
|
|
7815
7921
|
* 注册 dev/build/start 命令到 program
|
|
7816
7922
|
*/
|
|
7817
|
-
const registerCommand$
|
|
7923
|
+
const registerCommand$4 = program => {
|
|
7818
7924
|
// dev 命令
|
|
7819
7925
|
program
|
|
7820
7926
|
.command('dev')
|
|
@@ -8642,7 +8748,7 @@ const scanRoutesOnce = async (
|
|
|
8642
8748
|
}
|
|
8643
8749
|
};
|
|
8644
8750
|
|
|
8645
|
-
function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// Route manifest generation command
|
|
8751
|
+
function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// Route manifest generation command
|
|
8646
8752
|
|
|
8647
8753
|
|
|
8648
8754
|
const log = debug('coze:routes');
|
|
@@ -8730,7 +8836,7 @@ const executeRoutes = async (
|
|
|
8730
8836
|
/**
|
|
8731
8837
|
* Register routes command to program
|
|
8732
8838
|
*/
|
|
8733
|
-
const registerCommand$
|
|
8839
|
+
const registerCommand$3 = program => {
|
|
8734
8840
|
program
|
|
8735
8841
|
.command('routes')
|
|
8736
8842
|
.description('Generate routes manifest for the current project')
|
|
@@ -8743,14 +8849,13 @@ const registerCommand$2 = program => {
|
|
|
8743
8849
|
'Output file path (defaults to ~/.coze/routes.json)',
|
|
8744
8850
|
)
|
|
8745
8851
|
.action(async (directory, options) => {
|
|
8746
|
-
await executeRoutes({ directory, output: _optionalChain([options, 'optionalAccess', _ => _.output]) });
|
|
8852
|
+
await executeRoutes({ directory, output: _optionalChain$2([options, 'optionalAccess', _ => _.output]) });
|
|
8747
8853
|
});
|
|
8748
8854
|
};
|
|
8749
8855
|
|
|
8750
|
-
function _nullishCoalesce$
|
|
8856
|
+
function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
8751
8857
|
|
|
8752
8858
|
|
|
8753
|
-
const d = debug('coze-init-cli:check-bins');
|
|
8754
8859
|
|
|
8755
8860
|
|
|
8756
8861
|
|
|
@@ -8758,117 +8863,97 @@ const d = debug('coze-init-cli:check-bins');
|
|
|
8758
8863
|
|
|
8759
8864
|
|
|
8760
8865
|
|
|
8761
|
-
const checkBins = async (cwd, fix) => {
|
|
8762
|
-
d('starting check, cwd=%s fix=%s', cwd, fix);
|
|
8763
8866
|
|
|
8764
|
-
const pkgJson = safeJsonParse
|
|
8765
8867
|
|
|
8766
8868
|
|
|
8767
|
-
|
|
8869
|
+
const runScript = (script, options) =>
|
|
8870
|
+
new Promise(resolve => {
|
|
8871
|
+
const output = [];
|
|
8872
|
+
const child = child_process.spawn(options.packageManager, ['run', script], {
|
|
8873
|
+
cwd: options.cwd,
|
|
8874
|
+
env: process.env,
|
|
8875
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
8876
|
+
});
|
|
8768
8877
|
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8878
|
+
_optionalChain$1([child, 'access', _ => _.stdout, 'optionalAccess', _2 => _2.on, 'call', _3 => _3('data', data => {
|
|
8879
|
+
output.push(String(data));
|
|
8880
|
+
})]);
|
|
8881
|
+
_optionalChain$1([child, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6('data', data => {
|
|
8882
|
+
output.push(String(data));
|
|
8883
|
+
})]);
|
|
8884
|
+
child.on('error', error => {
|
|
8885
|
+
output.push(`${error.stack || error.message}\n`);
|
|
8886
|
+
resolve({
|
|
8887
|
+
script,
|
|
8888
|
+
code: 1,
|
|
8889
|
+
output: output.join(''),
|
|
8890
|
+
});
|
|
8891
|
+
});
|
|
8892
|
+
child.on('close', code => {
|
|
8893
|
+
resolve({
|
|
8894
|
+
script,
|
|
8895
|
+
code: _nullishCoalesce$2(code, () => ( 1)),
|
|
8896
|
+
output: output.join(''),
|
|
8897
|
+
});
|
|
8898
|
+
});
|
|
8772
8899
|
});
|
|
8773
8900
|
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
await Promise.all(
|
|
8781
|
-
allDeps.map(async depName => {
|
|
8782
|
-
let rawContent;
|
|
8783
|
-
try {
|
|
8784
|
-
rawContent = await fs$1.readFile(
|
|
8785
|
-
path.join(cwd, 'node_modules', depName, 'package.json'),
|
|
8786
|
-
'utf8',
|
|
8787
|
-
);
|
|
8788
|
-
} catch (err) {
|
|
8789
|
-
d('dep %s not found in node_modules: %s', depName, err);
|
|
8790
|
-
missing.push({ dep: depName, bin: '', reason: 'missing-package' });
|
|
8791
|
-
return;
|
|
8792
|
-
}
|
|
8793
|
-
const depPkg = safeJsonParse(
|
|
8794
|
-
rawContent,
|
|
8795
|
-
);
|
|
8796
|
-
if (!depPkg) {
|
|
8797
|
-
d('skipping %s: failed to parse package.json', depName);
|
|
8798
|
-
return;
|
|
8799
|
-
}
|
|
8800
|
-
|
|
8801
|
-
if (!depPkg.bin) {
|
|
8802
|
-
return;
|
|
8803
|
-
}
|
|
8804
|
-
|
|
8805
|
-
const bins =
|
|
8806
|
-
typeof depPkg.bin === 'string'
|
|
8807
|
-
? { [_nullishCoalesce$1(depName.split('/').pop(), () => ( depName))]: depPkg.bin }
|
|
8808
|
-
: depPkg.bin;
|
|
8809
|
-
|
|
8810
|
-
d('%s declares bins: %o', depName, Object.keys(bins));
|
|
8901
|
+
const runParallelScripts = async (scripts, options = {}) => {
|
|
8902
|
+
if (scripts.length === 0) {
|
|
8903
|
+
process.stderr.write('No scripts specified.\n');
|
|
8904
|
+
return 1;
|
|
8905
|
+
}
|
|
8811
8906
|
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
d('bin present: %s', binName);
|
|
8817
|
-
} catch (err) {
|
|
8818
|
-
d('bin missing: %s (from %s): %s', binName, depName, err);
|
|
8819
|
-
missing.push({ dep: depName, bin: binName, reason: 'missing-bin' });
|
|
8820
|
-
}
|
|
8821
|
-
}),
|
|
8822
|
-
);
|
|
8823
|
-
}),
|
|
8824
|
-
);
|
|
8907
|
+
const resolvedOptions = {
|
|
8908
|
+
cwd: options.cwd || process.cwd(),
|
|
8909
|
+
packageManager: options.packageManager || 'pnpm',
|
|
8910
|
+
};
|
|
8825
8911
|
|
|
8826
|
-
|
|
8912
|
+
process.stdout.write(`Running ${scripts.length} script(s) in parallel...\n`);
|
|
8913
|
+
scripts.forEach(script => {
|
|
8914
|
+
process.stdout.write(`[${script}] started\n`);
|
|
8915
|
+
});
|
|
8827
8916
|
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
'check-bins: all bin entries present, skipping force install.',
|
|
8831
|
-
);
|
|
8832
|
-
return;
|
|
8833
|
-
}
|
|
8917
|
+
const results = await Promise.all(scripts.map(script => runScript(script, resolvedOptions)));
|
|
8918
|
+
const failedResults = results.filter(result => result.code !== 0);
|
|
8834
8919
|
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
|
|
8838
|
-
logger.warn(` ${dep} -> (package not found in node_modules)`);
|
|
8920
|
+
results.forEach(result => {
|
|
8921
|
+
if (result.code === 0) {
|
|
8922
|
+
process.stdout.write(`[${result.script}] passed\n`);
|
|
8839
8923
|
} else {
|
|
8840
|
-
|
|
8924
|
+
process.stdout.write(`[${result.script}] failed (exit ${result.code})\n`);
|
|
8841
8925
|
}
|
|
8842
|
-
}
|
|
8926
|
+
});
|
|
8843
8927
|
|
|
8844
|
-
if (
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
);
|
|
8848
|
-
process.exit(1);
|
|
8928
|
+
if (failedResults.length === 0) {
|
|
8929
|
+
process.stdout.write('Parallel scripts passed.\n');
|
|
8930
|
+
return 0;
|
|
8849
8931
|
}
|
|
8850
8932
|
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8933
|
+
process.stdout.write('\nParallel scripts failed. Failed task logs:\n');
|
|
8934
|
+
failedResults.forEach(result => {
|
|
8935
|
+
process.stdout.write(`\n===== ${result.script} (exit ${result.code}) =====\n`);
|
|
8936
|
+
process.stdout.write(result.output || '(no output)\n');
|
|
8937
|
+
if (!result.output.endsWith('\n')) {
|
|
8938
|
+
process.stdout.write('\n');
|
|
8939
|
+
}
|
|
8940
|
+
process.stdout.write(`===== end ${result.script} =====\n`);
|
|
8941
|
+
});
|
|
8942
|
+
|
|
8943
|
+
return 1;
|
|
8855
8944
|
};
|
|
8856
8945
|
|
|
8857
|
-
const registerCommand$
|
|
8946
|
+
const registerCommand$2 = program => {
|
|
8858
8947
|
program
|
|
8859
|
-
.command('
|
|
8860
|
-
.description(
|
|
8861
|
-
|
|
8862
|
-
)
|
|
8863
|
-
.option('-
|
|
8864
|
-
.
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
} catch (err) {
|
|
8869
|
-
logger.warn(
|
|
8870
|
-
`check-bins: skipped due to error: ${err instanceof Error ? err.message : String(err)}`,
|
|
8871
|
-
);
|
|
8948
|
+
.command('parallel')
|
|
8949
|
+
.description('Run package scripts in parallel and print full logs for failed scripts')
|
|
8950
|
+
.argument('<scripts...>', 'Package scripts to run with pnpm run')
|
|
8951
|
+
.option('-c, --cwd <path>', 'Working directory', process.cwd())
|
|
8952
|
+
.option('--package-manager <command>', 'Package manager command', 'pnpm')
|
|
8953
|
+
.action(async (scripts, options) => {
|
|
8954
|
+
const exitCode = await runParallelScripts(scripts, options);
|
|
8955
|
+
if (exitCode !== 0) {
|
|
8956
|
+
process.exit(exitCode);
|
|
8872
8957
|
}
|
|
8873
8958
|
});
|
|
8874
8959
|
};
|
|
@@ -8972,34 +9057,26 @@ const ARGV_USER_ARGS_OFFSET = 2;
|
|
|
8972
9057
|
* @param knownOptions - 已知的选项集合(不需要透传的选项)
|
|
8973
9058
|
* @returns 参数对象
|
|
8974
9059
|
*/
|
|
8975
|
-
const parsePassThroughParams = (
|
|
8976
|
-
command,
|
|
8977
|
-
knownOptions = new Set(),
|
|
8978
|
-
) => {
|
|
9060
|
+
const parsePassThroughParams = (command, knownOptions = new Set()) => {
|
|
8979
9061
|
const parsed = minimist(process.argv.slice(ARGV_USER_ARGS_OFFSET));
|
|
8980
9062
|
|
|
8981
9063
|
// 过滤掉已知选项和位置参数(_)
|
|
8982
|
-
const filtered = Object.entries(parsed).reduce(
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
}
|
|
9064
|
+
const filtered = Object.entries(parsed).reduce((params, [key, value]) => {
|
|
9065
|
+
// 跳过 minimist 的位置参数数组
|
|
9066
|
+
if (key === '_') {
|
|
9067
|
+
return params;
|
|
9068
|
+
}
|
|
8988
9069
|
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
9070
|
+
// 跳过已知选项(支持原始格式和 camelCase 格式)
|
|
9071
|
+
if (knownOptions.has(key) || knownOptions.has(changeCase.camelCase(key))) {
|
|
9072
|
+
return params;
|
|
9073
|
+
}
|
|
8993
9074
|
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
// eslint-disable-next-line security/detect-object-injection -- camelKey is sanitized by camelCase
|
|
8997
|
-
params[camelKey] = value;
|
|
9075
|
+
// 将 kebab-case 转换为 camelCase
|
|
9076
|
+
const camelKey = changeCase.camelCase(key);
|
|
8998
9077
|
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
{},
|
|
9002
|
-
);
|
|
9078
|
+
return { ...params, [camelKey]: value };
|
|
9079
|
+
}, {});
|
|
9003
9080
|
|
|
9004
9081
|
return filtered;
|
|
9005
9082
|
};
|
|
@@ -9756,7 +9833,7 @@ const execute = async (
|
|
|
9756
9833
|
};
|
|
9757
9834
|
};
|
|
9758
9835
|
|
|
9759
|
-
function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
9836
|
+
function _nullishCoalesce$1(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
9760
9837
|
/**
|
|
9761
9838
|
* 运行 pnpm install
|
|
9762
9839
|
*/
|
|
@@ -9946,7 +10023,7 @@ const executeTemplateEngineStep = async ctx => {
|
|
|
9946
10023
|
templateName: ctx.templateName,
|
|
9947
10024
|
outputPath: ctx.outputPath,
|
|
9948
10025
|
command: ctx.command,
|
|
9949
|
-
force: _nullishCoalesce(ctx.options.force, () => ( false)),
|
|
10026
|
+
force: _nullishCoalesce$1(ctx.options.force, () => ( false)),
|
|
9950
10027
|
});
|
|
9951
10028
|
|
|
9952
10029
|
// 保存结果到上下文
|
|
@@ -10205,7 +10282,7 @@ const executeInit = async (
|
|
|
10205
10282
|
/**
|
|
10206
10283
|
* 注册 init 命令到 program
|
|
10207
10284
|
*/
|
|
10208
|
-
const registerCommand = program => {
|
|
10285
|
+
const registerCommand$1 = program => {
|
|
10209
10286
|
program
|
|
10210
10287
|
.command('init')
|
|
10211
10288
|
.description('Initialize a new project from a template')
|
|
@@ -10223,21 +10300,149 @@ const registerCommand = program => {
|
|
|
10223
10300
|
.allowUnknownOption() // 允许透传参数
|
|
10224
10301
|
.action(async (directory, options, command) => {
|
|
10225
10302
|
// 位置参数优先级高于 --output 选项
|
|
10226
|
-
const outputPath = _nullishCoalesce(directory, () => ( options.output));
|
|
10303
|
+
const outputPath = _nullishCoalesce$1(directory, () => ( options.output));
|
|
10227
10304
|
// Always use force mode - overwrite existing files without conflict check
|
|
10228
10305
|
const force = true;
|
|
10229
10306
|
await executeInit({ ...options, output: outputPath, force }, command);
|
|
10230
10307
|
});
|
|
10231
10308
|
};
|
|
10232
10309
|
|
|
10310
|
+
function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
10311
|
+
|
|
10312
|
+
|
|
10313
|
+
const d = debug('coze-init-cli:check-bins');
|
|
10314
|
+
|
|
10315
|
+
|
|
10316
|
+
|
|
10317
|
+
|
|
10318
|
+
|
|
10319
|
+
|
|
10320
|
+
|
|
10321
|
+
const checkBins = async (cwd, fix) => {
|
|
10322
|
+
d('starting check, cwd=%s fix=%s', cwd, fix);
|
|
10323
|
+
|
|
10324
|
+
const pkgJson = safeJsonParse
|
|
10325
|
+
|
|
10326
|
+
|
|
10327
|
+
(await fs$1.readFile(path.join(cwd, 'package.json'), 'utf8'), {});
|
|
10328
|
+
|
|
10329
|
+
const allDeps = Object.keys({
|
|
10330
|
+
...pkgJson.dependencies,
|
|
10331
|
+
...pkgJson.devDependencies,
|
|
10332
|
+
});
|
|
10333
|
+
|
|
10334
|
+
d('found %d total dependencies to scan', allDeps.length);
|
|
10335
|
+
|
|
10336
|
+
const binDir = path.join(cwd, 'node_modules', '.bin');
|
|
10337
|
+
d('bin directory: %s', binDir);
|
|
10338
|
+
const missing = [];
|
|
10339
|
+
|
|
10340
|
+
await Promise.all(
|
|
10341
|
+
allDeps.map(async depName => {
|
|
10342
|
+
let rawContent;
|
|
10343
|
+
try {
|
|
10344
|
+
rawContent = await fs$1.readFile(
|
|
10345
|
+
path.join(cwd, 'node_modules', depName, 'package.json'),
|
|
10346
|
+
'utf8',
|
|
10347
|
+
);
|
|
10348
|
+
} catch (err) {
|
|
10349
|
+
d('dep %s not found in node_modules: %s', depName, err);
|
|
10350
|
+
missing.push({ dep: depName, bin: '', reason: 'missing-package' });
|
|
10351
|
+
return;
|
|
10352
|
+
}
|
|
10353
|
+
const depPkg = safeJsonParse(
|
|
10354
|
+
rawContent,
|
|
10355
|
+
);
|
|
10356
|
+
if (!depPkg) {
|
|
10357
|
+
d('skipping %s: failed to parse package.json', depName);
|
|
10358
|
+
return;
|
|
10359
|
+
}
|
|
10360
|
+
|
|
10361
|
+
if (!depPkg.bin) {
|
|
10362
|
+
return;
|
|
10363
|
+
}
|
|
10364
|
+
|
|
10365
|
+
const bins =
|
|
10366
|
+
typeof depPkg.bin === 'string'
|
|
10367
|
+
? { [_nullishCoalesce(depName.split('/').pop(), () => ( depName))]: depPkg.bin }
|
|
10368
|
+
: depPkg.bin;
|
|
10369
|
+
|
|
10370
|
+
d('%s declares bins: %o', depName, Object.keys(bins));
|
|
10371
|
+
|
|
10372
|
+
await Promise.all(
|
|
10373
|
+
Object.keys(bins).map(async binName => {
|
|
10374
|
+
try {
|
|
10375
|
+
await fs$1.access(path.join(binDir, binName));
|
|
10376
|
+
d('bin present: %s', binName);
|
|
10377
|
+
} catch (err) {
|
|
10378
|
+
d('bin missing: %s (from %s): %s', binName, depName, err);
|
|
10379
|
+
missing.push({ dep: depName, bin: binName, reason: 'missing-bin' });
|
|
10380
|
+
}
|
|
10381
|
+
}),
|
|
10382
|
+
);
|
|
10383
|
+
}),
|
|
10384
|
+
);
|
|
10385
|
+
|
|
10386
|
+
d('scan complete, missing=%d', missing.length);
|
|
10387
|
+
|
|
10388
|
+
if (missing.length === 0) {
|
|
10389
|
+
logger.success(
|
|
10390
|
+
'check-bins: all bin entries present, skipping force install.',
|
|
10391
|
+
);
|
|
10392
|
+
return;
|
|
10393
|
+
}
|
|
10394
|
+
|
|
10395
|
+
logger.warn('check-bins: missing or broken dependencies detected:');
|
|
10396
|
+
for (const { dep, bin, reason } of missing) {
|
|
10397
|
+
if (reason === 'missing-package') {
|
|
10398
|
+
logger.warn(` ${dep} -> (package not found in node_modules)`);
|
|
10399
|
+
} else {
|
|
10400
|
+
logger.warn(` ${dep} -> .bin/${bin}`);
|
|
10401
|
+
}
|
|
10402
|
+
}
|
|
10403
|
+
|
|
10404
|
+
if (!fix) {
|
|
10405
|
+
logger.error(
|
|
10406
|
+
'check-bins: missing bin entries found, run with --fix to repair.',
|
|
10407
|
+
);
|
|
10408
|
+
process.exit(1);
|
|
10409
|
+
}
|
|
10410
|
+
|
|
10411
|
+
logger.info('check-bins: running pnpm i --force to fix...');
|
|
10412
|
+
d('executing: pnpm i --force');
|
|
10413
|
+
child_process.execSync('pnpm i --force', { stdio: 'inherit', cwd });
|
|
10414
|
+
d('pnpm i --force completed');
|
|
10415
|
+
};
|
|
10416
|
+
|
|
10417
|
+
const registerCommand = program => {
|
|
10418
|
+
program
|
|
10419
|
+
.command('check-bins')
|
|
10420
|
+
.description(
|
|
10421
|
+
'Verify all bin entries from dependencies exist in node_modules/.bin, run pnpm i --force if any are missing',
|
|
10422
|
+
)
|
|
10423
|
+
.option('-c, --cwd <path>', 'Working directory to check', process.cwd())
|
|
10424
|
+
.option('--fix', 'Run pnpm i --force to repair missing bin entries', false)
|
|
10425
|
+
.action(async (options) => {
|
|
10426
|
+
try {
|
|
10427
|
+
await checkBins(options.cwd, options.fix);
|
|
10428
|
+
} catch (err) {
|
|
10429
|
+
logger.warn(
|
|
10430
|
+
`check-bins: skipped due to error: ${err instanceof Error ? err.message : String(err)}`,
|
|
10431
|
+
);
|
|
10432
|
+
}
|
|
10433
|
+
});
|
|
10434
|
+
};
|
|
10435
|
+
|
|
10436
|
+
function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
10233
10437
|
const commands = [
|
|
10234
|
-
registerCommand,
|
|
10235
|
-
registerCommand$3,
|
|
10236
|
-
registerCommand$6,
|
|
10438
|
+
registerCommand$1,
|
|
10237
10439
|
registerCommand$4,
|
|
10440
|
+
registerCommand$7,
|
|
10238
10441
|
registerCommand$5,
|
|
10442
|
+
registerCommand$6,
|
|
10443
|
+
registerCommand$3,
|
|
10444
|
+
registerCommand,
|
|
10239
10445
|
registerCommand$2,
|
|
10240
|
-
registerCommand$1,
|
|
10241
10446
|
];
|
|
10242
10447
|
|
|
10243
10448
|
const main = async () => {
|
|
@@ -10268,10 +10473,8 @@ const main = async () => {
|
|
|
10268
10473
|
const program = new commander.Command();
|
|
10269
10474
|
|
|
10270
10475
|
program
|
|
10271
|
-
.name('coze')
|
|
10272
|
-
.description(
|
|
10273
|
-
'Coze Coding CLI - Project template engine for frontend stacks',
|
|
10274
|
-
)
|
|
10476
|
+
.name(_optionalChain([process, 'access', _ => _.argv, 'access', _2 => _2[1], 'optionalAccess', _3 => _3.split, 'call', _4 => _4('/'), 'access', _5 => _5.pop, 'call', _6 => _6()]) || 'coze')
|
|
10477
|
+
.description('Coze Coding CLI - Project template engine for frontend stacks')
|
|
10275
10478
|
.version(packageJson.version);
|
|
10276
10479
|
|
|
10277
10480
|
commands.forEach(initCmd => initCmd(program));
|