@sanity/runtime-cli 14.12.0 → 14.12.1
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 +19 -20
- package/dist/actions/blueprints/blueprint.d.ts +17 -0
- package/dist/actions/blueprints/blueprint.js +24 -20
- package/dist/actions/blueprints/resolve.d.ts +11 -6
- package/dist/actions/blueprints/resolve.js +14 -4
- package/dist/actions/functions/dev.d.ts +1 -2
- package/dist/actions/functions/dev.js +2 -2
- package/dist/baseCommands.d.ts +10 -23
- package/dist/baseCommands.js +26 -75
- package/dist/commands/blueprints/add.d.ts +3 -2
- package/dist/commands/blueprints/add.js +3 -2
- package/dist/commands/blueprints/config.d.ts +3 -2
- package/dist/commands/blueprints/config.js +3 -2
- package/dist/commands/blueprints/deploy.d.ts +3 -2
- package/dist/commands/blueprints/deploy.js +4 -3
- package/dist/commands/blueprints/destroy.d.ts +3 -2
- package/dist/commands/blueprints/destroy.js +3 -2
- package/dist/commands/blueprints/doctor.d.ts +0 -1
- package/dist/commands/blueprints/doctor.js +2 -3
- package/dist/commands/blueprints/init.d.ts +0 -1
- package/dist/commands/blueprints/init.js +1 -2
- package/dist/commands/blueprints/logs.d.ts +3 -2
- package/dist/commands/blueprints/logs.js +4 -3
- package/dist/commands/blueprints/plan.d.ts +3 -2
- package/dist/commands/blueprints/plan.js +5 -3
- package/dist/commands/blueprints/promote.d.ts +3 -2
- package/dist/commands/blueprints/promote.js +3 -2
- package/dist/commands/blueprints/stacks.d.ts +3 -2
- package/dist/commands/blueprints/stacks.js +3 -2
- package/dist/commands/functions/add.d.ts +3 -2
- package/dist/commands/functions/add.js +3 -2
- package/dist/commands/functions/build.d.ts +3 -2
- package/dist/commands/functions/build.js +3 -2
- package/dist/commands/functions/dev.d.ts +3 -2
- package/dist/commands/functions/dev.js +3 -2
- package/dist/commands/functions/env/add.d.ts +3 -2
- package/dist/commands/functions/env/add.js +3 -2
- package/dist/commands/functions/env/list.d.ts +3 -2
- package/dist/commands/functions/env/list.js +3 -2
- package/dist/commands/functions/env/remove.d.ts +3 -2
- package/dist/commands/functions/env/remove.js +3 -2
- package/dist/commands/functions/logs.d.ts +3 -2
- package/dist/commands/functions/logs.js +4 -3
- package/dist/commands/functions/test.d.ts +3 -2
- package/dist/commands/functions/test.js +3 -2
- package/dist/cores/blueprints/config.js +9 -4
- package/dist/cores/blueprints/destroy.js +78 -56
- package/dist/cores/blueprints/doctor.js +19 -5
- package/dist/cores/blueprints/init.js +2 -2
- package/dist/cores/functions/dev.js +1 -1
- package/dist/server/app.d.ts +1 -2
- package/dist/server/app.js +16 -8
- package/dist/server/handlers/invoke.d.ts +1 -2
- package/dist/server/handlers/invoke.js +4 -4
- package/oclif.manifest.json +3 -15
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class DeployCommand extends
|
|
1
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class DeployCommand extends ResolvedCommand<typeof DeployCommand> {
|
|
3
|
+
static needs: readonly ["deployedStack", "blueprint"];
|
|
3
4
|
static summary: string;
|
|
4
5
|
static description: string;
|
|
5
6
|
static examples: string[];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { ResolvedCommand, stackFlagConfig } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintDeployCore } from '../../cores/blueprints/deploy.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
5
|
import { INSTALLER_OPTIONS } from '../../utils/types.js';
|
|
6
|
-
export default class DeployCommand extends
|
|
6
|
+
export default class DeployCommand extends ResolvedCommand {
|
|
7
|
+
static needs = ['deployedStack', 'blueprint'];
|
|
7
8
|
static summary = 'Deploy the local Blueprint to the remote Stack';
|
|
8
9
|
static 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.
|
|
9
10
|
|
|
@@ -21,7 +22,7 @@ Set SANITY_ASSET_TIMEOUT (seconds) to override the 60-second timeout for process
|
|
|
21
22
|
'<%= config.bin %> <%= command.id %> --fn-installer npm',
|
|
22
23
|
];
|
|
23
24
|
static flags = {
|
|
24
|
-
stack:
|
|
25
|
+
stack: Flags.string({ ...stackFlagConfig }),
|
|
25
26
|
message: Flags.string({
|
|
26
27
|
description: 'Message describing the deployment (e.g. reason for change)',
|
|
27
28
|
char: 'm',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class DestroyCommand extends
|
|
1
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class DestroyCommand extends ResolvedCommand<typeof DestroyCommand> {
|
|
3
|
+
static needs: readonly ["token", "blueprint"];
|
|
3
4
|
static summary: string;
|
|
4
5
|
static description: string;
|
|
5
6
|
static examples: string[];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { organizationIdFlagConfig, projectIdFlagConfig, ResolvedCommand } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintDestroyCore } from '../../cores/blueprints/destroy.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
|
-
export default class DestroyCommand extends
|
|
5
|
+
export default class DestroyCommand extends ResolvedCommand {
|
|
6
|
+
static needs = ['token', 'blueprint'];
|
|
6
7
|
static summary = 'Destroy a remote Stack deployment and its resources';
|
|
7
8
|
static description = `Permanently removes the remote Stack and all its provisioned resources. Your local Blueprint files remain untouched, allowing you to redeploy later with 'blueprints init' + 'blueprints deploy'.
|
|
8
9
|
|
|
@@ -6,7 +6,6 @@ export default class DoctorCommand extends RuntimeCommand<typeof DoctorCommand>
|
|
|
6
6
|
static flags: {
|
|
7
7
|
path: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
fix: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
-
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
9
|
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
10
|
};
|
|
12
11
|
run(): Promise<Record<string, unknown> | undefined>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { pathFlagConfig, RuntimeCommand } from '../../baseCommands.js';
|
|
3
3
|
import config from '../../config.js';
|
|
4
4
|
import { blueprintDoctorCore } from '../../cores/blueprints/doctor.js';
|
|
5
5
|
import { Logger } from '../../utils/logger.js';
|
|
@@ -14,12 +14,11 @@ Run this command when encountering errors with other Blueprint commands. Use --f
|
|
|
14
14
|
'<%= config.bin %> <%= command.id %> --fix',
|
|
15
15
|
];
|
|
16
16
|
static flags = {
|
|
17
|
-
path:
|
|
17
|
+
path: Flags.string({ ...pathFlagConfig }),
|
|
18
18
|
fix: Flags.boolean({
|
|
19
19
|
description: 'Interactively fix configuration issues',
|
|
20
20
|
default: false,
|
|
21
21
|
}),
|
|
22
|
-
json: unhide(baseFlags.json),
|
|
23
22
|
verbose: Flags.boolean({
|
|
24
23
|
description: 'Verbose output; defaults to true',
|
|
25
24
|
default: true,
|
|
@@ -14,7 +14,6 @@ export default class InitCommand extends RuntimeCommand<typeof InitCommand> {
|
|
|
14
14
|
'organization-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
15
|
'stack-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
16
|
'stack-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
17
|
};
|
|
19
18
|
run(): Promise<void>;
|
|
20
19
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { organizationIdFlagConfig, projectIdFlagConfig, RuntimeCommand } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintInitCore } from '../../cores/blueprints/init.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
5
|
import { validTokenOrErrorMessage } from '../../utils/validated-token.js';
|
|
@@ -50,7 +50,6 @@ After initialization, use 'blueprints plan' to preview changes, then 'blueprints
|
|
|
50
50
|
aliases: ['name'],
|
|
51
51
|
exclusive: ['stack-id'],
|
|
52
52
|
}),
|
|
53
|
-
verbose: unhide(baseFlags.verbose),
|
|
54
53
|
};
|
|
55
54
|
async run() {
|
|
56
55
|
const log = Logger(this.log.bind(this), this.flags);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class LogsCommand extends
|
|
1
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class LogsCommand extends ResolvedCommand<typeof LogsCommand> {
|
|
3
|
+
static needs: readonly ["deployedStack"];
|
|
3
4
|
static summary: string;
|
|
4
5
|
static description: string;
|
|
5
6
|
static examples: string[];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { ResolvedCommand, stackFlagConfig } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintLogsCore } from '../../cores/blueprints/logs.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
|
-
export default class LogsCommand extends
|
|
5
|
+
export default class LogsCommand extends ResolvedCommand {
|
|
6
|
+
static needs = ['deployedStack'];
|
|
6
7
|
static summary = "Display logs for the current Blueprint's Stack deployment";
|
|
7
8
|
static description = `Retrieves Stack deployment logs, useful for debugging and monitoring deployment activity.
|
|
8
9
|
|
|
@@ -14,7 +15,7 @@ If you're not seeing expected logs, verify your Stack is deployed with 'blueprin
|
|
|
14
15
|
'<%= config.bin %> <%= command.id %> --watch',
|
|
15
16
|
];
|
|
16
17
|
static flags = {
|
|
17
|
-
stack:
|
|
18
|
+
stack: Flags.string({ ...stackFlagConfig }),
|
|
18
19
|
watch: Flags.boolean({
|
|
19
20
|
char: 'w',
|
|
20
21
|
description: 'Watch for new Stack logs (streaming mode)',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class PlanCommand extends
|
|
1
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class PlanCommand extends ResolvedCommand<typeof PlanCommand> {
|
|
3
|
+
static needs: readonly ["token", "blueprint"];
|
|
3
4
|
static summary: string;
|
|
4
5
|
static description: string;
|
|
5
6
|
static examples: string[];
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { ResolvedCommand, stackFlagConfig } from '../../baseCommands.js';
|
|
2
3
|
import { blueprintPlanCore } from '../../cores/blueprints/plan.js';
|
|
3
4
|
import { Logger } from '../../utils/logger.js';
|
|
4
|
-
export default class PlanCommand extends
|
|
5
|
+
export default class PlanCommand extends ResolvedCommand {
|
|
6
|
+
static needs = ['token', 'blueprint'];
|
|
5
7
|
static summary = 'Preview changes that will be applied to the remote Stack';
|
|
6
8
|
static description = `Use this command to preview what changes will be applied to your remote Stack before deploying. This is a safe, read-only operation—no resources are created, modified, or deleted.
|
|
7
9
|
|
|
8
10
|
Run 'blueprints plan' after making local changes to your Blueprint manifest to verify the expected diff. When ready, run 'blueprints deploy' to apply changes.`;
|
|
9
11
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
10
12
|
static flags = {
|
|
11
|
-
stack:
|
|
13
|
+
stack: Flags.string({ ...stackFlagConfig }),
|
|
12
14
|
};
|
|
13
15
|
async run() {
|
|
14
16
|
const result = await blueprintPlanCore({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class PromoteCommand extends
|
|
1
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class PromoteCommand extends ResolvedCommand<typeof PromoteCommand> {
|
|
3
|
+
static needs: readonly ["deployedStack", "blueprint"];
|
|
3
4
|
static summary: string;
|
|
4
5
|
static description: string;
|
|
5
6
|
static hidden: boolean;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintPromoteCore } from '../../cores/blueprints/promote.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
|
-
export default class PromoteCommand extends
|
|
5
|
+
export default class PromoteCommand extends ResolvedCommand {
|
|
6
|
+
static needs = ['deployedStack', 'blueprint'];
|
|
6
7
|
static summary = 'Promote a Stack from project scope to organization scope';
|
|
7
8
|
static description = `Promotes a deployed Stack to organization scope, enabling management of org-level resources. Promotion cannot be reversed.
|
|
8
9
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class StacksCommand extends
|
|
1
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class StacksCommand extends ResolvedCommand<typeof StacksCommand> {
|
|
3
|
+
static needs: readonly ["token", "blueprint"];
|
|
3
4
|
static summary: string;
|
|
4
5
|
static description: string;
|
|
5
6
|
static examples: string[];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { organizationIdFlagConfig, projectIdFlagConfig, ResolvedCommand } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintStacksCore } from '../../cores/blueprints/stacks.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
|
-
export default class StacksCommand extends
|
|
5
|
+
export default class StacksCommand extends ResolvedCommand {
|
|
6
|
+
static needs = ['token', 'blueprint'];
|
|
6
7
|
static summary = 'List remote Stack deployments for your project or organization';
|
|
7
8
|
static description = `Shows all Stacks associated with a project or organization. By default, lists Stacks scoped to the local Blueprint.
|
|
8
9
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class AddCommand extends
|
|
1
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class AddCommand extends ResolvedCommand<typeof AddCommand> {
|
|
3
|
+
static needs: readonly ["blueprint"];
|
|
3
4
|
static summary: string;
|
|
4
5
|
static description: string;
|
|
5
6
|
static examples: string[];
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
3
3
|
import { FUNCTION_TYPES } from '../../constants.js';
|
|
4
4
|
import { functionAddCore } from '../../cores/functions/index.js';
|
|
5
5
|
import { Logger } from '../../utils/logger.js';
|
|
6
6
|
import { INSTALLER_OPTIONS } from '../../utils/types.js';
|
|
7
|
-
export default class AddCommand extends
|
|
7
|
+
export default class AddCommand extends ResolvedCommand {
|
|
8
|
+
static needs = ['blueprint'];
|
|
8
9
|
static summary = 'Add a Function to your Blueprint';
|
|
9
10
|
static description = `Scaffolds a new Function in the functions/ folder and templates a resource for your Blueprint manifest.
|
|
10
11
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class BuildCommand extends
|
|
1
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class BuildCommand extends ResolvedCommand<typeof BuildCommand> {
|
|
3
|
+
static needs: readonly ["blueprint"];
|
|
3
4
|
static summary: string;
|
|
4
5
|
static hidden: boolean;
|
|
5
6
|
static args: {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
3
3
|
import { functionBuildCore } from '../../cores/functions/build.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
5
|
import { INSTALLER_OPTIONS } from '../../utils/types.js';
|
|
6
|
-
export default class BuildCommand extends
|
|
6
|
+
export default class BuildCommand extends ResolvedCommand {
|
|
7
|
+
static needs = ['blueprint'];
|
|
7
8
|
static summary = 'Build Sanity Function(s) to zip archives';
|
|
8
9
|
static hidden = true;
|
|
9
10
|
static args = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class DevCommand extends
|
|
1
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class DevCommand extends ResolvedCommand<typeof DevCommand> {
|
|
3
|
+
static needs: readonly ["blueprint"];
|
|
3
4
|
static summary: string;
|
|
4
5
|
static description: string;
|
|
5
6
|
static examples: string[];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
3
3
|
import { functionDevCore } from '../../cores/functions/dev.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
|
-
export default class DevCommand extends
|
|
5
|
+
export default class DevCommand extends ResolvedCommand {
|
|
6
|
+
static needs = ['blueprint'];
|
|
6
7
|
static summary = 'Start the Sanity Function emulator';
|
|
7
8
|
static description = `Runs a local, web-based development server to test your functions before deploying.
|
|
8
9
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class EnvAddCommand extends
|
|
1
|
+
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
2
|
+
export default class EnvAddCommand extends ResolvedCommand<typeof EnvAddCommand> {
|
|
3
|
+
static needs: readonly ["deployedStack", "blueprint"];
|
|
3
4
|
static summary: string;
|
|
4
5
|
static description: string;
|
|
5
6
|
static args: {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Args } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
3
3
|
import { functionEnvAddCore } from '../../../cores/functions/env/add.js';
|
|
4
4
|
import { Logger } from '../../../utils/logger.js';
|
|
5
|
-
export default class EnvAddCommand extends
|
|
5
|
+
export default class EnvAddCommand extends ResolvedCommand {
|
|
6
|
+
static needs = ['deployedStack', 'blueprint'];
|
|
6
7
|
static summary = 'Add or set an environment variable for a deployed function';
|
|
7
8
|
static description = `Sets an environment variable in a deployed Sanity Function. If the variable already exists, its value is updated.
|
|
8
9
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class EnvListCommand extends
|
|
1
|
+
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
2
|
+
export default class EnvListCommand extends ResolvedCommand<typeof EnvListCommand> {
|
|
3
|
+
static needs: readonly ["deployedStack", "blueprint"];
|
|
3
4
|
static summary: string;
|
|
4
5
|
static description: string;
|
|
5
6
|
static args: {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Args } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
3
3
|
import { functionEnvListCore } from '../../../cores/functions/env/list.js';
|
|
4
4
|
import { Logger } from '../../../utils/logger.js';
|
|
5
|
-
export default class EnvListCommand extends
|
|
5
|
+
export default class EnvListCommand extends ResolvedCommand {
|
|
6
|
+
static needs = ['deployedStack', 'blueprint'];
|
|
6
7
|
static summary = 'List environment variables for a deployed function';
|
|
7
8
|
static description = `Displays all environment variables (keys only) configured in a deployed Sanity Function.
|
|
8
9
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class EnvRemoveCommand extends
|
|
1
|
+
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
2
|
+
export default class EnvRemoveCommand extends ResolvedCommand<typeof EnvRemoveCommand> {
|
|
3
|
+
static needs: readonly ["deployedStack", "blueprint"];
|
|
3
4
|
static summary: string;
|
|
4
5
|
static description: string;
|
|
5
6
|
static args: {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Args } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
3
3
|
import { functionEnvRemoveCore } from '../../../cores/functions/env/remove.js';
|
|
4
4
|
import { Logger } from '../../../utils/logger.js';
|
|
5
|
-
export default class EnvRemoveCommand extends
|
|
5
|
+
export default class EnvRemoveCommand extends ResolvedCommand {
|
|
6
|
+
static needs = ['deployedStack', 'blueprint'];
|
|
6
7
|
static summary = 'Remove an environment variable from a deployed function';
|
|
7
8
|
static description = `Deletes an environment variable from a deployed Sanity Function. The change takes effect on the next function invocation.
|
|
8
9
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class LogsCommand extends
|
|
1
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class LogsCommand extends ResolvedCommand<typeof LogsCommand> {
|
|
3
|
+
static needs: readonly ["deployedStack", "blueprint"];
|
|
3
4
|
static summary: string;
|
|
4
5
|
static description: string;
|
|
5
6
|
static args: {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { ResolvedCommand, stackFlagConfig } from '../../baseCommands.js';
|
|
3
3
|
import { functionLogsCore } from '../../cores/functions/logs.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
|
-
export default class LogsCommand extends
|
|
5
|
+
export default class LogsCommand extends ResolvedCommand {
|
|
6
|
+
static needs = ['deployedStack', 'blueprint'];
|
|
6
7
|
static summary = 'Retrieve or delete logs for a Sanity Function';
|
|
7
8
|
static description = `Fetches execution logs from a deployed function, useful for debugging production issues or monitoring activity.
|
|
8
9
|
|
|
@@ -17,7 +18,7 @@ Use --watch (-w) to stream logs in real-time. Use --delete to clear all logs for
|
|
|
17
18
|
'<%= config.bin %> <%= command.id %> <name> --delete',
|
|
18
19
|
];
|
|
19
20
|
static flags = {
|
|
20
|
-
stack:
|
|
21
|
+
stack: Flags.string({ ...stackFlagConfig }),
|
|
21
22
|
limit: Flags.integer({
|
|
22
23
|
char: 'l',
|
|
23
24
|
description: 'Total number of log entries to retrieve',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class TestCommand extends
|
|
1
|
+
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class TestCommand extends ResolvedCommand<typeof TestCommand> {
|
|
3
|
+
static needs: readonly ["blueprint"];
|
|
3
4
|
static summary: string;
|
|
4
5
|
static description: string;
|
|
5
6
|
static args: {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { organizationIdFlagConfig, projectIdFlagConfig, ResolvedCommand } from '../../baseCommands.js';
|
|
3
3
|
import { functionTestCore } from '../../cores/functions/test.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
|
-
export default class TestCommand extends
|
|
5
|
+
export default class TestCommand extends ResolvedCommand {
|
|
6
|
+
static needs = ['blueprint'];
|
|
6
7
|
static summary = 'Invoke a local Sanity Function';
|
|
7
8
|
static description = `Executes a function locally with the provided payload, simulating how it would run when deployed. Use this to test your function logic before deploying.
|
|
8
9
|
|
|
@@ -9,10 +9,15 @@ export async function blueprintConfigCore(options) {
|
|
|
9
9
|
const providedConfigFlag = [flagProjectId, flagStack, flagOrganizationId].some(Boolean);
|
|
10
10
|
const { stackId: configStackId, scopeType: configScopeType, scopeId: configScopeId, blueprintConfig, fileInfo, } = blueprint;
|
|
11
11
|
const blueprintFilePath = fileInfo.blueprintFilePath;
|
|
12
|
+
const hasConfigFile = !!blueprintConfig;
|
|
12
13
|
if (!configStackId && !configScopeType && !configScopeId) {
|
|
13
|
-
|
|
14
|
+
if (hasConfigFile) {
|
|
15
|
+
log(warn('Incomplete configuration.'));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
log('No configuration file found.');
|
|
19
|
+
}
|
|
14
20
|
if (!editConfig) {
|
|
15
|
-
// blueprint.json exists but no config JSON
|
|
16
21
|
log(`Run \`npx ${bin} blueprints doctor\` for diagnostics.`);
|
|
17
22
|
return { success: true }; // not necessarily fatal
|
|
18
23
|
}
|
|
@@ -61,7 +66,7 @@ export async function blueprintConfigCore(options) {
|
|
|
61
66
|
// creates a new config file with the given properties
|
|
62
67
|
try {
|
|
63
68
|
const newConfig = writeConfigFile(blueprintFilePath, configUpdate);
|
|
64
|
-
printConfig({ configLabel: 'Updated', log, config: newConfig });
|
|
69
|
+
printConfig({ configLabel: hasConfigFile ? 'Updated' : 'New', log, config: newConfig });
|
|
65
70
|
return { success: true, json: { config: newConfig } };
|
|
66
71
|
}
|
|
67
72
|
catch {
|
|
@@ -98,7 +103,7 @@ export async function blueprintConfigCore(options) {
|
|
|
98
103
|
projectId: updatedProjectId,
|
|
99
104
|
stackId: updatedStackId,
|
|
100
105
|
});
|
|
101
|
-
printConfig({ configLabel: 'Updated', log, config: newConfig });
|
|
106
|
+
printConfig({ configLabel: hasConfigFile ? 'Updated' : 'New', log, config: newConfig });
|
|
102
107
|
return { success: true, json: { config: newConfig } };
|
|
103
108
|
}
|
|
104
109
|
catch {
|
|
@@ -8,7 +8,7 @@ import { styleText } from '../../utils/style-text.js';
|
|
|
8
8
|
export async function blueprintDestroyCore(options) {
|
|
9
9
|
const { bin = 'sanity', log, token, blueprint, flags } = options;
|
|
10
10
|
const { force = false, 'project-id': flagProjectId, 'organization-id': flagOrganizationId, stack: flagStack, 'no-wait': noWait = false, verbose: _verbose = false, } = flags;
|
|
11
|
-
// 3-flag combo:
|
|
11
|
+
// 3-flag combo: destroy without needing a local blueprint config
|
|
12
12
|
if ((flagProjectId || flagOrganizationId) && flagStack && force) {
|
|
13
13
|
let scopeType;
|
|
14
14
|
let scopeId;
|
|
@@ -25,6 +25,7 @@ export async function blueprintDestroyCore(options) {
|
|
|
25
25
|
}
|
|
26
26
|
const auth = { token, scopeType, scopeId };
|
|
27
27
|
const resolvedId = await resolveStackIdByNameOrId(flagStack, auth, log);
|
|
28
|
+
const isoNow = new Date().toISOString();
|
|
28
29
|
const { ok, error, stack } = await destroyStack({
|
|
29
30
|
stackId: resolvedId,
|
|
30
31
|
auth,
|
|
@@ -32,8 +33,18 @@ export async function blueprintDestroyCore(options) {
|
|
|
32
33
|
});
|
|
33
34
|
if (!ok)
|
|
34
35
|
return { success: false, error: error || 'Failed to destroy Stack deployment' };
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
if (noWait) {
|
|
37
|
+
log(styleText(['bold', 'magenta'], 'Stack destruction started!'));
|
|
38
|
+
return { success: true, json: { stackId: stack.id, stackName: stack.name } };
|
|
39
|
+
}
|
|
40
|
+
return waitForDestruction({
|
|
41
|
+
stackId: stack.id,
|
|
42
|
+
stackName: stack.name,
|
|
43
|
+
auth,
|
|
44
|
+
log,
|
|
45
|
+
bin,
|
|
46
|
+
since: isoNow,
|
|
47
|
+
});
|
|
37
48
|
}
|
|
38
49
|
const { scopeType, scopeId, stackId } = blueprint;
|
|
39
50
|
if (!scopeType || !scopeId)
|
|
@@ -103,62 +114,73 @@ export async function blueprintDestroyCore(options) {
|
|
|
103
114
|
log(styleText(['bold', 'magenta'], 'Stack destruction started!'));
|
|
104
115
|
return { success: true, json: { stackId: stack.id, stackName: stack.name } };
|
|
105
116
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
after: isoNow,
|
|
115
|
-
auth,
|
|
116
|
-
log,
|
|
117
|
-
onActivity: () => {
|
|
118
|
-
lastLogAt = Date.now();
|
|
119
|
-
},
|
|
120
|
-
onLogEntry: (logEntry) => logHints.inspect(logEntry),
|
|
121
|
-
});
|
|
122
|
-
while (true) {
|
|
123
|
-
const { ok, stack: currentStack } = await getStack({ stackId: stack.id, auth, logger: log });
|
|
124
|
-
const operation = currentStack?.recentOperation;
|
|
125
|
-
if (!ok || !operation || operation?.status === 'COMPLETED') {
|
|
126
|
-
// Operation is also marked destroyed when stack is deleted;
|
|
127
|
-
// it's possible that the operation is "gone" or available and "COMPLETED"
|
|
128
|
-
if (logStreamCleanup)
|
|
129
|
-
logStreamCleanup();
|
|
130
|
-
log(styleText(['bold', 'magenta'], 'Stack destruction completed!'));
|
|
131
|
-
return { success: true, json: { stackId: stack.id, stackName: stack.name } };
|
|
132
|
-
}
|
|
133
|
-
if (operation.status === 'FAILED') {
|
|
134
|
-
if (logStreamCleanup)
|
|
135
|
-
logStreamCleanup();
|
|
136
|
-
return {
|
|
137
|
-
success: false,
|
|
138
|
-
error: 'Stack destruction failed',
|
|
139
|
-
suggestions: [
|
|
140
|
-
...logHints.getSuggestions(),
|
|
141
|
-
`Run \`npx ${bin} blueprints logs\` to review destruction logs.`,
|
|
142
|
-
`Run \`npx ${bin} blueprints info\` to view current Stack status.`,
|
|
143
|
-
],
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
if (!idleMessageShown && Date.now() - lastLogAt > 60_000) {
|
|
147
|
-
log(`No new activity for 60 seconds. The destruction is still running on Sanity servers.`);
|
|
148
|
-
log(`You can safely exit and check status later with \`npx ${bin} blueprints info\`.`);
|
|
149
|
-
idleMessageShown = true;
|
|
150
|
-
}
|
|
151
|
-
await sleep(1500);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
if (logStreamCleanup)
|
|
156
|
-
logStreamCleanup();
|
|
157
|
-
throw error;
|
|
158
|
-
}
|
|
117
|
+
return waitForDestruction({
|
|
118
|
+
stackId: stack.id,
|
|
119
|
+
stackName: stack.name,
|
|
120
|
+
auth,
|
|
121
|
+
log,
|
|
122
|
+
bin,
|
|
123
|
+
since: isoNow,
|
|
124
|
+
});
|
|
159
125
|
}
|
|
160
126
|
catch (error) {
|
|
161
127
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
162
128
|
return { success: false, error: errorMessage };
|
|
163
129
|
}
|
|
164
130
|
}
|
|
131
|
+
async function waitForDestruction(options) {
|
|
132
|
+
const { stackId, stackName, auth, log, bin, since } = options;
|
|
133
|
+
log(styleText('dim', 'Stack destruction progress:'));
|
|
134
|
+
const logHints = createLogHintCollector(bin);
|
|
135
|
+
let logStreamCleanup = null;
|
|
136
|
+
try {
|
|
137
|
+
let lastLogAt = Date.now();
|
|
138
|
+
let idleMessageShown = false;
|
|
139
|
+
logStreamCleanup = await setupLogStreaming({
|
|
140
|
+
stackId,
|
|
141
|
+
after: since,
|
|
142
|
+
auth,
|
|
143
|
+
log,
|
|
144
|
+
onActivity: () => {
|
|
145
|
+
lastLogAt = Date.now();
|
|
146
|
+
},
|
|
147
|
+
onLogEntry: (logEntry) => logHints.inspect(logEntry),
|
|
148
|
+
});
|
|
149
|
+
while (true) {
|
|
150
|
+
const { ok, stack: currentStack } = await getStack({ stackId, auth, logger: log });
|
|
151
|
+
const operation = currentStack?.recentOperation;
|
|
152
|
+
if (!ok || !operation || operation?.status === 'COMPLETED') {
|
|
153
|
+
// Operation is also marked destroyed when stack is deleted;
|
|
154
|
+
// it's possible that the operation is "gone" or available and "COMPLETED"
|
|
155
|
+
if (logStreamCleanup)
|
|
156
|
+
logStreamCleanup();
|
|
157
|
+
log(styleText(['bold', 'magenta'], 'Stack destruction completed!'));
|
|
158
|
+
return { success: true, json: { stackId, stackName } };
|
|
159
|
+
}
|
|
160
|
+
if (operation.status === 'FAILED') {
|
|
161
|
+
if (logStreamCleanup)
|
|
162
|
+
logStreamCleanup();
|
|
163
|
+
return {
|
|
164
|
+
success: false,
|
|
165
|
+
error: 'Stack destruction failed',
|
|
166
|
+
suggestions: [
|
|
167
|
+
...logHints.getSuggestions(),
|
|
168
|
+
`Run \`npx ${bin} blueprints logs\` to review destruction logs.`,
|
|
169
|
+
`Run \`npx ${bin} blueprints info\` to view current Stack status.`,
|
|
170
|
+
],
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
if (!idleMessageShown && Date.now() - lastLogAt > 60_000) {
|
|
174
|
+
log(`No new activity for 60 seconds. The destruction is still running on Sanity servers.`);
|
|
175
|
+
log(`You can safely exit and check status later with \`npx ${bin} blueprints info\`.`);
|
|
176
|
+
idleMessageShown = true;
|
|
177
|
+
}
|
|
178
|
+
await sleep(1500);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
if (logStreamCleanup)
|
|
183
|
+
logStreamCleanup();
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
}
|