openxiangda 1.0.145 → 1.0.146
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli.js +44 -11
- package/package.json +1 -1
package/lib/cli.js
CHANGED
|
@@ -4682,7 +4682,8 @@ async function runtime(args) {
|
|
|
4682
4682
|
' openxiangda runtime releases --profile <name>',
|
|
4683
4683
|
'说明:',
|
|
4684
4684
|
' - deploy 上传当前工作区 dist/ 并激活 React SPA runtime release。',
|
|
4685
|
-
' - 默认 --upload-mode auto;multipart 上传遇到 403
|
|
4685
|
+
' - 默认 --upload-mode auto;multipart 上传遇到 403 时自动切换到平台内置对象存储直传。',
|
|
4686
|
+
' - --upload-mode oss-direct 是兼容参数名,实际 provider 由平台内置存储配置决定。',
|
|
4686
4687
|
' - 如果平台服务较旧不支持分片上传,可临时使用 --upload-mode legacy-json。',
|
|
4687
4688
|
' - runtime 只发布前端产物;表单、流程、通知等资源仍走 resource publish。',
|
|
4688
4689
|
].join('\n'));
|
|
@@ -4752,8 +4753,12 @@ async function runtime(args) {
|
|
|
4752
4753
|
assetBaseUrl = plan.assetBaseUrl;
|
|
4753
4754
|
if (uploadMode === 'auto') {
|
|
4754
4755
|
effectiveUploadMode = 'oss-direct';
|
|
4756
|
+
const storageProvider = resolveRuntimeStorageProvider(
|
|
4757
|
+
plan.storageProvider,
|
|
4758
|
+
plan.provider
|
|
4759
|
+
);
|
|
4755
4760
|
printRuntimeProgress(
|
|
4756
|
-
`runtime builtin
|
|
4761
|
+
`runtime builtin storage available; using ${formatRuntimeStorageProvider(storageProvider)} direct upload traceId=${traceId}`
|
|
4757
4762
|
);
|
|
4758
4763
|
}
|
|
4759
4764
|
}
|
|
@@ -4764,7 +4769,7 @@ async function runtime(args) {
|
|
|
4764
4769
|
effectiveUploadMode = 'auto';
|
|
4765
4770
|
assetBaseUrl = gatewayAssetBaseUrl;
|
|
4766
4771
|
printRuntimeProgress(
|
|
4767
|
-
`runtime builtin
|
|
4772
|
+
`runtime builtin storage preflight unavailable; using staged upload first traceId=${traceId}`
|
|
4768
4773
|
);
|
|
4769
4774
|
}
|
|
4770
4775
|
}
|
|
@@ -4821,7 +4826,7 @@ async function runtime(args) {
|
|
|
4821
4826
|
}
|
|
4822
4827
|
effectiveUploadMode = 'oss-direct';
|
|
4823
4828
|
printRuntimeProgress(
|
|
4824
|
-
`runtime staged upload blocked by HTTP 403; fallback to
|
|
4829
|
+
`runtime staged upload blocked by HTTP 403; fallback to builtin storage direct upload traceId=${traceId}`
|
|
4825
4830
|
);
|
|
4826
4831
|
releaseFiles = await uploadRuntimeDistFilesOssDirect({
|
|
4827
4832
|
config,
|
|
@@ -4863,6 +4868,10 @@ async function runtime(args) {
|
|
|
4863
4868
|
assetBaseUrl: releaseAssetBaseUrl,
|
|
4864
4869
|
activated: !flags['no-activate'],
|
|
4865
4870
|
uploadMode: effectiveUploadMode,
|
|
4871
|
+
storageProvider:
|
|
4872
|
+
data?.storageProvider ||
|
|
4873
|
+
releaseFiles.find(file => file.storageProvider)?.storageProvider ||
|
|
4874
|
+
null,
|
|
4866
4875
|
traceId,
|
|
4867
4876
|
};
|
|
4868
4877
|
if (flags.json) return writeJson(result);
|
|
@@ -5019,6 +5028,10 @@ async function uploadRuntimeDistFilesOssDirect(options) {
|
|
|
5019
5028
|
);
|
|
5020
5029
|
const uploadFiles = Array.isArray(plan?.files) ? plan.files : [];
|
|
5021
5030
|
const uploadByPath = new Map(uploadFiles.map(file => [file.path, file]));
|
|
5031
|
+
const planStorageProvider = resolveRuntimeStorageProvider(
|
|
5032
|
+
plan?.storageProvider,
|
|
5033
|
+
plan?.provider
|
|
5034
|
+
);
|
|
5022
5035
|
let completed = 0;
|
|
5023
5036
|
const results = await runWithConcurrency(
|
|
5024
5037
|
files,
|
|
@@ -5026,14 +5039,19 @@ async function uploadRuntimeDistFilesOssDirect(options) {
|
|
|
5026
5039
|
async file => {
|
|
5027
5040
|
const uploadInfo = uploadByPath.get(file.path);
|
|
5028
5041
|
if (!uploadInfo?.uploadUrl) {
|
|
5029
|
-
fail(`runtime
|
|
5042
|
+
fail(`runtime 内置对象存储上传计划缺少文件: ${file.path}`);
|
|
5030
5043
|
}
|
|
5044
|
+
const storageProvider = resolveRuntimeStorageProvider(
|
|
5045
|
+
uploadInfo.storageProvider,
|
|
5046
|
+
uploadInfo.provider,
|
|
5047
|
+
planStorageProvider
|
|
5048
|
+
);
|
|
5031
5049
|
const uploaded = await uploadRuntimeDistFileToSignedUrl(options, file, uploadInfo);
|
|
5032
5050
|
completed += 1;
|
|
5033
5051
|
printRuntimeProgress(
|
|
5034
|
-
`runtime
|
|
5052
|
+
`runtime ${formatRuntimeStorageProvider(storageProvider)} file uploaded [${completed}/${files.length}] ${file.path} ${formatBytes(file.size)} traceId=${options.traceId}`
|
|
5035
5053
|
);
|
|
5036
|
-
return uploaded;
|
|
5054
|
+
return { ...uploaded, storageProvider };
|
|
5037
5055
|
}
|
|
5038
5056
|
);
|
|
5039
5057
|
return results.map(file => ({
|
|
@@ -5041,7 +5059,7 @@ async function uploadRuntimeDistFilesOssDirect(options) {
|
|
|
5041
5059
|
size: file.size,
|
|
5042
5060
|
sha256: file.sha256,
|
|
5043
5061
|
contentType: file.contentType,
|
|
5044
|
-
storageProvider:
|
|
5062
|
+
storageProvider: resolveRuntimeStorageProvider(file.storageProvider),
|
|
5045
5063
|
objectName: file.objectName,
|
|
5046
5064
|
bucketName: file.bucketName,
|
|
5047
5065
|
}));
|
|
@@ -5061,16 +5079,16 @@ async function uploadRuntimeDistFileToSignedUrl(options, file, uploadInfo) {
|
|
|
5061
5079
|
});
|
|
5062
5080
|
} catch (error) {
|
|
5063
5081
|
if (isAbortError(error)) {
|
|
5064
|
-
throw new Error(`runtime
|
|
5082
|
+
throw new Error(`runtime 内置对象存储文件上传超时: ${file.path}, timeout=${timeoutMs}ms`);
|
|
5065
5083
|
}
|
|
5066
|
-
throw new Error(formatFetchError(error, `runtime
|
|
5084
|
+
throw new Error(formatFetchError(error, `runtime builtin storage upload ${file.path}`));
|
|
5067
5085
|
} finally {
|
|
5068
5086
|
clearTimeout(timer);
|
|
5069
5087
|
}
|
|
5070
5088
|
if (!response.ok) {
|
|
5071
5089
|
const text = await response.text().catch(() => '');
|
|
5072
5090
|
throw new Error(
|
|
5073
|
-
`runtime
|
|
5091
|
+
`runtime 内置对象存储文件上传失败: ${file.path}, HTTP ${response.status}: ${
|
|
5074
5092
|
text || response.statusText || 'request failed'
|
|
5075
5093
|
}`
|
|
5076
5094
|
);
|
|
@@ -5152,6 +5170,21 @@ function normalizeRuntimeUploadMode(value) {
|
|
|
5152
5170
|
fail(`--upload-mode 只支持 auto、staged、oss-direct 或 legacy-json,当前: ${value}`);
|
|
5153
5171
|
}
|
|
5154
5172
|
|
|
5173
|
+
function resolveRuntimeStorageProvider(...values) {
|
|
5174
|
+
for (const value of values) {
|
|
5175
|
+
const provider = String(value || '').trim().toLowerCase();
|
|
5176
|
+
if (provider) return provider;
|
|
5177
|
+
}
|
|
5178
|
+
return 'oss';
|
|
5179
|
+
}
|
|
5180
|
+
|
|
5181
|
+
function formatRuntimeStorageProvider(value) {
|
|
5182
|
+
const provider = resolveRuntimeStorageProvider(value);
|
|
5183
|
+
if (provider === 'oss') return 'OSS';
|
|
5184
|
+
if (provider === 'cos') return 'COS';
|
|
5185
|
+
return provider.toUpperCase();
|
|
5186
|
+
}
|
|
5187
|
+
|
|
5155
5188
|
function isRuntimeStagedUploadBlocked(error) {
|
|
5156
5189
|
return /^HTTP 403\b/.test(String(error?.message || ''));
|
|
5157
5190
|
}
|