@sanity/runtime-cli 17.12.0 → 17.13.0-next.g06897b0
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 +21 -21
- package/dist/actions/blueprints/assets.d.ts +23 -20
- package/dist/actions/blueprints/assets.js +18 -87
- package/dist/actions/blueprints/logs-polling.d.ts +3 -5
- package/dist/actions/blueprints/logs-polling.js +4 -9
- package/dist/actions/blueprints/logs.d.ts +1 -2
- package/dist/actions/blueprints/logs.js +1 -3
- package/dist/actions/blueprints/operations-state.d.ts +10 -0
- package/dist/actions/blueprints/operations-state.js +42 -0
- package/dist/actions/blueprints/operations.d.ts +2 -9
- package/dist/actions/blueprints/operations.js +1 -15
- package/dist/actions/blueprints/pre-deploy.d.ts +19 -11
- package/dist/actions/blueprints/pre-deploy.js +95 -27
- package/dist/actions/blueprints/process-assets.d.ts +13 -11
- package/dist/actions/blueprints/process-assets.js +9 -7
- package/dist/actions/blueprints/stacks.d.ts +4 -4
- package/dist/actions/blueprints/stacks.js +2 -4
- package/dist/actions/blueprints/wait-for-operation.d.ts +1 -10
- package/dist/actions/blueprints/wait-for-operation.js +56 -101
- package/dist/baseCommands.js +6 -1
- package/dist/commands/blueprints/deploy.js +2 -0
- package/dist/commands/functions/dev.js +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.js +6 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/cores/blueprints/config.js +1 -1
- package/dist/cores/blueprints/deploy.d.ts +2 -0
- package/dist/cores/blueprints/deploy.js +38 -7
- package/dist/cores/blueprints/destroy.js +4 -2
- package/dist/cores/blueprints/doctor.js +2 -2
- package/dist/cores/blueprints/init.js +3 -1
- package/dist/cores/blueprints/logs.js +11 -5
- package/dist/cores/blueprints/mint-deploy-token.js +2 -1
- package/dist/cores/functions/build.js +4 -5
- package/dist/cores/functions/test.js +3 -1
- package/dist/cores/index.js +3 -1
- package/dist/server/app.d.ts +2 -1
- package/dist/server/app.js +4 -1
- package/dist/server/handlers/invoke.js +1 -1
- package/dist/server/static/vendor/vendor.bundle.js +21791 -25197
- package/dist/server/static/web-socket.js +4 -2
- package/dist/utils/blueprints/deploy-metadata.d.ts +10 -0
- package/dist/utils/blueprints/deploy-metadata.js +17 -0
- package/dist/utils/blueprints/resolve-deployed-resources.d.ts +2 -3
- package/dist/utils/blueprints/resolve-deployed-resources.js +2 -2
- package/dist/utils/blueprints/wait-for.d.ts +60 -0
- package/dist/utils/blueprints/wait-for.js +115 -0
- package/dist/utils/display/blueprints-formatting.d.ts +1 -0
- package/dist/utils/display/blueprints-formatting.js +17 -3
- package/dist/utils/display/dates.d.ts +0 -2
- package/dist/utils/display/dates.js +0 -25
- package/dist/utils/display/functions-formatting.js +1 -1
- package/dist/utils/display/prompt.js +5 -2
- package/dist/utils/display/resources-formatting.d.ts +6 -0
- package/dist/utils/display/resources-formatting.js +17 -0
- package/dist/utils/functions/child-runtime/durable.js +2 -2
- package/dist/utils/functions/dependency-info.d.ts +30 -0
- package/dist/utils/functions/dependency-info.js +57 -0
- package/dist/utils/functions/invoke/assert-console.d.ts +5 -0
- package/dist/utils/functions/invoke/assert-console.js +60 -0
- package/dist/utils/functions/invoke/local.js +9 -0
- package/dist/utils/functions/is-folder-larger-than.d.ts +5 -0
- package/dist/utils/functions/is-folder-larger-than.js +38 -0
- package/dist/utils/functions/prepare-asset.d.ts +2 -0
- package/dist/utils/functions/prepare-asset.js +59 -23
- package/dist/utils/studios/prepare-asset.js +36 -9
- package/dist/utils/types.d.ts +35 -4
- package/dist/utils/types.js +0 -3
- package/oclif.manifest.json +2 -2
- package/package.json +17 -19
- package/skills/functions-dev.md +1 -1
- package/dist/utils/functions/get-folder-size.d.ts +0 -5
- package/dist/utils/functions/get-folder-size.js +0 -24
|
@@ -3,15 +3,19 @@ import { preDeploy } from '../../actions/blueprints/pre-deploy.js';
|
|
|
3
3
|
import { getStack, updateStack } from '../../actions/blueprints/stacks.js';
|
|
4
4
|
import { waitForOperation } from '../../actions/blueprints/wait-for-operation.js';
|
|
5
5
|
import { checkUserPermission } from '../../actions/sanity/access.js';
|
|
6
|
+
import { getClientMetadata } from '../../utils/blueprints/deploy-metadata.js';
|
|
6
7
|
import { extractDurableConfig } from '../../utils/blueprints/extract-durable-config.js';
|
|
7
8
|
import { createHintCollector } from '../../utils/blueprints/hints.js';
|
|
9
|
+
import { createWaitFor } from '../../utils/blueprints/wait-for.js';
|
|
10
|
+
import { formatStudioUrls } from '../../utils/display/blueprints-formatting.js';
|
|
8
11
|
import { check, niceId, severe } from '../../utils/display/presenters.js';
|
|
9
12
|
import { CODE_OPERATION_UNCONFIRMED, EXIT_OPERATION_UNCONFIRMED } from '../../utils/exit-codes.js';
|
|
10
13
|
import { runCommand } from '../../utils/package-manager.js';
|
|
11
14
|
import { styleText } from '../../utils/style-text.js';
|
|
15
|
+
import { createTracedFetch } from '../../utils/traced-fetch.js';
|
|
12
16
|
import { getWarnings } from '../../utils/warnings.js';
|
|
13
17
|
export async function blueprintDeployCore(options) {
|
|
14
|
-
const { bin = 'sanity', log: logger, auth, stackId, scopeType, scopeId, deployedStack, blueprint, flags, } = options;
|
|
18
|
+
const { bin = 'sanity', log: logger, auth, stackId, scopeType, scopeId, deployedStack, blueprint, cliVersion, flags, } = options;
|
|
15
19
|
const { verbose } = flags;
|
|
16
20
|
const noWait = flags['no-wait'] || false;
|
|
17
21
|
const stackName = flags['new-stack-name'] ?? deployedStack.name;
|
|
@@ -20,7 +24,8 @@ export async function blueprintDeployCore(options) {
|
|
|
20
24
|
const workspaceWarnings = getWarnings({ dir: blueprintFileDir });
|
|
21
25
|
logger(`Deploying "${stackName}" ${niceId(deployedStack.id)}...`);
|
|
22
26
|
try {
|
|
23
|
-
const
|
|
27
|
+
const fetchFn = createTracedFetch(logger);
|
|
28
|
+
const { ok: checkOk, stack: currentStack } = await getStack({ stackId, auth, fetchFn });
|
|
24
29
|
if (!checkOk) {
|
|
25
30
|
return { success: false, error: 'Failed to check current Stack status' };
|
|
26
31
|
}
|
|
@@ -37,6 +42,7 @@ export async function blueprintDeployCore(options) {
|
|
|
37
42
|
}
|
|
38
43
|
const resources = [...blueprint.resources];
|
|
39
44
|
await extractDurableConfig(resources, blueprintFileDir);
|
|
45
|
+
let spinner;
|
|
40
46
|
const preDeployResult = await preDeploy({
|
|
41
47
|
scopeType,
|
|
42
48
|
scopeId,
|
|
@@ -46,13 +52,33 @@ export async function blueprintDeployCore(options) {
|
|
|
46
52
|
auth,
|
|
47
53
|
blueprintFileDir,
|
|
48
54
|
installer,
|
|
49
|
-
logger,
|
|
50
55
|
bin,
|
|
51
|
-
|
|
56
|
+
fetchFn,
|
|
57
|
+
waitForFn: createWaitFor({ bin, log: logger, verbose }),
|
|
52
58
|
onAssetEvent: createAssetEventHandler(logger),
|
|
59
|
+
onPreDeployStackStart() {
|
|
60
|
+
spinner = logger.ora('Starting pre-deploy...').start();
|
|
61
|
+
},
|
|
62
|
+
onPreDeployStackFail() {
|
|
63
|
+
spinner.fail(`${styleText('red', 'Failed')} to complete Stack pre-deployment`);
|
|
64
|
+
},
|
|
65
|
+
onPreDeployStackDone() {
|
|
66
|
+
spinner.stop().clear();
|
|
67
|
+
},
|
|
68
|
+
onPreDeployOperationStart() {
|
|
69
|
+
logger(styleText('dim', 'Stack pre-deployment progress:'));
|
|
70
|
+
logger('');
|
|
71
|
+
},
|
|
72
|
+
onPreDeployOperationDone() {
|
|
73
|
+
logger(styleText(['bold', 'green'], 'Stack pre-deployment completed!'));
|
|
74
|
+
},
|
|
53
75
|
});
|
|
54
76
|
if (!preDeployResult?.success)
|
|
55
77
|
return preDeployResult;
|
|
78
|
+
const metadata = {
|
|
79
|
+
client: getClientMetadata({ cliVersion, dir: blueprintFileDir }),
|
|
80
|
+
resources: preDeployResult.resourceMetadata,
|
|
81
|
+
};
|
|
56
82
|
const deploySpinner = logger.ora('Deploying...').start();
|
|
57
83
|
const { ok: deployOk, stack, error: deployError, } = await updateStack({
|
|
58
84
|
stackId,
|
|
@@ -62,9 +88,10 @@ export async function blueprintDeployCore(options) {
|
|
|
62
88
|
name: stackName,
|
|
63
89
|
document: { resources },
|
|
64
90
|
userMessage: flags.message,
|
|
91
|
+
metadata,
|
|
65
92
|
},
|
|
66
93
|
auth,
|
|
67
|
-
|
|
94
|
+
fetchFn,
|
|
68
95
|
});
|
|
69
96
|
if (!deployOk) {
|
|
70
97
|
deploySpinner.fail(`${styleText('red', 'Failed')} to update Stack deployment`);
|
|
@@ -116,6 +143,8 @@ export async function blueprintDeployCore(options) {
|
|
|
116
143
|
});
|
|
117
144
|
if (outcome.type === 'completed') {
|
|
118
145
|
logger(styleText(['bold', 'green'], 'Stack deployment completed!'));
|
|
146
|
+
for (const line of formatStudioUrls(stack.resources))
|
|
147
|
+
logger(line);
|
|
119
148
|
const legacyWarning = await legacyPermissionsNoticePromise;
|
|
120
149
|
const warnings = [...(legacyWarning ? [legacyWarning] : []), ...workspaceWarnings];
|
|
121
150
|
return {
|
|
@@ -192,8 +221,10 @@ function createAssetEventHandler(logger) {
|
|
|
192
221
|
logger.error(` ${result.error}`);
|
|
193
222
|
continue;
|
|
194
223
|
}
|
|
195
|
-
|
|
196
|
-
|
|
224
|
+
const r = resource;
|
|
225
|
+
const assetParameter = String(r[result.assetParameter]);
|
|
226
|
+
logger(` ${check(`${resource.name} ${niceId(assetParameter)}`)}`);
|
|
227
|
+
logger(` Source: ${assetParameter}`);
|
|
197
228
|
if (result.hash) {
|
|
198
229
|
const hash = result.hash;
|
|
199
230
|
const h = hash.length > 24 ? `${hash.slice(0, 8)}...${hash.slice(-12)}` : hash;
|
|
@@ -7,6 +7,7 @@ import { niceId } from '../../utils/display/presenters.js';
|
|
|
7
7
|
import { CODE_OPERATION_UNCONFIRMED, EXIT_OPERATION_UNCONFIRMED } from '../../utils/exit-codes.js';
|
|
8
8
|
import { runCommand } from '../../utils/package-manager.js';
|
|
9
9
|
import { styleText } from '../../utils/style-text.js';
|
|
10
|
+
import { createTracedFetch } from '../../utils/traced-fetch.js';
|
|
10
11
|
export async function blueprintDestroyCore(options) {
|
|
11
12
|
const { bin = 'sanity', log, token, scopeType, scopeId, localStackId, blueprintConfig, flags, } = options;
|
|
12
13
|
const { force = false, 'project-id': flagProjectId, 'organization-id': flagOrganizationId, stack: flagStack, 'no-wait': noWait = false, verbose = false, } = flags;
|
|
@@ -48,14 +49,15 @@ export async function blueprintDestroyCore(options) {
|
|
|
48
49
|
: undefined;
|
|
49
50
|
let stack;
|
|
50
51
|
try {
|
|
52
|
+
const fetchFn = createTracedFetch(log);
|
|
51
53
|
if (resolvedStackId) {
|
|
52
|
-
const overrideStack = await getStack({ stackId: resolvedStackId, auth,
|
|
54
|
+
const overrideStack = await getStack({ stackId: resolvedStackId, auth, fetchFn });
|
|
53
55
|
if (!overrideStack.ok)
|
|
54
56
|
return { success: false, error: overrideStack.error || 'Failed to get Stack' };
|
|
55
57
|
stack = overrideStack.stack;
|
|
56
58
|
}
|
|
57
59
|
else if (localStackId) {
|
|
58
|
-
const blueprintStack = await getStack({ stackId: localStackId, auth,
|
|
60
|
+
const blueprintStack = await getStack({ stackId: localStackId, auth, fetchFn });
|
|
59
61
|
if (!blueprintStack.ok)
|
|
60
62
|
return { success: false, error: blueprintStack.error || 'Failed to get Stack' };
|
|
61
63
|
stack = blueprintStack.stack;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { dirname } from 'node:path';
|
|
3
3
|
import { arch, cwd, env, version as nodeVersion, platform } from 'node:process';
|
|
4
|
+
import { formatDateTime } from '@sanity/cli-core/dates';
|
|
4
5
|
import * as resolve from 'empathic/resolve';
|
|
5
6
|
import { loadAndParseBlueprint, } from '../../actions/blueprints/blueprint.js';
|
|
6
7
|
import { readConfigFile } from '../../actions/blueprints/config.js';
|
|
7
8
|
import { resolveIds } from '../../actions/blueprints/resolve.js';
|
|
8
9
|
import { getStack } from '../../actions/blueprints/stacks.js';
|
|
9
10
|
import config, { RUNTIME_CLI_VERSION } from '../../config.js';
|
|
10
|
-
import { formatDateTime } from '../../utils/display/dates.js';
|
|
11
11
|
import { presentBlueprintParserErrors } from '../../utils/display/errors.js';
|
|
12
12
|
import { advise, check, filePathRelativeToCwd, niceId, renderSection, severe, unsure, } from '../../utils/display/presenters.js';
|
|
13
13
|
import { runCommand } from '../../utils/package-manager.js';
|
|
@@ -172,7 +172,7 @@ export async function blueprintDoctorCore(options) {
|
|
|
172
172
|
const stackResponse = await getStack({
|
|
173
173
|
auth: { token, scopeType, scopeId },
|
|
174
174
|
stackId,
|
|
175
|
-
|
|
175
|
+
fetchFn,
|
|
176
176
|
});
|
|
177
177
|
if (stackResponse.ok) {
|
|
178
178
|
diagnostics.stackReady = { status: true };
|
|
@@ -15,6 +15,7 @@ import { CancelledError, promptForBlueprintType, promptForInitLocation, promptFo
|
|
|
15
15
|
import { isInteractive } from '../../utils/interactive.js';
|
|
16
16
|
import { installCommand, runCommand } from '../../utils/package-manager.js';
|
|
17
17
|
import { styleText } from '../../utils/style-text.js';
|
|
18
|
+
import { createTracedFetch } from '../../utils/traced-fetch.js';
|
|
18
19
|
import { blueprintConfigCore } from './config.js';
|
|
19
20
|
/** Derive scope type and ID from mutually exclusive flag values. */
|
|
20
21
|
function resolveScopeFromFlags(projectId, organizationId) {
|
|
@@ -288,11 +289,12 @@ export async function resolveScopeAndStack(params) {
|
|
|
288
289
|
}
|
|
289
290
|
// --stack-id: validate it exists
|
|
290
291
|
if (resolvedStackId && resolvedStackId === stackId) {
|
|
292
|
+
const fetchFn = createTracedFetch(log);
|
|
291
293
|
const spinner = log.ora('Validating Stack...').start();
|
|
292
294
|
const { ok, error } = await getStack({
|
|
293
295
|
stackId: resolvedStackId,
|
|
294
296
|
auth: { token, scopeType, scopeId },
|
|
295
|
-
|
|
297
|
+
fetchFn,
|
|
296
298
|
});
|
|
297
299
|
spinner.stop();
|
|
298
300
|
if (!ok) {
|
|
@@ -4,6 +4,7 @@ import { formatTitle } from '../../utils/display/blueprints-formatting.js';
|
|
|
4
4
|
import { formatLogEntry, formatLogs } from '../../utils/display/logs-formatting.js';
|
|
5
5
|
import { niceId } from '../../utils/display/presenters.js';
|
|
6
6
|
import { styleText } from '../../utils/style-text.js';
|
|
7
|
+
import { createTracedFetch } from '../../utils/traced-fetch.js';
|
|
7
8
|
/** Number of recent logs to show before entering watch mode */
|
|
8
9
|
const WATCH_PREFETCH_LIMIT = 10;
|
|
9
10
|
export async function blueprintLogsCore(options) {
|
|
@@ -11,8 +12,9 @@ export async function blueprintLogsCore(options) {
|
|
|
11
12
|
const { watch = false, verbose = false, limit, since, before } = flags;
|
|
12
13
|
const spinner = log.ora(`Fetching recent logs for Stack deployment ${niceId(stackId)}`).start();
|
|
13
14
|
try {
|
|
15
|
+
const fetchFn = createTracedFetch(log);
|
|
14
16
|
if (watch) {
|
|
15
|
-
const { ok, logs, error } = await getLogs({ stackId, limit: WATCH_PREFETCH_LIMIT }, auth,
|
|
17
|
+
const { ok, logs, error } = await getLogs({ stackId, limit: WATCH_PREFETCH_LIMIT }, auth, fetchFn);
|
|
16
18
|
if (!ok) {
|
|
17
19
|
spinner.fail(`${styleText('red', 'Failed')} to retrieve logs`);
|
|
18
20
|
log.error(`Error: ${error || 'Unknown error'}`);
|
|
@@ -38,9 +40,13 @@ export async function blueprintLogsCore(options) {
|
|
|
38
40
|
stackId,
|
|
39
41
|
knownIds: logs.map((l) => l.id),
|
|
40
42
|
auth,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
fetchFn,
|
|
44
|
+
onShowBanner() {
|
|
45
|
+
log(`Watching logs... ${styleText('bold', 'ctrl+c')} to cancel`);
|
|
46
|
+
},
|
|
47
|
+
onLogEntry(logEntry, previousLog) {
|
|
48
|
+
log(formatLogEntry(logEntry, verbose, previousLog));
|
|
49
|
+
},
|
|
44
50
|
});
|
|
45
51
|
// Return a never-resolving promise so the polling loop keeps running
|
|
46
52
|
return {
|
|
@@ -49,7 +55,7 @@ export async function blueprintLogsCore(options) {
|
|
|
49
55
|
};
|
|
50
56
|
}
|
|
51
57
|
// One-shot fetch (no watch)
|
|
52
|
-
const { ok, logs, error, hasMore } = await getLogs({ stackId, limit, before, after: since }, auth,
|
|
58
|
+
const { ok, logs, error, hasMore } = await getLogs({ stackId, limit, before, after: since }, auth, fetchFn);
|
|
53
59
|
if (!ok) {
|
|
54
60
|
spinner.fail(`${styleText('red', 'Failed')} to retrieve Stack deployment logs`);
|
|
55
61
|
log.error(`Error: ${error || 'Unknown error'}`);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { hostname } from 'node:os';
|
|
2
2
|
import { confirm, input, select } from '@inquirer/prompts';
|
|
3
|
+
import { formatDateTime } from '@sanity/cli-core/dates';
|
|
3
4
|
import { createRobotToken } from '../../actions/sanity/access.js';
|
|
4
5
|
import { ClipboardUnavailableError, write as clipboardWrite } from '../../utils/clipboard.js';
|
|
5
|
-
import { formatDate
|
|
6
|
+
import { formatDate } from '../../utils/display/dates.js';
|
|
6
7
|
import { styleText } from '../../utils/style-text.js';
|
|
7
8
|
const ROLE_BY_SCOPE = {
|
|
8
9
|
project: 'blueprints-deployer',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
3
|
+
import { CONVERT_BYTES_TO_MB } from '../../constants.js';
|
|
4
4
|
import { findFunctionInResources } from '../../utils/functions/find.js';
|
|
5
5
|
import { prepareAsset } from '../../utils/functions/prepare-asset.js';
|
|
6
6
|
import { isLocalFunctionResource } from '../../utils/types.js';
|
|
@@ -31,14 +31,13 @@ export async function functionBuildCore(options) {
|
|
|
31
31
|
errors.push({ name: resource.name, error: prepResult.error ?? 'Unknown error' });
|
|
32
32
|
continue;
|
|
33
33
|
}
|
|
34
|
-
const
|
|
35
|
-
const buffer = zip.toBuffer();
|
|
34
|
+
const buffer = prepResult.outputBuffer;
|
|
36
35
|
const zipPath = path.join(outDir, `${resource.name}.zip`);
|
|
37
|
-
await fs.promises.writeFile(zipPath,
|
|
36
|
+
await fs.promises.writeFile(zipPath, prepResult.outputBuffer);
|
|
38
37
|
if (prepResult.cleanup) {
|
|
39
38
|
await prepResult.cleanup();
|
|
40
39
|
}
|
|
41
|
-
const sizeMb = (buffer.length /
|
|
40
|
+
const sizeMb = (buffer.length / CONVERT_BYTES_TO_MB).toFixed(1);
|
|
42
41
|
spinner.succeed(`${resource.name}.zip (${sizeMb} MB) → ${zipPath}`);
|
|
43
42
|
built.push({ name: resource.name, size: buffer.length, path: zipPath });
|
|
44
43
|
}
|
|
@@ -7,6 +7,7 @@ import { createDurableJsonCollector } from '../../utils/functions/durable-logs.j
|
|
|
7
7
|
import { findFunctionInResources, getFunctionNames } from '../../utils/functions/find.js';
|
|
8
8
|
import { runFunction } from '../../utils/functions/invoke/nested.js';
|
|
9
9
|
import { buildContext, buildInvokeOptions, collectInvokeInput, defaultInvocationDeps, resolveInvocationPlan, } from '../../utils/functions/invoke/resolve-invoke-type.js';
|
|
10
|
+
import { createTracedFetch } from '../../utils/traced-fetch.js';
|
|
10
11
|
import { isEventType, } from '../../utils/types.js';
|
|
11
12
|
export async function functionTestCore(options) {
|
|
12
13
|
const { blueprint, log, error, args, flags, helpText } = options;
|
|
@@ -36,6 +37,7 @@ export async function functionTestCore(options) {
|
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
39
|
try {
|
|
40
|
+
const fetchFn = createTracedFetch(log);
|
|
39
41
|
const resource = findFunctionInResources(blueprint.resources, fnName); // throws if not found
|
|
40
42
|
const resolvedResources = await resolveDeployedResources({
|
|
41
43
|
resources: blueprint.resources,
|
|
@@ -43,7 +45,7 @@ export async function functionTestCore(options) {
|
|
|
43
45
|
auth: config.token && blueprint.scopeType && blueprint.scopeId
|
|
44
46
|
? { token: config.token, scopeType: blueprint.scopeType, scopeId: blueprint.scopeId }
|
|
45
47
|
: undefined,
|
|
46
|
-
|
|
48
|
+
fetchFn,
|
|
47
49
|
});
|
|
48
50
|
const input = {
|
|
49
51
|
flags,
|
package/dist/cores/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readLocalBlueprint } from '../actions/blueprints/blueprint.js';
|
|
2
2
|
import { getStack, resolveStackIdByNameOrId } from '../actions/blueprints/stacks.js';
|
|
3
3
|
import { presentBlueprintParserErrors } from '../utils/display/errors.js';
|
|
4
|
+
import { createTracedFetch } from '../utils/traced-fetch.js';
|
|
4
5
|
import { validTokenOrErrorMessage } from '../utils/validated-token.js';
|
|
5
6
|
export async function initBlueprintConfig({ bin, log, token, validateResources = false, validateToken = true, blueprintPath, }) {
|
|
6
7
|
let checkedToken = token;
|
|
@@ -51,7 +52,8 @@ export async function initDeployedBlueprintConfig(config) {
|
|
|
51
52
|
return { ok: false, error: 'Missing Stack deployment configuration for Blueprint' };
|
|
52
53
|
}
|
|
53
54
|
const spinner = config.log.ora('Loading Stack deployment...').start();
|
|
54
|
-
const
|
|
55
|
+
const fetchFn = createTracedFetch(config.log);
|
|
56
|
+
const stackResponse = await getStack({ stackId, auth, fetchFn });
|
|
55
57
|
if (!stackResponse.ok) {
|
|
56
58
|
spinner.fail('Could not load Stack deployment');
|
|
57
59
|
return { ok: false, error: 'Missing Stack deployment' };
|
package/dist/server/app.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as http from 'node:http';
|
|
1
2
|
import { type InvokeExecutionOptions } from '../utils/types.js';
|
|
2
|
-
declare const app: (host: string, port: number, validateResources: boolean, executionOptions?: Partial<InvokeExecutionOptions>) =>
|
|
3
|
+
declare const app: (host: string, port: number, validateResources: boolean, executionOptions?: Partial<InvokeExecutionOptions>) => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
3
4
|
declare function parseDocumentUrl(url: string): {
|
|
4
5
|
projectId: string;
|
|
5
6
|
dataset: string;
|
package/dist/server/app.js
CHANGED
|
@@ -11,7 +11,6 @@ import { isRecord } from '../utils/is-record.js';
|
|
|
11
11
|
import { isEventType, isGroqContextOptions, } from '../utils/types.js';
|
|
12
12
|
import { handleInvokeRequest } from './handlers/invoke.js';
|
|
13
13
|
const app = (host, port, validateResources, executionOptions) => {
|
|
14
|
-
const wss = new WebSocketServer({ port: 8974 });
|
|
15
14
|
// Send a JSON envelope to every connected UI client.
|
|
16
15
|
const broadcast = (envelope) => {
|
|
17
16
|
const message = JSON.stringify(envelope);
|
|
@@ -268,6 +267,9 @@ const app = (host, port, validateResources, executionOptions) => {
|
|
|
268
267
|
}
|
|
269
268
|
};
|
|
270
269
|
const server = http.createServer(requestListener);
|
|
270
|
+
// Share the HTTP server so live-reload upgrades on the emulator's own port,
|
|
271
|
+
// rather than reserving a second port that may already be taken.
|
|
272
|
+
const wss = new WebSocketServer({ server });
|
|
271
273
|
server.listen(port, host, () => { });
|
|
272
274
|
wss.on('connection', function connection(ws) {
|
|
273
275
|
ws.on('error', console.error);
|
|
@@ -280,6 +282,7 @@ const app = (host, port, validateResources, executionOptions) => {
|
|
|
280
282
|
ws.send('reload-blueprint');
|
|
281
283
|
});
|
|
282
284
|
});
|
|
285
|
+
return server;
|
|
283
286
|
};
|
|
284
287
|
// Helper function to test URL parsing and document fetching logic
|
|
285
288
|
function parseDocumentUrl(url) {
|
|
@@ -16,7 +16,7 @@ export async function handleInvokeRequest(functionName, event, metadata, context
|
|
|
16
16
|
resources,
|
|
17
17
|
stackId,
|
|
18
18
|
auth: config.token && scopeType && scopeId ? { token: config.token, scopeType, scopeId } : undefined,
|
|
19
|
-
|
|
19
|
+
fetchFn: fetch,
|
|
20
20
|
});
|
|
21
21
|
const payload = {
|
|
22
22
|
payload: event,
|