@lark-apaas/fullstack-cli 1.1.59-alpha.20260721164103 → 1.1.59-alpha.20260722050835
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/dist/index.js +92 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9829,6 +9829,22 @@ function createPreviewArtifactSwitcher(options) {
|
|
|
9829
9829
|
}
|
|
9830
9830
|
|
|
9831
9831
|
// src/commands/preview-artifact/runtime.ts
|
|
9832
|
+
function measure(timings, phase, operation, detail) {
|
|
9833
|
+
const startedAt = Date.now();
|
|
9834
|
+
try {
|
|
9835
|
+
return operation();
|
|
9836
|
+
} finally {
|
|
9837
|
+
timings.push({ phase, durationMs: Date.now() - startedAt, ...detail });
|
|
9838
|
+
}
|
|
9839
|
+
}
|
|
9840
|
+
async function measureAsync(timings, phase, operation, detail) {
|
|
9841
|
+
const startedAt = Date.now();
|
|
9842
|
+
try {
|
|
9843
|
+
return await operation();
|
|
9844
|
+
} finally {
|
|
9845
|
+
timings.push({ phase, durationMs: Date.now() - startedAt, ...detail });
|
|
9846
|
+
}
|
|
9847
|
+
}
|
|
9832
9848
|
function sleep2(ms) {
|
|
9833
9849
|
return new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
9834
9850
|
}
|
|
@@ -9937,16 +9953,21 @@ async function waitForCachedRuntime(origin, appBasePath, businessApiPath, timeou
|
|
|
9937
9953
|
throw new Error("cached runtime readiness timed out");
|
|
9938
9954
|
}
|
|
9939
9955
|
async function startPreviewArtifactRuntime(options) {
|
|
9940
|
-
const
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
|
|
9956
|
+
const timings = [...options.initialTimings ?? []];
|
|
9957
|
+
const resolved = measure(
|
|
9958
|
+
timings,
|
|
9959
|
+
"metadata_validate",
|
|
9960
|
+
() => resolveCurrentPreviewArtifact({
|
|
9961
|
+
storeRoot: options.storeRoot,
|
|
9962
|
+
nodeVersion: process.version,
|
|
9963
|
+
platform: process.platform,
|
|
9964
|
+
arch: process.arch,
|
|
9965
|
+
buildEnvironmentSha256: previewArtifactBuildEnvironmentHash(
|
|
9966
|
+
options.environment,
|
|
9967
|
+
options.appBasePath
|
|
9968
|
+
)
|
|
9969
|
+
})
|
|
9970
|
+
);
|
|
9950
9971
|
if (!resolved.resolved) return { started: false, reasons: resolved.reasons };
|
|
9951
9972
|
const runtimeRoot = path32.resolve(options.runtimeRoot);
|
|
9952
9973
|
const markerFile = path32.resolve(options.markerFile);
|
|
@@ -9971,14 +9992,22 @@ async function startPreviewArtifactRuntime(options) {
|
|
|
9971
9992
|
path32.join(runtimeRoot, `${resolved.generationId}-`)
|
|
9972
9993
|
);
|
|
9973
9994
|
const runtimeBundle = path32.join(runtimeDir, "server.bundle.cjs");
|
|
9974
|
-
|
|
9975
|
-
|
|
9976
|
-
|
|
9995
|
+
const serverSource = path32.join(resolved.generationDir, "server.bundle.cjs");
|
|
9996
|
+
measure(
|
|
9997
|
+
timings,
|
|
9998
|
+
"server_materialize",
|
|
9999
|
+
() => fs36.copyFileSync(serverSource, runtimeBundle),
|
|
10000
|
+
{ bytes: resolved.manifest.files.server.bytes }
|
|
9977
10001
|
);
|
|
9978
10002
|
const clientRoot = path32.join(runtimeDir, "dist", "client");
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
10003
|
+
measure(
|
|
10004
|
+
timings,
|
|
10005
|
+
"client_archive_inspect_extract",
|
|
10006
|
+
() => extractClientArchive(
|
|
10007
|
+
path32.join(resolved.generationDir, "client.zip"),
|
|
10008
|
+
clientRoot
|
|
10009
|
+
),
|
|
10010
|
+
{ bytes: resolved.manifest.files.client.bytes }
|
|
9982
10011
|
);
|
|
9983
10012
|
const cachedServerPort = options.cachedServerPort === 0 ? await reservePort2() : options.cachedServerPort;
|
|
9984
10013
|
cachedRuntime = spawn3(process.execPath, [runtimeBundle], {
|
|
@@ -9992,13 +10021,25 @@ async function startPreviewArtifactRuntime(options) {
|
|
|
9992
10021
|
}
|
|
9993
10022
|
});
|
|
9994
10023
|
const cachedOrigin = `http://127.0.0.1:${cachedServerPort}`;
|
|
9995
|
-
await
|
|
9996
|
-
|
|
9997
|
-
|
|
9998
|
-
|
|
9999
|
-
|
|
10000
|
-
|
|
10024
|
+
await measureAsync(
|
|
10025
|
+
timings,
|
|
10026
|
+
"backend_spawn_to_business_ready",
|
|
10027
|
+
() => waitForCachedRuntime(
|
|
10028
|
+
cachedOrigin,
|
|
10029
|
+
options.appBasePath,
|
|
10030
|
+
options.businessApiPath,
|
|
10031
|
+
options.startupTimeoutMs ?? 3e4,
|
|
10032
|
+
cachedRuntime
|
|
10033
|
+
)
|
|
10034
|
+
);
|
|
10035
|
+
const cachedAssetFiles = measure(
|
|
10036
|
+
timings,
|
|
10037
|
+
"asset_index",
|
|
10038
|
+
() => collectCachedAssetFiles(clientRoot, options.appBasePath)
|
|
10001
10039
|
);
|
|
10040
|
+
timings[timings.length - 1].fileCount = new Set(
|
|
10041
|
+
cachedAssetFiles.values()
|
|
10042
|
+
).size;
|
|
10002
10043
|
switcher = createPreviewArtifactSwitcher({
|
|
10003
10044
|
listenHost: options.listenHost,
|
|
10004
10045
|
listenPort: options.listenPort,
|
|
@@ -10006,13 +10047,14 @@ async function startPreviewArtifactRuntime(options) {
|
|
|
10006
10047
|
cachedTarget: { host: "127.0.0.1", port: cachedServerPort },
|
|
10007
10048
|
freshTarget: { host: "127.0.0.1", port: options.freshClientPort },
|
|
10008
10049
|
freshBusinessPath: options.businessApiPath,
|
|
10009
|
-
cachedAssetFiles
|
|
10010
|
-
clientRoot,
|
|
10011
|
-
options.appBasePath
|
|
10012
|
-
),
|
|
10050
|
+
cachedAssetFiles,
|
|
10013
10051
|
pollIntervalMs: options.pollIntervalMs
|
|
10014
10052
|
});
|
|
10015
|
-
const address = await
|
|
10053
|
+
const address = await measureAsync(
|
|
10054
|
+
timings,
|
|
10055
|
+
"switcher_listen",
|
|
10056
|
+
() => switcher.start()
|
|
10057
|
+
);
|
|
10016
10058
|
const runtimeMarker = {
|
|
10017
10059
|
schemaVersion: 1,
|
|
10018
10060
|
status: "cached-serving",
|
|
@@ -10021,8 +10063,14 @@ async function startPreviewArtifactRuntime(options) {
|
|
|
10021
10063
|
cachedServerPort,
|
|
10022
10064
|
freshServerPort: options.freshServerPort,
|
|
10023
10065
|
freshClientPort: options.freshClientPort,
|
|
10024
|
-
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
10066
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10067
|
+
timings
|
|
10025
10068
|
};
|
|
10069
|
+
measure(
|
|
10070
|
+
timings,
|
|
10071
|
+
"marker_write",
|
|
10072
|
+
() => writeMarkerAtomic(markerFile, runtimeMarker)
|
|
10073
|
+
);
|
|
10026
10074
|
writeMarkerAtomic(markerFile, runtimeMarker);
|
|
10027
10075
|
const cutover = switcher.cutover.then(async (result) => {
|
|
10028
10076
|
if (result.switched) {
|
|
@@ -10185,11 +10233,24 @@ var previewArtifactRuntimeCommand = {
|
|
|
10185
10233
|
"JSON application environment passed only to cached application child"
|
|
10186
10234
|
).action(
|
|
10187
10235
|
async (options) => {
|
|
10236
|
+
const environmentLoadStartedAt = Date.now();
|
|
10237
|
+
const environment = readPreviewArtifactEnvironmentFile(
|
|
10238
|
+
options.environmentFile
|
|
10239
|
+
);
|
|
10240
|
+
const environmentLoadDurationMs = Date.now() - environmentLoadStartedAt;
|
|
10188
10241
|
const runtime = await startPreviewArtifactRuntime({
|
|
10189
10242
|
...options,
|
|
10190
|
-
environment
|
|
10191
|
-
|
|
10192
|
-
|
|
10243
|
+
environment,
|
|
10244
|
+
initialTimings: [
|
|
10245
|
+
{
|
|
10246
|
+
phase: "cli_bootstrap",
|
|
10247
|
+
durationMs: Math.max(0, Math.round(process.uptime() * 1e3))
|
|
10248
|
+
},
|
|
10249
|
+
{
|
|
10250
|
+
phase: "environment_load",
|
|
10251
|
+
durationMs: environmentLoadDurationMs
|
|
10252
|
+
}
|
|
10253
|
+
]
|
|
10193
10254
|
});
|
|
10194
10255
|
if (!runtime.started) {
|
|
10195
10256
|
console.log(JSON.stringify(runtime));
|