@sanity/runtime-cli 12.2.0 → 12.4.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 +32 -31
- package/dist/actions/blueprints/assets.d.ts +3 -4
- package/dist/actions/blueprints/assets.js +124 -2
- package/dist/baseCommands.d.ts +43 -7
- package/dist/baseCommands.js +82 -10
- package/dist/commands/blueprints/add.d.ts +2 -2
- package/dist/commands/blueprints/add.js +2 -2
- package/dist/commands/blueprints/config.d.ts +2 -2
- package/dist/commands/blueprints/config.js +2 -2
- package/dist/commands/blueprints/deploy.d.ts +2 -2
- package/dist/commands/blueprints/deploy.js +2 -2
- package/dist/commands/blueprints/destroy.d.ts +2 -2
- package/dist/commands/blueprints/destroy.js +2 -2
- package/dist/commands/blueprints/doctor.d.ts +5 -4
- package/dist/commands/blueprints/doctor.js +10 -12
- package/dist/commands/blueprints/info.d.ts +2 -2
- package/dist/commands/blueprints/info.js +2 -2
- package/dist/commands/blueprints/init.d.ts +2 -2
- package/dist/commands/blueprints/init.js +6 -9
- package/dist/commands/blueprints/logs.d.ts +2 -2
- package/dist/commands/blueprints/logs.js +2 -2
- package/dist/commands/blueprints/plan.d.ts +2 -2
- package/dist/commands/blueprints/plan.js +2 -2
- package/dist/commands/blueprints/stacks.d.ts +2 -2
- package/dist/commands/blueprints/stacks.js +2 -2
- package/dist/commands/functions/add.d.ts +2 -2
- package/dist/commands/functions/add.js +2 -2
- package/dist/commands/functions/dev.d.ts +2 -2
- package/dist/commands/functions/dev.js +2 -2
- package/dist/commands/functions/env/add.d.ts +2 -2
- package/dist/commands/functions/env/add.js +2 -2
- package/dist/commands/functions/env/list.d.ts +2 -2
- package/dist/commands/functions/env/list.js +2 -2
- package/dist/commands/functions/env/remove.d.ts +2 -2
- package/dist/commands/functions/env/remove.js +2 -2
- package/dist/commands/functions/logs.d.ts +3 -3
- package/dist/commands/functions/logs.js +7 -4
- package/dist/commands/functions/test.d.ts +3 -3
- package/dist/commands/functions/test.js +7 -4
- package/dist/cores/blueprints/config.d.ts +2 -5
- package/dist/cores/blueprints/deploy.js +29 -13
- package/dist/cores/blueprints/destroy.d.ts +2 -5
- package/dist/cores/blueprints/doctor.js +12 -2
- package/dist/cores/blueprints/info.js +2 -2
- package/dist/cores/blueprints/stacks.d.ts +2 -5
- package/dist/cores/functions/logs.d.ts +3 -1
- package/dist/cores/functions/logs.js +11 -2
- package/dist/cores/functions/test.d.ts +3 -1
- package/dist/cores/functions/test.js +11 -2
- package/dist/server/static/components/app.css +0 -116
- package/dist/server/static/components/clear-button.js +1 -1
- package/dist/server/static/components/console-panel.js +27 -6
- package/dist/server/static/components/fetch-button.js +1 -1
- package/dist/server/static/components/filter-api-version.js +39 -3
- package/dist/server/static/components/filter-document-id.js +39 -3
- package/dist/server/static/components/filter-with-token.js +27 -4
- package/dist/server/static/components/filters.js +127 -62
- package/dist/server/static/components/function-list.js +33 -13
- package/dist/server/static/components/network-spinner.js +6 -4
- package/dist/server/static/components/payload-panel.js +46 -24
- package/dist/server/static/components/response-panel.js +33 -6
- package/dist/server/static/components/rule-panel.js +13 -4
- package/dist/server/static/components/run-panel.js +14 -7
- package/dist/server/static/components/select-dropdown.js +34 -5
- package/dist/server/static/components/shared-styles.js +31 -0
- package/dist/server/static/components/toggle-switch.js +11 -2
- package/dist/utils/display/blueprints-formatting.d.ts +2 -2
- package/dist/utils/display/blueprints-formatting.js +31 -26
- package/dist/utils/find-function.d.ts +4 -0
- package/dist/utils/find-function.js +6 -0
- package/dist/utils/types.d.ts +21 -3
- package/oclif.manifest.json +281 -38
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { DeployedStackCommand } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintDeployCore } from '../../cores/blueprints/deploy.js';
|
|
4
|
-
export default class DeployCommand extends
|
|
4
|
+
export default class DeployCommand extends DeployedStackCommand {
|
|
5
5
|
static description = 'Deploy a Blueprint';
|
|
6
6
|
static examples = [
|
|
7
7
|
'<%= config.bin %> <%= command.id %>',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class DestroyCommand extends
|
|
1
|
+
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class DestroyCommand extends LocalBlueprintCommand<typeof DestroyCommand> {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintDestroyCore } from '../../cores/blueprints/destroy.js';
|
|
4
|
-
export default class DestroyCommand extends
|
|
4
|
+
export default class DestroyCommand extends LocalBlueprintCommand {
|
|
5
5
|
static description = 'Destroy a Blueprint Stack deployment and its resources (will not delete local files)';
|
|
6
6
|
static examples = [
|
|
7
7
|
'<%= config.bin %> <%= command.id %>',
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class DoctorCommand extends
|
|
1
|
+
import { RuntimeCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class DoctorCommand extends RuntimeCommand<typeof DoctorCommand> {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: never[];
|
|
5
5
|
static flags: {
|
|
6
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
6
|
path: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
7
|
fix: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
10
|
};
|
|
10
|
-
run(): Promise<
|
|
11
|
+
run(): Promise<Record<string, unknown> | undefined>;
|
|
11
12
|
}
|
|
@@ -1,32 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { baseFlags, RuntimeCommand, unhide } from '../../baseCommands.js';
|
|
2
3
|
import config from '../../config.js';
|
|
3
4
|
import { blueprintDoctorCore } from '../../cores/blueprints/doctor.js';
|
|
4
|
-
export default class DoctorCommand extends
|
|
5
|
+
export default class DoctorCommand extends RuntimeCommand {
|
|
5
6
|
static description = 'Diagnose potential issues with Blueprint configuration';
|
|
6
7
|
static examples = [];
|
|
7
8
|
static flags = {
|
|
8
|
-
|
|
9
|
-
description: 'Provide detailed information about issues',
|
|
10
|
-
default: false,
|
|
11
|
-
}),
|
|
12
|
-
path: Flags.string({
|
|
13
|
-
description: 'Path to the Blueprint configuration file',
|
|
14
|
-
}),
|
|
9
|
+
path: unhide(baseFlags.path),
|
|
15
10
|
fix: Flags.boolean({
|
|
16
11
|
description: 'Interactively fix configuration issues',
|
|
17
12
|
default: false,
|
|
18
13
|
}),
|
|
14
|
+
json: unhide(baseFlags.json),
|
|
15
|
+
verbose: unhide(baseFlags.verbose),
|
|
19
16
|
};
|
|
20
17
|
async run() {
|
|
21
|
-
const { flags } = await this.parse(DoctorCommand);
|
|
22
18
|
const { token } = config;
|
|
23
|
-
const
|
|
19
|
+
const result = await blueprintDoctorCore({
|
|
24
20
|
bin: this.config.bin,
|
|
25
21
|
log: (message) => this.log(message),
|
|
26
22
|
token,
|
|
27
|
-
flags,
|
|
23
|
+
flags: this.flags,
|
|
28
24
|
});
|
|
25
|
+
const { success, error } = result;
|
|
29
26
|
if (!success)
|
|
30
27
|
this.error(error);
|
|
28
|
+
return result.data;
|
|
31
29
|
}
|
|
32
30
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class InfoCommand extends
|
|
1
|
+
import { DeployedStackCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class InfoCommand extends DeployedStackCommand<typeof InfoCommand> {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { DeployedStackCommand } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintInfoCore } from '../../cores/blueprints/info.js';
|
|
4
|
-
export default class InfoCommand extends
|
|
4
|
+
export default class InfoCommand extends DeployedStackCommand {
|
|
5
5
|
static description = 'Show information about a Blueprint Stack deployment';
|
|
6
6
|
static examples = [
|
|
7
7
|
'<%= config.bin %> <%= command.id %>',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class InitCommand extends
|
|
1
|
+
import { RuntimeCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class InitCommand extends RuntimeCommand<typeof InitCommand> {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static args: {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Args,
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { baseFlags, RuntimeCommand, unhide } from '../../baseCommands.js';
|
|
2
3
|
import { blueprintInitCore } from '../../cores/blueprints/init.js';
|
|
3
4
|
import { validTokenOrErrorMessage } from '../../utils/validated-token.js';
|
|
4
|
-
export default class InitCommand extends
|
|
5
|
+
export default class InitCommand extends RuntimeCommand {
|
|
5
6
|
static description = 'Initialize a new Blueprint Stack deployment';
|
|
6
7
|
static examples = [
|
|
7
8
|
'<%= config.bin %> <%= command.id %>',
|
|
@@ -48,13 +49,9 @@ export default class InitCommand extends Command {
|
|
|
48
49
|
aliases: ['name'],
|
|
49
50
|
exclusive: ['stack-id'],
|
|
50
51
|
}),
|
|
51
|
-
verbose:
|
|
52
|
-
description: 'Verbose output',
|
|
53
|
-
default: false,
|
|
54
|
-
}),
|
|
52
|
+
verbose: unhide(baseFlags.verbose),
|
|
55
53
|
};
|
|
56
54
|
async run() {
|
|
57
|
-
const { args, flags } = await this.parse(InitCommand);
|
|
58
55
|
const result = await validTokenOrErrorMessage();
|
|
59
56
|
if (!result.ok)
|
|
60
57
|
this.error(result.error.message);
|
|
@@ -62,8 +59,8 @@ export default class InitCommand extends Command {
|
|
|
62
59
|
bin: this.config.bin,
|
|
63
60
|
log: (message) => this.log(message),
|
|
64
61
|
token: result.value,
|
|
65
|
-
args,
|
|
66
|
-
flags,
|
|
62
|
+
args: this.args,
|
|
63
|
+
flags: this.flags,
|
|
67
64
|
});
|
|
68
65
|
if (!success)
|
|
69
66
|
this.error(error);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class LogsCommand extends
|
|
1
|
+
import { DeployedStackCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class LogsCommand extends DeployedStackCommand<typeof LogsCommand> {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { DeployedStackCommand } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintLogsCore } from '../../cores/blueprints/logs.js';
|
|
4
|
-
export default class LogsCommand extends
|
|
4
|
+
export default class LogsCommand extends DeployedStackCommand {
|
|
5
5
|
static description = 'Display logs for a Blueprint Stack deployment';
|
|
6
6
|
static examples = [
|
|
7
7
|
'<%= config.bin %> <%= command.id %>',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class PlanCommand extends
|
|
1
|
+
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class PlanCommand extends LocalBlueprintCommand<typeof PlanCommand> {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
run(): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
2
2
|
import { blueprintPlanCore } from '../../cores/blueprints/plan.js';
|
|
3
|
-
export default class PlanCommand extends
|
|
3
|
+
export default class PlanCommand extends LocalBlueprintCommand {
|
|
4
4
|
static description = 'Enumerate resources to be deployed - will not modify any resources';
|
|
5
5
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
6
6
|
async run() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class StacksCommand extends
|
|
1
|
+
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class StacksCommand extends LocalBlueprintCommand<typeof StacksCommand> {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintStacksCore } from '../../cores/blueprints/stacks.js';
|
|
4
|
-
export default class StacksCommand extends
|
|
4
|
+
export default class StacksCommand extends LocalBlueprintCommand {
|
|
5
5
|
static description = 'List all Blueprint Stacks';
|
|
6
6
|
static examples = [
|
|
7
7
|
'<%= config.bin %> <%= command.id %>',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class AddCommand extends
|
|
1
|
+
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class AddCommand extends LocalBlueprintCommand<typeof AddCommand> {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
3
3
|
import { functionAddCore } from '../../cores/functions/index.js';
|
|
4
|
-
export default class AddCommand extends
|
|
4
|
+
export default class AddCommand extends LocalBlueprintCommand {
|
|
5
5
|
static description = 'Add a Function to your Blueprint';
|
|
6
6
|
static examples = [
|
|
7
7
|
'<%= config.bin %> <%= command.id %>',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class DevCommand extends
|
|
1
|
+
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class DevCommand extends LocalBlueprintCommand<typeof DevCommand> {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
3
3
|
import { functionDevCore } from '../../cores/functions/dev.js';
|
|
4
|
-
export default class DevCommand extends
|
|
4
|
+
export default class DevCommand extends LocalBlueprintCommand {
|
|
5
5
|
static description = 'Start the Sanity Function emulator';
|
|
6
6
|
static examples = ['<%= config.bin %> <%= command.id %> --host 127.0.0.1 --port 8974'];
|
|
7
7
|
static flags = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class EnvAddCommand extends
|
|
1
|
+
import { DeployedStackCommand } from '../../../baseCommands.js';
|
|
2
|
+
export default class EnvAddCommand extends DeployedStackCommand<typeof EnvAddCommand> {
|
|
3
3
|
static args: {
|
|
4
4
|
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
5
|
key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Args } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { DeployedStackCommand } from '../../../baseCommands.js';
|
|
3
3
|
import { functionEnvAddCore } from '../../../cores/functions/env/add.js';
|
|
4
|
-
export default class EnvAddCommand extends
|
|
4
|
+
export default class EnvAddCommand extends DeployedStackCommand {
|
|
5
5
|
static args = {
|
|
6
6
|
name: Args.string({ description: 'The name of the Sanity Function', required: true }),
|
|
7
7
|
key: Args.string({ description: 'The name of the environment variable', required: true }),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class EnvListCommand extends
|
|
1
|
+
import { DeployedStackCommand } from '../../../baseCommands.js';
|
|
2
|
+
export default class EnvListCommand extends DeployedStackCommand<typeof EnvListCommand> {
|
|
3
3
|
static args: {
|
|
4
4
|
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
5
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Args } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { DeployedStackCommand } from '../../../baseCommands.js';
|
|
3
3
|
import { functionEnvListCore } from '../../../cores/functions/env/list.js';
|
|
4
|
-
export default class EnvListCommand extends
|
|
4
|
+
export default class EnvListCommand extends DeployedStackCommand {
|
|
5
5
|
static args = {
|
|
6
6
|
name: Args.string({ description: 'The name of the Sanity Function', required: true }),
|
|
7
7
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class EnvRemoveCommand extends
|
|
1
|
+
import { DeployedStackCommand } from '../../../baseCommands.js';
|
|
2
|
+
export default class EnvRemoveCommand extends DeployedStackCommand<typeof EnvRemoveCommand> {
|
|
3
3
|
static args: {
|
|
4
4
|
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
5
|
key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Args } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { DeployedStackCommand } from '../../../baseCommands.js';
|
|
3
3
|
import { functionEnvRemoveCore } from '../../../cores/functions/env/remove.js';
|
|
4
|
-
export default class EnvRemoveCommand extends
|
|
4
|
+
export default class EnvRemoveCommand extends DeployedStackCommand {
|
|
5
5
|
static args = {
|
|
6
6
|
name: Args.string({ description: 'The name of the Sanity Function', required: true }),
|
|
7
7
|
key: Args.string({ description: 'The name of the environment variable', required: true }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class LogsCommand extends
|
|
1
|
+
import { DeployedStackCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class LogsCommand extends DeployedStackCommand<typeof LogsCommand> {
|
|
3
3
|
static args: {
|
|
4
|
-
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
4
|
+
name: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
5
5
|
};
|
|
6
6
|
static description: string;
|
|
7
7
|
static examples: string[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { DeployedStackCommand } from '../../baseCommands.js';
|
|
3
3
|
import { functionLogsCore } from '../../cores/functions/logs.js';
|
|
4
|
-
export default class LogsCommand extends
|
|
4
|
+
export default class LogsCommand extends DeployedStackCommand {
|
|
5
5
|
static args = {
|
|
6
|
-
name: Args.string({ description: 'The name of the Sanity Function', required:
|
|
6
|
+
name: Args.string({ description: 'The name of the Sanity Function', required: false }),
|
|
7
7
|
};
|
|
8
8
|
static description = 'Retrieve or delete logs for a Sanity Function';
|
|
9
9
|
static examples = [
|
|
@@ -48,10 +48,12 @@ export default class LogsCommand extends DeployedBlueprintCommand {
|
|
|
48
48
|
}),
|
|
49
49
|
};
|
|
50
50
|
async run() {
|
|
51
|
+
const { name } = this.args;
|
|
51
52
|
const { success, error } = await functionLogsCore({
|
|
52
53
|
bin: this.config.bin,
|
|
53
54
|
log: (msg) => this.log(msg),
|
|
54
|
-
|
|
55
|
+
error: (msg, options) => this.error(msg, options),
|
|
56
|
+
args: { name },
|
|
55
57
|
flags: this.flags,
|
|
56
58
|
auth: this.auth,
|
|
57
59
|
blueprint: this.blueprint,
|
|
@@ -60,6 +62,7 @@ export default class LogsCommand extends DeployedBlueprintCommand {
|
|
|
60
62
|
scopeId: this.scopeId,
|
|
61
63
|
token: this.sanityToken,
|
|
62
64
|
stackId: this.stackId,
|
|
65
|
+
helpText: LogsCommand.getHelpText(this.config.bin, 'functions logs'),
|
|
63
66
|
});
|
|
64
67
|
if (!success)
|
|
65
68
|
this.error(error);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class TestCommand extends
|
|
1
|
+
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class TestCommand extends LocalBlueprintCommand<typeof TestCommand> {
|
|
3
3
|
static args: {
|
|
4
|
-
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
4
|
+
name: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
5
5
|
};
|
|
6
6
|
static description: string;
|
|
7
7
|
static examples: string[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
3
3
|
import { functionTestCore } from '../../cores/functions/test.js';
|
|
4
|
-
export default class TestCommand extends
|
|
4
|
+
export default class TestCommand extends LocalBlueprintCommand {
|
|
5
5
|
static args = {
|
|
6
|
-
name: Args.string({ description: 'The name of the Sanity Function', required:
|
|
6
|
+
name: Args.string({ description: 'The name of the Sanity Function', required: false }),
|
|
7
7
|
};
|
|
8
8
|
static description = 'Invoke a local Sanity Function';
|
|
9
9
|
static examples = [
|
|
@@ -151,6 +151,7 @@ export default class TestCommand extends BlueprintCommand {
|
|
|
151
151
|
}),
|
|
152
152
|
};
|
|
153
153
|
async run() {
|
|
154
|
+
const { name } = this.args;
|
|
154
155
|
if (this.flags.event === 'update') {
|
|
155
156
|
const hasDataPair = this.flags['data-before'] && this.flags['data-after'];
|
|
156
157
|
const hasFilePair = this.flags['file-before'] && this.flags['file-after'];
|
|
@@ -165,9 +166,11 @@ export default class TestCommand extends BlueprintCommand {
|
|
|
165
166
|
const { success, error } = await functionTestCore({
|
|
166
167
|
bin: this.config.bin,
|
|
167
168
|
log: (msg) => this.log(msg),
|
|
168
|
-
|
|
169
|
+
error: (msg, options) => this.error(msg, options),
|
|
170
|
+
args: { ...this.args, name },
|
|
169
171
|
flags: this.flags,
|
|
170
172
|
blueprint: this.blueprint,
|
|
173
|
+
helpText: TestCommand.getHelpText(this.config.bin, 'functions test'),
|
|
171
174
|
});
|
|
172
175
|
if (!success)
|
|
173
176
|
this.error(error);
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export interface BlueprintConfigOptions extends CoreConfig {
|
|
4
|
-
token: string;
|
|
5
|
-
blueprint: ReadBlueprintResult;
|
|
1
|
+
import type { BlueprintConfig, CoreResult } from '../index.js';
|
|
2
|
+
export interface BlueprintConfigOptions extends BlueprintConfig {
|
|
6
3
|
flags: {
|
|
7
4
|
edit?: boolean;
|
|
8
5
|
'project-id'?: string;
|
|
@@ -14,23 +14,37 @@ export async function blueprintDeployCore(options) {
|
|
|
14
14
|
try {
|
|
15
15
|
const { resources } = blueprint.parsedBlueprint;
|
|
16
16
|
const validResources = resources?.filter((r) => r.type) || [];
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const allFunctionResources = experimentalFunctionCollections.flatMap((r) => r.functions);
|
|
21
|
-
functionResources = [...functionResources, ...allFunctionResources];
|
|
22
|
-
}
|
|
17
|
+
const functionResources = validResources.filter(isLocalFunctionResource);
|
|
18
|
+
const functionCollections = validResources.filter(isLocalFunctionCollection);
|
|
19
|
+
const allFunctionResources = [...functionResources, ...functionCollections];
|
|
23
20
|
// First stash all function assets
|
|
24
|
-
if (
|
|
21
|
+
if (allFunctionResources.length > 0) {
|
|
25
22
|
log('Processing function assets...');
|
|
26
|
-
for (const resource of
|
|
23
|
+
for (const resource of allFunctionResources) {
|
|
27
24
|
const fnSpinner = ora({ text: `Processing ${resource.name}...`, prefixText: ' ' }).start();
|
|
28
25
|
const result = await stashAsset({ resource, auth });
|
|
29
26
|
if (result.success && result.assetId) {
|
|
30
|
-
const src = resource.src;
|
|
31
27
|
resource.src = result.assetId;
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
if (isLocalFunctionCollection(resource)) {
|
|
29
|
+
try {
|
|
30
|
+
for (const func of resource.functions) {
|
|
31
|
+
func.src = func.name;
|
|
32
|
+
}
|
|
33
|
+
fnSpinner.succeed(`${resource.name} collection ${niceId(result.assetId)} (${resource.functions.length} functions)`);
|
|
34
|
+
log(` Functions: ${resource.functions.map((f) => f.name).join(', ')}`);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
fnSpinner.fail(`Failed to update function collection ${resource.name}`);
|
|
38
|
+
return {
|
|
39
|
+
success: false,
|
|
40
|
+
error: `Error updating function collection '${resource.name}': ${err instanceof Error ? err.message : String(err)}`,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
fnSpinner.succeed(`${resource.name} ${niceId(result.assetId)}`);
|
|
46
|
+
log(` Source: ${resource.src}`);
|
|
47
|
+
}
|
|
34
48
|
if (verbose) {
|
|
35
49
|
if (result.hash) {
|
|
36
50
|
if (result.hash.length > 24) {
|
|
@@ -45,8 +59,10 @@ export async function blueprintDeployCore(options) {
|
|
|
45
59
|
}
|
|
46
60
|
}
|
|
47
61
|
else {
|
|
48
|
-
|
|
49
|
-
|
|
62
|
+
const errorMsg = isLocalFunctionCollection(resource)
|
|
63
|
+
? `Failed uploading function collection ${resource.name} (${resource.functions?.length || 0} functions), deploy has stopped`
|
|
64
|
+
: `Failed uploading ${resource.name} asset, deploy has stopped`;
|
|
65
|
+
fnSpinner.fail(errorMsg);
|
|
50
66
|
return { success: false, error: result.error || 'Failed to process function resource' };
|
|
51
67
|
}
|
|
52
68
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export interface BlueprintDestroyOptions extends CoreConfig {
|
|
4
|
-
token: string;
|
|
5
|
-
blueprint: ReadBlueprintResult;
|
|
1
|
+
import type { BlueprintConfig, CoreResult } from '../index.js';
|
|
2
|
+
export interface BlueprintDestroyOptions extends BlueprintConfig {
|
|
6
3
|
flags: {
|
|
7
4
|
force?: boolean;
|
|
8
5
|
'project-id'?: string;
|
|
@@ -181,21 +181,31 @@ export async function blueprintDoctorCore(options) {
|
|
|
181
181
|
}
|
|
182
182
|
else if (fix) {
|
|
183
183
|
if (p) {
|
|
184
|
-
return {
|
|
184
|
+
return {
|
|
185
|
+
success: false,
|
|
186
|
+
error: `${errorMessage}. --fix cannot be used with --path`,
|
|
187
|
+
data: { diagnostics },
|
|
188
|
+
};
|
|
185
189
|
}
|
|
186
190
|
if (!tokenOrError) {
|
|
187
|
-
return {
|
|
191
|
+
return {
|
|
192
|
+
success: false,
|
|
193
|
+
error: `${errorMessage}. Unable to fix: Missing authentication token`,
|
|
194
|
+
data: { diagnostics },
|
|
195
|
+
};
|
|
188
196
|
}
|
|
189
197
|
if (tokenOrError?.ok === false) {
|
|
190
198
|
return {
|
|
191
199
|
success: false,
|
|
192
200
|
error: `${errorMessage}. Unable to fix: ${tokenOrError.error.message}`,
|
|
201
|
+
data: { diagnostics },
|
|
193
202
|
};
|
|
194
203
|
}
|
|
195
204
|
if (!blueprint) {
|
|
196
205
|
return {
|
|
197
206
|
success: false,
|
|
198
207
|
error: `${errorMessage}. Unable to fix: Blueprint is missing or invalid`,
|
|
208
|
+
data: { diagnostics },
|
|
199
209
|
};
|
|
200
210
|
}
|
|
201
211
|
return blueprintConfigCore({
|
|
@@ -3,7 +3,7 @@ import { formatDeployedResourceTree, formatStackInfo, } from '../../utils/displa
|
|
|
3
3
|
import { niceId } from '../../utils/display/presenters.js';
|
|
4
4
|
export async function blueprintInfoCore(options) {
|
|
5
5
|
const { log, auth, stackId, flags, deployedStack } = options;
|
|
6
|
-
const { id: flagStackId, verbose
|
|
6
|
+
const { id: flagStackId, verbose = false } = flags;
|
|
7
7
|
try {
|
|
8
8
|
const targetStackId = flagStackId || stackId;
|
|
9
9
|
let stack = deployedStack;
|
|
@@ -20,7 +20,7 @@ export async function blueprintInfoCore(options) {
|
|
|
20
20
|
}
|
|
21
21
|
log(formatStackInfo(stack, true));
|
|
22
22
|
if (stack.resources)
|
|
23
|
-
log(formatDeployedResourceTree(stack.resources));
|
|
23
|
+
log(formatDeployedResourceTree(stack.resources, verbose));
|
|
24
24
|
return { success: true };
|
|
25
25
|
}
|
|
26
26
|
catch (error) {
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export interface BlueprintStacksOptions extends CoreConfig {
|
|
4
|
-
token: string;
|
|
5
|
-
blueprint: ReadBlueprintResult;
|
|
1
|
+
import type { BlueprintConfig, CoreResult } from '../index.js';
|
|
2
|
+
export interface BlueprintStacksOptions extends BlueprintConfig {
|
|
6
3
|
flags: {
|
|
7
4
|
'project-id'?: string;
|
|
8
5
|
'organization-id'?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CoreResult, DeployedBlueprintConfig } from '../index.js';
|
|
2
2
|
export interface FunctionLogsOptions extends DeployedBlueprintConfig {
|
|
3
3
|
args: {
|
|
4
|
-
name: string;
|
|
4
|
+
name: string | undefined;
|
|
5
5
|
};
|
|
6
6
|
flags: {
|
|
7
7
|
limit: number;
|
|
@@ -11,5 +11,7 @@ export interface FunctionLogsOptions extends DeployedBlueprintConfig {
|
|
|
11
11
|
force?: boolean;
|
|
12
12
|
watch?: boolean;
|
|
13
13
|
};
|
|
14
|
+
error: (message: string, options: object) => void;
|
|
15
|
+
helpText: string;
|
|
14
16
|
}
|
|
15
17
|
export declare function functionLogsCore(options: FunctionLogsOptions): Promise<CoreResult>;
|
|
@@ -4,11 +4,20 @@ import ora from 'ora';
|
|
|
4
4
|
import { deleteLogs as deleteLogsAction, logs as getLogsAction, streamLogs as streamLogsAction, } from '../../actions/functions/logs.js';
|
|
5
5
|
import { formatTitle } from '../../utils/display/blueprints-formatting.js';
|
|
6
6
|
import { niceId } from '../../utils/display/presenters.js';
|
|
7
|
-
import { findFunctionInStack } from '../../utils/find-function.js';
|
|
7
|
+
import { findFunctionInStack, getFunctionNames } from '../../utils/find-function.js';
|
|
8
8
|
export async function functionLogsCore(options) {
|
|
9
|
-
const { args, flags, log, auth, deployedStack } = options;
|
|
9
|
+
const { args, flags, log, error, auth, deployedStack, blueprint, helpText } = options;
|
|
10
10
|
const { name } = args;
|
|
11
11
|
const { delete: shouldDelete, watch: shouldWatch, force, limit, json, utc } = flags;
|
|
12
|
+
if (!name) {
|
|
13
|
+
const functionNames = getFunctionNames(blueprint.parsedBlueprint.resources);
|
|
14
|
+
const validNames = functionNames.length > 0
|
|
15
|
+
? `Valid names are: ${functionNames.join(', ')}`
|
|
16
|
+
: 'No functions are defined in the blueprint.';
|
|
17
|
+
error(`Missing required argument: name\n${validNames}\n`, { exit: false });
|
|
18
|
+
log(helpText);
|
|
19
|
+
return { success: true };
|
|
20
|
+
}
|
|
12
21
|
const { externalId } = findFunctionInStack(deployedStack, name); // throws if not found
|
|
13
22
|
if (shouldDelete)
|
|
14
23
|
return deleteLogs({ name, externalId, auth, force, log });
|