@coze-arch/cli 0.0.31-alpha.87aef4 → 0.0.31-alpha.e8a17f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__templates__/expo/.cozeproj/scripts/validate.sh +1 -1
- package/lib/__templates__/expo/package.json +1 -1
- package/lib/__templates__/nextjs/package.json +1 -1
- package/lib/__templates__/nextjs/scripts/prepare.sh +2 -2
- package/lib/__templates__/nextjs/scripts/validate.sh +1 -1
- package/lib/__templates__/nuxt-vue/package.json +1 -1
- package/lib/__templates__/nuxt-vue/scripts/prepare.sh +2 -2
- package/lib/__templates__/nuxt-vue/scripts/validate.sh +1 -1
- package/lib/__templates__/vite/package.json +1 -1
- package/lib/__templates__/vite/scripts/prepare.sh +2 -2
- package/lib/__templates__/vite/scripts/validate.sh +1 -1
- package/lib/cli.js +409 -542
- package/package.json +3 -5
package/lib/cli.js
CHANGED
|
@@ -1628,7 +1628,7 @@ function createNodeTransport() {
|
|
|
1628
1628
|
};
|
|
1629
1629
|
}
|
|
1630
1630
|
|
|
1631
|
-
function _nullishCoalesce$
|
|
1631
|
+
function _nullishCoalesce$a(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }/**
|
|
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$a(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$t([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$t([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$t([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$t([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$t([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$t([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$t([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$t([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$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; }
|
|
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$s([options, 'optionalAccess', _ => _.args]),
|
|
2000
2000
|
status: 'running' ,
|
|
2001
|
-
..._optionalChain$
|
|
2001
|
+
..._optionalChain$s([options, 'optionalAccess', _2 => _2.categories]),
|
|
2002
2002
|
},
|
|
2003
|
-
metrics: _optionalChain$
|
|
2003
|
+
metrics: _optionalChain$s([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$s([options, 'optionalAccess', _4 => _4.args]),
|
|
2025
2025
|
status: success ? ('success' ) : ('fail' ),
|
|
2026
|
-
..._optionalChain$
|
|
2026
|
+
..._optionalChain$s([options, 'optionalAccess', _5 => _5.categories]),
|
|
2027
2027
|
},
|
|
2028
2028
|
metrics: {
|
|
2029
2029
|
duration,
|
|
2030
|
-
...(_optionalChain$
|
|
2030
|
+
...(_optionalChain$s([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$s([options, 'optionalAccess', _7 => _7.method]) || 'GET',
|
|
2052
|
+
statusCode: _optionalChain$s([options, 'optionalAccess', _8 => _8.statusCode, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]),
|
|
2053
|
+
status: _optionalChain$s([options, 'optionalAccess', _11 => _11.success]) ? ('success' ) : ('fail' ),
|
|
2054
2054
|
},
|
|
2055
2055
|
metrics: {
|
|
2056
|
-
duration: _optionalChain$
|
|
2056
|
+
duration: _optionalChain$s([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$s([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
|
|
2079
2079
|
},
|
|
2080
2080
|
metrics: {
|
|
2081
|
-
duration: _optionalChain$
|
|
2082
|
-
fileSize: _optionalChain$
|
|
2081
|
+
duration: _optionalChain$s([options, 'optionalAccess', _14 => _14.duration]),
|
|
2082
|
+
fileSize: _optionalChain$s([options, 'optionalAccess', _15 => _15.fileSize]),
|
|
2083
2083
|
},
|
|
2084
2084
|
};
|
|
2085
2085
|
},
|
|
@@ -2107,15 +2107,14 @@ const EventBuilder = {
|
|
|
2107
2107
|
};
|
|
2108
2108
|
|
|
2109
2109
|
var name = "@coze-arch/cli";
|
|
2110
|
-
var version = "0.0.31-alpha.
|
|
2110
|
+
var version = "0.0.31-alpha.e8a17f";
|
|
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"
|
|
2118
|
-
"coze-dev": "bin/main"
|
|
2117
|
+
coze: "bin/main"
|
|
2119
2118
|
};
|
|
2120
2119
|
var files = [
|
|
2121
2120
|
"lib",
|
|
@@ -2197,8 +2196,7 @@ var publishConfig = {
|
|
|
2197
2196
|
};
|
|
2198
2197
|
var cozePublishConfig = {
|
|
2199
2198
|
bin: {
|
|
2200
|
-
coze: "bin/main"
|
|
2201
|
-
"coze-dev": "bin/main"
|
|
2199
|
+
coze: "bin/main"
|
|
2202
2200
|
}
|
|
2203
2201
|
};
|
|
2204
2202
|
var packageJson = {
|
|
@@ -2218,7 +2216,7 @@ var packageJson = {
|
|
|
2218
2216
|
cozePublishConfig: cozePublishConfig
|
|
2219
2217
|
};
|
|
2220
2218
|
|
|
2221
|
-
function _optionalChain$
|
|
2219
|
+
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; }/**
|
|
2222
2220
|
* Slardar 监控初始化和上报
|
|
2223
2221
|
*/
|
|
2224
2222
|
|
|
@@ -2321,11 +2319,11 @@ const reportCommandComplete = safeRun(
|
|
|
2321
2319
|
,
|
|
2322
2320
|
) => {
|
|
2323
2321
|
const event = EventBuilder.cliCommandComplete(command, success, duration, {
|
|
2324
|
-
args: _optionalChain$
|
|
2325
|
-
errorCode: _optionalChain$
|
|
2322
|
+
args: _optionalChain$r([options, 'optionalAccess', _ => _.args]),
|
|
2323
|
+
errorCode: _optionalChain$r([options, 'optionalAccess', _2 => _2.errorCode]),
|
|
2326
2324
|
categories: {
|
|
2327
|
-
...(_optionalChain$
|
|
2328
|
-
..._optionalChain$
|
|
2325
|
+
...(_optionalChain$r([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
|
|
2326
|
+
..._optionalChain$r([options, 'optionalAccess', _4 => _4.categories]),
|
|
2329
2327
|
},
|
|
2330
2328
|
});
|
|
2331
2329
|
reporter.sendEvent(event.name, event.metrics, event.categories);
|
|
@@ -2384,7 +2382,7 @@ const flushSlardar = safeRun('flushSlardar', async () => {
|
|
|
2384
2382
|
await reporter.flush();
|
|
2385
2383
|
});
|
|
2386
2384
|
|
|
2387
|
-
function _nullishCoalesce$
|
|
2385
|
+
function _nullishCoalesce$9(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }var LogLevel; (function (LogLevel) {
|
|
2388
2386
|
const ERROR = 0; LogLevel[LogLevel["ERROR"] = ERROR] = "ERROR";
|
|
2389
2387
|
const WARN = 1; LogLevel[LogLevel["WARN"] = WARN] = "WARN";
|
|
2390
2388
|
const SUCCESS = 2; LogLevel[LogLevel["SUCCESS"] = SUCCESS] = "SUCCESS";
|
|
@@ -2422,7 +2420,7 @@ class Logger {
|
|
|
2422
2420
|
|
|
2423
2421
|
constructor(options = {}) {
|
|
2424
2422
|
this.level = this.parseLogLevel(options.level);
|
|
2425
|
-
this.useColor = _nullishCoalesce$
|
|
2423
|
+
this.useColor = _nullishCoalesce$9(options.useColor, () => ( this.isColorSupported()));
|
|
2426
2424
|
this.prefix = options.prefix;
|
|
2427
2425
|
}
|
|
2428
2426
|
|
|
@@ -2431,7 +2429,7 @@ class Logger {
|
|
|
2431
2429
|
return level;
|
|
2432
2430
|
}
|
|
2433
2431
|
|
|
2434
|
-
const envLevel = _optionalChain$
|
|
2432
|
+
const envLevel = _optionalChain$q([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
|
|
2435
2433
|
if (envLevel && envLevel in LOG_LEVEL_MAP) {
|
|
2436
2434
|
return LOG_LEVEL_MAP[envLevel];
|
|
2437
2435
|
}
|
|
@@ -2443,7 +2441,7 @@ class Logger {
|
|
|
2443
2441
|
// 简单检测:Node.js 环境且支持 TTY
|
|
2444
2442
|
return (
|
|
2445
2443
|
typeof process !== 'undefined' &&
|
|
2446
|
-
_optionalChain$
|
|
2444
|
+
_optionalChain$q([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
|
|
2447
2445
|
process.env.NO_COLOR === undefined
|
|
2448
2446
|
);
|
|
2449
2447
|
}
|
|
@@ -2468,7 +2466,7 @@ class Logger {
|
|
|
2468
2466
|
|
|
2469
2467
|
const icon = this.colorize(options.icon, options.color);
|
|
2470
2468
|
const prefix = this.prefix ? `${icon} ${this.prefix}` : icon;
|
|
2471
|
-
console.log(prefix, options.message, ...(_nullishCoalesce$
|
|
2469
|
+
console.log(prefix, options.message, ...(_nullishCoalesce$9(options.args, () => ( []))));
|
|
2472
2470
|
}
|
|
2473
2471
|
|
|
2474
2472
|
error(message, ...args) {
|
|
@@ -2813,7 +2811,7 @@ const executeWarmup = async (options) => {
|
|
|
2813
2811
|
/**
|
|
2814
2812
|
* 注册 warmup 命令到 program
|
|
2815
2813
|
*/
|
|
2816
|
-
const registerCommand$
|
|
2814
|
+
const registerCommand$6 = program => {
|
|
2817
2815
|
program
|
|
2818
2816
|
.command('warmup')
|
|
2819
2817
|
.description('Pre-install dependencies for templates to speed up init')
|
|
@@ -3225,7 +3223,7 @@ const executeUpdate = (
|
|
|
3225
3223
|
/**
|
|
3226
3224
|
* 注册 update 命令到 program
|
|
3227
3225
|
*/
|
|
3228
|
-
const registerCommand$
|
|
3226
|
+
const registerCommand$5 = program => {
|
|
3229
3227
|
program
|
|
3230
3228
|
.command('update <package>')
|
|
3231
3229
|
.description('Update a package dependency')
|
|
@@ -3251,7 +3249,7 @@ const registerCommand$6 = program => {
|
|
|
3251
3249
|
});
|
|
3252
3250
|
};
|
|
3253
3251
|
|
|
3254
|
-
function _optionalChain$
|
|
3252
|
+
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; }/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3255
3253
|
// Safe JSON parsing utilities with type safety and error handling
|
|
3256
3254
|
// Provides fallback values, validation, and error monitoring capabilities
|
|
3257
3255
|
|
|
@@ -3351,12 +3349,12 @@ function safeJsonParse(
|
|
|
3351
3349
|
const parsed = JSON.parse(String(input));
|
|
3352
3350
|
|
|
3353
3351
|
// Optional validation
|
|
3354
|
-
if (_optionalChain$
|
|
3352
|
+
if (_optionalChain$p([options, 'optionalAccess', _ => _.validate])) {
|
|
3355
3353
|
if (options.validate(parsed)) {
|
|
3356
3354
|
return parsed;
|
|
3357
3355
|
} else {
|
|
3358
3356
|
const validationError = new Error('JSON validation failed');
|
|
3359
|
-
_optionalChain$
|
|
3357
|
+
_optionalChain$p([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
|
|
3360
3358
|
|
|
3361
3359
|
if (options.throwOnValidationError) {
|
|
3362
3360
|
throw validationError;
|
|
@@ -3368,10 +3366,10 @@ function safeJsonParse(
|
|
|
3368
3366
|
return parsed;
|
|
3369
3367
|
} catch (error) {
|
|
3370
3368
|
// Re-throw validation errors when throwOnValidationError is true
|
|
3371
|
-
if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$
|
|
3369
|
+
if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$p([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
|
|
3372
3370
|
throw error;
|
|
3373
3371
|
}
|
|
3374
|
-
_optionalChain$
|
|
3372
|
+
_optionalChain$p([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
|
|
3375
3373
|
return defaultValue;
|
|
3376
3374
|
}
|
|
3377
3375
|
}
|
|
@@ -3411,7 +3409,7 @@ function isNode(node) {
|
|
|
3411
3409
|
}
|
|
3412
3410
|
const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
|
|
3413
3411
|
|
|
3414
|
-
function _optionalChain$
|
|
3412
|
+
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; }
|
|
3415
3413
|
const BREAK = Symbol('break visit');
|
|
3416
3414
|
const SKIP = Symbol('skip children');
|
|
3417
3415
|
const REMOVE = Symbol('remove node');
|
|
@@ -3524,15 +3522,15 @@ function callVisitor(key, node, visitor, path) {
|
|
|
3524
3522
|
if (typeof visitor === 'function')
|
|
3525
3523
|
return visitor(key, node, path);
|
|
3526
3524
|
if (isMap(node))
|
|
3527
|
-
return _optionalChain$
|
|
3525
|
+
return _optionalChain$o([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
|
|
3528
3526
|
if (isSeq(node))
|
|
3529
|
-
return _optionalChain$
|
|
3527
|
+
return _optionalChain$o([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
|
|
3530
3528
|
if (isPair(node))
|
|
3531
|
-
return _optionalChain$
|
|
3529
|
+
return _optionalChain$o([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
|
|
3532
3530
|
if (isScalar(node))
|
|
3533
|
-
return _optionalChain$
|
|
3531
|
+
return _optionalChain$o([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
|
|
3534
3532
|
if (isAlias(node))
|
|
3535
|
-
return _optionalChain$
|
|
3533
|
+
return _optionalChain$o([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
|
|
3536
3534
|
return undefined;
|
|
3537
3535
|
}
|
|
3538
3536
|
function replaceNode(key, path, node) {
|
|
@@ -3623,7 +3621,7 @@ function applyReviver(reviver, obj, key, val) {
|
|
|
3623
3621
|
return reviver.call(obj, key, val);
|
|
3624
3622
|
}
|
|
3625
3623
|
|
|
3626
|
-
function _optionalChain$
|
|
3624
|
+
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; }
|
|
3627
3625
|
/**
|
|
3628
3626
|
* Recursively convert any node or its contents to native JavaScript
|
|
3629
3627
|
*
|
|
@@ -3653,7 +3651,7 @@ function toJS(value, arg, ctx) {
|
|
|
3653
3651
|
ctx.onCreate(res);
|
|
3654
3652
|
return res;
|
|
3655
3653
|
}
|
|
3656
|
-
if (typeof value === 'bigint' && !_optionalChain$
|
|
3654
|
+
if (typeof value === 'bigint' && !_optionalChain$n([ctx, 'optionalAccess', _ => _.keep]))
|
|
3657
3655
|
return Number(value);
|
|
3658
3656
|
return value;
|
|
3659
3657
|
}
|
|
@@ -3691,7 +3689,7 @@ class NodeBase {
|
|
|
3691
3689
|
}
|
|
3692
3690
|
}
|
|
3693
3691
|
|
|
3694
|
-
function _optionalChain$
|
|
3692
|
+
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; }
|
|
3695
3693
|
class Alias extends NodeBase {
|
|
3696
3694
|
constructor(source) {
|
|
3697
3695
|
super(ALIAS);
|
|
@@ -3707,10 +3705,10 @@ class Alias extends NodeBase {
|
|
|
3707
3705
|
* instance of the `source` anchor before this node.
|
|
3708
3706
|
*/
|
|
3709
3707
|
resolve(doc, ctx) {
|
|
3710
|
-
if (_optionalChain$
|
|
3708
|
+
if (_optionalChain$m([ctx, 'optionalAccess', _ => _.maxAliasCount]) === 0)
|
|
3711
3709
|
throw new ReferenceError('Alias resolution is disabled');
|
|
3712
3710
|
let nodes;
|
|
3713
|
-
if (_optionalChain$
|
|
3711
|
+
if (_optionalChain$m([ctx, 'optionalAccess', _2 => _2.aliasResolveCache])) {
|
|
3714
3712
|
nodes = ctx.aliasResolveCache;
|
|
3715
3713
|
}
|
|
3716
3714
|
else {
|
|
@@ -3749,7 +3747,7 @@ class Alias extends NodeBase {
|
|
|
3749
3747
|
data = anchors.get(source);
|
|
3750
3748
|
}
|
|
3751
3749
|
/* istanbul ignore if */
|
|
3752
|
-
if (_optionalChain$
|
|
3750
|
+
if (_optionalChain$m([data, 'optionalAccess', _3 => _3.res]) === undefined) {
|
|
3753
3751
|
const msg = 'This should not happen: Alias anchor was not resolved?';
|
|
3754
3752
|
throw new ReferenceError(msg);
|
|
3755
3753
|
}
|
|
@@ -3801,7 +3799,7 @@ function getAliasCount(doc, node, anchors) {
|
|
|
3801
3799
|
return 1;
|
|
3802
3800
|
}
|
|
3803
3801
|
|
|
3804
|
-
function _optionalChain$
|
|
3802
|
+
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; }
|
|
3805
3803
|
const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
|
|
3806
3804
|
class Scalar extends NodeBase {
|
|
3807
3805
|
constructor(value) {
|
|
@@ -3809,7 +3807,7 @@ class Scalar extends NodeBase {
|
|
|
3809
3807
|
this.value = value;
|
|
3810
3808
|
}
|
|
3811
3809
|
toJSON(arg, ctx) {
|
|
3812
|
-
return _optionalChain$
|
|
3810
|
+
return _optionalChain$l([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
|
|
3813
3811
|
}
|
|
3814
3812
|
toString() {
|
|
3815
3813
|
return String(this.value);
|
|
@@ -3821,17 +3819,17 @@ Scalar.PLAIN = 'PLAIN';
|
|
|
3821
3819
|
Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
|
|
3822
3820
|
Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
|
|
3823
3821
|
|
|
3824
|
-
function _nullishCoalesce$
|
|
3822
|
+
function _nullishCoalesce$8(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$k(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
3825
3823
|
const defaultTagPrefix = 'tag:yaml.org,2002:';
|
|
3826
3824
|
function findTagObject(value, tagName, tags) {
|
|
3827
3825
|
if (tagName) {
|
|
3828
3826
|
const match = tags.filter(t => t.tag === tagName);
|
|
3829
|
-
const tagObj = _nullishCoalesce$
|
|
3827
|
+
const tagObj = _nullishCoalesce$8(match.find(t => !t.format), () => ( match[0]));
|
|
3830
3828
|
if (!tagObj)
|
|
3831
3829
|
throw new Error(`Tag ${tagName} not found`);
|
|
3832
3830
|
return tagObj;
|
|
3833
3831
|
}
|
|
3834
|
-
return tags.find(t => _optionalChain$
|
|
3832
|
+
return tags.find(t => _optionalChain$k([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
|
|
3835
3833
|
}
|
|
3836
3834
|
function createNode(value, tagName, ctx) {
|
|
3837
3835
|
if (isDocument(value))
|
|
@@ -3839,7 +3837,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3839
3837
|
if (isNode(value))
|
|
3840
3838
|
return value;
|
|
3841
3839
|
if (isPair(value)) {
|
|
3842
|
-
const map = _optionalChain$
|
|
3840
|
+
const map = _optionalChain$k([ctx, 'access', _3 => _3.schema, 'access', _4 => _4[MAP], 'access', _5 => _5.createNode, 'optionalCall', _6 => _6(ctx.schema, null, ctx)]);
|
|
3843
3841
|
map.items.push(value);
|
|
3844
3842
|
return map;
|
|
3845
3843
|
}
|
|
@@ -3858,7 +3856,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3858
3856
|
if (aliasDuplicateObjects && value && typeof value === 'object') {
|
|
3859
3857
|
ref = sourceObjects.get(value);
|
|
3860
3858
|
if (ref) {
|
|
3861
|
-
_nullishCoalesce$
|
|
3859
|
+
_nullishCoalesce$8(ref.anchor, () => ( (ref.anchor = onAnchor(value))));
|
|
3862
3860
|
return new Alias(ref.anchor);
|
|
3863
3861
|
}
|
|
3864
3862
|
else {
|
|
@@ -3866,7 +3864,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3866
3864
|
sourceObjects.set(value, ref);
|
|
3867
3865
|
}
|
|
3868
3866
|
}
|
|
3869
|
-
if (_optionalChain$
|
|
3867
|
+
if (_optionalChain$k([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
|
|
3870
3868
|
tagName = defaultTagPrefix + tagName.slice(2);
|
|
3871
3869
|
let tagObj = findTagObject(value, tagName, schema.tags);
|
|
3872
3870
|
if (!tagObj) {
|
|
@@ -3891,9 +3889,9 @@ function createNode(value, tagName, ctx) {
|
|
|
3891
3889
|
onTagObj(tagObj);
|
|
3892
3890
|
delete ctx.onTagObj;
|
|
3893
3891
|
}
|
|
3894
|
-
const node = _optionalChain$
|
|
3892
|
+
const node = _optionalChain$k([tagObj, 'optionalAccess', _9 => _9.createNode])
|
|
3895
3893
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
3896
|
-
: typeof _optionalChain$
|
|
3894
|
+
: typeof _optionalChain$k([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
|
|
3897
3895
|
? tagObj.nodeClass.from(ctx.schema, value, ctx)
|
|
3898
3896
|
: new Scalar(value);
|
|
3899
3897
|
if (tagName)
|
|
@@ -4211,7 +4209,7 @@ function consumeMoreIndentedLines(text, i, indent) {
|
|
|
4211
4209
|
return end;
|
|
4212
4210
|
}
|
|
4213
4211
|
|
|
4214
|
-
function _optionalChain$
|
|
4212
|
+
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; }
|
|
4215
4213
|
const getFoldOptions = (ctx, isBlock) => ({
|
|
4216
4214
|
indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
|
|
4217
4215
|
lineWidth: ctx.options.lineWidth,
|
|
@@ -4496,9 +4494,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
4496
4494
|
// booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
|
|
4497
4495
|
// and others in v1.1.
|
|
4498
4496
|
if (actualString) {
|
|
4499
|
-
const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$
|
|
4497
|
+
const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$j([tag, 'access', _ => _.test, 'optionalAccess', _2 => _2.test, 'call', _3 => _3(str)]);
|
|
4500
4498
|
const { compat, tags } = ctx.doc.schema;
|
|
4501
|
-
if (tags.some(test) || _optionalChain$
|
|
4499
|
+
if (tags.some(test) || _optionalChain$j([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
|
|
4502
4500
|
return quotedString(value, ctx);
|
|
4503
4501
|
}
|
|
4504
4502
|
return implicitKey
|
|
@@ -4544,7 +4542,7 @@ function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
|
4544
4542
|
return res;
|
|
4545
4543
|
}
|
|
4546
4544
|
|
|
4547
|
-
function _nullishCoalesce$
|
|
4545
|
+
function _nullishCoalesce$7(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
|
|
4548
4546
|
function createStringifyContext(doc, options) {
|
|
4549
4547
|
const opt = Object.assign({
|
|
4550
4548
|
blockQuote: true,
|
|
@@ -4591,27 +4589,27 @@ function getTagObject(tags, item) {
|
|
|
4591
4589
|
if (item.tag) {
|
|
4592
4590
|
const match = tags.filter(t => t.tag === item.tag);
|
|
4593
4591
|
if (match.length > 0)
|
|
4594
|
-
return _nullishCoalesce$
|
|
4592
|
+
return _nullishCoalesce$7(match.find(t => t.format === item.format), () => ( match[0]));
|
|
4595
4593
|
}
|
|
4596
4594
|
let tagObj = undefined;
|
|
4597
4595
|
let obj;
|
|
4598
4596
|
if (isScalar(item)) {
|
|
4599
4597
|
obj = item.value;
|
|
4600
|
-
let match = tags.filter(t => _optionalChain$
|
|
4598
|
+
let match = tags.filter(t => _optionalChain$i([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
|
|
4601
4599
|
if (match.length > 1) {
|
|
4602
4600
|
const testMatch = match.filter(t => t.test);
|
|
4603
4601
|
if (testMatch.length > 0)
|
|
4604
4602
|
match = testMatch;
|
|
4605
4603
|
}
|
|
4606
4604
|
tagObj =
|
|
4607
|
-
_nullishCoalesce$
|
|
4605
|
+
_nullishCoalesce$7(match.find(t => t.format === item.format), () => ( match.find(t => !t.format)));
|
|
4608
4606
|
}
|
|
4609
4607
|
else {
|
|
4610
4608
|
obj = item;
|
|
4611
4609
|
tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
|
|
4612
4610
|
}
|
|
4613
4611
|
if (!tagObj) {
|
|
4614
|
-
const name = _nullishCoalesce$
|
|
4612
|
+
const name = _nullishCoalesce$7(_optionalChain$i([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
|
|
4615
4613
|
throw new Error(`Tag not resolved for ${name} value`);
|
|
4616
4614
|
}
|
|
4617
4615
|
return tagObj;
|
|
@@ -4626,7 +4624,7 @@ function stringifyProps(node, tagObj, { anchors, doc }) {
|
|
|
4626
4624
|
anchors.add(anchor);
|
|
4627
4625
|
props.push(`&${anchor}`);
|
|
4628
4626
|
}
|
|
4629
|
-
const tag = _nullishCoalesce$
|
|
4627
|
+
const tag = _nullishCoalesce$7(node.tag, () => ( (tagObj.default ? null : tagObj.tag)));
|
|
4630
4628
|
if (tag)
|
|
4631
4629
|
props.push(doc.directives.tagString(tag));
|
|
4632
4630
|
return props.join(' ');
|
|
@@ -4637,7 +4635,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
|
|
|
4637
4635
|
if (isAlias(item)) {
|
|
4638
4636
|
if (ctx.doc.directives)
|
|
4639
4637
|
return item.toString(ctx);
|
|
4640
|
-
if (_optionalChain$
|
|
4638
|
+
if (_optionalChain$i([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
|
|
4641
4639
|
throw new TypeError(`Cannot stringify circular structure without alias nodes`);
|
|
4642
4640
|
}
|
|
4643
4641
|
else {
|
|
@@ -4652,10 +4650,10 @@ function stringify(item, ctx, onComment, onChompKeep) {
|
|
|
4652
4650
|
const node = isNode(item)
|
|
4653
4651
|
? item
|
|
4654
4652
|
: ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
|
|
4655
|
-
_nullishCoalesce$
|
|
4653
|
+
_nullishCoalesce$7(tagObj, () => ( (tagObj = getTagObject(ctx.doc.schema.tags, node))));
|
|
4656
4654
|
const props = stringifyProps(node, tagObj, ctx);
|
|
4657
4655
|
if (props.length > 0)
|
|
4658
|
-
ctx.indentAtStart = (_nullishCoalesce$
|
|
4656
|
+
ctx.indentAtStart = (_nullishCoalesce$7(ctx.indentAtStart, () => ( 0))) + props.length + 1;
|
|
4659
4657
|
const str = typeof tagObj.stringify === 'function'
|
|
4660
4658
|
? tagObj.stringify(node, ctx, onComment, onChompKeep)
|
|
4661
4659
|
: isScalar(node)
|
|
@@ -4668,7 +4666,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
|
|
|
4668
4666
|
: `${props}\n${ctx.indent}${str}`;
|
|
4669
4667
|
}
|
|
4670
4668
|
|
|
4671
|
-
function _nullishCoalesce$
|
|
4669
|
+
function _nullishCoalesce$6(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
4672
4670
|
function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
4673
4671
|
const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
|
|
4674
4672
|
let keyComment = (isNode(key) && key.comment) || null;
|
|
@@ -4778,7 +4776,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
4778
4776
|
const vs0 = valueStr[0];
|
|
4779
4777
|
const nl0 = valueStr.indexOf('\n');
|
|
4780
4778
|
const hasNewline = nl0 !== -1;
|
|
4781
|
-
const flow = _nullishCoalesce$
|
|
4779
|
+
const flow = _nullishCoalesce$6(_nullishCoalesce$6(ctx.inFlow, () => ( value.flow)), () => ( value.items.length === 0));
|
|
4782
4780
|
if (hasNewline || !flow) {
|
|
4783
4781
|
let hasPropsLine = false;
|
|
4784
4782
|
if (hasNewline && (vs0 === '&' || vs0 === '!')) {
|
|
@@ -4819,7 +4817,7 @@ function warn(logLevel, warning) {
|
|
|
4819
4817
|
}
|
|
4820
4818
|
}
|
|
4821
4819
|
|
|
4822
|
-
function _optionalChain$
|
|
4820
|
+
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; }
|
|
4823
4821
|
// If the value associated with a merge key is a single mapping node, each of
|
|
4824
4822
|
// its key/value pairs is inserted into the current mapping, unless the key
|
|
4825
4823
|
// already exists in it. If the value associated with the merge key is a
|
|
@@ -4843,7 +4841,7 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
|
|
|
4843
4841
|
(isScalar(key) &&
|
|
4844
4842
|
(!key.type || key.type === Scalar.PLAIN) &&
|
|
4845
4843
|
merge.identify(key.value))) &&
|
|
4846
|
-
_optionalChain$
|
|
4844
|
+
_optionalChain$h([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)]);
|
|
4847
4845
|
function addMergeToJSMap(ctx, map, value) {
|
|
4848
4846
|
const source = resolveAliasValue(ctx, value);
|
|
4849
4847
|
if (isSeq(source))
|
|
@@ -4883,7 +4881,7 @@ function resolveAliasValue(ctx, value) {
|
|
|
4883
4881
|
return ctx && isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
|
|
4884
4882
|
}
|
|
4885
4883
|
|
|
4886
|
-
function _optionalChain$
|
|
4884
|
+
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; }
|
|
4887
4885
|
function addPairToJSMap(ctx, map, { key, value }) {
|
|
4888
4886
|
if (isNode(key) && key.addToJSMap)
|
|
4889
4887
|
key.addToJSMap(ctx, map, value);
|
|
@@ -4920,7 +4918,7 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
4920
4918
|
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
4921
4919
|
if (typeof jsKey !== 'object')
|
|
4922
4920
|
return String(jsKey);
|
|
4923
|
-
if (isNode(key) && _optionalChain$
|
|
4921
|
+
if (isNode(key) && _optionalChain$g([ctx, 'optionalAccess', _ => _.doc])) {
|
|
4924
4922
|
const strCtx = createStringifyContext(ctx.doc, {});
|
|
4925
4923
|
strCtx.anchors = new Set();
|
|
4926
4924
|
for (const node of ctx.anchors.keys())
|
|
@@ -4940,7 +4938,7 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
4940
4938
|
return JSON.stringify(jsKey);
|
|
4941
4939
|
}
|
|
4942
4940
|
|
|
4943
|
-
function _optionalChain$
|
|
4941
|
+
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; }
|
|
4944
4942
|
function createPair(key, value, ctx) {
|
|
4945
4943
|
const k = createNode(key, undefined, ctx);
|
|
4946
4944
|
const v = createNode(value, undefined, ctx);
|
|
@@ -4961,19 +4959,19 @@ class Pair {
|
|
|
4961
4959
|
return new Pair(key, value);
|
|
4962
4960
|
}
|
|
4963
4961
|
toJSON(_, ctx) {
|
|
4964
|
-
const pair = _optionalChain$
|
|
4962
|
+
const pair = _optionalChain$f([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
|
|
4965
4963
|
return addPairToJSMap(ctx, pair, this);
|
|
4966
4964
|
}
|
|
4967
4965
|
toString(ctx, onComment, onChompKeep) {
|
|
4968
|
-
return _optionalChain$
|
|
4966
|
+
return _optionalChain$f([ctx, 'optionalAccess', _3 => _3.doc])
|
|
4969
4967
|
? stringifyPair(this, ctx, onComment, onChompKeep)
|
|
4970
4968
|
: JSON.stringify(this);
|
|
4971
4969
|
}
|
|
4972
4970
|
}
|
|
4973
4971
|
|
|
4974
|
-
function _nullishCoalesce$
|
|
4972
|
+
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; }
|
|
4975
4973
|
function stringifyCollection(collection, ctx, options) {
|
|
4976
|
-
const flow = _nullishCoalesce$
|
|
4974
|
+
const flow = _nullishCoalesce$5(ctx.inFlow, () => ( collection.flow));
|
|
4977
4975
|
const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
|
|
4978
4976
|
return stringify(collection, ctx, options);
|
|
4979
4977
|
}
|
|
@@ -5065,7 +5063,7 @@ function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
|
|
|
5065
5063
|
if (iv.commentBefore)
|
|
5066
5064
|
reqNewline = true;
|
|
5067
5065
|
}
|
|
5068
|
-
else if (item.value == null && _optionalChain$
|
|
5066
|
+
else if (item.value == null && _optionalChain$e([ik, 'optionalAccess', _ => _.comment])) {
|
|
5069
5067
|
comment = ik.comment;
|
|
5070
5068
|
}
|
|
5071
5069
|
}
|
|
@@ -5120,7 +5118,7 @@ function addCommentBefore({ indent, options: { commentString } }, lines, comment
|
|
|
5120
5118
|
}
|
|
5121
5119
|
}
|
|
5122
5120
|
|
|
5123
|
-
function _nullishCoalesce$
|
|
5121
|
+
function _nullishCoalesce$4(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
|
|
5124
5122
|
function findPair(items, key) {
|
|
5125
5123
|
const k = isScalar(key) ? key.value : key;
|
|
5126
5124
|
for (const it of items) {
|
|
@@ -5181,12 +5179,12 @@ class YAMLMap extends Collection {
|
|
|
5181
5179
|
_pair = pair;
|
|
5182
5180
|
else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
|
|
5183
5181
|
// In TypeScript, this never happens.
|
|
5184
|
-
_pair = new Pair(pair, _optionalChain$
|
|
5182
|
+
_pair = new Pair(pair, _optionalChain$d([pair, 'optionalAccess', _2 => _2.value]));
|
|
5185
5183
|
}
|
|
5186
5184
|
else
|
|
5187
5185
|
_pair = new Pair(pair.key, pair.value);
|
|
5188
5186
|
const prev = findPair(this.items, _pair.key);
|
|
5189
|
-
const sortEntries = _optionalChain$
|
|
5187
|
+
const sortEntries = _optionalChain$d([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
|
|
5190
5188
|
if (prev) {
|
|
5191
5189
|
if (!overwrite)
|
|
5192
5190
|
throw new Error(`Key ${_pair.key} already set`);
|
|
@@ -5216,8 +5214,8 @@ class YAMLMap extends Collection {
|
|
|
5216
5214
|
}
|
|
5217
5215
|
get(key, keepScalar) {
|
|
5218
5216
|
const it = findPair(this.items, key);
|
|
5219
|
-
const node = _optionalChain$
|
|
5220
|
-
return _nullishCoalesce$
|
|
5217
|
+
const node = _optionalChain$d([it, 'optionalAccess', _5 => _5.value]);
|
|
5218
|
+
return _nullishCoalesce$4((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
|
|
5221
5219
|
}
|
|
5222
5220
|
has(key) {
|
|
5223
5221
|
return !!findPair(this.items, key);
|
|
@@ -5231,8 +5229,8 @@ class YAMLMap extends Collection {
|
|
|
5231
5229
|
* @returns Instance of Type, Map, or Object
|
|
5232
5230
|
*/
|
|
5233
5231
|
toJSON(_, ctx, Type) {
|
|
5234
|
-
const map = Type ? new Type() : _optionalChain$
|
|
5235
|
-
if (_optionalChain$
|
|
5232
|
+
const map = Type ? new Type() : _optionalChain$d([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
|
|
5233
|
+
if (_optionalChain$d([ctx, 'optionalAccess', _7 => _7.onCreate]))
|
|
5236
5234
|
ctx.onCreate(map);
|
|
5237
5235
|
for (const item of this.items)
|
|
5238
5236
|
addPairToJSMap(ctx, map, item);
|
|
@@ -5257,7 +5255,7 @@ class YAMLMap extends Collection {
|
|
|
5257
5255
|
}
|
|
5258
5256
|
}
|
|
5259
5257
|
|
|
5260
|
-
function _optionalChain$
|
|
5258
|
+
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; }
|
|
5261
5259
|
class YAMLSeq extends Collection {
|
|
5262
5260
|
static get tagName() {
|
|
5263
5261
|
return 'tag:yaml.org,2002:seq';
|
|
@@ -5320,7 +5318,7 @@ class YAMLSeq extends Collection {
|
|
|
5320
5318
|
}
|
|
5321
5319
|
toJSON(_, ctx) {
|
|
5322
5320
|
const seq = [];
|
|
5323
|
-
if (_optionalChain$
|
|
5321
|
+
if (_optionalChain$c([ctx, 'optionalAccess', _2 => _2.onCreate]))
|
|
5324
5322
|
ctx.onCreate(seq);
|
|
5325
5323
|
let i = 0;
|
|
5326
5324
|
for (const item of this.items)
|
|
@@ -5399,7 +5397,7 @@ function createPairs(schema, iterable, ctx) {
|
|
|
5399
5397
|
return pairs;
|
|
5400
5398
|
}
|
|
5401
5399
|
|
|
5402
|
-
function _optionalChain$
|
|
5400
|
+
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; }
|
|
5403
5401
|
class YAMLOMap extends YAMLSeq {
|
|
5404
5402
|
constructor() {
|
|
5405
5403
|
super();
|
|
@@ -5418,7 +5416,7 @@ class YAMLOMap extends YAMLSeq {
|
|
|
5418
5416
|
if (!ctx)
|
|
5419
5417
|
return super.toJSON(_);
|
|
5420
5418
|
const map = new Map();
|
|
5421
|
-
if (_optionalChain$
|
|
5419
|
+
if (_optionalChain$b([ctx, 'optionalAccess', _2 => _2.onCreate]))
|
|
5422
5420
|
ctx.onCreate(map);
|
|
5423
5421
|
for (const pair of this.items) {
|
|
5424
5422
|
let key, value;
|
|
@@ -5536,7 +5534,7 @@ const isDirExists = async (file) => {
|
|
|
5536
5534
|
}
|
|
5537
5535
|
};
|
|
5538
5536
|
|
|
5539
|
-
function _optionalChain$
|
|
5537
|
+
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; }// ABOUTME: Project type detection utility
|
|
5540
5538
|
|
|
5541
5539
|
/**
|
|
5542
5540
|
* 支持的项目类型枚举
|
|
@@ -5597,7 +5595,7 @@ var ProjectType; (function (ProjectType) {
|
|
|
5597
5595
|
/**
|
|
5598
5596
|
* 读取并解析 package.json
|
|
5599
5597
|
*/
|
|
5600
|
-
const readPackageJson = async (
|
|
5598
|
+
const readPackageJson$1 = async (
|
|
5601
5599
|
projectPath,
|
|
5602
5600
|
) => {
|
|
5603
5601
|
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
@@ -5619,7 +5617,7 @@ const collectProjectInfo = async (
|
|
|
5619
5617
|
projectPath,
|
|
5620
5618
|
) => {
|
|
5621
5619
|
// 1. 读取 package.json
|
|
5622
|
-
const packageJson = await readPackageJson(projectPath);
|
|
5620
|
+
const packageJson = await readPackageJson$1(projectPath);
|
|
5623
5621
|
|
|
5624
5622
|
// 2. 提取所有依赖
|
|
5625
5623
|
const dependencies = new Set();
|
|
@@ -5638,7 +5636,7 @@ const collectProjectInfo = async (
|
|
|
5638
5636
|
}
|
|
5639
5637
|
|
|
5640
5638
|
const scripts = Object.entries(
|
|
5641
|
-
(_optionalChain$
|
|
5639
|
+
(_optionalChain$a([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
|
|
5642
5640
|
).reduce((acc, [name, script]) => {
|
|
5643
5641
|
if (typeof script === 'string') {
|
|
5644
5642
|
acc[name] = script;
|
|
@@ -5792,7 +5790,7 @@ const detectProjectType = async (
|
|
|
5792
5790
|
};
|
|
5793
5791
|
};
|
|
5794
5792
|
|
|
5795
|
-
function _optionalChain$
|
|
5793
|
+
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; }
|
|
5796
5794
|
|
|
5797
5795
|
|
|
5798
5796
|
/**
|
|
@@ -5966,16 +5964,16 @@ const getCommandConfig = (
|
|
|
5966
5964
|
|
|
5967
5965
|
switch (commandName) {
|
|
5968
5966
|
case 'dev':
|
|
5969
|
-
commandConfig = _optionalChain$
|
|
5967
|
+
commandConfig = _optionalChain$9([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
|
|
5970
5968
|
break;
|
|
5971
5969
|
case 'build':
|
|
5972
|
-
commandConfig = _optionalChain$
|
|
5970
|
+
commandConfig = _optionalChain$9([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
|
|
5973
5971
|
break;
|
|
5974
5972
|
case 'start':
|
|
5975
|
-
commandConfig = _optionalChain$
|
|
5973
|
+
commandConfig = _optionalChain$9([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
|
|
5976
5974
|
break;
|
|
5977
5975
|
case 'validate':
|
|
5978
|
-
commandConfig = _optionalChain$
|
|
5976
|
+
commandConfig = _optionalChain$9([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
|
|
5979
5977
|
break;
|
|
5980
5978
|
default:
|
|
5981
5979
|
throw new Error(`Unknown command: ${commandName}`);
|
|
@@ -6126,7 +6124,7 @@ const byFlag = (flag) => {
|
|
|
6126
6124
|
return predicate;
|
|
6127
6125
|
};
|
|
6128
6126
|
|
|
6129
|
-
function _optionalChain$
|
|
6127
|
+
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; }
|
|
6130
6128
|
|
|
6131
6129
|
|
|
6132
6130
|
|
|
@@ -6134,7 +6132,7 @@ function _optionalChain$a(ops) { let lastAccessLHS = undefined; let value = ops[
|
|
|
6134
6132
|
|
|
6135
6133
|
|
|
6136
6134
|
const PATCH_ID$7 = 'expo/validate@0.0.20';
|
|
6137
|
-
const PACKAGE_JSON_FILE$
|
|
6135
|
+
const PACKAGE_JSON_FILE$5 = 'package.json';
|
|
6138
6136
|
const VALIDATE_SCRIPT_FILE$4 = '.cozeproj/scripts/validate.sh';
|
|
6139
6137
|
const EXPO_VALIDATE_FLAG = 'coding.arch.patch_expo_validate';
|
|
6140
6138
|
const TARGET_VALIDATE$3 = "pnpm run --parallel '/^(lint:client|lint:server)$/'";
|
|
@@ -6157,7 +6155,7 @@ echo "Validate passed!"
|
|
|
6157
6155
|
* @returns
|
|
6158
6156
|
*/
|
|
6159
6157
|
const isCozeValid$3 = (cozeConfig) => {
|
|
6160
|
-
if (_optionalChain$
|
|
6158
|
+
if (_optionalChain$8([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6161
6159
|
logger.info('[patch-expo-validate] NOT APPLY: dev.validate exists');
|
|
6162
6160
|
return false;
|
|
6163
6161
|
}
|
|
@@ -6173,7 +6171,7 @@ const isCozeValid$3 = (cozeConfig) => {
|
|
|
6173
6171
|
* @returns
|
|
6174
6172
|
*/
|
|
6175
6173
|
const isPackageJsonValid$3 = async (projectFolder) => {
|
|
6176
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$
|
|
6174
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$5);
|
|
6177
6175
|
if (!(await isFileExists(packageJsonPath))) {
|
|
6178
6176
|
logger.info('[patch-expo-validate] NOT APPLY: package.json not found');
|
|
6179
6177
|
return false;
|
|
@@ -6222,8 +6220,8 @@ const isScriptValid$3 = async (projectFolder) => {
|
|
|
6222
6220
|
* @param projectFolder
|
|
6223
6221
|
* @returns
|
|
6224
6222
|
*/
|
|
6225
|
-
const patchPackageJson$
|
|
6226
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$
|
|
6223
|
+
const patchPackageJson$4 = async (projectFolder) => {
|
|
6224
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$5);
|
|
6227
6225
|
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6228
6226
|
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
6229
6227
|
const scripts = packageJson.scripts || {};
|
|
@@ -6269,7 +6267,7 @@ const patchExpoValidate = {
|
|
|
6269
6267
|
operations: [
|
|
6270
6268
|
{
|
|
6271
6269
|
kind: 'file-patch',
|
|
6272
|
-
file: PACKAGE_JSON_FILE$
|
|
6270
|
+
file: PACKAGE_JSON_FILE$5,
|
|
6273
6271
|
description: 'Add validate script for expo projects',
|
|
6274
6272
|
},
|
|
6275
6273
|
{
|
|
@@ -6290,7 +6288,7 @@ const patchExpoValidate = {
|
|
|
6290
6288
|
(await isScriptValid$3(context.projectFolder)),
|
|
6291
6289
|
|
|
6292
6290
|
apply: async (context) => {
|
|
6293
|
-
await patchPackageJson$
|
|
6291
|
+
await patchPackageJson$4(context.projectFolder);
|
|
6294
6292
|
await patchValidateScript$3(context.projectFolder);
|
|
6295
6293
|
patchCoze$3(context.cozeConfig);
|
|
6296
6294
|
|
|
@@ -6302,7 +6300,7 @@ const patchExpoValidate = {
|
|
|
6302
6300
|
},
|
|
6303
6301
|
};
|
|
6304
6302
|
|
|
6305
|
-
function _optionalChain$
|
|
6303
|
+
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; }
|
|
6306
6304
|
|
|
6307
6305
|
|
|
6308
6306
|
|
|
@@ -6310,7 +6308,7 @@ function _optionalChain$9(ops) { let lastAccessLHS = undefined; let value = ops[
|
|
|
6310
6308
|
|
|
6311
6309
|
|
|
6312
6310
|
const PATCH_ID$6 = 'nextjs/validate@0.0.20';
|
|
6313
|
-
const PACKAGE_JSON_FILE$
|
|
6311
|
+
const PACKAGE_JSON_FILE$4 = 'package.json';
|
|
6314
6312
|
const VALIDATE_SCRIPT_FILE$3 = 'scripts/validate.sh';
|
|
6315
6313
|
const NEXTJS_VALIDATE_FLAG = 'coding.arch.patch_nextjs_validate';
|
|
6316
6314
|
const TARGET_LINT_BUILD$2 = 'eslint . --quiet';
|
|
@@ -6335,7 +6333,7 @@ echo "Validate passed!"
|
|
|
6335
6333
|
* @returns
|
|
6336
6334
|
*/
|
|
6337
6335
|
const isCozeValid$2 = (cozeConfig) => {
|
|
6338
|
-
if (_optionalChain$
|
|
6336
|
+
if (_optionalChain$7([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6339
6337
|
logger.info('[patch-nextjs-validate] NOT APPLY: dev.validate exists');
|
|
6340
6338
|
return false;
|
|
6341
6339
|
}
|
|
@@ -6351,7 +6349,7 @@ const isCozeValid$2 = (cozeConfig) => {
|
|
|
6351
6349
|
* @returns
|
|
6352
6350
|
*/
|
|
6353
6351
|
const isPackageJsonValid$2 = async (projectFolder) => {
|
|
6354
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$
|
|
6352
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$4);
|
|
6355
6353
|
if (!(await isFileExists(packageJsonPath))) {
|
|
6356
6354
|
logger.info('[patch-nextjs-validate] NOT APPLY: package.json not found');
|
|
6357
6355
|
return false;
|
|
@@ -6398,8 +6396,8 @@ const isScriptValid$2 = async (projectFolder) => {
|
|
|
6398
6396
|
* @param projectFolder
|
|
6399
6397
|
* @returns
|
|
6400
6398
|
*/
|
|
6401
|
-
const patchPackageJson$
|
|
6402
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$
|
|
6399
|
+
const patchPackageJson$3 = async (projectFolder) => {
|
|
6400
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$4);
|
|
6403
6401
|
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6404
6402
|
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
6405
6403
|
const scripts = packageJson.scripts || {};
|
|
@@ -6450,7 +6448,7 @@ const patchNextjsValidate = {
|
|
|
6450
6448
|
operations: [
|
|
6451
6449
|
{
|
|
6452
6450
|
kind: 'file-patch',
|
|
6453
|
-
file: PACKAGE_JSON_FILE$
|
|
6451
|
+
file: PACKAGE_JSON_FILE$4,
|
|
6454
6452
|
description: 'Add lint:build and validate scripts for nextjs projects',
|
|
6455
6453
|
},
|
|
6456
6454
|
{
|
|
@@ -6471,7 +6469,7 @@ const patchNextjsValidate = {
|
|
|
6471
6469
|
(await isScriptValid$2(context.projectFolder)),
|
|
6472
6470
|
|
|
6473
6471
|
apply: async (context) => {
|
|
6474
|
-
await patchPackageJson$
|
|
6472
|
+
await patchPackageJson$3(context.projectFolder);
|
|
6475
6473
|
await patchValidateScript$2(context.projectFolder);
|
|
6476
6474
|
patchCoze$2(context.cozeConfig);
|
|
6477
6475
|
|
|
@@ -6483,16 +6481,135 @@ const patchNextjsValidate = {
|
|
|
6483
6481
|
},
|
|
6484
6482
|
};
|
|
6485
6483
|
|
|
6486
|
-
function _optionalChain$
|
|
6484
|
+
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; }
|
|
6485
|
+
|
|
6486
|
+
const PATCH_ID$5 = 'nextjs/validate-concurrently@0.0.30';
|
|
6487
|
+
const PACKAGE_JSON_FILE$3 = 'package.json';
|
|
6488
|
+
const VALIDATE_SCRIPT_FILE$2 = 'scripts/validate.sh';
|
|
6489
|
+
const NEXTJS_VALIDATE_CONCURRENTLY_FLAG = 'coding.arch.patch_nextjs_validate_concurrently';
|
|
6490
|
+
const LEGACY_VALIDATE_WITH_STYLE = "pnpm run --parallel '/^(ts-check|lint:build|lint:style)$/'";
|
|
6491
|
+
const LEGACY_VALIDATE_WITHOUT_STYLE = "pnpm run --parallel '/^(ts-check|lint:build)$/'";
|
|
6492
|
+
const TARGET_VALIDATE_WITH_STYLE =
|
|
6493
|
+
'pnpm dlx concurrently --group --names lint-tsc,lint-build,lint-style "pnpm ts-check" "pnpm lint:build" "pnpm lint:style"';
|
|
6494
|
+
const TARGET_VALIDATE_WITHOUT_STYLE = 'pnpm dlx concurrently --group --names lint-tsc,lint-build "pnpm ts-check" "pnpm lint:build"';
|
|
6495
|
+
|
|
6496
|
+
|
|
6497
|
+
|
|
6498
|
+
|
|
6499
|
+
|
|
6500
|
+
const readPackageJson = async (projectFolder) => {
|
|
6501
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$3);
|
|
6502
|
+
if (!(await isFileExists(packageJsonPath))) {
|
|
6503
|
+
logger.info('[patch-nextjs-validate-concurrently] NOT APPLY: package.json not found');
|
|
6504
|
+
return null;
|
|
6505
|
+
}
|
|
6506
|
+
|
|
6507
|
+
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6508
|
+
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
6509
|
+
if (!packageJson) {
|
|
6510
|
+
logger.info('[patch-nextjs-validate-concurrently] NOT APPLY: package.json is invalid');
|
|
6511
|
+
return null;
|
|
6512
|
+
}
|
|
6513
|
+
return packageJson;
|
|
6514
|
+
};
|
|
6515
|
+
|
|
6516
|
+
const getTargetValidateScript = (packageJson) => {
|
|
6517
|
+
const validateScript = _optionalChain$6([packageJson, 'access', _ => _.scripts, 'optionalAccess', _2 => _2.validate]);
|
|
6518
|
+
if (typeof validateScript !== 'string') {
|
|
6519
|
+
return null;
|
|
6520
|
+
}
|
|
6521
|
+
|
|
6522
|
+
const normalizedScript = validateScript.trim();
|
|
6523
|
+
if (normalizedScript === LEGACY_VALIDATE_WITH_STYLE) {
|
|
6524
|
+
return TARGET_VALIDATE_WITH_STYLE;
|
|
6525
|
+
}
|
|
6526
|
+
if (normalizedScript === LEGACY_VALIDATE_WITHOUT_STYLE) {
|
|
6527
|
+
return TARGET_VALIDATE_WITHOUT_STYLE;
|
|
6528
|
+
}
|
|
6529
|
+
return null;
|
|
6530
|
+
};
|
|
6531
|
+
|
|
6532
|
+
const canStackAfterNextjsValidatePatch = async (context, packageJson) => {
|
|
6533
|
+
const scripts = packageJson.scripts || {};
|
|
6534
|
+
if (typeof scripts.validate !== 'undefined' || typeof scripts['ts-check'] !== 'string' || _optionalChain$6([context, 'access', _3 => _3.cozeConfig, 'access', _4 => _4.dev, 'optionalAccess', _5 => _5.validate])) {
|
|
6535
|
+
return false;
|
|
6536
|
+
}
|
|
6537
|
+
|
|
6538
|
+
return !(await isFileExists(path.join(context.projectFolder, VALIDATE_SCRIPT_FILE$2)));
|
|
6539
|
+
};
|
|
6540
|
+
|
|
6541
|
+
const hasPatchTarget = async (context) => {
|
|
6542
|
+
const packageJson = await readPackageJson(context.projectFolder);
|
|
6543
|
+
if (!packageJson) {
|
|
6544
|
+
return false;
|
|
6545
|
+
}
|
|
6546
|
+
|
|
6547
|
+
if (getTargetValidateScript(packageJson)) {
|
|
6548
|
+
return true;
|
|
6549
|
+
}
|
|
6487
6550
|
|
|
6551
|
+
if (await canStackAfterNextjsValidatePatch(context, packageJson)) {
|
|
6552
|
+
return true;
|
|
6553
|
+
}
|
|
6488
6554
|
|
|
6555
|
+
logger.info('[patch-nextjs-validate-concurrently] NOT APPLY: validate script is not legacy pnpm run --parallel command');
|
|
6556
|
+
return false;
|
|
6557
|
+
};
|
|
6489
6558
|
|
|
6559
|
+
const patchPackageJson$2 = async (context) => {
|
|
6560
|
+
const packageJsonPath = path.join(context.projectFolder, PACKAGE_JSON_FILE$3);
|
|
6561
|
+
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6562
|
+
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
6563
|
+
const scripts = packageJson.scripts || {};
|
|
6490
6564
|
|
|
6565
|
+
const targetValidateScript = getTargetValidateScript(packageJson);
|
|
6566
|
+
if (!targetValidateScript) {
|
|
6567
|
+
return {
|
|
6568
|
+
applied: false,
|
|
6569
|
+
patchId: PATCH_ID$5,
|
|
6570
|
+
message: 'legacy validate command not found',
|
|
6571
|
+
};
|
|
6572
|
+
}
|
|
6491
6573
|
|
|
6574
|
+
scripts.validate = targetValidateScript;
|
|
6575
|
+
packageJson.scripts = scripts;
|
|
6576
|
+
await fs$1.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, 'utf-8');
|
|
6577
|
+
logger.info('[patch-nextjs-validate-concurrently] package.json patched');
|
|
6492
6578
|
|
|
6493
|
-
|
|
6579
|
+
return {
|
|
6580
|
+
applied: true,
|
|
6581
|
+
patchId: PATCH_ID$5,
|
|
6582
|
+
message: 'nextjs validate command patched',
|
|
6583
|
+
};
|
|
6584
|
+
};
|
|
6585
|
+
|
|
6586
|
+
const patchNextjsValidateConcurrently = {
|
|
6587
|
+
id: PATCH_ID$5,
|
|
6588
|
+
template: 'nextjs',
|
|
6589
|
+
disabled: byFlag(NEXTJS_VALIDATE_CONCURRENTLY_FLAG),
|
|
6590
|
+
operations: [
|
|
6591
|
+
{
|
|
6592
|
+
kind: 'file-patch',
|
|
6593
|
+
file: PACKAGE_JSON_FILE$3,
|
|
6594
|
+
description: 'Replace legacy validate command with concurrently',
|
|
6595
|
+
},
|
|
6596
|
+
],
|
|
6597
|
+
|
|
6598
|
+
shouldApply: hasPatchTarget,
|
|
6599
|
+
|
|
6600
|
+
apply: patchPackageJson$2,
|
|
6601
|
+
};
|
|
6602
|
+
|
|
6603
|
+
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; }
|
|
6604
|
+
|
|
6605
|
+
|
|
6606
|
+
|
|
6607
|
+
|
|
6608
|
+
|
|
6609
|
+
|
|
6610
|
+
const PATCH_ID$4 = 'vite/validate@0.0.20';
|
|
6494
6611
|
const PACKAGE_JSON_FILE$2 = 'package.json';
|
|
6495
|
-
const VALIDATE_SCRIPT_FILE$
|
|
6612
|
+
const VALIDATE_SCRIPT_FILE$1 = 'scripts/validate.sh';
|
|
6496
6613
|
const VITE_VALIDATE_FLAG = 'coding.arch.patch_vite_validate';
|
|
6497
6614
|
const TARGET_LINT_BUILD$1 = 'eslint . --quiet';
|
|
6498
6615
|
const TARGET_VALIDATE$1 = "pnpm run --parallel '/^(ts-check|lint:build)$/'";
|
|
@@ -6516,7 +6633,7 @@ echo "Validate passed!"
|
|
|
6516
6633
|
* @returns
|
|
6517
6634
|
*/
|
|
6518
6635
|
const isCozeValid$1 = (cozeConfig) => {
|
|
6519
|
-
if (_optionalChain$
|
|
6636
|
+
if (_optionalChain$5([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6520
6637
|
logger.info('[patch-vite-validate] NOT APPLY: dev.validate exists');
|
|
6521
6638
|
return false;
|
|
6522
6639
|
}
|
|
@@ -6564,7 +6681,7 @@ const isPackageJsonValid$1 = async (projectFolder) => {
|
|
|
6564
6681
|
* @returns
|
|
6565
6682
|
*/
|
|
6566
6683
|
const isScriptValid$1 = async (projectFolder) => {
|
|
6567
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$
|
|
6684
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$1);
|
|
6568
6685
|
if (await isFileExists(validateScriptPath)) {
|
|
6569
6686
|
logger.info('[patch-vite-validate] NOT APPLY: validate.sh already exists');
|
|
6570
6687
|
return false;
|
|
@@ -6602,7 +6719,7 @@ const patchPackageJson$1 = async (projectFolder) => {
|
|
|
6602
6719
|
* @returns
|
|
6603
6720
|
*/
|
|
6604
6721
|
const patchValidateScript$1 = async (projectFolder) => {
|
|
6605
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$
|
|
6722
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$1);
|
|
6606
6723
|
await fs$1.mkdir(path.join(projectFolder, 'scripts'), { recursive: true });
|
|
6607
6724
|
await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT$1, 'utf-8');
|
|
6608
6725
|
logger.info('[patch-vite-validate] validate.sh patched');
|
|
@@ -6622,7 +6739,7 @@ const patchCoze$1 = (cozeConfig) => {
|
|
|
6622
6739
|
};
|
|
6623
6740
|
|
|
6624
6741
|
const patchViteValidate = {
|
|
6625
|
-
id: PATCH_ID$
|
|
6742
|
+
id: PATCH_ID$4,
|
|
6626
6743
|
template: 'vite',
|
|
6627
6744
|
disabled: byFlag(VITE_VALIDATE_FLAG),
|
|
6628
6745
|
operations: [
|
|
@@ -6633,7 +6750,7 @@ const patchViteValidate = {
|
|
|
6633
6750
|
},
|
|
6634
6751
|
{
|
|
6635
6752
|
kind: 'create-file',
|
|
6636
|
-
file: VALIDATE_SCRIPT_FILE$
|
|
6753
|
+
file: VALIDATE_SCRIPT_FILE$1,
|
|
6637
6754
|
description: 'Add validate shell script for vite projects',
|
|
6638
6755
|
},
|
|
6639
6756
|
{
|
|
@@ -6655,22 +6772,22 @@ const patchViteValidate = {
|
|
|
6655
6772
|
|
|
6656
6773
|
return {
|
|
6657
6774
|
applied: true,
|
|
6658
|
-
patchId: PATCH_ID$
|
|
6775
|
+
patchId: PATCH_ID$4,
|
|
6659
6776
|
message: 'vite validate patched',
|
|
6660
6777
|
};
|
|
6661
6778
|
},
|
|
6662
6779
|
};
|
|
6663
6780
|
|
|
6664
|
-
function _optionalChain$
|
|
6781
|
+
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; }
|
|
6665
6782
|
|
|
6666
6783
|
|
|
6667
6784
|
|
|
6668
6785
|
|
|
6669
6786
|
|
|
6670
6787
|
|
|
6671
|
-
const PATCH_ID$
|
|
6788
|
+
const PATCH_ID$3 = 'taro/validate@0.0.20';
|
|
6672
6789
|
const PACKAGE_JSON_FILE$1 = 'package.json';
|
|
6673
|
-
const VALIDATE_SCRIPT_FILE
|
|
6790
|
+
const VALIDATE_SCRIPT_FILE = '.cozeproj/scripts/validate.sh';
|
|
6674
6791
|
const TARO_VALIDATE_FLAG = 'coding.arch.patch_taro_validate';
|
|
6675
6792
|
|
|
6676
6793
|
const LEGACY_LINT_BUILD =
|
|
@@ -6698,7 +6815,7 @@ echo "Validate passed!"
|
|
|
6698
6815
|
* @returns
|
|
6699
6816
|
*/
|
|
6700
6817
|
const isCozeValid = (cozeConfig) => {
|
|
6701
|
-
if (_optionalChain$
|
|
6818
|
+
if (_optionalChain$4([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6702
6819
|
logger.info('[patch-taro-validate] NOT APPLY: dev.validate exists');
|
|
6703
6820
|
return false;
|
|
6704
6821
|
}
|
|
@@ -6748,7 +6865,7 @@ const isPackageJsonValid = async (projectFolder) => {
|
|
|
6748
6865
|
* @returns
|
|
6749
6866
|
*/
|
|
6750
6867
|
const isScriptValid = async (projectFolder) => {
|
|
6751
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE
|
|
6868
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE);
|
|
6752
6869
|
if (await isFileExists(validateScriptPath)) {
|
|
6753
6870
|
logger.info('[patch-taro-validate] NOT APPLY: validate.sh already exists');
|
|
6754
6871
|
return false;
|
|
@@ -6789,7 +6906,7 @@ const patchPackageJson = async (projectFolder) => {
|
|
|
6789
6906
|
* @returns
|
|
6790
6907
|
*/
|
|
6791
6908
|
const patchValidateScript = async (projectFolder) => {
|
|
6792
|
-
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE
|
|
6909
|
+
const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE);
|
|
6793
6910
|
await fs$1.mkdir(path.join(projectFolder, '.cozeproj', 'scripts'), { recursive: true });
|
|
6794
6911
|
await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT, 'utf-8');
|
|
6795
6912
|
logger.info('[patch-taro-validate] validate.sh patched');
|
|
@@ -6809,7 +6926,7 @@ const patchCoze = (cozeConfig) => {
|
|
|
6809
6926
|
};
|
|
6810
6927
|
|
|
6811
6928
|
const patchTaroValidate = {
|
|
6812
|
-
id: PATCH_ID$
|
|
6929
|
+
id: PATCH_ID$3,
|
|
6813
6930
|
template: 'taro',
|
|
6814
6931
|
disabled: byFlag(TARO_VALIDATE_FLAG),
|
|
6815
6932
|
operations: [
|
|
@@ -6821,7 +6938,7 @@ const patchTaroValidate = {
|
|
|
6821
6938
|
},
|
|
6822
6939
|
{
|
|
6823
6940
|
kind: 'create-file',
|
|
6824
|
-
file: VALIDATE_SCRIPT_FILE
|
|
6941
|
+
file: VALIDATE_SCRIPT_FILE,
|
|
6825
6942
|
description: 'Add validate shell script for taro projects',
|
|
6826
6943
|
},
|
|
6827
6944
|
{
|
|
@@ -6841,14 +6958,14 @@ const patchTaroValidate = {
|
|
|
6841
6958
|
|
|
6842
6959
|
return {
|
|
6843
6960
|
applied: true,
|
|
6844
|
-
patchId: PATCH_ID$
|
|
6961
|
+
patchId: PATCH_ID$3,
|
|
6845
6962
|
message: 'taro validate patched',
|
|
6846
6963
|
};
|
|
6847
6964
|
},
|
|
6848
6965
|
};
|
|
6849
6966
|
|
|
6850
|
-
function _optionalChain$
|
|
6851
|
-
const PATCH_ID$
|
|
6967
|
+
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; }
|
|
6968
|
+
const PATCH_ID$2 = 'taro/update-pack-script-for-tt-build@0.0.13';
|
|
6852
6969
|
const PACKAGE_JSON_FILE = 'package.json';
|
|
6853
6970
|
const PACK_SCRIPT_FILE = '.cozeproj/scripts/pack.sh';
|
|
6854
6971
|
const LEGACY_PACK_SCRIPT_HASHES = new Set([
|
|
@@ -6926,12 +7043,12 @@ const readPackageScripts = async (
|
|
|
6926
7043
|
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6927
7044
|
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
6928
7045
|
|
|
6929
|
-
return _optionalChain$
|
|
7046
|
+
return _optionalChain$3([packageJson, 'optionalAccess', _ => _.scripts]) || null;
|
|
6930
7047
|
};
|
|
6931
7048
|
|
|
6932
7049
|
const hasBuildTtScript = async (projectFolder) => {
|
|
6933
7050
|
const scripts = await readPackageScripts(projectFolder);
|
|
6934
|
-
return typeof _optionalChain$
|
|
7051
|
+
return typeof _optionalChain$3([scripts, 'optionalAccess', _2 => _2['build:tt']]) === 'string';
|
|
6935
7052
|
};
|
|
6936
7053
|
|
|
6937
7054
|
const hasLegacyPackScript = async (projectFolder) => {
|
|
@@ -6945,7 +7062,7 @@ const hasLegacyPackScript = async (projectFolder) => {
|
|
|
6945
7062
|
};
|
|
6946
7063
|
|
|
6947
7064
|
const patchTaroPackScript = {
|
|
6948
|
-
id: PATCH_ID$
|
|
7065
|
+
id: PATCH_ID$2,
|
|
6949
7066
|
template: 'taro',
|
|
6950
7067
|
disabled: byFlag('coding.arch.patch_taro_update_pack_script_for_tt_build'),
|
|
6951
7068
|
operations: [
|
|
@@ -6964,7 +7081,7 @@ const patchTaroPackScript = {
|
|
|
6964
7081
|
if (context.template !== 'taro') {
|
|
6965
7082
|
return {
|
|
6966
7083
|
applied: false,
|
|
6967
|
-
patchId: PATCH_ID$
|
|
7084
|
+
patchId: PATCH_ID$2,
|
|
6968
7085
|
message: 'Only applies to taro projects, skipping',
|
|
6969
7086
|
};
|
|
6970
7087
|
}
|
|
@@ -6972,7 +7089,7 @@ const patchTaroPackScript = {
|
|
|
6972
7089
|
if (!(await hasBuildTtScript(context.projectFolder))) {
|
|
6973
7090
|
return {
|
|
6974
7091
|
applied: false,
|
|
6975
|
-
patchId: PATCH_ID$
|
|
7092
|
+
patchId: PATCH_ID$2,
|
|
6976
7093
|
message: 'package.json does not contain build:tt, skipping',
|
|
6977
7094
|
};
|
|
6978
7095
|
}
|
|
@@ -6980,7 +7097,7 @@ const patchTaroPackScript = {
|
|
|
6980
7097
|
if (!(await hasLegacyPackScript(context.projectFolder))) {
|
|
6981
7098
|
return {
|
|
6982
7099
|
applied: false,
|
|
6983
|
-
patchId: PATCH_ID$
|
|
7100
|
+
patchId: PATCH_ID$2,
|
|
6984
7101
|
message: 'pack.sh does not match legacy template hash, skipping',
|
|
6985
7102
|
};
|
|
6986
7103
|
}
|
|
@@ -6994,13 +7111,13 @@ const patchTaroPackScript = {
|
|
|
6994
7111
|
|
|
6995
7112
|
return {
|
|
6996
7113
|
applied: true,
|
|
6997
|
-
patchId: PATCH_ID$
|
|
7114
|
+
patchId: PATCH_ID$2,
|
|
6998
7115
|
message: 'Updated legacy pack.sh to build weapp and tt targets',
|
|
6999
7116
|
};
|
|
7000
7117
|
},
|
|
7001
7118
|
};
|
|
7002
7119
|
|
|
7003
|
-
const PATCH_ID$
|
|
7120
|
+
const PATCH_ID$1 = 'taro/add-agents-md@0.0.13';
|
|
7004
7121
|
const AGENTS_FILE = 'AGENTS.md';
|
|
7005
7122
|
const getTemplateAgentsPath = () =>
|
|
7006
7123
|
path.join(getTemplatesDir(), 'taro', AGENTS_FILE);
|
|
@@ -7012,7 +7129,7 @@ const readTemplateAgentsContent = async () =>
|
|
|
7012
7129
|
fs$1.readFile(getTemplateAgentsPath(), 'utf-8');
|
|
7013
7130
|
|
|
7014
7131
|
const patchTaroAgentsMd = {
|
|
7015
|
-
id: PATCH_ID$
|
|
7132
|
+
id: PATCH_ID$1,
|
|
7016
7133
|
template: 'taro',
|
|
7017
7134
|
disabled: byFlag('coding.arch.patch_taro_add_agents_md'),
|
|
7018
7135
|
operations: [
|
|
@@ -7030,7 +7147,7 @@ const patchTaroAgentsMd = {
|
|
|
7030
7147
|
if (context.template !== 'taro') {
|
|
7031
7148
|
return {
|
|
7032
7149
|
applied: false,
|
|
7033
|
-
patchId: PATCH_ID$
|
|
7150
|
+
patchId: PATCH_ID$1,
|
|
7034
7151
|
message: 'Only applies to taro projects, skipping',
|
|
7035
7152
|
};
|
|
7036
7153
|
}
|
|
@@ -7039,7 +7156,7 @@ const patchTaroAgentsMd = {
|
|
|
7039
7156
|
if (await isFileExists(targetPath)) {
|
|
7040
7157
|
return {
|
|
7041
7158
|
applied: false,
|
|
7042
|
-
patchId: PATCH_ID$
|
|
7159
|
+
patchId: PATCH_ID$1,
|
|
7043
7160
|
message: 'AGENTS.md already exists, skipping',
|
|
7044
7161
|
};
|
|
7045
7162
|
}
|
|
@@ -7049,160 +7166,12 @@ const patchTaroAgentsMd = {
|
|
|
7049
7166
|
|
|
7050
7167
|
return {
|
|
7051
7168
|
applied: true,
|
|
7052
|
-
patchId: PATCH_ID$
|
|
7169
|
+
patchId: PATCH_ID$1,
|
|
7053
7170
|
message: 'Created AGENTS.md from taro template',
|
|
7054
7171
|
};
|
|
7055
7172
|
},
|
|
7056
7173
|
};
|
|
7057
7174
|
|
|
7058
|
-
function _nullishCoalesce$5(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
const OLD_WEB_VALIDATE_WITH_STYLE = "pnpm run --parallel '/^(ts-check|lint:build|lint:style)$/'";
|
|
7065
|
-
const OLD_WEB_VALIDATE_WITHOUT_STYLE = "pnpm run --parallel '/^(ts-check|lint:build)$/'";
|
|
7066
|
-
const JSON_INDENT$1 = 2;
|
|
7067
|
-
|
|
7068
|
-
const OLD_WEB_TEMPLATE_VALIDATE_SCRIPT = `#!/bin/bash
|
|
7069
|
-
set -Eeuo pipefail
|
|
7070
|
-
|
|
7071
|
-
COZE_WORKSPACE_PATH="\${COZE_WORKSPACE_PATH:-$(pwd)}"
|
|
7072
|
-
|
|
7073
|
-
cd "\${COZE_WORKSPACE_PATH}"
|
|
7074
|
-
|
|
7075
|
-
echo "\u{1F50D} Running validate..."
|
|
7076
|
-
pnpm validate
|
|
7077
|
-
echo "\u{2705} Validate passed!"
|
|
7078
|
-
`;
|
|
7079
|
-
|
|
7080
|
-
const OLD_WEB_PATCH_VALIDATE_SCRIPT = `#!/bin/bash
|
|
7081
|
-
set -Eeuo pipefail
|
|
7082
|
-
COZE_WORKSPACE_PATH="\${COZE_WORKSPACE_PATH:-$(pwd)}"
|
|
7083
|
-
cd "\${COZE_WORKSPACE_PATH}"
|
|
7084
|
-
echo "Running validate..."
|
|
7085
|
-
pnpm validate
|
|
7086
|
-
echo "Validate passed!"
|
|
7087
|
-
`;
|
|
7088
|
-
|
|
7089
|
-
const createValidateScript = (parallelArgs) => `#!/bin/bash
|
|
7090
|
-
set -Eeuo pipefail
|
|
7091
|
-
|
|
7092
|
-
COZE_WORKSPACE_PATH="\${COZE_WORKSPACE_PATH:-$(pwd)}"
|
|
7093
|
-
|
|
7094
|
-
cd "\${COZE_WORKSPACE_PATH}"
|
|
7095
|
-
|
|
7096
|
-
echo "Running validate..."
|
|
7097
|
-
coze-dev parallel ${parallelArgs}
|
|
7098
|
-
echo "Validate passed!"
|
|
7099
|
-
`;
|
|
7100
|
-
|
|
7101
|
-
const VALIDATE_SCRIPT_FILE = 'scripts/validate.sh';
|
|
7102
|
-
|
|
7103
|
-
const isKnownOldValidateScript = (content) => [OLD_WEB_TEMPLATE_VALIDATE_SCRIPT, OLD_WEB_PATCH_VALIDATE_SCRIPT].includes(content);
|
|
7104
|
-
|
|
7105
|
-
const loadPackageJson = async (projectFolder) => {
|
|
7106
|
-
const packageJsonPath = path.join(projectFolder, 'package.json');
|
|
7107
|
-
if (!(await isFileExists(packageJsonPath))) {
|
|
7108
|
-
return null;
|
|
7109
|
-
}
|
|
7110
|
-
|
|
7111
|
-
const content = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
7112
|
-
const packageJson = safeJsonParse(content, null);
|
|
7113
|
-
if (!packageJson) {
|
|
7114
|
-
return null;
|
|
7115
|
-
}
|
|
7116
|
-
|
|
7117
|
-
return { path: packageJsonPath, json: packageJson };
|
|
7118
|
-
};
|
|
7119
|
-
|
|
7120
|
-
const getParallelArgs = (packageJson) => {
|
|
7121
|
-
const validate = _optionalChain$5([packageJson, 'optionalAccess', _ => _.scripts, 'optionalAccess', _2 => _2.validate]);
|
|
7122
|
-
if (validate === OLD_WEB_VALIDATE_WITHOUT_STYLE) {
|
|
7123
|
-
return 'ts-check lint:build';
|
|
7124
|
-
}
|
|
7125
|
-
|
|
7126
|
-
if (validate === OLD_WEB_VALIDATE_WITH_STYLE) {
|
|
7127
|
-
return 'ts-check lint:build lint:style';
|
|
7128
|
-
}
|
|
7129
|
-
|
|
7130
|
-
return typeof _optionalChain$5([packageJson, 'optionalAccess', _3 => _3.scripts, 'optionalAccess', _4 => _4['lint:style']]) === 'string' ? 'ts-check lint:build lint:style' : 'ts-check lint:build';
|
|
7131
|
-
};
|
|
7132
|
-
|
|
7133
|
-
const updatePackageValidate = async (packageJsonInfo, parallelArgs) => {
|
|
7134
|
-
if (!_optionalChain$5([packageJsonInfo, 'optionalAccess', _5 => _5.json, 'access', _6 => _6.scripts])) {
|
|
7135
|
-
return false;
|
|
7136
|
-
}
|
|
7137
|
-
|
|
7138
|
-
const oldValidate = packageJsonInfo.json.scripts.validate;
|
|
7139
|
-
const shouldUpdate = oldValidate === OLD_WEB_VALIDATE_WITH_STYLE || oldValidate === OLD_WEB_VALIDATE_WITHOUT_STYLE;
|
|
7140
|
-
|
|
7141
|
-
if (!shouldUpdate) {
|
|
7142
|
-
return false;
|
|
7143
|
-
}
|
|
7144
|
-
|
|
7145
|
-
packageJsonInfo.json.scripts.validate = `coze-dev parallel ${parallelArgs}`;
|
|
7146
|
-
await fs$1.writeFile(packageJsonInfo.path, `${JSON.stringify(packageJsonInfo.json, null, JSON_INDENT$1)}\n`, 'utf-8');
|
|
7147
|
-
return true;
|
|
7148
|
-
};
|
|
7149
|
-
|
|
7150
|
-
const applyValidateRunnerPatch = async (context, patchId) => {
|
|
7151
|
-
const validateScriptPath = path.join(context.projectFolder, VALIDATE_SCRIPT_FILE);
|
|
7152
|
-
const content = await fs$1.readFile(validateScriptPath, 'utf-8');
|
|
7153
|
-
|
|
7154
|
-
if (!isKnownOldValidateScript(content)) {
|
|
7155
|
-
return {
|
|
7156
|
-
applied: false,
|
|
7157
|
-
patchId,
|
|
7158
|
-
message: 'validate.sh content is not a known old version, skipping',
|
|
7159
|
-
};
|
|
7160
|
-
}
|
|
7161
|
-
|
|
7162
|
-
const packageJsonInfo = await loadPackageJson(context.projectFolder);
|
|
7163
|
-
const parallelArgs = getParallelArgs(_nullishCoalesce$5(_optionalChain$5([packageJsonInfo, 'optionalAccess', _7 => _7.json]), () => ( null)));
|
|
7164
|
-
await fs$1.writeFile(validateScriptPath, createValidateScript(parallelArgs), 'utf-8');
|
|
7165
|
-
const packageJsonUpdated = await updatePackageValidate(packageJsonInfo, parallelArgs);
|
|
7166
|
-
|
|
7167
|
-
logger.info(`Patched ${VALIDATE_SCRIPT_FILE}: use coze-dev parallel`);
|
|
7168
|
-
|
|
7169
|
-
return {
|
|
7170
|
-
applied: true,
|
|
7171
|
-
patchId,
|
|
7172
|
-
message: packageJsonUpdated ? 'Updated validate.sh and package validate script' : 'Updated validate.sh',
|
|
7173
|
-
};
|
|
7174
|
-
};
|
|
7175
|
-
|
|
7176
|
-
const PATCH_ID$1 = 'nextjs/validate-runner@0.0.31';
|
|
7177
|
-
|
|
7178
|
-
const patchNextjsValidateRunner = {
|
|
7179
|
-
id: PATCH_ID$1,
|
|
7180
|
-
template: 'nextjs',
|
|
7181
|
-
disabled: byFlag('coding.arch.patch_nextjs_validate_runner'),
|
|
7182
|
-
operations: [
|
|
7183
|
-
{
|
|
7184
|
-
kind: 'file-patch',
|
|
7185
|
-
file: VALIDATE_SCRIPT_FILE,
|
|
7186
|
-
description: 'Update validate shell script to use coze-dev parallel',
|
|
7187
|
-
},
|
|
7188
|
-
{
|
|
7189
|
-
kind: 'file-patch',
|
|
7190
|
-
file: 'package.json',
|
|
7191
|
-
description: 'Update validate package script when it matches old pnpm run form',
|
|
7192
|
-
},
|
|
7193
|
-
],
|
|
7194
|
-
shouldApply: async context => {
|
|
7195
|
-
const validateScriptPath = path.join(context.projectFolder, VALIDATE_SCRIPT_FILE);
|
|
7196
|
-
if (!(await isFileExists(validateScriptPath))) {
|
|
7197
|
-
return false;
|
|
7198
|
-
}
|
|
7199
|
-
|
|
7200
|
-
const content = await fs$1.readFile(validateScriptPath, 'utf-8');
|
|
7201
|
-
return isKnownOldValidateScript(content);
|
|
7202
|
-
},
|
|
7203
|
-
apply: context => applyValidateRunnerPatch(context, PATCH_ID$1),
|
|
7204
|
-
};
|
|
7205
|
-
|
|
7206
7175
|
const SCRIPT_FILES = ['dev.sh', 'build.sh'] ;
|
|
7207
7176
|
const SUPPORTED_TEMPLATES = new Set(['nextjs', 'vite', 'nuxt-vue']);
|
|
7208
7177
|
|
|
@@ -7418,7 +7387,7 @@ const patches = [
|
|
|
7418
7387
|
patchExpoValidate,
|
|
7419
7388
|
replaceNpxWithPnpmPatchNextjs,
|
|
7420
7389
|
patchNextjsValidate,
|
|
7421
|
-
|
|
7390
|
+
patchNextjsValidateConcurrently,
|
|
7422
7391
|
replaceNpxWithPnpmPatchVite,
|
|
7423
7392
|
patchViteValidate,
|
|
7424
7393
|
replaceNpxWithPnpmPatchNuxtVue,
|
|
@@ -7428,9 +7397,12 @@ const patches = [
|
|
|
7428
7397
|
patchTaroPackScript,
|
|
7429
7398
|
] ;
|
|
7430
7399
|
|
|
7431
|
-
const getTemplatePatches = (
|
|
7400
|
+
const getTemplatePatches = (
|
|
7401
|
+
template,
|
|
7402
|
+
) =>
|
|
7403
|
+
patches.filter(patch => patch.template === template);
|
|
7432
7404
|
|
|
7433
|
-
function _nullishCoalesce$
|
|
7405
|
+
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; }
|
|
7434
7406
|
const DEFAULT_LEGACY_VERSION = 'legacy';
|
|
7435
7407
|
|
|
7436
7408
|
const loadFlagsWithFallback = async () => {
|
|
@@ -7536,7 +7508,7 @@ const getNextPatchState = (
|
|
|
7536
7508
|
|
|
7537
7509
|
) => ({
|
|
7538
7510
|
template,
|
|
7539
|
-
version: _optionalChain$
|
|
7511
|
+
version: _optionalChain$2([config, 'access', _ => _.project, 'optionalAccess', _2 => _2.version]) || DEFAULT_LEGACY_VERSION,
|
|
7540
7512
|
appliedPatches: [...appliedPatches, patchId],
|
|
7541
7513
|
});
|
|
7542
7514
|
|
|
@@ -7560,15 +7532,15 @@ const executePatch = async (
|
|
|
7560
7532
|
}
|
|
7561
7533
|
|
|
7562
7534
|
const template =
|
|
7563
|
-
_optionalChain$
|
|
7535
|
+
_optionalChain$2([config, 'access', _3 => _3.project, 'optionalAccess', _4 => _4.template]) || (await detectTemplateKey(projectFolder));
|
|
7564
7536
|
|
|
7565
7537
|
if (!template) {
|
|
7566
7538
|
logger.info('Patch skipped: template not detected');
|
|
7567
7539
|
return;
|
|
7568
7540
|
}
|
|
7569
7541
|
|
|
7570
|
-
const appliedPatches = [...(_optionalChain$
|
|
7571
|
-
const projectVersion = _optionalChain$
|
|
7542
|
+
const appliedPatches = [...(_optionalChain$2([config, 'access', _5 => _5.project, 'optionalAccess', _6 => _6.appliedPatches]) || [])];
|
|
7543
|
+
const projectVersion = _optionalChain$2([config, 'access', _7 => _7.project, 'optionalAccess', _8 => _8.version]);
|
|
7572
7544
|
const flags = await loadFlagsWithFallback();
|
|
7573
7545
|
|
|
7574
7546
|
const context = {
|
|
@@ -7613,7 +7585,7 @@ const executePatch = async (
|
|
|
7613
7585
|
|
|
7614
7586
|
if (options.dryRun) {
|
|
7615
7587
|
logger.info(`Detected template: ${template}`);
|
|
7616
|
-
logger.info(`Current version: ${_nullishCoalesce$
|
|
7588
|
+
logger.info(`Current version: ${_nullishCoalesce$3(projectVersion, () => ( DEFAULT_LEGACY_VERSION))}`);
|
|
7617
7589
|
logger.info(`Applied patches: ${appliedPatches.join(', ') || '(none)'}`);
|
|
7618
7590
|
logger.info('Matched patches:');
|
|
7619
7591
|
matchedPatches.forEach(patch => {
|
|
@@ -7654,7 +7626,7 @@ const executePatch = async (
|
|
|
7654
7626
|
}
|
|
7655
7627
|
};
|
|
7656
7628
|
|
|
7657
|
-
const registerCommand$
|
|
7629
|
+
const registerCommand$4 = program => {
|
|
7658
7630
|
program
|
|
7659
7631
|
.command('patch')
|
|
7660
7632
|
.description('Apply template patches for existing projects')
|
|
@@ -7671,14 +7643,14 @@ const registerCommand$5 = program => {
|
|
|
7671
7643
|
) => {
|
|
7672
7644
|
await executePatch({
|
|
7673
7645
|
directory,
|
|
7674
|
-
dryRun: _optionalChain$
|
|
7675
|
-
showFlags: _optionalChain$
|
|
7646
|
+
dryRun: _optionalChain$2([command, 'optionalAccess', _9 => _9.dryRun]),
|
|
7647
|
+
showFlags: _optionalChain$2([command, 'optionalAccess', _10 => _10.showFlags]),
|
|
7676
7648
|
});
|
|
7677
7649
|
},
|
|
7678
7650
|
);
|
|
7679
7651
|
};
|
|
7680
7652
|
|
|
7681
|
-
function _nullishCoalesce$
|
|
7653
|
+
function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
7682
7654
|
const d$1 = debug('coze-init-cli:run');
|
|
7683
7655
|
|
|
7684
7656
|
/**
|
|
@@ -7809,12 +7781,12 @@ const executeRun = async (commandName, options = {}) => {
|
|
|
7809
7781
|
}
|
|
7810
7782
|
|
|
7811
7783
|
// 将输出同时写入控制台和日志文件
|
|
7812
|
-
_optionalChain$
|
|
7784
|
+
_optionalChain$1([childProcess, 'access', _ => _.stdout, 'optionalAccess', _2 => _2.on, 'call', _3 => _3('data', (data) => {
|
|
7813
7785
|
process.stdout.write(data);
|
|
7814
7786
|
logStream.write(data);
|
|
7815
7787
|
})]);
|
|
7816
7788
|
|
|
7817
|
-
_optionalChain$
|
|
7789
|
+
_optionalChain$1([childProcess, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6('data', (data) => {
|
|
7818
7790
|
process.stderr.write(data);
|
|
7819
7791
|
logStream.write(data);
|
|
7820
7792
|
})]);
|
|
@@ -7827,7 +7799,7 @@ const executeRun = async (commandName, options = {}) => {
|
|
|
7827
7799
|
const buildDuration = Date.now() - buildStartTime;
|
|
7828
7800
|
|
|
7829
7801
|
if (code !== 0) {
|
|
7830
|
-
const errorMessage = `Command exited with code ${_nullishCoalesce$
|
|
7802
|
+
const errorMessage = `Command exited with code ${_nullishCoalesce$2(code, () => ( 'unknown'))}${signal ? ` and signal ${signal}` : ''}`;
|
|
7831
7803
|
logger.error(errorMessage);
|
|
7832
7804
|
logger.error(`Check log file for details: ${logFilePath}`);
|
|
7833
7805
|
|
|
@@ -7839,12 +7811,12 @@ const executeRun = async (commandName, options = {}) => {
|
|
|
7839
7811
|
categories: {
|
|
7840
7812
|
fixDuration: String(fixDuration),
|
|
7841
7813
|
buildDuration: String(buildDuration),
|
|
7842
|
-
exitCode: String(_nullishCoalesce$
|
|
7814
|
+
exitCode: String(_nullishCoalesce$2(code, () => ( 'unknown'))),
|
|
7843
7815
|
projectType,
|
|
7844
7816
|
},
|
|
7845
7817
|
errorContext: {
|
|
7846
|
-
exitCode: String(_nullishCoalesce$
|
|
7847
|
-
signal: _nullishCoalesce$
|
|
7818
|
+
exitCode: String(_nullishCoalesce$2(code, () => ( 'unknown'))),
|
|
7819
|
+
signal: _nullishCoalesce$2(signal, () => ( 'none')),
|
|
7848
7820
|
logFile: logFilePath,
|
|
7849
7821
|
projectType,
|
|
7850
7822
|
},
|
|
@@ -7920,7 +7892,7 @@ const executeRun = async (commandName, options = {}) => {
|
|
|
7920
7892
|
/**
|
|
7921
7893
|
* 注册 dev/build/start 命令到 program
|
|
7922
7894
|
*/
|
|
7923
|
-
const registerCommand$
|
|
7895
|
+
const registerCommand$3 = program => {
|
|
7924
7896
|
// dev 命令
|
|
7925
7897
|
program
|
|
7926
7898
|
.command('dev')
|
|
@@ -8748,7 +8720,7 @@ const scanRoutesOnce = async (
|
|
|
8748
8720
|
}
|
|
8749
8721
|
};
|
|
8750
8722
|
|
|
8751
|
-
function _optionalChain
|
|
8723
|
+
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
|
|
8752
8724
|
|
|
8753
8725
|
|
|
8754
8726
|
const log = debug('coze:routes');
|
|
@@ -8836,7 +8808,7 @@ const executeRoutes = async (
|
|
|
8836
8808
|
/**
|
|
8837
8809
|
* Register routes command to program
|
|
8838
8810
|
*/
|
|
8839
|
-
const registerCommand$
|
|
8811
|
+
const registerCommand$2 = program => {
|
|
8840
8812
|
program
|
|
8841
8813
|
.command('routes')
|
|
8842
8814
|
.description('Generate routes manifest for the current project')
|
|
@@ -8849,13 +8821,14 @@ const registerCommand$3 = program => {
|
|
|
8849
8821
|
'Output file path (defaults to ~/.coze/routes.json)',
|
|
8850
8822
|
)
|
|
8851
8823
|
.action(async (directory, options) => {
|
|
8852
|
-
await executeRoutes({ directory, output: _optionalChain
|
|
8824
|
+
await executeRoutes({ directory, output: _optionalChain([options, 'optionalAccess', _ => _.output]) });
|
|
8853
8825
|
});
|
|
8854
8826
|
};
|
|
8855
8827
|
|
|
8856
|
-
function _nullishCoalesce$
|
|
8828
|
+
function _nullishCoalesce$1(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
8857
8829
|
|
|
8858
8830
|
|
|
8831
|
+
const d = debug('coze-init-cli:check-bins');
|
|
8859
8832
|
|
|
8860
8833
|
|
|
8861
8834
|
|
|
@@ -8863,97 +8836,117 @@ function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else
|
|
|
8863
8836
|
|
|
8864
8837
|
|
|
8865
8838
|
|
|
8839
|
+
const checkBins = async (cwd, fix) => {
|
|
8840
|
+
d('starting check, cwd=%s fix=%s', cwd, fix);
|
|
8866
8841
|
|
|
8842
|
+
const pkgJson = safeJsonParse
|
|
8867
8843
|
|
|
8868
8844
|
|
|
8869
|
-
|
|
8870
|
-
new Promise(resolve => {
|
|
8871
|
-
const output = [];
|
|
8872
|
-
const child = child_process.spawn(options.packageManager, ['run', script], {
|
|
8873
|
-
cwd: options.cwd,
|
|
8874
|
-
env: process.env,
|
|
8875
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
8876
|
-
});
|
|
8845
|
+
(await fs$1.readFile(path.join(cwd, 'package.json'), 'utf8'), {});
|
|
8877
8846
|
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
_optionalChain$1([child, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6('data', data => {
|
|
8882
|
-
output.push(String(data));
|
|
8883
|
-
})]);
|
|
8884
|
-
child.on('error', error => {
|
|
8885
|
-
output.push(`${error.stack || error.message}\n`);
|
|
8886
|
-
resolve({
|
|
8887
|
-
script,
|
|
8888
|
-
code: 1,
|
|
8889
|
-
output: output.join(''),
|
|
8890
|
-
});
|
|
8891
|
-
});
|
|
8892
|
-
child.on('close', code => {
|
|
8893
|
-
resolve({
|
|
8894
|
-
script,
|
|
8895
|
-
code: _nullishCoalesce$2(code, () => ( 1)),
|
|
8896
|
-
output: output.join(''),
|
|
8897
|
-
});
|
|
8898
|
-
});
|
|
8847
|
+
const allDeps = Object.keys({
|
|
8848
|
+
...pkgJson.dependencies,
|
|
8849
|
+
...pkgJson.devDependencies,
|
|
8899
8850
|
});
|
|
8900
8851
|
|
|
8901
|
-
|
|
8902
|
-
if (scripts.length === 0) {
|
|
8903
|
-
process.stderr.write('No scripts specified.\n');
|
|
8904
|
-
return 1;
|
|
8905
|
-
}
|
|
8852
|
+
d('found %d total dependencies to scan', allDeps.length);
|
|
8906
8853
|
|
|
8907
|
-
const
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
};
|
|
8854
|
+
const binDir = path.join(cwd, 'node_modules', '.bin');
|
|
8855
|
+
d('bin directory: %s', binDir);
|
|
8856
|
+
const missing = [];
|
|
8911
8857
|
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8858
|
+
await Promise.all(
|
|
8859
|
+
allDeps.map(async depName => {
|
|
8860
|
+
let rawContent;
|
|
8861
|
+
try {
|
|
8862
|
+
rawContent = await fs$1.readFile(
|
|
8863
|
+
path.join(cwd, 'node_modules', depName, 'package.json'),
|
|
8864
|
+
'utf8',
|
|
8865
|
+
);
|
|
8866
|
+
} catch (err) {
|
|
8867
|
+
d('dep %s not found in node_modules: %s', depName, err);
|
|
8868
|
+
missing.push({ dep: depName, bin: '', reason: 'missing-package' });
|
|
8869
|
+
return;
|
|
8870
|
+
}
|
|
8871
|
+
const depPkg = safeJsonParse(
|
|
8872
|
+
rawContent,
|
|
8873
|
+
);
|
|
8874
|
+
if (!depPkg) {
|
|
8875
|
+
d('skipping %s: failed to parse package.json', depName);
|
|
8876
|
+
return;
|
|
8877
|
+
}
|
|
8916
8878
|
|
|
8917
|
-
|
|
8918
|
-
|
|
8879
|
+
if (!depPkg.bin) {
|
|
8880
|
+
return;
|
|
8881
|
+
}
|
|
8919
8882
|
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
|
|
8926
|
-
|
|
8883
|
+
const bins =
|
|
8884
|
+
typeof depPkg.bin === 'string'
|
|
8885
|
+
? { [_nullishCoalesce$1(depName.split('/').pop(), () => ( depName))]: depPkg.bin }
|
|
8886
|
+
: depPkg.bin;
|
|
8887
|
+
|
|
8888
|
+
d('%s declares bins: %o', depName, Object.keys(bins));
|
|
8889
|
+
|
|
8890
|
+
await Promise.all(
|
|
8891
|
+
Object.keys(bins).map(async binName => {
|
|
8892
|
+
try {
|
|
8893
|
+
await fs$1.access(path.join(binDir, binName));
|
|
8894
|
+
d('bin present: %s', binName);
|
|
8895
|
+
} catch (err) {
|
|
8896
|
+
d('bin missing: %s (from %s): %s', binName, depName, err);
|
|
8897
|
+
missing.push({ dep: depName, bin: binName, reason: 'missing-bin' });
|
|
8898
|
+
}
|
|
8899
|
+
}),
|
|
8900
|
+
);
|
|
8901
|
+
}),
|
|
8902
|
+
);
|
|
8927
8903
|
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8904
|
+
d('scan complete, missing=%d', missing.length);
|
|
8905
|
+
|
|
8906
|
+
if (missing.length === 0) {
|
|
8907
|
+
logger.success(
|
|
8908
|
+
'check-bins: all bin entries present, skipping force install.',
|
|
8909
|
+
);
|
|
8910
|
+
return;
|
|
8931
8911
|
}
|
|
8932
8912
|
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
|
|
8938
|
-
|
|
8913
|
+
logger.warn('check-bins: missing or broken dependencies detected:');
|
|
8914
|
+
for (const { dep, bin, reason } of missing) {
|
|
8915
|
+
if (reason === 'missing-package') {
|
|
8916
|
+
logger.warn(` ${dep} -> (package not found in node_modules)`);
|
|
8917
|
+
} else {
|
|
8918
|
+
logger.warn(` ${dep} -> .bin/${bin}`);
|
|
8939
8919
|
}
|
|
8940
|
-
|
|
8941
|
-
|
|
8920
|
+
}
|
|
8921
|
+
|
|
8922
|
+
if (!fix) {
|
|
8923
|
+
logger.error(
|
|
8924
|
+
'check-bins: missing bin entries found, run with --fix to repair.',
|
|
8925
|
+
);
|
|
8926
|
+
process.exit(1);
|
|
8927
|
+
}
|
|
8942
8928
|
|
|
8943
|
-
|
|
8929
|
+
logger.info('check-bins: running pnpm i --force to fix...');
|
|
8930
|
+
d('executing: pnpm i --force');
|
|
8931
|
+
child_process.execSync('pnpm i --force', { stdio: 'inherit', cwd });
|
|
8932
|
+
d('pnpm i --force completed');
|
|
8944
8933
|
};
|
|
8945
8934
|
|
|
8946
|
-
const registerCommand$
|
|
8935
|
+
const registerCommand$1 = program => {
|
|
8947
8936
|
program
|
|
8948
|
-
.command('
|
|
8949
|
-
.description(
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
.option('
|
|
8953
|
-
.
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8937
|
+
.command('check-bins')
|
|
8938
|
+
.description(
|
|
8939
|
+
'Verify all bin entries from dependencies exist in node_modules/.bin, run pnpm i --force if any are missing',
|
|
8940
|
+
)
|
|
8941
|
+
.option('-c, --cwd <path>', 'Working directory to check', process.cwd())
|
|
8942
|
+
.option('--fix', 'Run pnpm i --force to repair missing bin entries', false)
|
|
8943
|
+
.action(async (options) => {
|
|
8944
|
+
try {
|
|
8945
|
+
await checkBins(options.cwd, options.fix);
|
|
8946
|
+
} catch (err) {
|
|
8947
|
+
logger.warn(
|
|
8948
|
+
`check-bins: skipped due to error: ${err instanceof Error ? err.message : String(err)}`,
|
|
8949
|
+
);
|
|
8957
8950
|
}
|
|
8958
8951
|
});
|
|
8959
8952
|
};
|
|
@@ -9833,7 +9826,7 @@ const execute = async (
|
|
|
9833
9826
|
};
|
|
9834
9827
|
};
|
|
9835
9828
|
|
|
9836
|
-
function _nullishCoalesce
|
|
9829
|
+
function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
9837
9830
|
/**
|
|
9838
9831
|
* 运行 pnpm install
|
|
9839
9832
|
*/
|
|
@@ -10023,7 +10016,7 @@ const executeTemplateEngineStep = async ctx => {
|
|
|
10023
10016
|
templateName: ctx.templateName,
|
|
10024
10017
|
outputPath: ctx.outputPath,
|
|
10025
10018
|
command: ctx.command,
|
|
10026
|
-
force: _nullishCoalesce
|
|
10019
|
+
force: _nullishCoalesce(ctx.options.force, () => ( false)),
|
|
10027
10020
|
});
|
|
10028
10021
|
|
|
10029
10022
|
// 保存结果到上下文
|
|
@@ -10282,7 +10275,7 @@ const executeInit = async (
|
|
|
10282
10275
|
/**
|
|
10283
10276
|
* 注册 init 命令到 program
|
|
10284
10277
|
*/
|
|
10285
|
-
const registerCommand
|
|
10278
|
+
const registerCommand = program => {
|
|
10286
10279
|
program
|
|
10287
10280
|
.command('init')
|
|
10288
10281
|
.description('Initialize a new project from a template')
|
|
@@ -10300,149 +10293,21 @@ const registerCommand$1 = program => {
|
|
|
10300
10293
|
.allowUnknownOption() // 允许透传参数
|
|
10301
10294
|
.action(async (directory, options, command) => {
|
|
10302
10295
|
// 位置参数优先级高于 --output 选项
|
|
10303
|
-
const outputPath = _nullishCoalesce
|
|
10296
|
+
const outputPath = _nullishCoalesce(directory, () => ( options.output));
|
|
10304
10297
|
// Always use force mode - overwrite existing files without conflict check
|
|
10305
10298
|
const force = true;
|
|
10306
10299
|
await executeInit({ ...options, output: outputPath, force }, command);
|
|
10307
10300
|
});
|
|
10308
10301
|
};
|
|
10309
10302
|
|
|
10310
|
-
function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
const d = debug('coze-init-cli:check-bins');
|
|
10314
|
-
|
|
10315
|
-
|
|
10316
|
-
|
|
10317
|
-
|
|
10318
|
-
|
|
10319
|
-
|
|
10320
|
-
|
|
10321
|
-
const checkBins = async (cwd, fix) => {
|
|
10322
|
-
d('starting check, cwd=%s fix=%s', cwd, fix);
|
|
10323
|
-
|
|
10324
|
-
const pkgJson = safeJsonParse
|
|
10325
|
-
|
|
10326
|
-
|
|
10327
|
-
(await fs$1.readFile(path.join(cwd, 'package.json'), 'utf8'), {});
|
|
10328
|
-
|
|
10329
|
-
const allDeps = Object.keys({
|
|
10330
|
-
...pkgJson.dependencies,
|
|
10331
|
-
...pkgJson.devDependencies,
|
|
10332
|
-
});
|
|
10333
|
-
|
|
10334
|
-
d('found %d total dependencies to scan', allDeps.length);
|
|
10335
|
-
|
|
10336
|
-
const binDir = path.join(cwd, 'node_modules', '.bin');
|
|
10337
|
-
d('bin directory: %s', binDir);
|
|
10338
|
-
const missing = [];
|
|
10339
|
-
|
|
10340
|
-
await Promise.all(
|
|
10341
|
-
allDeps.map(async depName => {
|
|
10342
|
-
let rawContent;
|
|
10343
|
-
try {
|
|
10344
|
-
rawContent = await fs$1.readFile(
|
|
10345
|
-
path.join(cwd, 'node_modules', depName, 'package.json'),
|
|
10346
|
-
'utf8',
|
|
10347
|
-
);
|
|
10348
|
-
} catch (err) {
|
|
10349
|
-
d('dep %s not found in node_modules: %s', depName, err);
|
|
10350
|
-
missing.push({ dep: depName, bin: '', reason: 'missing-package' });
|
|
10351
|
-
return;
|
|
10352
|
-
}
|
|
10353
|
-
const depPkg = safeJsonParse(
|
|
10354
|
-
rawContent,
|
|
10355
|
-
);
|
|
10356
|
-
if (!depPkg) {
|
|
10357
|
-
d('skipping %s: failed to parse package.json', depName);
|
|
10358
|
-
return;
|
|
10359
|
-
}
|
|
10360
|
-
|
|
10361
|
-
if (!depPkg.bin) {
|
|
10362
|
-
return;
|
|
10363
|
-
}
|
|
10364
|
-
|
|
10365
|
-
const bins =
|
|
10366
|
-
typeof depPkg.bin === 'string'
|
|
10367
|
-
? { [_nullishCoalesce(depName.split('/').pop(), () => ( depName))]: depPkg.bin }
|
|
10368
|
-
: depPkg.bin;
|
|
10369
|
-
|
|
10370
|
-
d('%s declares bins: %o', depName, Object.keys(bins));
|
|
10371
|
-
|
|
10372
|
-
await Promise.all(
|
|
10373
|
-
Object.keys(bins).map(async binName => {
|
|
10374
|
-
try {
|
|
10375
|
-
await fs$1.access(path.join(binDir, binName));
|
|
10376
|
-
d('bin present: %s', binName);
|
|
10377
|
-
} catch (err) {
|
|
10378
|
-
d('bin missing: %s (from %s): %s', binName, depName, err);
|
|
10379
|
-
missing.push({ dep: depName, bin: binName, reason: 'missing-bin' });
|
|
10380
|
-
}
|
|
10381
|
-
}),
|
|
10382
|
-
);
|
|
10383
|
-
}),
|
|
10384
|
-
);
|
|
10385
|
-
|
|
10386
|
-
d('scan complete, missing=%d', missing.length);
|
|
10387
|
-
|
|
10388
|
-
if (missing.length === 0) {
|
|
10389
|
-
logger.success(
|
|
10390
|
-
'check-bins: all bin entries present, skipping force install.',
|
|
10391
|
-
);
|
|
10392
|
-
return;
|
|
10393
|
-
}
|
|
10394
|
-
|
|
10395
|
-
logger.warn('check-bins: missing or broken dependencies detected:');
|
|
10396
|
-
for (const { dep, bin, reason } of missing) {
|
|
10397
|
-
if (reason === 'missing-package') {
|
|
10398
|
-
logger.warn(` ${dep} -> (package not found in node_modules)`);
|
|
10399
|
-
} else {
|
|
10400
|
-
logger.warn(` ${dep} -> .bin/${bin}`);
|
|
10401
|
-
}
|
|
10402
|
-
}
|
|
10403
|
-
|
|
10404
|
-
if (!fix) {
|
|
10405
|
-
logger.error(
|
|
10406
|
-
'check-bins: missing bin entries found, run with --fix to repair.',
|
|
10407
|
-
);
|
|
10408
|
-
process.exit(1);
|
|
10409
|
-
}
|
|
10410
|
-
|
|
10411
|
-
logger.info('check-bins: running pnpm i --force to fix...');
|
|
10412
|
-
d('executing: pnpm i --force');
|
|
10413
|
-
child_process.execSync('pnpm i --force', { stdio: 'inherit', cwd });
|
|
10414
|
-
d('pnpm i --force completed');
|
|
10415
|
-
};
|
|
10416
|
-
|
|
10417
|
-
const registerCommand = program => {
|
|
10418
|
-
program
|
|
10419
|
-
.command('check-bins')
|
|
10420
|
-
.description(
|
|
10421
|
-
'Verify all bin entries from dependencies exist in node_modules/.bin, run pnpm i --force if any are missing',
|
|
10422
|
-
)
|
|
10423
|
-
.option('-c, --cwd <path>', 'Working directory to check', process.cwd())
|
|
10424
|
-
.option('--fix', 'Run pnpm i --force to repair missing bin entries', false)
|
|
10425
|
-
.action(async (options) => {
|
|
10426
|
-
try {
|
|
10427
|
-
await checkBins(options.cwd, options.fix);
|
|
10428
|
-
} catch (err) {
|
|
10429
|
-
logger.warn(
|
|
10430
|
-
`check-bins: skipped due to error: ${err instanceof Error ? err.message : String(err)}`,
|
|
10431
|
-
);
|
|
10432
|
-
}
|
|
10433
|
-
});
|
|
10434
|
-
};
|
|
10435
|
-
|
|
10436
|
-
function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
10437
10303
|
const commands = [
|
|
10438
|
-
registerCommand
|
|
10304
|
+
registerCommand,
|
|
10305
|
+
registerCommand$3,
|
|
10306
|
+
registerCommand$6,
|
|
10439
10307
|
registerCommand$4,
|
|
10440
|
-
registerCommand$7,
|
|
10441
10308
|
registerCommand$5,
|
|
10442
|
-
registerCommand$6,
|
|
10443
|
-
registerCommand$3,
|
|
10444
|
-
registerCommand,
|
|
10445
10309
|
registerCommand$2,
|
|
10310
|
+
registerCommand$1,
|
|
10446
10311
|
];
|
|
10447
10312
|
|
|
10448
10313
|
const main = async () => {
|
|
@@ -10473,8 +10338,10 @@ const main = async () => {
|
|
|
10473
10338
|
const program = new commander.Command();
|
|
10474
10339
|
|
|
10475
10340
|
program
|
|
10476
|
-
.name(
|
|
10477
|
-
.description(
|
|
10341
|
+
.name('coze')
|
|
10342
|
+
.description(
|
|
10343
|
+
'Coze Coding CLI - Project template engine for frontend stacks',
|
|
10344
|
+
)
|
|
10478
10345
|
.version(packageJson.version);
|
|
10479
10346
|
|
|
10480
10347
|
commands.forEach(initCmd => initCmd(program));
|