@coze-arch/cli 0.0.15-alpha.0f8aee → 0.0.15-alpha.73e572
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 +344 -89
- 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.15-alpha.
|
|
2110
|
+
var version = "0.0.15-alpha.73e572";
|
|
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
|
/**
|
|
@@ -5987,16 +5987,16 @@ const getCommandConfig = (
|
|
|
5987
5987
|
|
|
5988
5988
|
switch (commandName) {
|
|
5989
5989
|
case 'dev':
|
|
5990
|
-
commandConfig = _optionalChain$
|
|
5990
|
+
commandConfig = _optionalChain$5([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
|
|
5991
5991
|
break;
|
|
5992
5992
|
case 'build':
|
|
5993
|
-
commandConfig = _optionalChain$
|
|
5993
|
+
commandConfig = _optionalChain$5([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
|
|
5994
5994
|
break;
|
|
5995
5995
|
case 'start':
|
|
5996
|
-
commandConfig = _optionalChain$
|
|
5996
|
+
commandConfig = _optionalChain$5([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
|
|
5997
5997
|
break;
|
|
5998
5998
|
case 'validate':
|
|
5999
|
-
commandConfig = _optionalChain$
|
|
5999
|
+
commandConfig = _optionalChain$5([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
|
|
6000
6000
|
break;
|
|
6001
6001
|
default:
|
|
6002
6002
|
throw new Error(`Unknown command: ${commandName}`);
|
|
@@ -6147,6 +6147,256 @@ const byFlag = (flag) => {
|
|
|
6147
6147
|
return predicate;
|
|
6148
6148
|
};
|
|
6149
6149
|
|
|
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; }
|
|
6151
|
+
|
|
6152
|
+
|
|
6153
|
+
const COZE_FILE = '.coze';
|
|
6154
|
+
const PACKAGE_JSON_FILE$1 = 'package.json';
|
|
6155
|
+
|
|
6156
|
+
const VALIDATE_RELATED_SCRIPTS = {
|
|
6157
|
+
nextjs: ['validate', 'ts-check', 'lint:build'],
|
|
6158
|
+
vite: ['validate', 'ts-check', 'lint:build'],
|
|
6159
|
+
'nuxt-vue': ['validate', 'ts-check', 'lint:build'],
|
|
6160
|
+
taro: ['validate', 'lint:build', 'tsc'],
|
|
6161
|
+
expo: ['validate', 'lint:client', 'lint:server'],
|
|
6162
|
+
};
|
|
6163
|
+
|
|
6164
|
+
|
|
6165
|
+
|
|
6166
|
+
|
|
6167
|
+
|
|
6168
|
+
const FG_KEY_MAP = {
|
|
6169
|
+
nextjs: 'coding.arch.patch_nextjs_validate',
|
|
6170
|
+
vite: 'coding.arch.patch_vite_validate',
|
|
6171
|
+
'nuxt-vue': 'coding.arch.patch_nuxt_vue_validate',
|
|
6172
|
+
taro: 'coding.arch.patch_taro_validate',
|
|
6173
|
+
expo: 'coding.arch.patch_expo_validate',
|
|
6174
|
+
};
|
|
6175
|
+
|
|
6176
|
+
const VALIDATE_SCRIPT_MAP = {
|
|
6177
|
+
nextjs: 'scripts/validate.sh',
|
|
6178
|
+
vite: 'scripts/validate.sh',
|
|
6179
|
+
'nuxt-vue': 'scripts/validate.sh',
|
|
6180
|
+
taro: '.cozeproj/scripts/validate.sh',
|
|
6181
|
+
expo: '.cozeproj/scripts/validate.sh',
|
|
6182
|
+
};
|
|
6183
|
+
|
|
6184
|
+
const hasValidateInCoze = (context) =>
|
|
6185
|
+
_optionalChain$4([context, 'access', _ => _.cozeConfig, 'optionalAccess', _2 => _2.dev, 'optionalAccess', _3 => _3.validate]) !== undefined;
|
|
6186
|
+
|
|
6187
|
+
const getTemplateScripts = async (
|
|
6188
|
+
template,
|
|
6189
|
+
) => {
|
|
6190
|
+
const templatePackageJsonPath = path.join(
|
|
6191
|
+
getTemplatesDir(),
|
|
6192
|
+
template,
|
|
6193
|
+
PACKAGE_JSON_FILE$1,
|
|
6194
|
+
);
|
|
6195
|
+
const content = await fs$1.readFile(templatePackageJsonPath, 'utf-8');
|
|
6196
|
+
const templatePackageJson = safeJsonParse(content, null);
|
|
6197
|
+
if (!_optionalChain$4([templatePackageJson, 'optionalAccess', _4 => _4.scripts])) {
|
|
6198
|
+
return {};
|
|
6199
|
+
}
|
|
6200
|
+
|
|
6201
|
+
const relatedKeys = VALIDATE_RELATED_SCRIPTS[template];
|
|
6202
|
+
const result = {};
|
|
6203
|
+
for (const key of relatedKeys) {
|
|
6204
|
+
if (templatePackageJson.scripts[key] !== undefined) {
|
|
6205
|
+
result[key] = templatePackageJson.scripts[key];
|
|
6206
|
+
}
|
|
6207
|
+
}
|
|
6208
|
+
return result;
|
|
6209
|
+
};
|
|
6210
|
+
|
|
6211
|
+
const getMissingScripts = (
|
|
6212
|
+
scripts,
|
|
6213
|
+
templateScripts,
|
|
6214
|
+
) => {
|
|
6215
|
+
const missing = {};
|
|
6216
|
+
for (const [key, value] of Object.entries(templateScripts)) {
|
|
6217
|
+
if (!scripts || scripts[key] === undefined) {
|
|
6218
|
+
missing[key] = value;
|
|
6219
|
+
}
|
|
6220
|
+
}
|
|
6221
|
+
return missing;
|
|
6222
|
+
};
|
|
6223
|
+
|
|
6224
|
+
const addValidateToCoze = async (
|
|
6225
|
+
projectFolder,
|
|
6226
|
+
validateScriptPath,
|
|
6227
|
+
) => {
|
|
6228
|
+
const cozePath = path.join(projectFolder, COZE_FILE);
|
|
6229
|
+
const content = await fs$1.readFile(cozePath, 'utf-8');
|
|
6230
|
+
|
|
6231
|
+
const validateLine = `validate = ["bash", "${validateScriptPath}"]`;
|
|
6232
|
+
|
|
6233
|
+
const lines = content.split('\n');
|
|
6234
|
+
let devStart = -1;
|
|
6235
|
+
let devEnd = -1;
|
|
6236
|
+
|
|
6237
|
+
for (let i = 0; i < lines.length; i++) {
|
|
6238
|
+
if (lines[i].trim() === '[dev]') {
|
|
6239
|
+
devStart = i;
|
|
6240
|
+
} else if (devStart !== -1 && lines[i].startsWith('[')) {
|
|
6241
|
+
devEnd = i;
|
|
6242
|
+
break;
|
|
6243
|
+
}
|
|
6244
|
+
}
|
|
6245
|
+
|
|
6246
|
+
if (devStart === -1) {
|
|
6247
|
+
return false;
|
|
6248
|
+
}
|
|
6249
|
+
|
|
6250
|
+
if (devEnd === -1) {
|
|
6251
|
+
devEnd = lines.length;
|
|
6252
|
+
}
|
|
6253
|
+
|
|
6254
|
+
lines.splice(devEnd, 0, validateLine);
|
|
6255
|
+
await fs$1.writeFile(cozePath, lines.join('\n'), 'utf-8');
|
|
6256
|
+
return true;
|
|
6257
|
+
};
|
|
6258
|
+
|
|
6259
|
+
const createValidateScript = async (
|
|
6260
|
+
projectFolder,
|
|
6261
|
+
template,
|
|
6262
|
+
validateScriptFile,
|
|
6263
|
+
) => {
|
|
6264
|
+
const targetPath = path.join(projectFolder, validateScriptFile);
|
|
6265
|
+
if (await isFileExists(targetPath)) {
|
|
6266
|
+
return false;
|
|
6267
|
+
}
|
|
6268
|
+
|
|
6269
|
+
const scriptsDir = path.join(projectFolder, validateScriptFile.split('/').slice(0, -1).join('/'));
|
|
6270
|
+
if (!(await isFileExists(scriptsDir))) {
|
|
6271
|
+
await fs$1.mkdir(scriptsDir, { recursive: true });
|
|
6272
|
+
}
|
|
6273
|
+
|
|
6274
|
+
const templateScriptPath = path.join(
|
|
6275
|
+
getTemplatesDir(),
|
|
6276
|
+
template,
|
|
6277
|
+
validateScriptFile,
|
|
6278
|
+
);
|
|
6279
|
+
const templateContent = await fs$1.readFile(templateScriptPath, 'utf-8');
|
|
6280
|
+
await fs$1.writeFile(targetPath, templateContent, 'utf-8');
|
|
6281
|
+
return true;
|
|
6282
|
+
};
|
|
6283
|
+
|
|
6284
|
+
const addMissingScriptsToPackageJson = async (
|
|
6285
|
+
projectFolder,
|
|
6286
|
+
template,
|
|
6287
|
+
) => {
|
|
6288
|
+
const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$1);
|
|
6289
|
+
if (!(await isFileExists(packageJsonPath))) {
|
|
6290
|
+
return false;
|
|
6291
|
+
}
|
|
6292
|
+
|
|
6293
|
+
const content = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
6294
|
+
const packageJson = safeJsonParse(content, null);
|
|
6295
|
+
if (!packageJson) {
|
|
6296
|
+
return false;
|
|
6297
|
+
}
|
|
6298
|
+
|
|
6299
|
+
const templateScripts = await getTemplateScripts(template);
|
|
6300
|
+
const missingScripts = getMissingScripts(packageJson.scripts, templateScripts);
|
|
6301
|
+
if (Object.keys(missingScripts).length === 0) {
|
|
6302
|
+
return false;
|
|
6303
|
+
}
|
|
6304
|
+
|
|
6305
|
+
packageJson.scripts = { ...packageJson.scripts, ...missingScripts };
|
|
6306
|
+
await fs$1.writeFile(
|
|
6307
|
+
packageJsonPath,
|
|
6308
|
+
JSON.stringify(packageJson, null, 2),
|
|
6309
|
+
'utf-8',
|
|
6310
|
+
);
|
|
6311
|
+
return true;
|
|
6312
|
+
};
|
|
6313
|
+
|
|
6314
|
+
const createAddValidatePatch = (template) => {
|
|
6315
|
+
const patchId = `${template}/add-validate@0.0.1`;
|
|
6316
|
+
const validateScriptFile = VALIDATE_SCRIPT_MAP[template];
|
|
6317
|
+
const validateScriptPath = template === 'taro' || template === 'expo'
|
|
6318
|
+
? validateScriptFile
|
|
6319
|
+
: `./${validateScriptFile}`;
|
|
6320
|
+
|
|
6321
|
+
return {
|
|
6322
|
+
id: patchId,
|
|
6323
|
+
template,
|
|
6324
|
+
disabled: byFlag(FG_KEY_MAP[template]),
|
|
6325
|
+
operations: [
|
|
6326
|
+
{
|
|
6327
|
+
kind: 'file-patch',
|
|
6328
|
+
file: COZE_FILE,
|
|
6329
|
+
description: '在 [dev] 下添加 validate 命令',
|
|
6330
|
+
},
|
|
6331
|
+
{
|
|
6332
|
+
kind: 'create-file',
|
|
6333
|
+
file: validateScriptFile,
|
|
6334
|
+
description: '创建 validate 脚本',
|
|
6335
|
+
},
|
|
6336
|
+
{
|
|
6337
|
+
kind: 'file-patch',
|
|
6338
|
+
file: PACKAGE_JSON_FILE$1,
|
|
6339
|
+
description: '补齐 validate/ts-check/lint:build 脚本',
|
|
6340
|
+
},
|
|
6341
|
+
],
|
|
6342
|
+
shouldApply: context => !hasValidateInCoze(context),
|
|
6343
|
+
apply: async (context) => {
|
|
6344
|
+
const cozeUpdated = await addValidateToCoze(
|
|
6345
|
+
context.projectFolder,
|
|
6346
|
+
validateScriptPath,
|
|
6347
|
+
);
|
|
6348
|
+
if (!cozeUpdated) {
|
|
6349
|
+
return {
|
|
6350
|
+
applied: false,
|
|
6351
|
+
patchId,
|
|
6352
|
+
message:
|
|
6353
|
+
'Failed to add validate to .coze ([dev] section not found), skipping',
|
|
6354
|
+
};
|
|
6355
|
+
}
|
|
6356
|
+
if (context.cozeConfig) {
|
|
6357
|
+
context.cozeConfig.dev = {
|
|
6358
|
+
...context.cozeConfig.dev,
|
|
6359
|
+
validate: ['bash', validateScriptPath],
|
|
6360
|
+
};
|
|
6361
|
+
}
|
|
6362
|
+
logger.info('Patched .coze: added validate command');
|
|
6363
|
+
|
|
6364
|
+
const scriptCreated = await createValidateScript(
|
|
6365
|
+
context.projectFolder,
|
|
6366
|
+
template,
|
|
6367
|
+
validateScriptFile,
|
|
6368
|
+
);
|
|
6369
|
+
if (scriptCreated) {
|
|
6370
|
+
logger.info(`Created ${validateScriptFile}`);
|
|
6371
|
+
} else {
|
|
6372
|
+
logger.info(`${validateScriptFile} already exists, skipping`);
|
|
6373
|
+
}
|
|
6374
|
+
|
|
6375
|
+
const scriptsUpdated = await addMissingScriptsToPackageJson(
|
|
6376
|
+
context.projectFolder,
|
|
6377
|
+
template,
|
|
6378
|
+
);
|
|
6379
|
+
if (scriptsUpdated) {
|
|
6380
|
+
logger.info('Patched package.json: added missing scripts');
|
|
6381
|
+
} else {
|
|
6382
|
+
logger.info('package.json scripts already complete, skipping');
|
|
6383
|
+
}
|
|
6384
|
+
|
|
6385
|
+
return {
|
|
6386
|
+
applied: true,
|
|
6387
|
+
patchId,
|
|
6388
|
+
message: `Added validate support to ${template} project`,
|
|
6389
|
+
};
|
|
6390
|
+
},
|
|
6391
|
+
};
|
|
6392
|
+
};
|
|
6393
|
+
|
|
6394
|
+
const patchNextjsAddValidate = createAddValidatePatch('nextjs');
|
|
6395
|
+
const patchViteAddValidate = createAddValidatePatch('vite');
|
|
6396
|
+
const patchNuxtVueAddValidate = createAddValidatePatch('nuxt-vue');
|
|
6397
|
+
const patchTaroAddValidate = createAddValidatePatch('taro');
|
|
6398
|
+
const patchExpoAddValidate = createAddValidatePatch('expo');
|
|
6399
|
+
|
|
6150
6400
|
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; }
|
|
6151
6401
|
const PATCH_ID$2 = 'taro/update-pack-script-for-tt-build@0.0.13';
|
|
6152
6402
|
const PACKAGE_JSON_FILE = 'package.json';
|
|
@@ -6573,6 +6823,11 @@ const patches = [
|
|
|
6573
6823
|
patchNextOutputTracingRoot,
|
|
6574
6824
|
patchTaroAgentsMd,
|
|
6575
6825
|
patchTaroPackScript,
|
|
6826
|
+
patchNextjsAddValidate,
|
|
6827
|
+
patchViteAddValidate,
|
|
6828
|
+
patchNuxtVueAddValidate,
|
|
6829
|
+
patchTaroAddValidate,
|
|
6830
|
+
patchExpoAddValidate,
|
|
6576
6831
|
] ;
|
|
6577
6832
|
|
|
6578
6833
|
const getTemplatePatches = (
|