@coze-arch/cli 0.0.36-alpha.0a210b → 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 +68 -114
- package/docs/deploy.md +57 -40
- package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +38 -4
- package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +1 -1
- package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +1 -1
- package/lib/__templates__/expo/client/metro.config.js +3 -1
- package/lib/__templates__/expo/pnpm-lock.yaml +5 -5
- package/lib/__templates__/expo/server/package.json +2 -2
- package/lib/__templates__/expo/server/src/index.ts +1 -1
- package/lib/__templates__/expo/template.config.js +11 -2
- package/lib/__templates__/native-static/.coze +2 -0
- package/lib/__templates__/native-static/scripts/serve.ps1 +7 -0
- package/lib/__templates__/nextjs/.coze +5 -0
- package/lib/__templates__/nextjs/package.json +3 -3
- package/lib/__templates__/nextjs/pnpm-lock.yaml +513 -9
- package/lib/__templates__/nextjs/scripts/build.ps1 +16 -0
- package/lib/__templates__/nextjs/scripts/dev.ps1 +63 -0
- package/lib/__templates__/nextjs/scripts/dev.sh +230 -13
- package/lib/__templates__/nextjs/scripts/prepare.ps1 +18 -0
- package/lib/__templates__/nextjs/scripts/start.ps1 +11 -0
- package/lib/__templates__/nextjs/scripts/validate.ps1 +8 -0
- package/lib/__templates__/nextjs/template.config.js +1 -1
- package/lib/__templates__/nuxt-vue/.coze +5 -0
- 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/build.ps1 +12 -0
- package/lib/__templates__/nuxt-vue/scripts/dev.ps1 +63 -0
- package/lib/__templates__/nuxt-vue/scripts/dev.sh +110 -1
- package/lib/__templates__/nuxt-vue/scripts/prepare.ps1 +12 -0
- package/lib/__templates__/nuxt-vue/scripts/start.ps1 +11 -0
- package/lib/__templates__/nuxt-vue/scripts/validate.ps1 +8 -0
- package/lib/__templates__/phaser/.coze +5 -0
- package/lib/__templates__/phaser/README.md +8 -0
- package/lib/__templates__/phaser/scripts/build.ps1 +12 -0
- package/lib/__templates__/phaser/scripts/dev.ps1 +49 -0
- package/lib/__templates__/phaser/scripts/prepare.ps1 +8 -0
- package/lib/__templates__/phaser/scripts/start.ps1 +49 -0
- package/lib/__templates__/phaser/scripts/validate.ps1 +7 -0
- package/lib/__templates__/phaser/src/global.d.ts +3 -0
- package/lib/__templates__/phaser/src/scene/BootScene.ts +4 -0
- package/lib/__templates__/phaser/src/scene/DevLoadingScene.ts +3 -0
- package/lib/__templates__/phaser/src/utils/mark-editable.ts +8 -1
- package/lib/__templates__/phaser/vite.config.ts +1 -1
- package/lib/__templates__/phaser-static/.coze +15 -0
- package/lib/__templates__/phaser-static/README.md +40 -0
- package/lib/__templates__/phaser-static/_gitignore +6 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0001.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0002.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0003.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0004.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0005.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0006.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0007.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0008.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0009.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0010.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0011.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0012.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0013.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0014.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0015.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0016.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0017.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0018.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0019.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0020.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0021.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0022.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0023.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0024.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/manifest.json +11 -0
- package/lib/__templates__/phaser-static/debug-runtime/flow-graph.json +20 -0
- package/lib/__templates__/phaser-static/index.html +17 -0
- package/lib/__templates__/phaser-static/scripts/serve.ps1 +7 -0
- package/lib/__templates__/phaser-static/src/assets.js +15 -0
- package/lib/__templates__/phaser-static/src/main.js +26 -0
- package/lib/__templates__/phaser-static/src/phaser.js +7 -0
- package/lib/__templates__/phaser-static/src/scene/BootScene.js +205 -0
- package/lib/__templates__/phaser-static/src/scene/DevLoadingScene.js +67 -0
- package/lib/__templates__/phaser-static/src/style.css +28 -0
- package/lib/__templates__/phaser-static/src/utils/asset-loader.js +267 -0
- package/lib/__templates__/phaser-static/src/utils/index.js +2 -0
- package/lib/__templates__/phaser-static/src/utils/mark-editable.js +3 -0
- package/lib/__templates__/phaser-static/template.config.js +35 -0
- 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/deploy_run.sh +1 -1
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +172 -68
- package/lib/__templates__/taro/AGENTS.md +11 -7
- package/lib/__templates__/taro/README.md +4 -4
- package/lib/__templates__/taro/config/index.ts +10 -2
- package/lib/__templates__/taro/pnpm-lock.yaml +5 -5
- package/lib/__templates__/taro/server/package.json +1 -1
- package/lib/__templates__/taro/server/src/main.ts +8 -2
- package/lib/__templates__/templates.json +26 -1
- package/lib/__templates__/vite/.coze +5 -0
- package/lib/__templates__/vite/package.json +1 -1
- package/lib/__templates__/vite/pnpm-lock.yaml +5 -5
- package/lib/__templates__/vite/scripts/build.ps1 +16 -0
- package/lib/__templates__/vite/scripts/dev.ps1 +63 -0
- package/lib/__templates__/vite/scripts/dev.sh +110 -1
- package/lib/__templates__/vite/scripts/prepare.ps1 +18 -0
- package/lib/__templates__/vite/scripts/start.ps1 +11 -0
- package/lib/__templates__/vite/scripts/validate.ps1 +8 -0
- package/lib/__templates__/vite/template.config.js +1 -1
- package/lib/cli.js +746 -217
- package/lib/deploy/package-project.js +22 -4
- package/lib/deploy/package-project.py +18 -3
- package/package.json +1 -1
package/lib/cli.js
CHANGED
|
@@ -23,11 +23,12 @@ 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
|
+
var tar = require('tar');
|
|
31
32
|
var node_stream = require('node:stream');
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -1634,7 +1635,7 @@ function createNodeTransport() {
|
|
|
1634
1635
|
};
|
|
1635
1636
|
}
|
|
1636
1637
|
|
|
1637
|
-
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; }/**
|
|
1638
1639
|
* Slardar CLI Reporter 主类
|
|
1639
1640
|
* 封装 @slardar/base 的初始化和上报逻辑
|
|
1640
1641
|
*/
|
|
@@ -1706,7 +1707,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1706
1707
|
this.client.on('send', (ev) => {
|
|
1707
1708
|
log$6(
|
|
1708
1709
|
'send hook called for event: %s',
|
|
1709
|
-
(_optionalChain$
|
|
1710
|
+
(_optionalChain$G([ev, 'optionalAccess', _ => _.ev_type]) ) || 'unknown',
|
|
1710
1711
|
);
|
|
1711
1712
|
});
|
|
1712
1713
|
|
|
@@ -1764,7 +1765,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1764
1765
|
)
|
|
1765
1766
|
: undefined;
|
|
1766
1767
|
|
|
1767
|
-
_optionalChain$
|
|
1768
|
+
_optionalChain$G([this, 'access', _2 => _2.client, 'access', _3 => _3.sendEvent, 'optionalCall', _4 => _4({
|
|
1768
1769
|
name,
|
|
1769
1770
|
metrics: cleanMetrics ,
|
|
1770
1771
|
categories: cleanCategories ,
|
|
@@ -1835,7 +1836,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1835
1836
|
log$6('Reporting JS error:', {
|
|
1836
1837
|
name: error.name,
|
|
1837
1838
|
message: error.message.slice(0, 100),
|
|
1838
|
-
stack: _optionalChain$
|
|
1839
|
+
stack: _optionalChain$G([error, 'access', _5 => _5.stack, 'optionalAccess', _6 => _6.slice, 'call', _7 => _7(0, 200)]),
|
|
1839
1840
|
extra,
|
|
1840
1841
|
source,
|
|
1841
1842
|
});
|
|
@@ -1855,7 +1856,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1855
1856
|
if (!this.ensureInitialized()) {
|
|
1856
1857
|
return;
|
|
1857
1858
|
}
|
|
1858
|
-
_optionalChain$
|
|
1859
|
+
_optionalChain$G([this, 'access', _8 => _8.client, 'access', _9 => _9.context, 'optionalAccess', _10 => _10.set, 'call', _11 => _11(key, value)]);
|
|
1859
1860
|
}
|
|
1860
1861
|
|
|
1861
1862
|
/**
|
|
@@ -1866,7 +1867,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1866
1867
|
return;
|
|
1867
1868
|
}
|
|
1868
1869
|
log$6('Merging context:', context);
|
|
1869
|
-
_optionalChain$
|
|
1870
|
+
_optionalChain$G([this, 'access', _12 => _12.client, 'access', _13 => _13.context, 'optionalAccess', _14 => _14.merge, 'call', _15 => _15(context)]);
|
|
1870
1871
|
}
|
|
1871
1872
|
|
|
1872
1873
|
/**
|
|
@@ -1876,7 +1877,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1876
1877
|
if (!this.ensureInitialized()) {
|
|
1877
1878
|
return;
|
|
1878
1879
|
}
|
|
1879
|
-
_optionalChain$
|
|
1880
|
+
_optionalChain$G([this, 'access', _16 => _16.client, 'access', _17 => _17.context, 'optionalAccess', _18 => _18.delete, 'call', _19 => _19(key)]);
|
|
1880
1881
|
}
|
|
1881
1882
|
|
|
1882
1883
|
/**
|
|
@@ -1886,7 +1887,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1886
1887
|
if (!this.ensureInitialized()) {
|
|
1887
1888
|
return;
|
|
1888
1889
|
}
|
|
1889
|
-
_optionalChain$
|
|
1890
|
+
_optionalChain$G([this, 'access', _20 => _20.client, 'access', _21 => _21.context, 'optionalAccess', _22 => _22.clear, 'call', _23 => _23()]);
|
|
1890
1891
|
}
|
|
1891
1892
|
|
|
1892
1893
|
/**
|
|
@@ -1923,7 +1924,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1923
1924
|
return;
|
|
1924
1925
|
}
|
|
1925
1926
|
log$6('Flushing Slardar data...');
|
|
1926
|
-
_optionalChain$
|
|
1927
|
+
_optionalChain$G([this, 'access', _24 => _24.client, 'access', _25 => _25.getSender, 'optionalCall', _26 => _26(), 'optionalAccess', _27 => _27.flush, 'call', _28 => _28()]);
|
|
1927
1928
|
log$6('Waiting %dms for events to be sent...', waitMs);
|
|
1928
1929
|
await new Promise(resolve => setTimeout(resolve, waitMs));
|
|
1929
1930
|
log$6('Slardar data flushed');
|
|
@@ -1942,7 +1943,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
|
|
|
1942
1943
|
*/
|
|
1943
1944
|
const reporter = new SlardarCLIReporter();
|
|
1944
1945
|
|
|
1945
|
-
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; }
|
|
1946
1947
|
|
|
1947
1948
|
|
|
1948
1949
|
|
|
@@ -2002,11 +2003,11 @@ const EventBuilder = {
|
|
|
2002
2003
|
name: CLI_EVENTS.CLI_COMMAND,
|
|
2003
2004
|
categories: {
|
|
2004
2005
|
command,
|
|
2005
|
-
args: _optionalChain$
|
|
2006
|
+
args: _optionalChain$F([options, 'optionalAccess', _ => _.args]),
|
|
2006
2007
|
status: 'running' ,
|
|
2007
|
-
..._optionalChain$
|
|
2008
|
+
..._optionalChain$F([options, 'optionalAccess', _2 => _2.categories]),
|
|
2008
2009
|
},
|
|
2009
|
-
metrics: _optionalChain$
|
|
2010
|
+
metrics: _optionalChain$F([options, 'optionalAccess', _3 => _3.metrics]),
|
|
2010
2011
|
};
|
|
2011
2012
|
},
|
|
2012
2013
|
|
|
@@ -2027,13 +2028,13 @@ const EventBuilder = {
|
|
|
2027
2028
|
name: CLI_EVENTS.CLI_COMMAND_COMPLETE,
|
|
2028
2029
|
categories: {
|
|
2029
2030
|
command,
|
|
2030
|
-
args: _optionalChain$
|
|
2031
|
+
args: _optionalChain$F([options, 'optionalAccess', _4 => _4.args]),
|
|
2031
2032
|
status: success ? ('success' ) : ('fail' ),
|
|
2032
|
-
..._optionalChain$
|
|
2033
|
+
..._optionalChain$F([options, 'optionalAccess', _5 => _5.categories]),
|
|
2033
2034
|
},
|
|
2034
2035
|
metrics: {
|
|
2035
2036
|
duration,
|
|
2036
|
-
...(_optionalChain$
|
|
2037
|
+
...(_optionalChain$F([options, 'optionalAccess', _6 => _6.errorCode]) && { errorCode: options.errorCode }),
|
|
2037
2038
|
},
|
|
2038
2039
|
};
|
|
2039
2040
|
},
|
|
@@ -2054,12 +2055,12 @@ const EventBuilder = {
|
|
|
2054
2055
|
name: CLI_EVENTS.NETWORK_REQUEST,
|
|
2055
2056
|
categories: {
|
|
2056
2057
|
url,
|
|
2057
|
-
method: _optionalChain$
|
|
2058
|
-
statusCode: _optionalChain$
|
|
2059
|
-
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' ),
|
|
2060
2061
|
},
|
|
2061
2062
|
metrics: {
|
|
2062
|
-
duration: _optionalChain$
|
|
2063
|
+
duration: _optionalChain$F([options, 'optionalAccess', _12 => _12.duration]),
|
|
2063
2064
|
},
|
|
2064
2065
|
};
|
|
2065
2066
|
},
|
|
@@ -2081,11 +2082,11 @@ const EventBuilder = {
|
|
|
2081
2082
|
categories: {
|
|
2082
2083
|
operation,
|
|
2083
2084
|
filePath,
|
|
2084
|
-
status: _optionalChain$
|
|
2085
|
+
status: _optionalChain$F([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
|
|
2085
2086
|
},
|
|
2086
2087
|
metrics: {
|
|
2087
|
-
duration: _optionalChain$
|
|
2088
|
-
fileSize: _optionalChain$
|
|
2088
|
+
duration: _optionalChain$F([options, 'optionalAccess', _14 => _14.duration]),
|
|
2089
|
+
fileSize: _optionalChain$F([options, 'optionalAccess', _15 => _15.fileSize]),
|
|
2089
2090
|
},
|
|
2090
2091
|
};
|
|
2091
2092
|
},
|
|
@@ -2113,7 +2114,7 @@ const EventBuilder = {
|
|
|
2113
2114
|
};
|
|
2114
2115
|
|
|
2115
2116
|
var name = "@coze-arch/cli";
|
|
2116
|
-
var version = "0.0.36-alpha.
|
|
2117
|
+
var version = "0.0.36-alpha.15544e";
|
|
2117
2118
|
var description = "coze coding devtools cli";
|
|
2118
2119
|
var license = "MIT";
|
|
2119
2120
|
var author = "fanwenjie.fe@bytedance.com";
|
|
@@ -2223,7 +2224,7 @@ var packageJson = {
|
|
|
2223
2224
|
cozePublishConfig: cozePublishConfig
|
|
2224
2225
|
};
|
|
2225
2226
|
|
|
2226
|
-
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; }/**
|
|
2227
2228
|
* Slardar 监控初始化和上报
|
|
2228
2229
|
*/
|
|
2229
2230
|
|
|
@@ -2326,11 +2327,11 @@ const reportCommandComplete = safeRun(
|
|
|
2326
2327
|
,
|
|
2327
2328
|
) => {
|
|
2328
2329
|
const event = EventBuilder.cliCommandComplete(command, success, duration, {
|
|
2329
|
-
args: _optionalChain$
|
|
2330
|
-
errorCode: _optionalChain$
|
|
2330
|
+
args: _optionalChain$E([options, 'optionalAccess', _ => _.args]),
|
|
2331
|
+
errorCode: _optionalChain$E([options, 'optionalAccess', _2 => _2.errorCode]),
|
|
2331
2332
|
categories: {
|
|
2332
|
-
...(_optionalChain$
|
|
2333
|
-
..._optionalChain$
|
|
2333
|
+
...(_optionalChain$E([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
|
|
2334
|
+
..._optionalChain$E([options, 'optionalAccess', _4 => _4.categories]),
|
|
2334
2335
|
},
|
|
2335
2336
|
});
|
|
2336
2337
|
reporter.sendEvent(event.name, event.metrics, event.categories);
|
|
@@ -2389,7 +2390,7 @@ const flushSlardar = safeRun('flushSlardar', async () => {
|
|
|
2389
2390
|
await reporter.flush();
|
|
2390
2391
|
});
|
|
2391
2392
|
|
|
2392
|
-
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) {
|
|
2393
2394
|
const ERROR = 0; LogLevel[LogLevel["ERROR"] = ERROR] = "ERROR";
|
|
2394
2395
|
const WARN = 1; LogLevel[LogLevel["WARN"] = WARN] = "WARN";
|
|
2395
2396
|
const SUCCESS = 2; LogLevel[LogLevel["SUCCESS"] = SUCCESS] = "SUCCESS";
|
|
@@ -2436,7 +2437,7 @@ class Logger {
|
|
|
2436
2437
|
return level;
|
|
2437
2438
|
}
|
|
2438
2439
|
|
|
2439
|
-
const envLevel = _optionalChain$
|
|
2440
|
+
const envLevel = _optionalChain$D([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
|
|
2440
2441
|
if (envLevel && envLevel in LOG_LEVEL_MAP) {
|
|
2441
2442
|
// envLevel 已通过 `in` 检查确认为 LOG_LEVEL_MAP 的键;
|
|
2442
2443
|
// 显式判空以满足 noUncheckedIndexedAccess,运行时行为不变
|
|
@@ -2453,7 +2454,7 @@ class Logger {
|
|
|
2453
2454
|
// 简单检测:Node.js 环境且支持 TTY
|
|
2454
2455
|
return (
|
|
2455
2456
|
typeof process !== 'undefined' &&
|
|
2456
|
-
_optionalChain$
|
|
2457
|
+
_optionalChain$D([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
|
|
2457
2458
|
process.env.NO_COLOR === undefined
|
|
2458
2459
|
);
|
|
2459
2460
|
}
|
|
@@ -3261,7 +3262,7 @@ const registerCommand$6 = program => {
|
|
|
3261
3262
|
});
|
|
3262
3263
|
};
|
|
3263
3264
|
|
|
3264
|
-
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
|
|
3265
3266
|
// Provides fallback values, validation, and error monitoring capabilities
|
|
3266
3267
|
|
|
3267
3268
|
/**
|
|
@@ -3361,12 +3362,12 @@ function safeJsonParse(
|
|
|
3361
3362
|
const parsed = JSON.parse(String(input));
|
|
3362
3363
|
|
|
3363
3364
|
// Optional validation
|
|
3364
|
-
if (_optionalChain$
|
|
3365
|
+
if (_optionalChain$C([options, 'optionalAccess', _ => _.validate])) {
|
|
3365
3366
|
if (options.validate(parsed)) {
|
|
3366
3367
|
return parsed;
|
|
3367
3368
|
} else {
|
|
3368
3369
|
const validationError = new Error('JSON validation failed');
|
|
3369
|
-
_optionalChain$
|
|
3370
|
+
_optionalChain$C([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
|
|
3370
3371
|
|
|
3371
3372
|
if (options.throwOnValidationError) {
|
|
3372
3373
|
throw validationError;
|
|
@@ -3378,10 +3379,10 @@ function safeJsonParse(
|
|
|
3378
3379
|
return parsed;
|
|
3379
3380
|
} catch (error) {
|
|
3380
3381
|
// Re-throw validation errors when throwOnValidationError is true
|
|
3381
|
-
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])) {
|
|
3382
3383
|
throw error;
|
|
3383
3384
|
}
|
|
3384
|
-
_optionalChain$
|
|
3385
|
+
_optionalChain$C([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
|
|
3385
3386
|
return defaultValue;
|
|
3386
3387
|
}
|
|
3387
3388
|
}
|
|
@@ -3421,7 +3422,7 @@ function isNode(node) {
|
|
|
3421
3422
|
}
|
|
3422
3423
|
const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
|
|
3423
3424
|
|
|
3424
|
-
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; }
|
|
3425
3426
|
const BREAK = Symbol('break visit');
|
|
3426
3427
|
const SKIP = Symbol('skip children');
|
|
3427
3428
|
const REMOVE = Symbol('remove node');
|
|
@@ -3534,15 +3535,15 @@ function callVisitor(key, node, visitor, path) {
|
|
|
3534
3535
|
if (typeof visitor === 'function')
|
|
3535
3536
|
return visitor(key, node, path);
|
|
3536
3537
|
if (isMap(node))
|
|
3537
|
-
return _optionalChain$
|
|
3538
|
+
return _optionalChain$B([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
|
|
3538
3539
|
if (isSeq(node))
|
|
3539
|
-
return _optionalChain$
|
|
3540
|
+
return _optionalChain$B([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
|
|
3540
3541
|
if (isPair(node))
|
|
3541
|
-
return _optionalChain$
|
|
3542
|
+
return _optionalChain$B([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
|
|
3542
3543
|
if (isScalar(node))
|
|
3543
|
-
return _optionalChain$
|
|
3544
|
+
return _optionalChain$B([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
|
|
3544
3545
|
if (isAlias(node))
|
|
3545
|
-
return _optionalChain$
|
|
3546
|
+
return _optionalChain$B([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
|
|
3546
3547
|
return undefined;
|
|
3547
3548
|
}
|
|
3548
3549
|
function replaceNode(key, path, node) {
|
|
@@ -3633,7 +3634,7 @@ function applyReviver(reviver, obj, key, val) {
|
|
|
3633
3634
|
return reviver.call(obj, key, val);
|
|
3634
3635
|
}
|
|
3635
3636
|
|
|
3636
|
-
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; }
|
|
3637
3638
|
/**
|
|
3638
3639
|
* Recursively convert any node or its contents to native JavaScript
|
|
3639
3640
|
*
|
|
@@ -3663,7 +3664,7 @@ function toJS(value, arg, ctx) {
|
|
|
3663
3664
|
ctx.onCreate(res);
|
|
3664
3665
|
return res;
|
|
3665
3666
|
}
|
|
3666
|
-
if (typeof value === 'bigint' && !_optionalChain$
|
|
3667
|
+
if (typeof value === 'bigint' && !_optionalChain$A([ctx, 'optionalAccess', _ => _.keep]))
|
|
3667
3668
|
return Number(value);
|
|
3668
3669
|
return value;
|
|
3669
3670
|
}
|
|
@@ -3701,7 +3702,7 @@ class NodeBase {
|
|
|
3701
3702
|
}
|
|
3702
3703
|
}
|
|
3703
3704
|
|
|
3704
|
-
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; }
|
|
3705
3706
|
class Alias extends NodeBase {
|
|
3706
3707
|
constructor(source) {
|
|
3707
3708
|
super(ALIAS);
|
|
@@ -3717,10 +3718,10 @@ class Alias extends NodeBase {
|
|
|
3717
3718
|
* instance of the `source` anchor before this node.
|
|
3718
3719
|
*/
|
|
3719
3720
|
resolve(doc, ctx) {
|
|
3720
|
-
if (_optionalChain$
|
|
3721
|
+
if (_optionalChain$z([ctx, 'optionalAccess', _ => _.maxAliasCount]) === 0)
|
|
3721
3722
|
throw new ReferenceError('Alias resolution is disabled');
|
|
3722
3723
|
let nodes;
|
|
3723
|
-
if (_optionalChain$
|
|
3724
|
+
if (_optionalChain$z([ctx, 'optionalAccess', _2 => _2.aliasResolveCache])) {
|
|
3724
3725
|
nodes = ctx.aliasResolveCache;
|
|
3725
3726
|
}
|
|
3726
3727
|
else {
|
|
@@ -3759,7 +3760,7 @@ class Alias extends NodeBase {
|
|
|
3759
3760
|
data = anchors.get(source);
|
|
3760
3761
|
}
|
|
3761
3762
|
/* istanbul ignore if */
|
|
3762
|
-
if (_optionalChain$
|
|
3763
|
+
if (_optionalChain$z([data, 'optionalAccess', _3 => _3.res]) === undefined) {
|
|
3763
3764
|
const msg = 'This should not happen: Alias anchor was not resolved?';
|
|
3764
3765
|
throw new ReferenceError(msg);
|
|
3765
3766
|
}
|
|
@@ -3811,7 +3812,7 @@ function getAliasCount(doc, node, anchors) {
|
|
|
3811
3812
|
return 1;
|
|
3812
3813
|
}
|
|
3813
3814
|
|
|
3814
|
-
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; }
|
|
3815
3816
|
const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
|
|
3816
3817
|
class Scalar extends NodeBase {
|
|
3817
3818
|
constructor(value) {
|
|
@@ -3819,7 +3820,7 @@ class Scalar extends NodeBase {
|
|
|
3819
3820
|
this.value = value;
|
|
3820
3821
|
}
|
|
3821
3822
|
toJSON(arg, ctx) {
|
|
3822
|
-
return _optionalChain$
|
|
3823
|
+
return _optionalChain$y([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
|
|
3823
3824
|
}
|
|
3824
3825
|
toString() {
|
|
3825
3826
|
return String(this.value);
|
|
@@ -3831,7 +3832,7 @@ Scalar.PLAIN = 'PLAIN';
|
|
|
3831
3832
|
Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
|
|
3832
3833
|
Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
|
|
3833
3834
|
|
|
3834
|
-
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; }
|
|
3835
3836
|
const defaultTagPrefix = 'tag:yaml.org,2002:';
|
|
3836
3837
|
function findTagObject(value, tagName, tags) {
|
|
3837
3838
|
if (tagName) {
|
|
@@ -3841,7 +3842,7 @@ function findTagObject(value, tagName, tags) {
|
|
|
3841
3842
|
throw new Error(`Tag ${tagName} not found`);
|
|
3842
3843
|
return tagObj;
|
|
3843
3844
|
}
|
|
3844
|
-
return tags.find(t => _optionalChain$
|
|
3845
|
+
return tags.find(t => _optionalChain$x([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
|
|
3845
3846
|
}
|
|
3846
3847
|
function createNode(value, tagName, ctx) {
|
|
3847
3848
|
if (isDocument(value))
|
|
@@ -3849,7 +3850,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3849
3850
|
if (isNode(value))
|
|
3850
3851
|
return value;
|
|
3851
3852
|
if (isPair(value)) {
|
|
3852
|
-
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)]);
|
|
3853
3854
|
map.items.push(value);
|
|
3854
3855
|
return map;
|
|
3855
3856
|
}
|
|
@@ -3876,7 +3877,7 @@ function createNode(value, tagName, ctx) {
|
|
|
3876
3877
|
sourceObjects.set(value, ref);
|
|
3877
3878
|
}
|
|
3878
3879
|
}
|
|
3879
|
-
if (_optionalChain$
|
|
3880
|
+
if (_optionalChain$x([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
|
|
3880
3881
|
tagName = defaultTagPrefix + tagName.slice(2);
|
|
3881
3882
|
let tagObj = findTagObject(value, tagName, schema.tags);
|
|
3882
3883
|
if (!tagObj) {
|
|
@@ -3901,9 +3902,9 @@ function createNode(value, tagName, ctx) {
|
|
|
3901
3902
|
onTagObj(tagObj);
|
|
3902
3903
|
delete ctx.onTagObj;
|
|
3903
3904
|
}
|
|
3904
|
-
const node = _optionalChain$
|
|
3905
|
+
const node = _optionalChain$x([tagObj, 'optionalAccess', _9 => _9.createNode])
|
|
3905
3906
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
3906
|
-
: typeof _optionalChain$
|
|
3907
|
+
: typeof _optionalChain$x([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
|
|
3907
3908
|
? tagObj.nodeClass.from(ctx.schema, value, ctx)
|
|
3908
3909
|
: new Scalar(value);
|
|
3909
3910
|
if (tagName)
|
|
@@ -4221,7 +4222,7 @@ function consumeMoreIndentedLines(text, i, indent) {
|
|
|
4221
4222
|
return end;
|
|
4222
4223
|
}
|
|
4223
4224
|
|
|
4224
|
-
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; }
|
|
4225
4226
|
const getFoldOptions = (ctx, isBlock) => ({
|
|
4226
4227
|
indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
|
|
4227
4228
|
lineWidth: ctx.options.lineWidth,
|
|
@@ -4506,9 +4507,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
4506
4507
|
// booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
|
|
4507
4508
|
// and others in v1.1.
|
|
4508
4509
|
if (actualString) {
|
|
4509
|
-
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)]);
|
|
4510
4511
|
const { compat, tags } = ctx.doc.schema;
|
|
4511
|
-
if (tags.some(test) || _optionalChain$
|
|
4512
|
+
if (tags.some(test) || _optionalChain$w([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
|
|
4512
4513
|
return quotedString(value, ctx);
|
|
4513
4514
|
}
|
|
4514
4515
|
return implicitKey
|
|
@@ -4554,7 +4555,7 @@ function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
|
4554
4555
|
return res;
|
|
4555
4556
|
}
|
|
4556
4557
|
|
|
4557
|
-
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; }
|
|
4558
4559
|
function createStringifyContext(doc, options) {
|
|
4559
4560
|
const opt = Object.assign({
|
|
4560
4561
|
blockQuote: true,
|
|
@@ -4607,7 +4608,7 @@ function getTagObject(tags, item) {
|
|
|
4607
4608
|
let obj;
|
|
4608
4609
|
if (isScalar(item)) {
|
|
4609
4610
|
obj = item.value;
|
|
4610
|
-
let match = tags.filter(t => _optionalChain$
|
|
4611
|
+
let match = tags.filter(t => _optionalChain$v([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
|
|
4611
4612
|
if (match.length > 1) {
|
|
4612
4613
|
const testMatch = match.filter(t => t.test);
|
|
4613
4614
|
if (testMatch.length > 0)
|
|
@@ -4621,7 +4622,7 @@ function getTagObject(tags, item) {
|
|
|
4621
4622
|
tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
|
|
4622
4623
|
}
|
|
4623
4624
|
if (!tagObj) {
|
|
4624
|
-
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)));
|
|
4625
4626
|
throw new Error(`Tag not resolved for ${name} value`);
|
|
4626
4627
|
}
|
|
4627
4628
|
return tagObj;
|
|
@@ -4647,7 +4648,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
|
|
|
4647
4648
|
if (isAlias(item)) {
|
|
4648
4649
|
if (ctx.doc.directives)
|
|
4649
4650
|
return item.toString(ctx);
|
|
4650
|
-
if (_optionalChain$
|
|
4651
|
+
if (_optionalChain$v([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
|
|
4651
4652
|
throw new TypeError(`Cannot stringify circular structure without alias nodes`);
|
|
4652
4653
|
}
|
|
4653
4654
|
else {
|
|
@@ -4829,7 +4830,7 @@ function warn(logLevel, warning) {
|
|
|
4829
4830
|
}
|
|
4830
4831
|
}
|
|
4831
4832
|
|
|
4832
|
-
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; }
|
|
4833
4834
|
// If the value associated with a merge key is a single mapping node, each of
|
|
4834
4835
|
// its key/value pairs is inserted into the current mapping, unless the key
|
|
4835
4836
|
// already exists in it. If the value associated with the merge key is a
|
|
@@ -4853,7 +4854,7 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
|
|
|
4853
4854
|
(isScalar(key) &&
|
|
4854
4855
|
(!key.type || key.type === Scalar.PLAIN) &&
|
|
4855
4856
|
merge.identify(key.value))) &&
|
|
4856
|
-
_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)]);
|
|
4857
4858
|
function addMergeToJSMap(ctx, map, value) {
|
|
4858
4859
|
const source = resolveAliasValue(ctx, value);
|
|
4859
4860
|
if (isSeq(source))
|
|
@@ -4893,7 +4894,7 @@ function resolveAliasValue(ctx, value) {
|
|
|
4893
4894
|
return ctx && isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
|
|
4894
4895
|
}
|
|
4895
4896
|
|
|
4896
|
-
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; }
|
|
4897
4898
|
function addPairToJSMap(ctx, map, { key, value }) {
|
|
4898
4899
|
if (isNode(key) && key.addToJSMap)
|
|
4899
4900
|
key.addToJSMap(ctx, map, value);
|
|
@@ -4930,7 +4931,7 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
4930
4931
|
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
4931
4932
|
if (typeof jsKey !== 'object')
|
|
4932
4933
|
return String(jsKey);
|
|
4933
|
-
if (isNode(key) && _optionalChain$
|
|
4934
|
+
if (isNode(key) && _optionalChain$t([ctx, 'optionalAccess', _ => _.doc])) {
|
|
4934
4935
|
const strCtx = createStringifyContext(ctx.doc, {});
|
|
4935
4936
|
strCtx.anchors = new Set();
|
|
4936
4937
|
for (const node of ctx.anchors.keys())
|
|
@@ -4950,7 +4951,7 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
4950
4951
|
return JSON.stringify(jsKey);
|
|
4951
4952
|
}
|
|
4952
4953
|
|
|
4953
|
-
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; }
|
|
4954
4955
|
function createPair(key, value, ctx) {
|
|
4955
4956
|
const k = createNode(key, undefined, ctx);
|
|
4956
4957
|
const v = createNode(value, undefined, ctx);
|
|
@@ -4971,17 +4972,17 @@ class Pair {
|
|
|
4971
4972
|
return new Pair(key, value);
|
|
4972
4973
|
}
|
|
4973
4974
|
toJSON(_, ctx) {
|
|
4974
|
-
const pair = _optionalChain$
|
|
4975
|
+
const pair = _optionalChain$s([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
|
|
4975
4976
|
return addPairToJSMap(ctx, pair, this);
|
|
4976
4977
|
}
|
|
4977
4978
|
toString(ctx, onComment, onChompKeep) {
|
|
4978
|
-
return _optionalChain$
|
|
4979
|
+
return _optionalChain$s([ctx, 'optionalAccess', _3 => _3.doc])
|
|
4979
4980
|
? stringifyPair(this, ctx, onComment, onChompKeep)
|
|
4980
4981
|
: JSON.stringify(this);
|
|
4981
4982
|
}
|
|
4982
4983
|
}
|
|
4983
4984
|
|
|
4984
|
-
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; }
|
|
4985
4986
|
function stringifyCollection(collection, ctx, options) {
|
|
4986
4987
|
const flow = _nullishCoalesce$7(ctx.inFlow, () => ( collection.flow));
|
|
4987
4988
|
const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
|
|
@@ -5075,7 +5076,7 @@ function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
|
|
|
5075
5076
|
if (iv.commentBefore)
|
|
5076
5077
|
reqNewline = true;
|
|
5077
5078
|
}
|
|
5078
|
-
else if (item.value == null && _optionalChain$
|
|
5079
|
+
else if (item.value == null && _optionalChain$r([ik, 'optionalAccess', _ => _.comment])) {
|
|
5079
5080
|
comment = ik.comment;
|
|
5080
5081
|
}
|
|
5081
5082
|
}
|
|
@@ -5130,7 +5131,7 @@ function addCommentBefore({ indent, options: { commentString } }, lines, comment
|
|
|
5130
5131
|
}
|
|
5131
5132
|
}
|
|
5132
5133
|
|
|
5133
|
-
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; }
|
|
5134
5135
|
function findPair(items, key) {
|
|
5135
5136
|
const k = isScalar(key) ? key.value : key;
|
|
5136
5137
|
for (const it of items) {
|
|
@@ -5191,12 +5192,12 @@ class YAMLMap extends Collection {
|
|
|
5191
5192
|
_pair = pair;
|
|
5192
5193
|
else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
|
|
5193
5194
|
// In TypeScript, this never happens.
|
|
5194
|
-
_pair = new Pair(pair, _optionalChain$
|
|
5195
|
+
_pair = new Pair(pair, _optionalChain$q([pair, 'optionalAccess', _2 => _2.value]));
|
|
5195
5196
|
}
|
|
5196
5197
|
else
|
|
5197
5198
|
_pair = new Pair(pair.key, pair.value);
|
|
5198
5199
|
const prev = findPair(this.items, _pair.key);
|
|
5199
|
-
const sortEntries = _optionalChain$
|
|
5200
|
+
const sortEntries = _optionalChain$q([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
|
|
5200
5201
|
if (prev) {
|
|
5201
5202
|
if (!overwrite)
|
|
5202
5203
|
throw new Error(`Key ${_pair.key} already set`);
|
|
@@ -5226,7 +5227,7 @@ class YAMLMap extends Collection {
|
|
|
5226
5227
|
}
|
|
5227
5228
|
get(key, keepScalar) {
|
|
5228
5229
|
const it = findPair(this.items, key);
|
|
5229
|
-
const node = _optionalChain$
|
|
5230
|
+
const node = _optionalChain$q([it, 'optionalAccess', _5 => _5.value]);
|
|
5230
5231
|
return _nullishCoalesce$6((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
|
|
5231
5232
|
}
|
|
5232
5233
|
has(key) {
|
|
@@ -5241,8 +5242,8 @@ class YAMLMap extends Collection {
|
|
|
5241
5242
|
* @returns Instance of Type, Map, or Object
|
|
5242
5243
|
*/
|
|
5243
5244
|
toJSON(_, ctx, Type) {
|
|
5244
|
-
const map = Type ? new Type() : _optionalChain$
|
|
5245
|
-
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]))
|
|
5246
5247
|
ctx.onCreate(map);
|
|
5247
5248
|
for (const item of this.items)
|
|
5248
5249
|
addPairToJSMap(ctx, map, item);
|
|
@@ -5267,7 +5268,7 @@ class YAMLMap extends Collection {
|
|
|
5267
5268
|
}
|
|
5268
5269
|
}
|
|
5269
5270
|
|
|
5270
|
-
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; }
|
|
5271
5272
|
class YAMLSeq extends Collection {
|
|
5272
5273
|
static get tagName() {
|
|
5273
5274
|
return 'tag:yaml.org,2002:seq';
|
|
@@ -5330,7 +5331,7 @@ class YAMLSeq extends Collection {
|
|
|
5330
5331
|
}
|
|
5331
5332
|
toJSON(_, ctx) {
|
|
5332
5333
|
const seq = [];
|
|
5333
|
-
if (_optionalChain$
|
|
5334
|
+
if (_optionalChain$p([ctx, 'optionalAccess', _2 => _2.onCreate]))
|
|
5334
5335
|
ctx.onCreate(seq);
|
|
5335
5336
|
let i = 0;
|
|
5336
5337
|
for (const item of this.items)
|
|
@@ -5409,7 +5410,7 @@ function createPairs(schema, iterable, ctx) {
|
|
|
5409
5410
|
return pairs;
|
|
5410
5411
|
}
|
|
5411
5412
|
|
|
5412
|
-
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; }
|
|
5413
5414
|
class YAMLOMap extends YAMLSeq {
|
|
5414
5415
|
constructor() {
|
|
5415
5416
|
super();
|
|
@@ -5428,7 +5429,7 @@ class YAMLOMap extends YAMLSeq {
|
|
|
5428
5429
|
if (!ctx)
|
|
5429
5430
|
return super.toJSON(_);
|
|
5430
5431
|
const map = new Map();
|
|
5431
|
-
if (_optionalChain$
|
|
5432
|
+
if (_optionalChain$o([ctx, 'optionalAccess', _2 => _2.onCreate]))
|
|
5432
5433
|
ctx.onCreate(map);
|
|
5433
5434
|
for (const pair of this.items) {
|
|
5434
5435
|
let key, value;
|
|
@@ -5546,7 +5547,7 @@ const isDirExists = async (file) => {
|
|
|
5546
5547
|
}
|
|
5547
5548
|
};
|
|
5548
5549
|
|
|
5549
|
-
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
|
|
5550
5551
|
|
|
5551
5552
|
/**
|
|
5552
5553
|
* 支持的项目类型枚举
|
|
@@ -5648,7 +5649,7 @@ const collectProjectInfo = async (
|
|
|
5648
5649
|
}
|
|
5649
5650
|
|
|
5650
5651
|
const scripts = Object.entries(
|
|
5651
|
-
(_optionalChain$
|
|
5652
|
+
(_optionalChain$n([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
|
|
5652
5653
|
).reduce((acc, [name, script]) => {
|
|
5653
5654
|
if (typeof script === 'string') {
|
|
5654
5655
|
acc[name] = script;
|
|
@@ -5802,7 +5803,7 @@ const detectProjectType = async (
|
|
|
5802
5803
|
};
|
|
5803
5804
|
};
|
|
5804
5805
|
|
|
5805
|
-
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; }
|
|
5806
5807
|
|
|
5807
5808
|
|
|
5808
5809
|
/**
|
|
@@ -5961,35 +5962,66 @@ const saveProjectPatchState = async (
|
|
|
5961
5962
|
await saveTomlCozeConfig(config, projectPath);
|
|
5962
5963
|
};
|
|
5963
5964
|
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
* @param config - .coze 配置对象
|
|
5968
|
-
* @param commandName - 命令名称 (dev/build/start)
|
|
5969
|
-
* @returns 命令配置数组
|
|
5970
|
-
*/
|
|
5971
|
-
const getCommandConfig = (
|
|
5965
|
+
|
|
5966
|
+
|
|
5967
|
+
const getDefaultCommandConfig = (
|
|
5972
5968
|
config,
|
|
5973
5969
|
commandName,
|
|
5974
5970
|
) => {
|
|
5975
|
-
|
|
5971
|
+
switch (commandName) {
|
|
5972
|
+
case 'dev':
|
|
5973
|
+
return _optionalChain$m([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
|
|
5974
|
+
case 'build':
|
|
5975
|
+
return _optionalChain$m([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
|
|
5976
|
+
case 'start':
|
|
5977
|
+
return _optionalChain$m([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
|
|
5978
|
+
case 'validate':
|
|
5979
|
+
return _optionalChain$m([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
|
|
5980
|
+
default:
|
|
5981
|
+
throw new Error(`Unknown command: ${commandName}`);
|
|
5982
|
+
}
|
|
5983
|
+
};
|
|
5976
5984
|
|
|
5985
|
+
const getWindowsCommandConfig = (
|
|
5986
|
+
config,
|
|
5987
|
+
commandName,
|
|
5988
|
+
) => {
|
|
5977
5989
|
switch (commandName) {
|
|
5978
5990
|
case 'dev':
|
|
5979
|
-
|
|
5980
|
-
break;
|
|
5991
|
+
return _optionalChain$m([config, 'access', _9 => _9.dev, 'optionalAccess', _10 => _10.run_win]);
|
|
5981
5992
|
case 'build':
|
|
5982
|
-
|
|
5983
|
-
break;
|
|
5993
|
+
return _optionalChain$m([config, 'access', _11 => _11.deploy, 'optionalAccess', _12 => _12.build_win]);
|
|
5984
5994
|
case 'start':
|
|
5985
|
-
|
|
5986
|
-
break;
|
|
5995
|
+
return _optionalChain$m([config, 'access', _13 => _13.deploy, 'optionalAccess', _14 => _14.run_win]);
|
|
5987
5996
|
case 'validate':
|
|
5988
|
-
|
|
5989
|
-
break;
|
|
5997
|
+
return _optionalChain$m([config, 'access', _15 => _15.dev, 'optionalAccess', _16 => _16.validate_win]);
|
|
5990
5998
|
default:
|
|
5991
5999
|
throw new Error(`Unknown command: ${commandName}`);
|
|
5992
6000
|
}
|
|
6001
|
+
};
|
|
6002
|
+
|
|
6003
|
+
/**
|
|
6004
|
+
* 获取指定命令的配置
|
|
6005
|
+
*
|
|
6006
|
+
* Windows 优先使用非空的 *_win 配置;其他平台(包括 WSL)始终使用默认配置。
|
|
6007
|
+
*
|
|
6008
|
+
* @param config - .coze 配置对象
|
|
6009
|
+
* @param commandName - 命令名称 (dev/build/start)
|
|
6010
|
+
* @returns 命令配置数组
|
|
6011
|
+
*/
|
|
6012
|
+
const getCommandConfig = (
|
|
6013
|
+
config,
|
|
6014
|
+
commandName,
|
|
6015
|
+
platform = process.platform,
|
|
6016
|
+
) => {
|
|
6017
|
+
const defaultCommandConfig = getDefaultCommandConfig(config, commandName);
|
|
6018
|
+
const windowsCommandConfig =
|
|
6019
|
+
platform === 'win32'
|
|
6020
|
+
? getWindowsCommandConfig(config, commandName)
|
|
6021
|
+
: undefined;
|
|
6022
|
+
const commandConfig = _optionalChain$m([windowsCommandConfig, 'optionalAccess', _17 => _17.length])
|
|
6023
|
+
? windowsCommandConfig
|
|
6024
|
+
: defaultCommandConfig;
|
|
5993
6025
|
|
|
5994
6026
|
if (!commandConfig || commandConfig.length === 0) {
|
|
5995
6027
|
throw new Error(
|
|
@@ -6136,7 +6168,7 @@ const byFlag = (flag) => {
|
|
|
6136
6168
|
return predicate;
|
|
6137
6169
|
};
|
|
6138
6170
|
|
|
6139
|
-
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; }
|
|
6140
6172
|
|
|
6141
6173
|
|
|
6142
6174
|
|
|
@@ -6167,7 +6199,7 @@ echo "Validate passed!"
|
|
|
6167
6199
|
* @returns
|
|
6168
6200
|
*/
|
|
6169
6201
|
const isCozeValid$3 = (cozeConfig) => {
|
|
6170
|
-
if (_optionalChain$
|
|
6202
|
+
if (_optionalChain$l([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6171
6203
|
logger.info('[patch-expo-validate] NOT APPLY: dev.validate exists');
|
|
6172
6204
|
return false;
|
|
6173
6205
|
}
|
|
@@ -6312,7 +6344,7 @@ const patchExpoValidate = {
|
|
|
6312
6344
|
},
|
|
6313
6345
|
};
|
|
6314
6346
|
|
|
6315
|
-
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; }
|
|
6316
6348
|
|
|
6317
6349
|
|
|
6318
6350
|
|
|
@@ -6345,7 +6377,7 @@ echo "Validate passed!"
|
|
|
6345
6377
|
* @returns
|
|
6346
6378
|
*/
|
|
6347
6379
|
const isCozeValid$2 = (cozeConfig) => {
|
|
6348
|
-
if (_optionalChain$
|
|
6380
|
+
if (_optionalChain$k([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6349
6381
|
logger.info('[patch-nextjs-validate] NOT APPLY: dev.validate exists');
|
|
6350
6382
|
return false;
|
|
6351
6383
|
}
|
|
@@ -6493,7 +6525,7 @@ const patchNextjsValidate = {
|
|
|
6493
6525
|
},
|
|
6494
6526
|
};
|
|
6495
6527
|
|
|
6496
|
-
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; }
|
|
6497
6529
|
|
|
6498
6530
|
const PATCH_ID$5 = 'nextjs/validate-concurrently@0.0.30';
|
|
6499
6531
|
const PACKAGE_JSON_FILE$3 = 'package.json';
|
|
@@ -6526,7 +6558,7 @@ const readPackageJson = async (projectFolder) => {
|
|
|
6526
6558
|
};
|
|
6527
6559
|
|
|
6528
6560
|
const getTargetValidateScript = (packageJson) => {
|
|
6529
|
-
const validateScript = _optionalChain$
|
|
6561
|
+
const validateScript = _optionalChain$j([packageJson, 'access', _ => _.scripts, 'optionalAccess', _2 => _2.validate]);
|
|
6530
6562
|
if (typeof validateScript !== 'string') {
|
|
6531
6563
|
return null;
|
|
6532
6564
|
}
|
|
@@ -6543,7 +6575,7 @@ const getTargetValidateScript = (packageJson) => {
|
|
|
6543
6575
|
|
|
6544
6576
|
const canStackAfterNextjsValidatePatch = async (context, packageJson) => {
|
|
6545
6577
|
const scripts = packageJson.scripts || {};
|
|
6546
|
-
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])) {
|
|
6547
6579
|
return false;
|
|
6548
6580
|
}
|
|
6549
6581
|
|
|
@@ -6612,7 +6644,7 @@ const patchNextjsValidateConcurrently = {
|
|
|
6612
6644
|
apply: patchPackageJson$2,
|
|
6613
6645
|
};
|
|
6614
6646
|
|
|
6615
|
-
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; }
|
|
6616
6648
|
|
|
6617
6649
|
|
|
6618
6650
|
|
|
@@ -6645,7 +6677,7 @@ echo "Validate passed!"
|
|
|
6645
6677
|
* @returns
|
|
6646
6678
|
*/
|
|
6647
6679
|
const isCozeValid$1 = (cozeConfig) => {
|
|
6648
|
-
if (_optionalChain$
|
|
6680
|
+
if (_optionalChain$i([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6649
6681
|
logger.info('[patch-vite-validate] NOT APPLY: dev.validate exists');
|
|
6650
6682
|
return false;
|
|
6651
6683
|
}
|
|
@@ -6790,7 +6822,7 @@ const patchViteValidate = {
|
|
|
6790
6822
|
},
|
|
6791
6823
|
};
|
|
6792
6824
|
|
|
6793
|
-
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; }
|
|
6794
6826
|
|
|
6795
6827
|
|
|
6796
6828
|
|
|
@@ -6827,7 +6859,7 @@ echo "Validate passed!"
|
|
|
6827
6859
|
* @returns
|
|
6828
6860
|
*/
|
|
6829
6861
|
const isCozeValid = (cozeConfig) => {
|
|
6830
|
-
if (_optionalChain$
|
|
6862
|
+
if (_optionalChain$h([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
|
|
6831
6863
|
logger.info('[patch-taro-validate] NOT APPLY: dev.validate exists');
|
|
6832
6864
|
return false;
|
|
6833
6865
|
}
|
|
@@ -6976,7 +7008,7 @@ const patchTaroValidate = {
|
|
|
6976
7008
|
},
|
|
6977
7009
|
};
|
|
6978
7010
|
|
|
6979
|
-
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; }
|
|
6980
7012
|
const PATCH_ID$2 = 'taro/update-pack-script-for-tt-build@0.0.13';
|
|
6981
7013
|
const PACKAGE_JSON_FILE = 'package.json';
|
|
6982
7014
|
const PACK_SCRIPT_FILE = '.cozeproj/scripts/pack.sh';
|
|
@@ -7055,12 +7087,12 @@ const readPackageScripts = async (
|
|
|
7055
7087
|
const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
|
|
7056
7088
|
const packageJson = safeJsonParse(packageJsonContent, null);
|
|
7057
7089
|
|
|
7058
|
-
return _optionalChain$
|
|
7090
|
+
return _optionalChain$g([packageJson, 'optionalAccess', _ => _.scripts]) || null;
|
|
7059
7091
|
};
|
|
7060
7092
|
|
|
7061
7093
|
const hasBuildTtScript = async (projectFolder) => {
|
|
7062
7094
|
const scripts = await readPackageScripts(projectFolder);
|
|
7063
|
-
return typeof _optionalChain$
|
|
7095
|
+
return typeof _optionalChain$g([scripts, 'optionalAccess', _2 => _2['build:tt']]) === 'string';
|
|
7064
7096
|
};
|
|
7065
7097
|
|
|
7066
7098
|
const hasLegacyPackScript = async (projectFolder) => {
|
|
@@ -7414,7 +7446,7 @@ const getTemplatePatches = (
|
|
|
7414
7446
|
) =>
|
|
7415
7447
|
patches.filter(patch => patch.template === template);
|
|
7416
7448
|
|
|
7417
|
-
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; }
|
|
7418
7450
|
const DEFAULT_LEGACY_VERSION = 'legacy';
|
|
7419
7451
|
|
|
7420
7452
|
const loadFlagsWithFallback = async () => {
|
|
@@ -7520,7 +7552,7 @@ const getNextPatchState = (
|
|
|
7520
7552
|
|
|
7521
7553
|
) => ({
|
|
7522
7554
|
template,
|
|
7523
|
-
version: _optionalChain$
|
|
7555
|
+
version: _optionalChain$f([config, 'access', _ => _.project, 'optionalAccess', _2 => _2.version]) || DEFAULT_LEGACY_VERSION,
|
|
7524
7556
|
appliedPatches: [...appliedPatches, patchId],
|
|
7525
7557
|
});
|
|
7526
7558
|
|
|
@@ -7544,15 +7576,15 @@ const executePatch = async (
|
|
|
7544
7576
|
}
|
|
7545
7577
|
|
|
7546
7578
|
const template =
|
|
7547
|
-
_optionalChain$
|
|
7579
|
+
_optionalChain$f([config, 'access', _3 => _3.project, 'optionalAccess', _4 => _4.template]) || (await detectTemplateKey(projectFolder));
|
|
7548
7580
|
|
|
7549
7581
|
if (!template) {
|
|
7550
7582
|
logger.info('Patch skipped: template not detected');
|
|
7551
7583
|
return;
|
|
7552
7584
|
}
|
|
7553
7585
|
|
|
7554
|
-
const appliedPatches = [...(_optionalChain$
|
|
7555
|
-
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]);
|
|
7556
7588
|
const flags = await loadFlagsWithFallback();
|
|
7557
7589
|
|
|
7558
7590
|
const context = {
|
|
@@ -7655,14 +7687,14 @@ const registerCommand$5 = program => {
|
|
|
7655
7687
|
) => {
|
|
7656
7688
|
await executePatch({
|
|
7657
7689
|
directory,
|
|
7658
|
-
dryRun: _optionalChain$
|
|
7659
|
-
showFlags: _optionalChain$
|
|
7690
|
+
dryRun: _optionalChain$f([command, 'optionalAccess', _9 => _9.dryRun]),
|
|
7691
|
+
showFlags: _optionalChain$f([command, 'optionalAccess', _10 => _10.showFlags]),
|
|
7660
7692
|
});
|
|
7661
7693
|
},
|
|
7662
7694
|
);
|
|
7663
7695
|
};
|
|
7664
7696
|
|
|
7665
|
-
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; }
|
|
7666
7698
|
const d$1 = debug('coze-init-cli:run');
|
|
7667
7699
|
|
|
7668
7700
|
/**
|
|
@@ -7793,12 +7825,12 @@ const executeRun = async (commandName, options = {}) => {
|
|
|
7793
7825
|
}
|
|
7794
7826
|
|
|
7795
7827
|
// 将输出同时写入控制台和日志文件
|
|
7796
|
-
_optionalChain$
|
|
7828
|
+
_optionalChain$e([childProcess, 'access', _ => _.stdout, 'optionalAccess', _2 => _2.on, 'call', _3 => _3('data', (data) => {
|
|
7797
7829
|
process.stdout.write(data);
|
|
7798
7830
|
logStream.write(data);
|
|
7799
7831
|
})]);
|
|
7800
7832
|
|
|
7801
|
-
_optionalChain$
|
|
7833
|
+
_optionalChain$e([childProcess, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6('data', (data) => {
|
|
7802
7834
|
process.stderr.write(data);
|
|
7803
7835
|
logStream.write(data);
|
|
7804
7836
|
})]);
|
|
@@ -8742,7 +8774,7 @@ const scanRoutesOnce = async (
|
|
|
8742
8774
|
}
|
|
8743
8775
|
};
|
|
8744
8776
|
|
|
8745
|
-
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
|
|
8746
8778
|
|
|
8747
8779
|
|
|
8748
8780
|
const log = debug('coze:routes');
|
|
@@ -8843,7 +8875,7 @@ const registerCommand$3 = program => {
|
|
|
8843
8875
|
'Output file path (defaults to ~/.coze/routes.json)',
|
|
8844
8876
|
)
|
|
8845
8877
|
.action(async (directory, options) => {
|
|
8846
|
-
await executeRoutes({ directory, output: _optionalChain$
|
|
8878
|
+
await executeRoutes({ directory, output: _optionalChain$d([options, 'optionalAccess', _ => _.output]) });
|
|
8847
8879
|
});
|
|
8848
8880
|
};
|
|
8849
8881
|
|
|
@@ -10434,8 +10466,7 @@ const withRequestedApplicationType = (
|
|
|
10434
10466
|
};
|
|
10435
10467
|
};
|
|
10436
10468
|
|
|
10437
|
-
function _optionalChain$
|
|
10438
|
-
|
|
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; }
|
|
10439
10470
|
const DEFAULT_CONFIG = {
|
|
10440
10471
|
apiBaseUrl: 'https://code.coze.cn/',
|
|
10441
10472
|
openApiBaseUrl: 'https://api.coze.cn',
|
|
@@ -10447,6 +10478,20 @@ const getSharedConfigPath = () =>
|
|
|
10447
10478
|
|
|
10448
10479
|
const getLegacyConfigPath = () => node_path.join(node_os.homedir(), '.coze', 'config.json');
|
|
10449
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
|
+
|
|
10450
10495
|
const isRecord$3 = (value) =>
|
|
10451
10496
|
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
10452
10497
|
|
|
@@ -10462,33 +10507,71 @@ const readJson = async (path) => {
|
|
|
10462
10507
|
}
|
|
10463
10508
|
};
|
|
10464
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
|
+
|
|
10465
10528
|
const configuredPath = (options) =>
|
|
10466
|
-
_optionalChain$
|
|
10529
|
+
_optionalChain$c([options, 'optionalAccess', _ => _.config]) || process.env.COZE_CONFIG_FILE;
|
|
10467
10530
|
|
|
10468
10531
|
const loadConfig = async (options = {}) => {
|
|
10469
10532
|
const customPath = configuredPath(options);
|
|
10470
10533
|
const globalConfig = customPath
|
|
10471
10534
|
? await readJson(node_path.resolve(customPath))
|
|
10472
10535
|
: (await readJson(getSharedConfigPath())) || (await readJson(getLegacyConfigPath()));
|
|
10473
|
-
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]);
|
|
10474
10545
|
const config = {
|
|
10475
10546
|
...DEFAULT_CONFIG,
|
|
10476
10547
|
...globalConfig,
|
|
10477
|
-
...(
|
|
10548
|
+
...(fixedAccessToken
|
|
10478
10549
|
? {
|
|
10479
|
-
accessToken:
|
|
10480
|
-
// COZE_API_TOKEN
|
|
10481
|
-
// 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.
|
|
10482
10553
|
refreshToken: undefined,
|
|
10483
10554
|
tokenExpiresAt: undefined,
|
|
10484
10555
|
}
|
|
10485
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,
|
|
10486
10565
|
...(process.env.COZE_ORG_ID ? { organizationId: process.env.COZE_ORG_ID } : {}),
|
|
10566
|
+
...(process.env.COZE_ACCOUNT_ID ? { cozeAccountId: process.env.COZE_ACCOUNT_ID } : {}),
|
|
10487
10567
|
...(process.env.COZE_SPACE_ID ? { spaceId: process.env.COZE_SPACE_ID } : {}),
|
|
10488
10568
|
...(process.env.COZE_PROJECT_ID ? { projectId: process.env.COZE_PROJECT_ID } : {}),
|
|
10489
10569
|
...(options.orgId ? { organizationId: options.orgId } : {}),
|
|
10490
10570
|
...(options.spaceId ? { spaceId: options.spaceId } : {}),
|
|
10491
10571
|
...(options.apiBaseUrl ? { apiBaseUrl: options.apiBaseUrl } : {}),
|
|
10572
|
+
// Runtime-only trust decision: a value persisted in config.json must never enable
|
|
10573
|
+
// project-secret injection for an OAuth access token.
|
|
10574
|
+
injectApiToken: Boolean(fixedAccessToken),
|
|
10492
10575
|
};
|
|
10493
10576
|
return config;
|
|
10494
10577
|
};
|
|
@@ -10512,7 +10595,10 @@ const saveSharedConfig = async (
|
|
|
10512
10595
|
}
|
|
10513
10596
|
};
|
|
10514
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
|
+
|
|
10515
10600
|
const FIVE_MINUTES = 5 * 60 * 1000;
|
|
10601
|
+
const HTTP_UNAUTHORIZED = 401;
|
|
10516
10602
|
|
|
10517
10603
|
|
|
10518
10604
|
|
|
@@ -10537,6 +10623,54 @@ const parseJson = async (response) => {
|
|
|
10537
10623
|
const isRecord$2 = (value) =>
|
|
10538
10624
|
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
10539
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
|
+
|
|
10540
10674
|
const getCurrentUser = async (
|
|
10541
10675
|
config,
|
|
10542
10676
|
options,
|
|
@@ -10551,7 +10685,7 @@ const getCurrentUser = async (
|
|
|
10551
10685
|
typeof payload.msg === 'string'
|
|
10552
10686
|
? payload.msg
|
|
10553
10687
|
: 'Unable to validate the current login. Run `coze-dev deploy auth login` again.',
|
|
10554
|
-
response.status ===
|
|
10688
|
+
response.status === HTTP_UNAUTHORIZED ? 'AUTH_REQUIRED' : 'AUTH_STATUS_FAILED',
|
|
10555
10689
|
{ status: response.status },
|
|
10556
10690
|
);
|
|
10557
10691
|
}
|
|
@@ -10572,6 +10706,7 @@ const getAccessToken = async (
|
|
|
10572
10706
|
config,
|
|
10573
10707
|
options,
|
|
10574
10708
|
) => {
|
|
10709
|
+
await resolveFixedAccessToken(config);
|
|
10575
10710
|
if (!config.accessToken) {
|
|
10576
10711
|
throw new CliError(
|
|
10577
10712
|
'No shared login found. Run `coze-dev deploy auth login` first.',
|
|
@@ -10814,7 +10949,7 @@ const loginWithOAuth = async (
|
|
|
10814
10949
|
await saveOAuthToken(config, options, await pollToken(config, deviceCode));
|
|
10815
10950
|
};
|
|
10816
10951
|
|
|
10817
|
-
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; }
|
|
10818
10953
|
|
|
10819
10954
|
|
|
10820
10955
|
|
|
@@ -10880,10 +11015,10 @@ const unwrap = (
|
|
|
10880
11015
|
responseMetadata,
|
|
10881
11016
|
) => {
|
|
10882
11017
|
const root = isRecord(payload) ? payload : undefined;
|
|
10883
|
-
const first = isRecord(_optionalChain$
|
|
10884
|
-
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;
|
|
10885
11020
|
const envelope = [root, first].find(candidate => candidate && 'code' in candidate);
|
|
10886
|
-
if (_optionalChain$
|
|
11021
|
+
if (_optionalChain$a([envelope, 'optionalAccess', _3 => _3.code]) !== undefined && Number(envelope.code) !== 0) {
|
|
10887
11022
|
throw new CliError(
|
|
10888
11023
|
typeof envelope.msg === 'string'
|
|
10889
11024
|
? envelope.msg.slice(0, MAX_MESSAGE_LENGTH)
|
|
@@ -10932,10 +11067,22 @@ class DeployApiClient {
|
|
|
10932
11067
|
'agw-js-conv': 'str',
|
|
10933
11068
|
'x-request-from-coze-cli': '1',
|
|
10934
11069
|
};
|
|
10935
|
-
|
|
10936
|
-
|
|
11070
|
+
// Only a fixed runtime credential (desktop PAT or COZE_API_TOKEN) may become
|
|
11071
|
+
// a project runtime secret. OAuth credentials remain authentication-only.
|
|
11072
|
+
if (
|
|
11073
|
+
this.config.injectApiToken &&
|
|
11074
|
+
path === '/deploy_history/create' &&
|
|
11075
|
+
useApiPrefix
|
|
11076
|
+
) {
|
|
11077
|
+
headers['x-coze-deploy-inject-api-token'] = 'true';
|
|
11078
|
+
}
|
|
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;
|
|
10937
11084
|
}
|
|
10938
|
-
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()]);
|
|
10939
11086
|
if (lane) {
|
|
10940
11087
|
headers['x-use-ppe'] = '1';
|
|
10941
11088
|
headers['x-tt-env'] = lane;
|
|
@@ -10966,7 +11113,7 @@ class DeployApiClient {
|
|
|
10966
11113
|
if (!response.ok) {
|
|
10967
11114
|
const root = isRecord(payload) ? payload : undefined;
|
|
10968
11115
|
throw new CliError(
|
|
10969
|
-
typeof _optionalChain$
|
|
11116
|
+
typeof _optionalChain$a([root, 'optionalAccess', _12 => _12.msg]) === 'string'
|
|
10970
11117
|
? root.msg.slice(0, MAX_MESSAGE_LENGTH)
|
|
10971
11118
|
: `Deployment API failed: ${response.status} ${response.statusText}` +
|
|
10972
11119
|
`${validJson ? '' : '; response was not JSON'}`,
|
|
@@ -10999,6 +11146,17 @@ class DeployApiClient {
|
|
|
10999
11146
|
);
|
|
11000
11147
|
}
|
|
11001
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
|
+
|
|
11002
11160
|
listSpaces(body
|
|
11003
11161
|
|
|
11004
11162
|
|
|
@@ -11171,6 +11329,36 @@ class DeployApiClient {
|
|
|
11171
11329
|
);
|
|
11172
11330
|
}
|
|
11173
11331
|
|
|
11332
|
+
authorizeMiniProgram(body
|
|
11333
|
+
|
|
11334
|
+
|
|
11335
|
+
|
|
11336
|
+
|
|
11337
|
+
|
|
11338
|
+
|
|
11339
|
+
) {
|
|
11340
|
+
return this.post
|
|
11341
|
+
|
|
11342
|
+
|
|
11343
|
+
|
|
11344
|
+
('/mini_program/auth', body);
|
|
11345
|
+
}
|
|
11346
|
+
|
|
11347
|
+
createMiniProgramPreview(body
|
|
11348
|
+
|
|
11349
|
+
|
|
11350
|
+
|
|
11351
|
+
|
|
11352
|
+
|
|
11353
|
+
) {
|
|
11354
|
+
return this.post
|
|
11355
|
+
|
|
11356
|
+
|
|
11357
|
+
|
|
11358
|
+
|
|
11359
|
+
('/mini_program/preview', body);
|
|
11360
|
+
}
|
|
11361
|
+
|
|
11174
11362
|
listDomains(appId, unitType) {
|
|
11175
11363
|
return this.post(
|
|
11176
11364
|
'/domain/list', {
|
|
@@ -11404,7 +11592,7 @@ const registerDoctor = (program) => {
|
|
|
11404
11592
|
});
|
|
11405
11593
|
};
|
|
11406
11594
|
|
|
11407
|
-
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; }
|
|
11408
11596
|
|
|
11409
11597
|
|
|
11410
11598
|
|
|
@@ -11435,13 +11623,66 @@ function _optionalChain$8(ops) { let lastAccessLHS = undefined; let value = ops[
|
|
|
11435
11623
|
|
|
11436
11624
|
|
|
11437
11625
|
const getDeployParentOptions = (command) =>
|
|
11438
|
-
_optionalChain$
|
|
11626
|
+
_optionalChain$9([command, 'access', _ => _.parent, 'optionalAccess', _2 => _2.opts, 'call', _3 => _3()]) || {};
|
|
11439
11627
|
|
|
11440
11628
|
const getDeployAppIdOption = (
|
|
11441
11629
|
options,
|
|
11442
11630
|
command,
|
|
11443
11631
|
) => options.appId || getDeployParentOptions(command).appId;
|
|
11444
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
|
+
|
|
11445
11686
|
const getCreateDeployConfig = (config) => ({
|
|
11446
11687
|
deploy_config: {
|
|
11447
11688
|
cpu: config.deploy_config.cpu,
|
|
@@ -11475,16 +11716,27 @@ const STATUS_NAMES = {
|
|
|
11475
11716
|
[DEPLOY_STATUS.preDeploy]: 'WaitingForUpload',
|
|
11476
11717
|
};
|
|
11477
11718
|
|
|
11719
|
+
/**
|
|
11720
|
+
* 终态 = 不会再变了。
|
|
11721
|
+
*
|
|
11722
|
+
* ⚠️ `interrupted(6)` **不是**终态,别再往这里加。它是过程态:服务端某条流水线自身轮询超时时,
|
|
11723
|
+
* 会把整次部署标成 Interrupted 并安排稍后重新触发(`base_pipe.NewInterruptedResult`),之后仍
|
|
11724
|
+
* 会推进到 Succeeded。安卓构建 10 分钟起步,几乎必然经过至少一次 Interrupted —— 把它当终态会
|
|
11725
|
+
* 让 `deploy --wait` 在构建中途就收工返回,此时 APK 还没产出,`mobile_artifact_list` 是空的。
|
|
11726
|
+
*/
|
|
11478
11727
|
const TERMINAL_STATUSES = new Set([
|
|
11479
11728
|
DEPLOY_STATUS.succeeded,
|
|
11480
11729
|
DEPLOY_STATUS.failed,
|
|
11481
11730
|
DEPLOY_STATUS.canceled,
|
|
11482
|
-
DEPLOY_STATUS.interrupted,
|
|
11483
11731
|
]);
|
|
11484
11732
|
|
|
11485
11733
|
const getDeployStatusText = (status) =>
|
|
11486
11734
|
status ? STATUS_NAMES[status] || 'Unknown' : 'Unknown';
|
|
11487
11735
|
|
|
11736
|
+
/** 这次部署的结果是否已经定下来了(到了终态就不会再变)。 */
|
|
11737
|
+
const isDeploymentSettled = (status) =>
|
|
11738
|
+
status !== undefined && TERMINAL_STATUSES.has(status);
|
|
11739
|
+
|
|
11488
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; }
|
|
11489
11741
|
|
|
11490
11742
|
const formatDeployDetails = (history) =>
|
|
@@ -11749,6 +12001,27 @@ const readDeployLocalContext = async (
|
|
|
11749
12001
|
return { ...sourceSnapshot, metadata, isPagesDeployment };
|
|
11750
12002
|
};
|
|
11751
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
|
+
|
|
11752
12025
|
// 服务端 deploy_app/list 的 page_size 上限,超了会被判参数错误。
|
|
11753
12026
|
// 客户端先拦一道,是为了把错误说在本地(带上上限值),而不是回一句服务端的通用参数错误。
|
|
11754
12027
|
const APP_LIST_MAX_PAGE_SIZE = 100;
|
|
@@ -11860,11 +12133,12 @@ const registerDeployReadCommands = (deploy) => {
|
|
|
11860
12133
|
deploy_history_id: deployHistoryId,
|
|
11861
12134
|
status: getDeployStatusText(history.status),
|
|
11862
12135
|
commit_hash: history.commit_hash,
|
|
12136
|
+
commit_message: history.commit_message,
|
|
11863
12137
|
domains: history.domain_list || [],
|
|
11864
12138
|
error_analysis: history.error_analysis,
|
|
11865
12139
|
deploy_detail: formatDeployDetails(history),
|
|
11866
12140
|
connector_data_list: history.connector_data_list || [],
|
|
11867
|
-
|
|
12141
|
+
...mobileArtifactsOutput(history),
|
|
11868
12142
|
});
|
|
11869
12143
|
});
|
|
11870
12144
|
|
|
@@ -11889,11 +12163,12 @@ const registerDeployReadCommands = (deploy) => {
|
|
|
11889
12163
|
deploy_history_id: item.deploy_history_id,
|
|
11890
12164
|
status: getDeployStatusText(item.status),
|
|
11891
12165
|
commit_hash: item.commit_hash_short || item.commit_hash,
|
|
12166
|
+
commit_message: item.commit_message,
|
|
11892
12167
|
created_at: item.created_at,
|
|
11893
12168
|
can_rollback: item.can_rollback,
|
|
11894
12169
|
deploy_detail: formatDeployDetails(item),
|
|
11895
12170
|
connector_data_list: item.connector_data_list || [],
|
|
11896
|
-
|
|
12171
|
+
...mobileArtifactsOutput(item),
|
|
11897
12172
|
})),
|
|
11898
12173
|
next_page_token: data.next_page_token,
|
|
11899
12174
|
has_more: data.has_more,
|
|
@@ -11914,10 +12189,11 @@ const registerDeployReadCommands = (deploy) => {
|
|
|
11914
12189
|
deploy_history_id: item.deploy_history_id,
|
|
11915
12190
|
status: getDeployStatusText(item.status),
|
|
11916
12191
|
commit_hash: item.commit_hash_short || item.commit_hash,
|
|
12192
|
+
commit_message: item.commit_message,
|
|
11917
12193
|
created_at: item.created_at,
|
|
11918
12194
|
deploy_detail: formatDeployDetails(item),
|
|
11919
12195
|
domains: item.domain_list || [],
|
|
11920
|
-
|
|
12196
|
+
...mobileArtifactsOutput(item),
|
|
11921
12197
|
})),
|
|
11922
12198
|
});
|
|
11923
12199
|
});
|
|
@@ -11979,12 +12255,108 @@ const registerEnv = (code) => {
|
|
|
11979
12255
|
});
|
|
11980
12256
|
};
|
|
11981
12257
|
|
|
11982
|
-
|
|
12258
|
+
/* eslint-disable security/detect-non-literal-fs-filename -- validated project-local build output paths */
|
|
12259
|
+
|
|
12260
|
+
const BUILD_OUTPUT_DIRS = new Set(['dist', 'dist-tt']);
|
|
12261
|
+
const EXCLUDED_PARTS = new Set([
|
|
12262
|
+
'.git',
|
|
12263
|
+
'.env',
|
|
12264
|
+
'node_modules',
|
|
12265
|
+
]);
|
|
12266
|
+
const REPRODUCIBLE_ARCHIVE_MTIME = new Date(0);
|
|
12267
|
+
|
|
12268
|
+
const validateBuildOutput = async (
|
|
12269
|
+
sourceRoot,
|
|
12270
|
+
buildOutputDir,
|
|
12271
|
+
) => {
|
|
12272
|
+
if (!BUILD_OUTPUT_DIRS.has(buildOutputDir)) {
|
|
12273
|
+
throw new CliError(
|
|
12274
|
+
`Unsupported Mini-program build output directory: ${buildOutputDir}.`,
|
|
12275
|
+
'SOURCE_PACKAGE_FAILED',
|
|
12276
|
+
);
|
|
12277
|
+
}
|
|
12278
|
+
const buildOutputRoot = node_path.resolve(sourceRoot, buildOutputDir);
|
|
12279
|
+
try {
|
|
12280
|
+
const info = await promises.lstat(buildOutputRoot);
|
|
12281
|
+
if (info.isSymbolicLink() || !info.isDirectory()) {
|
|
12282
|
+
throw new Error('build output must be a regular directory');
|
|
12283
|
+
}
|
|
12284
|
+
const realSourceRoot = await promises.realpath(sourceRoot);
|
|
12285
|
+
const realBuildOutputRoot = await promises.realpath(buildOutputRoot);
|
|
12286
|
+
const relativeOutput = node_path.relative(realSourceRoot, realBuildOutputRoot);
|
|
12287
|
+
if (!relativeOutput || relativeOutput.startsWith('..')) {
|
|
12288
|
+
throw new Error('build output must be inside the source root');
|
|
12289
|
+
}
|
|
12290
|
+
} catch (error) {
|
|
12291
|
+
throw new CliError(
|
|
12292
|
+
`Invalid Mini-program build output ${buildOutputRoot}: ${error instanceof Error ? error.message : String(error)}`,
|
|
12293
|
+
'SOURCE_PACKAGE_FAILED',
|
|
12294
|
+
);
|
|
12295
|
+
}
|
|
12296
|
+
};
|
|
12297
|
+
|
|
12298
|
+
const shouldInclude = (
|
|
12299
|
+
archivePath,
|
|
12300
|
+
entry,
|
|
12301
|
+
) => {
|
|
12302
|
+
if ('isSymbolicLink' in entry && entry.isSymbolicLink()) {
|
|
12303
|
+
return false;
|
|
12304
|
+
}
|
|
12305
|
+
return !archivePath.split(/[\\/]/u).some(part =>
|
|
12306
|
+
EXCLUDED_PARTS.has(part) || part.startsWith('.git'),
|
|
12307
|
+
);
|
|
12308
|
+
};
|
|
12309
|
+
|
|
12310
|
+
const createMiniProgramPackage = async (
|
|
12311
|
+
sourceRoot,
|
|
12312
|
+
buildOutputDir,
|
|
12313
|
+
) => {
|
|
12314
|
+
const resolvedSourceRoot = node_path.resolve(sourceRoot);
|
|
12315
|
+
await validateBuildOutput(resolvedSourceRoot, buildOutputDir);
|
|
12316
|
+
const tempDirectory = await promises.mkdtemp(node_path.join(node_os.tmpdir(), 'coze-mini-program-source-'));
|
|
12317
|
+
const outputPath = node_path.join(tempDirectory, 'source.tar.gz');
|
|
12318
|
+
try {
|
|
12319
|
+
await tar.create(
|
|
12320
|
+
{
|
|
12321
|
+
cwd: resolvedSourceRoot,
|
|
12322
|
+
file: outputPath,
|
|
12323
|
+
filter: shouldInclude,
|
|
12324
|
+
gzip: true,
|
|
12325
|
+
mtime: REPRODUCIBLE_ARCHIVE_MTIME,
|
|
12326
|
+
portable: true,
|
|
12327
|
+
},
|
|
12328
|
+
[buildOutputDir],
|
|
12329
|
+
);
|
|
12330
|
+
const info = await promises.stat(outputPath);
|
|
12331
|
+
if (info.size === 0) {
|
|
12332
|
+
throw new Error('source archive is empty');
|
|
12333
|
+
}
|
|
12334
|
+
return {
|
|
12335
|
+
path: outputPath,
|
|
12336
|
+
sizeBytes: info.size,
|
|
12337
|
+
cleanup: () => promises.rm(tempDirectory, { recursive: true, force: true }),
|
|
12338
|
+
};
|
|
12339
|
+
} catch (error) {
|
|
12340
|
+
await promises.rm(tempDirectory, { recursive: true, force: true });
|
|
12341
|
+
throw new CliError(
|
|
12342
|
+
`Unable to package Mini-program build output: ${error instanceof Error ? error.message : String(error)}`,
|
|
12343
|
+
'SOURCE_PACKAGE_FAILED',
|
|
12344
|
+
);
|
|
12345
|
+
}
|
|
12346
|
+
};
|
|
12347
|
+
|
|
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; }
|
|
11983
12349
|
const CONNECTOR_IDS = {
|
|
11984
12350
|
wechat: '10000127',
|
|
11985
12351
|
douyin: '10000126',
|
|
11986
12352
|
} ;
|
|
11987
12353
|
|
|
12354
|
+
const MINI_PROGRAM_BUILD_OUTPUT_DIRS = {
|
|
12355
|
+
wechat: 'dist',
|
|
12356
|
+
douyin: 'dist-tt',
|
|
12357
|
+
} ;
|
|
12358
|
+
|
|
12359
|
+
|
|
11988
12360
|
|
|
11989
12361
|
|
|
11990
12362
|
|
|
@@ -12009,11 +12381,23 @@ const resolveConnectorId = (platform) => {
|
|
|
12009
12381
|
return connectorId;
|
|
12010
12382
|
};
|
|
12011
12383
|
|
|
12384
|
+
const resolveBuildOutputDir = (platform) => {
|
|
12385
|
+
const outputDir =
|
|
12386
|
+
MINI_PROGRAM_BUILD_OUTPUT_DIRS[platform ];
|
|
12387
|
+
if (!outputDir) {
|
|
12388
|
+
throw new CliError(
|
|
12389
|
+
`Unsupported Mini-program platform ${String(platform)}; expected wechat or douyin.`,
|
|
12390
|
+
'INVALID_MINIPROGRAM_PLATFORM',
|
|
12391
|
+
);
|
|
12392
|
+
}
|
|
12393
|
+
return outputDir;
|
|
12394
|
+
};
|
|
12395
|
+
|
|
12012
12396
|
const resolveProjectId = async (
|
|
12013
12397
|
command,
|
|
12014
12398
|
options,
|
|
12015
12399
|
) => {
|
|
12016
|
-
if (_optionalChain$
|
|
12400
|
+
if (_optionalChain$3([options, 'access', _ => _.projectId, 'optionalAccess', _2 => _2.trim, 'call', _3 => _3()])) {
|
|
12017
12401
|
return options.projectId.trim();
|
|
12018
12402
|
}
|
|
12019
12403
|
const runtime = await getRuntime(command);
|
|
@@ -12028,6 +12412,139 @@ const resolveProjectId = async (
|
|
|
12028
12412
|
return metadata.projectId;
|
|
12029
12413
|
};
|
|
12030
12414
|
|
|
12415
|
+
const MINI_PROGRAM_AUTH_STATUS = {
|
|
12416
|
+
authorized: 1,
|
|
12417
|
+
needAuthorize: 2,
|
|
12418
|
+
boundToOtherUser: 3,
|
|
12419
|
+
} ;
|
|
12420
|
+
|
|
12421
|
+
const getBoundToOtherUserMessage = (platform) => {
|
|
12422
|
+
const platformName = platform === 'wechat' ? 'WeChat' : 'Douyin';
|
|
12423
|
+
const platformConsole =
|
|
12424
|
+
platform === 'wechat' ? 'WeChat Public Platform' : 'Douyin Open Platform';
|
|
12425
|
+
return [
|
|
12426
|
+
`This ${platformName} Mini-program AppID is authorized by another Coze user.`,
|
|
12427
|
+
`If this is an AppID you manage, revoke Coze's previous third-party platform authorization in the ${platformConsole}, then rerun this auth command. The CLI will recheck the AppID and authorize it for your current Coze account.`,
|
|
12428
|
+
'If this is not your AppID, change --mini-app-id to an AppID for which you have administrator permission, then rerun this auth command.',
|
|
12429
|
+
].join(' ');
|
|
12430
|
+
};
|
|
12431
|
+
|
|
12432
|
+
const getAuthRequiredMessage = () =>
|
|
12433
|
+
'This Mini-program AppID is not authorized for the current Coze user. Run `coze-dev deploy mini-program auth` first.';
|
|
12434
|
+
|
|
12435
|
+
const getPreviewFailureMessage = (data
|
|
12436
|
+
|
|
12437
|
+
|
|
12438
|
+
) =>
|
|
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.';
|
|
12440
|
+
|
|
12441
|
+
const registerAuthorizationCommand = (miniProgram) => {
|
|
12442
|
+
miniProgram
|
|
12443
|
+
.command('auth')
|
|
12444
|
+
.description('Authorize a Mini-program AppID for the current Coze user')
|
|
12445
|
+
.requiredOption('--platform <platform>', 'wechat or douyin')
|
|
12446
|
+
.requiredOption('--mini-app-id <miniAppId>', 'Mini-program AppID')
|
|
12447
|
+
.option('--project-id <projectId>', 'Deployment Project ID')
|
|
12448
|
+
.option('--source-root <sourceRoot>', 'Directory containing .coze', '.')
|
|
12449
|
+
.action(async (options, command) => {
|
|
12450
|
+
const runtime = await getRuntime(command);
|
|
12451
|
+
const projectId = await resolveProjectId(command, options);
|
|
12452
|
+
const authorization = await runtime.client.authorizeMiniProgram({
|
|
12453
|
+
project_id: projectId,
|
|
12454
|
+
app_id: options.miniAppId || '',
|
|
12455
|
+
connector_id: resolveConnectorId(options.platform),
|
|
12456
|
+
redirect_url: 'https://code.coze.cn/coding/auth/callback/miniprogram',
|
|
12457
|
+
});
|
|
12458
|
+
if (authorization.status === MINI_PROGRAM_AUTH_STATUS.needAuthorize) {
|
|
12459
|
+
runtime.output.print({
|
|
12460
|
+
project_id: projectId,
|
|
12461
|
+
mini_app_id: options.miniAppId,
|
|
12462
|
+
platform: options.platform,
|
|
12463
|
+
authorization_required: true,
|
|
12464
|
+
auth_url: authorization.auth_url,
|
|
12465
|
+
});
|
|
12466
|
+
return;
|
|
12467
|
+
}
|
|
12468
|
+
if (authorization.status === MINI_PROGRAM_AUTH_STATUS.boundToOtherUser) {
|
|
12469
|
+
throw new CliError(
|
|
12470
|
+
getBoundToOtherUserMessage(options.platform),
|
|
12471
|
+
'MINIPROGRAM_AUTHORIZED_BY_OTHER_USER',
|
|
12472
|
+
);
|
|
12473
|
+
}
|
|
12474
|
+
if (authorization.status !== MINI_PROGRAM_AUTH_STATUS.authorized) {
|
|
12475
|
+
throw new CliError(
|
|
12476
|
+
`Unexpected Mini-program authorization status: ${String(authorization.status)}.`,
|
|
12477
|
+
'INVALID_RESPONSE',
|
|
12478
|
+
);
|
|
12479
|
+
}
|
|
12480
|
+
runtime.output.print({
|
|
12481
|
+
project_id: projectId,
|
|
12482
|
+
mini_app_id: options.miniAppId,
|
|
12483
|
+
platform: options.platform,
|
|
12484
|
+
authorized: true,
|
|
12485
|
+
});
|
|
12486
|
+
});
|
|
12487
|
+
};
|
|
12488
|
+
|
|
12489
|
+
const registerPreviewCommand = (miniProgram) => {
|
|
12490
|
+
miniProgram
|
|
12491
|
+
.command('preview')
|
|
12492
|
+
.description('Create a Mini-program preview QR code from the local build artifact')
|
|
12493
|
+
.requiredOption('--platform <platform>', 'wechat or douyin')
|
|
12494
|
+
.requiredOption('--mini-app-id <miniAppId>', 'Mini-program AppID')
|
|
12495
|
+
.option('--project-id <projectId>', 'Deployment Project ID')
|
|
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')
|
|
12498
|
+
.action(async (options, command) => {
|
|
12499
|
+
const runtime = await getRuntime(command);
|
|
12500
|
+
const projectId = await resolveProjectId(command, options);
|
|
12501
|
+
const authorization = await runtime.client.getMiniProgramAuthStatus({
|
|
12502
|
+
project_id: projectId,
|
|
12503
|
+
connector_id: resolveConnectorId(options.platform),
|
|
12504
|
+
});
|
|
12505
|
+
if (
|
|
12506
|
+
!authorization.is_authorized ||
|
|
12507
|
+
authorization.bound_related_id !== options.miniAppId
|
|
12508
|
+
) {
|
|
12509
|
+
throw new CliError(
|
|
12510
|
+
getAuthRequiredMessage(),
|
|
12511
|
+
'MINIPROGRAM_AUTH_REQUIRED',
|
|
12512
|
+
);
|
|
12513
|
+
}
|
|
12514
|
+
const sourceRoot = node_path.resolve(runtime.cwd, options.sourceRoot || '.');
|
|
12515
|
+
const buildOutputDir = resolveBuildOutputDir(options.platform);
|
|
12516
|
+
const sourcePackage = await createMiniProgramPackage(
|
|
12517
|
+
sourceRoot,
|
|
12518
|
+
buildOutputDir,
|
|
12519
|
+
);
|
|
12520
|
+
try {
|
|
12521
|
+
const content = await promises.readFile(sourcePackage.path);
|
|
12522
|
+
const data = await runtime.client.createMiniProgramPreview({
|
|
12523
|
+
project_id: projectId,
|
|
12524
|
+
app_id: options.miniAppId || '',
|
|
12525
|
+
connector_id: resolveConnectorId(options.platform),
|
|
12526
|
+
source_package_base64: content.toString('base64'),
|
|
12527
|
+
...(options.serverUrl ? { server_url: options.serverUrl } : {}),
|
|
12528
|
+
});
|
|
12529
|
+
if (data.failed) {
|
|
12530
|
+
throw new CliError(
|
|
12531
|
+
getPreviewFailureMessage(data),
|
|
12532
|
+
'MINIPROGRAM_PREVIEW_FAILED',
|
|
12533
|
+
);
|
|
12534
|
+
}
|
|
12535
|
+
runtime.output.print({
|
|
12536
|
+
project_id: projectId,
|
|
12537
|
+
mini_app_id: options.miniAppId,
|
|
12538
|
+
platform: options.platform,
|
|
12539
|
+
source_package_size_bytes: sourcePackage.sizeBytes,
|
|
12540
|
+
...data,
|
|
12541
|
+
});
|
|
12542
|
+
} finally {
|
|
12543
|
+
await sourcePackage.cleanup();
|
|
12544
|
+
}
|
|
12545
|
+
});
|
|
12546
|
+
};
|
|
12547
|
+
|
|
12031
12548
|
const registerMiniProgram = (code) => {
|
|
12032
12549
|
const miniProgram = code
|
|
12033
12550
|
.command('mini-program')
|
|
@@ -12112,13 +12629,26 @@ const registerMiniProgram = (code) => {
|
|
|
12112
12629
|
});
|
|
12113
12630
|
runtime.output.print({ project_id: projectId, platform: options.platform, unbound: true });
|
|
12114
12631
|
});
|
|
12632
|
+
|
|
12633
|
+
registerAuthorizationCommand(miniProgram);
|
|
12634
|
+
registerPreviewCommand(miniProgram);
|
|
12115
12635
|
};
|
|
12116
12636
|
|
|
12117
|
-
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; }
|
|
12118
12638
|
|
|
12119
12639
|
const POLL_INTERVAL_MS = 3000;
|
|
12120
12640
|
const MAX_CONSECUTIVE_RETRIES = 5;
|
|
12121
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;
|
|
12122
12652
|
|
|
12123
12653
|
const wait = async () =>
|
|
12124
12654
|
new Promise(resolve => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
@@ -12126,17 +12656,21 @@ const wait = async () =>
|
|
|
12126
12656
|
const isRetryablePollError = (error) =>
|
|
12127
12657
|
error instanceof CliError &&
|
|
12128
12658
|
error.code === 'API_REJECTED' &&
|
|
12129
|
-
Number(_optionalChain$
|
|
12659
|
+
Number(_optionalChain$2([error, 'access', _ => _.details, 'optionalAccess', _2 => _2.business_code])) === TRANSIENT_RPC_ERROR_CODE;
|
|
12130
12660
|
|
|
12131
12661
|
const pollHistory = async (
|
|
12132
12662
|
command,
|
|
12133
12663
|
appId,
|
|
12134
12664
|
deployHistoryId,
|
|
12665
|
+
timeoutMs = POLL_TIMEOUT_MS,
|
|
12135
12666
|
) => {
|
|
12136
12667
|
const runtime = await getRuntime(command);
|
|
12137
12668
|
const startedAt = Date.now();
|
|
12138
12669
|
let consecutiveFailures = 0;
|
|
12670
|
+
let lastStatus;
|
|
12671
|
+
let lastBeatAt = startedAt;
|
|
12139
12672
|
while (true) {
|
|
12673
|
+
const elapsed = () => Math.floor((Date.now() - startedAt) / 1000);
|
|
12140
12674
|
try {
|
|
12141
12675
|
const history = await runtime.client.getDeployHistory({
|
|
12142
12676
|
app_id: appId,
|
|
@@ -12145,11 +12679,21 @@ const pollHistory = async (
|
|
|
12145
12679
|
consecutiveFailures = 0;
|
|
12146
12680
|
const status = getDeployStatusText(history.status);
|
|
12147
12681
|
runtime.output.debug(
|
|
12148
|
-
`[deploy] History ${deployHistoryId}: ${status} (${String(
|
|
12682
|
+
`[deploy] History ${deployHistoryId}: ${status} (${String(elapsed())}s elapsed)`,
|
|
12149
12683
|
);
|
|
12150
12684
|
if (history.status && TERMINAL_STATUSES.has(history.status)) {
|
|
12151
12685
|
return history;
|
|
12152
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
|
+
}
|
|
12153
12697
|
} catch (error) {
|
|
12154
12698
|
if (!isRetryablePollError(error) || consecutiveFailures >= MAX_CONSECUTIVE_RETRIES) {
|
|
12155
12699
|
throw error;
|
|
@@ -12159,6 +12703,15 @@ const pollHistory = async (
|
|
|
12159
12703
|
`[deploy] Status check failed transiently; retrying (${String(consecutiveFailures)}/${String(MAX_CONSECUTIVE_RETRIES)}).`,
|
|
12160
12704
|
);
|
|
12161
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
|
+
}
|
|
12162
12715
|
await wait();
|
|
12163
12716
|
}
|
|
12164
12717
|
};
|
|
@@ -12505,52 +13058,6 @@ const registerDomain = (code) => {
|
|
|
12505
13058
|
});
|
|
12506
13059
|
};
|
|
12507
13060
|
|
|
12508
|
-
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; }
|
|
12509
|
-
|
|
12510
|
-
const firstPage = { page: 1, size: 1 };
|
|
12511
|
-
|
|
12512
|
-
const listSpaceRequest = (runtime) => ({
|
|
12513
|
-
...(runtime.config.organizationId
|
|
12514
|
-
? { organization_id: runtime.config.organizationId }
|
|
12515
|
-
: {}),
|
|
12516
|
-
...(runtime.config.enterpriseId
|
|
12517
|
-
? { enterprise_id: runtime.config.enterpriseId }
|
|
12518
|
-
: {}),
|
|
12519
|
-
});
|
|
12520
|
-
|
|
12521
|
-
const resolveDeploymentSpaceId = async (runtime) => {
|
|
12522
|
-
const configuredSpaceId = _optionalChain$2([runtime, 'access', _ => _.config, 'access', _2 => _2.spaceId, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]);
|
|
12523
|
-
const request = listSpaceRequest(runtime);
|
|
12524
|
-
if (configuredSpaceId) {
|
|
12525
|
-
const data = await runtime.client.listSpaces(request);
|
|
12526
|
-
if (!data.bot_space_list.some(space => space.id === configuredSpaceId)) {
|
|
12527
|
-
throw new CliError(
|
|
12528
|
-
`Space ID ${configuredSpaceId} is invalid or is not available to the current account.`,
|
|
12529
|
-
'INVALID_SPACE_ID',
|
|
12530
|
-
);
|
|
12531
|
-
}
|
|
12532
|
-
return configuredSpaceId;
|
|
12533
|
-
}
|
|
12534
|
-
|
|
12535
|
-
const data = await runtime.client.listSpaces({ ...request, ...firstPage });
|
|
12536
|
-
const space = data.bot_space_list.find(item => item.id);
|
|
12537
|
-
if (!space) {
|
|
12538
|
-
throw new CliError(
|
|
12539
|
-
'No available Space was found for the current account. Create or join a Space before deploying.',
|
|
12540
|
-
'SPACE_NOT_FOUND',
|
|
12541
|
-
);
|
|
12542
|
-
}
|
|
12543
|
-
|
|
12544
|
-
runtime.config.spaceId = space.id;
|
|
12545
|
-
try {
|
|
12546
|
-
await saveSharedConfig({ spaceId: space.id }, runtime.globalOptions);
|
|
12547
|
-
} catch (error) {
|
|
12548
|
-
runtime.output.warn(`Unable to save the auto-selected Space: ${String(error)}`);
|
|
12549
|
-
}
|
|
12550
|
-
runtime.output.debug(`Auto-selected Space: ${space.name || space.id} (${space.id})`);
|
|
12551
|
-
return space.id;
|
|
12552
|
-
};
|
|
12553
|
-
|
|
12554
13061
|
const PACKAGE_SCRIPT_CANDIDATES = [
|
|
12555
13062
|
node_path.resolve(__dirname, 'deploy/package-project.js'),
|
|
12556
13063
|
node_path.resolve(__dirname, '../../../scripts/deploy/package-project.js'),
|
|
@@ -12847,9 +13354,8 @@ const getConnectorConfigs = (connectorIds) =>
|
|
|
12847
13354
|
|
|
12848
13355
|
// Keep deployment option and output contracts together for auditing against the V2 IDL.
|
|
12849
13356
|
// eslint-disable-next-line @coze-arch/max-line-per-function -- keep V2 deployment contracts together
|
|
12850
|
-
const registerDeploy = (
|
|
12851
|
-
|
|
12852
|
-
.command('deploy')
|
|
13357
|
+
const registerDeploy = (deploy) => {
|
|
13358
|
+
deploy
|
|
12853
13359
|
.description('Deploy an application using deployment V2')
|
|
12854
13360
|
.option('--source-root <sourceRoot>', 'Local source root', '.')
|
|
12855
13361
|
.option('--project-id <projectId>', 'Project ID for the first deployment')
|
|
@@ -12922,14 +13428,21 @@ const registerDeploy = (code) => {
|
|
|
12922
13428
|
}
|
|
12923
13429
|
}
|
|
12924
13430
|
if (!projectId) {
|
|
12925
|
-
runtime.output.debug(
|
|
12926
|
-
|
|
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);
|
|
12927
13437
|
const project = await runtime.client.createDeploymentProject({
|
|
12928
|
-
space_id:
|
|
13438
|
+
space_id: '0',
|
|
12929
13439
|
user_query: deploymentName || 'CLI deployment project',
|
|
12930
13440
|
project_type: resolveCreationProjectType(metadata.projectType),
|
|
12931
13441
|
create_source: 'cli',
|
|
12932
|
-
project_settings: {
|
|
13442
|
+
project_settings: {
|
|
13443
|
+
project_symbol: 'v3.5',
|
|
13444
|
+
...(cozeAccountId ? { extra: { coze_account_id: cozeAccountId } } : {}),
|
|
13445
|
+
},
|
|
12933
13446
|
});
|
|
12934
13447
|
projectId = project.project_id;
|
|
12935
13448
|
projectCreated = true;
|
|
@@ -13018,6 +13531,7 @@ const registerDeploy = (code) => {
|
|
|
13018
13531
|
...(appId ? { app_id: appId } : { project_id: projectId }),
|
|
13019
13532
|
application_type: applicationType,
|
|
13020
13533
|
commit_hash: commitHash,
|
|
13534
|
+
...(options.message ? { commit_message: options.message } : {}),
|
|
13021
13535
|
...(!appId
|
|
13022
13536
|
? { name: deploymentName, source_root: sourceRoot }
|
|
13023
13537
|
: {}),
|
|
@@ -13061,16 +13575,19 @@ const registerDeploy = (code) => {
|
|
|
13061
13575
|
const history = options.wait
|
|
13062
13576
|
? await pollHistory(command, result.app_id, deployHistoryId)
|
|
13063
13577
|
: undefined;
|
|
13578
|
+
// 不带 --wait 时 history 是 undefined,产物必然还没落库:这里一定会带上
|
|
13579
|
+
// artifacts_pending,而不是甩一个看起来像「查过了,没有」的空数组出去。
|
|
13580
|
+
const effectiveStatus = _nullishCoalesce(_optionalChain([history, 'optionalAccess', _2 => _2.status]), () => ( result.status));
|
|
13064
13581
|
runtime.output.print({
|
|
13065
13582
|
app_id: result.app_id,
|
|
13066
13583
|
deploy_history_id: deployHistoryId,
|
|
13067
13584
|
version: result.version,
|
|
13068
13585
|
commit_hash: commitHash,
|
|
13069
|
-
status: getDeployStatusText(
|
|
13586
|
+
status: getDeployStatusText(effectiveStatus),
|
|
13070
13587
|
source_package_size_bytes: sourcePackage.sizeBytes,
|
|
13071
13588
|
upload_mode: deployment.uploadMode,
|
|
13072
13589
|
local_link: appId && !projectCreated ? 'unchanged' : 'written',
|
|
13073
|
-
|
|
13590
|
+
...mobileArtifactsOutput(history, effectiveStatus),
|
|
13074
13591
|
});
|
|
13075
13592
|
});
|
|
13076
13593
|
|
|
@@ -13173,7 +13690,7 @@ const registerDeploy = (code) => {
|
|
|
13173
13690
|
.action(async (options, command) => {
|
|
13174
13691
|
const runtime = await getRuntime(command);
|
|
13175
13692
|
const appId = await requireAppId(runtime.cwd, getDeployAppIdOption(options, command));
|
|
13176
|
-
let key = _optionalChain([options, 'access',
|
|
13693
|
+
let key = _optionalChain([options, 'access', _3 => _3.key, 'optionalAccess', _4 => _4.trim, 'call', _5 => _5()]);
|
|
13177
13694
|
if (!key) {
|
|
13178
13695
|
const history = await runtime.client.getDeployHistory({
|
|
13179
13696
|
app_id: appId,
|
|
@@ -13215,7 +13732,7 @@ const registerDeploy = (code) => {
|
|
|
13215
13732
|
const runtime = await getRuntime(command);
|
|
13216
13733
|
const appId = await requireAppId(runtime.cwd, getDeployAppIdOption(options, command));
|
|
13217
13734
|
const application = await runtime.client.getApplication(appId);
|
|
13218
|
-
const commitHash = options.commitId || _optionalChain([application, 'access',
|
|
13735
|
+
const commitHash = options.commitId || _optionalChain([application, 'access', _6 => _6.latest_deployment, 'optionalAccess', _7 => _7.commit_hash]);
|
|
13219
13736
|
if (!commitHash) {
|
|
13220
13737
|
throw new CliError('No deployment commit is available.', 'DEPLOYMENT_NOT_FOUND');
|
|
13221
13738
|
}
|
|
@@ -13238,9 +13755,20 @@ const registerCommands = (program) => {
|
|
|
13238
13755
|
registerAuth(program);
|
|
13239
13756
|
registerContext(program);
|
|
13240
13757
|
registerDoctor(program);
|
|
13241
|
-
|
|
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');
|
|
13242
13770
|
registerApp(code);
|
|
13243
|
-
registerDeploy(code);
|
|
13771
|
+
registerDeploy(code.command('deploy'));
|
|
13244
13772
|
registerDomain(code);
|
|
13245
13773
|
registerEnv(code);
|
|
13246
13774
|
registerMiniProgram(code);
|
|
@@ -13249,6 +13777,7 @@ const registerCommands = (program) => {
|
|
|
13249
13777
|
const configureDeployCommand = (command) => {
|
|
13250
13778
|
markDeployCommand(command)
|
|
13251
13779
|
.description('Deploy and manage Coze applications')
|
|
13780
|
+
.enablePositionalOptions()
|
|
13252
13781
|
.option('--format <format>', 'Output format: json or text', 'json')
|
|
13253
13782
|
.option('--config <path>', 'Shared Coze CLI config path')
|
|
13254
13783
|
.option('--org-id <id>', 'Override organization ID')
|