@sanity/runtime-cli 17.1.0 → 17.2.0-next.ga4b9ae7
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 +23 -22
- package/dist/actions/blueprints/assets.d.ts +2 -1
- package/dist/actions/blueprints/assets.js +17 -26
- package/dist/actions/blueprints/blueprint.d.ts +1 -1
- package/dist/actions/blueprints/pre-deploy.d.ts +29 -0
- package/dist/actions/blueprints/pre-deploy.js +164 -0
- package/dist/actions/blueprints/wait-for-operation.js +4 -0
- package/dist/actions/sanity/examples.d.ts +4 -4
- package/dist/baseCommands.d.ts +4 -4
- package/dist/commands/blueprints/add.d.ts +1 -1
- package/dist/commands/blueprints/config.d.ts +1 -1
- package/dist/commands/blueprints/deploy.d.ts +1 -1
- package/dist/commands/blueprints/destroy.d.ts +1 -1
- package/dist/commands/blueprints/doctor.d.ts +0 -1
- package/dist/commands/blueprints/doctor.js +3 -7
- package/dist/commands/blueprints/info.d.ts +1 -1
- package/dist/commands/blueprints/logs.d.ts +1 -1
- package/dist/commands/blueprints/mint-deploy-token.d.ts +1 -1
- package/dist/commands/blueprints/plan.d.ts +1 -1
- package/dist/commands/blueprints/promote.d.ts +1 -1
- package/dist/commands/blueprints/stacks.d.ts +1 -1
- package/dist/commands/functions/add.d.ts +1 -1
- package/dist/commands/functions/build.d.ts +1 -1
- package/dist/commands/functions/dev.d.ts +1 -1
- package/dist/commands/functions/env/add.d.ts +1 -1
- package/dist/commands/functions/env/list.d.ts +1 -1
- package/dist/commands/functions/env/remove.d.ts +1 -1
- package/dist/commands/functions/logs.d.ts +1 -1
- package/dist/commands/functions/test.d.ts +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/cores/blueprints/deploy.js +18 -65
- package/dist/cores/blueprints/doctor.js +15 -12
- package/dist/cores/functions/build.js +3 -2
- package/dist/cores/functions/test.js +4 -2
- package/dist/server/app.js +8 -2
- package/dist/server/static/favicon-dark.svg +1 -0
- package/dist/server/static/favicon.svg +1 -0
- package/dist/server/static/index.html +1 -1
- package/dist/server/static/vendor/vendor.bundle.js +5 -0
- package/dist/utils/functions/child-process-wrapper.js +13 -171
- package/dist/utils/functions/child-runtime/console.d.ts +1 -0
- package/dist/utils/functions/child-runtime/console.js +50 -0
- package/dist/utils/functions/child-runtime/invoke.d.ts +4 -0
- package/dist/utils/functions/child-runtime/invoke.js +47 -0
- package/dist/utils/functions/child-runtime/resources.d.ts +4 -0
- package/dist/utils/functions/child-runtime/resources.js +59 -0
- package/dist/utils/functions/find-entry-point.d.ts +1 -1
- package/dist/utils/functions/find-entry-point.js +10 -12
- package/dist/utils/functions/invoke/local.js +1 -1
- package/dist/utils/functions/invoke/prepare.d.ts +1 -1
- package/dist/utils/functions/invoke/prepare.js +19 -8
- package/dist/utils/functions/package-json.d.ts +1 -2
- package/dist/utils/functions/package-json.js +4 -6
- package/dist/utils/functions/prepare-asset.d.ts +2 -2
- package/dist/utils/functions/prepare-asset.js +18 -7
- package/dist/utils/functions/resolve-dependencies.d.ts +4 -1
- package/dist/utils/functions/resolve-dependencies.js +5 -6
- package/dist/utils/functions/resource-to-arc.d.ts +1 -1
- package/dist/utils/functions/resource-to-arc.js +4 -5
- package/dist/utils/functions/should-transpile.d.ts +7 -1
- package/dist/utils/functions/should-transpile.js +10 -10
- package/dist/utils/functions/transpile/function.d.ts +4 -1
- package/dist/utils/functions/transpile/function.js +9 -14
- package/dist/utils/functions/transpile/verify-handler.js +1 -1
- package/dist/utils/logger.d.ts +7 -5
- package/dist/utils/logger.js +33 -1
- package/dist/utils/progress.d.ts +5 -0
- package/dist/utils/progress.js +40 -0
- package/dist/utils/studios/prepare-asset.d.ts +6 -0
- package/dist/utils/studios/prepare-asset.js +139 -0
- package/dist/utils/types.d.ts +9 -8
- package/dist/utils/types.js +2 -3
- package/oclif.manifest.json +896 -895
- package/package.json +30 -23
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class LogsCommand extends ResolvedCommand<typeof LogsCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['deployedStack'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class MintDeployTokenCommand extends ResolvedCommand<typeof MintDeployTokenCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['scope'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class PlanCommand extends ResolvedCommand<typeof PlanCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['token', 'blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class PromoteCommand extends ResolvedCommand<typeof PromoteCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['deployedStack', 'blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class StacksCommand extends ResolvedCommand<typeof StacksCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['scope'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class AddCommand extends ResolvedCommand<typeof AddCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class BuildCommand extends ResolvedCommand<typeof BuildCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static hidden: boolean;
|
|
6
6
|
static args: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class DevCommand extends ResolvedCommand<typeof DevCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
2
2
|
export default class EnvAddCommand extends ResolvedCommand<typeof EnvAddCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['deployedStack', 'blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static args: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
2
2
|
export default class EnvListCommand extends ResolvedCommand<typeof EnvListCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['deployedStack', 'blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static args: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
2
2
|
export default class EnvRemoveCommand extends ResolvedCommand<typeof EnvRemoveCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['deployedStack', 'blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static args: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class LogsCommand extends ResolvedCommand<typeof LogsCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['deployedStack', 'blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static args: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class TestCommand extends ResolvedCommand<typeof TestCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static args: {
|
package/dist/constants.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const SANITY_PROJECT = "sanity.project";
|
|
|
9
9
|
export declare const SANITY_PROJECT_CORS = "sanity.project.cors";
|
|
10
10
|
export declare const SANITY_PROJECT_DATASET = "sanity.project.dataset";
|
|
11
11
|
export declare const SANITY_PROJECT_WEBHOOK = "sanity.project.webhook";
|
|
12
|
+
export declare const SANITY_STUDIO = "sanity.studio";
|
|
12
13
|
export declare const EVENT_DOCUMENT_PUBLISH = "document-publish";
|
|
13
14
|
export declare const EVENT_DOCUMENT_CREATE = "document-create";
|
|
14
15
|
export declare const EVENT_DOCUMENT_UPDATE = "document-update";
|
package/dist/constants.js
CHANGED
|
@@ -9,6 +9,7 @@ export const SANITY_PROJECT = 'sanity.project';
|
|
|
9
9
|
export const SANITY_PROJECT_CORS = 'sanity.project.cors';
|
|
10
10
|
export const SANITY_PROJECT_DATASET = 'sanity.project.dataset';
|
|
11
11
|
export const SANITY_PROJECT_WEBHOOK = 'sanity.project.webhook';
|
|
12
|
+
export const SANITY_STUDIO = 'sanity.studio';
|
|
12
13
|
export const EVENT_DOCUMENT_PUBLISH = 'document-publish';
|
|
13
14
|
export const EVENT_DOCUMENT_CREATE = 'document-create';
|
|
14
15
|
export const EVENT_DOCUMENT_UPDATE = 'document-update';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dirname } from 'node:path';
|
|
2
|
-
import {
|
|
2
|
+
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';
|
|
@@ -7,19 +7,15 @@ import { createHintCollector } from '../../utils/blueprints/hints.js';
|
|
|
7
7
|
import { niceId } from '../../utils/display/presenters.js';
|
|
8
8
|
import { CODE_OPERATION_UNCONFIRMED, EXIT_OPERATION_UNCONFIRMED } from '../../utils/exit-codes.js';
|
|
9
9
|
import { styleText } from '../../utils/style-text.js';
|
|
10
|
-
import { isAssetResource } from '../../utils/types.js';
|
|
11
10
|
import { getWarnings } from '../../utils/warnings.js';
|
|
12
|
-
const DEFAULT_ASSET_TIMEOUT = 60;
|
|
13
|
-
const assetTimeoutS = Number(process.env.SANITY_ASSET_TIMEOUT) || DEFAULT_ASSET_TIMEOUT;
|
|
14
|
-
const assetTimeoutMs = assetTimeoutS * 1000;
|
|
15
|
-
const warnTimeoutMs = assetTimeoutMs / 2;
|
|
16
11
|
export async function blueprintDeployCore(options) {
|
|
17
12
|
const { bin = 'sanity', log, auth, stackId, scopeType, scopeId, deployedStack, blueprint, flags, } = options;
|
|
18
13
|
const { verbose } = flags;
|
|
19
14
|
const noWait = flags['no-wait'] || false;
|
|
20
15
|
const stackName = flags['new-stack-name'] ?? deployedStack.name;
|
|
21
16
|
const installer = flags['fn-installer'] || undefined;
|
|
22
|
-
const
|
|
17
|
+
const blueprintFileDir = dirname(blueprint.fileInfo.blueprintFilePath);
|
|
18
|
+
const workspaceWarnings = getWarnings({ dir: blueprintFileDir });
|
|
23
19
|
log(`Deploying "${stackName}" ${niceId(deployedStack.id)}...`);
|
|
24
20
|
try {
|
|
25
21
|
const { ok: checkOk, stack: currentStack } = await getStack({ stackId, auth, logger: log });
|
|
@@ -38,17 +34,21 @@ export async function blueprintDeployCore(options) {
|
|
|
38
34
|
};
|
|
39
35
|
}
|
|
40
36
|
const resources = [...blueprint.resources];
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
const preDeployResult = await preDeploy({
|
|
38
|
+
scopeType,
|
|
39
|
+
scopeId,
|
|
40
|
+
resources,
|
|
41
|
+
stackId,
|
|
42
|
+
stackName,
|
|
43
|
+
auth,
|
|
44
|
+
blueprintFileDir,
|
|
45
|
+
installer,
|
|
46
|
+
log,
|
|
47
|
+
bin,
|
|
48
|
+
verbose,
|
|
49
|
+
});
|
|
50
|
+
if (!preDeployResult?.success) {
|
|
51
|
+
return preDeployResult;
|
|
52
52
|
}
|
|
53
53
|
const spinner = log.ora('Deploying...').start();
|
|
54
54
|
const { ok: deployOk, stack, error: deployError, } = await updateStack({
|
|
@@ -151,53 +151,6 @@ export async function blueprintDeployCore(options) {
|
|
|
151
151
|
return { success: false, error: errorMessage };
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
async function preDeploy(resource, options) {
|
|
155
|
-
const { auth, installer, log } = options;
|
|
156
|
-
const fnSpinner = log.ora({ text: `Processing ${resource.name}...`, prefixText: ' ' }).start();
|
|
157
|
-
const warnTimer = setTimeout(() => {
|
|
158
|
-
fnSpinner.text = `Still processing ${resource.name}, this can take a moment...`;
|
|
159
|
-
}, warnTimeoutMs);
|
|
160
|
-
let assetTimeoutTimer;
|
|
161
|
-
let result;
|
|
162
|
-
try {
|
|
163
|
-
result = await Promise.race([
|
|
164
|
-
stashAsset({ resource, auth, logger: log, installer }),
|
|
165
|
-
new Promise((_, reject) => {
|
|
166
|
-
assetTimeoutTimer = setTimeout(() => {
|
|
167
|
-
reject(new Error(`Processing ${resource.name} timed out after ${assetTimeoutS}s`));
|
|
168
|
-
}, assetTimeoutMs);
|
|
169
|
-
}),
|
|
170
|
-
]);
|
|
171
|
-
}
|
|
172
|
-
catch (err) {
|
|
173
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
174
|
-
fnSpinner.fail(msg);
|
|
175
|
-
return { success: false, error: msg };
|
|
176
|
-
}
|
|
177
|
-
finally {
|
|
178
|
-
clearTimeout(warnTimer);
|
|
179
|
-
clearTimeout(assetTimeoutTimer);
|
|
180
|
-
}
|
|
181
|
-
if (result.success && result.assetId) {
|
|
182
|
-
const updatedResource = { ...resource, src: result.assetId };
|
|
183
|
-
fnSpinner.succeed(`${updatedResource.name} ${niceId(result.assetId)}`);
|
|
184
|
-
log(` Source: ${updatedResource.src}`);
|
|
185
|
-
if (result.hash) {
|
|
186
|
-
if (result.hash.length > 24) {
|
|
187
|
-
log.verbose(` Hash: ${result.hash.slice(0, 8)}...${result.hash.slice(-12)}`);
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
log.verbose(` Hash: ${result.hash}`);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (result.exists)
|
|
194
|
-
log.verbose(' Asset unchanged');
|
|
195
|
-
return { success: true, resource: updatedResource };
|
|
196
|
-
}
|
|
197
|
-
const errorMsg = `Failed uploading ${resource.name} asset, deploy has stopped`;
|
|
198
|
-
fnSpinner.fail(errorMsg);
|
|
199
|
-
return { success: false, error: result.error || 'Failed to process asset' };
|
|
200
|
-
}
|
|
201
154
|
const CHECK_LEGACY_DEPLOY_PERMISSION = false;
|
|
202
155
|
const BLUEPRINTS_PERMISSION_ENFORCEMENT_DATE = 'July 1, 2026';
|
|
203
156
|
async function checkLegacyDeployPermission({ auth, scopeType, scopeId, log, }) {
|
|
@@ -2,13 +2,13 @@ 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
4
|
import * as resolve from 'empathic/resolve';
|
|
5
|
-
import ora from 'ora';
|
|
6
5
|
import { loadAndParseBlueprint, } from '../../actions/blueprints/blueprint.js';
|
|
7
6
|
import { readConfigFile } from '../../actions/blueprints/config.js';
|
|
8
7
|
import { resolveIds } from '../../actions/blueprints/resolve.js';
|
|
9
8
|
import { getStack } from '../../actions/blueprints/stacks.js';
|
|
10
9
|
import config, { RUNTIME_CLI_VERSION } from '../../config.js';
|
|
11
10
|
import { formatDateTime } from '../../utils/display/dates.js';
|
|
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 { styleText } from '../../utils/style-text.js';
|
|
14
14
|
import { createTracedFetch } from '../../utils/traced-fetch.js';
|
|
@@ -55,7 +55,7 @@ export async function blueprintDoctorCore(options) {
|
|
|
55
55
|
envRows.push(['CLI', bin]);
|
|
56
56
|
const configRows = [];
|
|
57
57
|
const stackRows = [];
|
|
58
|
-
const spinner = ora('Running diagnostics...').start();
|
|
58
|
+
const spinner = log.ora('Running diagnostics...').start();
|
|
59
59
|
// --- ONLINE ---
|
|
60
60
|
const fetchFn = createTracedFetch(log);
|
|
61
61
|
try {
|
|
@@ -109,6 +109,7 @@ export async function blueprintDoctorCore(options) {
|
|
|
109
109
|
status: false,
|
|
110
110
|
detail: `${blueprint.errors.length} error(s)`,
|
|
111
111
|
};
|
|
112
|
+
log.verbose(presentBlueprintParserErrors(blueprint.errors));
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
catch {
|
|
@@ -186,6 +187,8 @@ export async function blueprintDoctorCore(options) {
|
|
|
186
187
|
stackRows.push(['Operation', `${op.status}${timestamp}`]);
|
|
187
188
|
if (op.userMessage)
|
|
188
189
|
stackRows.push([' Message', `"${op.userMessage}"`]);
|
|
190
|
+
if (v && op.systemMessage)
|
|
191
|
+
stackRows.push([' System', `"${op.systemMessage}"`]);
|
|
189
192
|
}
|
|
190
193
|
if (stack.resources) {
|
|
191
194
|
stackRows.push(['Resources', `${stack.resources.length}`]);
|
|
@@ -275,20 +278,20 @@ export async function blueprintDoctorCore(options) {
|
|
|
275
278
|
}
|
|
276
279
|
// --- RENDER REPORT ---
|
|
277
280
|
spinner.stop();
|
|
278
|
-
// Environment
|
|
279
|
-
log
|
|
280
|
-
log
|
|
281
|
-
// Configuration
|
|
281
|
+
// Environment
|
|
282
|
+
log(renderSection('Environment', envRows));
|
|
283
|
+
log('');
|
|
284
|
+
// Configuration
|
|
282
285
|
if (configRows.length > 0) {
|
|
283
|
-
log
|
|
284
|
-
log
|
|
286
|
+
log(renderSection('Configuration', configRows));
|
|
287
|
+
log('');
|
|
285
288
|
}
|
|
286
|
-
// Deployment
|
|
289
|
+
// Deployment
|
|
287
290
|
if (stackRows.length > 0) {
|
|
288
|
-
log
|
|
289
|
-
log
|
|
291
|
+
log(renderSection('Deployment', stackRows));
|
|
292
|
+
log('');
|
|
290
293
|
}
|
|
291
|
-
// Checks
|
|
294
|
+
// Checks
|
|
292
295
|
const maxLabel = Math.max(...Object.values(diagLookup).map((l) => l.length));
|
|
293
296
|
log(styleText('bold', 'Checks'));
|
|
294
297
|
let allGood = true;
|
|
@@ -18,13 +18,14 @@ export async function functionBuildCore(options) {
|
|
|
18
18
|
functions = allFunctions;
|
|
19
19
|
}
|
|
20
20
|
const installer = flags['fn-installer'] || undefined;
|
|
21
|
-
const
|
|
21
|
+
const blueprintFileDir = path.dirname(blueprint.fileInfo.blueprintFilePath);
|
|
22
|
+
const outDir = flags['out-dir'] || path.join(blueprintFileDir, '.build');
|
|
22
23
|
await fs.promises.mkdir(outDir, { recursive: true });
|
|
23
24
|
const errors = [];
|
|
24
25
|
const built = [];
|
|
25
26
|
for (const resource of functions) {
|
|
26
27
|
const spinner = log.ora(`Building ${resource.name}...`).start();
|
|
27
|
-
const prepResult = await prepareAsset({ resource
|
|
28
|
+
const prepResult = await prepareAsset({ resource, blueprintFileDir, installer });
|
|
28
29
|
if (prepResult.success === false) {
|
|
29
30
|
spinner.fail(`Failed to build ${resource.name}`);
|
|
30
31
|
errors.push({ name: resource.name, error: prepResult.error ?? 'Unknown error' });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
3
|
import { cwd } from 'node:process';
|
|
4
4
|
import { testAction } from '../../actions/functions/test.js';
|
|
5
5
|
import config from '../../config.js';
|
|
@@ -50,6 +50,7 @@ export async function functionTestCore(options) {
|
|
|
50
50
|
: undefined,
|
|
51
51
|
logger: log,
|
|
52
52
|
});
|
|
53
|
+
const blueprintFileDir = dirname(blueprint.fileInfo.blueprintFilePath);
|
|
53
54
|
const contextOptions = docFunction || mediaFunction
|
|
54
55
|
? {
|
|
55
56
|
clientOptions: {
|
|
@@ -63,8 +64,9 @@ export async function functionTestCore(options) {
|
|
|
63
64
|
functionResourceType: 'project',
|
|
64
65
|
functionResourceId: projectId || '',
|
|
65
66
|
resources: resolvedResources,
|
|
67
|
+
blueprintFileDir,
|
|
66
68
|
}
|
|
67
|
-
: { clientOptions: {}, resources: resolvedResources };
|
|
69
|
+
: { clientOptions: {}, resources: resolvedResources, blueprintFileDir };
|
|
68
70
|
// If the user sets the flag to use the real token set it in our options
|
|
69
71
|
if (withUserToken) {
|
|
70
72
|
contextOptions.clientOptions.token = config.token || undefined;
|
package/dist/server/app.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync, watchFile } from 'node:fs';
|
|
2
2
|
import * as http from 'node:http';
|
|
3
|
+
import { dirname } from 'node:path';
|
|
3
4
|
import { default as mime } from 'mime-types';
|
|
4
5
|
import { WebSocket, WebSocketServer } from 'ws';
|
|
5
6
|
import { findBlueprintFile, loadAndParseBlueprint } from '../actions/blueprints/blueprint.js';
|
|
@@ -68,7 +69,11 @@ const app = (host, port, validateResources, executionOptions) => {
|
|
|
68
69
|
req.on('end', async () => {
|
|
69
70
|
res.setHeader('Content-Type', 'application/json');
|
|
70
71
|
try {
|
|
71
|
-
const
|
|
72
|
+
const fileInfo = findBlueprintFile();
|
|
73
|
+
if (!fileInfo) {
|
|
74
|
+
throw Error('Could not find a Blueprint manifest (sanity.blueprint.ts, .js, or .json). Run `blueprints init` to create one.');
|
|
75
|
+
}
|
|
76
|
+
const { data, func: functionName, metadata, } = parseInvokeRequest(Buffer.concat(body), dirname(fileInfo.blueprintFilePath));
|
|
72
77
|
const { context, event } = data;
|
|
73
78
|
// replace user token if required
|
|
74
79
|
if (isGroqContextOptions(context)) {
|
|
@@ -312,7 +317,7 @@ function buildApiUrl(projectId, dataset, docId, apiUrl) {
|
|
|
312
317
|
function buildAssetUrl(mediaLibraryId, docId, apiUrl) {
|
|
313
318
|
return `${apiUrl}/v2025-03-24/media-libraries/${mediaLibraryId}/doc/${docId}`;
|
|
314
319
|
}
|
|
315
|
-
function parseInvokeRequest(body) {
|
|
320
|
+
function parseInvokeRequest(body, blueprintFileDir) {
|
|
316
321
|
let json;
|
|
317
322
|
try {
|
|
318
323
|
json = JSON.parse(body.toString('utf8'));
|
|
@@ -404,6 +409,7 @@ function parseInvokeRequest(body) {
|
|
|
404
409
|
context: {
|
|
405
410
|
...context,
|
|
406
411
|
clientOptions,
|
|
412
|
+
blueprintFileDir,
|
|
407
413
|
// Provide default values for required properties if not present
|
|
408
414
|
eventResourceType: typeof context.eventResourceType === 'string' ? context.eventResourceType : '',
|
|
409
415
|
eventResourceId: typeof context.eventResourceId === 'string' ? context.eventResourceId : '',
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
<filters-component></filters-component>
|
|
34
34
|
<input type="checkbox" id="nav-toggle" class="hidden">
|
|
35
35
|
<nav id="sidebar" class="relative y-scroll max-h-100 pad-t-5 border-right overflow-auto nav-min-width">
|
|
36
|
-
<label for="nav-toggle" id="nav-toggle-label" title="Toggle Functions list" class="z-10 nav-label"></label>
|
|
36
|
+
<label for="nav-toggle" id="nav-toggle-label" aria-label="Toggle Functions list" title="Toggle Functions list" class="z-10 nav-label"></label>
|
|
37
37
|
<h4 class="config-label mar-t-0 mar-b-3 pad-l-3">Functions</h4>
|
|
38
38
|
<function-list></function-list>
|
|
39
39
|
</nav>
|
|
@@ -6203,6 +6203,7 @@ class FacetProvider {
|
|
|
6203
6203
|
}
|
|
6204
6204
|
};
|
|
6205
6205
|
}
|
|
6206
|
+
get extension() { return this; }
|
|
6206
6207
|
}
|
|
6207
6208
|
function compareArray(a, b, compare) {
|
|
6208
6209
|
if (a.length != b.length)
|
|
@@ -6400,6 +6401,7 @@ class PrecExtension {
|
|
|
6400
6401
|
this.inner = inner;
|
|
6401
6402
|
this.prec = prec;
|
|
6402
6403
|
}
|
|
6404
|
+
get extension() { return this; }
|
|
6403
6405
|
}
|
|
6404
6406
|
/**
|
|
6405
6407
|
Extension compartments can be used to make a configuration
|
|
@@ -6434,6 +6436,7 @@ class CompartmentInstance {
|
|
|
6434
6436
|
this.compartment = compartment;
|
|
6435
6437
|
this.inner = inner;
|
|
6436
6438
|
}
|
|
6439
|
+
get extension() { return this; }
|
|
6437
6440
|
}
|
|
6438
6441
|
class Configuration {
|
|
6439
6442
|
constructor(base, compartments, dynamicSlots, address, staticValues, facets) {
|
|
@@ -6543,6 +6546,8 @@ function flatten(extension, compartments, newCompartments) {
|
|
|
6543
6546
|
else {
|
|
6544
6547
|
let content = ext.extension;
|
|
6545
6548
|
if (!content)
|
|
6549
|
+
throw new Error(`Unrecognized extension value in extension set (${ext}).`);
|
|
6550
|
+
if (content == ext)
|
|
6546
6551
|
throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
|
|
6547
6552
|
inner(content, prec);
|
|
6548
6553
|
}
|