@sanity/runtime-cli 17.4.0 → 17.6.0
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 +55 -52
- package/SKILL.md +59 -0
- package/dist/actions/blueprints/blueprint.js +2 -1
- package/dist/actions/blueprints/pre-deploy.d.ts +15 -6
- package/dist/actions/blueprints/pre-deploy.js +29 -70
- package/dist/actions/blueprints/process-assets.d.ts +29 -0
- package/dist/actions/blueprints/process-assets.js +80 -0
- package/dist/actions/blueprints/resources.js +17 -1
- package/dist/commands/blueprints/deploy.js +3 -1
- package/dist/commands/blueprints/destroy.js +1 -1
- package/dist/commands/blueprints/info.d.ts +1 -0
- package/dist/commands/blueprints/info.js +5 -0
- package/dist/commands/blueprints/init.js +1 -2
- package/dist/commands/blueprints/logs.js +1 -0
- package/dist/commands/functions/add.js +3 -3
- package/dist/commands/functions/dev.js +2 -2
- package/dist/commands/functions/logs.d.ts +1 -1
- package/dist/commands/functions/logs.js +3 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.js +6 -0
- package/dist/cores/blueprints/deploy.js +71 -19
- package/dist/cores/blueprints/plan.js +2 -0
- package/dist/cores/functions/add.js +11 -8
- package/dist/server/static/components/api-base.js +1 -0
- package/dist/server/static/components/filters.js +4 -2
- package/dist/server/static/components/payload-panel.js +3 -0
- package/dist/utils/blueprints/extract-durable-config.d.ts +8 -0
- package/dist/utils/blueprints/extract-durable-config.js +60 -0
- package/dist/utils/blueprints/validate-resources.js +5 -2
- package/dist/utils/display/blueprints-formatting.js +8 -4
- package/dist/utils/display/resources-formatting.js +2 -2
- package/dist/utils/style-text.js +1 -0
- package/dist/utils/types.d.ts +8 -2
- package/dist/utils/types.js +8 -2
- package/oclif.manifest.json +22 -15
- package/package.json +29 -15
- package/skills/_functions-build.md +23 -0
- package/skills/_functions-list.md +28 -0
- package/skills/blueprints-add.md +8 -0
- package/skills/blueprints-config.md +33 -0
- package/skills/blueprints-deploy.md +36 -0
- package/skills/blueprints-destroy.md +30 -0
- package/skills/blueprints-doctor.md +31 -0
- package/skills/blueprints-info.md +23 -0
- package/skills/blueprints-init.md +48 -0
- package/skills/blueprints-logs.md +33 -0
- package/skills/blueprints-mint-deploy-token.md +25 -0
- package/skills/blueprints-plan.md +28 -0
- package/skills/blueprints-promote.md +31 -0
- package/skills/blueprints-stacks.md +28 -0
- package/skills/functions-add.md +35 -0
- package/skills/functions-dev.md +21 -0
- package/skills/functions-env-add.md +29 -0
- package/skills/functions-env-list.md +21 -0
- package/skills/functions-env-remove.md +22 -0
- package/skills/functions-logs.md +39 -0
- package/skills/functions-test.md +31 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import { validateDurableFunction, } from '@sanity/blueprints';
|
|
4
|
+
import { SANITY_FUNCTION_DURABLE } from '../../constants.js';
|
|
5
|
+
import { findFunctionEntryPoint } from '../functions/find-entry-point.js';
|
|
6
|
+
import { transpileFunction } from '../functions/transpile/function.js';
|
|
7
|
+
import { isLocalFunctionResource } from '../types.js';
|
|
8
|
+
const DURABLE_CONFIG_KEYS = ['event', 'concurrency', 'debounce', 'debounceKey'];
|
|
9
|
+
/**
|
|
10
|
+
* Extracts the blueprint config from the function source code and mutates it to the resource object.
|
|
11
|
+
* This is used for durable functions that may not have a config defined in the blueprint.
|
|
12
|
+
* @param resources
|
|
13
|
+
* @param blueprintFileDir
|
|
14
|
+
*/
|
|
15
|
+
export const extractDurableConfig = async (resources, blueprintFileDir) => {
|
|
16
|
+
for (const resource of resources) {
|
|
17
|
+
if (!isLocalFunctionResource(resource))
|
|
18
|
+
continue;
|
|
19
|
+
// skip if not a durable function
|
|
20
|
+
if (resource.type !== SANITY_FUNCTION_DURABLE)
|
|
21
|
+
continue;
|
|
22
|
+
// Check if source needs to be transpiled before attempting to get config
|
|
23
|
+
const resourceSrc = resolve(blueprintFileDir, resource.src);
|
|
24
|
+
const entryPoint = await findFunctionEntryPoint(resourceSrc, resource.name);
|
|
25
|
+
let importPath = entryPoint;
|
|
26
|
+
let cleanup = async () => { };
|
|
27
|
+
// need to transpile and grab the config from the built output if the entry point is a TypeScript file
|
|
28
|
+
if (entryPoint.endsWith('.ts')) {
|
|
29
|
+
const built = await transpileFunction({ resource, functionPath: resourceSrc, entryPoint });
|
|
30
|
+
importPath = await findFunctionEntryPoint(built.outputDir, resource.name);
|
|
31
|
+
cleanup = built.cleanup;
|
|
32
|
+
}
|
|
33
|
+
let config = {};
|
|
34
|
+
try {
|
|
35
|
+
const mod = await import(pathToFileURL(importPath).href);
|
|
36
|
+
config = (mod.handler || mod.default)?.config;
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
await cleanup();
|
|
40
|
+
}
|
|
41
|
+
// Update values not included in the blueprint.
|
|
42
|
+
if (resource.event === undefined && config?.event !== undefined) {
|
|
43
|
+
resource.event = config.event;
|
|
44
|
+
}
|
|
45
|
+
if (resource.concurrency === undefined && config?.concurrency !== undefined) {
|
|
46
|
+
resource.concurrency = config.concurrency;
|
|
47
|
+
}
|
|
48
|
+
if (resource.debounce === undefined && config?.debounce !== undefined) {
|
|
49
|
+
resource.debounce = config.debounce;
|
|
50
|
+
}
|
|
51
|
+
if (resource.debounceKey === undefined && config?.debounceKey !== undefined) {
|
|
52
|
+
resource.debounceKey = config.debounceKey;
|
|
53
|
+
}
|
|
54
|
+
// Validate the resource after merging the config values
|
|
55
|
+
const errors = validateDurableFunction(resource);
|
|
56
|
+
if (errors.length > 0) {
|
|
57
|
+
throw new Error(`Invalid durable resource "${resource.name}": ${errors.map((error) => error.message).join('; ')}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { validateCorsOrigin, validateDataset, validateDocumentFunction, validateDocumentWebhook, validateMediaLibraryAssetFunction, validateProject, validateRole, validateScheduledFunction, } from '@sanity/blueprints';
|
|
2
|
-
import { SANITY_ACCESS_ROLE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, SANITY_PROJECT, SANITY_PROJECT_CORS, SANITY_PROJECT_DATASET, SANITY_PROJECT_WEBHOOK, } from '../../constants.js';
|
|
1
|
+
import { validateCorsOrigin, validateDataset, validateDocumentFunction, validateDocumentWebhook, validateDurableFunction, validateMediaLibraryAssetFunction, validateProject, validateRole, validateScheduledFunction, } from '@sanity/blueprints';
|
|
2
|
+
import { SANITY_ACCESS_ROLE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_DURABLE, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, SANITY_PROJECT, SANITY_PROJECT_CORS, SANITY_PROJECT_DATASET, SANITY_PROJECT_WEBHOOK, } from '../../constants.js';
|
|
3
3
|
const RESOURCE_VALIDATORS = {
|
|
4
4
|
[SANITY_ACCESS_ROLE]: {
|
|
5
5
|
validate: validateRole,
|
|
@@ -25,6 +25,9 @@ const RESOURCE_VALIDATORS = {
|
|
|
25
25
|
[SANITY_PROJECT_WEBHOOK]: {
|
|
26
26
|
validate: validateDocumentWebhook,
|
|
27
27
|
},
|
|
28
|
+
[SANITY_FUNCTION_DURABLE]: {
|
|
29
|
+
validate: validateDurableFunction,
|
|
30
|
+
},
|
|
28
31
|
};
|
|
29
32
|
export function validateResources(resources) {
|
|
30
33
|
const errors = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { treeify } from 'array-treeify';
|
|
2
|
-
import { SANITY_ACCESS_ROBOT, SANITY_ACCESS_ROLE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, SANITY_FUNCTION_SYNC_TAG_INVALIDATE, SANITY_PROJECT, SANITY_PROJECT_CORS, SANITY_PROJECT_DATASET, SANITY_PROJECT_WEBHOOK, } from '../../constants.js';
|
|
2
|
+
import { SANITY_ACCESS_ROBOT, SANITY_ACCESS_ROLE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_DURABLE, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_PUBSUB, SANITY_FUNCTION_SCHEDULED, SANITY_FUNCTION_SYNC_TAG_INVALIDATE, SANITY_PROJECT, SANITY_PROJECT_CORS, SANITY_PROJECT_DATASET, SANITY_PROJECT_WEBHOOK, } from '../../constants.js';
|
|
3
3
|
import { styleText } from '../style-text.js';
|
|
4
4
|
import { isCorsOriginResource, isDatasetResource, isRobotResource, isRoleResource, isWebhookResource, } from '../types.js';
|
|
5
5
|
import { formatDateTime, formatDuration } from './dates.js';
|
|
@@ -27,8 +27,10 @@ const RESOURCE_CATEGORIES = {
|
|
|
27
27
|
},
|
|
28
28
|
[SANITY_FUNCTION_DOCUMENT]: functionCategory,
|
|
29
29
|
[SANITY_FUNCTION_MEDIA_LIBRARY_ASSET]: functionCategory,
|
|
30
|
+
[SANITY_FUNCTION_PUBSUB]: functionCategory,
|
|
30
31
|
[SANITY_FUNCTION_SCHEDULED]: functionCategory,
|
|
31
32
|
[SANITY_FUNCTION_SYNC_TAG_INVALIDATE]: functionCategory,
|
|
33
|
+
[SANITY_FUNCTION_DURABLE]: functionCategory,
|
|
32
34
|
[SANITY_PROJECT]: {
|
|
33
35
|
label: 'Projects',
|
|
34
36
|
displayNameAttribute: 'displayName',
|
|
@@ -72,15 +74,15 @@ function resourceName(res, displayNameAttribute) {
|
|
|
72
74
|
nameParts.push(styleText('green', `"${displayName}"`));
|
|
73
75
|
return nameParts.join(' ');
|
|
74
76
|
}
|
|
75
|
-
function deployedResourceName(res, displayNameAttribute,
|
|
77
|
+
function deployedResourceName(res, displayNameAttribute, verbose = false) {
|
|
76
78
|
const nameParts = [styleText(['bold', 'green'], res.name)];
|
|
77
79
|
const displayName = displayNameAttribute &&
|
|
78
80
|
typeof res.parameters[displayNameAttribute] === 'string' &&
|
|
79
81
|
res.parameters[displayNameAttribute];
|
|
80
82
|
if (displayName && displayName !== res.name)
|
|
81
83
|
nameParts.push(styleText('green', `"${displayName}"`));
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
if (verbose)
|
|
85
|
+
nameParts.push(idList(res));
|
|
84
86
|
return nameParts.join(' ');
|
|
85
87
|
}
|
|
86
88
|
function idList(res) {
|
|
@@ -215,11 +217,13 @@ export function formatStacksListing(stacks, currentStackId) {
|
|
|
215
217
|
const IGNORED_PARAMS = {
|
|
216
218
|
[SANITY_FUNCTION_DOCUMENT]: new Set(['src']),
|
|
217
219
|
[SANITY_FUNCTION_MEDIA_LIBRARY_ASSET]: new Set(['src']),
|
|
220
|
+
[SANITY_FUNCTION_PUBSUB]: new Set(['src']),
|
|
218
221
|
[SANITY_FUNCTION_SCHEDULED]: new Set(['src']),
|
|
219
222
|
};
|
|
220
223
|
const ASSET_RESOURCE_TYPES = new Set([
|
|
221
224
|
SANITY_FUNCTION_DOCUMENT,
|
|
222
225
|
SANITY_FUNCTION_MEDIA_LIBRARY_ASSET,
|
|
226
|
+
SANITY_FUNCTION_PUBSUB,
|
|
223
227
|
SANITY_FUNCTION_SCHEDULED,
|
|
224
228
|
]);
|
|
225
229
|
function stringifyUnknown(val) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isLocalFunctionResource, isScheduleEvent } from '../../utils/types.js';
|
|
1
|
+
import { hasEventSource, isLocalFunctionResource, isScheduleEvent, } from '../../utils/types.js';
|
|
2
2
|
import { styleText } from '../style-text.js';
|
|
3
3
|
function formatLabel(label) {
|
|
4
4
|
return styleText('dim', `${label}:`);
|
|
@@ -46,7 +46,7 @@ export function arrayifyFunction(fn) {
|
|
|
46
46
|
details.push(formatLabeledValue('memory', fn.memory));
|
|
47
47
|
if (fn.timeout)
|
|
48
48
|
details.push(formatLabeledValue('timeout', fn.timeout));
|
|
49
|
-
if (fn.event) {
|
|
49
|
+
if (hasEventSource(fn) && fn.event) {
|
|
50
50
|
const eventDetails = arrayifyEvent(fn.event);
|
|
51
51
|
if (eventDetails) {
|
|
52
52
|
details.push(formatLabel('event'));
|
package/dist/utils/style-text.js
CHANGED
package/dist/utils/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BlueprintCorsOriginResource, type BlueprintDatasetResource, type BlueprintDocumentFunctionResource, type BlueprintDocumentWebhookResource, type BlueprintMediaLibraryAssetFunctionResource, type BlueprintProjectResource, type BlueprintResource, type BlueprintRobotResource, type BlueprintRoleResource, type BlueprintScheduledFunctionResource, type BlueprintStudioResource, type BlueprintSyncTagInvalidateFunctionResource } from '@sanity/blueprints';
|
|
1
|
+
import { type BlueprintCorsOriginResource, type BlueprintDatasetResource, type BlueprintDocumentFunctionResource, type BlueprintDocumentWebhookResource, type BlueprintDurableFunctionResource, type BlueprintMediaLibraryAssetFunctionResource, type BlueprintProjectResource, type BlueprintPubSubFunctionResource, type BlueprintResource, type BlueprintRobotResource, type BlueprintRoleResource, type BlueprintScheduledFunctionResource, type BlueprintStudioResource, type BlueprintSyncTagInvalidateFunctionResource } from '@sanity/blueprints';
|
|
2
2
|
export type ScopeType = 'organization' | 'project';
|
|
3
3
|
/** Result utility type */
|
|
4
4
|
export type Result<T, E = string> = {
|
|
@@ -15,7 +15,11 @@ export interface ActionResponse {
|
|
|
15
15
|
}
|
|
16
16
|
/** @internal */
|
|
17
17
|
export type FunctionGroqResource = BlueprintDocumentFunctionResource | BlueprintMediaLibraryAssetFunctionResource;
|
|
18
|
-
export type FunctionResource = FunctionGroqResource | BlueprintScheduledFunctionResource | BlueprintSyncTagInvalidateFunctionResource;
|
|
18
|
+
export type FunctionResource = FunctionGroqResource | BlueprintPubSubFunctionResource | BlueprintScheduledFunctionResource | BlueprintSyncTagInvalidateFunctionResource | BlueprintDurableFunctionResource;
|
|
19
|
+
/** Function resources that declare an `event`; PubSub functions are triggered by other functions */
|
|
20
|
+
export type EventFunctionResource = Exclude<FunctionResource, BlueprintPubSubFunctionResource>;
|
|
21
|
+
/** The `event` of any function resource that declares one */
|
|
22
|
+
export type FunctionResourceEvent = EventFunctionResource['event'];
|
|
19
23
|
/** Resource types that carry a deployable asset (have src: string) */
|
|
20
24
|
export type AssetResource = FunctionResource | BlueprintStudioResource;
|
|
21
25
|
/** @internal */
|
|
@@ -36,6 +40,7 @@ export interface DeployedResource extends BlueprintResourceRecord {
|
|
|
36
40
|
externalId: string;
|
|
37
41
|
}
|
|
38
42
|
export declare function isLocalFunctionResource(r: BlueprintResource): r is FunctionResource;
|
|
43
|
+
export declare function hasEventSource(r: FunctionResource): r is EventFunctionResource;
|
|
39
44
|
export declare function isScheduleEvent(e: unknown): e is BlueprintScheduledFunctionResource['event'];
|
|
40
45
|
export declare function isCorsOriginResource(r: unknown): r is BlueprintCorsOriginResource;
|
|
41
46
|
export declare function isProjectResource(r: unknown): r is BlueprintProjectResource;
|
|
@@ -43,6 +48,7 @@ export declare function isRobotResource(r: unknown): r is BlueprintRobotResource
|
|
|
43
48
|
export declare function isRoleResource(r: unknown): r is BlueprintRoleResource;
|
|
44
49
|
export declare function isDatasetResource(r: unknown): r is BlueprintDatasetResource;
|
|
45
50
|
export declare function isStudioResource(r: BlueprintResource): r is BlueprintStudioResource;
|
|
51
|
+
export declare function isDurableFunctionResource(r: unknown): r is BlueprintDurableFunctionResource;
|
|
46
52
|
export declare function isAssetResource(r: BlueprintResource): r is AssetResource;
|
|
47
53
|
export declare function isWebhookResource(r: unknown): r is BlueprintDocumentWebhookResource;
|
|
48
54
|
interface StackBase {
|
package/dist/utils/types.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { validateCorsOrigin, validateDataset, validateDocumentWebhook, validateProject, validateRobot, validateRole, } from '@sanity/blueprints';
|
|
2
|
-
import { SANITY_FUNCTION_PREFIX, SANITY_STUDIO } from '../constants.js';
|
|
1
|
+
import { validateCorsOrigin, validateDataset, validateDocumentWebhook, validateDurableFunction, validateProject, validateRobot, validateRole, } from '@sanity/blueprints';
|
|
2
|
+
import { SANITY_FUNCTION_PREFIX, SANITY_FUNCTION_PUBSUB, SANITY_STUDIO } from '../constants.js';
|
|
3
3
|
export function isLocalFunctionResource(r) {
|
|
4
4
|
return r.type.startsWith(SANITY_FUNCTION_PREFIX);
|
|
5
5
|
}
|
|
6
|
+
export function hasEventSource(r) {
|
|
7
|
+
return r.type !== SANITY_FUNCTION_PUBSUB;
|
|
8
|
+
}
|
|
6
9
|
// type narrowing with predicate functions
|
|
7
10
|
export function isScheduleEvent(e) {
|
|
8
11
|
return e !== null && typeof e === 'object' && ('hour' in e || 'expression' in e);
|
|
@@ -25,6 +28,9 @@ export function isDatasetResource(r) {
|
|
|
25
28
|
export function isStudioResource(r) {
|
|
26
29
|
return r.type === SANITY_STUDIO;
|
|
27
30
|
}
|
|
31
|
+
export function isDurableFunctionResource(r) {
|
|
32
|
+
return validateDurableFunction(r).length === 0;
|
|
33
|
+
}
|
|
28
34
|
export function isAssetResource(r) {
|
|
29
35
|
return isLocalFunctionResource(r) || isStudioResource(r);
|
|
30
36
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -148,6 +148,7 @@
|
|
|
148
148
|
"media-library-asset-create",
|
|
149
149
|
"media-library-asset-delete",
|
|
150
150
|
"media-library-asset-update",
|
|
151
|
+
"pub-sub",
|
|
151
152
|
"scheduled-function",
|
|
152
153
|
"sync-tag-invalidate"
|
|
153
154
|
],
|
|
@@ -373,7 +374,7 @@
|
|
|
373
374
|
"blueprints:deploy": {
|
|
374
375
|
"aliases": [],
|
|
375
376
|
"args": {},
|
|
376
|
-
"description": "Applies your local Blueprint to the remote Stack, creating, updating, or removing resources as needed. This is the primary command for applying infrastructure changes.\n\nBefore deploying, run 'blueprints plan' to preview changes. After deployment, use 'blueprints info' to verify Stack status or 'blueprints logs' to monitor activity.\n\nUse --no-wait to queue the deployment and return immediately without waiting for completion.\n\nUse --fn-installer to force which package manager to use when deploying functions.\n\nSet SANITY_ASSET_TIMEOUT (seconds) to override the
|
|
377
|
+
"description": "Applies your local Blueprint to the remote Stack, creating, updating, or removing resources as needed. This is the primary command for applying infrastructure changes.\n\nBefore deploying, run 'blueprints plan' to preview changes. After deployment, use 'blueprints info' to verify Stack status or 'blueprints logs' to monitor activity.\n\nUse --no-wait to queue the deployment and return immediately without waiting for completion.\n\nUse --fn-installer to force which package manager to use when deploying functions.\n\nSet SANITY_ASSET_TIMEOUT (seconds) to override the 180-second timeout for processing resource assets.\n\nSet SANITY_ASSET_CONCURRENCY to override how many resource assets are processed at once (default 4).\n\nExit codes: 0 deployed, 2 deployment failed, 75 deployment accepted but completion could not be confirmed (rerun 'blueprints info' to check).",
|
|
377
378
|
"examples": [
|
|
378
379
|
"<%= config.bin %> <%= command.id %>",
|
|
379
380
|
"<%= config.bin %> <%= command.id %> --message \"Enable staging dataset\"",
|
|
@@ -629,9 +630,7 @@
|
|
|
629
630
|
"type": "option"
|
|
630
631
|
},
|
|
631
632
|
"force": {
|
|
632
|
-
"
|
|
633
|
-
"f"
|
|
634
|
-
],
|
|
633
|
+
"char": "f",
|
|
635
634
|
"description": "Force Stack destruction (skip confirmation)",
|
|
636
635
|
"name": "force",
|
|
637
636
|
"allowNo": false,
|
|
@@ -781,8 +780,8 @@
|
|
|
781
780
|
"type": "boolean"
|
|
782
781
|
},
|
|
783
782
|
"verbose": {
|
|
784
|
-
"
|
|
785
|
-
"
|
|
783
|
+
"char": "v",
|
|
784
|
+
"description": "Show resource and external IDs",
|
|
786
785
|
"name": "verbose",
|
|
787
786
|
"allowNo": false,
|
|
788
787
|
"type": "boolean"
|
|
@@ -855,7 +854,7 @@
|
|
|
855
854
|
"name": "dir"
|
|
856
855
|
}
|
|
857
856
|
},
|
|
858
|
-
"description": "A Blueprint is your local infrastructure-as-code configuration that defines Sanity resources (datasets, functions, etc.). A Stack is the remote deployment target where your Blueprint is applied.\n
|
|
857
|
+
"description": "A Blueprint is your local infrastructure-as-code configuration that defines Sanity resources (datasets, functions, etc.). A Stack is the remote deployment target where your Blueprint is applied.\n\nThis is typically the first command you run in a new project. It creates a local Blueprint manifest file (sanity.blueprint.ts, .js, or .json) and provisions a new remote Stack.\nAdditionally, a Blueprint configuration file is created in .sanity/ containing the scope and Stack IDs. A .gitignore covering node_modules, .env, and Function build output is created or updated; the .sanity/ config itself is not ignored.\n\nAfter initialization, use 'blueprints plan' to preview changes, then 'blueprints deploy' to apply them.\n\nRunning without a directory prompts to confirm the current directory. Run 'blueprints init .' to initialize in the current directory without a prompt.",
|
|
859
858
|
"examples": [
|
|
860
859
|
"<%= config.bin %> <%= command.id %>",
|
|
861
860
|
"<%= config.bin %> <%= command.id %> .",
|
|
@@ -1132,6 +1131,9 @@
|
|
|
1132
1131
|
],
|
|
1133
1132
|
"char": "w",
|
|
1134
1133
|
"description": "Watch for new Stack logs",
|
|
1134
|
+
"exclusive": [
|
|
1135
|
+
"json"
|
|
1136
|
+
],
|
|
1135
1137
|
"name": "watch",
|
|
1136
1138
|
"allowNo": false,
|
|
1137
1139
|
"type": "boolean"
|
|
@@ -1768,11 +1770,12 @@
|
|
|
1768
1770
|
"description": "Example to use for the Function",
|
|
1769
1771
|
"exclusive": [
|
|
1770
1772
|
"name",
|
|
1771
|
-
"
|
|
1773
|
+
"type",
|
|
1772
1774
|
"language",
|
|
1773
1775
|
"javascript",
|
|
1774
|
-
"
|
|
1775
|
-
"
|
|
1776
|
+
"helpers",
|
|
1777
|
+
"installer",
|
|
1778
|
+
"install"
|
|
1776
1779
|
],
|
|
1777
1780
|
"name": "example",
|
|
1778
1781
|
"hasDynamicHelp": false,
|
|
@@ -1803,6 +1806,7 @@
|
|
|
1803
1806
|
"media-library-asset-create",
|
|
1804
1807
|
"media-library-asset-delete",
|
|
1805
1808
|
"media-library-asset-update",
|
|
1809
|
+
"pub-sub",
|
|
1806
1810
|
"scheduled-function",
|
|
1807
1811
|
"sync-tag-invalidate"
|
|
1808
1812
|
],
|
|
@@ -1856,9 +1860,9 @@
|
|
|
1856
1860
|
},
|
|
1857
1861
|
"install": {
|
|
1858
1862
|
"char": "i",
|
|
1859
|
-
"description": "Shortcut for --
|
|
1863
|
+
"description": "Shortcut for --installer npm",
|
|
1860
1864
|
"exclusive": [
|
|
1861
|
-
"
|
|
1865
|
+
"installer"
|
|
1862
1866
|
],
|
|
1863
1867
|
"name": "install",
|
|
1864
1868
|
"allowNo": false,
|
|
@@ -2024,9 +2028,9 @@
|
|
|
2024
2028
|
"functions:dev": {
|
|
2025
2029
|
"aliases": [],
|
|
2026
2030
|
"args": {},
|
|
2027
|
-
"description": "Runs a local, web-based development server to test your functions before deploying.\n\nOpen the emulator in your browser to interactively test your functions with the payload editor.\n\nOptionally, set the host and port with the --host and --port flags. Function timeout can be configured with the --timeout flag.\n\nTo invoke a function with the CLI, use 'functions test'.",
|
|
2031
|
+
"description": "Runs a local, web-based development server to test your functions before deploying.\n\nOpen the emulator in your browser to interactively test your functions with the payload editor.\n\nOptionally, set the host and port with the --host and --port flags. Port 8974 is reserved for the emulator's live-reload WebSocket server. Function timeout can be configured with the --timeout flag.\n\nTo invoke a function with the CLI, use 'functions test'.",
|
|
2028
2032
|
"examples": [
|
|
2029
|
-
"<%= config.bin %> <%= command.id %> --host 127.0.0.1 --port
|
|
2033
|
+
"<%= config.bin %> <%= command.id %> --host 127.0.0.1 --port 3333",
|
|
2030
2034
|
"<%= config.bin %> <%= command.id %> --timeout 60"
|
|
2031
2035
|
],
|
|
2032
2036
|
"flags": {
|
|
@@ -2410,6 +2414,9 @@
|
|
|
2410
2414
|
],
|
|
2411
2415
|
"char": "w",
|
|
2412
2416
|
"description": "Watch for new logs (streaming mode)",
|
|
2417
|
+
"exclusive": [
|
|
2418
|
+
"json"
|
|
2419
|
+
],
|
|
2413
2420
|
"name": "watch",
|
|
2414
2421
|
"allowNo": false,
|
|
2415
2422
|
"type": "boolean"
|
|
@@ -3120,5 +3127,5 @@
|
|
|
3120
3127
|
]
|
|
3121
3128
|
}
|
|
3122
3129
|
},
|
|
3123
|
-
"version": "17.
|
|
3130
|
+
"version": "17.6.0"
|
|
3124
3131
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/runtime-cli",
|
|
3
3
|
"description": "Sanity's Runtime CLI for Blueprints and Functions",
|
|
4
|
-
"version": "17.
|
|
4
|
+
"version": "17.6.0",
|
|
5
5
|
"author": "Sanity Runtime Team",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
"files": [
|
|
27
27
|
"./bin",
|
|
28
28
|
"./dist",
|
|
29
|
+
"./SKILL.md",
|
|
30
|
+
"./skills",
|
|
29
31
|
"./oclif.manifest.json"
|
|
30
32
|
],
|
|
31
33
|
"bin": {
|
|
@@ -48,7 +50,7 @@
|
|
|
48
50
|
"lint:fix": "npm run lint:write",
|
|
49
51
|
"prepare": "npm run build",
|
|
50
52
|
"postpack": "shx rm -f oclif.manifest.json",
|
|
51
|
-
"test": "vitest run && npm run test:depmgmt && npm run lint",
|
|
53
|
+
"test": "npm run typecheck && vitest run && npm run test:depmgmt && npm run lint",
|
|
52
54
|
"test:depmgmt": "vitest run --config ./test-depmgmt/vitest.config.ts",
|
|
53
55
|
"test:coverage": "vitest run --coverage --coverage.include \"runtime-cli/src/**/*\"",
|
|
54
56
|
"test:scenarios": "vitest run test/scenarios",
|
|
@@ -63,19 +65,20 @@
|
|
|
63
65
|
"@architect/hydrate": "~6.0.2",
|
|
64
66
|
"@architect/inventory": "~6.1.0",
|
|
65
67
|
"@inquirer/prompts": "^8.5.2",
|
|
66
|
-
"@oclif/core": "^4.13.
|
|
67
|
-
"@oclif/plugin-help": "^6.2.
|
|
68
|
+
"@oclif/core": "^4.13.3",
|
|
69
|
+
"@oclif/plugin-help": "^6.2.56",
|
|
68
70
|
"@sanity-labs/design-tokens": "^0.0.2-alpha.2",
|
|
69
|
-
"@sanity/
|
|
71
|
+
"@sanity-labs/oclif-plugin-skills-flag": "^0.2.1",
|
|
72
|
+
"@sanity/blueprints": "^0.23.2",
|
|
70
73
|
"@sanity/blueprints-parser": "^0.4.0",
|
|
71
74
|
"@sanity/cli-build": "^5.1.0",
|
|
72
|
-
"@sanity/cli-core": "^2.
|
|
73
|
-
"@sanity/client": "^7.26.
|
|
75
|
+
"@sanity/cli-core": "^2.8.1",
|
|
76
|
+
"@sanity/client": "^7.26.2",
|
|
74
77
|
"adm-zip": "^0.6.0",
|
|
75
78
|
"array-treeify": "^0.1.5",
|
|
76
79
|
"cardinal": "^2.1.1",
|
|
77
80
|
"empathic": "^2.0.1",
|
|
78
|
-
"eventsource": "^4.1.
|
|
81
|
+
"eventsource": "^4.1.1",
|
|
79
82
|
"groq-js": "^2.0.0",
|
|
80
83
|
"jiti": "^2.7.0",
|
|
81
84
|
"mime-types": "^3.0.2",
|
|
@@ -84,12 +87,12 @@
|
|
|
84
87
|
"strip-ansi": "^7.2.0",
|
|
85
88
|
"tar-fs": "^3.1.3",
|
|
86
89
|
"tar-stream": "^3.2.0",
|
|
87
|
-
"vite": "^8.1
|
|
88
|
-
"ws": "^8.21.
|
|
90
|
+
"vite": "^8.2.1",
|
|
91
|
+
"ws": "^8.21.3",
|
|
89
92
|
"xdg-basedir": "^5.1.0"
|
|
90
93
|
},
|
|
91
94
|
"devDependencies": {
|
|
92
|
-
"@biomejs/biome": "2.5.
|
|
95
|
+
"@biomejs/biome": "2.5.7",
|
|
93
96
|
"@codemirror/lang-json": "^6.0.2",
|
|
94
97
|
"@codemirror/state": "^6.7.1",
|
|
95
98
|
"@enhance/store": "^1.0.2",
|
|
@@ -97,7 +100,7 @@
|
|
|
97
100
|
"@oclif/test": "^4.1.21",
|
|
98
101
|
"@playwright/test": "^1.62.1",
|
|
99
102
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
100
|
-
"@sanity/functions": "^1.
|
|
103
|
+
"@sanity/functions": "^1.6.0",
|
|
101
104
|
"@types/adm-zip": "^0.5.8",
|
|
102
105
|
"@types/cardinal": "^2.1.1",
|
|
103
106
|
"@types/mime-types": "^3.0.1",
|
|
@@ -108,10 +111,10 @@
|
|
|
108
111
|
"@vitest/coverage-v8": "4.1.10",
|
|
109
112
|
"codemirror": "^6.0.2",
|
|
110
113
|
"mentoss": "^0.13.0",
|
|
111
|
-
"oclif": "^4.23.
|
|
114
|
+
"oclif": "^4.23.30",
|
|
112
115
|
"pretty-bytes": "^7.1.1",
|
|
113
116
|
"pretty-ms": "^9.3.0",
|
|
114
|
-
"rollup": "^4.62.
|
|
117
|
+
"rollup": "^4.62.4",
|
|
115
118
|
"shx": "^0.4.0",
|
|
116
119
|
"typescript": "^7.0.2",
|
|
117
120
|
"vitest": "4.1.10"
|
|
@@ -121,7 +124,8 @@
|
|
|
121
124
|
"dirname": "sanity-run",
|
|
122
125
|
"commands": "./dist/commands",
|
|
123
126
|
"plugins": [
|
|
124
|
-
"@oclif/plugin-help"
|
|
127
|
+
"@oclif/plugin-help",
|
|
128
|
+
"@sanity-labs/oclif-plugin-skills-flag"
|
|
125
129
|
],
|
|
126
130
|
"topicSeparator": " ",
|
|
127
131
|
"topics": {
|
|
@@ -133,6 +137,16 @@
|
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
139
|
},
|
|
140
|
+
"oclif-plugin-skills-flag": {
|
|
141
|
+
"flag": "skill",
|
|
142
|
+
"aliases": [
|
|
143
|
+
"agent",
|
|
144
|
+
"llm",
|
|
145
|
+
"llms",
|
|
146
|
+
"skills"
|
|
147
|
+
],
|
|
148
|
+
"directory": "skills"
|
|
149
|
+
},
|
|
136
150
|
"publishConfig": {
|
|
137
151
|
"access": "public",
|
|
138
152
|
"provenance": false
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# `npx @sanity/cli functions build`
|
|
2
|
+
|
|
3
|
+
Build local Functions into zip archives. This command is hidden from generated help; use it when archive artifacts are explicitly needed, not as a required step before `blueprints deploy`.
|
|
4
|
+
|
|
5
|
+
## Build
|
|
6
|
+
|
|
7
|
+
Build every local Function in the Blueprint:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx @sanity/cli functions build --json
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Build one Function into a chosen directory:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npx @sanity/cli functions build process-order --out-dir artifacts/functions --json
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Without `--out-dir`, archives are written to `.build/` beside the Blueprint manifest. An existing archive with the same Function name is replaced.
|
|
20
|
+
|
|
21
|
+
The JSON result contains `built`, `errors`, and `outDir`. A run can succeed when some Functions build and others fail, so inspect `errors` even when the exit code is zero. If every build fails, the command exits with an error.
|
|
22
|
+
|
|
23
|
+
The `.gitignore` written by `blueprints init` covers `functions/**/.build/`, not the top-level `.build/` these archives land in, so exclude the output directory before committing.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# `npx @sanity/cli functions list`
|
|
2
|
+
|
|
3
|
+
List Functions deployed in a project or organization scope. This command is hidden from generated help. Results cover the whole scope rather than one Stack; use `blueprints info` for the resources of a single Stack.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
Use the locally configured scope:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx @sanity/cli functions list --json
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Select a scope explicitly when working outside a local Blueprint:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npx @sanity/cli functions list --project-id PROJECT_ID --json
|
|
17
|
+
npx @sanity/cli functions list --organization-id ORGANIZATION_ID --json
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The two flags are mutually exclusive. No Blueprint manifest is required: the scope resolves from those flags, from `SANITY_PROJECT_ID` or `SANITY_ORGANIZATION_ID`, or from `.sanity/blueprint.config.json`, and the command fails with `Missing scope` when none of them do. The scope is sent with the request, so a project and its organization return different sets: scheduled Functions are organization-scoped, every other type is project-scoped.
|
|
21
|
+
|
|
22
|
+
## Read the result
|
|
23
|
+
|
|
24
|
+
The JSON result contains `functions`, `scopeType`, and `scopeId`. Each entry carries `id`, `name`, `displayName`, `type`, `runtime`, `status`, `memory`, `storage`, `timeout`, `resourceType`, `resourceId`, `url`, `createdAt`, and `updatedAt`. An empty scope still emits `{"functions": []}` and exits `0`, so check the array length rather than the exit code.
|
|
25
|
+
|
|
26
|
+
Default output is one line per Function with its name, ID, type, and last update time. `--verbose` (`-v`) instead prints the type, update time, memory, timeout, and event rule of each.
|
|
27
|
+
|
|
28
|
+
Treat this as an inspection command. `functions logs`, `functions env add`, and `functions env remove` address a Function by its Blueprint resource name resolved through the deployed Stack, not by the `id` shown here.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints add`
|
|
2
|
+
|
|
3
|
+
Treat this command as legacy compatibility only. It is deprecated and supports only the `function` resource type. Prefer `npx @sanity/cli functions add` for new work.
|
|
4
|
+
|
|
5
|
+
## Agent guidance
|
|
6
|
+
|
|
7
|
+
- Warn that the command is deprecated before adding new usage to scripts or documentation.
|
|
8
|
+
- Migrate existing legacy invocations to `npx @sanity/cli functions add`.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints config`
|
|
2
|
+
|
|
3
|
+
Read or update `.sanity/blueprint.config.json`, written next to the Blueprint manifest, which connects the local Blueprint to a Sanity scope and Stack.
|
|
4
|
+
|
|
5
|
+
## Inspect first
|
|
6
|
+
|
|
7
|
+
Run from the Blueprint directory and request structured output:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx @sanity/cli blueprints config --json
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Without `--edit`, the command only displays the current configuration; with no config file on disk, `--json` emits nothing and exits `0`. Treat the project or organization ID and Stack ID as a single target; changing one can redirect later plan, deploy, info, logs, promote, or destroy commands.
|
|
14
|
+
|
|
15
|
+
## Update
|
|
16
|
+
|
|
17
|
+
For agent-driven changes, pass the intended values instead of using the interactive editor:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npx @sanity/cli blueprints config --edit --project-id PROJECT_ID --stack NAME_OR_ID --json
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Use `--organization-id ORGANIZATION_ID` instead of `--project-id` for an organization scope. The two scope flags are mutually exclusive. `--stack` accepts a Stack name or ID.
|
|
24
|
+
|
|
25
|
+
Scope or Stack flags without `--edit` write nothing: the command prints `To update the Blueprint config, use the --edit flag.` (suppressed under `--json`) and exits `0`, so a successful exit does not mean the change was applied.
|
|
26
|
+
|
|
27
|
+
## Switching scope
|
|
28
|
+
|
|
29
|
+
An update only sets the keys it was given. Adding `--organization-id` to a config that already holds `projectId` leaves both in the file, and project scope takes precedence over organization scope, so the switch has no effect on later commands.
|
|
30
|
+
|
|
31
|
+
To move a Blueprint from project to organization scope, either edit `.sanity/blueprint.config.json` to remove `projectId`, or use `blueprints promote`, which clears it as part of the scope change.
|
|
32
|
+
|
|
33
|
+
After an update, run `blueprints config --json` again and verify every ID before executing a mutating command.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints deploy`
|
|
2
|
+
|
|
3
|
+
Apply the local Blueprint to a remote Stack. This command can create, update, and remove remote resources.
|
|
4
|
+
|
|
5
|
+
## Preflight
|
|
6
|
+
|
|
7
|
+
1. Locate and inspect the Blueprint manifest.
|
|
8
|
+
2. Resolve the target from local configuration, or pass an explicit scope and `--stack`.
|
|
9
|
+
3. Run `npx @sanity/cli blueprints plan --json`.
|
|
10
|
+
4. Review all planned changes, especially replacements and removals.
|
|
11
|
+
|
|
12
|
+
Do not deploy when the target or plan is ambiguous.
|
|
13
|
+
|
|
14
|
+
## Deploy
|
|
15
|
+
|
|
16
|
+
Include a message that records the reason for the change:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npx @sanity/cli blueprints deploy --message "Deploy order processing changes" --json
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
To target another Stack, pass `--stack NAME_OR_ID`, adding `--project-id PROJECT_ID` or `--organization-id ORGANIZATION_ID` when the scope also differs.
|
|
23
|
+
|
|
24
|
+
Use `--no-wait` only when the caller does not need a confirmed result. Follow an asynchronous deployment with:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx @sanity/cli blueprints info --json
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Exit code `0` means the deployment completed, or was accepted when `--no-wait` is set. Exit code `2` means it failed. Exit code `75` means the request was accepted but completion could not be confirmed; inspect `blueprints info` and `blueprints logs` before retrying.
|
|
31
|
+
|
|
32
|
+
The command refuses to start while the Stack has a `QUEUED` or `IN_PROGRESS` operation, so a retry during one fails with that message rather than deploying twice. Once the earlier operation settles, a retry does deploy again.
|
|
33
|
+
|
|
34
|
+
Use `--new-stack-name NAME` only when the deployment should also rename the Stack.
|
|
35
|
+
|
|
36
|
+
Set `SANITY_ASSET_TIMEOUT` in seconds to raise the 180-second per-asset limit on processing resource assets when large Functions time out during preparation. Set `SANITY_ASSET_CONCURRENCY` to change how many assets are processed at once (default 4).
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# `npx @sanity/cli blueprints destroy`
|
|
2
|
+
|
|
3
|
+
Permanently destroy a remote Stack and its provisioned resources. The local Blueprint manifest and resource files remain, and a matching local Stack ID is cleared from `.sanity/blueprint.config.json`.
|
|
4
|
+
|
|
5
|
+
## Required safety checks
|
|
6
|
+
|
|
7
|
+
1. Obtain explicit authorization to destroy the Stack.
|
|
8
|
+
2. Resolve the exact project or organization scope and Stack ID.
|
|
9
|
+
3. Run `npx @sanity/cli blueprints info --json` for that target.
|
|
10
|
+
4. Present the resolved target and affected resources before continuing.
|
|
11
|
+
|
|
12
|
+
Do not infer authorization from a request to clean up files, redeploy, or fix configuration.
|
|
13
|
+
|
|
14
|
+
## Run
|
|
15
|
+
|
|
16
|
+
Interactive use prompts for confirmation:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npx @sanity/cli blueprints destroy
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
For an authorized non-interactive destruction, provide the complete target:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npx @sanity/cli blueprints destroy --project-id PROJECT_ID --stack NAME_OR_ID --force --json
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Use `--organization-id` instead of `--project-id` for an organization-scoped Stack. The explicit scope flags require both `--stack` and `--force`.
|
|
29
|
+
|
|
30
|
+
Use `--no-wait` only when asynchronous destruction is intended: it exits `0` as soon as the request is accepted. While waiting, exit code `75` means the request was accepted but completion could not be confirmed. Check `blueprints info` before retrying.
|