@coze-arch/cli 0.0.36-alpha.102c95 → 0.0.36-alpha.15544e
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/README.md +5 -2
- package/docs/deploy.md +50 -41
- package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +35 -2
- package/lib/__templates__/expo/pnpm-lock.yaml +5 -5
- package/lib/__templates__/expo/server/package.json +1 -1
- package/lib/__templates__/nextjs/package.json +3 -3
- package/lib/__templates__/nextjs/pnpm-lock.yaml +513 -9
- package/lib/__templates__/nextjs/scripts/dev.sh +159 -14
- package/lib/__templates__/nextjs/template.config.js +1 -1
- package/lib/__templates__/nuxt-vue/package.json +1 -1
- package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +5 -5
- package/lib/__templates__/nuxt-vue/scripts/dev.sh +29 -1
- package/lib/__templates__/pi-agent/package.json +1 -1
- package/lib/__templates__/pi-agent/pnpm-lock.yaml +5 -5
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +29 -1
- package/lib/__templates__/taro/pnpm-lock.yaml +5 -5
- package/lib/__templates__/taro/server/package.json +1 -1
- package/lib/__templates__/vite/package.json +1 -1
- package/lib/__templates__/vite/pnpm-lock.yaml +5 -5
- package/lib/__templates__/vite/scripts/dev.sh +29 -1
- package/lib/__templates__/vite/template.config.js +1 -1
- package/lib/cli.js +429 -214
- package/package.json +1 -1
package/lib/cli.js
CHANGED
|
@@ -23,9 +23,9 @@ var Ajv = require('ajv');
|
|
|
23
23
|
var minimist = require('minimist');
|
|
24
24
|
var changeCase = require('change-case');
|
|
25
25
|
var ejs = require('ejs');
|
|
26
|
-
var node_crypto = require('node:crypto');
|
|
27
26
|
var node_os = require('node:os');
|
|
28
27
|
var promises = require('node:fs/promises');
|
|
28
|
+
var node_crypto = require('node:crypto');
|
|
29
29
|
var node_child_process = require('node:child_process');
|
|
30
30
|
var node_util = require('node:util');
|
|
31
31
|
var tar = require('tar');
|
|
@@ -1635,7 +1635,7 @@ function createNodeTransport() {
|
|
|
1635
1635
|
};
|
|
1636
1636
|
}
|
|
1637
1637
|
|
|
1638
|
-
function _nullishCoalesce$c(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
1638
|
+
function _nullishCoalesce$c(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; }/**
|
|
1639
1639
|
* Slardar CLI Reporter 主类
|
|
1640
1640
|
* 封装 @slardar/base 的初始化和上报逻辑
|
|
1641
1641
|
*/
|
|
@@ -1707,7 +1707,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1707
1707
|
this.client.on('send', (ev) => {
|
|
1708
1708
|
log$6(
|
|
1709
1709
|
'send hook called for event: %s',
|
|
1710
|
-
(_optionalChain$
|
|
1710
|
+
(_optionalChain$G([ev, 'optionalAccess', _ => _.ev_type]) ) || 'unknown',
|
|
1711
1711
|
);
|
|
1712
1712
|
});
|
|
1713
1713
|
|
|
@@ -1765,7 +1765,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1765
1765
|
)
|
|
1766
1766
|
: undefined;
|
|
1767
1767
|
|
|
1768
|
-
_optionalChain$
|
|
1768
|
+
_optionalChain$G([this, 'access', _2 => _2.client, 'access', _3 => _3.sendEvent, 'optionalCall', _4 => _4({
|
|
1769
1769
|
name,
|
|
1770
1770
|
metrics: cleanMetrics ,
|
|
1771
1771
|
categories: cleanCategories ,
|
|
@@ -1836,7 +1836,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1836
1836
|
log$6('Reporting JS error:', {
|
|
1837
1837
|
name: error.name,
|
|
1838
1838
|
message: error.message.slice(0, 100),
|
|
1839
|
-
stack: _optionalChain$
|
|
1839
|
+
stack: _optionalChain$G([error, 'access', _5 => _5.stack, 'optionalAccess', _6 => _6.slice, 'call', _7 => _7(0, 200)]),
|
|
1840
1840
|
extra,
|
|
1841
1841
|
source,
|
|
1842
1842
|
});
|
|
@@ -1856,7 +1856,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1856
1856
|
if (!this.ensureInitialized()) {
|
|
1857
1857
|
return;
|
|
1858
1858
|
}
|
|
1859
|
-
_optionalChain$
|
|
1859
|
+
_optionalChain$G([this, 'access', _8 => _8.client, 'access', _9 => _9.context, 'optionalAccess', _10 => _10.set, 'call', _11 => _11(key, value)]);
|
|
1860
1860
|
}
|
|
1861
1861
|
|
|
1862
1862
|
/**
|
|
@@ -1867,7 +1867,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1867
1867
|
return;
|
|
1868
1868
|
}
|
|
1869
1869
|
log$6('Merging context:', context);
|
|
1870
|
-
_optionalChain$
|
|
1870
|
+
_optionalChain$G([this, 'access', _12 => _12.client, 'access', _13 => _13.context, 'optionalAccess', _14 => _14.merge, 'call', _15 => _15(context)]);
|
|
1871
1871
|
}
|
|
1872
1872
|
|
|
1873
1873
|
/**
|
|
@@ -1877,7 +1877,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1877
1877
|
if (!this.ensureInitialized()) {
|
|
1878
1878
|
return;
|
|
1879
1879
|
}
|
|
1880
|
-
_optionalChain$
|
|
1880
|
+
_optionalChain$G([this, 'access', _16 => _16.client, 'access', _17 => _17.context, 'optionalAccess', _18 => _18.delete, 'call', _19 => _19(key)]);
|
|
1881
1881
|
}
|
|
1882
1882
|
|
|
1883
1883
|
/**
|
|
@@ -1887,7 +1887,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1887
1887
|
if (!this.ensureInitialized()) {
|
|
1888
1888
|
return;
|
|
1889
1889
|
}
|
|
1890
|
-
_optionalChain$
|
|
1890
|
+
_optionalChain$G([this, 'access', _20 => _20.client, 'access', _21 => _21.context, 'optionalAccess', _22 => _22.clear, 'call', _23 => _23()]);
|
|
1891
1891
|
}
|
|
1892
1892
|
|
|
1893
1893
|
/**
|
|
@@ -1924,7 +1924,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1924
1924
|
return;
|
|
1925
1925
|
}
|
|
1926
1926
|
log$6('Flushing Slardar data...');
|
|
1927
|
-
_optionalChain$
|
|
1927
|
+
_optionalChain$G([this, 'access', _24 => _24.client, 'access', _25 => _25.getSender, 'optionalCall', _26 => _26(), 'optionalAccess', _27 => _27.flush, 'call', _28 => _28()]);
|
|
1928
1928
|
log$6('Waiting %dms for events to be sent...', waitMs);
|
|
1929
1929
|
await new Promise(resolve => setTimeout(resolve, waitMs));
|
|
1930
1930
|
log$6('Slardar data flushed');
|
|
@@ -1943,7 +1943,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1943
1943
|
*/
|
|
1944
1944
|
const reporter = new SlardarCLIReporter();
|
|
1945
1945
|
|
|
1946
|
-
function _optionalChain$
|
|
1946
|
+
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; }
|
|
1947
1947
|
|
|
1948
1948
|
|
|
1949
1949
|
|
|
@@ -2003,11 +2003,11 @@ const EventBuilder = {
|
|
|
2003
2003
|
name: CLI_EVENTS.CLI_COMMAND,
|
|
2004
2004
|
categories: {
|
|
2005
2005
|
command,
|
|
2006
|
-
args: _optionalChain$
|
|
2006
|
+
args: _optionalChain$F([options, 'optionalAccess', _ => _.args]),
|
|
2007
2007
|
status: 'running' ,
|
|
2008
|
-
..._optionalChain$
|
|
2008
|
+
..._optionalChain$F([options, 'optionalAccess', _2 => _2.categories]),
|
|
2009
2009
|
},
|
|
2010
|
-
metrics: _optionalChain$
|
|
2010
|
+
metrics: _optionalChain$F([options, 'optionalAccess', _3 => _3.metrics]),
|
|
2011
2011
|
};
|
|
2012
2012
|
},
|
|
2013
2013
|
|
|
@@ -2028,13 +2028,13 @@ const EventBuilder = {
|
|
|
2028
2028
|
name: CLI_EVENTS.CLI_COMMAND_COMPLETE,
|
|
2029
2029
|
categories: {
|
|
2030
2030
|
command,
|
|
2031
|
-
args: _optionalChain$
|
|
2031
|
+
args: _optionalChain$F([options, 'optionalAccess', _4 => _4.args]),
|
|
2032
2032
|
status: success ? ('success' ) : ('fail' ),
|
|
2033
|
-
..._optionalChain$
|
|
2033
|
+
..._optionalChain$F([options, 'optionalAccess', _5 => _5.categories]),
|
|
2034
2034
|
},
|
|
2035
2035
|
metrics: {
|
|
2036
2036
|
duration,
|
|
2037
|
-
...(_optionalChain$
|
|
2037
|
+
...(_optionalChain$F([options, 'optionalAccess', _6 => _6.errorCode]) && { errorCode: options.errorCode }),
|
|
2038
2038
|
},
|
|
2039
2039
|
};
|
|
2040
2040
|
},
|
|
@@ -2055,12 +2055,12 @@ const EventBuilder = {
|
|
|
2055
2055
|
name: CLI_EVENTS.NETWORK_REQUEST,
|
|
2056
2056
|
categories: {
|
|
2057
2057
|
url,
|
|
2058
|
-
method: _optionalChain$
|
|
2059
|
-
statusCode: _optionalChain$
|
|
2060
|
-
status: _optionalChain$
|
|
2058
|
+
method: _optionalChain$F([options, 'optionalAccess', _7 => _7.method]) || 'GET',
|
|
2059
|
+
statusCode: _optionalChain$F([options, 'optionalAccess', _8 => _8.statusCode, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]),
|
|
2060
|
+
status: _optionalChain$F([options, 'optionalAccess', _11 => _11.success]) ? ('success' ) : ('fail' ),
|
|
2061
2061
|
},
|
|
2062
2062
|
metrics: {
|
|
2063
|
-
duration: _optionalChain$
|
|
2063
|
+
duration: _optionalChain$F([options, 'optionalAccess', _12 => _12.duration]),
|
|
2064
2064
|
},
|
|
2065
2065
|
};
|
|
2066
2066
|
},
|
|
@@ -2082,11 +2082,11 @@ const EventBuilder = {
|
|
|
2082
2082
|
categories: {
|
|
2083
2083
|
operation,
|
|
2084
2084
|
filePath,
|
|
2085
|
-
status: _optionalChain$
|
|
2085
|
+
status: _optionalChain$F([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
|
|
2086
2086
|
},
|
|
2087
2087
|
metrics: {
|
|
2088
|
-
duration: _optionalChain$
|
|
2089
|
-
fileSize: _optionalChain$
|
|
2088
|
+
duration: _optionalChain$F([options, 'optionalAccess', _14 => _14.duration]),
|
|
2089
|
+
fileSize: _optionalChain$F([options, 'optionalAccess', _15 => _15.fileSize]),
|
|
2090
2090
|
},
|
|
2091
2091
|
};
|
|
2092
2092
|
},
|
|
@@ -2114,7 +2114,7 @@ const EventBuilder = {
|
|
|
2114
2114
|
};
|
|
2115
2115
|
|
|
2116
2116
|
var name = "@coze-arch/cli";
|
|
2117
|
-
var version = "0.0.36-alpha.
|
|
2117
|
+
var version = "0.0.36-alpha.15544e";
|
|
2118
2118
|
var description = "coze coding devtools cli";
|
|
2119
2119
|
var license = "MIT";
|
|
2120
2120
|
var author = "fanwenjie.fe@bytedance.com";
|
|
@@ -2224,7 +2224,7 @@ var packageJson = {
|
|
|
2224
2224
|
cozePublishConfig: cozePublishConfig
|
|
2225
2225
|
};
|
|
2226
2226
|
|
|
2227
|
-
function _optionalChain$
|
|
2227
|
+
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; }/**
|
|
2228
2228
|
* Slardar 监控初始化和上报
|
|
2229
2229
|
*/
|
|
2230
2230
|
|
|
@@ -2327,11 +2327,11 @@ const reportCommandComplete = safeRun(
|
|
|
2327
2327
|
,
|
|
2328
2328
|
) => {
|
|
2329
2329
|
const event = EventBuilder.cliCommandComplete(command, success, duration, {
|
|
2330
|
-
args: _optionalChain$
|
|
2331
|
-
errorCode: _optionalChain$
|
|
2330
|
+
args: _optionalChain$E([options, 'optionalAccess', _ => _.args]),
|
|
2331
|
+
errorCode: _optionalChain$E([options, 'optionalAccess', _2 => _2.errorCode]),
|
|
2332
2332
|
categories: {
|
|
2333
|
-
...(_optionalChain$
|
|
2334
|
-
..._optionalChain$
|
|
2333
|
+
...(_optionalChain$E([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
|
|
2334
|
+
..._optionalChain$E([options, 'optionalAccess', _4 => _4.categories]),
|
|
2335
2335
|
},
|
|
2336
2336
|
});
|
|
2337
2337
|
reporter.sendEvent(event.name, event.metrics, event.categories);
|
|
@@ -2390,7 +2390,7 @@ const flushSlardar = safeRun('flushSlardar', async () => {
|
|
|
2390
2390
|
await reporter.flush();
|
|
2391
2391
|
});
|
|
2392
2392
|
|
|
2393
|
-
function _nullishCoalesce$b(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
2393
|
+
function _nullishCoalesce$b(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$D(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var LogLevel; (function (LogLevel) {
|
|
2394
2394
|
const ERROR = 0; LogLevel[LogLevel["ERROR"] = ERROR] = "ERROR";
|
|
2395
2395
|
const WARN = 1; LogLevel[LogLevel["WARN"] = WARN] = "WARN";
|
|
2396
2396
|
const SUCCESS = 2; LogLevel[LogLevel["SUCCESS"] = SUCCESS] = "SUCCESS";
|
|
@@ -2437,7 +2437,7 @@ class Logger {
|
|
|
2437
2437
|
return level;
|
|
2438
2438
|
}
|
|
2439
2439
|
|
|
2440
|
-
const envLevel = _optionalChain$
|
|
2440
|
+
const envLevel = _optionalChain$D([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
|
|
2441
2441
|
if (envLevel && envLevel in LOG_LEVEL_MAP) {
|
|
2442
2442
|
// envLevel 已通过 `in` 检查确认为 LOG_LEVEL_MAP 的键;
|
|
2443
2443
|
// 显式判空以满足 noUncheckedIndexedAccess,运行时行为不变
|
|
@@ -2454,7 +2454,7 @@ class Logger {
|
|
|
2454
2454
|
// 简单检测:Node.js 环境且支持 TTY
|
|
2455
2455
|
return (
|
|
2456
2456
|
typeof process !== 'undefined' &&
|
|
2457
|
-
_optionalChain$
|
|
2457
|
+
_optionalChain$D([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
|
|
2458
2458
|
process.env.NO_COLOR === undefined
|
|
2459
2459
|
);
|
|
2460
2460
|
}
|
|
@@ -3262,7 +3262,7 @@ const registerCommand$6 = program => {
|
|
|
3262
3262
|
});
|
|
3263
3263
|
};
|
|
3264
3264
|
|
|
3265
|
-
function _optionalChain$
|
|
3265
|
+
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; }// Safe JSON parsing utilities with type safety and error handling
|
|
3266
3266
|
// Provides fallback values, validation, and error monitoring capabilities
|
|
3267
3267
|
|
|
3268
3268
|
/**
|
|
@@ -3362,12 +3362,12 @@ function safeJsonParse(
|
|
|
3362
3362
|
const parsed = JSON.parse(String(input));
|
|
3363
3363
|
|
|
3364
3364
|
// Optional validation
|
|
3365
|
-
if (_optionalChain$
|
|
3365
|
+
if (_optionalChain$C([options, 'optionalAccess', _ => _.validate])) {
|
|
3366
3366
|
if (options.validate(parsed)) {
|
|
3367
3367
|
return parsed;
|
|
3368
3368
|
} else {
|
|
3369
3369
|
const validationError = new Error('JSON validation failed');
|
|
3370
|
-
_optionalChain$
|
|
3370
|
+
_optionalChain$C([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
|
|
3371
3371
|
|
|
3372
3372
|
if (options.throwOnValidationError) {
|
|
3373
3373
|
throw validationError;
|
|
@@ -3379,10 +3379,10 @@ function safeJsonParse(
|
|
|
3379
3379
|
return parsed;
|
|
3380
3380
|
} catch (error) {
|
|
3381
3381
|
// Re-throw validation errors when throwOnValidationError is true
|
|
3382
|
-
if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$
|
|
3382
|
+
if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$C([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
|
|
3383
3383
|
throw error;
|
|
3384
3384
|
}
|
|
3385
|
-
_optionalChain$
|
|
3385
|
+
_optionalChain$C([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
|
|
3386
3386
|
return defaultValue;
|
|
3387
3387
|
}
|
|
3388
3388
|
}
|
|
@@ -3422,7 +3422,7 @@ function isNode(node) {
|
|
|
3422
3422
|
}
|
|
3423
3423
|
const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
|
|
3424
3424
|
|
|
3425
|
-
function _optionalChain$
|
|
3425
|
+
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; }
|
|
3426
3426
|
const BREAK = Symbol('break visit');
|
|
3427
3427
|
const SKIP = Symbol('skip children');
|
|
3428
3428
|
const REMOVE = Symbol('remove node');
|
|
@@ -3535,15 +3535,15 @@ function callVisitor(key, node, visitor, path) {
|
|
|
3535
3535
|
if (typeof visitor === 'function')
|
|
3536
3536
|
return visitor(key, node, path);
|
|
3537
3537
|
if (isMap(node))
|
|
3538
|
-
return _optionalChain$
|
|
3538
|
+
return _optionalChain$B([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
|
|
3539
3539
|
if (isSeq(node))
|
|
3540
|
-
return _optionalChain$
|
|
3540
|
+
return _optionalChain$B([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
|
|
3541
3541
|
if (isPair(node))
|
|
3542
|
-
return _optionalChain$
|
|
3542
|
+
return _optionalChain$B([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
|
|
3543
3543
|
if (isScalar(node))
|
|
3544
|
-
return _optionalChain$
|
|
3544
|
+
return _optionalChain$B([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
|
|
3545
3545
|
if (isAlias(node))
|
|
3546
|
-
return _optionalChain$
|
|
3546
|
+
return _optionalChain$B([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
|
|
3547
3547
|
return undefined;
|
|
3548
3548
|
}
|
|
3549
3549
|
function replaceNode(key, path, node) {
|
|
@@ -3634,7 +3634,7 @@ function applyReviver(reviver, obj, key, val) {
|
|
|
3634
3634
|
return reviver.call(obj, key, val);
|
|
3635
3635
|
}
|
|
3636
3636
|
|
|
3637
|
-
function _optionalChain$
|
|
3637
|
+
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; }
|
|
3638
3638
|
/**
|
|
3639
3639
|
* Recursively convert any node or its contents to native JavaScript
|
|
3640
3640
|
*
|
|
@@ -3664,7 +3664,7 @@ function toJS(value, arg, ctx) {
|
|
|
3664
3664
|
ctx.onCreate(res);
|
|
3665
3665
|
return res;
|
|
3666
3666
|
}
|
|
3667
|
-
if (typeof value === 'bigint' && !_optionalChain$
|
|
3667
|
+
if (typeof value === 'bigint' && !_optionalChain$A([ctx, 'optionalAccess', _ => _.keep]))
|
|
3668
3668
|
return Number(value);
|
|
3669
3669
|
return value;
|
|
3670
3670
|
}
|
|
@@ -3702,7 +3702,7 @@ class NodeBase {
|
|
|
3702
3702
|
}
|
|
3703
3703
|
}
|
|
3704
3704
|
|
|
3705
|
-
function _optionalChain$
|
|
3705
|
+
function _optionalChain$z(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; }
|
|
3706
3706
|
class Alias extends NodeBase {
|
|
3707
3707
|
constructor(source) {
|
|
3708
3708
|
super(ALIAS);
|
|
@@ -3718,10 +3718,10 @@ class Alias extends NodeBase {
|
|
|
3718
3718
|
* instance of the `source` anchor before this node.
|
|
3719
3719
|
*/
|
|
3720
3720
|
resolve(doc, ctx) {
|
|
3721
|
-
if (_optionalChain$
|
|
3721
|
+
if (_optionalChain$z([ctx, 'optionalAccess', _ => _.maxAliasCount]) === 0)
|
|
3722
3722
|
throw new ReferenceError('Alias resolution is disabled');
|
|
3723
3723
|
let nodes;
|
|
3724
|
-
if (_optionalChain$
|
|
3724
|
+
if (_optionalChain$z([ctx, 'optionalAccess', _2 => _2.aliasResolveCache])) {
|
|
3725
3725
|
nodes = ctx.aliasResolveCache;
|
|
3726
3726
|
}
|
|
3727
3727
|
else {
|
|
@@ -3760,7 +3760,7 @@ class Alias extends NodeBase {
|
|
|
3760
3760
|
data = anchors.get(source);
|
|
3761
3761
|
}
|
|
3762
3762
|
/* istanbul ignore if */
|
|
3763
|
-
if (_optionalChain$
|
|
3763
|
+
if (_optionalChain$z([data, 'optionalAccess', _3 => _3.res]) === undefined) {
|
|
3764
3764
|
const msg = 'This should not happen: Alias anchor was not resolved?';
|
|
3765
3765
|
throw new ReferenceError(msg);
|
|
3766
3766
|
}
|
|
@@ -3812,7 +3812,7 @@ function getAliasCount(doc, node, anchors) {
|
|
|
3812
3812
|
return 1;
|
|
3813
3813
|
}
|
|
3814
3814
|
|
|
3815
|
-
function _optionalChain$
|
|
3815
|
+
function _optionalChain$y(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; }
|
|
3816
3816
|
const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
|
|
3817
3817
|
class Scalar extends NodeBase {
|
|
3818
3818
|
constructor(value) {
|
|
@@ -3820,7 +3820,7 @@ class Scalar extends NodeBase {
|
|
|
3820
3820
|
this.value = value;
|
|
3821
3821
|
}
|
|
3822
3822
|
toJSON(arg, ctx) {
|
|
3823
|
-
return _optionalChain$
|
|
3823
|
+
return _optionalChain$y([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
|
|
3824
3824
|
}
|
|
3825
3825
|
toString() {
|
|
3826
3826
|
return String(this.value);
|
|
@@ -3832,7 +3832,7 @@ Scalar.PLAIN = 'PLAIN';
|
|
|
3832
3832
|
Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
|
|
3833
3833
|
Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
|
|
3834
3834
|
|
|
3835
|
-
function _nullishCoalesce$a(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
3835
|
+
function _nullishCoalesce$a(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$x(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; }
|
|
3836
3836
|
const defaultTagPrefix = 'tag:yaml.org,2002:';
|
|
3837
3837
|
function findTagObject(value, tagName, tags) {
|
|
3838
3838
|
if (tagName) {
|
|
@@ -3842,7 +3842,7 @@ function findTagObject(value, tagName, tags) {
|
|
|
3842
3842
|
throw new Error(`Tag ${tagName} not found`);
|
|
3843
3843
|
return tagObj;
|
|
3844
3844
|
}
|
|
3845
|
-
return tags.find(t => _optionalChain$
|
|
3845
|
+
return tags.find(t => _optionalChain$x([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
|
|
3846
3846
|
}
|
|
3847
3847
|
function createNode(value, tagName, ctx) {
|
|
3848
3848
|
if (isDocument(value))
|
|
@@ -3850,7 +3850,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3850
3850
|
if (isNode(value))
|
|
3851
3851
|
return value;
|
|
3852
3852
|
if (isPair(value)) {
|
|
3853
|
-
const map = _optionalChain$
|
|
3853
|
+
const map = _optionalChain$x([ctx, 'access', _3 => _3.schema, 'access', _4 => _4[MAP], 'access', _5 => _5.createNode, 'optionalCall', _6 => _6(ctx.schema, null, ctx)]);
|
|
3854
3854
|
map.items.push(value);
|
|
3855
3855
|
return map;
|
|
3856
3856
|
}
|
|
@@ -3877,7 +3877,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3877
3877
|
sourceObjects.set(value, ref);
|
|
3878
3878
|
}
|
|
3879
3879
|
}
|
|
3880
|
-
if (_optionalChain$
|
|
3880
|
+
if (_optionalChain$x([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
|
|
3881
3881
|
tagName = defaultTagPrefix + tagName.slice(2);
|
|
3882
3882
|
let tagObj = findTagObject(value, tagName, schema.tags);
|
|
3883
3883
|
if (!tagObj) {
|
|
@@ -3902,9 +3902,9 @@ function createNode(value, tagName, ctx) {
|
|
|
3902
3902
|
onTagObj(tagObj);
|
|
3903
3903
|
delete ctx.onTagObj;
|
|
3904
3904
|
}
|
|
3905
|
-
const node = _optionalChain$
|
|
3905
|
+
const node = _optionalChain$x([tagObj, 'optionalAccess', _9 => _9.createNode])
|
|
3906
3906
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
3907
|
-
: typeof _optionalChain$
|
|
3907
|
+
: typeof _optionalChain$x([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
|
|
3908
3908
|
? tagObj.nodeClass.from(ctx.schema, value, ctx)
|
|
3909
3909
|
: new Scalar(value);
|
|
3910
3910
|
if (tagName)
|
|
@@ -4222,7 +4222,7 @@ function consumeMoreIndentedLines(text, i, indent) {
|
|
|
4222
4222
|
return end;
|
|
4223
4223
|
}
|
|
4224
4224
|
|
|
4225
|
-
function _optionalChain$
|
|
4225
|
+
function _optionalChain$w(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; }
|
|
4226
4226
|
const getFoldOptions = (ctx, isBlock) => ({
|
|
4227
4227
|
indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
|
|
4228
4228
|
lineWidth: ctx.options.lineWidth,
|
|
@@ -4507,9 +4507,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
4507
4507
|
// booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
|
|
4508
4508
|
// and others in v1.1.
|
|
4509
4509
|
if (actualString) {
|
|
4510
|
-
const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$
|
|
4510
|
+
const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$w([tag, 'access', _ => _.test, 'optionalAccess', _2 => _2.test, 'call', _3 => _3(str)]);
|
|
4511
4511
|
const { compat, tags } = ctx.doc.schema;
|
|
4512
|
-
if (tags.some(test) || _optionalChain$
|
|
4512
|
+
if (tags.some(test) || _optionalChain$w([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
|
|
4513
4513
|
return quotedString(value, ctx);
|
|
4514
4514
|
}
|
|
4515
4515
|
return implicitKey
|
|
@@ -4555,7 +4555,7 @@ function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
|
4555
4555
|
return res;
|
|
4556
4556
|
}
|
|
4557
4557
|
|
|
4558
|
-
function _nullishCoalesce$9(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
4558
|
+
function _nullishCoalesce$9(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$v(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; }
|
|
4559
4559
|
function createStringifyContext(doc, options) {
|
|
4560
4560
|
const opt = Object.assign({
|
|
4561
4561
|
blockQuote: true,
|
|
@@ -4608,7 +4608,7 @@ function getTagObject(tags, item) {
|
|
|
4608
4608
|
let obj;
|
|
4609
4609
|
if (isScalar(item)) {
|
|
4610
4610
|
obj = item.value;
|
|
4611
|
-
let match = tags.filter(t => _optionalChain$
|
|
4611
|
+
let match = tags.filter(t => _optionalChain$v([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
|
|
4612
4612
|
if (match.length > 1) {
|
|
4613
4613
|
const testMatch = match.filter(t => t.test);
|
|
4614
4614
|
if (testMatch.length > 0)
|
|
@@ -4622,7 +4622,7 @@ function getTagObject(tags, item) {
|
|
|
4622
4622
|
tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
|
|
4623
4623
|
}
|
|
4624
4624
|
if (!tagObj) {
|
|
4625
|
-
const name = _nullishCoalesce$9(_optionalChain$
|
|
4625
|
+
const name = _nullishCoalesce$9(_optionalChain$v([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
|
|
4626
4626
|
throw new Error(`Tag not resolved for ${name} value`);
|
|
4627
4627
|
}
|
|
4628
4628
|
return tagObj;
|
|
@@ -4648,7 +4648,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
|
|
|
4648
4648
|
if (isAlias(item)) {
|
|
4649
4649
|
if (ctx.doc.directives)
|
|
4650
4650
|
return item.toString(ctx);
|
|
4651
|
-
if (_optionalChain$
|
|
4651
|
+
if (_optionalChain$v([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
|
|
4652
4652
|
throw new TypeError(`Cannot stringify circular structure without alias nodes`);
|
|
4653
4653
|
}
|
|
4654
4654
|
else {
|
|
@@ -4830,7 +4830,7 @@ function warn(logLevel, warning) {
|
|
|
4830
4830
|
}
|
|
4831
4831
|
}
|
|
4832
4832
|
|
|
4833
|
-
function _optionalChain$
|
|
4833
|
+
function _optionalChain$u(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
4834
4834
|
// If the value associated with a merge key is a single mapping node, each of
|
|
4835
4835
|
// its key/value pairs is inserted into the current mapping, unless the key
|
|
4836
4836
|
// already exists in it. If the value associated with the merge key is a
|
|
@@ -4854,7 +4854,7 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
|
|
|
4854
4854
|
(isScalar(key) &&
|
|
4855
4855
|
(!key.type || key.type === Scalar.PLAIN) &&
|
|
4856
4856
|
merge.identify(key.value))) &&
|
|
4857
|
-
_optionalChain$
|
|
4857
|
+
_optionalChain$u([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)]);
|
|
4858
4858
|
function addMergeToJSMap(ctx, map, value) {
|
|
4859
4859
|
const source = resolveAliasValue(ctx, value);
|
|
4860
4860
|
if (isSeq(source))
|
|
@@ -4894,7 +4894,7 @@ function resolveAliasValue(ctx, value) {
|
|
|
4894
4894
|
return ctx && isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
|
|
4895
4895
|
}
|
|
4896
4896
|
|
|
4897
|
-
function _optionalChain$
|
|
4897
|
+
function _optionalChain$t(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
4898
4898
|
function addPairToJSMap(ctx, map, { key, value }) {
|
|
4899
4899
|
if (isNode(key) && key.addToJSMap)
|
|
4900
4900
|
key.addToJSMap(ctx, map, value);
|
|
@@ -4931,7 +4931,7 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
4931
4931
|
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
4932
4932
|
if (typeof jsKey !== 'object')
|
|
4933
4933
|
return String(jsKey);
|
|
4934
|
-
if (isNode(key) && _optionalChain$
|
|
4934
|
+
if (isNode(key) && _optionalChain$t([ctx, 'optionalAccess', _ => _.doc])) {
|
|
4935
4935
|
const strCtx = createStringifyContext(ctx.doc, {});
|
|
4936
4936
|
strCtx.anchors = new Set();
|
|
4937
4937
|
for (const node of ctx.anchors.keys())
|
|
@@ -4951,7 +4951,7 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
4951
4951
|
return JSON.stringify(jsKey);
|
|
4952
4952
|
}
|
|
4953
4953
|
|
|
4954
|
-
function _optionalChain$
|
|
4954
|
+
function _optionalChain$s(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
4955
4955
|
function createPair(key, value, ctx) {
|
|
4956
4956
|
const k = createNode(key, undefined, ctx);
|
|
4957
4957
|
const v = createNode(value, undefined, ctx);
|
|
@@ -4972,17 +4972,17 @@ class Pair {
|
|
|
4972
4972
|
return new Pair(key, value);
|
|
4973
4973
|
}
|
|
4974
4974
|
toJSON(_, ctx) {
|
|
4975
|
-
const pair = _optionalChain$
|
|
4975
|
+
const pair = _optionalChain$s([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
|
|
4976
4976
|
return addPairToJSMap(ctx, pair, this);
|
|
4977
4977
|
}
|
|
4978
4978
|
toString(ctx, onComment, onChompKeep) {
|
|
4979
|
-
return _optionalChain$
|
|
4979
|
+
return _optionalChain$s([ctx, 'optionalAccess', _3 => _3.doc])
|
|
4980
4980
|
? stringifyPair(this, ctx, onComment, onChompKeep)
|
|
4981
4981
|
: JSON.stringify(this);
|
|
4982
4982
|
}
|
|
4983
4983
|
}
|
|
4984
4984
|
|
|
4985
|
-
function _nullishCoalesce$7(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
4985
|
+
function _nullishCoalesce$7(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$r(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
4986
4986
|
function stringifyCollection(collection, ctx, options) {
|
|
4987
4987
|
const flow = _nullishCoalesce$7(ctx.inFlow, () => ( collection.flow));
|
|
4988
4988
|
const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
|
|
@@ -5076,7 +5076,7 @@ function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
|
|
|
5076
5076
|
if (iv.commentBefore)
|
|
5077
5077
|
reqNewline = true;
|
|
5078
5078
|
}
|
|
5079
|
-
else if (item.value == null && _optionalChain$
|
|
5079
|
+
else if (item.value == null && _optionalChain$r([ik, 'optionalAccess', _ => _.comment])) {
|
|
5080
5080
|
comment = ik.comment;
|
|
5081
5081
|
}
|
|
5082
5082
|
}
|
|
@@ -5131,7 +5131,7 @@ function addCommentBefore({ indent, options: { commentString } }, lines, comment
|
|
|
5131
5131
|
}
|
|
5132
5132
|
}
|
|
5133
5133
|
|
|
5134
|
-
function _nullishCoalesce$6(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
5134
|
+
function _nullishCoalesce$6(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; }
|
|
5135
5135
|
function findPair(items, key) {
|
|
5136
5136
|
const k = isScalar(key) ? key.value : key;
|
|
5137
5137
|
for (const it of items) {
|
|
@@ -5192,12 +5192,12 @@ class YAMLMap extends Collection {
|
|
|
5192
5192
|
_pair = pair;
|
|
5193
5193
|
else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
|
|
5194
5194
|
// In TypeScript, this never happens.
|
|
5195
|
-
_pair = new Pair(pair, _optionalChain$
|
|
5195
|
+
_pair = new Pair(pair, _optionalChain$q([pair, 'optionalAccess', _2 => _2.value]));
|
|
5196
5196
|
}
|
|
5197
5197
|
else
|
|
5198
5198
|
_pair = new Pair(pair.key, pair.value);
|
|
5199
5199
|
const prev = findPair(this.items, _pair.key);
|
|
5200
|
-
const sortEntries = _optionalChain$
|
|
5200
|
+
const sortEntries = _optionalChain$q([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
|
|
5201
5201
|
if (prev) {
|
|
5202
5202
|
if (!overwrite)
|
|
5203
5203
|
throw new Error(`Key ${_pair.key} already set`);
|
|
@@ -5227,7 +5227,7 @@ class YAMLMap extends Collection {
|
|
|
5227
5227
|
}
|
|
5228
5228
|
get(key, keepScalar) {
|
|
5229
5229
|
const it = findPair(this.items, key);
|
|
5230
|
-
const node = _optionalChain$
|
|
5230
|
+
const node = _optionalChain$q([it, 'optionalAccess', _5 => _5.value]);
|
|
5231
5231
|
return _nullishCoalesce$6((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
|
|
5232
5232
|
}
|
|
5233
5233
|
has(key) {
|
|
@@ -5242,8 +5242,8 @@ class YAMLMap extends Collection {
|
|
|
5242
5242
|
* @returns Instance of Type, Map, or Object
|
|
5243
5243
|
*/
|
|
5244
5244
|
toJSON(_, ctx, Type) {
|
|
5245
|
-
const map = Type ? new Type() : _optionalChain$
|
|
5246
|
-
if (_optionalChain$
|
|
5245
|
+
const map = Type ? new Type() : _optionalChain$q([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
|
|
5246
|
+
if (_optionalChain$q([ctx, 'optionalAccess', _7 => _7.onCreate]))
|
|
5247
5247
|
ctx.onCreate(map);
|
|
5248
5248
|
for (const item of this.items)
|
|
5249
5249
|
addPairToJSMap(ctx, map, item);
|
|
@@ -5268,7 +5268,7 @@ class YAMLMap extends Collection {
|
|
|
5268
5268
|
}
|
|
5269
5269
|
}
|
|
5270
5270
|
|
|
5271
|
-
function _optionalChain$
|
|
5271
|
+
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; }
|
|
5272
5272
|
class YAMLSeq extends Collection {
|
|
5273
5273
|
static get tagName() {
|
|
5274
5274
|
return 'tag:yaml.org,2002:seq';
|
|
@@ -5331,7 +5331,7 @@ class YAMLSeq extends Collection {
|
|
|
5331
5331
|
}
|
|
5332
5332
|
toJSON(_, ctx) {
|
|
5333
5333
|
const seq = [];
|
|
5334
|
-
if (_optionalChain$
|
|
5334
|
+
if (_optionalChain$p([ctx, 'optionalAccess', _2 => _2.onCreate]))
|
|
5335
5335
|
ctx.onCreate(seq);
|
|
5336
5336
|
let i = 0;
|
|
5337
5337
|
for (const item of this.items)
|
|
@@ -5410,7 +5410,7 @@ function createPairs(schema, iterable, ctx) {
|
|
|
5410
5410
|
return pairs;
|
|
5411
5411
|
}
|
|
5412
5412
|
|
|
5413
|
-
function _optionalChain$
|
|
5413
|
+
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; }
|
|
5414
5414
|
class YAMLOMap extends YAMLSeq {
|
|
5415
5415
|
constructor() {
|
|
5416
5416
|
super();
|
|
@@ -5429,7 +5429,7 @@ class YAMLOMap extends YAMLSeq {
|
|
|
5429
5429
|
if (!ctx)
|
|
5430
5430
|
return super.toJSON(_);
|
|
5431
5431
|
const map = new Map();
|
|
5432
|
-
if (_optionalChain$
|
|
5432
|
+
if (_optionalChain$o([ctx, 'optionalAccess', _2 => _2.onCreate]))
|
|
5433
5433
|
ctx.onCreate(map);
|
|
5434
5434
|
for (const pair of this.items) {
|
|
5435
5435
|
let key, value;
|
|
@@ -5547,7 +5547,7 @@ const isDirExists = async (file) => {
|
|
|
5547
5547
|
}
|
|
5548
5548
|
};
|
|
5549
5549
|
|
|
5550
|
-
function _optionalChain$
|
|
5550
|
+
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; }// ABOUTME: Project type detection utility
|
|
5551
5551
|
|
|
5552
5552
|
/**
|
|
5553
5553
|
* 支持的项目类型枚举
|
|
@@ -5649,7 +5649,7 @@ const collectProjectInfo = async (
|
|
|
5649
5649
|
}
|
|
5650
5650
|
|
|
5651
5651
|
const scripts = Object.entries(
|
|
5652
|
-
(_optionalChain$
|
|
5652
|
+
(_optionalChain$n([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
|
|
5653
5653
|
).reduce((acc, [name, script]) => {
|
|
5654
5654
|
if (typeof script === 'string') {
|
|
5655
5655
|
acc[name] = script;
|
|
@@ -5803,7 +5803,7 @@ const detectProjectType = async (
|
|
|
5803
5803
|
};
|
|
5804
5804
|
};
|
|
5805
5805
|
|
|
5806
|
-
function _optionalChain$
|
|
5806
|
+
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; }
|
|
5807
5807
|
|
|
5808
5808
|
|
|
5809
5809
|
/**
|
|
@@ -5970,13 +5970,13 @@ const getDefaultCommandConfig = (
|
|
|
5970
5970
|
) => {
|
|
5971
5971
|
switch (commandName) {
|
|
5972
5972
|
case 'dev':
|
|
5973
|
-
return _optionalChain$
|
|
5973
|
+
return _optionalChain$m([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
|
|
5974
5974
|
case 'build':
|
|
5975
|
-
return _optionalChain$
|
|
5975
|
+
return _optionalChain$m([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
|
|
5976
5976
|
case 'start':
|
|
5977
|
-
return _optionalChain$
|
|
5977
|
+
return _optionalChain$m([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
|
|
5978
5978
|
case 'validate':
|
|
5979
|
-
return _optionalChain$
|
|
5979
|
+
return _optionalChain$m([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
|
|
5980
5980
|
default:
|
|
5981
5981
|
throw new Error(`Unknown command: ${commandName}`);
|
|
5982
5982
|
}
|
|
@@ -5988,13 +5988,13 @@ const getWindowsCommandConfig = (
|
|
|
5988
5988
|
) => {
|
|
5989
5989
|
switch (commandName) {
|
|
5990
5990
|
case 'dev':
|
|
5991
|
-
return _optionalChain$
|
|
5991
|
+
return _optionalChain$m([config, 'access', _9 => _9.dev, 'optionalAccess', _10 => _10.run_win]);
|
|
5992
5992
|
case 'build':
|
|
5993
|
-
return _optionalChain$
|
|
5993
|
+
return _optionalChain$m([config, 'access', _11 => _11.deploy, 'optionalAccess', _12 => _12.build_win]);
|
|
5994
5994
|
case 'start':
|
|
5995
|
-
return _optionalChain$
|
|
5995
|
+
return _optionalChain$m([config, 'access', _13 => _13.deploy, 'optionalAccess', _14 => _14.run_win]);
|
|
5996
5996
|
case 'validate':
|
|
5997
|
-
return _optionalChain$
|
|
5997
|
+
return _optionalChain$m([config, 'access', _15 => _15.dev, 'optionalAccess', _16 => _16.validate_win]);
|
|
5998
5998
|
default:
|
|
5999
5999
|
throw new Error(`Unknown command: ${commandName}`);
|
|
6000
6000
|
}
|
|
@@ -6019,7 +6019,7 @@ const getCommandConfig = (
|
|
|
6019
6019
|
platform === 'win32'
|
|
6020
6020
|
? getWindowsCommandConfig(config, commandName)
|
|
6021
6021
|
: undefined;
|
|
6022
|
-
const commandConfig = _optionalChain$
|
|
6022
|
+
const commandConfig = _optionalChain$m([windowsCommandConfig, 'optionalAccess', _17 => _17.length])
|
|
6023
6023
|
? windowsCommandConfig
|
|
6024
6024
|
: defaultCommandConfig;
|
|
6025
6025
|
|
|
@@ -6168,7 +6168,7 @@ const byFlag = (flag) => {
|
|
|
6168
6168
|
return predicate;
|
|
6169
6169
|
};
|
|
6170
6170
|
|
|
6171
|
-
function _optionalChain$
|
|
6171
|
+
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; }
|
|
6172
6172
|
|
|
6173
6173
|
|
|
6174
6174
|
|
|
@@ -6199,7 +6199,7 @@ echo "Validate passed!"
|
|
|
6199
6199
|
* @returns
|
|
6200
6200
|
*/
|
|
6201
6201
|
const isCozeValid$3 = (cozeConfig) => {
|
|
6202
|
-
if (_optionalChain$
|
|
6202
|
+
if (_optionalChain$l([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6203
6203
|
logger.info('[patch-expo-validate] NOT APPLY: dev.validate exists');
|
|
6204
6204
|
return false;
|
|
6205
6205
|
}
|
|
@@ -6344,7 +6344,7 @@ const patchExpoValidate = {
|
|
|
6344
6344
|
},
|
|
6345
6345
|
};
|
|
6346
6346
|
|
|
6347
|
-
function _optionalChain$
|
|
6347
|
+
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; }
|
|
6348
6348
|
|
|
6349
6349
|
|
|
6350
6350
|
|
|
@@ -6377,7 +6377,7 @@ echo "Validate passed!"
|
|
|
6377
6377
|
* @returns
|
|
6378
6378
|
*/
|
|
6379
6379
|
const isCozeValid$2 = (cozeConfig) => {
|
|
6380
|
-
if (_optionalChain$
|
|
6380
|
+
if (_optionalChain$k([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6381
6381
|
logger.info('[patch-nextjs-validate] NOT APPLY: dev.validate exists');
|
|
6382
6382
|
return false;
|
|
6383
6383
|
}
|
|
@@ -6525,7 +6525,7 @@ const patchNextjsValidate = {
|
|
|
6525
6525
|
},
|
|
6526
6526
|
};
|
|
6527
6527
|
|
|
6528
|
-
function _optionalChain$
|
|
6528
|
+
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; }
|
|
6529
6529
|
|
|
6530
6530
|
const PATCH_ID$5 = 'nextjs/validate-concurrently@0.0.30';
|
|
6531
6531
|
const PACKAGE_JSON_FILE$3 = 'package.json';
|
|
@@ -6558,7 +6558,7 @@ const readPackageJson = async (projectFolder) => {
|
|
|
6558
6558
|
};
|
|
6559
6559
|
|
|
6560
6560
|
const getTargetValidateScript = (packageJson) => {
|
|
6561
|
-
const validateScript = _optionalChain$
|
|
6561
|
+
const validateScript = _optionalChain$j([packageJson, 'access', _ => _.scripts, 'optionalAccess', _2 => _2.validate]);
|
|
6562
6562
|
if (typeof validateScript !== 'string') {
|
|
6563
6563
|
return null;
|
|
6564
6564
|
}
|
|
@@ -6575,7 +6575,7 @@ const getTargetValidateScript = (packageJson) => {
|
|
|
6575
6575
|
|
|
6576
6576
|
const canStackAfterNextjsValidatePatch = async (context, packageJson) => {
|
|
6577
6577
|
const scripts = packageJson.scripts || {};
|
|
6578
|
-
if (typeof scripts.validate !== 'undefined' || typeof scripts['ts-check'] !== 'string' || _optionalChain$
|
|
6578
|
+
if (typeof scripts.validate !== 'undefined' || typeof scripts['ts-check'] !== 'string' || _optionalChain$j([context, 'access', _3 => _3.cozeConfig, 'access', _4 => _4.dev, 'optionalAccess', _5 => _5.validate])) {
|
|
6579
6579
|
return false;
|
|
6580
6580
|
}
|
|
6581
6581
|
|
|
@@ -6644,7 +6644,7 @@ const patchNextjsValidateConcurrently = {
|
|
|
6644
6644
|
apply: patchPackageJson$2,
|
|
6645
6645
|
};
|
|
6646
6646
|
|
|
6647
|
-
function _optionalChain$
|
|
6647
|
+
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; }
|
|
6648
6648
|
|
|
6649
6649
|
|
|
6650
6650
|
|
|
@@ -6677,7 +6677,7 @@ echo "Validate passed!"
|
|
|
6677
6677
|
* @returns
|
|
6678
6678
|
*/
|
|
6679
6679
|
const isCozeValid$1 = (cozeConfig) => {
|
|
6680
|
-
if (_optionalChain$
|
|
6680
|
+
if (_optionalChain$i([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6681
6681
|
logger.info('[patch-vite-validate] NOT APPLY: dev.validate exists');
|
|
6682
6682
|
return false;
|
|
6683
6683
|
}
|
|
@@ -6822,7 +6822,7 @@ const patchViteValidate = {
|
|
|
6822
6822
|
},
|
|
6823
6823
|
};
|
|
6824
6824
|
|
|
6825
|
-
function _optionalChain$
|
|
6825
|
+
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; }
|
|
6826
6826
|
|
|
6827
6827
|
|
|
6828
6828
|
|
|
@@ -6859,7 +6859,7 @@ echo "Validate passed!"
|
|
|
6859
6859
|
* @returns
|
|
6860
6860
|
*/
|
|
6861
6861
|
const isCozeValid = (cozeConfig) => {
|
|
6862
|
-
if (_optionalChain$
|
|
6862
|
+
if (_optionalChain$h([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6863
6863
|
logger.info('[patch-taro-validate] NOT APPLY: dev.validate exists');
|
|
6864
6864
|
return false;
|
|
6865
6865
|
}
|
|
@@ -7008,7 +7008,7 @@ const patchTaroValidate = {
|
|
|
7008
7008
|
},
|
|
7009
7009
|
};
|
|
7010
7010
|
|
|
7011
|
-
function _optionalChain$
|
|
7011
|
+
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; }
|
|
7012
7012
|
const PATCH_ID$2 = 'taro/update-pack-script-for-tt-build@0.0.13';
|
|
7013
7013
|
const PACKAGE_JSON_FILE = 'package.json';
|
|
7014
7014
|
const PACK_SCRIPT_FILE = '.cozeproj/scripts/pack.sh';
|
|
@@ -7087,12 +7087,12 @@ const readPackageScripts = async (
|
|
|
7087
7087
|
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
7088
7088
|
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
7089
7089
|
|
|
7090
|
-
return _optionalChain$
|
|
7090
|
+
return _optionalChain$g([packageJson, 'optionalAccess', _ => _.scripts]) || null;
|
|
7091
7091
|
};
|
|
7092
7092
|
|
|
7093
7093
|
const hasBuildTtScript = async (projectFolder) => {
|
|
7094
7094
|
const scripts = await readPackageScripts(projectFolder);
|
|
7095
|
-
return typeof _optionalChain$
|
|
7095
|
+
return typeof _optionalChain$g([scripts, 'optionalAccess', _2 => _2['build:tt']]) === 'string';
|
|
7096
7096
|
};
|
|
7097
7097
|
|
|
7098
7098
|
const hasLegacyPackScript = async (projectFolder) => {
|
|
@@ -7446,7 +7446,7 @@ const getTemplatePatches = (
|
|
|
7446
7446
|
) =>
|
|
7447
7447
|
patches.filter(patch => patch.template === template);
|
|
7448
7448
|
|
|
7449
|
-
function _nullishCoalesce$5(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
7449
|
+
function _nullishCoalesce$5(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; }
|
|
7450
7450
|
const DEFAULT_LEGACY_VERSION = 'legacy';
|
|
7451
7451
|
|
|
7452
7452
|
const loadFlagsWithFallback = async () => {
|
|
@@ -7552,7 +7552,7 @@ const getNextPatchState = (
|
|
|
7552
7552
|
|
|
7553
7553
|
) => ({
|
|
7554
7554
|
template,
|
|
7555
|
-
version: _optionalChain$
|
|
7555
|
+
version: _optionalChain$f([config, 'access', _ => _.project, 'optionalAccess', _2 => _2.version]) || DEFAULT_LEGACY_VERSION,
|
|
7556
7556
|
appliedPatches: [...appliedPatches, patchId],
|
|
7557
7557
|
});
|
|
7558
7558
|
|
|
@@ -7576,15 +7576,15 @@ const executePatch = async (
|
|
|
7576
7576
|
}
|
|
7577
7577
|
|
|
7578
7578
|
const template =
|
|
7579
|
-
_optionalChain$
|
|
7579
|
+
_optionalChain$f([config, 'access', _3 => _3.project, 'optionalAccess', _4 => _4.template]) || (await detectTemplateKey(projectFolder));
|
|
7580
7580
|
|
|
7581
7581
|
if (!template) {
|
|
7582
7582
|
logger.info('Patch skipped: template not detected');
|
|
7583
7583
|
return;
|
|
7584
7584
|
}
|
|
7585
7585
|
|
|
7586
|
-
const appliedPatches = [...(_optionalChain$
|
|
7587
|
-
const projectVersion = _optionalChain$
|
|
7586
|
+
const appliedPatches = [...(_optionalChain$f([config, 'access', _5 => _5.project, 'optionalAccess', _6 => _6.appliedPatches]) || [])];
|
|
7587
|
+
const projectVersion = _optionalChain$f([config, 'access', _7 => _7.project, 'optionalAccess', _8 => _8.version]);
|
|
7588
7588
|
const flags = await loadFlagsWithFallback();
|
|
7589
7589
|
|
|
7590
7590
|
const context = {
|
|
@@ -7687,14 +7687,14 @@ const registerCommand$5 = program => {
|
|
|
7687
7687
|
) => {
|
|
7688
7688
|
await executePatch({
|
|
7689
7689
|
directory,
|
|
7690
|
-
dryRun: _optionalChain$
|
|
7691
|
-
showFlags: _optionalChain$
|
|
7690
|
+
dryRun: _optionalChain$f([command, 'optionalAccess', _9 => _9.dryRun]),
|
|
7691
|
+
showFlags: _optionalChain$f([command, 'optionalAccess', _10 => _10.showFlags]),
|
|
7692
7692
|
});
|
|
7693
7693
|
},
|
|
7694
7694
|
);
|
|
7695
7695
|
};
|
|
7696
7696
|
|
|
7697
|
-
function _nullishCoalesce$4(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
7697
|
+
function _nullishCoalesce$4(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; }
|
|
7698
7698
|
const d$1 = debug('coze-init-cli:run');
|
|
7699
7699
|
|
|
7700
7700
|
/**
|
|
@@ -7825,12 +7825,12 @@ const executeRun = async (commandName, options = {}) => {
|
|
|
7825
7825
|
}
|
|
7826
7826
|
|
|
7827
7827
|
// 将输出同时写入控制台和日志文件
|
|
7828
|
-
_optionalChain$
|
|
7828
|
+
_optionalChain$e([childProcess, 'access', _ => _.stdout, 'optionalAccess', _2 => _2.on, 'call', _3 => _3('data', (data) => {
|
|
7829
7829
|
process.stdout.write(data);
|
|
7830
7830
|
logStream.write(data);
|
|
7831
7831
|
})]);
|
|
7832
7832
|
|
|
7833
|
-
_optionalChain$
|
|
7833
|
+
_optionalChain$e([childProcess, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6('data', (data) => {
|
|
7834
7834
|
process.stderr.write(data);
|
|
7835
7835
|
logStream.write(data);
|
|
7836
7836
|
})]);
|
|
@@ -8774,7 +8774,7 @@ const scanRoutesOnce = async (
|
|
|
8774
8774
|
}
|
|
8775
8775
|
};
|
|
8776
8776
|
|
|
8777
|
-
function _optionalChain$
|
|
8777
|
+
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; }// Route manifest generation command
|
|
8778
8778
|
|
|
8779
8779
|
|
|
8780
8780
|
const log = debug('coze:routes');
|
|
@@ -8875,7 +8875,7 @@ const registerCommand$3 = program => {
|
|
|
8875
8875
|
'Output file path (defaults to ~/.coze/routes.json)',
|
|
8876
8876
|
)
|
|
8877
8877
|
.action(async (directory, options) => {
|
|
8878
|
-
await executeRoutes({ directory, output: _optionalChain$
|
|
8878
|
+
await executeRoutes({ directory, output: _optionalChain$d([options, 'optionalAccess', _ => _.output]) });
|
|
8879
8879
|
});
|
|
8880
8880
|
};
|
|
8881
8881
|
|
|
@@ -10466,8 +10466,7 @@ const withRequestedApplicationType = (
|
|
|
10466
10466
|
};
|
|
10467
10467
|
};
|
|
10468
10468
|
|
|
10469
|
-
function _optionalChain$
|
|
10470
|
-
|
|
10469
|
+
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; }
|
|
10471
10470
|
const DEFAULT_CONFIG = {
|
|
10472
10471
|
apiBaseUrl: 'https://code.coze.cn/',
|
|
10473
10472
|
openApiBaseUrl: 'https://api.coze.cn',
|
|
@@ -10479,6 +10478,20 @@ const getSharedConfigPath = () =>
|
|
|
10479
10478
|
|
|
10480
10479
|
const getLegacyConfigPath = () => node_path.join(node_os.homedir(), '.coze', 'config.json');
|
|
10481
10480
|
|
|
10481
|
+
const getDesktopRuntimePaths = (
|
|
10482
|
+
|
|
10483
|
+
|
|
10484
|
+
) => [
|
|
10485
|
+
{
|
|
10486
|
+
path: node_path.join(node_os.homedir(), '.coze', 'desktop', 'runtime.beta.json'),
|
|
10487
|
+
source: 'desktop_beta',
|
|
10488
|
+
},
|
|
10489
|
+
{
|
|
10490
|
+
path: node_path.join(node_os.homedir(), '.coze', 'desktop', 'runtime.json'),
|
|
10491
|
+
source: 'desktop',
|
|
10492
|
+
},
|
|
10493
|
+
];
|
|
10494
|
+
|
|
10482
10495
|
const isRecord$3 = (value) =>
|
|
10483
10496
|
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
10484
10497
|
|
|
@@ -10494,28 +10507,63 @@ const readJson = async (path) => {
|
|
|
10494
10507
|
}
|
|
10495
10508
|
};
|
|
10496
10509
|
|
|
10510
|
+
const readDesktopAccessTokens = async () => {
|
|
10511
|
+
const candidates = [];
|
|
10512
|
+
for (const { path, source } of getDesktopRuntimePaths()) {
|
|
10513
|
+
try {
|
|
10514
|
+
const runtime = safeJsonParse(await promises.readFile(path, 'utf8'), undefined);
|
|
10515
|
+
if (!isRecord$3(runtime) || !isRecord$3(runtime.patToken)) {
|
|
10516
|
+
continue;
|
|
10517
|
+
}
|
|
10518
|
+
const {accessToken} = runtime.patToken;
|
|
10519
|
+
if (typeof accessToken === 'string' && accessToken.trim()) {
|
|
10520
|
+
candidates.push({ accessToken: accessToken.trim(), source });
|
|
10521
|
+
}
|
|
10522
|
+
} catch (error) {
|
|
10523
|
+
}
|
|
10524
|
+
}
|
|
10525
|
+
return candidates;
|
|
10526
|
+
};
|
|
10527
|
+
|
|
10497
10528
|
const configuredPath = (options) =>
|
|
10498
|
-
_optionalChain$
|
|
10529
|
+
_optionalChain$c([options, 'optionalAccess', _ => _.config]) || process.env.COZE_CONFIG_FILE;
|
|
10499
10530
|
|
|
10500
10531
|
const loadConfig = async (options = {}) => {
|
|
10501
10532
|
const customPath = configuredPath(options);
|
|
10502
10533
|
const globalConfig = customPath
|
|
10503
10534
|
? await readJson(node_path.resolve(customPath))
|
|
10504
10535
|
: (await readJson(getSharedConfigPath())) || (await readJson(getLegacyConfigPath()));
|
|
10505
|
-
const
|
|
10536
|
+
const fixedAccessTokenCandidates = await readDesktopAccessTokens();
|
|
10537
|
+
const environmentAccessToken = _optionalChain$c([process, 'access', _2 => _2.env, 'access', _3 => _3.COZE_API_TOKEN, 'optionalAccess', _4 => _4.trim, 'call', _5 => _5()]);
|
|
10538
|
+
if (environmentAccessToken) {
|
|
10539
|
+
fixedAccessTokenCandidates.push({
|
|
10540
|
+
accessToken: environmentAccessToken,
|
|
10541
|
+
source: 'environment',
|
|
10542
|
+
});
|
|
10543
|
+
}
|
|
10544
|
+
const fixedAccessToken = _optionalChain$c([fixedAccessTokenCandidates, 'access', _6 => _6[0], 'optionalAccess', _7 => _7.accessToken]);
|
|
10506
10545
|
const config = {
|
|
10507
10546
|
...DEFAULT_CONFIG,
|
|
10508
10547
|
...globalConfig,
|
|
10509
|
-
...(
|
|
10548
|
+
...(fixedAccessToken
|
|
10510
10549
|
? {
|
|
10511
|
-
accessToken:
|
|
10512
|
-
// COZE_API_TOKEN
|
|
10513
|
-
// refresh metadata
|
|
10550
|
+
accessToken: fixedAccessToken,
|
|
10551
|
+
// Desktop PAT and COZE_API_TOKEN are fixed runtime credentials. Never
|
|
10552
|
+
// combine them with refresh metadata from an earlier OAuth login.
|
|
10514
10553
|
refreshToken: undefined,
|
|
10515
10554
|
tokenExpiresAt: undefined,
|
|
10516
10555
|
}
|
|
10517
10556
|
: {}),
|
|
10557
|
+
fixedAccessTokenCandidates,
|
|
10558
|
+
oauthAccessToken:
|
|
10559
|
+
typeof _optionalChain$c([globalConfig, 'optionalAccess', _8 => _8.accessToken]) === 'string' ? globalConfig.accessToken : undefined,
|
|
10560
|
+
oauthRefreshToken:
|
|
10561
|
+
typeof _optionalChain$c([globalConfig, 'optionalAccess', _9 => _9.refreshToken]) === 'string' ? globalConfig.refreshToken : undefined,
|
|
10562
|
+
oauthTokenExpiresAt:
|
|
10563
|
+
typeof _optionalChain$c([globalConfig, 'optionalAccess', _10 => _10.tokenExpiresAt]) === 'number' ? globalConfig.tokenExpiresAt : undefined,
|
|
10564
|
+
fixedAccessTokenResolved: fixedAccessTokenCandidates.length === 0,
|
|
10518
10565
|
...(process.env.COZE_ORG_ID ? { organizationId: process.env.COZE_ORG_ID } : {}),
|
|
10566
|
+
...(process.env.COZE_ACCOUNT_ID ? { cozeAccountId: process.env.COZE_ACCOUNT_ID } : {}),
|
|
10519
10567
|
...(process.env.COZE_SPACE_ID ? { spaceId: process.env.COZE_SPACE_ID } : {}),
|
|
10520
10568
|
...(process.env.COZE_PROJECT_ID ? { projectId: process.env.COZE_PROJECT_ID } : {}),
|
|
10521
10569
|
...(options.orgId ? { organizationId: options.orgId } : {}),
|
|
@@ -10523,7 +10571,7 @@ const loadConfig = async (options = {}) => {
|
|
|
10523
10571
|
...(options.apiBaseUrl ? { apiBaseUrl: options.apiBaseUrl } : {}),
|
|
10524
10572
|
// Runtime-only trust decision: a value persisted in config.json must never enable
|
|
10525
10573
|
// project-secret injection for an OAuth access token.
|
|
10526
|
-
injectApiToken: Boolean(
|
|
10574
|
+
injectApiToken: Boolean(fixedAccessToken),
|
|
10527
10575
|
};
|
|
10528
10576
|
return config;
|
|
10529
10577
|
};
|
|
@@ -10547,7 +10595,10 @@ const saveSharedConfig = async (
|
|
|
10547
10595
|
}
|
|
10548
10596
|
};
|
|
10549
10597
|
|
|
10598
|
+
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; }
|
|
10599
|
+
|
|
10550
10600
|
const FIVE_MINUTES = 5 * 60 * 1000;
|
|
10601
|
+
const HTTP_UNAUTHORIZED = 401;
|
|
10551
10602
|
|
|
10552
10603
|
|
|
10553
10604
|
|
|
@@ -10572,6 +10623,54 @@ const parseJson = async (response) => {
|
|
|
10572
10623
|
const isRecord$2 = (value) =>
|
|
10573
10624
|
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
10574
10625
|
|
|
10626
|
+
const validateFixedAccessToken = async (
|
|
10627
|
+
accessToken,
|
|
10628
|
+
config,
|
|
10629
|
+
) => {
|
|
10630
|
+
const response = await fetch(new URL('/v1/users/me', config.openApiBaseUrl), {
|
|
10631
|
+
headers: { authorization: `Bearer ${accessToken}` },
|
|
10632
|
+
});
|
|
10633
|
+
const payload = await parseJson(response);
|
|
10634
|
+
if (response.ok) {
|
|
10635
|
+
return true;
|
|
10636
|
+
}
|
|
10637
|
+
if (response.status === HTTP_UNAUTHORIZED) {
|
|
10638
|
+
return false;
|
|
10639
|
+
}
|
|
10640
|
+
throw new CliError(
|
|
10641
|
+
typeof payload.msg === 'string'
|
|
10642
|
+
? payload.msg
|
|
10643
|
+
: 'Unable to validate the current login.',
|
|
10644
|
+
'AUTH_STATUS_FAILED',
|
|
10645
|
+
{ status: response.status },
|
|
10646
|
+
);
|
|
10647
|
+
};
|
|
10648
|
+
|
|
10649
|
+
const resolveFixedAccessToken = async (config) => {
|
|
10650
|
+
if (
|
|
10651
|
+
config.fixedAccessTokenResolved ||
|
|
10652
|
+
!_optionalChain$b([config, 'access', _ => _.fixedAccessTokenCandidates, 'optionalAccess', _2 => _2.length])
|
|
10653
|
+
) {
|
|
10654
|
+
config.fixedAccessTokenResolved = true;
|
|
10655
|
+
return;
|
|
10656
|
+
}
|
|
10657
|
+
for (const candidate of config.fixedAccessTokenCandidates || []) {
|
|
10658
|
+
if (await validateFixedAccessToken(candidate.accessToken, config)) {
|
|
10659
|
+
config.accessToken = candidate.accessToken;
|
|
10660
|
+
config.refreshToken = undefined;
|
|
10661
|
+
config.tokenExpiresAt = undefined;
|
|
10662
|
+
config.injectApiToken = true;
|
|
10663
|
+
config.fixedAccessTokenResolved = true;
|
|
10664
|
+
return;
|
|
10665
|
+
}
|
|
10666
|
+
}
|
|
10667
|
+
config.accessToken = config.oauthAccessToken;
|
|
10668
|
+
config.refreshToken = config.oauthRefreshToken;
|
|
10669
|
+
config.tokenExpiresAt = config.oauthTokenExpiresAt;
|
|
10670
|
+
config.injectApiToken = false;
|
|
10671
|
+
config.fixedAccessTokenResolved = true;
|
|
10672
|
+
};
|
|
10673
|
+
|
|
10575
10674
|
const getCurrentUser = async (
|
|
10576
10675
|
config,
|
|
10577
10676
|
options,
|
|
@@ -10586,7 +10685,7 @@ const getCurrentUser = async (
|
|
|
10586
10685
|
typeof payload.msg === 'string'
|
|
10587
10686
|
? payload.msg
|
|
10588
10687
|
: 'Unable to validate the current login. Run `coze-dev deploy auth login` again.',
|
|
10589
|
-
response.status ===
|
|
10688
|
+
response.status === HTTP_UNAUTHORIZED ? 'AUTH_REQUIRED' : 'AUTH_STATUS_FAILED',
|
|
10590
10689
|
{ status: response.status },
|
|
10591
10690
|
);
|
|
10592
10691
|
}
|
|
@@ -10607,6 +10706,7 @@ const getAccessToken = async (
|
|
|
10607
10706
|
config,
|
|
10608
10707
|
options,
|
|
10609
10708
|
) => {
|
|
10709
|
+
await resolveFixedAccessToken(config);
|
|
10610
10710
|
if (!config.accessToken) {
|
|
10611
10711
|
throw new CliError(
|
|
10612
10712
|
'No shared login found. Run `coze-dev deploy auth login` first.',
|
|
@@ -10849,7 +10949,7 @@ const loginWithOAuth = async (
|
|
|
10849
10949
|
await saveOAuthToken(config, options, await pollToken(config, deviceCode));
|
|
10850
10950
|
};
|
|
10851
10951
|
|
|
10852
|
-
function _optionalChain$
|
|
10952
|
+
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; }
|
|
10853
10953
|
|
|
10854
10954
|
|
|
10855
10955
|
|
|
@@ -10915,10 +11015,10 @@ const unwrap = (
|
|
|
10915
11015
|
responseMetadata,
|
|
10916
11016
|
) => {
|
|
10917
11017
|
const root = isRecord(payload) ? payload : undefined;
|
|
10918
|
-
const first = isRecord(_optionalChain$
|
|
10919
|
-
const second = isRecord(_optionalChain$
|
|
11018
|
+
const first = isRecord(_optionalChain$a([root, 'optionalAccess', _ => _.data])) ? root.data : undefined;
|
|
11019
|
+
const second = isRecord(_optionalChain$a([first, 'optionalAccess', _2 => _2.data])) ? first.data : undefined;
|
|
10920
11020
|
const envelope = [root, first].find(candidate => candidate && 'code' in candidate);
|
|
10921
|
-
if (_optionalChain$
|
|
11021
|
+
if (_optionalChain$a([envelope, 'optionalAccess', _3 => _3.code]) !== undefined && Number(envelope.code) !== 0) {
|
|
10922
11022
|
throw new CliError(
|
|
10923
11023
|
typeof envelope.msg === 'string'
|
|
10924
11024
|
? envelope.msg.slice(0, MAX_MESSAGE_LENGTH)
|
|
@@ -10967,8 +11067,8 @@ class DeployApiClient {
|
|
|
10967
11067
|
'agw-js-conv': 'str',
|
|
10968
11068
|
'x-request-from-coze-cli': '1',
|
|
10969
11069
|
};
|
|
10970
|
-
// Only
|
|
10971
|
-
//
|
|
11070
|
+
// Only a fixed runtime credential (desktop PAT or COZE_API_TOKEN) may become
|
|
11071
|
+
// a project runtime secret. OAuth credentials remain authentication-only.
|
|
10972
11072
|
if (
|
|
10973
11073
|
this.config.injectApiToken &&
|
|
10974
11074
|
path === '/deploy_history/create' &&
|
|
@@ -10976,10 +11076,13 @@ class DeployApiClient {
|
|
|
10976
11076
|
) {
|
|
10977
11077
|
headers['x-coze-deploy-inject-api-token'] = 'true';
|
|
10978
11078
|
}
|
|
10979
|
-
|
|
10980
|
-
|
|
11079
|
+
// Coze account id: an explicit COZE_ACCOUNT_ID (config.cozeAccountId) always wins;
|
|
11080
|
+
// otherwise fall back to the organization id resolved from login/config.
|
|
11081
|
+
const cozeAccount = this.config.cozeAccountId || this.config.organizationId;
|
|
11082
|
+
if (cozeAccount) {
|
|
11083
|
+
headers['x-coze-account'] = cozeAccount;
|
|
10981
11084
|
}
|
|
10982
|
-
const lane = _optionalChain$
|
|
11085
|
+
const lane = _optionalChain$a([this, 'access', _4 => _4.globalOptions, 'access', _5 => _5.lane, 'optionalAccess', _6 => _6.trim, 'call', _7 => _7()]) || _optionalChain$a([this, 'access', _8 => _8.config, 'access', _9 => _9.xTTEnv, 'optionalAccess', _10 => _10.trim, 'call', _11 => _11()]);
|
|
10983
11086
|
if (lane) {
|
|
10984
11087
|
headers['x-use-ppe'] = '1';
|
|
10985
11088
|
headers['x-tt-env'] = lane;
|
|
@@ -11010,7 +11113,7 @@ class DeployApiClient {
|
|
|
11010
11113
|
if (!response.ok) {
|
|
11011
11114
|
const root = isRecord(payload) ? payload : undefined;
|
|
11012
11115
|
throw new CliError(
|
|
11013
|
-
typeof _optionalChain$
|
|
11116
|
+
typeof _optionalChain$a([root, 'optionalAccess', _12 => _12.msg]) === 'string'
|
|
11014
11117
|
? root.msg.slice(0, MAX_MESSAGE_LENGTH)
|
|
11015
11118
|
: `Deployment API failed: ${response.status} ${response.statusText}` +
|
|
11016
11119
|
`${validJson ? '' : '; response was not JSON'}`,
|
|
@@ -11043,6 +11146,17 @@ class DeployApiClient {
|
|
|
11043
11146
|
);
|
|
11044
11147
|
}
|
|
11045
11148
|
|
|
11149
|
+
// 回读当前登录态对应的 Coze 账号 id。无入参:账号由服务端从登录态解析(X-Coze-Account →
|
|
11150
|
+
// access token → 兜底登录用户),客户端传什么都只有「等于登录态」一种合法取值。
|
|
11151
|
+
// 只在建 Project 前用一次,用来定这个 Project 下应用的账号归属。
|
|
11152
|
+
getCozeAccount() {
|
|
11153
|
+
return this.post(
|
|
11154
|
+
'/account/get',
|
|
11155
|
+
{},
|
|
11156
|
+
'coze_account_id',
|
|
11157
|
+
);
|
|
11158
|
+
}
|
|
11159
|
+
|
|
11046
11160
|
listSpaces(body
|
|
11047
11161
|
|
|
11048
11162
|
|
|
@@ -11235,6 +11349,7 @@ class DeployApiClient {
|
|
|
11235
11349
|
|
|
11236
11350
|
|
|
11237
11351
|
|
|
11352
|
+
|
|
11238
11353
|
) {
|
|
11239
11354
|
return this.post
|
|
11240
11355
|
|
|
@@ -11477,7 +11592,7 @@ const registerDoctor = (program) => {
|
|
|
11477
11592
|
});
|
|
11478
11593
|
};
|
|
11479
11594
|
|
|
11480
|
-
function _optionalChain$
|
|
11595
|
+
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; }
|
|
11481
11596
|
|
|
11482
11597
|
|
|
11483
11598
|
|
|
@@ -11508,13 +11623,66 @@ function _optionalChain$8(ops) { let lastAccessLHS = undefined; let value = ops[
|
|
|
11508
11623
|
|
|
11509
11624
|
|
|
11510
11625
|
const getDeployParentOptions = (command) =>
|
|
11511
|
-
_optionalChain$
|
|
11626
|
+
_optionalChain$9([command, 'access', _ => _.parent, 'optionalAccess', _2 => _2.opts, 'call', _3 => _3()]) || {};
|
|
11512
11627
|
|
|
11513
11628
|
const getDeployAppIdOption = (
|
|
11514
11629
|
options,
|
|
11515
11630
|
command,
|
|
11516
11631
|
) => options.appId || getDeployParentOptions(command).appId;
|
|
11517
11632
|
|
|
11633
|
+
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; } async function _asyncOptionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
11634
|
+
|
|
11635
|
+
const isAccountId = (value) => /^[1-9]\d*$/u.test(value);
|
|
11636
|
+
|
|
11637
|
+
/**
|
|
11638
|
+
* 定出这个 Project 下的应用该归属哪个 Coze 账号,写进 project_settings.extra.coze_account_id。
|
|
11639
|
+
*
|
|
11640
|
+
* 优先级(与 api-client 里 x-coze-account 的取值顺序一致,不另立一套口径):
|
|
11641
|
+
* 1. COZE_ACCOUNT_ID(config.cozeAccountId)—— 用户显式指定
|
|
11642
|
+
* 2. COZE_ORG_ID / --org-id(config.organizationId)—— 用户显式指定组织
|
|
11643
|
+
* 3. 登录态回读(deploy v2 account/get)
|
|
11644
|
+
*
|
|
11645
|
+
* ⚠️ 1、2 命中时**不打接口**:本地已经知道账号了,再问一次服务端只是多一个 RTT 和一个失败点。
|
|
11646
|
+
*
|
|
11647
|
+
* 拿不到就返回 undefined(不写 extra),部署照常继续:服务端在 deploy_history/create 里仍会
|
|
11648
|
+
* 按同一条阶梯解析账号,结果与不加这段逻辑时完全一致 —— 只是无登录态的预览初始化那条链路
|
|
11649
|
+
* 少了 Project 上这份归属记录。这是一个辅助接口,不该成为首次部署的单点。
|
|
11650
|
+
*/
|
|
11651
|
+
const resolveCozeAccountId = async (
|
|
11652
|
+
runtime,
|
|
11653
|
+
) => {
|
|
11654
|
+
const configured =
|
|
11655
|
+
_optionalChain$8([runtime, 'access', _ => _.config, 'access', _2 => _2.cozeAccountId, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]) || _optionalChain$8([runtime, 'access', _5 => _5.config, 'access', _6 => _6.organizationId, 'optionalAccess', _7 => _7.trim, 'call', _8 => _8()]);
|
|
11656
|
+
if (configured) {
|
|
11657
|
+
if (!isAccountId(configured)) {
|
|
11658
|
+
// 不把非法值写进 Project —— 它会被服务端当成「明确但损坏的归属」直接报错。
|
|
11659
|
+
// 该值仍会作为 x-coze-account 发出去,由服务端给出明确的参数错误。
|
|
11660
|
+
runtime.output.debug(
|
|
11661
|
+
`[deploy] Ignoring malformed Coze account id for project settings: ${configured}`,
|
|
11662
|
+
);
|
|
11663
|
+
return undefined;
|
|
11664
|
+
}
|
|
11665
|
+
runtime.output.debug(`[deploy] Using configured Coze account ${configured}`);
|
|
11666
|
+
return configured;
|
|
11667
|
+
}
|
|
11668
|
+
try {
|
|
11669
|
+
const accountId = await _asyncOptionalChain$1([(await runtime.client.getCozeAccount()), 'access', async _9 => _9.coze_account_id, 'optionalAccess', async _10 => _10.trim, 'call', async _11 => _11()]);
|
|
11670
|
+
if (!accountId || !isAccountId(accountId)) {
|
|
11671
|
+
runtime.output.debug(
|
|
11672
|
+
`[deploy] Deployment API returned no usable Coze account id: ${String(accountId)}`,
|
|
11673
|
+
);
|
|
11674
|
+
return undefined;
|
|
11675
|
+
}
|
|
11676
|
+
runtime.output.debug(`[deploy] Resolved Coze account ${accountId} from the current login`);
|
|
11677
|
+
return accountId;
|
|
11678
|
+
} catch (error) {
|
|
11679
|
+
runtime.output.warn(
|
|
11680
|
+
`Unable to resolve the Coze account from the current login; the project will be created without an explicit account: ${String(error)}`,
|
|
11681
|
+
);
|
|
11682
|
+
return undefined;
|
|
11683
|
+
}
|
|
11684
|
+
};
|
|
11685
|
+
|
|
11518
11686
|
const getCreateDeployConfig = (config) => ({
|
|
11519
11687
|
deploy_config: {
|
|
11520
11688
|
cpu: config.deploy_config.cpu,
|
|
@@ -11548,16 +11716,27 @@ const STATUS_NAMES = {
|
|
|
11548
11716
|
[DEPLOY_STATUS.preDeploy]: 'WaitingForUpload',
|
|
11549
11717
|
};
|
|
11550
11718
|
|
|
11719
|
+
/**
|
|
11720
|
+
* 终态 = 不会再变了。
|
|
11721
|
+
*
|
|
11722
|
+
* ⚠️ `interrupted(6)` **不是**终态,别再往这里加。它是过程态:服务端某条流水线自身轮询超时时,
|
|
11723
|
+
* 会把整次部署标成 Interrupted 并安排稍后重新触发(`base_pipe.NewInterruptedResult`),之后仍
|
|
11724
|
+
* 会推进到 Succeeded。安卓构建 10 分钟起步,几乎必然经过至少一次 Interrupted —— 把它当终态会
|
|
11725
|
+
* 让 `deploy --wait` 在构建中途就收工返回,此时 APK 还没产出,`mobile_artifact_list` 是空的。
|
|
11726
|
+
*/
|
|
11551
11727
|
const TERMINAL_STATUSES = new Set([
|
|
11552
11728
|
DEPLOY_STATUS.succeeded,
|
|
11553
11729
|
DEPLOY_STATUS.failed,
|
|
11554
11730
|
DEPLOY_STATUS.canceled,
|
|
11555
|
-
DEPLOY_STATUS.interrupted,
|
|
11556
11731
|
]);
|
|
11557
11732
|
|
|
11558
11733
|
const getDeployStatusText = (status) =>
|
|
11559
11734
|
status ? STATUS_NAMES[status] || 'Unknown' : 'Unknown';
|
|
11560
11735
|
|
|
11736
|
+
/** 这次部署的结果是否已经定下来了(到了终态就不会再变)。 */
|
|
11737
|
+
const isDeploymentSettled = (status) =>
|
|
11738
|
+
status !== undefined && TERMINAL_STATUSES.has(status);
|
|
11739
|
+
|
|
11561
11740
|
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; }
|
|
11562
11741
|
|
|
11563
11742
|
const formatDeployDetails = (history) =>
|
|
@@ -11822,6 +12001,27 @@ const readDeployLocalContext = async (
|
|
|
11822
12001
|
return { ...sourceSnapshot, metadata, isPagesDeployment };
|
|
11823
12002
|
};
|
|
11824
12003
|
|
|
12004
|
+
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; }
|
|
12005
|
+
|
|
12006
|
+
/**
|
|
12007
|
+
* 把 `mobile_artifact_list` 连同「这个空数组到底什么意思」一起输出。
|
|
12008
|
+
*
|
|
12009
|
+
* 产物是部署过程中逐步落库的:APK 要等安卓构建跑完才写进去,比部署记录本身晚好几分钟。部署没到
|
|
12010
|
+
* 终态时,空的 `mobile_artifact_list` 只代表「还没产出来」,不代表「没有产物」—— 可这两种情况在
|
|
12011
|
+
* 输出里长得一模一样,调用方(尤其是 agent)会把前者读成后者,然后得出「部署成功但系统没返回
|
|
12012
|
+
* APK 下载地址」这种错误结论。线上真发生过。
|
|
12013
|
+
*
|
|
12014
|
+
* 所以未定终态时额外带一个 `artifacts_pending: true`;这个字段不出现,就表示这份列表已经是最终
|
|
12015
|
+
* 结果。`mobile_artifact_list` 本身保持恒存在,避免破坏已有脚本的读法。
|
|
12016
|
+
*/
|
|
12017
|
+
const mobileArtifactsOutput = (
|
|
12018
|
+
history,
|
|
12019
|
+
status = _optionalChain$4([history, 'optionalAccess', _ => _.status]),
|
|
12020
|
+
) => ({
|
|
12021
|
+
mobile_artifact_list: _optionalChain$4([history, 'optionalAccess', _2 => _2.mobile_artifact_list]) || [],
|
|
12022
|
+
...(isDeploymentSettled(status) ? {} : { artifacts_pending: true }),
|
|
12023
|
+
});
|
|
12024
|
+
|
|
11825
12025
|
// 服务端 deploy_app/list 的 page_size 上限,超了会被判参数错误。
|
|
11826
12026
|
// 客户端先拦一道,是为了把错误说在本地(带上上限值),而不是回一句服务端的通用参数错误。
|
|
11827
12027
|
const APP_LIST_MAX_PAGE_SIZE = 100;
|
|
@@ -11933,11 +12133,12 @@ const registerDeployReadCommands = (deploy) => {
|
|
|
11933
12133
|
deploy_history_id: deployHistoryId,
|
|
11934
12134
|
status: getDeployStatusText(history.status),
|
|
11935
12135
|
commit_hash: history.commit_hash,
|
|
12136
|
+
commit_message: history.commit_message,
|
|
11936
12137
|
domains: history.domain_list || [],
|
|
11937
12138
|
error_analysis: history.error_analysis,
|
|
11938
12139
|
deploy_detail: formatDeployDetails(history),
|
|
11939
12140
|
connector_data_list: history.connector_data_list || [],
|
|
11940
|
-
|
|
12141
|
+
...mobileArtifactsOutput(history),
|
|
11941
12142
|
});
|
|
11942
12143
|
});
|
|
11943
12144
|
|
|
@@ -11962,11 +12163,12 @@ const registerDeployReadCommands = (deploy) => {
|
|
|
11962
12163
|
deploy_history_id: item.deploy_history_id,
|
|
11963
12164
|
status: getDeployStatusText(item.status),
|
|
11964
12165
|
commit_hash: item.commit_hash_short || item.commit_hash,
|
|
12166
|
+
commit_message: item.commit_message,
|
|
11965
12167
|
created_at: item.created_at,
|
|
11966
12168
|
can_rollback: item.can_rollback,
|
|
11967
12169
|
deploy_detail: formatDeployDetails(item),
|
|
11968
12170
|
connector_data_list: item.connector_data_list || [],
|
|
11969
|
-
|
|
12171
|
+
...mobileArtifactsOutput(item),
|
|
11970
12172
|
})),
|
|
11971
12173
|
next_page_token: data.next_page_token,
|
|
11972
12174
|
has_more: data.has_more,
|
|
@@ -11987,10 +12189,11 @@ const registerDeployReadCommands = (deploy) => {
|
|
|
11987
12189
|
deploy_history_id: item.deploy_history_id,
|
|
11988
12190
|
status: getDeployStatusText(item.status),
|
|
11989
12191
|
commit_hash: item.commit_hash_short || item.commit_hash,
|
|
12192
|
+
commit_message: item.commit_message,
|
|
11990
12193
|
created_at: item.created_at,
|
|
11991
12194
|
deploy_detail: formatDeployDetails(item),
|
|
11992
12195
|
domains: item.domain_list || [],
|
|
11993
|
-
|
|
12196
|
+
...mobileArtifactsOutput(item),
|
|
11994
12197
|
})),
|
|
11995
12198
|
});
|
|
11996
12199
|
});
|
|
@@ -12142,7 +12345,7 @@ const createMiniProgramPackage = async (
|
|
|
12142
12345
|
}
|
|
12143
12346
|
};
|
|
12144
12347
|
|
|
12145
|
-
function _nullishCoalesce$1(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$
|
|
12348
|
+
function _nullishCoalesce$1(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$3(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
12146
12349
|
const CONNECTOR_IDS = {
|
|
12147
12350
|
wechat: '10000127',
|
|
12148
12351
|
douyin: '10000126',
|
|
@@ -12166,6 +12369,7 @@ const MINI_PROGRAM_BUILD_OUTPUT_DIRS = {
|
|
|
12166
12369
|
|
|
12167
12370
|
|
|
12168
12371
|
|
|
12372
|
+
|
|
12169
12373
|
const resolveConnectorId = (platform) => {
|
|
12170
12374
|
const connectorId = CONNECTOR_IDS[platform ];
|
|
12171
12375
|
if (!connectorId) {
|
|
@@ -12193,7 +12397,7 @@ const resolveProjectId = async (
|
|
|
12193
12397
|
command,
|
|
12194
12398
|
options,
|
|
12195
12399
|
) => {
|
|
12196
|
-
if (_optionalChain$
|
|
12400
|
+
if (_optionalChain$3([options, 'access', _ => _.projectId, 'optionalAccess', _2 => _2.trim, 'call', _3 => _3()])) {
|
|
12197
12401
|
return options.projectId.trim();
|
|
12198
12402
|
}
|
|
12199
12403
|
const runtime = await getRuntime(command);
|
|
@@ -12226,13 +12430,13 @@ const getBoundToOtherUserMessage = (platform) => {
|
|
|
12226
12430
|
};
|
|
12227
12431
|
|
|
12228
12432
|
const getAuthRequiredMessage = () =>
|
|
12229
|
-
'This Mini-program AppID is not authorized for the current Coze user. Run `coze-dev deploy
|
|
12433
|
+
'This Mini-program AppID is not authorized for the current Coze user. Run `coze-dev deploy mini-program auth` first.';
|
|
12230
12434
|
|
|
12231
12435
|
const getPreviewFailureMessage = (data
|
|
12232
12436
|
|
|
12233
12437
|
|
|
12234
12438
|
) =>
|
|
12235
|
-
_optionalChain$
|
|
12439
|
+
_optionalChain$3([data, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]) || _optionalChain$3([data, 'access', _7 => _7.stdout, 'optionalAccess', _8 => _8.trim, 'call', _9 => _9()]) || 'Mini-program preview failed.';
|
|
12236
12440
|
|
|
12237
12441
|
const registerAuthorizationCommand = (miniProgram) => {
|
|
12238
12442
|
miniProgram
|
|
@@ -12290,6 +12494,7 @@ const registerPreviewCommand = (miniProgram) => {
|
|
|
12290
12494
|
.requiredOption('--mini-app-id <miniAppId>', 'Mini-program AppID')
|
|
12291
12495
|
.option('--project-id <projectId>', 'Deployment Project ID')
|
|
12292
12496
|
.option('--source-root <sourceRoot>', 'Directory containing dist or dist-tt', '.')
|
|
12497
|
+
.option('--server-url <serverUrl>', 'Public HTTPS server URL to whitelist for this preview')
|
|
12293
12498
|
.action(async (options, command) => {
|
|
12294
12499
|
const runtime = await getRuntime(command);
|
|
12295
12500
|
const projectId = await resolveProjectId(command, options);
|
|
@@ -12319,6 +12524,7 @@ const registerPreviewCommand = (miniProgram) => {
|
|
|
12319
12524
|
app_id: options.miniAppId || '',
|
|
12320
12525
|
connector_id: resolveConnectorId(options.platform),
|
|
12321
12526
|
source_package_base64: content.toString('base64'),
|
|
12527
|
+
...(options.serverUrl ? { server_url: options.serverUrl } : {}),
|
|
12322
12528
|
});
|
|
12323
12529
|
if (data.failed) {
|
|
12324
12530
|
throw new CliError(
|
|
@@ -12428,11 +12634,21 @@ const registerMiniProgram = (code) => {
|
|
|
12428
12634
|
registerPreviewCommand(miniProgram);
|
|
12429
12635
|
};
|
|
12430
12636
|
|
|
12431
|
-
function _optionalChain$
|
|
12637
|
+
function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
12432
12638
|
|
|
12433
12639
|
const POLL_INTERVAL_MS = 3000;
|
|
12434
12640
|
const MAX_CONSECUTIVE_RETRIES = 5;
|
|
12435
12641
|
const TRANSIENT_RPC_ERROR_CODE = 230000001;
|
|
12642
|
+
/**
|
|
12643
|
+
* `--wait` 的总时长上限。
|
|
12644
|
+
*
|
|
12645
|
+
* Interrupted 不再算终态(见 status.ts),轮询只能靠这个兜底,否则一次卡住的部署会把 CLI
|
|
12646
|
+
* 永远挂在这里。取 60min 是照安卓构建定的:实测 10 分钟起步,中途还会经历若干次
|
|
12647
|
+
* Interrupted → 重新触发。
|
|
12648
|
+
*/
|
|
12649
|
+
const POLL_TIMEOUT_MS = 3600000; // 60min
|
|
12650
|
+
/** 心跳间隔:text 模式下每隔这么久报一次「还在跑」,免得长构建看起来像挂死。 */
|
|
12651
|
+
const HEARTBEAT_MS = 30000;
|
|
12436
12652
|
|
|
12437
12653
|
const wait = async () =>
|
|
12438
12654
|
new Promise(resolve => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
@@ -12440,17 +12656,21 @@ const wait = async () =>
|
|
|
12440
12656
|
const isRetryablePollError = (error) =>
|
|
12441
12657
|
error instanceof CliError &&
|
|
12442
12658
|
error.code === 'API_REJECTED' &&
|
|
12443
|
-
Number(_optionalChain$
|
|
12659
|
+
Number(_optionalChain$2([error, 'access', _ => _.details, 'optionalAccess', _2 => _2.business_code])) === TRANSIENT_RPC_ERROR_CODE;
|
|
12444
12660
|
|
|
12445
12661
|
const pollHistory = async (
|
|
12446
12662
|
command,
|
|
12447
12663
|
appId,
|
|
12448
12664
|
deployHistoryId,
|
|
12665
|
+
timeoutMs = POLL_TIMEOUT_MS,
|
|
12449
12666
|
) => {
|
|
12450
12667
|
const runtime = await getRuntime(command);
|
|
12451
12668
|
const startedAt = Date.now();
|
|
12452
12669
|
let consecutiveFailures = 0;
|
|
12670
|
+
let lastStatus;
|
|
12671
|
+
let lastBeatAt = startedAt;
|
|
12453
12672
|
while (true) {
|
|
12673
|
+
const elapsed = () => Math.floor((Date.now() - startedAt) / 1000);
|
|
12454
12674
|
try {
|
|
12455
12675
|
const history = await runtime.client.getDeployHistory({
|
|
12456
12676
|
app_id: appId,
|
|
@@ -12459,11 +12679,21 @@ const pollHistory = async (
|
|
|
12459
12679
|
consecutiveFailures = 0;
|
|
12460
12680
|
const status = getDeployStatusText(history.status);
|
|
12461
12681
|
runtime.output.debug(
|
|
12462
|
-
`[deploy] History ${deployHistoryId}: ${status} (${String(
|
|
12682
|
+
`[deploy] History ${deployHistoryId}: ${status} (${String(elapsed())}s elapsed)`,
|
|
12463
12683
|
);
|
|
12464
12684
|
if (history.status && TERMINAL_STATUSES.has(history.status)) {
|
|
12465
12685
|
return history;
|
|
12466
12686
|
}
|
|
12687
|
+
// 长构建(安卓十几分钟)期间给点动静:状态一变就报,否则每 30s 报一次还活着。
|
|
12688
|
+
// output.info 只在 text 模式写 stderr,json 模式是 no-op,不会污染机器可读输出。
|
|
12689
|
+
if (history.status !== lastStatus) {
|
|
12690
|
+
lastStatus = history.status;
|
|
12691
|
+
lastBeatAt = Date.now();
|
|
12692
|
+
runtime.output.info(`[deploy] ${status} (${String(elapsed())}s)`);
|
|
12693
|
+
} else if (Date.now() - lastBeatAt >= HEARTBEAT_MS) {
|
|
12694
|
+
lastBeatAt = Date.now();
|
|
12695
|
+
runtime.output.info(`[deploy] still ${status} (${String(elapsed())}s)`);
|
|
12696
|
+
}
|
|
12467
12697
|
} catch (error) {
|
|
12468
12698
|
if (!isRetryablePollError(error) || consecutiveFailures >= MAX_CONSECUTIVE_RETRIES) {
|
|
12469
12699
|
throw error;
|
|
@@ -12473,6 +12703,15 @@ const pollHistory = async (
|
|
|
12473
12703
|
`[deploy] Status check failed transiently; retrying (${String(consecutiveFailures)}/${String(MAX_CONSECUTIVE_RETRIES)}).`,
|
|
12474
12704
|
);
|
|
12475
12705
|
}
|
|
12706
|
+
if (Date.now() - startedAt >= timeoutMs) {
|
|
12707
|
+
throw new CliError(
|
|
12708
|
+
`Timed out after ${String(elapsed())}s waiting for deployment ${deployHistoryId}; ` +
|
|
12709
|
+
`last status: ${getDeployStatusText(lastStatus)}. The deployment may still be running — ` +
|
|
12710
|
+
'check it with `coze-dev deploy status`.',
|
|
12711
|
+
'DEPLOY_WAIT_TIMEOUT',
|
|
12712
|
+
{ app_id: appId, deploy_history_id: deployHistoryId, last_status: lastStatus },
|
|
12713
|
+
);
|
|
12714
|
+
}
|
|
12476
12715
|
await wait();
|
|
12477
12716
|
}
|
|
12478
12717
|
};
|
|
@@ -12819,52 +13058,6 @@ const registerDomain = (code) => {
|
|
|
12819
13058
|
});
|
|
12820
13059
|
};
|
|
12821
13060
|
|
|
12822
|
-
function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
12823
|
-
|
|
12824
|
-
const firstPage = { page: 1, size: 1 };
|
|
12825
|
-
|
|
12826
|
-
const listSpaceRequest = (runtime) => ({
|
|
12827
|
-
...(runtime.config.organizationId
|
|
12828
|
-
? { organization_id: runtime.config.organizationId }
|
|
12829
|
-
: {}),
|
|
12830
|
-
...(runtime.config.enterpriseId
|
|
12831
|
-
? { enterprise_id: runtime.config.enterpriseId }
|
|
12832
|
-
: {}),
|
|
12833
|
-
});
|
|
12834
|
-
|
|
12835
|
-
const resolveDeploymentSpaceId = async (runtime) => {
|
|
12836
|
-
const configuredSpaceId = _optionalChain$2([runtime, 'access', _ => _.config, 'access', _2 => _2.spaceId, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]);
|
|
12837
|
-
const request = listSpaceRequest(runtime);
|
|
12838
|
-
if (configuredSpaceId) {
|
|
12839
|
-
const data = await runtime.client.listSpaces(request);
|
|
12840
|
-
if (!data.bot_space_list.some(space => space.id === configuredSpaceId)) {
|
|
12841
|
-
throw new CliError(
|
|
12842
|
-
`Space ID ${configuredSpaceId} is invalid or is not available to the current account.`,
|
|
12843
|
-
'INVALID_SPACE_ID',
|
|
12844
|
-
);
|
|
12845
|
-
}
|
|
12846
|
-
return configuredSpaceId;
|
|
12847
|
-
}
|
|
12848
|
-
|
|
12849
|
-
const data = await runtime.client.listSpaces({ ...request, ...firstPage });
|
|
12850
|
-
const space = data.bot_space_list.find(item => item.id);
|
|
12851
|
-
if (!space) {
|
|
12852
|
-
throw new CliError(
|
|
12853
|
-
'No available Space was found for the current account. Create or join a Space before deploying.',
|
|
12854
|
-
'SPACE_NOT_FOUND',
|
|
12855
|
-
);
|
|
12856
|
-
}
|
|
12857
|
-
|
|
12858
|
-
runtime.config.spaceId = space.id;
|
|
12859
|
-
try {
|
|
12860
|
-
await saveSharedConfig({ spaceId: space.id }, runtime.globalOptions);
|
|
12861
|
-
} catch (error) {
|
|
12862
|
-
runtime.output.warn(`Unable to save the auto-selected Space: ${String(error)}`);
|
|
12863
|
-
}
|
|
12864
|
-
runtime.output.debug(`Auto-selected Space: ${space.name || space.id} (${space.id})`);
|
|
12865
|
-
return space.id;
|
|
12866
|
-
};
|
|
12867
|
-
|
|
12868
13061
|
const PACKAGE_SCRIPT_CANDIDATES = [
|
|
12869
13062
|
node_path.resolve(__dirname, 'deploy/package-project.js'),
|
|
12870
13063
|
node_path.resolve(__dirname, '../../../scripts/deploy/package-project.js'),
|
|
@@ -13161,9 +13354,8 @@ const getConnectorConfigs = (connectorIds) =>
|
|
|
13161
13354
|
|
|
13162
13355
|
// Keep deployment option and output contracts together for auditing against the V2 IDL.
|
|
13163
13356
|
// eslint-disable-next-line @coze-arch/max-line-per-function -- keep V2 deployment contracts together
|
|
13164
|
-
const registerDeploy = (
|
|
13165
|
-
|
|
13166
|
-
.command('deploy')
|
|
13357
|
+
const registerDeploy = (deploy) => {
|
|
13358
|
+
deploy
|
|
13167
13359
|
.description('Deploy an application using deployment V2')
|
|
13168
13360
|
.option('--source-root <sourceRoot>', 'Local source root', '.')
|
|
13169
13361
|
.option('--project-id <projectId>', 'Project ID for the first deployment')
|
|
@@ -13236,14 +13428,21 @@ const registerDeploy = (code) => {
|
|
|
13236
13428
|
}
|
|
13237
13429
|
}
|
|
13238
13430
|
if (!projectId) {
|
|
13239
|
-
runtime.output.debug(
|
|
13240
|
-
|
|
13431
|
+
runtime.output.debug(
|
|
13432
|
+
'[deploy] Creating a dedicated deployment project in personal space...',
|
|
13433
|
+
);
|
|
13434
|
+
// 账号归属只在建 Project 这一次定死:写进 project_settings.extra 之后,有登录态的首次
|
|
13435
|
+
// 部署和无登录态的预览初始化读到的是同一个账号。本地已经知道账号就不打这次接口。
|
|
13436
|
+
const cozeAccountId = await resolveCozeAccountId(runtime);
|
|
13241
13437
|
const project = await runtime.client.createDeploymentProject({
|
|
13242
|
-
space_id:
|
|
13438
|
+
space_id: '0',
|
|
13243
13439
|
user_query: deploymentName || 'CLI deployment project',
|
|
13244
13440
|
project_type: resolveCreationProjectType(metadata.projectType),
|
|
13245
13441
|
create_source: 'cli',
|
|
13246
|
-
project_settings: {
|
|
13442
|
+
project_settings: {
|
|
13443
|
+
project_symbol: 'v3.5',
|
|
13444
|
+
...(cozeAccountId ? { extra: { coze_account_id: cozeAccountId } } : {}),
|
|
13445
|
+
},
|
|
13247
13446
|
});
|
|
13248
13447
|
projectId = project.project_id;
|
|
13249
13448
|
projectCreated = true;
|
|
@@ -13332,6 +13531,7 @@ const registerDeploy = (code) => {
|
|
|
13332
13531
|
...(appId ? { app_id: appId } : { project_id: projectId }),
|
|
13333
13532
|
application_type: applicationType,
|
|
13334
13533
|
commit_hash: commitHash,
|
|
13534
|
+
...(options.message ? { commit_message: options.message } : {}),
|
|
13335
13535
|
...(!appId
|
|
13336
13536
|
? { name: deploymentName, source_root: sourceRoot }
|
|
13337
13537
|
: {}),
|
|
@@ -13375,16 +13575,19 @@ const registerDeploy = (code) => {
|
|
|
13375
13575
|
const history = options.wait
|
|
13376
13576
|
? await pollHistory(command, result.app_id, deployHistoryId)
|
|
13377
13577
|
: undefined;
|
|
13578
|
+
// 不带 --wait 时 history 是 undefined,产物必然还没落库:这里一定会带上
|
|
13579
|
+
// artifacts_pending,而不是甩一个看起来像「查过了,没有」的空数组出去。
|
|
13580
|
+
const effectiveStatus = _nullishCoalesce(_optionalChain([history, 'optionalAccess', _2 => _2.status]), () => ( result.status));
|
|
13378
13581
|
runtime.output.print({
|
|
13379
13582
|
app_id: result.app_id,
|
|
13380
13583
|
deploy_history_id: deployHistoryId,
|
|
13381
13584
|
version: result.version,
|
|
13382
13585
|
commit_hash: commitHash,
|
|
13383
|
-
status: getDeployStatusText(
|
|
13586
|
+
status: getDeployStatusText(effectiveStatus),
|
|
13384
13587
|
source_package_size_bytes: sourcePackage.sizeBytes,
|
|
13385
13588
|
upload_mode: deployment.uploadMode,
|
|
13386
13589
|
local_link: appId && !projectCreated ? 'unchanged' : 'written',
|
|
13387
|
-
|
|
13590
|
+
...mobileArtifactsOutput(history, effectiveStatus),
|
|
13388
13591
|
});
|
|
13389
13592
|
});
|
|
13390
13593
|
|
|
@@ -13487,7 +13690,7 @@ const registerDeploy = (code) => {
|
|
|
13487
13690
|
.action(async (options, command) => {
|
|
13488
13691
|
const runtime = await getRuntime(command);
|
|
13489
13692
|
const appId = await requireAppId(runtime.cwd, getDeployAppIdOption(options, command));
|
|
13490
|
-
let key = _optionalChain([options, 'access',
|
|
13693
|
+
let key = _optionalChain([options, 'access', _3 => _3.key, 'optionalAccess', _4 => _4.trim, 'call', _5 => _5()]);
|
|
13491
13694
|
if (!key) {
|
|
13492
13695
|
const history = await runtime.client.getDeployHistory({
|
|
13493
13696
|
app_id: appId,
|
|
@@ -13529,7 +13732,7 @@ const registerDeploy = (code) => {
|
|
|
13529
13732
|
const runtime = await getRuntime(command);
|
|
13530
13733
|
const appId = await requireAppId(runtime.cwd, getDeployAppIdOption(options, command));
|
|
13531
13734
|
const application = await runtime.client.getApplication(appId);
|
|
13532
|
-
const commitHash = options.commitId || _optionalChain([application, 'access',
|
|
13735
|
+
const commitHash = options.commitId || _optionalChain([application, 'access', _6 => _6.latest_deployment, 'optionalAccess', _7 => _7.commit_hash]);
|
|
13533
13736
|
if (!commitHash) {
|
|
13534
13737
|
throw new CliError('No deployment commit is available.', 'DEPLOYMENT_NOT_FOUND');
|
|
13535
13738
|
}
|
|
@@ -13552,9 +13755,20 @@ const registerCommands = (program) => {
|
|
|
13552
13755
|
registerAuth(program);
|
|
13553
13756
|
registerContext(program);
|
|
13554
13757
|
registerDoctor(program);
|
|
13555
|
-
|
|
13758
|
+
|
|
13759
|
+
// Keep deployment operations directly under `coze-dev deploy` so the common
|
|
13760
|
+
// path is concise: `coze-dev deploy`, `coze-dev deploy status`, etc.
|
|
13761
|
+
registerDeploy(program);
|
|
13762
|
+
registerApp(program);
|
|
13763
|
+
registerDomain(program);
|
|
13764
|
+
registerEnv(program);
|
|
13765
|
+
registerMiniProgram(program);
|
|
13766
|
+
|
|
13767
|
+
// Preserve the original `coze-dev deploy code ...` hierarchy for scripts and
|
|
13768
|
+
// older plugin versions that still rely on it.
|
|
13769
|
+
const code = program.command('code', { hidden: true }).description('Legacy deployment operations');
|
|
13556
13770
|
registerApp(code);
|
|
13557
|
-
registerDeploy(code);
|
|
13771
|
+
registerDeploy(code.command('deploy'));
|
|
13558
13772
|
registerDomain(code);
|
|
13559
13773
|
registerEnv(code);
|
|
13560
13774
|
registerMiniProgram(code);
|
|
@@ -13563,6 +13777,7 @@ const registerCommands = (program) => {
|
|
|
13563
13777
|
const configureDeployCommand = (command) => {
|
|
13564
13778
|
markDeployCommand(command)
|
|
13565
13779
|
.description('Deploy and manage Coze applications')
|
|
13780
|
+
.enablePositionalOptions()
|
|
13566
13781
|
.option('--format <format>', 'Output format: json or text', 'json')
|
|
13567
13782
|
.option('--config <path>', 'Shared Coze CLI config path')
|
|
13568
13783
|
.option('--org-id <id>', 'Override organization ID')
|