@coze-arch/cli 0.0.15-alpha.511af9 → 0.0.15-alpha.763911
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/cli.js +359 -152
- 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$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; }/**
|
|
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$q([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$q([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$q([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$q([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$q([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$q([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$q([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$q([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$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; }
|
|
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$p([options, 'optionalAccess', _ => _.args]),
|
|
2000
2000
|
status: 'running' ,
|
|
2001
|
-
..._optionalChain$
|
|
2001
|
+
..._optionalChain$p([options, 'optionalAccess', _2 => _2.categories]),
|
|
2002
2002
|
},
|
|
2003
|
-
metrics: _optionalChain$
|
|
2003
|
+
metrics: _optionalChain$p([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$p([options, 'optionalAccess', _4 => _4.args]),
|
|
2025
2025
|
status: success ? ('success' ) : ('fail' ),
|
|
2026
|
-
..._optionalChain$
|
|
2026
|
+
..._optionalChain$p([options, 'optionalAccess', _5 => _5.categories]),
|
|
2027
2027
|
},
|
|
2028
2028
|
metrics: {
|
|
2029
2029
|
duration,
|
|
2030
|
-
...(_optionalChain$
|
|
2030
|
+
...(_optionalChain$p([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$p([options, 'optionalAccess', _7 => _7.method]) || 'GET',
|
|
2052
|
+
statusCode: _optionalChain$p([options, 'optionalAccess', _8 => _8.statusCode, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]),
|
|
2053
|
+
status: _optionalChain$p([options, 'optionalAccess', _11 => _11.success]) ? ('success' ) : ('fail' ),
|
|
2054
2054
|
},
|
|
2055
2055
|
metrics: {
|
|
2056
|
-
duration: _optionalChain$
|
|
2056
|
+
duration: _optionalChain$p([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$p([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
|
|
2079
2079
|
},
|
|
2080
2080
|
metrics: {
|
|
2081
|
-
duration: _optionalChain$
|
|
2082
|
-
fileSize: _optionalChain$
|
|
2081
|
+
duration: _optionalChain$p([options, 'optionalAccess', _14 => _14.duration]),
|
|
2082
|
+
fileSize: _optionalChain$p([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.15-alpha.
|
|
2110
|
+
var version = "0.0.15-alpha.763911";
|
|
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$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; }/**
|
|
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$o([options, 'optionalAccess', _ => _.args]),
|
|
2320
|
+
errorCode: _optionalChain$o([options, 'optionalAccess', _2 => _2.errorCode]),
|
|
2321
2321
|
categories: {
|
|
2322
|
-
...(_optionalChain$
|
|
2323
|
-
..._optionalChain$
|
|
2322
|
+
...(_optionalChain$o([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
|
|
2323
|
+
..._optionalChain$o([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$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; }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$n([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$n([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$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; }/* 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$m([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$m([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$m([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
|
|
3398
3398
|
throw error;
|
|
3399
3399
|
}
|
|
3400
|
-
_optionalChain$
|
|
3400
|
+
_optionalChain$m([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$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; }
|
|
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$l([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
|
|
3554
3554
|
if (isSeq(node))
|
|
3555
|
-
return _optionalChain$
|
|
3555
|
+
return _optionalChain$l([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
|
|
3556
3556
|
if (isPair(node))
|
|
3557
|
-
return _optionalChain$
|
|
3557
|
+
return _optionalChain$l([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
|
|
3558
3558
|
if (isScalar(node))
|
|
3559
|
-
return _optionalChain$
|
|
3559
|
+
return _optionalChain$l([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
|
|
3560
3560
|
if (isAlias(node))
|
|
3561
|
-
return _optionalChain$
|
|
3561
|
+
return _optionalChain$l([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$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; }
|
|
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$k([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$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; }
|
|
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$j([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$j([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$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; }
|
|
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$i([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$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; }
|
|
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$h([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$h([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$h([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$h([tagObj, 'optionalAccess', _9 => _9.createNode])
|
|
3919
3919
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
3920
|
-
: typeof _optionalChain$
|
|
3920
|
+
: typeof _optionalChain$h([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$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; }
|
|
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$g([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$g([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$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; }
|
|
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$f([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$f([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$f([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$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; }
|
|
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$e([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$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; }
|
|
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$d([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$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; }
|
|
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$c([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$c([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$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; }
|
|
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$b([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$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; }
|
|
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$a([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$a([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$a([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$a([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
|
|
5256
|
+
if (_optionalChain$a([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$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; }
|
|
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$9([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$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; }
|
|
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$8([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$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; }// 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$7([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$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; }
|
|
5817
5817
|
|
|
5818
5818
|
|
|
5819
5819
|
/**
|
|
@@ -5987,16 +5987,16 @@ const getCommandConfig = (
|
|
|
5987
5987
|
|
|
5988
5988
|
switch (commandName) {
|
|
5989
5989
|
case 'dev':
|
|
5990
|
-
commandConfig = _optionalChain$
|
|
5990
|
+
commandConfig = _optionalChain$6([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
|
|
5991
5991
|
break;
|
|
5992
5992
|
case 'build':
|
|
5993
|
-
commandConfig = _optionalChain$
|
|
5993
|
+
commandConfig = _optionalChain$6([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
|
|
5994
5994
|
break;
|
|
5995
5995
|
case 'start':
|
|
5996
|
-
commandConfig = _optionalChain$
|
|
5996
|
+
commandConfig = _optionalChain$6([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
|
|
5997
5997
|
break;
|
|
5998
5998
|
case 'validate':
|
|
5999
|
-
commandConfig = _optionalChain$
|
|
5999
|
+
commandConfig = _optionalChain$6([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
|
|
6000
6000
|
break;
|
|
6001
6001
|
default:
|
|
6002
6002
|
throw new Error(`Unknown command: ${commandName}`);
|
|
@@ -6147,15 +6147,15 @@ const byFlag = (flag) => {
|
|
|
6147
6147
|
return predicate;
|
|
6148
6148
|
};
|
|
6149
6149
|
|
|
6150
|
-
function _optionalChain$
|
|
6151
|
-
const PATCH_ID$
|
|
6152
|
-
const COZE_FILE = '.coze';
|
|
6153
|
-
const VALIDATE_SCRIPT_FILE = 'scripts/validate.sh';
|
|
6154
|
-
const PACKAGE_JSON_FILE$
|
|
6150
|
+
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; }
|
|
6151
|
+
const PATCH_ID$4 = 'vite/add-validate@0.0.14';
|
|
6152
|
+
const COZE_FILE$1 = '.coze';
|
|
6153
|
+
const VALIDATE_SCRIPT_FILE$1 = 'scripts/validate.sh';
|
|
6154
|
+
const PACKAGE_JSON_FILE$2 = 'package.json';
|
|
6155
6155
|
|
|
6156
|
-
const VALIDATE_LINE = 'validate = ["bash", "./scripts/validate.sh"]';
|
|
6156
|
+
const VALIDATE_LINE$1 = 'validate = ["bash", "./scripts/validate.sh"]';
|
|
6157
6157
|
|
|
6158
|
-
const REQUIRED_SCRIPTS = {
|
|
6158
|
+
const REQUIRED_SCRIPTS$1 = {
|
|
6159
6159
|
'ts-check': 'tsc -p tsconfig.json',
|
|
6160
6160
|
'lint:build': 'eslint . --quiet',
|
|
6161
6161
|
validate: "pnpm run --parallel '/^(ts-check|lint:build)$/'",
|
|
@@ -6165,23 +6165,23 @@ const REQUIRED_SCRIPTS = {
|
|
|
6165
6165
|
|
|
6166
6166
|
|
|
6167
6167
|
|
|
6168
|
-
const getTemplateValidateScriptPath = () =>
|
|
6168
|
+
const getTemplateValidateScriptPath$1 = () =>
|
|
6169
6169
|
path.join(getTemplatesDir(), 'vite', 'scripts', 'validate.sh');
|
|
6170
6170
|
|
|
6171
|
-
const getProjectValidateScriptPath = (projectFolder) =>
|
|
6172
|
-
path.join(projectFolder, VALIDATE_SCRIPT_FILE);
|
|
6171
|
+
const getProjectValidateScriptPath$1 = (projectFolder) =>
|
|
6172
|
+
path.join(projectFolder, VALIDATE_SCRIPT_FILE$1);
|
|
6173
6173
|
|
|
6174
|
-
const readTemplateValidateScriptContent = async () =>
|
|
6175
|
-
fs$1.readFile(getTemplateValidateScriptPath(), 'utf-8');
|
|
6174
|
+
const readTemplateValidateScriptContent$1 = async () =>
|
|
6175
|
+
fs$1.readFile(getTemplateValidateScriptPath$1(), 'utf-8');
|
|
6176
6176
|
|
|
6177
|
-
const hasValidateInCoze = (context) =>
|
|
6178
|
-
_optionalChain$
|
|
6177
|
+
const hasValidateInCoze$1 = (context) =>
|
|
6178
|
+
_optionalChain$5([context, 'access', _ => _.cozeConfig, 'optionalAccess', _2 => _2.dev, 'optionalAccess', _3 => _3.validate]) !== undefined;
|
|
6179
6179
|
|
|
6180
|
-
const getMissingScripts = (
|
|
6180
|
+
const getMissingScripts$1 = (
|
|
6181
6181
|
scripts,
|
|
6182
6182
|
) => {
|
|
6183
6183
|
const missing = {};
|
|
6184
|
-
for (const [key, value] of Object.entries(REQUIRED_SCRIPTS)) {
|
|
6184
|
+
for (const [key, value] of Object.entries(REQUIRED_SCRIPTS$1)) {
|
|
6185
6185
|
if (!scripts || scripts[key] === undefined) {
|
|
6186
6186
|
missing[key] = value;
|
|
6187
6187
|
}
|
|
@@ -6189,30 +6189,40 @@ const getMissingScripts = (
|
|
|
6189
6189
|
return missing;
|
|
6190
6190
|
};
|
|
6191
6191
|
|
|
6192
|
-
const addValidateToCoze = async (projectFolder) => {
|
|
6193
|
-
const cozePath = path.join(projectFolder, COZE_FILE);
|
|
6192
|
+
const addValidateToCoze$1 = async (projectFolder) => {
|
|
6193
|
+
const cozePath = path.join(projectFolder, COZE_FILE$1);
|
|
6194
6194
|
const content = await fs$1.readFile(cozePath, 'utf-8');
|
|
6195
6195
|
|
|
6196
|
-
const
|
|
6197
|
-
|
|
6198
|
-
|
|
6196
|
+
const lines = content.split('\n');
|
|
6197
|
+
let devStart = -1;
|
|
6198
|
+
let devEnd = -1;
|
|
6199
|
+
|
|
6200
|
+
for (let i = 0; i < lines.length; i++) {
|
|
6201
|
+
if (lines[i].trim() === '[dev]') {
|
|
6202
|
+
devStart = i;
|
|
6203
|
+
} else if (devStart !== -1 && lines[i].startsWith('[')) {
|
|
6204
|
+
devEnd = i;
|
|
6205
|
+
break;
|
|
6206
|
+
}
|
|
6207
|
+
}
|
|
6208
|
+
|
|
6209
|
+
if (devStart === -1) {
|
|
6199
6210
|
return false;
|
|
6200
6211
|
}
|
|
6201
6212
|
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
`${runLine}\n${VALIDATE_LINE}`,
|
|
6206
|
-
);
|
|
6213
|
+
if (devEnd === -1) {
|
|
6214
|
+
devEnd = lines.length;
|
|
6215
|
+
}
|
|
6207
6216
|
|
|
6208
|
-
|
|
6217
|
+
lines.splice(devEnd, 0, VALIDATE_LINE$1);
|
|
6218
|
+
await fs$1.writeFile(cozePath, lines.join('\n'), 'utf-8');
|
|
6209
6219
|
return true;
|
|
6210
6220
|
};
|
|
6211
6221
|
|
|
6212
|
-
const createValidateScript = async (
|
|
6222
|
+
const createValidateScript$1 = async (
|
|
6213
6223
|
projectFolder,
|
|
6214
6224
|
) => {
|
|
6215
|
-
const targetPath = getProjectValidateScriptPath(projectFolder);
|
|
6225
|
+
const targetPath = getProjectValidateScriptPath$1(projectFolder);
|
|
6216
6226
|
if (await isFileExists(targetPath)) {
|
|
6217
6227
|
return false;
|
|
6218
6228
|
}
|
|
@@ -6222,15 +6232,15 @@ const createValidateScript = async (
|
|
|
6222
6232
|
await fs$1.mkdir(scriptsDir, { recursive: true });
|
|
6223
6233
|
}
|
|
6224
6234
|
|
|
6225
|
-
const templateContent = await readTemplateValidateScriptContent();
|
|
6235
|
+
const templateContent = await readTemplateValidateScriptContent$1();
|
|
6226
6236
|
await fs$1.writeFile(targetPath, templateContent, 'utf-8');
|
|
6227
6237
|
return true;
|
|
6228
6238
|
};
|
|
6229
6239
|
|
|
6230
|
-
const addMissingScriptsToPackageJson = async (
|
|
6240
|
+
const addMissingScriptsToPackageJson$1 = async (
|
|
6231
6241
|
projectFolder,
|
|
6232
6242
|
) => {
|
|
6233
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$
|
|
6243
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$2);
|
|
6234
6244
|
if (!(await isFileExists(packageJsonPath))) {
|
|
6235
6245
|
return false;
|
|
6236
6246
|
}
|
|
@@ -6241,7 +6251,7 @@ const addMissingScriptsToPackageJson = async (
|
|
|
6241
6251
|
return false;
|
|
6242
6252
|
}
|
|
6243
6253
|
|
|
6244
|
-
const missingScripts = getMissingScripts(packageJson.scripts);
|
|
6254
|
+
const missingScripts = getMissingScripts$1(packageJson.scripts);
|
|
6245
6255
|
if (Object.keys(missingScripts).length === 0) {
|
|
6246
6256
|
return false;
|
|
6247
6257
|
}
|
|
@@ -6256,64 +6266,64 @@ const addMissingScriptsToPackageJson = async (
|
|
|
6256
6266
|
};
|
|
6257
6267
|
|
|
6258
6268
|
const patchViteAddValidate = {
|
|
6259
|
-
id: PATCH_ID$
|
|
6269
|
+
id: PATCH_ID$4,
|
|
6260
6270
|
template: 'vite',
|
|
6261
6271
|
disabled: byFlag('coding.arch.patch_vite_validate'),
|
|
6262
6272
|
operations: [
|
|
6263
6273
|
{
|
|
6264
6274
|
kind: 'file-patch',
|
|
6265
|
-
file: COZE_FILE,
|
|
6275
|
+
file: COZE_FILE$1,
|
|
6266
6276
|
description: '在 [dev] 下添加 validate 命令',
|
|
6267
6277
|
},
|
|
6268
6278
|
{
|
|
6269
6279
|
kind: 'create-file',
|
|
6270
|
-
file: VALIDATE_SCRIPT_FILE,
|
|
6280
|
+
file: VALIDATE_SCRIPT_FILE$1,
|
|
6271
6281
|
description: '创建 validate 脚本',
|
|
6272
6282
|
},
|
|
6273
6283
|
{
|
|
6274
6284
|
kind: 'file-patch',
|
|
6275
|
-
file: PACKAGE_JSON_FILE$
|
|
6285
|
+
file: PACKAGE_JSON_FILE$2,
|
|
6276
6286
|
description: '补齐 validate/ts-check/lint:build 脚本',
|
|
6277
6287
|
},
|
|
6278
6288
|
],
|
|
6279
6289
|
shouldApply: context =>
|
|
6280
|
-
context.template === 'vite' && !hasValidateInCoze(context),
|
|
6290
|
+
context.template === 'vite' && !hasValidateInCoze$1(context),
|
|
6281
6291
|
apply: async (context) => {
|
|
6282
6292
|
if (context.template !== 'vite') {
|
|
6283
6293
|
return {
|
|
6284
6294
|
applied: false,
|
|
6285
|
-
patchId: PATCH_ID$
|
|
6295
|
+
patchId: PATCH_ID$4,
|
|
6286
6296
|
message: 'Only applies to vite projects, skipping',
|
|
6287
6297
|
};
|
|
6288
6298
|
}
|
|
6289
6299
|
|
|
6290
|
-
if (hasValidateInCoze(context)) {
|
|
6300
|
+
if (hasValidateInCoze$1(context)) {
|
|
6291
6301
|
return {
|
|
6292
6302
|
applied: false,
|
|
6293
|
-
patchId: PATCH_ID$
|
|
6303
|
+
patchId: PATCH_ID$4,
|
|
6294
6304
|
message: '.coze already has validate config, skipping',
|
|
6295
6305
|
};
|
|
6296
6306
|
}
|
|
6297
6307
|
|
|
6298
|
-
const cozeUpdated = await addValidateToCoze(context.projectFolder);
|
|
6308
|
+
const cozeUpdated = await addValidateToCoze$1(context.projectFolder);
|
|
6299
6309
|
if (!cozeUpdated) {
|
|
6300
6310
|
return {
|
|
6301
6311
|
applied: false,
|
|
6302
|
-
patchId: PATCH_ID$
|
|
6312
|
+
patchId: PATCH_ID$4,
|
|
6303
6313
|
message:
|
|
6304
|
-
'Failed to add validate to .coze (
|
|
6314
|
+
'Failed to add validate to .coze ([dev] section not found), skipping',
|
|
6305
6315
|
};
|
|
6306
6316
|
}
|
|
6307
6317
|
logger.info('Patched .coze: added validate command');
|
|
6308
6318
|
|
|
6309
|
-
const scriptCreated = await createValidateScript(context.projectFolder);
|
|
6319
|
+
const scriptCreated = await createValidateScript$1(context.projectFolder);
|
|
6310
6320
|
if (scriptCreated) {
|
|
6311
6321
|
logger.info('Created scripts/validate.sh');
|
|
6312
6322
|
} else {
|
|
6313
6323
|
logger.info('scripts/validate.sh already exists, skipping');
|
|
6314
6324
|
}
|
|
6315
6325
|
|
|
6316
|
-
const scriptsUpdated = await addMissingScriptsToPackageJson(
|
|
6326
|
+
const scriptsUpdated = await addMissingScriptsToPackageJson$1(
|
|
6317
6327
|
context.projectFolder,
|
|
6318
6328
|
);
|
|
6319
6329
|
if (scriptsUpdated) {
|
|
@@ -6324,15 +6334,15 @@ const patchViteAddValidate = {
|
|
|
6324
6334
|
|
|
6325
6335
|
return {
|
|
6326
6336
|
applied: true,
|
|
6327
|
-
patchId: PATCH_ID$
|
|
6337
|
+
patchId: PATCH_ID$4,
|
|
6328
6338
|
message: 'Added validate support to vite project',
|
|
6329
6339
|
};
|
|
6330
6340
|
},
|
|
6331
6341
|
};
|
|
6332
6342
|
|
|
6333
|
-
function _optionalChain$
|
|
6334
|
-
const PATCH_ID$
|
|
6335
|
-
const PACKAGE_JSON_FILE = 'package.json';
|
|
6343
|
+
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; }
|
|
6344
|
+
const PATCH_ID$3 = 'taro/update-pack-script-for-tt-build@0.0.13';
|
|
6345
|
+
const PACKAGE_JSON_FILE$1 = 'package.json';
|
|
6336
6346
|
const PACK_SCRIPT_FILE = '.cozeproj/scripts/pack.sh';
|
|
6337
6347
|
const LEGACY_PACK_SCRIPT_HASHES = new Set([
|
|
6338
6348
|
'987575c08e1c32ce7bc553e1668b3ad8faad5623343fd0d21fea34d39f25a56d',
|
|
@@ -6401,7 +6411,7 @@ const hashContent = (content) =>
|
|
|
6401
6411
|
const readPackageScripts = async (
|
|
6402
6412
|
projectFolder,
|
|
6403
6413
|
) => {
|
|
6404
|
-
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE);
|
|
6414
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$1);
|
|
6405
6415
|
if (!(await isFileExists(packageJsonPath))) {
|
|
6406
6416
|
return null;
|
|
6407
6417
|
}
|
|
@@ -6409,12 +6419,12 @@ const readPackageScripts = async (
|
|
|
6409
6419
|
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6410
6420
|
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
6411
6421
|
|
|
6412
|
-
return _optionalChain$
|
|
6422
|
+
return _optionalChain$4([packageJson, 'optionalAccess', _ => _.scripts]) || null;
|
|
6413
6423
|
};
|
|
6414
6424
|
|
|
6415
6425
|
const hasBuildTtScript = async (projectFolder) => {
|
|
6416
6426
|
const scripts = await readPackageScripts(projectFolder);
|
|
6417
|
-
return typeof _optionalChain$
|
|
6427
|
+
return typeof _optionalChain$4([scripts, 'optionalAccess', _2 => _2['build:tt']]) === 'string';
|
|
6418
6428
|
};
|
|
6419
6429
|
|
|
6420
6430
|
const hasLegacyPackScript = async (projectFolder) => {
|
|
@@ -6428,7 +6438,7 @@ const hasLegacyPackScript = async (projectFolder) => {
|
|
|
6428
6438
|
};
|
|
6429
6439
|
|
|
6430
6440
|
const patchTaroPackScript = {
|
|
6431
|
-
id: PATCH_ID$
|
|
6441
|
+
id: PATCH_ID$3,
|
|
6432
6442
|
template: 'taro',
|
|
6433
6443
|
disabled: byFlag('coding.arch.patch_taro_update_pack_script_for_tt_build'),
|
|
6434
6444
|
operations: [
|
|
@@ -6447,7 +6457,7 @@ const patchTaroPackScript = {
|
|
|
6447
6457
|
if (context.template !== 'taro') {
|
|
6448
6458
|
return {
|
|
6449
6459
|
applied: false,
|
|
6450
|
-
patchId: PATCH_ID$
|
|
6460
|
+
patchId: PATCH_ID$3,
|
|
6451
6461
|
message: 'Only applies to taro projects, skipping',
|
|
6452
6462
|
};
|
|
6453
6463
|
}
|
|
@@ -6455,7 +6465,7 @@ const patchTaroPackScript = {
|
|
|
6455
6465
|
if (!(await hasBuildTtScript(context.projectFolder))) {
|
|
6456
6466
|
return {
|
|
6457
6467
|
applied: false,
|
|
6458
|
-
patchId: PATCH_ID$
|
|
6468
|
+
patchId: PATCH_ID$3,
|
|
6459
6469
|
message: 'package.json does not contain build:tt, skipping',
|
|
6460
6470
|
};
|
|
6461
6471
|
}
|
|
@@ -6463,7 +6473,7 @@ const patchTaroPackScript = {
|
|
|
6463
6473
|
if (!(await hasLegacyPackScript(context.projectFolder))) {
|
|
6464
6474
|
return {
|
|
6465
6475
|
applied: false,
|
|
6466
|
-
patchId: PATCH_ID$
|
|
6476
|
+
patchId: PATCH_ID$3,
|
|
6467
6477
|
message: 'pack.sh does not match legacy template hash, skipping',
|
|
6468
6478
|
};
|
|
6469
6479
|
}
|
|
@@ -6477,13 +6487,13 @@ const patchTaroPackScript = {
|
|
|
6477
6487
|
|
|
6478
6488
|
return {
|
|
6479
6489
|
applied: true,
|
|
6480
|
-
patchId: PATCH_ID$
|
|
6490
|
+
patchId: PATCH_ID$3,
|
|
6481
6491
|
message: 'Updated legacy pack.sh to build weapp and tt targets',
|
|
6482
6492
|
};
|
|
6483
6493
|
},
|
|
6484
6494
|
};
|
|
6485
6495
|
|
|
6486
|
-
const PATCH_ID$
|
|
6496
|
+
const PATCH_ID$2 = 'taro/add-agents-md@0.0.13';
|
|
6487
6497
|
const AGENTS_FILE = 'AGENTS.md';
|
|
6488
6498
|
const getTemplateAgentsPath = () =>
|
|
6489
6499
|
path.join(getTemplatesDir(), 'taro', AGENTS_FILE);
|
|
@@ -6495,7 +6505,7 @@ const readTemplateAgentsContent = async () =>
|
|
|
6495
6505
|
fs$1.readFile(getTemplateAgentsPath(), 'utf-8');
|
|
6496
6506
|
|
|
6497
6507
|
const patchTaroAgentsMd = {
|
|
6498
|
-
id: PATCH_ID$
|
|
6508
|
+
id: PATCH_ID$2,
|
|
6499
6509
|
template: 'taro',
|
|
6500
6510
|
disabled: byFlag('coding.arch.patch_taro_add_agents_md'),
|
|
6501
6511
|
operations: [
|
|
@@ -6513,7 +6523,7 @@ const patchTaroAgentsMd = {
|
|
|
6513
6523
|
if (context.template !== 'taro') {
|
|
6514
6524
|
return {
|
|
6515
6525
|
applied: false,
|
|
6516
|
-
patchId: PATCH_ID$
|
|
6526
|
+
patchId: PATCH_ID$2,
|
|
6517
6527
|
message: 'Only applies to taro projects, skipping',
|
|
6518
6528
|
};
|
|
6519
6529
|
}
|
|
@@ -6522,7 +6532,7 @@ const patchTaroAgentsMd = {
|
|
|
6522
6532
|
if (await isFileExists(targetPath)) {
|
|
6523
6533
|
return {
|
|
6524
6534
|
applied: false,
|
|
6525
|
-
patchId: PATCH_ID$
|
|
6535
|
+
patchId: PATCH_ID$2,
|
|
6526
6536
|
message: 'AGENTS.md already exists, skipping',
|
|
6527
6537
|
};
|
|
6528
6538
|
}
|
|
@@ -6532,7 +6542,7 @@ const patchTaroAgentsMd = {
|
|
|
6532
6542
|
|
|
6533
6543
|
return {
|
|
6534
6544
|
applied: true,
|
|
6535
|
-
patchId: PATCH_ID$
|
|
6545
|
+
patchId: PATCH_ID$2,
|
|
6536
6546
|
message: 'Created AGENTS.md from taro template',
|
|
6537
6547
|
};
|
|
6538
6548
|
},
|
|
@@ -6645,6 +6655,202 @@ const replaceNpxWithPnpmPatchVite =
|
|
|
6645
6655
|
const replaceNpxWithPnpmPatchNuxtVue =
|
|
6646
6656
|
createReplaceNpxWithPnpmPatch('nuxt-vue');
|
|
6647
6657
|
|
|
6658
|
+
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; }
|
|
6659
|
+
const PATCH_ID$1 = 'nextjs/add-validate@0.0.14';
|
|
6660
|
+
const COZE_FILE = '.coze';
|
|
6661
|
+
const VALIDATE_SCRIPT_FILE = 'scripts/validate.sh';
|
|
6662
|
+
const PACKAGE_JSON_FILE = 'package.json';
|
|
6663
|
+
|
|
6664
|
+
const VALIDATE_LINE = 'validate = ["bash", "./scripts/validate.sh"]';
|
|
6665
|
+
|
|
6666
|
+
const REQUIRED_SCRIPTS = {
|
|
6667
|
+
'ts-check': 'tsc -p tsconfig.json',
|
|
6668
|
+
'lint:build': 'eslint . --quiet',
|
|
6669
|
+
validate: "pnpm run --parallel '/^(ts-check|lint:build)$/'",
|
|
6670
|
+
};
|
|
6671
|
+
|
|
6672
|
+
|
|
6673
|
+
|
|
6674
|
+
|
|
6675
|
+
|
|
6676
|
+
const getTemplateValidateScriptPath = () =>
|
|
6677
|
+
path.join(getTemplatesDir(), 'nextjs', 'scripts', 'validate.sh');
|
|
6678
|
+
|
|
6679
|
+
const getProjectValidateScriptPath = (projectFolder) =>
|
|
6680
|
+
path.join(projectFolder, VALIDATE_SCRIPT_FILE);
|
|
6681
|
+
|
|
6682
|
+
const readTemplateValidateScriptContent = async () =>
|
|
6683
|
+
fs$1.readFile(getTemplateValidateScriptPath(), 'utf-8');
|
|
6684
|
+
|
|
6685
|
+
const hasValidateInCoze = (context) =>
|
|
6686
|
+
_optionalChain$3([context, 'access', _ => _.cozeConfig, 'optionalAccess', _2 => _2.dev, 'optionalAccess', _3 => _3.validate]) !== undefined;
|
|
6687
|
+
|
|
6688
|
+
const getMissingScripts = (
|
|
6689
|
+
scripts,
|
|
6690
|
+
) => {
|
|
6691
|
+
const missing = {};
|
|
6692
|
+
for (const [key, value] of Object.entries(REQUIRED_SCRIPTS)) {
|
|
6693
|
+
if (!scripts || scripts[key] === undefined) {
|
|
6694
|
+
missing[key] = value;
|
|
6695
|
+
}
|
|
6696
|
+
}
|
|
6697
|
+
return missing;
|
|
6698
|
+
};
|
|
6699
|
+
|
|
6700
|
+
const addValidateToCoze = async (projectFolder) => {
|
|
6701
|
+
const cozePath = path.join(projectFolder, COZE_FILE);
|
|
6702
|
+
const content = await fs$1.readFile(cozePath, 'utf-8');
|
|
6703
|
+
|
|
6704
|
+
const lines = content.split('\n');
|
|
6705
|
+
let devStart = -1;
|
|
6706
|
+
let devEnd = -1;
|
|
6707
|
+
|
|
6708
|
+
for (let i = 0; i < lines.length; i++) {
|
|
6709
|
+
if (lines[i].trim() === '[dev]') {
|
|
6710
|
+
devStart = i;
|
|
6711
|
+
} else if (devStart !== -1 && lines[i].startsWith('[')) {
|
|
6712
|
+
devEnd = i;
|
|
6713
|
+
break;
|
|
6714
|
+
}
|
|
6715
|
+
}
|
|
6716
|
+
|
|
6717
|
+
if (devStart === -1) {
|
|
6718
|
+
return false;
|
|
6719
|
+
}
|
|
6720
|
+
|
|
6721
|
+
if (devEnd === -1) {
|
|
6722
|
+
devEnd = lines.length;
|
|
6723
|
+
}
|
|
6724
|
+
|
|
6725
|
+
lines.splice(devEnd, 0, VALIDATE_LINE);
|
|
6726
|
+
await fs$1.writeFile(cozePath, lines.join('\n'), 'utf-8');
|
|
6727
|
+
return true;
|
|
6728
|
+
};
|
|
6729
|
+
|
|
6730
|
+
const createValidateScript = async (
|
|
6731
|
+
projectFolder,
|
|
6732
|
+
) => {
|
|
6733
|
+
const targetPath = getProjectValidateScriptPath(projectFolder);
|
|
6734
|
+
if (await isFileExists(targetPath)) {
|
|
6735
|
+
return false;
|
|
6736
|
+
}
|
|
6737
|
+
|
|
6738
|
+
const scriptsDir = path.join(projectFolder, 'scripts');
|
|
6739
|
+
if (!(await isFileExists(scriptsDir))) {
|
|
6740
|
+
await fs$1.mkdir(scriptsDir, { recursive: true });
|
|
6741
|
+
}
|
|
6742
|
+
|
|
6743
|
+
const templateContent = await readTemplateValidateScriptContent();
|
|
6744
|
+
await fs$1.writeFile(targetPath, templateContent, 'utf-8');
|
|
6745
|
+
return true;
|
|
6746
|
+
};
|
|
6747
|
+
|
|
6748
|
+
const addMissingScriptsToPackageJson = async (
|
|
6749
|
+
projectFolder,
|
|
6750
|
+
) => {
|
|
6751
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE);
|
|
6752
|
+
if (!(await isFileExists(packageJsonPath))) {
|
|
6753
|
+
return false;
|
|
6754
|
+
}
|
|
6755
|
+
|
|
6756
|
+
const content = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6757
|
+
const packageJson = safeJsonParse(content, null);
|
|
6758
|
+
if (!packageJson) {
|
|
6759
|
+
return false;
|
|
6760
|
+
}
|
|
6761
|
+
|
|
6762
|
+
const missingScripts = getMissingScripts(packageJson.scripts);
|
|
6763
|
+
if (Object.keys(missingScripts).length === 0) {
|
|
6764
|
+
return false;
|
|
6765
|
+
}
|
|
6766
|
+
|
|
6767
|
+
packageJson.scripts = { ...packageJson.scripts, ...missingScripts };
|
|
6768
|
+
await fs$1.writeFile(
|
|
6769
|
+
packageJsonPath,
|
|
6770
|
+
JSON.stringify(packageJson, null, 2),
|
|
6771
|
+
'utf-8',
|
|
6772
|
+
);
|
|
6773
|
+
return true;
|
|
6774
|
+
};
|
|
6775
|
+
|
|
6776
|
+
const patchNextjsAddValidate = {
|
|
6777
|
+
id: PATCH_ID$1,
|
|
6778
|
+
template: 'nextjs',
|
|
6779
|
+
disabled: byFlag('coding.arch.patch_nextjs_validate'),
|
|
6780
|
+
operations: [
|
|
6781
|
+
{
|
|
6782
|
+
kind: 'file-patch',
|
|
6783
|
+
file: COZE_FILE,
|
|
6784
|
+
description: '在 [dev] 下添加 validate 命令',
|
|
6785
|
+
},
|
|
6786
|
+
{
|
|
6787
|
+
kind: 'create-file',
|
|
6788
|
+
file: VALIDATE_SCRIPT_FILE,
|
|
6789
|
+
description: '创建 validate 脚本',
|
|
6790
|
+
},
|
|
6791
|
+
{
|
|
6792
|
+
kind: 'file-patch',
|
|
6793
|
+
file: PACKAGE_JSON_FILE,
|
|
6794
|
+
description: '补齐 validate/ts-check/lint:build 脚本',
|
|
6795
|
+
},
|
|
6796
|
+
],
|
|
6797
|
+
shouldApply: context => {
|
|
6798
|
+
console.log('<<<< shouldApply', context.template);
|
|
6799
|
+
console.log('<<<< shouldApply', hasValidateInCoze(context));
|
|
6800
|
+
return context.template === 'nextjs' && !hasValidateInCoze(context);
|
|
6801
|
+
},
|
|
6802
|
+
apply: async (context) => {
|
|
6803
|
+
if (context.template !== 'nextjs') {
|
|
6804
|
+
return {
|
|
6805
|
+
applied: false,
|
|
6806
|
+
patchId: PATCH_ID$1,
|
|
6807
|
+
message: 'Only applies to nextjs projects, skipping',
|
|
6808
|
+
};
|
|
6809
|
+
}
|
|
6810
|
+
|
|
6811
|
+
if (hasValidateInCoze(context)) {
|
|
6812
|
+
return {
|
|
6813
|
+
applied: false,
|
|
6814
|
+
patchId: PATCH_ID$1,
|
|
6815
|
+
message: '.coze already has validate config, skipping',
|
|
6816
|
+
};
|
|
6817
|
+
}
|
|
6818
|
+
|
|
6819
|
+
const cozeUpdated = await addValidateToCoze(context.projectFolder);
|
|
6820
|
+
if (!cozeUpdated) {
|
|
6821
|
+
return {
|
|
6822
|
+
applied: false,
|
|
6823
|
+
patchId: PATCH_ID$1,
|
|
6824
|
+
message:
|
|
6825
|
+
'Failed to add validate to .coze ([dev] section not found), skipping',
|
|
6826
|
+
};
|
|
6827
|
+
}
|
|
6828
|
+
logger.info('Patched .coze: added validate command');
|
|
6829
|
+
|
|
6830
|
+
const scriptCreated = await createValidateScript(context.projectFolder);
|
|
6831
|
+
if (scriptCreated) {
|
|
6832
|
+
logger.info('Created scripts/validate.sh');
|
|
6833
|
+
} else {
|
|
6834
|
+
logger.info('scripts/validate.sh already exists, skipping');
|
|
6835
|
+
}
|
|
6836
|
+
|
|
6837
|
+
const scriptsUpdated = await addMissingScriptsToPackageJson(
|
|
6838
|
+
context.projectFolder,
|
|
6839
|
+
);
|
|
6840
|
+
if (scriptsUpdated) {
|
|
6841
|
+
logger.info('Patched package.json: added missing scripts');
|
|
6842
|
+
} else {
|
|
6843
|
+
logger.info('package.json scripts already complete, skipping');
|
|
6844
|
+
}
|
|
6845
|
+
|
|
6846
|
+
return {
|
|
6847
|
+
applied: true,
|
|
6848
|
+
patchId: PATCH_ID$1,
|
|
6849
|
+
message: 'Added validate support to nextjs project',
|
|
6850
|
+
};
|
|
6851
|
+
},
|
|
6852
|
+
};
|
|
6853
|
+
|
|
6648
6854
|
const findNextConfigFile = async (
|
|
6649
6855
|
projectFolder,
|
|
6650
6856
|
) => {
|
|
@@ -6757,6 +6963,7 @@ const patches = [
|
|
|
6757
6963
|
patchTaroAgentsMd,
|
|
6758
6964
|
patchTaroPackScript,
|
|
6759
6965
|
patchViteAddValidate,
|
|
6966
|
+
patchNextjsAddValidate,
|
|
6760
6967
|
] ;
|
|
6761
6968
|
|
|
6762
6969
|
const getTemplatePatches = (
|