@coze-arch/cli 0.0.15 → 0.0.16-alpha.a1c0bb
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/.coze +1 -0
- package/lib/__templates__/expo/.cozeproj/scripts/validate.sh +8 -0
- package/lib/__templates__/expo/package.json +2 -1
- package/lib/__templates__/nextjs/.coze +1 -0
- package/lib/__templates__/nextjs/package.json +3 -1
- package/lib/__templates__/nextjs/scripts/validate.sh +10 -0
- package/lib/__templates__/nuxt-vue/.coze +1 -0
- package/lib/__templates__/nuxt-vue/eslint.config.mjs +25 -0
- package/lib/__templates__/nuxt-vue/package.json +9 -2
- package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +790 -10
- package/lib/__templates__/nuxt-vue/scripts/validate.sh +10 -0
- package/lib/__templates__/taro/.coze +1 -0
- package/lib/__templates__/taro/.cozeproj/scripts/validate.sh +8 -0
- package/lib/__templates__/taro/package.json +1 -1
- package/lib/__templates__/vite/.coze +1 -0
- package/lib/__templates__/vite/package.json +3 -1
- package/lib/__templates__/vite/scripts/validate.sh +10 -0
- package/lib/cli.js +396 -102
- package/package.json +1 -1
package/lib/cli.js
CHANGED
|
@@ -1628,7 +1628,7 @@ function createNodeTransport() {
|
|
|
1628
1628
|
};
|
|
1629
1629
|
}
|
|
1630
1630
|
|
|
1631
|
-
function _nullishCoalesce$9(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
1631
|
+
function _nullishCoalesce$9(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }/**
|
|
1632
1632
|
* Slardar CLI Reporter 主类
|
|
1633
1633
|
* 封装 @slardar/base 的初始化和上报逻辑
|
|
1634
1634
|
*/
|
|
@@ -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$p([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$p([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$p([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$p([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$p([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$p([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$p([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$p([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$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; }
|
|
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$o([options, 'optionalAccess', _ => _.args]),
|
|
2000
2000
|
status: 'running' ,
|
|
2001
|
-
..._optionalChain$
|
|
2001
|
+
..._optionalChain$o([options, 'optionalAccess', _2 => _2.categories]),
|
|
2002
2002
|
},
|
|
2003
|
-
metrics: _optionalChain$
|
|
2003
|
+
metrics: _optionalChain$o([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$o([options, 'optionalAccess', _4 => _4.args]),
|
|
2025
2025
|
status: success ? ('success' ) : ('fail' ),
|
|
2026
|
-
..._optionalChain$
|
|
2026
|
+
..._optionalChain$o([options, 'optionalAccess', _5 => _5.categories]),
|
|
2027
2027
|
},
|
|
2028
2028
|
metrics: {
|
|
2029
2029
|
duration,
|
|
2030
|
-
...(_optionalChain$
|
|
2030
|
+
...(_optionalChain$o([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$o([options, 'optionalAccess', _7 => _7.method]) || 'GET',
|
|
2052
|
+
statusCode: _optionalChain$o([options, 'optionalAccess', _8 => _8.statusCode, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]),
|
|
2053
|
+
status: _optionalChain$o([options, 'optionalAccess', _11 => _11.success]) ? ('success' ) : ('fail' ),
|
|
2054
2054
|
},
|
|
2055
2055
|
metrics: {
|
|
2056
|
-
duration: _optionalChain$
|
|
2056
|
+
duration: _optionalChain$o([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$o([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
|
|
2079
2079
|
},
|
|
2080
2080
|
metrics: {
|
|
2081
|
-
duration: _optionalChain$
|
|
2082
|
-
fileSize: _optionalChain$
|
|
2081
|
+
duration: _optionalChain$o([options, 'optionalAccess', _14 => _14.duration]),
|
|
2082
|
+
fileSize: _optionalChain$o([options, 'optionalAccess', _15 => _15.fileSize]),
|
|
2083
2083
|
},
|
|
2084
2084
|
};
|
|
2085
2085
|
},
|
|
@@ -2107,7 +2107,7 @@ const EventBuilder = {
|
|
|
2107
2107
|
};
|
|
2108
2108
|
|
|
2109
2109
|
var name = "@coze-arch/cli";
|
|
2110
|
-
var version = "0.0.
|
|
2110
|
+
var version = "0.0.16-alpha.a1c0bb";
|
|
2111
2111
|
var description = "coze coding devtools cli";
|
|
2112
2112
|
var license = "MIT";
|
|
2113
2113
|
var author = "fanwenjie.fe@bytedance.com";
|
|
@@ -2213,7 +2213,7 @@ var packageJson = {
|
|
|
2213
2213
|
cozePublishConfig: cozePublishConfig
|
|
2214
2214
|
};
|
|
2215
2215
|
|
|
2216
|
-
function _optionalChain$
|
|
2216
|
+
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; }/**
|
|
2217
2217
|
* Slardar 监控初始化和上报
|
|
2218
2218
|
*/
|
|
2219
2219
|
|
|
@@ -2316,11 +2316,11 @@ const reportCommandComplete = safeRun(
|
|
|
2316
2316
|
,
|
|
2317
2317
|
) => {
|
|
2318
2318
|
const event = EventBuilder.cliCommandComplete(command, success, duration, {
|
|
2319
|
-
args: _optionalChain$
|
|
2320
|
-
errorCode: _optionalChain$
|
|
2319
|
+
args: _optionalChain$n([options, 'optionalAccess', _ => _.args]),
|
|
2320
|
+
errorCode: _optionalChain$n([options, 'optionalAccess', _2 => _2.errorCode]),
|
|
2321
2321
|
categories: {
|
|
2322
|
-
...(_optionalChain$
|
|
2323
|
-
..._optionalChain$
|
|
2322
|
+
...(_optionalChain$n([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
|
|
2323
|
+
..._optionalChain$n([options, 'optionalAccess', _4 => _4.categories]),
|
|
2324
2324
|
},
|
|
2325
2325
|
});
|
|
2326
2326
|
reporter.sendEvent(event.name, event.metrics, event.categories);
|
|
@@ -2379,7 +2379,7 @@ const flushSlardar = safeRun('flushSlardar', async () => {
|
|
|
2379
2379
|
await reporter.flush();
|
|
2380
2380
|
});
|
|
2381
2381
|
|
|
2382
|
-
function _nullishCoalesce$8(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
2382
|
+
function _nullishCoalesce$8(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$m(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var LogLevel; (function (LogLevel) {
|
|
2383
2383
|
const ERROR = 0; LogLevel[LogLevel["ERROR"] = ERROR] = "ERROR";
|
|
2384
2384
|
const WARN = 1; LogLevel[LogLevel["WARN"] = WARN] = "WARN";
|
|
2385
2385
|
const SUCCESS = 2; LogLevel[LogLevel["SUCCESS"] = SUCCESS] = "SUCCESS";
|
|
@@ -2426,7 +2426,7 @@ class Logger {
|
|
|
2426
2426
|
return level;
|
|
2427
2427
|
}
|
|
2428
2428
|
|
|
2429
|
-
const envLevel = _optionalChain$
|
|
2429
|
+
const envLevel = _optionalChain$m([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
|
|
2430
2430
|
if (envLevel && envLevel in LOG_LEVEL_MAP) {
|
|
2431
2431
|
return LOG_LEVEL_MAP[envLevel];
|
|
2432
2432
|
}
|
|
@@ -2438,7 +2438,7 @@ class Logger {
|
|
|
2438
2438
|
// 简单检测:Node.js 环境且支持 TTY
|
|
2439
2439
|
return (
|
|
2440
2440
|
typeof process !== 'undefined' &&
|
|
2441
|
-
_optionalChain$
|
|
2441
|
+
_optionalChain$m([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
|
|
2442
2442
|
process.env.NO_COLOR === undefined
|
|
2443
2443
|
);
|
|
2444
2444
|
}
|
|
@@ -3277,7 +3277,7 @@ const registerCommand$5 = program => {
|
|
|
3277
3277
|
});
|
|
3278
3278
|
};
|
|
3279
3279
|
|
|
3280
|
-
function _optionalChain$
|
|
3280
|
+
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; }/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3281
3281
|
// Safe JSON parsing utilities with type safety and error handling
|
|
3282
3282
|
// Provides fallback values, validation, and error monitoring capabilities
|
|
3283
3283
|
|
|
@@ -3377,12 +3377,12 @@ function safeJsonParse(
|
|
|
3377
3377
|
const parsed = JSON.parse(String(input));
|
|
3378
3378
|
|
|
3379
3379
|
// Optional validation
|
|
3380
|
-
if (_optionalChain$
|
|
3380
|
+
if (_optionalChain$l([options, 'optionalAccess', _ => _.validate])) {
|
|
3381
3381
|
if (options.validate(parsed)) {
|
|
3382
3382
|
return parsed;
|
|
3383
3383
|
} else {
|
|
3384
3384
|
const validationError = new Error('JSON validation failed');
|
|
3385
|
-
_optionalChain$
|
|
3385
|
+
_optionalChain$l([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
|
|
3386
3386
|
|
|
3387
3387
|
if (options.throwOnValidationError) {
|
|
3388
3388
|
throw validationError;
|
|
@@ -3394,10 +3394,10 @@ function safeJsonParse(
|
|
|
3394
3394
|
return parsed;
|
|
3395
3395
|
} catch (error) {
|
|
3396
3396
|
// Re-throw validation errors when throwOnValidationError is true
|
|
3397
|
-
if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$
|
|
3397
|
+
if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$l([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
|
|
3398
3398
|
throw error;
|
|
3399
3399
|
}
|
|
3400
|
-
_optionalChain$
|
|
3400
|
+
_optionalChain$l([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
|
|
3401
3401
|
return defaultValue;
|
|
3402
3402
|
}
|
|
3403
3403
|
}
|
|
@@ -3437,7 +3437,7 @@ function isNode(node) {
|
|
|
3437
3437
|
}
|
|
3438
3438
|
const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
|
|
3439
3439
|
|
|
3440
|
-
function _optionalChain$
|
|
3440
|
+
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; }
|
|
3441
3441
|
const BREAK = Symbol('break visit');
|
|
3442
3442
|
const SKIP = Symbol('skip children');
|
|
3443
3443
|
const REMOVE = Symbol('remove node');
|
|
@@ -3550,15 +3550,15 @@ function callVisitor(key, node, visitor, path) {
|
|
|
3550
3550
|
if (typeof visitor === 'function')
|
|
3551
3551
|
return visitor(key, node, path);
|
|
3552
3552
|
if (isMap(node))
|
|
3553
|
-
return _optionalChain$
|
|
3553
|
+
return _optionalChain$k([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
|
|
3554
3554
|
if (isSeq(node))
|
|
3555
|
-
return _optionalChain$
|
|
3555
|
+
return _optionalChain$k([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
|
|
3556
3556
|
if (isPair(node))
|
|
3557
|
-
return _optionalChain$
|
|
3557
|
+
return _optionalChain$k([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
|
|
3558
3558
|
if (isScalar(node))
|
|
3559
|
-
return _optionalChain$
|
|
3559
|
+
return _optionalChain$k([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
|
|
3560
3560
|
if (isAlias(node))
|
|
3561
|
-
return _optionalChain$
|
|
3561
|
+
return _optionalChain$k([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
|
|
3562
3562
|
return undefined;
|
|
3563
3563
|
}
|
|
3564
3564
|
function replaceNode(key, path, node) {
|
|
@@ -3649,7 +3649,7 @@ function applyReviver(reviver, obj, key, val) {
|
|
|
3649
3649
|
return reviver.call(obj, key, val);
|
|
3650
3650
|
}
|
|
3651
3651
|
|
|
3652
|
-
function _optionalChain$
|
|
3652
|
+
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; }
|
|
3653
3653
|
/**
|
|
3654
3654
|
* Recursively convert any node or its contents to native JavaScript
|
|
3655
3655
|
*
|
|
@@ -3679,7 +3679,7 @@ function toJS(value, arg, ctx) {
|
|
|
3679
3679
|
ctx.onCreate(res);
|
|
3680
3680
|
return res;
|
|
3681
3681
|
}
|
|
3682
|
-
if (typeof value === 'bigint' && !_optionalChain$
|
|
3682
|
+
if (typeof value === 'bigint' && !_optionalChain$j([ctx, 'optionalAccess', _ => _.keep]))
|
|
3683
3683
|
return Number(value);
|
|
3684
3684
|
return value;
|
|
3685
3685
|
}
|
|
@@ -3717,7 +3717,7 @@ class NodeBase {
|
|
|
3717
3717
|
}
|
|
3718
3718
|
}
|
|
3719
3719
|
|
|
3720
|
-
function _optionalChain$
|
|
3720
|
+
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; }
|
|
3721
3721
|
class Alias extends NodeBase {
|
|
3722
3722
|
constructor(source) {
|
|
3723
3723
|
super(ALIAS);
|
|
@@ -3734,7 +3734,7 @@ class Alias extends NodeBase {
|
|
|
3734
3734
|
*/
|
|
3735
3735
|
resolve(doc, ctx) {
|
|
3736
3736
|
let nodes;
|
|
3737
|
-
if (_optionalChain$
|
|
3737
|
+
if (_optionalChain$i([ctx, 'optionalAccess', _ => _.aliasResolveCache])) {
|
|
3738
3738
|
nodes = ctx.aliasResolveCache;
|
|
3739
3739
|
}
|
|
3740
3740
|
else {
|
|
@@ -3773,7 +3773,7 @@ class Alias extends NodeBase {
|
|
|
3773
3773
|
data = anchors.get(source);
|
|
3774
3774
|
}
|
|
3775
3775
|
/* istanbul ignore if */
|
|
3776
|
-
if (_optionalChain$
|
|
3776
|
+
if (_optionalChain$i([data, 'optionalAccess', _2 => _2.res]) === undefined) {
|
|
3777
3777
|
const msg = 'This should not happen: Alias anchor was not resolved?';
|
|
3778
3778
|
throw new ReferenceError(msg);
|
|
3779
3779
|
}
|
|
@@ -3825,7 +3825,7 @@ function getAliasCount(doc, node, anchors) {
|
|
|
3825
3825
|
return 1;
|
|
3826
3826
|
}
|
|
3827
3827
|
|
|
3828
|
-
function _optionalChain$
|
|
3828
|
+
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; }
|
|
3829
3829
|
const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
|
|
3830
3830
|
class Scalar extends NodeBase {
|
|
3831
3831
|
constructor(value) {
|
|
@@ -3833,7 +3833,7 @@ class Scalar extends NodeBase {
|
|
|
3833
3833
|
this.value = value;
|
|
3834
3834
|
}
|
|
3835
3835
|
toJSON(arg, ctx) {
|
|
3836
|
-
return _optionalChain$
|
|
3836
|
+
return _optionalChain$h([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
|
|
3837
3837
|
}
|
|
3838
3838
|
toString() {
|
|
3839
3839
|
return String(this.value);
|
|
@@ -3845,7 +3845,7 @@ Scalar.PLAIN = 'PLAIN';
|
|
|
3845
3845
|
Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
|
|
3846
3846
|
Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
|
|
3847
3847
|
|
|
3848
|
-
function _nullishCoalesce$7(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
3848
|
+
function _nullishCoalesce$7(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$g(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
3849
3849
|
const defaultTagPrefix = 'tag:yaml.org,2002:';
|
|
3850
3850
|
function findTagObject(value, tagName, tags) {
|
|
3851
3851
|
if (tagName) {
|
|
@@ -3855,7 +3855,7 @@ function findTagObject(value, tagName, tags) {
|
|
|
3855
3855
|
throw new Error(`Tag ${tagName} not found`);
|
|
3856
3856
|
return tagObj;
|
|
3857
3857
|
}
|
|
3858
|
-
return tags.find(t => _optionalChain$
|
|
3858
|
+
return tags.find(t => _optionalChain$g([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
|
|
3859
3859
|
}
|
|
3860
3860
|
function createNode(value, tagName, ctx) {
|
|
3861
3861
|
if (isDocument(value))
|
|
@@ -3863,7 +3863,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3863
3863
|
if (isNode(value))
|
|
3864
3864
|
return value;
|
|
3865
3865
|
if (isPair(value)) {
|
|
3866
|
-
const map = _optionalChain$
|
|
3866
|
+
const map = _optionalChain$g([ctx, 'access', _3 => _3.schema, 'access', _4 => _4[MAP], 'access', _5 => _5.createNode, 'optionalCall', _6 => _6(ctx.schema, null, ctx)]);
|
|
3867
3867
|
map.items.push(value);
|
|
3868
3868
|
return map;
|
|
3869
3869
|
}
|
|
@@ -3890,7 +3890,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3890
3890
|
sourceObjects.set(value, ref);
|
|
3891
3891
|
}
|
|
3892
3892
|
}
|
|
3893
|
-
if (_optionalChain$
|
|
3893
|
+
if (_optionalChain$g([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
|
|
3894
3894
|
tagName = defaultTagPrefix + tagName.slice(2);
|
|
3895
3895
|
let tagObj = findTagObject(value, tagName, schema.tags);
|
|
3896
3896
|
if (!tagObj) {
|
|
@@ -3915,9 +3915,9 @@ function createNode(value, tagName, ctx) {
|
|
|
3915
3915
|
onTagObj(tagObj);
|
|
3916
3916
|
delete ctx.onTagObj;
|
|
3917
3917
|
}
|
|
3918
|
-
const node = _optionalChain$
|
|
3918
|
+
const node = _optionalChain$g([tagObj, 'optionalAccess', _9 => _9.createNode])
|
|
3919
3919
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
3920
|
-
: typeof _optionalChain$
|
|
3920
|
+
: typeof _optionalChain$g([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
|
|
3921
3921
|
? tagObj.nodeClass.from(ctx.schema, value, ctx)
|
|
3922
3922
|
: new Scalar(value);
|
|
3923
3923
|
if (tagName)
|
|
@@ -4235,7 +4235,7 @@ function consumeMoreIndentedLines(text, i, indent) {
|
|
|
4235
4235
|
return end;
|
|
4236
4236
|
}
|
|
4237
4237
|
|
|
4238
|
-
function _optionalChain$
|
|
4238
|
+
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; }
|
|
4239
4239
|
const getFoldOptions = (ctx, isBlock) => ({
|
|
4240
4240
|
indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
|
|
4241
4241
|
lineWidth: ctx.options.lineWidth,
|
|
@@ -4520,9 +4520,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
4520
4520
|
// booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
|
|
4521
4521
|
// and others in v1.1.
|
|
4522
4522
|
if (actualString) {
|
|
4523
|
-
const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$
|
|
4523
|
+
const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$f([tag, 'access', _ => _.test, 'optionalAccess', _2 => _2.test, 'call', _3 => _3(str)]);
|
|
4524
4524
|
const { compat, tags } = ctx.doc.schema;
|
|
4525
|
-
if (tags.some(test) || _optionalChain$
|
|
4525
|
+
if (tags.some(test) || _optionalChain$f([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
|
|
4526
4526
|
return quotedString(value, ctx);
|
|
4527
4527
|
}
|
|
4528
4528
|
return implicitKey
|
|
@@ -4568,7 +4568,7 @@ function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
|
4568
4568
|
return res;
|
|
4569
4569
|
}
|
|
4570
4570
|
|
|
4571
|
-
function _nullishCoalesce$6(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
4571
|
+
function _nullishCoalesce$6(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; }
|
|
4572
4572
|
function createStringifyContext(doc, options) {
|
|
4573
4573
|
const opt = Object.assign({
|
|
4574
4574
|
blockQuote: true,
|
|
@@ -4621,7 +4621,7 @@ function getTagObject(tags, item) {
|
|
|
4621
4621
|
let obj;
|
|
4622
4622
|
if (isScalar(item)) {
|
|
4623
4623
|
obj = item.value;
|
|
4624
|
-
let match = tags.filter(t => _optionalChain$
|
|
4624
|
+
let match = tags.filter(t => _optionalChain$e([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
|
|
4625
4625
|
if (match.length > 1) {
|
|
4626
4626
|
const testMatch = match.filter(t => t.test);
|
|
4627
4627
|
if (testMatch.length > 0)
|
|
@@ -4635,7 +4635,7 @@ function getTagObject(tags, item) {
|
|
|
4635
4635
|
tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
|
|
4636
4636
|
}
|
|
4637
4637
|
if (!tagObj) {
|
|
4638
|
-
const name = _nullishCoalesce$6(_optionalChain$
|
|
4638
|
+
const name = _nullishCoalesce$6(_optionalChain$e([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
|
|
4639
4639
|
throw new Error(`Tag not resolved for ${name} value`);
|
|
4640
4640
|
}
|
|
4641
4641
|
return tagObj;
|
|
@@ -4661,7 +4661,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
|
|
|
4661
4661
|
if (isAlias(item)) {
|
|
4662
4662
|
if (ctx.doc.directives)
|
|
4663
4663
|
return item.toString(ctx);
|
|
4664
|
-
if (_optionalChain$
|
|
4664
|
+
if (_optionalChain$e([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
|
|
4665
4665
|
throw new TypeError(`Cannot stringify circular structure without alias nodes`);
|
|
4666
4666
|
}
|
|
4667
4667
|
else {
|
|
@@ -4843,7 +4843,7 @@ function warn(logLevel, warning) {
|
|
|
4843
4843
|
}
|
|
4844
4844
|
}
|
|
4845
4845
|
|
|
4846
|
-
function _optionalChain$
|
|
4846
|
+
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; }
|
|
4847
4847
|
// If the value associated with a merge key is a single mapping node, each of
|
|
4848
4848
|
// its key/value pairs is inserted into the current mapping, unless the key
|
|
4849
4849
|
// already exists in it. If the value associated with the merge key is a
|
|
@@ -4867,7 +4867,7 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
|
|
|
4867
4867
|
(isScalar(key) &&
|
|
4868
4868
|
(!key.type || key.type === Scalar.PLAIN) &&
|
|
4869
4869
|
merge.identify(key.value))) &&
|
|
4870
|
-
_optionalChain$
|
|
4870
|
+
_optionalChain$d([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)]);
|
|
4871
4871
|
function addMergeToJSMap(ctx, map, value) {
|
|
4872
4872
|
value = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
4873
4873
|
if (isSeq(value))
|
|
@@ -4904,7 +4904,7 @@ function mergeValue(ctx, map, value) {
|
|
|
4904
4904
|
return map;
|
|
4905
4905
|
}
|
|
4906
4906
|
|
|
4907
|
-
function _optionalChain$
|
|
4907
|
+
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; }
|
|
4908
4908
|
function addPairToJSMap(ctx, map, { key, value }) {
|
|
4909
4909
|
if (isNode(key) && key.addToJSMap)
|
|
4910
4910
|
key.addToJSMap(ctx, map, value);
|
|
@@ -4941,7 +4941,7 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
4941
4941
|
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
4942
4942
|
if (typeof jsKey !== 'object')
|
|
4943
4943
|
return String(jsKey);
|
|
4944
|
-
if (isNode(key) && _optionalChain$
|
|
4944
|
+
if (isNode(key) && _optionalChain$c([ctx, 'optionalAccess', _ => _.doc])) {
|
|
4945
4945
|
const strCtx = createStringifyContext(ctx.doc, {});
|
|
4946
4946
|
strCtx.anchors = new Set();
|
|
4947
4947
|
for (const node of ctx.anchors.keys())
|
|
@@ -4961,7 +4961,7 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
4961
4961
|
return JSON.stringify(jsKey);
|
|
4962
4962
|
}
|
|
4963
4963
|
|
|
4964
|
-
function _optionalChain$
|
|
4964
|
+
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; }
|
|
4965
4965
|
function createPair(key, value, ctx) {
|
|
4966
4966
|
const k = createNode(key, undefined, ctx);
|
|
4967
4967
|
const v = createNode(value, undefined, ctx);
|
|
@@ -4982,17 +4982,17 @@ class Pair {
|
|
|
4982
4982
|
return new Pair(key, value);
|
|
4983
4983
|
}
|
|
4984
4984
|
toJSON(_, ctx) {
|
|
4985
|
-
const pair = _optionalChain$
|
|
4985
|
+
const pair = _optionalChain$b([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
|
|
4986
4986
|
return addPairToJSMap(ctx, pair, this);
|
|
4987
4987
|
}
|
|
4988
4988
|
toString(ctx, onComment, onChompKeep) {
|
|
4989
|
-
return _optionalChain$
|
|
4989
|
+
return _optionalChain$b([ctx, 'optionalAccess', _3 => _3.doc])
|
|
4990
4990
|
? stringifyPair(this, ctx, onComment, onChompKeep)
|
|
4991
4991
|
: JSON.stringify(this);
|
|
4992
4992
|
}
|
|
4993
4993
|
}
|
|
4994
4994
|
|
|
4995
|
-
function _nullishCoalesce$4(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
4995
|
+
function _nullishCoalesce$4(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
|
|
4996
4996
|
function stringifyCollection(collection, ctx, options) {
|
|
4997
4997
|
const flow = _nullishCoalesce$4(ctx.inFlow, () => ( collection.flow));
|
|
4998
4998
|
const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
|
|
@@ -5086,7 +5086,7 @@ function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
|
|
|
5086
5086
|
if (iv.commentBefore)
|
|
5087
5087
|
reqNewline = true;
|
|
5088
5088
|
}
|
|
5089
|
-
else if (item.value == null && _optionalChain$
|
|
5089
|
+
else if (item.value == null && _optionalChain$a([ik, 'optionalAccess', _ => _.comment])) {
|
|
5090
5090
|
comment = ik.comment;
|
|
5091
5091
|
}
|
|
5092
5092
|
}
|
|
@@ -5141,7 +5141,7 @@ function addCommentBefore({ indent, options: { commentString } }, lines, comment
|
|
|
5141
5141
|
}
|
|
5142
5142
|
}
|
|
5143
5143
|
|
|
5144
|
-
function _nullishCoalesce$3(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
5144
|
+
function _nullishCoalesce$3(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
|
|
5145
5145
|
function findPair(items, key) {
|
|
5146
5146
|
const k = isScalar(key) ? key.value : key;
|
|
5147
5147
|
for (const it of items) {
|
|
@@ -5202,12 +5202,12 @@ class YAMLMap extends Collection {
|
|
|
5202
5202
|
_pair = pair;
|
|
5203
5203
|
else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
|
|
5204
5204
|
// In TypeScript, this never happens.
|
|
5205
|
-
_pair = new Pair(pair, _optionalChain$
|
|
5205
|
+
_pair = new Pair(pair, _optionalChain$9([pair, 'optionalAccess', _2 => _2.value]));
|
|
5206
5206
|
}
|
|
5207
5207
|
else
|
|
5208
5208
|
_pair = new Pair(pair.key, pair.value);
|
|
5209
5209
|
const prev = findPair(this.items, _pair.key);
|
|
5210
|
-
const sortEntries = _optionalChain$
|
|
5210
|
+
const sortEntries = _optionalChain$9([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
|
|
5211
5211
|
if (prev) {
|
|
5212
5212
|
if (!overwrite)
|
|
5213
5213
|
throw new Error(`Key ${_pair.key} already set`);
|
|
@@ -5237,7 +5237,7 @@ class YAMLMap extends Collection {
|
|
|
5237
5237
|
}
|
|
5238
5238
|
get(key, keepScalar) {
|
|
5239
5239
|
const it = findPair(this.items, key);
|
|
5240
|
-
const node = _optionalChain$
|
|
5240
|
+
const node = _optionalChain$9([it, 'optionalAccess', _5 => _5.value]);
|
|
5241
5241
|
return _nullishCoalesce$3((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
|
|
5242
5242
|
}
|
|
5243
5243
|
has(key) {
|
|
@@ -5252,8 +5252,8 @@ class YAMLMap extends Collection {
|
|
|
5252
5252
|
* @returns Instance of Type, Map, or Object
|
|
5253
5253
|
*/
|
|
5254
5254
|
toJSON(_, ctx, Type) {
|
|
5255
|
-
const map = Type ? new Type() : _optionalChain$
|
|
5256
|
-
if (_optionalChain$
|
|
5255
|
+
const map = Type ? new Type() : _optionalChain$9([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
|
|
5256
|
+
if (_optionalChain$9([ctx, 'optionalAccess', _7 => _7.onCreate]))
|
|
5257
5257
|
ctx.onCreate(map);
|
|
5258
5258
|
for (const item of this.items)
|
|
5259
5259
|
addPairToJSMap(ctx, map, item);
|
|
@@ -5278,7 +5278,7 @@ class YAMLMap extends Collection {
|
|
|
5278
5278
|
}
|
|
5279
5279
|
}
|
|
5280
5280
|
|
|
5281
|
-
function _optionalChain$
|
|
5281
|
+
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; }
|
|
5282
5282
|
class YAMLSeq extends Collection {
|
|
5283
5283
|
static get tagName() {
|
|
5284
5284
|
return 'tag:yaml.org,2002:seq';
|
|
@@ -5341,7 +5341,7 @@ class YAMLSeq extends Collection {
|
|
|
5341
5341
|
}
|
|
5342
5342
|
toJSON(_, ctx) {
|
|
5343
5343
|
const seq = [];
|
|
5344
|
-
if (_optionalChain$
|
|
5344
|
+
if (_optionalChain$8([ctx, 'optionalAccess', _2 => _2.onCreate]))
|
|
5345
5345
|
ctx.onCreate(seq);
|
|
5346
5346
|
let i = 0;
|
|
5347
5347
|
for (const item of this.items)
|
|
@@ -5420,7 +5420,7 @@ function createPairs(schema, iterable, ctx) {
|
|
|
5420
5420
|
return pairs;
|
|
5421
5421
|
}
|
|
5422
5422
|
|
|
5423
|
-
function _optionalChain$
|
|
5423
|
+
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; }
|
|
5424
5424
|
class YAMLOMap extends YAMLSeq {
|
|
5425
5425
|
constructor() {
|
|
5426
5426
|
super();
|
|
@@ -5439,7 +5439,7 @@ class YAMLOMap extends YAMLSeq {
|
|
|
5439
5439
|
if (!ctx)
|
|
5440
5440
|
return super.toJSON(_);
|
|
5441
5441
|
const map = new Map();
|
|
5442
|
-
if (_optionalChain$
|
|
5442
|
+
if (_optionalChain$7([ctx, 'optionalAccess', _2 => _2.onCreate]))
|
|
5443
5443
|
ctx.onCreate(map);
|
|
5444
5444
|
for (const pair of this.items) {
|
|
5445
5445
|
let key, value;
|
|
@@ -5557,7 +5557,7 @@ const isDirExists = async (file) => {
|
|
|
5557
5557
|
}
|
|
5558
5558
|
};
|
|
5559
5559
|
|
|
5560
|
-
function _optionalChain$
|
|
5560
|
+
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; }// ABOUTME: Project type detection utility
|
|
5561
5561
|
|
|
5562
5562
|
/**
|
|
5563
5563
|
* 支持的项目类型枚举
|
|
@@ -5659,7 +5659,7 @@ const collectProjectInfo = async (
|
|
|
5659
5659
|
}
|
|
5660
5660
|
|
|
5661
5661
|
const scripts = Object.entries(
|
|
5662
|
-
(_optionalChain$
|
|
5662
|
+
(_optionalChain$6([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
|
|
5663
5663
|
).reduce((acc, [name, script]) => {
|
|
5664
5664
|
if (typeof script === 'string') {
|
|
5665
5665
|
acc[name] = script;
|
|
@@ -5813,7 +5813,7 @@ const detectProjectType = async (
|
|
|
5813
5813
|
};
|
|
5814
5814
|
};
|
|
5815
5815
|
|
|
5816
|
-
function _optionalChain$
|
|
5816
|
+
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; }
|
|
5817
5817
|
|
|
5818
5818
|
|
|
5819
5819
|
/**
|
|
@@ -5985,16 +5985,18 @@ const getCommandConfig = (
|
|
|
5985
5985
|
) => {
|
|
5986
5986
|
let commandConfig;
|
|
5987
5987
|
|
|
5988
|
-
// 根据命令名称映射到配置路径
|
|
5989
5988
|
switch (commandName) {
|
|
5990
5989
|
case 'dev':
|
|
5991
|
-
commandConfig = _optionalChain$
|
|
5990
|
+
commandConfig = _optionalChain$5([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
|
|
5992
5991
|
break;
|
|
5993
5992
|
case 'build':
|
|
5994
|
-
commandConfig = _optionalChain$
|
|
5993
|
+
commandConfig = _optionalChain$5([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
|
|
5995
5994
|
break;
|
|
5996
5995
|
case 'start':
|
|
5997
|
-
commandConfig = _optionalChain$
|
|
5996
|
+
commandConfig = _optionalChain$5([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
|
|
5997
|
+
break;
|
|
5998
|
+
case 'validate':
|
|
5999
|
+
commandConfig = _optionalChain$5([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
|
|
5998
6000
|
break;
|
|
5999
6001
|
default:
|
|
6000
6002
|
throw new Error(`Unknown command: ${commandName}`);
|
|
@@ -6145,9 +6147,9 @@ const byFlag = (flag) => {
|
|
|
6145
6147
|
return predicate;
|
|
6146
6148
|
};
|
|
6147
6149
|
|
|
6148
|
-
function _optionalChain$
|
|
6150
|
+
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; }
|
|
6149
6151
|
const PATCH_ID$2 = 'taro/update-pack-script-for-tt-build@0.0.13';
|
|
6150
|
-
const PACKAGE_JSON_FILE = 'package.json';
|
|
6152
|
+
const PACKAGE_JSON_FILE$1 = 'package.json';
|
|
6151
6153
|
const PACK_SCRIPT_FILE = '.cozeproj/scripts/pack.sh';
|
|
6152
6154
|
const LEGACY_PACK_SCRIPT_HASHES = new Set([
|
|
6153
6155
|
'987575c08e1c32ce7bc553e1668b3ad8faad5623343fd0d21fea34d39f25a56d',
|
|
@@ -6216,7 +6218,7 @@ const hashContent = (content) =>
|
|
|
6216
6218
|
const readPackageScripts = async (
|
|
6217
6219
|
projectFolder,
|
|
6218
6220
|
) => {
|
|
6219
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE);
|
|
6221
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$1);
|
|
6220
6222
|
if (!(await isFileExists(packageJsonPath))) {
|
|
6221
6223
|
return null;
|
|
6222
6224
|
}
|
|
@@ -6224,12 +6226,12 @@ const readPackageScripts = async (
|
|
|
6224
6226
|
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6225
6227
|
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
6226
6228
|
|
|
6227
|
-
return _optionalChain$
|
|
6229
|
+
return _optionalChain$4([packageJson, 'optionalAccess', _ => _.scripts]) || null;
|
|
6228
6230
|
};
|
|
6229
6231
|
|
|
6230
6232
|
const hasBuildTtScript = async (projectFolder) => {
|
|
6231
6233
|
const scripts = await readPackageScripts(projectFolder);
|
|
6232
|
-
return typeof _optionalChain$
|
|
6234
|
+
return typeof _optionalChain$4([scripts, 'optionalAccess', _2 => _2['build:tt']]) === 'string';
|
|
6233
6235
|
};
|
|
6234
6236
|
|
|
6235
6237
|
const hasLegacyPackScript = async (projectFolder) => {
|
|
@@ -6564,6 +6566,256 @@ const patchNextOutputTracingRoot = {
|
|
|
6564
6566
|
},
|
|
6565
6567
|
};
|
|
6566
6568
|
|
|
6569
|
+
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; }
|
|
6570
|
+
|
|
6571
|
+
|
|
6572
|
+
const COZE_FILE = '.coze';
|
|
6573
|
+
const PACKAGE_JSON_FILE = 'package.json';
|
|
6574
|
+
|
|
6575
|
+
const VALIDATE_RELATED_SCRIPTS = {
|
|
6576
|
+
nextjs: ['validate', 'ts-check', 'lint:build'],
|
|
6577
|
+
vite: ['validate', 'ts-check', 'lint:build'],
|
|
6578
|
+
'nuxt-vue': ['validate', 'ts-check', 'lint:build'],
|
|
6579
|
+
taro: ['validate', 'lint:build', 'tsc'],
|
|
6580
|
+
expo: ['validate', 'lint:client', 'lint:server'],
|
|
6581
|
+
};
|
|
6582
|
+
|
|
6583
|
+
|
|
6584
|
+
|
|
6585
|
+
|
|
6586
|
+
|
|
6587
|
+
const FG_KEY_MAP = {
|
|
6588
|
+
nextjs: 'coding.arch.patch_nextjs_validate',
|
|
6589
|
+
vite: 'coding.arch.patch_vite_validate',
|
|
6590
|
+
'nuxt-vue': 'coding.arch.patch_nuxt_vue_validate',
|
|
6591
|
+
taro: 'coding.arch.patch_taro_validate',
|
|
6592
|
+
expo: 'coding.arch.patch_expo_validate',
|
|
6593
|
+
};
|
|
6594
|
+
|
|
6595
|
+
const VALIDATE_SCRIPT_MAP = {
|
|
6596
|
+
nextjs: 'scripts/validate.sh',
|
|
6597
|
+
vite: 'scripts/validate.sh',
|
|
6598
|
+
'nuxt-vue': 'scripts/validate.sh',
|
|
6599
|
+
taro: '.cozeproj/scripts/validate.sh',
|
|
6600
|
+
expo: '.cozeproj/scripts/validate.sh',
|
|
6601
|
+
};
|
|
6602
|
+
|
|
6603
|
+
const hasValidateInCoze = (context) =>
|
|
6604
|
+
_optionalChain$3([context, 'access', _ => _.cozeConfig, 'optionalAccess', _2 => _2.dev, 'optionalAccess', _3 => _3.validate]) !== undefined;
|
|
6605
|
+
|
|
6606
|
+
const getTemplateScripts = async (
|
|
6607
|
+
template,
|
|
6608
|
+
) => {
|
|
6609
|
+
const templatePackageJsonPath = path.join(
|
|
6610
|
+
getTemplatesDir(),
|
|
6611
|
+
template,
|
|
6612
|
+
PACKAGE_JSON_FILE,
|
|
6613
|
+
);
|
|
6614
|
+
const content = await fs$1.readFile(templatePackageJsonPath, 'utf-8');
|
|
6615
|
+
const templatePackageJson = safeJsonParse(content, null);
|
|
6616
|
+
if (!_optionalChain$3([templatePackageJson, 'optionalAccess', _4 => _4.scripts])) {
|
|
6617
|
+
return {};
|
|
6618
|
+
}
|
|
6619
|
+
|
|
6620
|
+
const relatedKeys = VALIDATE_RELATED_SCRIPTS[template];
|
|
6621
|
+
const result = {};
|
|
6622
|
+
for (const key of relatedKeys) {
|
|
6623
|
+
if (templatePackageJson.scripts[key] !== undefined) {
|
|
6624
|
+
result[key] = templatePackageJson.scripts[key];
|
|
6625
|
+
}
|
|
6626
|
+
}
|
|
6627
|
+
return result;
|
|
6628
|
+
};
|
|
6629
|
+
|
|
6630
|
+
const getMissingScripts = (
|
|
6631
|
+
scripts,
|
|
6632
|
+
templateScripts,
|
|
6633
|
+
) => {
|
|
6634
|
+
const missing = {};
|
|
6635
|
+
for (const [key, value] of Object.entries(templateScripts)) {
|
|
6636
|
+
if (!scripts || scripts[key] === undefined) {
|
|
6637
|
+
missing[key] = value;
|
|
6638
|
+
}
|
|
6639
|
+
}
|
|
6640
|
+
return missing;
|
|
6641
|
+
};
|
|
6642
|
+
|
|
6643
|
+
const addValidateToCoze = async (
|
|
6644
|
+
projectFolder,
|
|
6645
|
+
validateScriptPath,
|
|
6646
|
+
) => {
|
|
6647
|
+
const cozePath = path.join(projectFolder, COZE_FILE);
|
|
6648
|
+
const content = await fs$1.readFile(cozePath, 'utf-8');
|
|
6649
|
+
|
|
6650
|
+
const validateLine = `validate = ["bash", "${validateScriptPath}"]`;
|
|
6651
|
+
|
|
6652
|
+
const lines = content.split('\n');
|
|
6653
|
+
let devStart = -1;
|
|
6654
|
+
let devEnd = -1;
|
|
6655
|
+
|
|
6656
|
+
for (let i = 0; i < lines.length; i++) {
|
|
6657
|
+
if (lines[i].trim() === '[dev]') {
|
|
6658
|
+
devStart = i;
|
|
6659
|
+
} else if (devStart !== -1 && lines[i].startsWith('[')) {
|
|
6660
|
+
devEnd = i;
|
|
6661
|
+
break;
|
|
6662
|
+
}
|
|
6663
|
+
}
|
|
6664
|
+
|
|
6665
|
+
if (devStart === -1) {
|
|
6666
|
+
return false;
|
|
6667
|
+
}
|
|
6668
|
+
|
|
6669
|
+
if (devEnd === -1) {
|
|
6670
|
+
devEnd = lines.length;
|
|
6671
|
+
}
|
|
6672
|
+
|
|
6673
|
+
lines.splice(devEnd, 0, validateLine);
|
|
6674
|
+
await fs$1.writeFile(cozePath, lines.join('\n'), 'utf-8');
|
|
6675
|
+
return true;
|
|
6676
|
+
};
|
|
6677
|
+
|
|
6678
|
+
const createValidateScript = async (
|
|
6679
|
+
projectFolder,
|
|
6680
|
+
template,
|
|
6681
|
+
validateScriptFile,
|
|
6682
|
+
) => {
|
|
6683
|
+
const targetPath = path.join(projectFolder, validateScriptFile);
|
|
6684
|
+
if (await isFileExists(targetPath)) {
|
|
6685
|
+
return false;
|
|
6686
|
+
}
|
|
6687
|
+
|
|
6688
|
+
const scriptsDir = path.join(projectFolder, validateScriptFile.split('/').slice(0, -1).join('/'));
|
|
6689
|
+
if (!(await isFileExists(scriptsDir))) {
|
|
6690
|
+
await fs$1.mkdir(scriptsDir, { recursive: true });
|
|
6691
|
+
}
|
|
6692
|
+
|
|
6693
|
+
const templateScriptPath = path.join(
|
|
6694
|
+
getTemplatesDir(),
|
|
6695
|
+
template,
|
|
6696
|
+
validateScriptFile,
|
|
6697
|
+
);
|
|
6698
|
+
const templateContent = await fs$1.readFile(templateScriptPath, 'utf-8');
|
|
6699
|
+
await fs$1.writeFile(targetPath, templateContent, 'utf-8');
|
|
6700
|
+
return true;
|
|
6701
|
+
};
|
|
6702
|
+
|
|
6703
|
+
const addMissingScriptsToPackageJson = async (
|
|
6704
|
+
projectFolder,
|
|
6705
|
+
template,
|
|
6706
|
+
) => {
|
|
6707
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE);
|
|
6708
|
+
if (!(await isFileExists(packageJsonPath))) {
|
|
6709
|
+
return false;
|
|
6710
|
+
}
|
|
6711
|
+
|
|
6712
|
+
const content = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6713
|
+
const packageJson = safeJsonParse(content, null);
|
|
6714
|
+
if (!packageJson) {
|
|
6715
|
+
return false;
|
|
6716
|
+
}
|
|
6717
|
+
|
|
6718
|
+
const templateScripts = await getTemplateScripts(template);
|
|
6719
|
+
const missingScripts = getMissingScripts(packageJson.scripts, templateScripts);
|
|
6720
|
+
if (Object.keys(missingScripts).length === 0) {
|
|
6721
|
+
return false;
|
|
6722
|
+
}
|
|
6723
|
+
|
|
6724
|
+
packageJson.scripts = { ...packageJson.scripts, ...missingScripts };
|
|
6725
|
+
await fs$1.writeFile(
|
|
6726
|
+
packageJsonPath,
|
|
6727
|
+
JSON.stringify(packageJson, null, 2),
|
|
6728
|
+
'utf-8',
|
|
6729
|
+
);
|
|
6730
|
+
return true;
|
|
6731
|
+
};
|
|
6732
|
+
|
|
6733
|
+
const createAddValidatePatch = (template) => {
|
|
6734
|
+
const patchId = `${template}/add-validate@0.0.1`;
|
|
6735
|
+
const validateScriptFile = VALIDATE_SCRIPT_MAP[template];
|
|
6736
|
+
const validateScriptPath = template === 'taro' || template === 'expo'
|
|
6737
|
+
? validateScriptFile
|
|
6738
|
+
: `./${validateScriptFile}`;
|
|
6739
|
+
|
|
6740
|
+
return {
|
|
6741
|
+
id: patchId,
|
|
6742
|
+
template,
|
|
6743
|
+
disabled: byFlag(FG_KEY_MAP[template]),
|
|
6744
|
+
operations: [
|
|
6745
|
+
{
|
|
6746
|
+
kind: 'file-patch',
|
|
6747
|
+
file: COZE_FILE,
|
|
6748
|
+
description: '在 [dev] 下添加 validate 命令',
|
|
6749
|
+
},
|
|
6750
|
+
{
|
|
6751
|
+
kind: 'create-file',
|
|
6752
|
+
file: validateScriptFile,
|
|
6753
|
+
description: '创建 validate 脚本',
|
|
6754
|
+
},
|
|
6755
|
+
{
|
|
6756
|
+
kind: 'file-patch',
|
|
6757
|
+
file: PACKAGE_JSON_FILE,
|
|
6758
|
+
description: '补齐 validate/ts-check/lint:build 脚本',
|
|
6759
|
+
},
|
|
6760
|
+
],
|
|
6761
|
+
shouldApply: context => !hasValidateInCoze(context),
|
|
6762
|
+
apply: async (context) => {
|
|
6763
|
+
const cozeUpdated = await addValidateToCoze(
|
|
6764
|
+
context.projectFolder,
|
|
6765
|
+
validateScriptPath,
|
|
6766
|
+
);
|
|
6767
|
+
if (!cozeUpdated) {
|
|
6768
|
+
return {
|
|
6769
|
+
applied: false,
|
|
6770
|
+
patchId,
|
|
6771
|
+
message:
|
|
6772
|
+
'Failed to add validate to .coze ([dev] section not found), skipping',
|
|
6773
|
+
};
|
|
6774
|
+
}
|
|
6775
|
+
if (context.cozeConfig) {
|
|
6776
|
+
context.cozeConfig.dev = {
|
|
6777
|
+
...context.cozeConfig.dev,
|
|
6778
|
+
validate: ['bash', validateScriptPath],
|
|
6779
|
+
};
|
|
6780
|
+
}
|
|
6781
|
+
logger.info('Patched .coze: added validate command');
|
|
6782
|
+
|
|
6783
|
+
const scriptCreated = await createValidateScript(
|
|
6784
|
+
context.projectFolder,
|
|
6785
|
+
template,
|
|
6786
|
+
validateScriptFile,
|
|
6787
|
+
);
|
|
6788
|
+
if (scriptCreated) {
|
|
6789
|
+
logger.info(`Created ${validateScriptFile}`);
|
|
6790
|
+
} else {
|
|
6791
|
+
logger.info(`${validateScriptFile} already exists, skipping`);
|
|
6792
|
+
}
|
|
6793
|
+
|
|
6794
|
+
const scriptsUpdated = await addMissingScriptsToPackageJson(
|
|
6795
|
+
context.projectFolder,
|
|
6796
|
+
template,
|
|
6797
|
+
);
|
|
6798
|
+
if (scriptsUpdated) {
|
|
6799
|
+
logger.info('Patched package.json: added missing scripts');
|
|
6800
|
+
} else {
|
|
6801
|
+
logger.info('package.json scripts already complete, skipping');
|
|
6802
|
+
}
|
|
6803
|
+
|
|
6804
|
+
return {
|
|
6805
|
+
applied: true,
|
|
6806
|
+
patchId,
|
|
6807
|
+
message: `Added validate support to ${template} project`,
|
|
6808
|
+
};
|
|
6809
|
+
},
|
|
6810
|
+
};
|
|
6811
|
+
};
|
|
6812
|
+
|
|
6813
|
+
const patchNextjsAddValidate = createAddValidatePatch('nextjs');
|
|
6814
|
+
const patchViteAddValidate = createAddValidatePatch('vite');
|
|
6815
|
+
const patchNuxtVueAddValidate = createAddValidatePatch('nuxt-vue');
|
|
6816
|
+
const patchTaroAddValidate = createAddValidatePatch('taro');
|
|
6817
|
+
const patchExpoAddValidate = createAddValidatePatch('expo');
|
|
6818
|
+
|
|
6567
6819
|
const patches = [
|
|
6568
6820
|
replaceNpxWithPnpmPatchNextjs,
|
|
6569
6821
|
replaceNpxWithPnpmPatchVite,
|
|
@@ -6571,6 +6823,11 @@ const patches = [
|
|
|
6571
6823
|
patchNextOutputTracingRoot,
|
|
6572
6824
|
patchTaroAgentsMd,
|
|
6573
6825
|
patchTaroPackScript,
|
|
6826
|
+
patchNextjsAddValidate,
|
|
6827
|
+
patchViteAddValidate,
|
|
6828
|
+
patchNuxtVueAddValidate,
|
|
6829
|
+
patchTaroAddValidate,
|
|
6830
|
+
patchExpoAddValidate,
|
|
6574
6831
|
] ;
|
|
6575
6832
|
|
|
6576
6833
|
const getTemplatePatches = (
|
|
@@ -7100,6 +7357,15 @@ const registerCommand$3 = program => {
|
|
|
7100
7357
|
.action(async options => {
|
|
7101
7358
|
await executeRun('start', options);
|
|
7102
7359
|
});
|
|
7360
|
+
|
|
7361
|
+
// validate 命令
|
|
7362
|
+
program
|
|
7363
|
+
.command('validate')
|
|
7364
|
+
.description('Validate project (lint + type check)')
|
|
7365
|
+
.option('--log-file <path>', 'Log file path')
|
|
7366
|
+
.action(async options => {
|
|
7367
|
+
await executeRun('validate', options);
|
|
7368
|
+
});
|
|
7103
7369
|
};
|
|
7104
7370
|
|
|
7105
7371
|
// ABOUTME: Nuxt route scanner
|
|
@@ -7997,8 +8263,18 @@ const registerCommand$2 = program => {
|
|
|
7997
8263
|
});
|
|
7998
8264
|
};
|
|
7999
8265
|
|
|
8266
|
+
const d = debug('coze-init-cli:check-bins');
|
|
8267
|
+
|
|
8268
|
+
|
|
8269
|
+
|
|
8270
|
+
|
|
8271
|
+
|
|
8272
|
+
|
|
8273
|
+
|
|
8000
8274
|
const checkBins = async (cwd, fix) => {
|
|
8001
|
-
|
|
8275
|
+
d('starting check, cwd=%s fix=%s', cwd, fix);
|
|
8276
|
+
|
|
8277
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- fallback {} ensures non-null
|
|
8002
8278
|
const pkgJson = safeJsonParse
|
|
8003
8279
|
|
|
8004
8280
|
|
|
@@ -8009,7 +8285,10 @@ const checkBins = async (cwd, fix) => {
|
|
|
8009
8285
|
...pkgJson.devDependencies,
|
|
8010
8286
|
});
|
|
8011
8287
|
|
|
8288
|
+
d('found %d total dependencies to scan', allDeps.length);
|
|
8289
|
+
|
|
8012
8290
|
const binDir = path.join(cwd, 'node_modules', '.bin');
|
|
8291
|
+
d('bin directory: %s', binDir);
|
|
8013
8292
|
const missing = [];
|
|
8014
8293
|
|
|
8015
8294
|
await Promise.all(
|
|
@@ -8020,13 +8299,16 @@ const checkBins = async (cwd, fix) => {
|
|
|
8020
8299
|
path.join(cwd, 'node_modules', depName, 'package.json'),
|
|
8021
8300
|
'utf8',
|
|
8022
8301
|
);
|
|
8023
|
-
} catch (
|
|
8302
|
+
} catch (err) {
|
|
8303
|
+
d('dep %s not found in node_modules: %s', depName, err);
|
|
8304
|
+
missing.push({ dep: depName, bin: '', reason: 'missing-package' });
|
|
8024
8305
|
return;
|
|
8025
8306
|
}
|
|
8026
8307
|
const depPkg = safeJsonParse(
|
|
8027
8308
|
rawContent,
|
|
8028
8309
|
);
|
|
8029
8310
|
if (!depPkg) {
|
|
8311
|
+
d('skipping %s: failed to parse package.json', depName);
|
|
8030
8312
|
return;
|
|
8031
8313
|
}
|
|
8032
8314
|
|
|
@@ -8036,22 +8318,28 @@ const checkBins = async (cwd, fix) => {
|
|
|
8036
8318
|
|
|
8037
8319
|
const bins =
|
|
8038
8320
|
typeof depPkg.bin === 'string'
|
|
8039
|
-
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
8321
|
+
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- split always has ≥1 element
|
|
8040
8322
|
{ [depName.split('/').pop()]: depPkg.bin }
|
|
8041
8323
|
: depPkg.bin;
|
|
8042
8324
|
|
|
8325
|
+
d('%s declares bins: %o', depName, Object.keys(bins));
|
|
8326
|
+
|
|
8043
8327
|
await Promise.all(
|
|
8044
8328
|
Object.keys(bins).map(async binName => {
|
|
8045
8329
|
try {
|
|
8046
8330
|
await fs$1.access(path.join(binDir, binName));
|
|
8047
|
-
|
|
8048
|
-
|
|
8331
|
+
d('bin present: %s', binName);
|
|
8332
|
+
} catch (err) {
|
|
8333
|
+
d('bin missing: %s (from %s): %s', binName, depName, err);
|
|
8334
|
+
missing.push({ dep: depName, bin: binName, reason: 'missing-bin' });
|
|
8049
8335
|
}
|
|
8050
8336
|
}),
|
|
8051
8337
|
);
|
|
8052
8338
|
}),
|
|
8053
8339
|
);
|
|
8054
8340
|
|
|
8341
|
+
d('scan complete, missing=%d', missing.length);
|
|
8342
|
+
|
|
8055
8343
|
if (missing.length === 0) {
|
|
8056
8344
|
logger.success(
|
|
8057
8345
|
'check-bins: all bin entries present, skipping force install.',
|
|
@@ -8059,9 +8347,13 @@ const checkBins = async (cwd, fix) => {
|
|
|
8059
8347
|
return;
|
|
8060
8348
|
}
|
|
8061
8349
|
|
|
8062
|
-
logger.warn('check-bins: missing
|
|
8063
|
-
for (const { dep, bin } of missing) {
|
|
8064
|
-
|
|
8350
|
+
logger.warn('check-bins: missing or broken dependencies detected:');
|
|
8351
|
+
for (const { dep, bin, reason } of missing) {
|
|
8352
|
+
if (reason === 'missing-package') {
|
|
8353
|
+
logger.warn(` ${dep} -> (package not found in node_modules)`);
|
|
8354
|
+
} else {
|
|
8355
|
+
logger.warn(` ${dep} -> .bin/${bin}`);
|
|
8356
|
+
}
|
|
8065
8357
|
}
|
|
8066
8358
|
|
|
8067
8359
|
if (!fix) {
|
|
@@ -8072,7 +8364,9 @@ const checkBins = async (cwd, fix) => {
|
|
|
8072
8364
|
}
|
|
8073
8365
|
|
|
8074
8366
|
logger.info('check-bins: running pnpm i --force to fix...');
|
|
8367
|
+
d('executing: pnpm i --force');
|
|
8075
8368
|
child_process.execSync('pnpm i --force', { stdio: 'inherit', cwd });
|
|
8369
|
+
d('pnpm i --force completed');
|
|
8076
8370
|
};
|
|
8077
8371
|
|
|
8078
8372
|
const registerCommand$1 = program => {
|