@coze-arch/cli 0.0.30 → 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 +542 -289
- 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) {
|
|
@@ -2811,7 +2813,7 @@ const executeWarmup = async (options) => {
|
|
|
2811
2813
|
/**
|
|
2812
2814
|
* 注册 warmup 命令到 program
|
|
2813
2815
|
*/
|
|
2814
|
-
const registerCommand$
|
|
2816
|
+
const registerCommand$7 = program => {
|
|
2815
2817
|
program
|
|
2816
2818
|
.command('warmup')
|
|
2817
2819
|
.description('Pre-install dependencies for templates to speed up init')
|
|
@@ -3223,7 +3225,7 @@ const executeUpdate = (
|
|
|
3223
3225
|
/**
|
|
3224
3226
|
* 注册 update 命令到 program
|
|
3225
3227
|
*/
|
|
3226
|
-
const registerCommand$
|
|
3228
|
+
const registerCommand$6 = program => {
|
|
3227
3229
|
program
|
|
3228
3230
|
.command('update <package>')
|
|
3229
3231
|
.description('Update a package dependency')
|
|
@@ -3249,7 +3251,7 @@ const registerCommand$5 = program => {
|
|
|
3249
3251
|
});
|
|
3250
3252
|
};
|
|
3251
3253
|
|
|
3252
|
-
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 */
|
|
3253
3255
|
// Safe JSON parsing utilities with type safety and error handling
|
|
3254
3256
|
// Provides fallback values, validation, and error monitoring capabilities
|
|
3255
3257
|
|
|
@@ -3349,12 +3351,12 @@ function safeJsonParse(
|
|
|
3349
3351
|
const parsed = JSON.parse(String(input));
|
|
3350
3352
|
|
|
3351
3353
|
// Optional validation
|
|
3352
|
-
if (_optionalChain$
|
|
3354
|
+
if (_optionalChain$r([options, 'optionalAccess', _ => _.validate])) {
|
|
3353
3355
|
if (options.validate(parsed)) {
|
|
3354
3356
|
return parsed;
|
|
3355
3357
|
} else {
|
|
3356
3358
|
const validationError = new Error('JSON validation failed');
|
|
3357
|
-
_optionalChain$
|
|
3359
|
+
_optionalChain$r([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
|
|
3358
3360
|
|
|
3359
3361
|
if (options.throwOnValidationError) {
|
|
3360
3362
|
throw validationError;
|
|
@@ -3366,10 +3368,10 @@ function safeJsonParse(
|
|
|
3366
3368
|
return parsed;
|
|
3367
3369
|
} catch (error) {
|
|
3368
3370
|
// Re-throw validation errors when throwOnValidationError is true
|
|
3369
|
-
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])) {
|
|
3370
3372
|
throw error;
|
|
3371
3373
|
}
|
|
3372
|
-
_optionalChain$
|
|
3374
|
+
_optionalChain$r([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
|
|
3373
3375
|
return defaultValue;
|
|
3374
3376
|
}
|
|
3375
3377
|
}
|
|
@@ -3409,7 +3411,7 @@ function isNode(node) {
|
|
|
3409
3411
|
}
|
|
3410
3412
|
const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
|
|
3411
3413
|
|
|
3412
|
-
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; }
|
|
3413
3415
|
const BREAK = Symbol('break visit');
|
|
3414
3416
|
const SKIP = Symbol('skip children');
|
|
3415
3417
|
const REMOVE = Symbol('remove node');
|
|
@@ -3522,15 +3524,15 @@ function callVisitor(key, node, visitor, path) {
|
|
|
3522
3524
|
if (typeof visitor === 'function')
|
|
3523
3525
|
return visitor(key, node, path);
|
|
3524
3526
|
if (isMap(node))
|
|
3525
|
-
return _optionalChain$
|
|
3527
|
+
return _optionalChain$q([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
|
|
3526
3528
|
if (isSeq(node))
|
|
3527
|
-
return _optionalChain$
|
|
3529
|
+
return _optionalChain$q([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
|
|
3528
3530
|
if (isPair(node))
|
|
3529
|
-
return _optionalChain$
|
|
3531
|
+
return _optionalChain$q([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
|
|
3530
3532
|
if (isScalar(node))
|
|
3531
|
-
return _optionalChain$
|
|
3533
|
+
return _optionalChain$q([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
|
|
3532
3534
|
if (isAlias(node))
|
|
3533
|
-
return _optionalChain$
|
|
3535
|
+
return _optionalChain$q([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
|
|
3534
3536
|
return undefined;
|
|
3535
3537
|
}
|
|
3536
3538
|
function replaceNode(key, path, node) {
|
|
@@ -3621,7 +3623,7 @@ function applyReviver(reviver, obj, key, val) {
|
|
|
3621
3623
|
return reviver.call(obj, key, val);
|
|
3622
3624
|
}
|
|
3623
3625
|
|
|
3624
|
-
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; }
|
|
3625
3627
|
/**
|
|
3626
3628
|
* Recursively convert any node or its contents to native JavaScript
|
|
3627
3629
|
*
|
|
@@ -3651,7 +3653,7 @@ function toJS(value, arg, ctx) {
|
|
|
3651
3653
|
ctx.onCreate(res);
|
|
3652
3654
|
return res;
|
|
3653
3655
|
}
|
|
3654
|
-
if (typeof value === 'bigint' && !_optionalChain$
|
|
3656
|
+
if (typeof value === 'bigint' && !_optionalChain$p([ctx, 'optionalAccess', _ => _.keep]))
|
|
3655
3657
|
return Number(value);
|
|
3656
3658
|
return value;
|
|
3657
3659
|
}
|
|
@@ -3689,7 +3691,7 @@ class NodeBase {
|
|
|
3689
3691
|
}
|
|
3690
3692
|
}
|
|
3691
3693
|
|
|
3692
|
-
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; }
|
|
3693
3695
|
class Alias extends NodeBase {
|
|
3694
3696
|
constructor(source) {
|
|
3695
3697
|
super(ALIAS);
|
|
@@ -3705,10 +3707,10 @@ class Alias extends NodeBase {
|
|
|
3705
3707
|
* instance of the `source` anchor before this node.
|
|
3706
3708
|
*/
|
|
3707
3709
|
resolve(doc, ctx) {
|
|
3708
|
-
if (_optionalChain$
|
|
3710
|
+
if (_optionalChain$o([ctx, 'optionalAccess', _ => _.maxAliasCount]) === 0)
|
|
3709
3711
|
throw new ReferenceError('Alias resolution is disabled');
|
|
3710
3712
|
let nodes;
|
|
3711
|
-
if (_optionalChain$
|
|
3713
|
+
if (_optionalChain$o([ctx, 'optionalAccess', _2 => _2.aliasResolveCache])) {
|
|
3712
3714
|
nodes = ctx.aliasResolveCache;
|
|
3713
3715
|
}
|
|
3714
3716
|
else {
|
|
@@ -3747,7 +3749,7 @@ class Alias extends NodeBase {
|
|
|
3747
3749
|
data = anchors.get(source);
|
|
3748
3750
|
}
|
|
3749
3751
|
/* istanbul ignore if */
|
|
3750
|
-
if (_optionalChain$
|
|
3752
|
+
if (_optionalChain$o([data, 'optionalAccess', _3 => _3.res]) === undefined) {
|
|
3751
3753
|
const msg = 'This should not happen: Alias anchor was not resolved?';
|
|
3752
3754
|
throw new ReferenceError(msg);
|
|
3753
3755
|
}
|
|
@@ -3799,7 +3801,7 @@ function getAliasCount(doc, node, anchors) {
|
|
|
3799
3801
|
return 1;
|
|
3800
3802
|
}
|
|
3801
3803
|
|
|
3802
|
-
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; }
|
|
3803
3805
|
const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
|
|
3804
3806
|
class Scalar extends NodeBase {
|
|
3805
3807
|
constructor(value) {
|
|
@@ -3807,7 +3809,7 @@ class Scalar extends NodeBase {
|
|
|
3807
3809
|
this.value = value;
|
|
3808
3810
|
}
|
|
3809
3811
|
toJSON(arg, ctx) {
|
|
3810
|
-
return _optionalChain$
|
|
3812
|
+
return _optionalChain$n([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
|
|
3811
3813
|
}
|
|
3812
3814
|
toString() {
|
|
3813
3815
|
return String(this.value);
|
|
@@ -3819,17 +3821,17 @@ Scalar.PLAIN = 'PLAIN';
|
|
|
3819
3821
|
Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
|
|
3820
3822
|
Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
|
|
3821
3823
|
|
|
3822
|
-
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; }
|
|
3823
3825
|
const defaultTagPrefix = 'tag:yaml.org,2002:';
|
|
3824
3826
|
function findTagObject(value, tagName, tags) {
|
|
3825
3827
|
if (tagName) {
|
|
3826
3828
|
const match = tags.filter(t => t.tag === tagName);
|
|
3827
|
-
const tagObj = _nullishCoalesce$
|
|
3829
|
+
const tagObj = _nullishCoalesce$a(match.find(t => !t.format), () => ( match[0]));
|
|
3828
3830
|
if (!tagObj)
|
|
3829
3831
|
throw new Error(`Tag ${tagName} not found`);
|
|
3830
3832
|
return tagObj;
|
|
3831
3833
|
}
|
|
3832
|
-
return tags.find(t => _optionalChain$
|
|
3834
|
+
return tags.find(t => _optionalChain$m([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
|
|
3833
3835
|
}
|
|
3834
3836
|
function createNode(value, tagName, ctx) {
|
|
3835
3837
|
if (isDocument(value))
|
|
@@ -3837,7 +3839,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3837
3839
|
if (isNode(value))
|
|
3838
3840
|
return value;
|
|
3839
3841
|
if (isPair(value)) {
|
|
3840
|
-
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)]);
|
|
3841
3843
|
map.items.push(value);
|
|
3842
3844
|
return map;
|
|
3843
3845
|
}
|
|
@@ -3856,7 +3858,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3856
3858
|
if (aliasDuplicateObjects && value && typeof value === 'object') {
|
|
3857
3859
|
ref = sourceObjects.get(value);
|
|
3858
3860
|
if (ref) {
|
|
3859
|
-
_nullishCoalesce$
|
|
3861
|
+
_nullishCoalesce$a(ref.anchor, () => ( (ref.anchor = onAnchor(value))));
|
|
3860
3862
|
return new Alias(ref.anchor);
|
|
3861
3863
|
}
|
|
3862
3864
|
else {
|
|
@@ -3864,7 +3866,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3864
3866
|
sourceObjects.set(value, ref);
|
|
3865
3867
|
}
|
|
3866
3868
|
}
|
|
3867
|
-
if (_optionalChain$
|
|
3869
|
+
if (_optionalChain$m([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
|
|
3868
3870
|
tagName = defaultTagPrefix + tagName.slice(2);
|
|
3869
3871
|
let tagObj = findTagObject(value, tagName, schema.tags);
|
|
3870
3872
|
if (!tagObj) {
|
|
@@ -3889,9 +3891,9 @@ function createNode(value, tagName, ctx) {
|
|
|
3889
3891
|
onTagObj(tagObj);
|
|
3890
3892
|
delete ctx.onTagObj;
|
|
3891
3893
|
}
|
|
3892
|
-
const node = _optionalChain$
|
|
3894
|
+
const node = _optionalChain$m([tagObj, 'optionalAccess', _9 => _9.createNode])
|
|
3893
3895
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
3894
|
-
: typeof _optionalChain$
|
|
3896
|
+
: typeof _optionalChain$m([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
|
|
3895
3897
|
? tagObj.nodeClass.from(ctx.schema, value, ctx)
|
|
3896
3898
|
: new Scalar(value);
|
|
3897
3899
|
if (tagName)
|
|
@@ -4209,7 +4211,7 @@ function consumeMoreIndentedLines(text, i, indent) {
|
|
|
4209
4211
|
return end;
|
|
4210
4212
|
}
|
|
4211
4213
|
|
|
4212
|
-
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; }
|
|
4213
4215
|
const getFoldOptions = (ctx, isBlock) => ({
|
|
4214
4216
|
indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
|
|
4215
4217
|
lineWidth: ctx.options.lineWidth,
|
|
@@ -4494,9 +4496,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
4494
4496
|
// booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
|
|
4495
4497
|
// and others in v1.1.
|
|
4496
4498
|
if (actualString) {
|
|
4497
|
-
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)]);
|
|
4498
4500
|
const { compat, tags } = ctx.doc.schema;
|
|
4499
|
-
if (tags.some(test) || _optionalChain$
|
|
4501
|
+
if (tags.some(test) || _optionalChain$l([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
|
|
4500
4502
|
return quotedString(value, ctx);
|
|
4501
4503
|
}
|
|
4502
4504
|
return implicitKey
|
|
@@ -4542,7 +4544,7 @@ function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
|
4542
4544
|
return res;
|
|
4543
4545
|
}
|
|
4544
4546
|
|
|
4545
|
-
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; }
|
|
4546
4548
|
function createStringifyContext(doc, options) {
|
|
4547
4549
|
const opt = Object.assign({
|
|
4548
4550
|
blockQuote: true,
|
|
@@ -4589,27 +4591,27 @@ function getTagObject(tags, item) {
|
|
|
4589
4591
|
if (item.tag) {
|
|
4590
4592
|
const match = tags.filter(t => t.tag === item.tag);
|
|
4591
4593
|
if (match.length > 0)
|
|
4592
|
-
return _nullishCoalesce$
|
|
4594
|
+
return _nullishCoalesce$9(match.find(t => t.format === item.format), () => ( match[0]));
|
|
4593
4595
|
}
|
|
4594
4596
|
let tagObj = undefined;
|
|
4595
4597
|
let obj;
|
|
4596
4598
|
if (isScalar(item)) {
|
|
4597
4599
|
obj = item.value;
|
|
4598
|
-
let match = tags.filter(t => _optionalChain$
|
|
4600
|
+
let match = tags.filter(t => _optionalChain$k([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
|
|
4599
4601
|
if (match.length > 1) {
|
|
4600
4602
|
const testMatch = match.filter(t => t.test);
|
|
4601
4603
|
if (testMatch.length > 0)
|
|
4602
4604
|
match = testMatch;
|
|
4603
4605
|
}
|
|
4604
4606
|
tagObj =
|
|
4605
|
-
_nullishCoalesce$
|
|
4607
|
+
_nullishCoalesce$9(match.find(t => t.format === item.format), () => ( match.find(t => !t.format)));
|
|
4606
4608
|
}
|
|
4607
4609
|
else {
|
|
4608
4610
|
obj = item;
|
|
4609
4611
|
tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
|
|
4610
4612
|
}
|
|
4611
4613
|
if (!tagObj) {
|
|
4612
|
-
const name = _nullishCoalesce$
|
|
4614
|
+
const name = _nullishCoalesce$9(_optionalChain$k([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
|
|
4613
4615
|
throw new Error(`Tag not resolved for ${name} value`);
|
|
4614
4616
|
}
|
|
4615
4617
|
return tagObj;
|
|
@@ -4624,7 +4626,7 @@ function stringifyProps(node, tagObj, { anchors, doc }) {
|
|
|
4624
4626
|
anchors.add(anchor);
|
|
4625
4627
|
props.push(`&${anchor}`);
|
|
4626
4628
|
}
|
|
4627
|
-
const tag = _nullishCoalesce$
|
|
4629
|
+
const tag = _nullishCoalesce$9(node.tag, () => ( (tagObj.default ? null : tagObj.tag)));
|
|
4628
4630
|
if (tag)
|
|
4629
4631
|
props.push(doc.directives.tagString(tag));
|
|
4630
4632
|
return props.join(' ');
|
|
@@ -4635,7 +4637,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
|
|
|
4635
4637
|
if (isAlias(item)) {
|
|
4636
4638
|
if (ctx.doc.directives)
|
|
4637
4639
|
return item.toString(ctx);
|
|
4638
|
-
if (_optionalChain$
|
|
4640
|
+
if (_optionalChain$k([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
|
|
4639
4641
|
throw new TypeError(`Cannot stringify circular structure without alias nodes`);
|
|
4640
4642
|
}
|
|
4641
4643
|
else {
|
|
@@ -4650,10 +4652,10 @@ function stringify(item, ctx, onComment, onChompKeep) {
|
|
|
4650
4652
|
const node = isNode(item)
|
|
4651
4653
|
? item
|
|
4652
4654
|
: ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
|
|
4653
|
-
_nullishCoalesce$
|
|
4655
|
+
_nullishCoalesce$9(tagObj, () => ( (tagObj = getTagObject(ctx.doc.schema.tags, node))));
|
|
4654
4656
|
const props = stringifyProps(node, tagObj, ctx);
|
|
4655
4657
|
if (props.length > 0)
|
|
4656
|
-
ctx.indentAtStart = (_nullishCoalesce$
|
|
4658
|
+
ctx.indentAtStart = (_nullishCoalesce$9(ctx.indentAtStart, () => ( 0))) + props.length + 1;
|
|
4657
4659
|
const str = typeof tagObj.stringify === 'function'
|
|
4658
4660
|
? tagObj.stringify(node, ctx, onComment, onChompKeep)
|
|
4659
4661
|
: isScalar(node)
|
|
@@ -4666,7 +4668,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
|
|
|
4666
4668
|
: `${props}\n${ctx.indent}${str}`;
|
|
4667
4669
|
}
|
|
4668
4670
|
|
|
4669
|
-
function _nullishCoalesce$
|
|
4671
|
+
function _nullishCoalesce$8(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
4670
4672
|
function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
4671
4673
|
const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
|
|
4672
4674
|
let keyComment = (isNode(key) && key.comment) || null;
|
|
@@ -4776,7 +4778,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
4776
4778
|
const vs0 = valueStr[0];
|
|
4777
4779
|
const nl0 = valueStr.indexOf('\n');
|
|
4778
4780
|
const hasNewline = nl0 !== -1;
|
|
4779
|
-
const flow = _nullishCoalesce$
|
|
4781
|
+
const flow = _nullishCoalesce$8(_nullishCoalesce$8(ctx.inFlow, () => ( value.flow)), () => ( value.items.length === 0));
|
|
4780
4782
|
if (hasNewline || !flow) {
|
|
4781
4783
|
let hasPropsLine = false;
|
|
4782
4784
|
if (hasNewline && (vs0 === '&' || vs0 === '!')) {
|
|
@@ -4817,7 +4819,7 @@ function warn(logLevel, warning) {
|
|
|
4817
4819
|
}
|
|
4818
4820
|
}
|
|
4819
4821
|
|
|
4820
|
-
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; }
|
|
4821
4823
|
// If the value associated with a merge key is a single mapping node, each of
|
|
4822
4824
|
// its key/value pairs is inserted into the current mapping, unless the key
|
|
4823
4825
|
// already exists in it. If the value associated with the merge key is a
|
|
@@ -4841,7 +4843,7 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
|
|
|
4841
4843
|
(isScalar(key) &&
|
|
4842
4844
|
(!key.type || key.type === Scalar.PLAIN) &&
|
|
4843
4845
|
merge.identify(key.value))) &&
|
|
4844
|
-
_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)]);
|
|
4845
4847
|
function addMergeToJSMap(ctx, map, value) {
|
|
4846
4848
|
const source = resolveAliasValue(ctx, value);
|
|
4847
4849
|
if (isSeq(source))
|
|
@@ -4881,7 +4883,7 @@ function resolveAliasValue(ctx, value) {
|
|
|
4881
4883
|
return ctx && isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
|
|
4882
4884
|
}
|
|
4883
4885
|
|
|
4884
|
-
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; }
|
|
4885
4887
|
function addPairToJSMap(ctx, map, { key, value }) {
|
|
4886
4888
|
if (isNode(key) && key.addToJSMap)
|
|
4887
4889
|
key.addToJSMap(ctx, map, value);
|
|
@@ -4918,7 +4920,7 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
4918
4920
|
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
4919
4921
|
if (typeof jsKey !== 'object')
|
|
4920
4922
|
return String(jsKey);
|
|
4921
|
-
if (isNode(key) && _optionalChain$
|
|
4923
|
+
if (isNode(key) && _optionalChain$i([ctx, 'optionalAccess', _ => _.doc])) {
|
|
4922
4924
|
const strCtx = createStringifyContext(ctx.doc, {});
|
|
4923
4925
|
strCtx.anchors = new Set();
|
|
4924
4926
|
for (const node of ctx.anchors.keys())
|
|
@@ -4938,7 +4940,7 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
4938
4940
|
return JSON.stringify(jsKey);
|
|
4939
4941
|
}
|
|
4940
4942
|
|
|
4941
|
-
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; }
|
|
4942
4944
|
function createPair(key, value, ctx) {
|
|
4943
4945
|
const k = createNode(key, undefined, ctx);
|
|
4944
4946
|
const v = createNode(value, undefined, ctx);
|
|
@@ -4959,19 +4961,19 @@ class Pair {
|
|
|
4959
4961
|
return new Pair(key, value);
|
|
4960
4962
|
}
|
|
4961
4963
|
toJSON(_, ctx) {
|
|
4962
|
-
const pair = _optionalChain$
|
|
4964
|
+
const pair = _optionalChain$h([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
|
|
4963
4965
|
return addPairToJSMap(ctx, pair, this);
|
|
4964
4966
|
}
|
|
4965
4967
|
toString(ctx, onComment, onChompKeep) {
|
|
4966
|
-
return _optionalChain$
|
|
4968
|
+
return _optionalChain$h([ctx, 'optionalAccess', _3 => _3.doc])
|
|
4967
4969
|
? stringifyPair(this, ctx, onComment, onChompKeep)
|
|
4968
4970
|
: JSON.stringify(this);
|
|
4969
4971
|
}
|
|
4970
4972
|
}
|
|
4971
4973
|
|
|
4972
|
-
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; }
|
|
4973
4975
|
function stringifyCollection(collection, ctx, options) {
|
|
4974
|
-
const flow = _nullishCoalesce$
|
|
4976
|
+
const flow = _nullishCoalesce$7(ctx.inFlow, () => ( collection.flow));
|
|
4975
4977
|
const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
|
|
4976
4978
|
return stringify(collection, ctx, options);
|
|
4977
4979
|
}
|
|
@@ -5063,7 +5065,7 @@ function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
|
|
|
5063
5065
|
if (iv.commentBefore)
|
|
5064
5066
|
reqNewline = true;
|
|
5065
5067
|
}
|
|
5066
|
-
else if (item.value == null && _optionalChain$
|
|
5068
|
+
else if (item.value == null && _optionalChain$g([ik, 'optionalAccess', _ => _.comment])) {
|
|
5067
5069
|
comment = ik.comment;
|
|
5068
5070
|
}
|
|
5069
5071
|
}
|
|
@@ -5118,7 +5120,7 @@ function addCommentBefore({ indent, options: { commentString } }, lines, comment
|
|
|
5118
5120
|
}
|
|
5119
5121
|
}
|
|
5120
5122
|
|
|
5121
|
-
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; }
|
|
5122
5124
|
function findPair(items, key) {
|
|
5123
5125
|
const k = isScalar(key) ? key.value : key;
|
|
5124
5126
|
for (const it of items) {
|
|
@@ -5179,12 +5181,12 @@ class YAMLMap extends Collection {
|
|
|
5179
5181
|
_pair = pair;
|
|
5180
5182
|
else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
|
|
5181
5183
|
// In TypeScript, this never happens.
|
|
5182
|
-
_pair = new Pair(pair, _optionalChain$
|
|
5184
|
+
_pair = new Pair(pair, _optionalChain$f([pair, 'optionalAccess', _2 => _2.value]));
|
|
5183
5185
|
}
|
|
5184
5186
|
else
|
|
5185
5187
|
_pair = new Pair(pair.key, pair.value);
|
|
5186
5188
|
const prev = findPair(this.items, _pair.key);
|
|
5187
|
-
const sortEntries = _optionalChain$
|
|
5189
|
+
const sortEntries = _optionalChain$f([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
|
|
5188
5190
|
if (prev) {
|
|
5189
5191
|
if (!overwrite)
|
|
5190
5192
|
throw new Error(`Key ${_pair.key} already set`);
|
|
@@ -5214,8 +5216,8 @@ class YAMLMap extends Collection {
|
|
|
5214
5216
|
}
|
|
5215
5217
|
get(key, keepScalar) {
|
|
5216
5218
|
const it = findPair(this.items, key);
|
|
5217
|
-
const node = _optionalChain$
|
|
5218
|
-
return _nullishCoalesce$
|
|
5219
|
+
const node = _optionalChain$f([it, 'optionalAccess', _5 => _5.value]);
|
|
5220
|
+
return _nullishCoalesce$6((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
|
|
5219
5221
|
}
|
|
5220
5222
|
has(key) {
|
|
5221
5223
|
return !!findPair(this.items, key);
|
|
@@ -5229,8 +5231,8 @@ class YAMLMap extends Collection {
|
|
|
5229
5231
|
* @returns Instance of Type, Map, or Object
|
|
5230
5232
|
*/
|
|
5231
5233
|
toJSON(_, ctx, Type) {
|
|
5232
|
-
const map = Type ? new Type() : _optionalChain$
|
|
5233
|
-
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]))
|
|
5234
5236
|
ctx.onCreate(map);
|
|
5235
5237
|
for (const item of this.items)
|
|
5236
5238
|
addPairToJSMap(ctx, map, item);
|
|
@@ -5255,7 +5257,7 @@ class YAMLMap extends Collection {
|
|
|
5255
5257
|
}
|
|
5256
5258
|
}
|
|
5257
5259
|
|
|
5258
|
-
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; }
|
|
5259
5261
|
class YAMLSeq extends Collection {
|
|
5260
5262
|
static get tagName() {
|
|
5261
5263
|
return 'tag:yaml.org,2002:seq';
|
|
@@ -5318,7 +5320,7 @@ class YAMLSeq extends Collection {
|
|
|
5318
5320
|
}
|
|
5319
5321
|
toJSON(_, ctx) {
|
|
5320
5322
|
const seq = [];
|
|
5321
|
-
if (_optionalChain$
|
|
5323
|
+
if (_optionalChain$e([ctx, 'optionalAccess', _2 => _2.onCreate]))
|
|
5322
5324
|
ctx.onCreate(seq);
|
|
5323
5325
|
let i = 0;
|
|
5324
5326
|
for (const item of this.items)
|
|
@@ -5397,7 +5399,7 @@ function createPairs(schema, iterable, ctx) {
|
|
|
5397
5399
|
return pairs;
|
|
5398
5400
|
}
|
|
5399
5401
|
|
|
5400
|
-
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; }
|
|
5401
5403
|
class YAMLOMap extends YAMLSeq {
|
|
5402
5404
|
constructor() {
|
|
5403
5405
|
super();
|
|
@@ -5416,7 +5418,7 @@ class YAMLOMap extends YAMLSeq {
|
|
|
5416
5418
|
if (!ctx)
|
|
5417
5419
|
return super.toJSON(_);
|
|
5418
5420
|
const map = new Map();
|
|
5419
|
-
if (_optionalChain$
|
|
5421
|
+
if (_optionalChain$d([ctx, 'optionalAccess', _2 => _2.onCreate]))
|
|
5420
5422
|
ctx.onCreate(map);
|
|
5421
5423
|
for (const pair of this.items) {
|
|
5422
5424
|
let key, value;
|
|
@@ -5534,7 +5536,7 @@ const isDirExists = async (file) => {
|
|
|
5534
5536
|
}
|
|
5535
5537
|
};
|
|
5536
5538
|
|
|
5537
|
-
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
|
|
5538
5540
|
|
|
5539
5541
|
/**
|
|
5540
5542
|
* 支持的项目类型枚举
|
|
@@ -5636,7 +5638,7 @@ const collectProjectInfo = async (
|
|
|
5636
5638
|
}
|
|
5637
5639
|
|
|
5638
5640
|
const scripts = Object.entries(
|
|
5639
|
-
(_optionalChain$
|
|
5641
|
+
(_optionalChain$c([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
|
|
5640
5642
|
).reduce((acc, [name, script]) => {
|
|
5641
5643
|
if (typeof script === 'string') {
|
|
5642
5644
|
acc[name] = script;
|
|
@@ -5790,7 +5792,7 @@ const detectProjectType = async (
|
|
|
5790
5792
|
};
|
|
5791
5793
|
};
|
|
5792
5794
|
|
|
5793
|
-
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; }
|
|
5794
5796
|
|
|
5795
5797
|
|
|
5796
5798
|
/**
|
|
@@ -5964,16 +5966,16 @@ const getCommandConfig = (
|
|
|
5964
5966
|
|
|
5965
5967
|
switch (commandName) {
|
|
5966
5968
|
case 'dev':
|
|
5967
|
-
commandConfig = _optionalChain$
|
|
5969
|
+
commandConfig = _optionalChain$b([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
|
|
5968
5970
|
break;
|
|
5969
5971
|
case 'build':
|
|
5970
|
-
commandConfig = _optionalChain$
|
|
5972
|
+
commandConfig = _optionalChain$b([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
|
|
5971
5973
|
break;
|
|
5972
5974
|
case 'start':
|
|
5973
|
-
commandConfig = _optionalChain$
|
|
5975
|
+
commandConfig = _optionalChain$b([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
|
|
5974
5976
|
break;
|
|
5975
5977
|
case 'validate':
|
|
5976
|
-
commandConfig = _optionalChain$
|
|
5978
|
+
commandConfig = _optionalChain$b([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
|
|
5977
5979
|
break;
|
|
5978
5980
|
default:
|
|
5979
5981
|
throw new Error(`Unknown command: ${commandName}`);
|
|
@@ -6124,16 +6126,16 @@ const byFlag = (flag) => {
|
|
|
6124
6126
|
return predicate;
|
|
6125
6127
|
};
|
|
6126
6128
|
|
|
6127
|
-
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; }
|
|
6128
6130
|
|
|
6129
6131
|
|
|
6130
6132
|
|
|
6131
6133
|
|
|
6132
6134
|
|
|
6133
6135
|
|
|
6134
|
-
const PATCH_ID$
|
|
6136
|
+
const PATCH_ID$7 = 'expo/validate@0.0.20';
|
|
6135
6137
|
const PACKAGE_JSON_FILE$4 = 'package.json';
|
|
6136
|
-
const VALIDATE_SCRIPT_FILE$
|
|
6138
|
+
const VALIDATE_SCRIPT_FILE$4 = '.cozeproj/scripts/validate.sh';
|
|
6137
6139
|
const EXPO_VALIDATE_FLAG = 'coding.arch.patch_expo_validate';
|
|
6138
6140
|
const TARGET_VALIDATE$3 = "pnpm run --parallel '/^(lint:client|lint:server)$/'";
|
|
6139
6141
|
const TARGET_VALIDATE_SCRIPT$3 = `#!/bin/bash
|
|
@@ -6155,7 +6157,7 @@ echo "Validate passed!"
|
|
|
6155
6157
|
* @returns
|
|
6156
6158
|
*/
|
|
6157
6159
|
const isCozeValid$3 = (cozeConfig) => {
|
|
6158
|
-
if (_optionalChain$
|
|
6160
|
+
if (_optionalChain$a([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6159
6161
|
logger.info('[patch-expo-validate] NOT APPLY: dev.validate exists');
|
|
6160
6162
|
return false;
|
|
6161
6163
|
}
|
|
@@ -6207,7 +6209,7 @@ const isPackageJsonValid$3 = async (projectFolder) => {
|
|
|
6207
6209
|
* @returns
|
|
6208
6210
|
*/
|
|
6209
6211
|
const isScriptValid$3 = async (projectFolder) => {
|
|
6210
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$
|
|
6212
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$4);
|
|
6211
6213
|
if (await isFileExists(validateScriptPath)) {
|
|
6212
6214
|
logger.info('NOT APPLY: validate.sh already exists');
|
|
6213
6215
|
return false;
|
|
@@ -6241,7 +6243,7 @@ const patchPackageJson$3 = async (projectFolder) => {
|
|
|
6241
6243
|
* @returns
|
|
6242
6244
|
*/
|
|
6243
6245
|
const patchValidateScript$3 = async (projectFolder) => {
|
|
6244
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$
|
|
6246
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$4);
|
|
6245
6247
|
await fs$1.mkdir(path.join(projectFolder, '.cozeproj', 'scripts'), { recursive: true });
|
|
6246
6248
|
await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT$3, 'utf-8');
|
|
6247
6249
|
logger.info('[patch-expo-validate] validate.sh patched');
|
|
@@ -6261,7 +6263,7 @@ const patchCoze$3 = (cozeConfig) => {
|
|
|
6261
6263
|
};
|
|
6262
6264
|
|
|
6263
6265
|
const patchExpoValidate = {
|
|
6264
|
-
id: PATCH_ID$
|
|
6266
|
+
id: PATCH_ID$7,
|
|
6265
6267
|
template: 'expo',
|
|
6266
6268
|
disabled: byFlag(EXPO_VALIDATE_FLAG),
|
|
6267
6269
|
operations: [
|
|
@@ -6272,7 +6274,7 @@ const patchExpoValidate = {
|
|
|
6272
6274
|
},
|
|
6273
6275
|
{
|
|
6274
6276
|
kind: 'create-file',
|
|
6275
|
-
file: VALIDATE_SCRIPT_FILE$
|
|
6277
|
+
file: VALIDATE_SCRIPT_FILE$4,
|
|
6276
6278
|
description: 'Add validate shell script for expo projects',
|
|
6277
6279
|
},
|
|
6278
6280
|
{
|
|
@@ -6294,22 +6296,22 @@ const patchExpoValidate = {
|
|
|
6294
6296
|
|
|
6295
6297
|
return {
|
|
6296
6298
|
applied: true,
|
|
6297
|
-
patchId: PATCH_ID$
|
|
6299
|
+
patchId: PATCH_ID$7,
|
|
6298
6300
|
message: 'expo validate patched',
|
|
6299
6301
|
};
|
|
6300
6302
|
},
|
|
6301
6303
|
};
|
|
6302
6304
|
|
|
6303
|
-
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; }
|
|
6304
6306
|
|
|
6305
6307
|
|
|
6306
6308
|
|
|
6307
6309
|
|
|
6308
6310
|
|
|
6309
6311
|
|
|
6310
|
-
const PATCH_ID$
|
|
6312
|
+
const PATCH_ID$6 = 'nextjs/validate@0.0.20';
|
|
6311
6313
|
const PACKAGE_JSON_FILE$3 = 'package.json';
|
|
6312
|
-
const VALIDATE_SCRIPT_FILE$
|
|
6314
|
+
const VALIDATE_SCRIPT_FILE$3 = 'scripts/validate.sh';
|
|
6313
6315
|
const NEXTJS_VALIDATE_FLAG = 'coding.arch.patch_nextjs_validate';
|
|
6314
6316
|
const TARGET_LINT_BUILD$2 = 'eslint . --quiet';
|
|
6315
6317
|
const TARGET_VALIDATE$2 = "pnpm run --parallel '/^(ts-check|lint:build)$/'";
|
|
@@ -6333,7 +6335,7 @@ echo "Validate passed!"
|
|
|
6333
6335
|
* @returns
|
|
6334
6336
|
*/
|
|
6335
6337
|
const isCozeValid$2 = (cozeConfig) => {
|
|
6336
|
-
if (_optionalChain$
|
|
6338
|
+
if (_optionalChain$9([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6337
6339
|
logger.info('[patch-nextjs-validate] NOT APPLY: dev.validate exists');
|
|
6338
6340
|
return false;
|
|
6339
6341
|
}
|
|
@@ -6381,7 +6383,7 @@ const isPackageJsonValid$2 = async (projectFolder) => {
|
|
|
6381
6383
|
* @returns
|
|
6382
6384
|
*/
|
|
6383
6385
|
const isScriptValid$2 = async (projectFolder) => {
|
|
6384
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$
|
|
6386
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$3);
|
|
6385
6387
|
if (await isFileExists(validateScriptPath)) {
|
|
6386
6388
|
logger.info(
|
|
6387
6389
|
'[patch-nextjs-validate] NOT APPLY: validate.sh already exists',
|
|
@@ -6422,7 +6424,7 @@ const patchPackageJson$2 = async (projectFolder) => {
|
|
|
6422
6424
|
* @returns
|
|
6423
6425
|
*/
|
|
6424
6426
|
const patchValidateScript$2 = async (projectFolder) => {
|
|
6425
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$
|
|
6427
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$3);
|
|
6426
6428
|
await fs$1.mkdir(path.join(projectFolder, 'scripts'), { recursive: true });
|
|
6427
6429
|
await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT$2, 'utf-8');
|
|
6428
6430
|
logger.info('[patch-nextjs-validate] validate.sh patched');
|
|
@@ -6442,7 +6444,7 @@ const patchCoze$2 = (cozeConfig) => {
|
|
|
6442
6444
|
};
|
|
6443
6445
|
|
|
6444
6446
|
const patchNextjsValidate = {
|
|
6445
|
-
id: PATCH_ID$
|
|
6447
|
+
id: PATCH_ID$6,
|
|
6446
6448
|
template: 'nextjs',
|
|
6447
6449
|
disabled: byFlag(NEXTJS_VALIDATE_FLAG),
|
|
6448
6450
|
operations: [
|
|
@@ -6453,7 +6455,7 @@ const patchNextjsValidate = {
|
|
|
6453
6455
|
},
|
|
6454
6456
|
{
|
|
6455
6457
|
kind: 'create-file',
|
|
6456
|
-
file: VALIDATE_SCRIPT_FILE$
|
|
6458
|
+
file: VALIDATE_SCRIPT_FILE$3,
|
|
6457
6459
|
description: 'Add validate shell script for nextjs projects',
|
|
6458
6460
|
},
|
|
6459
6461
|
{
|
|
@@ -6475,22 +6477,22 @@ const patchNextjsValidate = {
|
|
|
6475
6477
|
|
|
6476
6478
|
return {
|
|
6477
6479
|
applied: true,
|
|
6478
|
-
patchId: PATCH_ID$
|
|
6480
|
+
patchId: PATCH_ID$6,
|
|
6479
6481
|
message: 'nextjs validate patched',
|
|
6480
6482
|
};
|
|
6481
6483
|
},
|
|
6482
6484
|
};
|
|
6483
6485
|
|
|
6484
|
-
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; }
|
|
6485
6487
|
|
|
6486
6488
|
|
|
6487
6489
|
|
|
6488
6490
|
|
|
6489
6491
|
|
|
6490
6492
|
|
|
6491
|
-
const PATCH_ID$
|
|
6493
|
+
const PATCH_ID$5 = 'vite/validate@0.0.20';
|
|
6492
6494
|
const PACKAGE_JSON_FILE$2 = 'package.json';
|
|
6493
|
-
const VALIDATE_SCRIPT_FILE$
|
|
6495
|
+
const VALIDATE_SCRIPT_FILE$2 = 'scripts/validate.sh';
|
|
6494
6496
|
const VITE_VALIDATE_FLAG = 'coding.arch.patch_vite_validate';
|
|
6495
6497
|
const TARGET_LINT_BUILD$1 = 'eslint . --quiet';
|
|
6496
6498
|
const TARGET_VALIDATE$1 = "pnpm run --parallel '/^(ts-check|lint:build)$/'";
|
|
@@ -6514,7 +6516,7 @@ echo "Validate passed!"
|
|
|
6514
6516
|
* @returns
|
|
6515
6517
|
*/
|
|
6516
6518
|
const isCozeValid$1 = (cozeConfig) => {
|
|
6517
|
-
if (_optionalChain$
|
|
6519
|
+
if (_optionalChain$8([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6518
6520
|
logger.info('[patch-vite-validate] NOT APPLY: dev.validate exists');
|
|
6519
6521
|
return false;
|
|
6520
6522
|
}
|
|
@@ -6562,7 +6564,7 @@ const isPackageJsonValid$1 = async (projectFolder) => {
|
|
|
6562
6564
|
* @returns
|
|
6563
6565
|
*/
|
|
6564
6566
|
const isScriptValid$1 = async (projectFolder) => {
|
|
6565
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$
|
|
6567
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$2);
|
|
6566
6568
|
if (await isFileExists(validateScriptPath)) {
|
|
6567
6569
|
logger.info('[patch-vite-validate] NOT APPLY: validate.sh already exists');
|
|
6568
6570
|
return false;
|
|
@@ -6600,7 +6602,7 @@ const patchPackageJson$1 = async (projectFolder) => {
|
|
|
6600
6602
|
* @returns
|
|
6601
6603
|
*/
|
|
6602
6604
|
const patchValidateScript$1 = async (projectFolder) => {
|
|
6603
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$
|
|
6605
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$2);
|
|
6604
6606
|
await fs$1.mkdir(path.join(projectFolder, 'scripts'), { recursive: true });
|
|
6605
6607
|
await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT$1, 'utf-8');
|
|
6606
6608
|
logger.info('[patch-vite-validate] validate.sh patched');
|
|
@@ -6620,7 +6622,7 @@ const patchCoze$1 = (cozeConfig) => {
|
|
|
6620
6622
|
};
|
|
6621
6623
|
|
|
6622
6624
|
const patchViteValidate = {
|
|
6623
|
-
id: PATCH_ID$
|
|
6625
|
+
id: PATCH_ID$5,
|
|
6624
6626
|
template: 'vite',
|
|
6625
6627
|
disabled: byFlag(VITE_VALIDATE_FLAG),
|
|
6626
6628
|
operations: [
|
|
@@ -6631,7 +6633,7 @@ const patchViteValidate = {
|
|
|
6631
6633
|
},
|
|
6632
6634
|
{
|
|
6633
6635
|
kind: 'create-file',
|
|
6634
|
-
file: VALIDATE_SCRIPT_FILE$
|
|
6636
|
+
file: VALIDATE_SCRIPT_FILE$2,
|
|
6635
6637
|
description: 'Add validate shell script for vite projects',
|
|
6636
6638
|
},
|
|
6637
6639
|
{
|
|
@@ -6653,22 +6655,22 @@ const patchViteValidate = {
|
|
|
6653
6655
|
|
|
6654
6656
|
return {
|
|
6655
6657
|
applied: true,
|
|
6656
|
-
patchId: PATCH_ID$
|
|
6658
|
+
patchId: PATCH_ID$5,
|
|
6657
6659
|
message: 'vite validate patched',
|
|
6658
6660
|
};
|
|
6659
6661
|
},
|
|
6660
6662
|
};
|
|
6661
6663
|
|
|
6662
|
-
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; }
|
|
6663
6665
|
|
|
6664
6666
|
|
|
6665
6667
|
|
|
6666
6668
|
|
|
6667
6669
|
|
|
6668
6670
|
|
|
6669
|
-
const PATCH_ID$
|
|
6671
|
+
const PATCH_ID$4 = 'taro/validate@0.0.20';
|
|
6670
6672
|
const PACKAGE_JSON_FILE$1 = 'package.json';
|
|
6671
|
-
const VALIDATE_SCRIPT_FILE = '.cozeproj/scripts/validate.sh';
|
|
6673
|
+
const VALIDATE_SCRIPT_FILE$1 = '.cozeproj/scripts/validate.sh';
|
|
6672
6674
|
const TARO_VALIDATE_FLAG = 'coding.arch.patch_taro_validate';
|
|
6673
6675
|
|
|
6674
6676
|
const LEGACY_LINT_BUILD =
|
|
@@ -6696,7 +6698,7 @@ echo "Validate passed!"
|
|
|
6696
6698
|
* @returns
|
|
6697
6699
|
*/
|
|
6698
6700
|
const isCozeValid = (cozeConfig) => {
|
|
6699
|
-
if (_optionalChain$
|
|
6701
|
+
if (_optionalChain$7([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6700
6702
|
logger.info('[patch-taro-validate] NOT APPLY: dev.validate exists');
|
|
6701
6703
|
return false;
|
|
6702
6704
|
}
|
|
@@ -6746,7 +6748,7 @@ const isPackageJsonValid = async (projectFolder) => {
|
|
|
6746
6748
|
* @returns
|
|
6747
6749
|
*/
|
|
6748
6750
|
const isScriptValid = async (projectFolder) => {
|
|
6749
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE);
|
|
6751
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$1);
|
|
6750
6752
|
if (await isFileExists(validateScriptPath)) {
|
|
6751
6753
|
logger.info('[patch-taro-validate] NOT APPLY: validate.sh already exists');
|
|
6752
6754
|
return false;
|
|
@@ -6787,7 +6789,7 @@ const patchPackageJson = async (projectFolder) => {
|
|
|
6787
6789
|
* @returns
|
|
6788
6790
|
*/
|
|
6789
6791
|
const patchValidateScript = async (projectFolder) => {
|
|
6790
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE);
|
|
6792
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$1);
|
|
6791
6793
|
await fs$1.mkdir(path.join(projectFolder, '.cozeproj', 'scripts'), { recursive: true });
|
|
6792
6794
|
await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT, 'utf-8');
|
|
6793
6795
|
logger.info('[patch-taro-validate] validate.sh patched');
|
|
@@ -6807,7 +6809,7 @@ const patchCoze = (cozeConfig) => {
|
|
|
6807
6809
|
};
|
|
6808
6810
|
|
|
6809
6811
|
const patchTaroValidate = {
|
|
6810
|
-
id: PATCH_ID$
|
|
6812
|
+
id: PATCH_ID$4,
|
|
6811
6813
|
template: 'taro',
|
|
6812
6814
|
disabled: byFlag(TARO_VALIDATE_FLAG),
|
|
6813
6815
|
operations: [
|
|
@@ -6819,7 +6821,7 @@ const patchTaroValidate = {
|
|
|
6819
6821
|
},
|
|
6820
6822
|
{
|
|
6821
6823
|
kind: 'create-file',
|
|
6822
|
-
file: VALIDATE_SCRIPT_FILE,
|
|
6824
|
+
file: VALIDATE_SCRIPT_FILE$1,
|
|
6823
6825
|
description: 'Add validate shell script for taro projects',
|
|
6824
6826
|
},
|
|
6825
6827
|
{
|
|
@@ -6839,14 +6841,14 @@ const patchTaroValidate = {
|
|
|
6839
6841
|
|
|
6840
6842
|
return {
|
|
6841
6843
|
applied: true,
|
|
6842
|
-
patchId: PATCH_ID$
|
|
6844
|
+
patchId: PATCH_ID$4,
|
|
6843
6845
|
message: 'taro validate patched',
|
|
6844
6846
|
};
|
|
6845
6847
|
},
|
|
6846
6848
|
};
|
|
6847
6849
|
|
|
6848
|
-
function _optionalChain$
|
|
6849
|
-
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';
|
|
6850
6852
|
const PACKAGE_JSON_FILE = 'package.json';
|
|
6851
6853
|
const PACK_SCRIPT_FILE = '.cozeproj/scripts/pack.sh';
|
|
6852
6854
|
const LEGACY_PACK_SCRIPT_HASHES = new Set([
|
|
@@ -6924,12 +6926,12 @@ const readPackageScripts = async (
|
|
|
6924
6926
|
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6925
6927
|
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
6926
6928
|
|
|
6927
|
-
return _optionalChain$
|
|
6929
|
+
return _optionalChain$6([packageJson, 'optionalAccess', _ => _.scripts]) || null;
|
|
6928
6930
|
};
|
|
6929
6931
|
|
|
6930
6932
|
const hasBuildTtScript = async (projectFolder) => {
|
|
6931
6933
|
const scripts = await readPackageScripts(projectFolder);
|
|
6932
|
-
return typeof _optionalChain$
|
|
6934
|
+
return typeof _optionalChain$6([scripts, 'optionalAccess', _2 => _2['build:tt']]) === 'string';
|
|
6933
6935
|
};
|
|
6934
6936
|
|
|
6935
6937
|
const hasLegacyPackScript = async (projectFolder) => {
|
|
@@ -6943,7 +6945,7 @@ const hasLegacyPackScript = async (projectFolder) => {
|
|
|
6943
6945
|
};
|
|
6944
6946
|
|
|
6945
6947
|
const patchTaroPackScript = {
|
|
6946
|
-
id: PATCH_ID$
|
|
6948
|
+
id: PATCH_ID$3,
|
|
6947
6949
|
template: 'taro',
|
|
6948
6950
|
disabled: byFlag('coding.arch.patch_taro_update_pack_script_for_tt_build'),
|
|
6949
6951
|
operations: [
|
|
@@ -6962,7 +6964,7 @@ const patchTaroPackScript = {
|
|
|
6962
6964
|
if (context.template !== 'taro') {
|
|
6963
6965
|
return {
|
|
6964
6966
|
applied: false,
|
|
6965
|
-
patchId: PATCH_ID$
|
|
6967
|
+
patchId: PATCH_ID$3,
|
|
6966
6968
|
message: 'Only applies to taro projects, skipping',
|
|
6967
6969
|
};
|
|
6968
6970
|
}
|
|
@@ -6970,7 +6972,7 @@ const patchTaroPackScript = {
|
|
|
6970
6972
|
if (!(await hasBuildTtScript(context.projectFolder))) {
|
|
6971
6973
|
return {
|
|
6972
6974
|
applied: false,
|
|
6973
|
-
patchId: PATCH_ID$
|
|
6975
|
+
patchId: PATCH_ID$3,
|
|
6974
6976
|
message: 'package.json does not contain build:tt, skipping',
|
|
6975
6977
|
};
|
|
6976
6978
|
}
|
|
@@ -6978,7 +6980,7 @@ const patchTaroPackScript = {
|
|
|
6978
6980
|
if (!(await hasLegacyPackScript(context.projectFolder))) {
|
|
6979
6981
|
return {
|
|
6980
6982
|
applied: false,
|
|
6981
|
-
patchId: PATCH_ID$
|
|
6983
|
+
patchId: PATCH_ID$3,
|
|
6982
6984
|
message: 'pack.sh does not match legacy template hash, skipping',
|
|
6983
6985
|
};
|
|
6984
6986
|
}
|
|
@@ -6992,13 +6994,13 @@ const patchTaroPackScript = {
|
|
|
6992
6994
|
|
|
6993
6995
|
return {
|
|
6994
6996
|
applied: true,
|
|
6995
|
-
patchId: PATCH_ID$
|
|
6997
|
+
patchId: PATCH_ID$3,
|
|
6996
6998
|
message: 'Updated legacy pack.sh to build weapp and tt targets',
|
|
6997
6999
|
};
|
|
6998
7000
|
},
|
|
6999
7001
|
};
|
|
7000
7002
|
|
|
7001
|
-
const PATCH_ID$
|
|
7003
|
+
const PATCH_ID$2 = 'taro/add-agents-md@0.0.13';
|
|
7002
7004
|
const AGENTS_FILE = 'AGENTS.md';
|
|
7003
7005
|
const getTemplateAgentsPath = () =>
|
|
7004
7006
|
path.join(getTemplatesDir(), 'taro', AGENTS_FILE);
|
|
@@ -7010,7 +7012,7 @@ const readTemplateAgentsContent = async () =>
|
|
|
7010
7012
|
fs$1.readFile(getTemplateAgentsPath(), 'utf-8');
|
|
7011
7013
|
|
|
7012
7014
|
const patchTaroAgentsMd = {
|
|
7013
|
-
id: PATCH_ID$
|
|
7015
|
+
id: PATCH_ID$2,
|
|
7014
7016
|
template: 'taro',
|
|
7015
7017
|
disabled: byFlag('coding.arch.patch_taro_add_agents_md'),
|
|
7016
7018
|
operations: [
|
|
@@ -7028,7 +7030,7 @@ const patchTaroAgentsMd = {
|
|
|
7028
7030
|
if (context.template !== 'taro') {
|
|
7029
7031
|
return {
|
|
7030
7032
|
applied: false,
|
|
7031
|
-
patchId: PATCH_ID$
|
|
7033
|
+
patchId: PATCH_ID$2,
|
|
7032
7034
|
message: 'Only applies to taro projects, skipping',
|
|
7033
7035
|
};
|
|
7034
7036
|
}
|
|
@@ -7037,7 +7039,7 @@ const patchTaroAgentsMd = {
|
|
|
7037
7039
|
if (await isFileExists(targetPath)) {
|
|
7038
7040
|
return {
|
|
7039
7041
|
applied: false,
|
|
7040
|
-
patchId: PATCH_ID$
|
|
7042
|
+
patchId: PATCH_ID$2,
|
|
7041
7043
|
message: 'AGENTS.md already exists, skipping',
|
|
7042
7044
|
};
|
|
7043
7045
|
}
|
|
@@ -7047,12 +7049,160 @@ const patchTaroAgentsMd = {
|
|
|
7047
7049
|
|
|
7048
7050
|
return {
|
|
7049
7051
|
applied: true,
|
|
7050
|
-
patchId: PATCH_ID$
|
|
7052
|
+
patchId: PATCH_ID$2,
|
|
7051
7053
|
message: 'Created AGENTS.md from taro template',
|
|
7052
7054
|
};
|
|
7053
7055
|
},
|
|
7054
7056
|
};
|
|
7055
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
|
+
|
|
7056
7206
|
const SCRIPT_FILES = ['dev.sh', 'build.sh'] ;
|
|
7057
7207
|
const SUPPORTED_TEMPLATES = new Set(['nextjs', 'vite', 'nuxt-vue']);
|
|
7058
7208
|
|
|
@@ -7268,6 +7418,7 @@ const patches = [
|
|
|
7268
7418
|
patchExpoValidate,
|
|
7269
7419
|
replaceNpxWithPnpmPatchNextjs,
|
|
7270
7420
|
patchNextjsValidate,
|
|
7421
|
+
patchNextjsValidateRunner,
|
|
7271
7422
|
replaceNpxWithPnpmPatchVite,
|
|
7272
7423
|
patchViteValidate,
|
|
7273
7424
|
replaceNpxWithPnpmPatchNuxtVue,
|
|
@@ -7277,12 +7428,9 @@ const patches = [
|
|
|
7277
7428
|
patchTaroPackScript,
|
|
7278
7429
|
] ;
|
|
7279
7430
|
|
|
7280
|
-
const getTemplatePatches = (
|
|
7281
|
-
template,
|
|
7282
|
-
) =>
|
|
7283
|
-
patches.filter(patch => patch.template === template);
|
|
7431
|
+
const getTemplatePatches = (template) => patches.filter(patch => patch.template === template);
|
|
7284
7432
|
|
|
7285
|
-
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; }
|
|
7286
7434
|
const DEFAULT_LEGACY_VERSION = 'legacy';
|
|
7287
7435
|
|
|
7288
7436
|
const loadFlagsWithFallback = async () => {
|
|
@@ -7388,7 +7536,7 @@ const getNextPatchState = (
|
|
|
7388
7536
|
|
|
7389
7537
|
) => ({
|
|
7390
7538
|
template,
|
|
7391
|
-
version: _optionalChain$
|
|
7539
|
+
version: _optionalChain$4([config, 'access', _ => _.project, 'optionalAccess', _2 => _2.version]) || DEFAULT_LEGACY_VERSION,
|
|
7392
7540
|
appliedPatches: [...appliedPatches, patchId],
|
|
7393
7541
|
});
|
|
7394
7542
|
|
|
@@ -7412,15 +7560,15 @@ const executePatch = async (
|
|
|
7412
7560
|
}
|
|
7413
7561
|
|
|
7414
7562
|
const template =
|
|
7415
|
-
_optionalChain$
|
|
7563
|
+
_optionalChain$4([config, 'access', _3 => _3.project, 'optionalAccess', _4 => _4.template]) || (await detectTemplateKey(projectFolder));
|
|
7416
7564
|
|
|
7417
7565
|
if (!template) {
|
|
7418
7566
|
logger.info('Patch skipped: template not detected');
|
|
7419
7567
|
return;
|
|
7420
7568
|
}
|
|
7421
7569
|
|
|
7422
|
-
const appliedPatches = [...(_optionalChain$
|
|
7423
|
-
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]);
|
|
7424
7572
|
const flags = await loadFlagsWithFallback();
|
|
7425
7573
|
|
|
7426
7574
|
const context = {
|
|
@@ -7465,7 +7613,7 @@ const executePatch = async (
|
|
|
7465
7613
|
|
|
7466
7614
|
if (options.dryRun) {
|
|
7467
7615
|
logger.info(`Detected template: ${template}`);
|
|
7468
|
-
logger.info(`Current version: ${_nullishCoalesce$
|
|
7616
|
+
logger.info(`Current version: ${_nullishCoalesce$4(projectVersion, () => ( DEFAULT_LEGACY_VERSION))}`);
|
|
7469
7617
|
logger.info(`Applied patches: ${appliedPatches.join(', ') || '(none)'}`);
|
|
7470
7618
|
logger.info('Matched patches:');
|
|
7471
7619
|
matchedPatches.forEach(patch => {
|
|
@@ -7506,7 +7654,7 @@ const executePatch = async (
|
|
|
7506
7654
|
}
|
|
7507
7655
|
};
|
|
7508
7656
|
|
|
7509
|
-
const registerCommand$
|
|
7657
|
+
const registerCommand$5 = program => {
|
|
7510
7658
|
program
|
|
7511
7659
|
.command('patch')
|
|
7512
7660
|
.description('Apply template patches for existing projects')
|
|
@@ -7523,14 +7671,14 @@ const registerCommand$4 = program => {
|
|
|
7523
7671
|
) => {
|
|
7524
7672
|
await executePatch({
|
|
7525
7673
|
directory,
|
|
7526
|
-
dryRun: _optionalChain$
|
|
7527
|
-
showFlags: _optionalChain$
|
|
7674
|
+
dryRun: _optionalChain$4([command, 'optionalAccess', _9 => _9.dryRun]),
|
|
7675
|
+
showFlags: _optionalChain$4([command, 'optionalAccess', _10 => _10.showFlags]),
|
|
7528
7676
|
});
|
|
7529
7677
|
},
|
|
7530
7678
|
);
|
|
7531
7679
|
};
|
|
7532
7680
|
|
|
7533
|
-
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; }
|
|
7534
7682
|
const d$1 = debug('coze-init-cli:run');
|
|
7535
7683
|
|
|
7536
7684
|
/**
|
|
@@ -7661,12 +7809,12 @@ const executeRun = async (commandName, options = {}) => {
|
|
|
7661
7809
|
}
|
|
7662
7810
|
|
|
7663
7811
|
// 将输出同时写入控制台和日志文件
|
|
7664
|
-
_optionalChain$
|
|
7812
|
+
_optionalChain$3([childProcess, 'access', _ => _.stdout, 'optionalAccess', _2 => _2.on, 'call', _3 => _3('data', (data) => {
|
|
7665
7813
|
process.stdout.write(data);
|
|
7666
7814
|
logStream.write(data);
|
|
7667
7815
|
})]);
|
|
7668
7816
|
|
|
7669
|
-
_optionalChain$
|
|
7817
|
+
_optionalChain$3([childProcess, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6('data', (data) => {
|
|
7670
7818
|
process.stderr.write(data);
|
|
7671
7819
|
logStream.write(data);
|
|
7672
7820
|
})]);
|
|
@@ -7679,7 +7827,7 @@ const executeRun = async (commandName, options = {}) => {
|
|
|
7679
7827
|
const buildDuration = Date.now() - buildStartTime;
|
|
7680
7828
|
|
|
7681
7829
|
if (code !== 0) {
|
|
7682
|
-
const errorMessage = `Command exited with code ${_nullishCoalesce$
|
|
7830
|
+
const errorMessage = `Command exited with code ${_nullishCoalesce$3(code, () => ( 'unknown'))}${signal ? ` and signal ${signal}` : ''}`;
|
|
7683
7831
|
logger.error(errorMessage);
|
|
7684
7832
|
logger.error(`Check log file for details: ${logFilePath}`);
|
|
7685
7833
|
|
|
@@ -7691,12 +7839,12 @@ const executeRun = async (commandName, options = {}) => {
|
|
|
7691
7839
|
categories: {
|
|
7692
7840
|
fixDuration: String(fixDuration),
|
|
7693
7841
|
buildDuration: String(buildDuration),
|
|
7694
|
-
exitCode: String(_nullishCoalesce$
|
|
7842
|
+
exitCode: String(_nullishCoalesce$3(code, () => ( 'unknown'))),
|
|
7695
7843
|
projectType,
|
|
7696
7844
|
},
|
|
7697
7845
|
errorContext: {
|
|
7698
|
-
exitCode: String(_nullishCoalesce$
|
|
7699
|
-
signal: _nullishCoalesce$
|
|
7846
|
+
exitCode: String(_nullishCoalesce$3(code, () => ( 'unknown'))),
|
|
7847
|
+
signal: _nullishCoalesce$3(signal, () => ( 'none')),
|
|
7700
7848
|
logFile: logFilePath,
|
|
7701
7849
|
projectType,
|
|
7702
7850
|
},
|
|
@@ -7772,7 +7920,7 @@ const executeRun = async (commandName, options = {}) => {
|
|
|
7772
7920
|
/**
|
|
7773
7921
|
* 注册 dev/build/start 命令到 program
|
|
7774
7922
|
*/
|
|
7775
|
-
const registerCommand$
|
|
7923
|
+
const registerCommand$4 = program => {
|
|
7776
7924
|
// dev 命令
|
|
7777
7925
|
program
|
|
7778
7926
|
.command('dev')
|
|
@@ -8600,7 +8748,7 @@ const scanRoutesOnce = async (
|
|
|
8600
8748
|
}
|
|
8601
8749
|
};
|
|
8602
8750
|
|
|
8603
|
-
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
|
|
8604
8752
|
|
|
8605
8753
|
|
|
8606
8754
|
const log = debug('coze:routes');
|
|
@@ -8688,7 +8836,7 @@ const executeRoutes = async (
|
|
|
8688
8836
|
/**
|
|
8689
8837
|
* Register routes command to program
|
|
8690
8838
|
*/
|
|
8691
|
-
const registerCommand$
|
|
8839
|
+
const registerCommand$3 = program => {
|
|
8692
8840
|
program
|
|
8693
8841
|
.command('routes')
|
|
8694
8842
|
.description('Generate routes manifest for the current project')
|
|
@@ -8701,14 +8849,13 @@ const registerCommand$2 = program => {
|
|
|
8701
8849
|
'Output file path (defaults to ~/.coze/routes.json)',
|
|
8702
8850
|
)
|
|
8703
8851
|
.action(async (directory, options) => {
|
|
8704
|
-
await executeRoutes({ directory, output: _optionalChain([options, 'optionalAccess', _ => _.output]) });
|
|
8852
|
+
await executeRoutes({ directory, output: _optionalChain$2([options, 'optionalAccess', _ => _.output]) });
|
|
8705
8853
|
});
|
|
8706
8854
|
};
|
|
8707
8855
|
|
|
8708
|
-
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; }
|
|
8709
8857
|
|
|
8710
8858
|
|
|
8711
|
-
const d = debug('coze-init-cli:check-bins');
|
|
8712
8859
|
|
|
8713
8860
|
|
|
8714
8861
|
|
|
@@ -8716,117 +8863,97 @@ const d = debug('coze-init-cli:check-bins');
|
|
|
8716
8863
|
|
|
8717
8864
|
|
|
8718
8865
|
|
|
8719
|
-
const checkBins = async (cwd, fix) => {
|
|
8720
|
-
d('starting check, cwd=%s fix=%s', cwd, fix);
|
|
8721
8866
|
|
|
8722
|
-
const pkgJson = safeJsonParse
|
|
8723
8867
|
|
|
8724
8868
|
|
|
8725
|
-
|
|
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
|
+
});
|
|
8726
8877
|
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
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
|
+
});
|
|
8730
8899
|
});
|
|
8731
8900
|
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
await Promise.all(
|
|
8739
|
-
allDeps.map(async depName => {
|
|
8740
|
-
let rawContent;
|
|
8741
|
-
try {
|
|
8742
|
-
rawContent = await fs$1.readFile(
|
|
8743
|
-
path.join(cwd, 'node_modules', depName, 'package.json'),
|
|
8744
|
-
'utf8',
|
|
8745
|
-
);
|
|
8746
|
-
} catch (err) {
|
|
8747
|
-
d('dep %s not found in node_modules: %s', depName, err);
|
|
8748
|
-
missing.push({ dep: depName, bin: '', reason: 'missing-package' });
|
|
8749
|
-
return;
|
|
8750
|
-
}
|
|
8751
|
-
const depPkg = safeJsonParse(
|
|
8752
|
-
rawContent,
|
|
8753
|
-
);
|
|
8754
|
-
if (!depPkg) {
|
|
8755
|
-
d('skipping %s: failed to parse package.json', depName);
|
|
8756
|
-
return;
|
|
8757
|
-
}
|
|
8758
|
-
|
|
8759
|
-
if (!depPkg.bin) {
|
|
8760
|
-
return;
|
|
8761
|
-
}
|
|
8762
|
-
|
|
8763
|
-
const bins =
|
|
8764
|
-
typeof depPkg.bin === 'string'
|
|
8765
|
-
? { [_nullishCoalesce$1(depName.split('/').pop(), () => ( depName))]: depPkg.bin }
|
|
8766
|
-
: depPkg.bin;
|
|
8767
|
-
|
|
8768
|
-
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
|
+
}
|
|
8769
8906
|
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
d('bin present: %s', binName);
|
|
8775
|
-
} catch (err) {
|
|
8776
|
-
d('bin missing: %s (from %s): %s', binName, depName, err);
|
|
8777
|
-
missing.push({ dep: depName, bin: binName, reason: 'missing-bin' });
|
|
8778
|
-
}
|
|
8779
|
-
}),
|
|
8780
|
-
);
|
|
8781
|
-
}),
|
|
8782
|
-
);
|
|
8907
|
+
const resolvedOptions = {
|
|
8908
|
+
cwd: options.cwd || process.cwd(),
|
|
8909
|
+
packageManager: options.packageManager || 'pnpm',
|
|
8910
|
+
};
|
|
8783
8911
|
|
|
8784
|
-
|
|
8912
|
+
process.stdout.write(`Running ${scripts.length} script(s) in parallel...\n`);
|
|
8913
|
+
scripts.forEach(script => {
|
|
8914
|
+
process.stdout.write(`[${script}] started\n`);
|
|
8915
|
+
});
|
|
8785
8916
|
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
'check-bins: all bin entries present, skipping force install.',
|
|
8789
|
-
);
|
|
8790
|
-
return;
|
|
8791
|
-
}
|
|
8917
|
+
const results = await Promise.all(scripts.map(script => runScript(script, resolvedOptions)));
|
|
8918
|
+
const failedResults = results.filter(result => result.code !== 0);
|
|
8792
8919
|
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
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`);
|
|
8797
8923
|
} else {
|
|
8798
|
-
|
|
8924
|
+
process.stdout.write(`[${result.script}] failed (exit ${result.code})\n`);
|
|
8799
8925
|
}
|
|
8800
|
-
}
|
|
8926
|
+
});
|
|
8801
8927
|
|
|
8802
|
-
if (
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
);
|
|
8806
|
-
process.exit(1);
|
|
8928
|
+
if (failedResults.length === 0) {
|
|
8929
|
+
process.stdout.write('Parallel scripts passed.\n');
|
|
8930
|
+
return 0;
|
|
8807
8931
|
}
|
|
8808
8932
|
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
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;
|
|
8813
8944
|
};
|
|
8814
8945
|
|
|
8815
|
-
const registerCommand$
|
|
8946
|
+
const registerCommand$2 = program => {
|
|
8816
8947
|
program
|
|
8817
|
-
.command('
|
|
8818
|
-
.description(
|
|
8819
|
-
|
|
8820
|
-
)
|
|
8821
|
-
.option('-
|
|
8822
|
-
.
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
} catch (err) {
|
|
8827
|
-
logger.warn(
|
|
8828
|
-
`check-bins: skipped due to error: ${err instanceof Error ? err.message : String(err)}`,
|
|
8829
|
-
);
|
|
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);
|
|
8830
8957
|
}
|
|
8831
8958
|
});
|
|
8832
8959
|
};
|
|
@@ -9706,7 +9833,7 @@ const execute = async (
|
|
|
9706
9833
|
};
|
|
9707
9834
|
};
|
|
9708
9835
|
|
|
9709
|
-
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(); } }
|
|
9710
9837
|
/**
|
|
9711
9838
|
* 运行 pnpm install
|
|
9712
9839
|
*/
|
|
@@ -9896,7 +10023,7 @@ const executeTemplateEngineStep = async ctx => {
|
|
|
9896
10023
|
templateName: ctx.templateName,
|
|
9897
10024
|
outputPath: ctx.outputPath,
|
|
9898
10025
|
command: ctx.command,
|
|
9899
|
-
force: _nullishCoalesce(ctx.options.force, () => ( false)),
|
|
10026
|
+
force: _nullishCoalesce$1(ctx.options.force, () => ( false)),
|
|
9900
10027
|
});
|
|
9901
10028
|
|
|
9902
10029
|
// 保存结果到上下文
|
|
@@ -10155,7 +10282,7 @@ const executeInit = async (
|
|
|
10155
10282
|
/**
|
|
10156
10283
|
* 注册 init 命令到 program
|
|
10157
10284
|
*/
|
|
10158
|
-
const registerCommand = program => {
|
|
10285
|
+
const registerCommand$1 = program => {
|
|
10159
10286
|
program
|
|
10160
10287
|
.command('init')
|
|
10161
10288
|
.description('Initialize a new project from a template')
|
|
@@ -10173,21 +10300,149 @@ const registerCommand = program => {
|
|
|
10173
10300
|
.allowUnknownOption() // 允许透传参数
|
|
10174
10301
|
.action(async (directory, options, command) => {
|
|
10175
10302
|
// 位置参数优先级高于 --output 选项
|
|
10176
|
-
const outputPath = _nullishCoalesce(directory, () => ( options.output));
|
|
10303
|
+
const outputPath = _nullishCoalesce$1(directory, () => ( options.output));
|
|
10177
10304
|
// Always use force mode - overwrite existing files without conflict check
|
|
10178
10305
|
const force = true;
|
|
10179
10306
|
await executeInit({ ...options, output: outputPath, force }, command);
|
|
10180
10307
|
});
|
|
10181
10308
|
};
|
|
10182
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; }
|
|
10183
10437
|
const commands = [
|
|
10184
|
-
registerCommand,
|
|
10185
|
-
registerCommand$3,
|
|
10186
|
-
registerCommand$6,
|
|
10438
|
+
registerCommand$1,
|
|
10187
10439
|
registerCommand$4,
|
|
10440
|
+
registerCommand$7,
|
|
10188
10441
|
registerCommand$5,
|
|
10442
|
+
registerCommand$6,
|
|
10443
|
+
registerCommand$3,
|
|
10444
|
+
registerCommand,
|
|
10189
10445
|
registerCommand$2,
|
|
10190
|
-
registerCommand$1,
|
|
10191
10446
|
];
|
|
10192
10447
|
|
|
10193
10448
|
const main = async () => {
|
|
@@ -10218,10 +10473,8 @@ const main = async () => {
|
|
|
10218
10473
|
const program = new commander.Command();
|
|
10219
10474
|
|
|
10220
10475
|
program
|
|
10221
|
-
.name('coze')
|
|
10222
|
-
.description(
|
|
10223
|
-
'Coze Coding CLI - Project template engine for frontend stacks',
|
|
10224
|
-
)
|
|
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')
|
|
10225
10478
|
.version(packageJson.version);
|
|
10226
10479
|
|
|
10227
10480
|
commands.forEach(initCmd => initCmd(program));
|