@coze-arch/cli 0.0.30 → 0.0.31-alpha.08f83e
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__/nextjs/scripts/prepare.sh +2 -2
- package/lib/__templates__/nextjs/scripts/validate.sh +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/scripts/prepare.sh +2 -2
- package/lib/__templates__/vite/scripts/validate.sh +1 -1
- package/lib/cli.js +569 -304
- 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$b(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }/**
|
|
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$b(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$u([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$u([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$u([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$u([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$u([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$u([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$u([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$u([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$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; }
|
|
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$t([options, 'optionalAccess', _ => _.args]),
|
|
2000
2000
|
status: 'running' ,
|
|
2001
|
-
..._optionalChain$
|
|
2001
|
+
..._optionalChain$t([options, 'optionalAccess', _2 => _2.categories]),
|
|
2002
2002
|
},
|
|
2003
|
-
metrics: _optionalChain$
|
|
2003
|
+
metrics: _optionalChain$t([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$t([options, 'optionalAccess', _4 => _4.args]),
|
|
2025
2025
|
status: success ? ('success' ) : ('fail' ),
|
|
2026
|
-
..._optionalChain$
|
|
2026
|
+
..._optionalChain$t([options, 'optionalAccess', _5 => _5.categories]),
|
|
2027
2027
|
},
|
|
2028
2028
|
metrics: {
|
|
2029
2029
|
duration,
|
|
2030
|
-
...(_optionalChain$
|
|
2030
|
+
...(_optionalChain$t([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$t([options, 'optionalAccess', _7 => _7.method]) || 'GET',
|
|
2052
|
+
statusCode: _optionalChain$t([options, 'optionalAccess', _8 => _8.statusCode, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]),
|
|
2053
|
+
status: _optionalChain$t([options, 'optionalAccess', _11 => _11.success]) ? ('success' ) : ('fail' ),
|
|
2054
2054
|
},
|
|
2055
2055
|
metrics: {
|
|
2056
|
-
duration: _optionalChain$
|
|
2056
|
+
duration: _optionalChain$t([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$t([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
|
|
2079
2079
|
},
|
|
2080
2080
|
metrics: {
|
|
2081
|
-
duration: _optionalChain$
|
|
2082
|
-
fileSize: _optionalChain$
|
|
2081
|
+
duration: _optionalChain$t([options, 'optionalAccess', _14 => _14.duration]),
|
|
2082
|
+
fileSize: _optionalChain$t([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.08f83e";
|
|
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$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; }/**
|
|
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$s([options, 'optionalAccess', _ => _.args]),
|
|
2325
|
+
errorCode: _optionalChain$s([options, 'optionalAccess', _2 => _2.errorCode]),
|
|
2324
2326
|
categories: {
|
|
2325
|
-
...(_optionalChain$
|
|
2326
|
-
..._optionalChain$
|
|
2327
|
+
...(_optionalChain$s([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
|
|
2328
|
+
..._optionalChain$s([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$a(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }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$a(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$r([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$r([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$a(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$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; }/* 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$q([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$q([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$q([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
|
|
3370
3372
|
throw error;
|
|
3371
3373
|
}
|
|
3372
|
-
_optionalChain$
|
|
3374
|
+
_optionalChain$q([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$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; }
|
|
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$p([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
|
|
3526
3528
|
if (isSeq(node))
|
|
3527
|
-
return _optionalChain$
|
|
3529
|
+
return _optionalChain$p([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
|
|
3528
3530
|
if (isPair(node))
|
|
3529
|
-
return _optionalChain$
|
|
3531
|
+
return _optionalChain$p([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
|
|
3530
3532
|
if (isScalar(node))
|
|
3531
|
-
return _optionalChain$
|
|
3533
|
+
return _optionalChain$p([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
|
|
3532
3534
|
if (isAlias(node))
|
|
3533
|
-
return _optionalChain$
|
|
3535
|
+
return _optionalChain$p([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$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; }
|
|
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$o([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$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; }
|
|
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$n([ctx, 'optionalAccess', _ => _.maxAliasCount]) === 0)
|
|
3709
3711
|
throw new ReferenceError('Alias resolution is disabled');
|
|
3710
3712
|
let nodes;
|
|
3711
|
-
if (_optionalChain$
|
|
3713
|
+
if (_optionalChain$n([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$n([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$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; }
|
|
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$m([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$9(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
|
|
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$9(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$l([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$l([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$9(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$l([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$l([tagObj, 'optionalAccess', _9 => _9.createNode])
|
|
3893
3895
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
3894
|
-
: typeof _optionalChain$
|
|
3896
|
+
: typeof _optionalChain$l([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$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; }
|
|
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$k([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$k([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$8(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
|
|
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$8(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$j([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$8(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$8(_optionalChain$j([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$8(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$j([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$8(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$8(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$7(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$7(_nullishCoalesce$7(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$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; }
|
|
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$i([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$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; }
|
|
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$h([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$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; }
|
|
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$g([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$g([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$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; }
|
|
4973
4975
|
function stringifyCollection(collection, ctx, options) {
|
|
4974
|
-
const flow = _nullishCoalesce$
|
|
4976
|
+
const flow = _nullishCoalesce$6(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$f([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$5(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
|
|
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$e([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$e([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$e([it, 'optionalAccess', _5 => _5.value]);
|
|
5220
|
+
return _nullishCoalesce$5((!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$e([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
|
|
5235
|
+
if (_optionalChain$e([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$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; }
|
|
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$d([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$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; }
|
|
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$c([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$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; }// 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$b([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$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; }
|
|
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$a([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
|
|
5968
5970
|
break;
|
|
5969
5971
|
case 'build':
|
|
5970
|
-
commandConfig = _optionalChain$
|
|
5972
|
+
commandConfig = _optionalChain$a([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
|
|
5971
5973
|
break;
|
|
5972
5974
|
case 'start':
|
|
5973
|
-
commandConfig = _optionalChain$
|
|
5975
|
+
commandConfig = _optionalChain$a([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
|
|
5974
5976
|
break;
|
|
5975
5977
|
case 'validate':
|
|
5976
|
-
commandConfig = _optionalChain$
|
|
5978
|
+
commandConfig = _optionalChain$a([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$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; }
|
|
6128
6130
|
|
|
6129
6131
|
|
|
6130
6132
|
|
|
6131
6133
|
|
|
6132
6134
|
|
|
6133
6135
|
|
|
6134
|
-
const PATCH_ID$
|
|
6135
|
-
const PACKAGE_JSON_FILE$
|
|
6136
|
-
const VALIDATE_SCRIPT_FILE$
|
|
6136
|
+
const PATCH_ID$7 = 'expo/validate@0.0.20';
|
|
6137
|
+
const PACKAGE_JSON_FILE$5 = 'package.json';
|
|
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$9([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
|
}
|
|
@@ -6171,7 +6173,7 @@ const isCozeValid$3 = (cozeConfig) => {
|
|
|
6171
6173
|
* @returns
|
|
6172
6174
|
*/
|
|
6173
6175
|
const isPackageJsonValid$3 = async (projectFolder) => {
|
|
6174
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$
|
|
6176
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$5);
|
|
6175
6177
|
if (!(await isFileExists(packageJsonPath))) {
|
|
6176
6178
|
logger.info('[patch-expo-validate] NOT APPLY: package.json not found');
|
|
6177
6179
|
return false;
|
|
@@ -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;
|
|
@@ -6221,7 +6223,7 @@ const isScriptValid$3 = async (projectFolder) => {
|
|
|
6221
6223
|
* @returns
|
|
6222
6224
|
*/
|
|
6223
6225
|
const patchPackageJson$3 = async (projectFolder) => {
|
|
6224
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$
|
|
6226
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$5);
|
|
6225
6227
|
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6226
6228
|
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
6227
6229
|
const scripts = packageJson.scripts || {};
|
|
@@ -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,18 +6263,18 @@ 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: [
|
|
6268
6270
|
{
|
|
6269
6271
|
kind: 'file-patch',
|
|
6270
|
-
file: PACKAGE_JSON_FILE$
|
|
6272
|
+
file: PACKAGE_JSON_FILE$5,
|
|
6271
6273
|
description: 'Add validate script for expo projects',
|
|
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$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; }
|
|
6304
6306
|
|
|
6305
6307
|
|
|
6306
6308
|
|
|
6307
6309
|
|
|
6308
6310
|
|
|
6309
6311
|
|
|
6310
|
-
const PATCH_ID$
|
|
6311
|
-
const PACKAGE_JSON_FILE$
|
|
6312
|
-
const VALIDATE_SCRIPT_FILE$
|
|
6312
|
+
const PATCH_ID$6 = 'nextjs/validate@0.0.20';
|
|
6313
|
+
const PACKAGE_JSON_FILE$4 = 'package.json';
|
|
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$8([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
|
}
|
|
@@ -6349,7 +6351,7 @@ const isCozeValid$2 = (cozeConfig) => {
|
|
|
6349
6351
|
* @returns
|
|
6350
6352
|
*/
|
|
6351
6353
|
const isPackageJsonValid$2 = async (projectFolder) => {
|
|
6352
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$
|
|
6354
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$4);
|
|
6353
6355
|
if (!(await isFileExists(packageJsonPath))) {
|
|
6354
6356
|
logger.info('[patch-nextjs-validate] NOT APPLY: package.json not found');
|
|
6355
6357
|
return false;
|
|
@@ -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',
|
|
@@ -6397,7 +6399,7 @@ const isScriptValid$2 = async (projectFolder) => {
|
|
|
6397
6399
|
* @returns
|
|
6398
6400
|
*/
|
|
6399
6401
|
const patchPackageJson$2 = async (projectFolder) => {
|
|
6400
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$
|
|
6402
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$4);
|
|
6401
6403
|
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6402
6404
|
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
6403
6405
|
const scripts = packageJson.scripts || {};
|
|
@@ -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,18 +6444,18 @@ 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: [
|
|
6449
6451
|
{
|
|
6450
6452
|
kind: 'file-patch',
|
|
6451
|
-
file: PACKAGE_JSON_FILE$
|
|
6453
|
+
file: PACKAGE_JSON_FILE$4,
|
|
6452
6454
|
description: 'Add lint:build and validate scripts for nextjs projects',
|
|
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$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; }
|
|
6485
6487
|
|
|
6486
6488
|
|
|
6487
6489
|
|
|
6488
6490
|
|
|
6489
6491
|
|
|
6490
6492
|
|
|
6491
|
-
const PATCH_ID$
|
|
6492
|
-
const PACKAGE_JSON_FILE$
|
|
6493
|
-
const VALIDATE_SCRIPT_FILE$
|
|
6493
|
+
const PATCH_ID$5 = 'vite/validate@0.0.20';
|
|
6494
|
+
const PACKAGE_JSON_FILE$3 = 'package.json';
|
|
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$7([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
|
}
|
|
@@ -6530,7 +6532,7 @@ const isCozeValid$1 = (cozeConfig) => {
|
|
|
6530
6532
|
* @returns
|
|
6531
6533
|
*/
|
|
6532
6534
|
const isPackageJsonValid$1 = async (projectFolder) => {
|
|
6533
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$
|
|
6535
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$3);
|
|
6534
6536
|
if (!(await isFileExists(packageJsonPath))) {
|
|
6535
6537
|
logger.info('[patch-vite-validate] NOT APPLY: package.json not found');
|
|
6536
6538
|
return false;
|
|
@@ -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;
|
|
@@ -6576,7 +6578,7 @@ const isScriptValid$1 = async (projectFolder) => {
|
|
|
6576
6578
|
* @returns
|
|
6577
6579
|
*/
|
|
6578
6580
|
const patchPackageJson$1 = async (projectFolder) => {
|
|
6579
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$
|
|
6581
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$3);
|
|
6580
6582
|
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6581
6583
|
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
6582
6584
|
const scripts = packageJson.scripts || {};
|
|
@@ -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,18 +6622,18 @@ 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: [
|
|
6627
6629
|
{
|
|
6628
6630
|
kind: 'file-patch',
|
|
6629
|
-
file: PACKAGE_JSON_FILE$
|
|
6631
|
+
file: PACKAGE_JSON_FILE$3,
|
|
6630
6632
|
description: 'Add lint:build and validate scripts for vite projects',
|
|
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$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; }
|
|
6663
6665
|
|
|
6664
6666
|
|
|
6665
6667
|
|
|
6666
6668
|
|
|
6667
6669
|
|
|
6668
6670
|
|
|
6669
|
-
const PATCH_ID$
|
|
6670
|
-
const PACKAGE_JSON_FILE$
|
|
6671
|
-
const VALIDATE_SCRIPT_FILE = '.cozeproj/scripts/validate.sh';
|
|
6671
|
+
const PATCH_ID$4 = 'taro/validate@0.0.20';
|
|
6672
|
+
const PACKAGE_JSON_FILE$2 = 'package.json';
|
|
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$6([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
|
}
|
|
@@ -6712,7 +6714,7 @@ const isCozeValid = (cozeConfig) => {
|
|
|
6712
6714
|
* @returns
|
|
6713
6715
|
*/
|
|
6714
6716
|
const isPackageJsonValid = async (projectFolder) => {
|
|
6715
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$
|
|
6717
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$2);
|
|
6716
6718
|
if (!(await isFileExists(packageJsonPath))) {
|
|
6717
6719
|
logger.info('[patch-taro-validate] NOT APPLY: package.json not found');
|
|
6718
6720
|
return false;
|
|
@@ -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;
|
|
@@ -6760,7 +6762,7 @@ const isScriptValid = async (projectFolder) => {
|
|
|
6760
6762
|
* @returns
|
|
6761
6763
|
*/
|
|
6762
6764
|
const patchPackageJson = async (projectFolder) => {
|
|
6763
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$
|
|
6765
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$2);
|
|
6764
6766
|
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6765
6767
|
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
6766
6768
|
const scripts = packageJson.scripts || {};
|
|
@@ -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,19 +6809,19 @@ 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: [
|
|
6814
6816
|
{
|
|
6815
6817
|
kind: 'file-patch',
|
|
6816
|
-
file: PACKAGE_JSON_FILE$
|
|
6818
|
+
file: PACKAGE_JSON_FILE$2,
|
|
6817
6819
|
description:
|
|
6818
6820
|
'Update lint:build and add validate script for taro projects',
|
|
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,15 +6841,15 @@ 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
|
-
const PACKAGE_JSON_FILE = 'package.json';
|
|
6850
|
+
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; }
|
|
6851
|
+
const PATCH_ID$3 = 'taro/update-pack-script-for-tt-build@0.0.13';
|
|
6852
|
+
const PACKAGE_JSON_FILE$1 = 'package.json';
|
|
6851
6853
|
const PACK_SCRIPT_FILE = '.cozeproj/scripts/pack.sh';
|
|
6852
6854
|
const LEGACY_PACK_SCRIPT_HASHES = new Set([
|
|
6853
6855
|
'987575c08e1c32ce7bc553e1668b3ad8faad5623343fd0d21fea34d39f25a56d',
|
|
@@ -6916,7 +6918,7 @@ const hashContent = (content) =>
|
|
|
6916
6918
|
const readPackageScripts = async (
|
|
6917
6919
|
projectFolder,
|
|
6918
6920
|
) => {
|
|
6919
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE);
|
|
6921
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$1);
|
|
6920
6922
|
if (!(await isFileExists(packageJsonPath))) {
|
|
6921
6923
|
return null;
|
|
6922
6924
|
}
|
|
@@ -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$5([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$5([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,146 @@ 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 _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; }
|
|
7059
|
+
|
|
7060
|
+
|
|
7061
|
+
|
|
7062
|
+
|
|
7063
|
+
|
|
7064
|
+
const OLD_WEB_TEMPLATE_VALIDATE_SCRIPT = `#!/bin/bash
|
|
7065
|
+
set -Eeuo pipefail
|
|
7066
|
+
|
|
7067
|
+
COZE_WORKSPACE_PATH="\${COZE_WORKSPACE_PATH:-$(pwd)}"
|
|
7068
|
+
|
|
7069
|
+
cd "\${COZE_WORKSPACE_PATH}"
|
|
7070
|
+
|
|
7071
|
+
echo "\u{1F50D} Running validate..."
|
|
7072
|
+
pnpm validate
|
|
7073
|
+
echo "\u{2705} Validate passed!"
|
|
7074
|
+
`;
|
|
7075
|
+
|
|
7076
|
+
const OLD_WEB_PATCH_VALIDATE_SCRIPT = `#!/bin/bash
|
|
7077
|
+
set -Eeuo pipefail
|
|
7078
|
+
COZE_WORKSPACE_PATH="\${COZE_WORKSPACE_PATH:-$(pwd)}"
|
|
7079
|
+
cd "\${COZE_WORKSPACE_PATH}"
|
|
7080
|
+
echo "Running validate..."
|
|
7081
|
+
pnpm validate
|
|
7082
|
+
echo "Validate passed!"
|
|
7083
|
+
`;
|
|
7084
|
+
|
|
7085
|
+
const createValidateScript = (parallelArgs) => `#!/bin/bash
|
|
7086
|
+
set -Eeuo pipefail
|
|
7087
|
+
|
|
7088
|
+
COZE_WORKSPACE_PATH="\${COZE_WORKSPACE_PATH:-$(pwd)}"
|
|
7089
|
+
|
|
7090
|
+
cd "\${COZE_WORKSPACE_PATH}"
|
|
7091
|
+
|
|
7092
|
+
echo "Running validate..."
|
|
7093
|
+
coze-dev parallel ${parallelArgs}
|
|
7094
|
+
echo "Validate passed!"
|
|
7095
|
+
`;
|
|
7096
|
+
|
|
7097
|
+
const PACKAGE_JSON_FILE = 'package.json';
|
|
7098
|
+
const VALIDATE_SCRIPT_FILE = 'scripts/validate.sh';
|
|
7099
|
+
const PARALLEL_SCRIPT_NAMES = ['ts-check', 'lint:build', 'lint:style'] ;
|
|
7100
|
+
const REQUIRED_SCRIPT_NAMES = ['ts-check', 'lint:build'] ;
|
|
7101
|
+
|
|
7102
|
+
const isKnownOldValidateScript = (content) => [OLD_WEB_TEMPLATE_VALIDATE_SCRIPT, OLD_WEB_PATCH_VALIDATE_SCRIPT].includes(content);
|
|
7103
|
+
|
|
7104
|
+
const loadPackageJson = async (projectFolder) => {
|
|
7105
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE);
|
|
7106
|
+
if (!(await isFileExists(packageJsonPath))) {
|
|
7107
|
+
return null;
|
|
7108
|
+
}
|
|
7109
|
+
|
|
7110
|
+
const content = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
7111
|
+
return safeJsonParse(content, null);
|
|
7112
|
+
};
|
|
7113
|
+
|
|
7114
|
+
const hasScript = (scripts, scriptName) => {
|
|
7115
|
+
if (!scripts) {
|
|
7116
|
+
return false;
|
|
7117
|
+
}
|
|
7118
|
+
return typeof _optionalChain$4([Object, 'access', _ => _.getOwnPropertyDescriptor, 'call', _2 => _2(scripts, scriptName), 'optionalAccess', _3 => _3.value]) === 'string';
|
|
7119
|
+
};
|
|
7120
|
+
|
|
7121
|
+
const getParallelArgs = async (projectFolder) => {
|
|
7122
|
+
const packageJson = await loadPackageJson(projectFolder);
|
|
7123
|
+
const scripts = _optionalChain$4([packageJson, 'optionalAccess', _4 => _4.scripts]);
|
|
7124
|
+
if (!REQUIRED_SCRIPT_NAMES.every(scriptName => hasScript(scripts, scriptName))) {
|
|
7125
|
+
return null;
|
|
7126
|
+
}
|
|
7127
|
+
|
|
7128
|
+
return PARALLEL_SCRIPT_NAMES.filter(scriptName => hasScript(scripts, scriptName)).join(' ');
|
|
7129
|
+
};
|
|
7130
|
+
|
|
7131
|
+
const applyValidateRunnerPatch = async (context, patchId) => {
|
|
7132
|
+
const validateScriptPath = path.join(context.projectFolder, VALIDATE_SCRIPT_FILE);
|
|
7133
|
+
const content = await fs$1.readFile(validateScriptPath, 'utf-8');
|
|
7134
|
+
|
|
7135
|
+
if (!isKnownOldValidateScript(content)) {
|
|
7136
|
+
return {
|
|
7137
|
+
applied: false,
|
|
7138
|
+
patchId,
|
|
7139
|
+
message: 'validate.sh content is not a known old version, skipping',
|
|
7140
|
+
};
|
|
7141
|
+
}
|
|
7142
|
+
|
|
7143
|
+
const parallelArgs = await getParallelArgs(context.projectFolder);
|
|
7144
|
+
if (!parallelArgs) {
|
|
7145
|
+
return {
|
|
7146
|
+
applied: false,
|
|
7147
|
+
patchId,
|
|
7148
|
+
message: 'package.json scripts do not contain known validate scripts, skipping',
|
|
7149
|
+
};
|
|
7150
|
+
}
|
|
7151
|
+
|
|
7152
|
+
await fs$1.writeFile(validateScriptPath, createValidateScript(parallelArgs), 'utf-8');
|
|
7153
|
+
|
|
7154
|
+
logger.info(`Patched ${VALIDATE_SCRIPT_FILE}: use coze-dev parallel`);
|
|
7155
|
+
|
|
7156
|
+
return {
|
|
7157
|
+
applied: true,
|
|
7158
|
+
patchId,
|
|
7159
|
+
message: 'Updated validate.sh',
|
|
7160
|
+
};
|
|
7161
|
+
};
|
|
7162
|
+
|
|
7163
|
+
const PATCH_ID$1 = 'nextjs/validate-runner@0.0.31';
|
|
7164
|
+
|
|
7165
|
+
const patchNextjsValidateRunner = {
|
|
7166
|
+
id: PATCH_ID$1,
|
|
7167
|
+
template: 'nextjs',
|
|
7168
|
+
disabled: byFlag('coding.arch.patch_nextjs_validate_runner'),
|
|
7169
|
+
operations: [
|
|
7170
|
+
{
|
|
7171
|
+
kind: 'file-patch',
|
|
7172
|
+
file: VALIDATE_SCRIPT_FILE,
|
|
7173
|
+
description: 'Update validate shell script to use coze-dev parallel',
|
|
7174
|
+
},
|
|
7175
|
+
],
|
|
7176
|
+
shouldApply: async context => {
|
|
7177
|
+
const validateScriptPath = path.join(context.projectFolder, VALIDATE_SCRIPT_FILE);
|
|
7178
|
+
if (!(await isFileExists(validateScriptPath))) {
|
|
7179
|
+
return false;
|
|
7180
|
+
}
|
|
7181
|
+
|
|
7182
|
+
const content = await fs$1.readFile(validateScriptPath, 'utf-8');
|
|
7183
|
+
if (!isKnownOldValidateScript(content)) {
|
|
7184
|
+
return false;
|
|
7185
|
+
}
|
|
7186
|
+
|
|
7187
|
+
return Boolean(await getParallelArgs(context.projectFolder));
|
|
7188
|
+
},
|
|
7189
|
+
apply: context => applyValidateRunnerPatch(context, PATCH_ID$1),
|
|
7190
|
+
};
|
|
7191
|
+
|
|
7056
7192
|
const SCRIPT_FILES = ['dev.sh', 'build.sh'] ;
|
|
7057
7193
|
const SUPPORTED_TEMPLATES = new Set(['nextjs', 'vite', 'nuxt-vue']);
|
|
7058
7194
|
|
|
@@ -7268,6 +7404,7 @@ const patches = [
|
|
|
7268
7404
|
patchExpoValidate,
|
|
7269
7405
|
replaceNpxWithPnpmPatchNextjs,
|
|
7270
7406
|
patchNextjsValidate,
|
|
7407
|
+
patchNextjsValidateRunner,
|
|
7271
7408
|
replaceNpxWithPnpmPatchVite,
|
|
7272
7409
|
patchViteValidate,
|
|
7273
7410
|
replaceNpxWithPnpmPatchNuxtVue,
|
|
@@ -7277,12 +7414,9 @@ const patches = [
|
|
|
7277
7414
|
patchTaroPackScript,
|
|
7278
7415
|
] ;
|
|
7279
7416
|
|
|
7280
|
-
const getTemplatePatches = (
|
|
7281
|
-
template,
|
|
7282
|
-
) =>
|
|
7283
|
-
patches.filter(patch => patch.template === template);
|
|
7417
|
+
const getTemplatePatches = (template) => patches.filter(patch => patch.template === template);
|
|
7284
7418
|
|
|
7285
|
-
function _nullishCoalesce$
|
|
7419
|
+
function _nullishCoalesce$4(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; }
|
|
7286
7420
|
const DEFAULT_LEGACY_VERSION = 'legacy';
|
|
7287
7421
|
|
|
7288
7422
|
const loadFlagsWithFallback = async () => {
|
|
@@ -7388,7 +7522,7 @@ const getNextPatchState = (
|
|
|
7388
7522
|
|
|
7389
7523
|
) => ({
|
|
7390
7524
|
template,
|
|
7391
|
-
version: _optionalChain$
|
|
7525
|
+
version: _optionalChain$3([config, 'access', _ => _.project, 'optionalAccess', _2 => _2.version]) || DEFAULT_LEGACY_VERSION,
|
|
7392
7526
|
appliedPatches: [...appliedPatches, patchId],
|
|
7393
7527
|
});
|
|
7394
7528
|
|
|
@@ -7412,15 +7546,15 @@ const executePatch = async (
|
|
|
7412
7546
|
}
|
|
7413
7547
|
|
|
7414
7548
|
const template =
|
|
7415
|
-
_optionalChain$
|
|
7549
|
+
_optionalChain$3([config, 'access', _3 => _3.project, 'optionalAccess', _4 => _4.template]) || (await detectTemplateKey(projectFolder));
|
|
7416
7550
|
|
|
7417
7551
|
if (!template) {
|
|
7418
7552
|
logger.info('Patch skipped: template not detected');
|
|
7419
7553
|
return;
|
|
7420
7554
|
}
|
|
7421
7555
|
|
|
7422
|
-
const appliedPatches = [...(_optionalChain$
|
|
7423
|
-
const projectVersion = _optionalChain$
|
|
7556
|
+
const appliedPatches = [...(_optionalChain$3([config, 'access', _5 => _5.project, 'optionalAccess', _6 => _6.appliedPatches]) || [])];
|
|
7557
|
+
const projectVersion = _optionalChain$3([config, 'access', _7 => _7.project, 'optionalAccess', _8 => _8.version]);
|
|
7424
7558
|
const flags = await loadFlagsWithFallback();
|
|
7425
7559
|
|
|
7426
7560
|
const context = {
|
|
@@ -7465,7 +7599,7 @@ const executePatch = async (
|
|
|
7465
7599
|
|
|
7466
7600
|
if (options.dryRun) {
|
|
7467
7601
|
logger.info(`Detected template: ${template}`);
|
|
7468
|
-
logger.info(`Current version: ${_nullishCoalesce$
|
|
7602
|
+
logger.info(`Current version: ${_nullishCoalesce$4(projectVersion, () => ( DEFAULT_LEGACY_VERSION))}`);
|
|
7469
7603
|
logger.info(`Applied patches: ${appliedPatches.join(', ') || '(none)'}`);
|
|
7470
7604
|
logger.info('Matched patches:');
|
|
7471
7605
|
matchedPatches.forEach(patch => {
|
|
@@ -7506,7 +7640,7 @@ const executePatch = async (
|
|
|
7506
7640
|
}
|
|
7507
7641
|
};
|
|
7508
7642
|
|
|
7509
|
-
const registerCommand$
|
|
7643
|
+
const registerCommand$5 = program => {
|
|
7510
7644
|
program
|
|
7511
7645
|
.command('patch')
|
|
7512
7646
|
.description('Apply template patches for existing projects')
|
|
@@ -7523,14 +7657,14 @@ const registerCommand$4 = program => {
|
|
|
7523
7657
|
) => {
|
|
7524
7658
|
await executePatch({
|
|
7525
7659
|
directory,
|
|
7526
|
-
dryRun: _optionalChain$
|
|
7527
|
-
showFlags: _optionalChain$
|
|
7660
|
+
dryRun: _optionalChain$3([command, 'optionalAccess', _9 => _9.dryRun]),
|
|
7661
|
+
showFlags: _optionalChain$3([command, 'optionalAccess', _10 => _10.showFlags]),
|
|
7528
7662
|
});
|
|
7529
7663
|
},
|
|
7530
7664
|
);
|
|
7531
7665
|
};
|
|
7532
7666
|
|
|
7533
|
-
function _nullishCoalesce$
|
|
7667
|
+
function _nullishCoalesce$3(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
|
|
7534
7668
|
const d$1 = debug('coze-init-cli:run');
|
|
7535
7669
|
|
|
7536
7670
|
/**
|
|
@@ -7661,12 +7795,12 @@ const executeRun = async (commandName, options = {}) => {
|
|
|
7661
7795
|
}
|
|
7662
7796
|
|
|
7663
7797
|
// 将输出同时写入控制台和日志文件
|
|
7664
|
-
_optionalChain$
|
|
7798
|
+
_optionalChain$2([childProcess, 'access', _ => _.stdout, 'optionalAccess', _2 => _2.on, 'call', _3 => _3('data', (data) => {
|
|
7665
7799
|
process.stdout.write(data);
|
|
7666
7800
|
logStream.write(data);
|
|
7667
7801
|
})]);
|
|
7668
7802
|
|
|
7669
|
-
_optionalChain$
|
|
7803
|
+
_optionalChain$2([childProcess, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6('data', (data) => {
|
|
7670
7804
|
process.stderr.write(data);
|
|
7671
7805
|
logStream.write(data);
|
|
7672
7806
|
})]);
|
|
@@ -7679,7 +7813,7 @@ const executeRun = async (commandName, options = {}) => {
|
|
|
7679
7813
|
const buildDuration = Date.now() - buildStartTime;
|
|
7680
7814
|
|
|
7681
7815
|
if (code !== 0) {
|
|
7682
|
-
const errorMessage = `Command exited with code ${_nullishCoalesce$
|
|
7816
|
+
const errorMessage = `Command exited with code ${_nullishCoalesce$3(code, () => ( 'unknown'))}${signal ? ` and signal ${signal}` : ''}`;
|
|
7683
7817
|
logger.error(errorMessage);
|
|
7684
7818
|
logger.error(`Check log file for details: ${logFilePath}`);
|
|
7685
7819
|
|
|
@@ -7691,12 +7825,12 @@ const executeRun = async (commandName, options = {}) => {
|
|
|
7691
7825
|
categories: {
|
|
7692
7826
|
fixDuration: String(fixDuration),
|
|
7693
7827
|
buildDuration: String(buildDuration),
|
|
7694
|
-
exitCode: String(_nullishCoalesce$
|
|
7828
|
+
exitCode: String(_nullishCoalesce$3(code, () => ( 'unknown'))),
|
|
7695
7829
|
projectType,
|
|
7696
7830
|
},
|
|
7697
7831
|
errorContext: {
|
|
7698
|
-
exitCode: String(_nullishCoalesce$
|
|
7699
|
-
signal: _nullishCoalesce$
|
|
7832
|
+
exitCode: String(_nullishCoalesce$3(code, () => ( 'unknown'))),
|
|
7833
|
+
signal: _nullishCoalesce$3(signal, () => ( 'none')),
|
|
7700
7834
|
logFile: logFilePath,
|
|
7701
7835
|
projectType,
|
|
7702
7836
|
},
|
|
@@ -7772,7 +7906,7 @@ const executeRun = async (commandName, options = {}) => {
|
|
|
7772
7906
|
/**
|
|
7773
7907
|
* 注册 dev/build/start 命令到 program
|
|
7774
7908
|
*/
|
|
7775
|
-
const registerCommand$
|
|
7909
|
+
const registerCommand$4 = program => {
|
|
7776
7910
|
// dev 命令
|
|
7777
7911
|
program
|
|
7778
7912
|
.command('dev')
|
|
@@ -8600,7 +8734,7 @@ const scanRoutesOnce = async (
|
|
|
8600
8734
|
}
|
|
8601
8735
|
};
|
|
8602
8736
|
|
|
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
|
|
8737
|
+
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; }// Route manifest generation command
|
|
8604
8738
|
|
|
8605
8739
|
|
|
8606
8740
|
const log = debug('coze:routes');
|
|
@@ -8688,7 +8822,7 @@ const executeRoutes = async (
|
|
|
8688
8822
|
/**
|
|
8689
8823
|
* Register routes command to program
|
|
8690
8824
|
*/
|
|
8691
|
-
const registerCommand$
|
|
8825
|
+
const registerCommand$3 = program => {
|
|
8692
8826
|
program
|
|
8693
8827
|
.command('routes')
|
|
8694
8828
|
.description('Generate routes manifest for the current project')
|
|
@@ -8701,14 +8835,13 @@ const registerCommand$2 = program => {
|
|
|
8701
8835
|
'Output file path (defaults to ~/.coze/routes.json)',
|
|
8702
8836
|
)
|
|
8703
8837
|
.action(async (directory, options) => {
|
|
8704
|
-
await executeRoutes({ directory, output: _optionalChain([options, 'optionalAccess', _ => _.output]) });
|
|
8838
|
+
await executeRoutes({ directory, output: _optionalChain$1([options, 'optionalAccess', _ => _.output]) });
|
|
8705
8839
|
});
|
|
8706
8840
|
};
|
|
8707
8841
|
|
|
8708
|
-
function _nullishCoalesce$
|
|
8842
|
+
function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
|
|
8709
8843
|
|
|
8710
8844
|
|
|
8711
|
-
const d = debug('coze-init-cli:check-bins');
|
|
8712
8845
|
|
|
8713
8846
|
|
|
8714
8847
|
|
|
@@ -8716,117 +8849,127 @@ const d = debug('coze-init-cli:check-bins');
|
|
|
8716
8849
|
|
|
8717
8850
|
|
|
8718
8851
|
|
|
8719
|
-
const checkBins = async (cwd, fix) => {
|
|
8720
|
-
d('starting check, cwd=%s fix=%s', cwd, fix);
|
|
8721
8852
|
|
|
8722
|
-
const pkgJson = safeJsonParse
|
|
8723
8853
|
|
|
8724
8854
|
|
|
8725
|
-
(await fs$1.readFile(path.join(cwd, 'package.json'), 'utf8'), {});
|
|
8726
8855
|
|
|
8727
|
-
const allDeps = Object.keys({
|
|
8728
|
-
...pkgJson.dependencies,
|
|
8729
|
-
...pkgJson.devDependencies,
|
|
8730
|
-
});
|
|
8731
8856
|
|
|
8732
|
-
d('found %d total dependencies to scan', allDeps.length);
|
|
8733
8857
|
|
|
8734
|
-
const binDir = path.join(cwd, 'node_modules', '.bin');
|
|
8735
|
-
d('bin directory: %s', binDir);
|
|
8736
|
-
const missing = [];
|
|
8737
8858
|
|
|
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
8859
|
|
|
8759
|
-
if (!depPkg.bin) {
|
|
8760
|
-
return;
|
|
8761
|
-
}
|
|
8762
8860
|
|
|
8763
|
-
const bins =
|
|
8764
|
-
typeof depPkg.bin === 'string'
|
|
8765
|
-
? { [_nullishCoalesce$1(depName.split('/').pop(), () => ( depName))]: depPkg.bin }
|
|
8766
|
-
: depPkg.bin;
|
|
8767
8861
|
|
|
8768
|
-
d('%s declares bins: %o', depName, Object.keys(bins));
|
|
8769
8862
|
|
|
8770
|
-
|
|
8771
|
-
Object.keys(bins).map(async binName => {
|
|
8772
|
-
try {
|
|
8773
|
-
await fs$1.access(path.join(binDir, binName));
|
|
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
|
-
);
|
|
8863
|
+
const collectOption = (value, previous = []) => [...previous, value];
|
|
8783
8864
|
|
|
8784
|
-
|
|
8865
|
+
const createScriptTask = (script, packageManager) => ({
|
|
8866
|
+
label: script,
|
|
8867
|
+
command: packageManager,
|
|
8868
|
+
args: ['run', script],
|
|
8869
|
+
});
|
|
8785
8870
|
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8871
|
+
const createCommandTask = (command) => ({
|
|
8872
|
+
label: command,
|
|
8873
|
+
command,
|
|
8874
|
+
args: [],
|
|
8875
|
+
shell: true,
|
|
8876
|
+
});
|
|
8877
|
+
|
|
8878
|
+
const runTask = (task, cwd) =>
|
|
8879
|
+
new Promise(resolve => {
|
|
8880
|
+
const output = [];
|
|
8881
|
+
const child = child_process.spawn(task.command, task.args, {
|
|
8882
|
+
cwd,
|
|
8883
|
+
env: process.env,
|
|
8884
|
+
shell: task.shell,
|
|
8885
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
8886
|
+
});
|
|
8887
|
+
|
|
8888
|
+
_optionalChain([child, 'access', _ => _.stdout, 'optionalAccess', _2 => _2.on, 'call', _3 => _3('data', data => {
|
|
8889
|
+
output.push(String(data));
|
|
8890
|
+
})]);
|
|
8891
|
+
_optionalChain([child, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6('data', data => {
|
|
8892
|
+
output.push(String(data));
|
|
8893
|
+
})]);
|
|
8894
|
+
child.on('error', error => {
|
|
8895
|
+
output.push(`${error.stack || error.message}\n`);
|
|
8896
|
+
resolve({
|
|
8897
|
+
label: task.label,
|
|
8898
|
+
code: 1,
|
|
8899
|
+
output: output.join(''),
|
|
8900
|
+
});
|
|
8901
|
+
});
|
|
8902
|
+
child.on('close', code => {
|
|
8903
|
+
resolve({
|
|
8904
|
+
label: task.label,
|
|
8905
|
+
code: _nullishCoalesce$2(code, () => ( 1)),
|
|
8906
|
+
output: output.join(''),
|
|
8907
|
+
});
|
|
8908
|
+
});
|
|
8909
|
+
});
|
|
8910
|
+
|
|
8911
|
+
const runParallelScripts = async (scripts, options = {}) => {
|
|
8912
|
+
const resolvedOptions = {
|
|
8913
|
+
cwd: options.cwd || process.cwd(),
|
|
8914
|
+
packageManager: options.packageManager || 'pnpm',
|
|
8915
|
+
commands: options.cmd || [],
|
|
8916
|
+
};
|
|
8917
|
+
const tasks = [
|
|
8918
|
+
...scripts.map(script => createScriptTask(script, resolvedOptions.packageManager)),
|
|
8919
|
+
...resolvedOptions.commands.map(command => createCommandTask(command)),
|
|
8920
|
+
];
|
|
8921
|
+
|
|
8922
|
+
if (tasks.length === 0) {
|
|
8923
|
+
process.stderr.write('No scripts or commands specified.\n');
|
|
8924
|
+
return 1;
|
|
8791
8925
|
}
|
|
8792
8926
|
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8927
|
+
process.stdout.write(`Running ${tasks.length} task(s) in parallel...\n`);
|
|
8928
|
+
tasks.forEach(task => {
|
|
8929
|
+
process.stdout.write(`[${task.label}] started\n`);
|
|
8930
|
+
});
|
|
8931
|
+
|
|
8932
|
+
const results = await Promise.all(tasks.map(task => runTask(task, resolvedOptions.cwd)));
|
|
8933
|
+
const failedResults = results.filter(result => result.code !== 0);
|
|
8934
|
+
|
|
8935
|
+
results.forEach(result => {
|
|
8936
|
+
if (result.code === 0) {
|
|
8937
|
+
process.stdout.write(`[${result.label}] passed\n`);
|
|
8797
8938
|
} else {
|
|
8798
|
-
|
|
8939
|
+
process.stdout.write(`[${result.label}] failed (exit ${result.code})\n`);
|
|
8799
8940
|
}
|
|
8800
|
-
}
|
|
8941
|
+
});
|
|
8801
8942
|
|
|
8802
|
-
if (
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
);
|
|
8806
|
-
process.exit(1);
|
|
8943
|
+
if (failedResults.length === 0) {
|
|
8944
|
+
process.stdout.write('Parallel tasks passed.\n');
|
|
8945
|
+
return 0;
|
|
8807
8946
|
}
|
|
8808
8947
|
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8948
|
+
process.stdout.write('\nParallel tasks failed. Failed task logs:\n');
|
|
8949
|
+
failedResults.forEach(result => {
|
|
8950
|
+
process.stdout.write(`\n===== ${result.label} (exit ${result.code}) =====\n`);
|
|
8951
|
+
process.stdout.write(result.output || '(no output)\n');
|
|
8952
|
+
if (!result.output.endsWith('\n')) {
|
|
8953
|
+
process.stdout.write('\n');
|
|
8954
|
+
}
|
|
8955
|
+
process.stdout.write(`===== end ${result.label} =====\n`);
|
|
8956
|
+
});
|
|
8957
|
+
|
|
8958
|
+
return 1;
|
|
8813
8959
|
};
|
|
8814
8960
|
|
|
8815
|
-
const registerCommand$
|
|
8961
|
+
const registerCommand$2 = program => {
|
|
8816
8962
|
program
|
|
8817
|
-
.command('
|
|
8818
|
-
.description(
|
|
8819
|
-
|
|
8820
|
-
)
|
|
8821
|
-
.option('
|
|
8822
|
-
.option('--
|
|
8823
|
-
.action(async (options) => {
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
logger.warn(
|
|
8828
|
-
`check-bins: skipped due to error: ${err instanceof Error ? err.message : String(err)}`,
|
|
8829
|
-
);
|
|
8963
|
+
.command('parallel')
|
|
8964
|
+
.description('Run package scripts or shell commands in parallel and print full logs for failed tasks')
|
|
8965
|
+
.argument('[scripts...]', 'Package scripts to run with pnpm run')
|
|
8966
|
+
.option('-c, --cmd <command>', 'Shell command to run in parallel', collectOption, [])
|
|
8967
|
+
.option('--cwd <path>', 'Working directory', process.cwd())
|
|
8968
|
+
.option('--package-manager <command>', 'Package manager command', 'pnpm')
|
|
8969
|
+
.action(async (scripts, options) => {
|
|
8970
|
+
const exitCode = await runParallelScripts(scripts, options);
|
|
8971
|
+
if (exitCode !== 0) {
|
|
8972
|
+
process.exit(exitCode);
|
|
8830
8973
|
}
|
|
8831
8974
|
});
|
|
8832
8975
|
};
|
|
@@ -9706,7 +9849,7 @@ const execute = async (
|
|
|
9706
9849
|
};
|
|
9707
9850
|
};
|
|
9708
9851
|
|
|
9709
|
-
function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
9852
|
+
function _nullishCoalesce$1(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
9710
9853
|
/**
|
|
9711
9854
|
* 运行 pnpm install
|
|
9712
9855
|
*/
|
|
@@ -9896,7 +10039,7 @@ const executeTemplateEngineStep = async ctx => {
|
|
|
9896
10039
|
templateName: ctx.templateName,
|
|
9897
10040
|
outputPath: ctx.outputPath,
|
|
9898
10041
|
command: ctx.command,
|
|
9899
|
-
force: _nullishCoalesce(ctx.options.force, () => ( false)),
|
|
10042
|
+
force: _nullishCoalesce$1(ctx.options.force, () => ( false)),
|
|
9900
10043
|
});
|
|
9901
10044
|
|
|
9902
10045
|
// 保存结果到上下文
|
|
@@ -10155,7 +10298,7 @@ const executeInit = async (
|
|
|
10155
10298
|
/**
|
|
10156
10299
|
* 注册 init 命令到 program
|
|
10157
10300
|
*/
|
|
10158
|
-
const registerCommand = program => {
|
|
10301
|
+
const registerCommand$1 = program => {
|
|
10159
10302
|
program
|
|
10160
10303
|
.command('init')
|
|
10161
10304
|
.description('Initialize a new project from a template')
|
|
@@ -10173,21 +10316,148 @@ const registerCommand = program => {
|
|
|
10173
10316
|
.allowUnknownOption() // 允许透传参数
|
|
10174
10317
|
.action(async (directory, options, command) => {
|
|
10175
10318
|
// 位置参数优先级高于 --output 选项
|
|
10176
|
-
const outputPath = _nullishCoalesce(directory, () => ( options.output));
|
|
10319
|
+
const outputPath = _nullishCoalesce$1(directory, () => ( options.output));
|
|
10177
10320
|
// Always use force mode - overwrite existing files without conflict check
|
|
10178
10321
|
const force = true;
|
|
10179
10322
|
await executeInit({ ...options, output: outputPath, force }, command);
|
|
10180
10323
|
});
|
|
10181
10324
|
};
|
|
10182
10325
|
|
|
10326
|
+
function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
10327
|
+
|
|
10328
|
+
|
|
10329
|
+
const d = debug('coze-init-cli:check-bins');
|
|
10330
|
+
|
|
10331
|
+
|
|
10332
|
+
|
|
10333
|
+
|
|
10334
|
+
|
|
10335
|
+
|
|
10336
|
+
|
|
10337
|
+
const checkBins = async (cwd, fix) => {
|
|
10338
|
+
d('starting check, cwd=%s fix=%s', cwd, fix);
|
|
10339
|
+
|
|
10340
|
+
const pkgJson = safeJsonParse
|
|
10341
|
+
|
|
10342
|
+
|
|
10343
|
+
(await fs$1.readFile(path.join(cwd, 'package.json'), 'utf8'), {});
|
|
10344
|
+
|
|
10345
|
+
const allDeps = Object.keys({
|
|
10346
|
+
...pkgJson.dependencies,
|
|
10347
|
+
...pkgJson.devDependencies,
|
|
10348
|
+
});
|
|
10349
|
+
|
|
10350
|
+
d('found %d total dependencies to scan', allDeps.length);
|
|
10351
|
+
|
|
10352
|
+
const binDir = path.join(cwd, 'node_modules', '.bin');
|
|
10353
|
+
d('bin directory: %s', binDir);
|
|
10354
|
+
const missing = [];
|
|
10355
|
+
|
|
10356
|
+
await Promise.all(
|
|
10357
|
+
allDeps.map(async depName => {
|
|
10358
|
+
let rawContent;
|
|
10359
|
+
try {
|
|
10360
|
+
rawContent = await fs$1.readFile(
|
|
10361
|
+
path.join(cwd, 'node_modules', depName, 'package.json'),
|
|
10362
|
+
'utf8',
|
|
10363
|
+
);
|
|
10364
|
+
} catch (err) {
|
|
10365
|
+
d('dep %s not found in node_modules: %s', depName, err);
|
|
10366
|
+
missing.push({ dep: depName, bin: '', reason: 'missing-package' });
|
|
10367
|
+
return;
|
|
10368
|
+
}
|
|
10369
|
+
const depPkg = safeJsonParse(
|
|
10370
|
+
rawContent,
|
|
10371
|
+
);
|
|
10372
|
+
if (!depPkg) {
|
|
10373
|
+
d('skipping %s: failed to parse package.json', depName);
|
|
10374
|
+
return;
|
|
10375
|
+
}
|
|
10376
|
+
|
|
10377
|
+
if (!depPkg.bin) {
|
|
10378
|
+
return;
|
|
10379
|
+
}
|
|
10380
|
+
|
|
10381
|
+
const bins =
|
|
10382
|
+
typeof depPkg.bin === 'string'
|
|
10383
|
+
? { [_nullishCoalesce(depName.split('/').pop(), () => ( depName))]: depPkg.bin }
|
|
10384
|
+
: depPkg.bin;
|
|
10385
|
+
|
|
10386
|
+
d('%s declares bins: %o', depName, Object.keys(bins));
|
|
10387
|
+
|
|
10388
|
+
await Promise.all(
|
|
10389
|
+
Object.keys(bins).map(async binName => {
|
|
10390
|
+
try {
|
|
10391
|
+
await fs$1.access(path.join(binDir, binName));
|
|
10392
|
+
d('bin present: %s', binName);
|
|
10393
|
+
} catch (err) {
|
|
10394
|
+
d('bin missing: %s (from %s): %s', binName, depName, err);
|
|
10395
|
+
missing.push({ dep: depName, bin: binName, reason: 'missing-bin' });
|
|
10396
|
+
}
|
|
10397
|
+
}),
|
|
10398
|
+
);
|
|
10399
|
+
}),
|
|
10400
|
+
);
|
|
10401
|
+
|
|
10402
|
+
d('scan complete, missing=%d', missing.length);
|
|
10403
|
+
|
|
10404
|
+
if (missing.length === 0) {
|
|
10405
|
+
logger.success(
|
|
10406
|
+
'check-bins: all bin entries present, skipping force install.',
|
|
10407
|
+
);
|
|
10408
|
+
return;
|
|
10409
|
+
}
|
|
10410
|
+
|
|
10411
|
+
logger.warn('check-bins: missing or broken dependencies detected:');
|
|
10412
|
+
for (const { dep, bin, reason } of missing) {
|
|
10413
|
+
if (reason === 'missing-package') {
|
|
10414
|
+
logger.warn(` ${dep} -> (package not found in node_modules)`);
|
|
10415
|
+
} else {
|
|
10416
|
+
logger.warn(` ${dep} -> .bin/${bin}`);
|
|
10417
|
+
}
|
|
10418
|
+
}
|
|
10419
|
+
|
|
10420
|
+
if (!fix) {
|
|
10421
|
+
logger.error(
|
|
10422
|
+
'check-bins: missing bin entries found, run with --fix to repair.',
|
|
10423
|
+
);
|
|
10424
|
+
process.exit(1);
|
|
10425
|
+
}
|
|
10426
|
+
|
|
10427
|
+
logger.info('check-bins: running pnpm i --force to fix...');
|
|
10428
|
+
d('executing: pnpm i --force');
|
|
10429
|
+
child_process.execSync('pnpm i --force', { stdio: 'inherit', cwd });
|
|
10430
|
+
d('pnpm i --force completed');
|
|
10431
|
+
};
|
|
10432
|
+
|
|
10433
|
+
const registerCommand = program => {
|
|
10434
|
+
program
|
|
10435
|
+
.command('check-bins')
|
|
10436
|
+
.description(
|
|
10437
|
+
'Verify all bin entries from dependencies exist in node_modules/.bin, run pnpm i --force if any are missing',
|
|
10438
|
+
)
|
|
10439
|
+
.option('-c, --cwd <path>', 'Working directory to check', process.cwd())
|
|
10440
|
+
.option('--fix', 'Run pnpm i --force to repair missing bin entries', false)
|
|
10441
|
+
.action(async (options) => {
|
|
10442
|
+
try {
|
|
10443
|
+
await checkBins(options.cwd, options.fix);
|
|
10444
|
+
} catch (err) {
|
|
10445
|
+
logger.warn(
|
|
10446
|
+
`check-bins: skipped due to error: ${err instanceof Error ? err.message : String(err)}`,
|
|
10447
|
+
);
|
|
10448
|
+
}
|
|
10449
|
+
});
|
|
10450
|
+
};
|
|
10451
|
+
|
|
10183
10452
|
const commands = [
|
|
10184
|
-
registerCommand,
|
|
10185
|
-
registerCommand$3,
|
|
10186
|
-
registerCommand$6,
|
|
10453
|
+
registerCommand$1,
|
|
10187
10454
|
registerCommand$4,
|
|
10455
|
+
registerCommand$7,
|
|
10188
10456
|
registerCommand$5,
|
|
10457
|
+
registerCommand$6,
|
|
10458
|
+
registerCommand$3,
|
|
10459
|
+
registerCommand,
|
|
10189
10460
|
registerCommand$2,
|
|
10190
|
-
registerCommand$1,
|
|
10191
10461
|
];
|
|
10192
10462
|
|
|
10193
10463
|
const main = async () => {
|
|
@@ -10217,12 +10487,7 @@ const main = async () => {
|
|
|
10217
10487
|
|
|
10218
10488
|
const program = new commander.Command();
|
|
10219
10489
|
|
|
10220
|
-
program
|
|
10221
|
-
.name('coze')
|
|
10222
|
-
.description(
|
|
10223
|
-
'Coze Coding CLI - Project template engine for frontend stacks',
|
|
10224
|
-
)
|
|
10225
|
-
.version(packageJson.version);
|
|
10490
|
+
program.name('coze-dev').description('Coze Coding CLI - Project template engine for frontend stacks').version(packageJson.version);
|
|
10226
10491
|
|
|
10227
10492
|
commands.forEach(initCmd => initCmd(program));
|
|
10228
10493
|
|