@sanity/runtime-cli 14.7.2 → 14.8.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 +150 -99
- package/dist/actions/blueprints/assets.d.ts +4 -3
- package/dist/actions/blueprints/assets.js +69 -101
- package/dist/actions/blueprints/blueprint.d.ts +2 -2
- package/dist/actions/blueprints/blueprint.js +1 -8
- package/dist/actions/blueprints/config.d.ts +2 -2
- package/dist/actions/blueprints/logs-streaming.d.ts +2 -2
- package/dist/actions/blueprints/logs.d.ts +2 -4
- package/dist/actions/blueprints/resources.d.ts +3 -3
- package/dist/actions/blueprints/resources.js +30 -10
- package/dist/actions/blueprints/stacks.d.ts +15 -25
- package/dist/actions/functions/dev.d.ts +1 -1
- package/dist/actions/functions/env/list.d.ts +1 -1
- package/dist/actions/functions/env/remove.d.ts +1 -1
- package/dist/actions/functions/env/update.d.ts +1 -1
- package/dist/actions/functions/logs.d.ts +3 -3
- package/dist/actions/node.d.ts +1 -1
- package/dist/actions/sanity/examples.d.ts +2 -2
- package/dist/actions/sanity/projects.d.ts +7 -13
- package/dist/baseCommands.d.ts +8 -0
- package/dist/baseCommands.js +10 -4
- package/dist/commands/blueprints/config.d.ts +1 -1
- package/dist/commands/blueprints/config.js +5 -13
- package/dist/commands/blueprints/deploy.d.ts +1 -1
- package/dist/commands/blueprints/deploy.js +2 -1
- package/dist/commands/blueprints/destroy.d.ts +1 -1
- package/dist/commands/blueprints/destroy.js +5 -7
- package/dist/commands/blueprints/doctor.js +2 -2
- package/dist/commands/blueprints/info.d.ts +1 -1
- package/dist/commands/blueprints/info.js +2 -1
- package/dist/commands/blueprints/init.js +3 -11
- package/dist/commands/blueprints/plan.d.ts +1 -1
- package/dist/commands/blueprints/plan.js +2 -1
- package/dist/commands/blueprints/promote.d.ts +0 -1
- package/dist/commands/blueprints/promote.js +2 -6
- package/dist/commands/blueprints/stacks.d.ts +1 -1
- package/dist/commands/blueprints/stacks.js +5 -13
- package/dist/commands/functions/build.d.ts +1 -1
- package/dist/commands/functions/build.js +2 -1
- package/dist/commands/functions/env/add.d.ts +1 -1
- package/dist/commands/functions/env/add.js +2 -1
- package/dist/commands/functions/env/list.d.ts +1 -1
- package/dist/commands/functions/env/list.js +2 -1
- package/dist/commands/functions/env/remove.d.ts +1 -1
- package/dist/commands/functions/env/remove.js +2 -1
- package/dist/commands/functions/logs.d.ts +0 -1
- package/dist/commands/functions/logs.js +0 -5
- package/dist/commands/functions/test.d.ts +1 -1
- package/dist/commands/functions/test.js +5 -13
- package/dist/constants.d.ts +2 -1
- package/dist/cores/blueprints/config.js +11 -7
- package/dist/cores/blueprints/deploy.js +62 -74
- package/dist/cores/blueprints/destroy.js +3 -3
- package/dist/cores/blueprints/doctor.js +5 -1
- package/dist/cores/blueprints/info.js +1 -1
- package/dist/cores/blueprints/init.d.ts +4 -3
- package/dist/cores/blueprints/plan.js +7 -1
- package/dist/cores/blueprints/promote.d.ts +0 -1
- package/dist/cores/blueprints/promote.js +4 -4
- package/dist/cores/blueprints/stacks.js +6 -2
- package/dist/cores/functions/add.d.ts +1 -0
- package/dist/cores/functions/add.js +2 -2
- package/dist/cores/functions/build.js +2 -2
- package/dist/cores/functions/env/add.js +1 -1
- package/dist/cores/functions/env/list.js +1 -1
- package/dist/cores/functions/env/remove.js +1 -1
- package/dist/cores/functions/test.js +4 -4
- package/dist/cores/index.d.ts +9 -2
- package/dist/cores/index.js +3 -2
- package/dist/server/app.d.ts +1 -1
- package/dist/server/handlers/invoke.d.ts +1 -1
- package/dist/utils/display/prompt.d.ts +2 -2
- package/dist/utils/display/prompt.js +1 -1
- package/dist/utils/display/resources-formatting.d.ts +2 -2
- package/dist/utils/display/resources-formatting.js +1 -1
- package/dist/utils/functions/fetch-document.d.ts +2 -2
- package/dist/utils/functions/prepare-asset.d.ts +3 -8
- package/dist/utils/functions/prepare-asset.js +2 -2
- package/dist/utils/functions/should-auto-resolve-deps.js +1 -1
- package/dist/utils/functions/should-transpile.js +1 -1
- package/dist/utils/invoke-local.d.ts +1 -7
- package/dist/utils/invoke-local.js +5 -24
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/logger.js +2 -0
- package/dist/utils/other/github.d.ts +1 -1
- package/dist/utils/other/npmjs.d.ts +1 -1
- package/dist/utils/traced-fetch.d.ts +1 -1
- package/dist/utils/types.d.ts +21 -80
- package/dist/utils/types.js +6 -14
- package/dist/utils/validate/resource.d.ts +0 -3
- package/dist/utils/validate/resource.js +0 -270
- package/dist/utils/validated-token.d.ts +2 -2
- package/oclif.manifest.json +36 -90
- package/package.json +2 -2
package/dist/baseCommands.js
CHANGED
|
@@ -6,8 +6,7 @@ const hidden = true;
|
|
|
6
6
|
export const baseFlags = {
|
|
7
7
|
json: OclifFlags.boolean({
|
|
8
8
|
// override defaults from oclif's built-in --json flag
|
|
9
|
-
description: 'Format output as json
|
|
10
|
-
hidden,
|
|
9
|
+
description: 'Format output as json',
|
|
11
10
|
}),
|
|
12
11
|
path: OclifFlags.string({
|
|
13
12
|
description: 'Path to a Blueprint file or directory containing one',
|
|
@@ -23,9 +22,8 @@ export const baseFlags = {
|
|
|
23
22
|
}),
|
|
24
23
|
'validate-resources': OclifFlags.boolean({
|
|
25
24
|
description: 'Validate resources',
|
|
26
|
-
default:
|
|
25
|
+
default: true,
|
|
27
26
|
allowNo: true,
|
|
28
|
-
hidden, // TODO: reveal this once support is added in main CLI
|
|
29
27
|
}),
|
|
30
28
|
verbose: OclifFlags.boolean({
|
|
31
29
|
description: 'Verbose output',
|
|
@@ -37,6 +35,14 @@ export const stackFlag = OclifFlags.string({
|
|
|
37
35
|
description: 'Stack name or ID to use instead of the locally configured Stack',
|
|
38
36
|
hidden: true,
|
|
39
37
|
});
|
|
38
|
+
export const projectIdFlagConfig = {
|
|
39
|
+
description: 'Sanity project ID used to scope Blueprint and Stack',
|
|
40
|
+
aliases: ['project', 'projectId'],
|
|
41
|
+
};
|
|
42
|
+
export const organizationIdFlagConfig = {
|
|
43
|
+
description: 'Sanity organization ID used to scope Blueprint and Stack',
|
|
44
|
+
aliases: ['organization', 'organizationId', 'org'],
|
|
45
|
+
};
|
|
40
46
|
/**
|
|
41
47
|
* @description Unhides a flag by setting its hidden property to false
|
|
42
48
|
* Also makes oclif's types happy when destructuring the flag
|
|
@@ -9,5 +9,5 @@ export default class ConfigCommand extends LocalBlueprintCommand<typeof ConfigCo
|
|
|
9
9
|
'organization-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
};
|
|
12
|
-
run(): Promise<
|
|
12
|
+
run(): Promise<Record<string, unknown> | undefined>;
|
|
13
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
2
|
+
import { LocalBlueprintCommand, organizationIdFlagConfig, projectIdFlagConfig, } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintConfigCore } from '../../cores/blueprints/config.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
5
|
export default class ConfigCommand extends LocalBlueprintCommand {
|
|
@@ -21,17 +21,8 @@ If you need to switch your Blueprint to a different Stack, use --edit --stack.`;
|
|
|
21
21
|
description: 'Modify the configuration interactively, or directly when combined with ID flags.',
|
|
22
22
|
default: false,
|
|
23
23
|
}),
|
|
24
|
-
'project-id': Flags.string({
|
|
25
|
-
|
|
26
|
-
aliases: ['project', 'projectId'],
|
|
27
|
-
dependsOn: ['edit'],
|
|
28
|
-
}),
|
|
29
|
-
'organization-id': Flags.string({
|
|
30
|
-
description: 'Directly set the organization ID in the configuration. Requires --edit flag',
|
|
31
|
-
aliases: ['organization', 'organizationId', 'org'],
|
|
32
|
-
dependsOn: ['edit'],
|
|
33
|
-
hidden: true,
|
|
34
|
-
}),
|
|
24
|
+
'project-id': Flags.string({ ...projectIdFlagConfig, dependsOn: ['edit'] }),
|
|
25
|
+
'organization-id': Flags.string({ ...organizationIdFlagConfig, dependsOn: ['edit'] }),
|
|
35
26
|
stack: Flags.string({
|
|
36
27
|
description: 'Stack name or ID to set in the configuration. Requires --edit flag',
|
|
37
28
|
aliases: ['stack-id', 'stackId'],
|
|
@@ -39,7 +30,7 @@ If you need to switch your Blueprint to a different Stack, use --edit --stack.`;
|
|
|
39
30
|
}),
|
|
40
31
|
};
|
|
41
32
|
async run() {
|
|
42
|
-
const { success, error } = await blueprintConfigCore({
|
|
33
|
+
const { success, error, json } = await blueprintConfigCore({
|
|
43
34
|
bin: this.config.bin,
|
|
44
35
|
log: Logger(this.log.bind(this), this.flags),
|
|
45
36
|
blueprint: this.blueprint,
|
|
@@ -49,5 +40,6 @@ If you need to switch your Blueprint to a different Stack, use --edit --stack.`;
|
|
|
49
40
|
});
|
|
50
41
|
if (!success)
|
|
51
42
|
this.error(error);
|
|
43
|
+
return json;
|
|
52
44
|
}
|
|
53
45
|
}
|
|
@@ -9,5 +9,5 @@ export default class DeployCommand extends DeployedStackCommand<typeof DeployCom
|
|
|
9
9
|
'no-wait': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
10
|
'new-stack-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
};
|
|
12
|
-
run(): Promise<
|
|
12
|
+
run(): Promise<Record<string, unknown> | undefined>;
|
|
13
13
|
}
|
|
@@ -37,7 +37,7 @@ Set SANITY_ASSET_TIMEOUT (seconds) to override the 60-second timeout for process
|
|
|
37
37
|
}),
|
|
38
38
|
};
|
|
39
39
|
async run() {
|
|
40
|
-
const { success, error } = await blueprintDeployCore({
|
|
40
|
+
const { success, error, json } = await blueprintDeployCore({
|
|
41
41
|
bin: this.config.bin,
|
|
42
42
|
log: Logger(this.log.bind(this), this.flags),
|
|
43
43
|
auth: this.auth,
|
|
@@ -51,5 +51,6 @@ Set SANITY_ASSET_TIMEOUT (seconds) to override the 60-second timeout for process
|
|
|
51
51
|
});
|
|
52
52
|
if (!success)
|
|
53
53
|
this.error(error);
|
|
54
|
+
return json;
|
|
54
55
|
}
|
|
55
56
|
}
|
|
@@ -10,5 +10,5 @@ export default class DestroyCommand extends LocalBlueprintCommand<typeof Destroy
|
|
|
10
10
|
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
'no-wait': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
12
|
};
|
|
13
|
-
run(): Promise<
|
|
13
|
+
run(): Promise<Record<string, unknown> | undefined>;
|
|
14
14
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
2
|
+
import { LocalBlueprintCommand, organizationIdFlagConfig, projectIdFlagConfig, } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintDestroyCore } from '../../cores/blueprints/destroy.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
5
|
export default class DestroyCommand extends LocalBlueprintCommand {
|
|
@@ -20,17 +20,14 @@ Use this to clean up test environments or decommission a Stack you no longer nee
|
|
|
20
20
|
default: false,
|
|
21
21
|
}),
|
|
22
22
|
'project-id': Flags.string({
|
|
23
|
-
|
|
24
|
-
aliases: ['projectId', 'project'],
|
|
23
|
+
...projectIdFlagConfig,
|
|
25
24
|
dependsOn: ['stack', 'force'],
|
|
26
25
|
exclusive: ['organization-id'],
|
|
27
26
|
}),
|
|
28
27
|
'organization-id': Flags.string({
|
|
29
|
-
|
|
30
|
-
aliases: ['organizationId', 'organization', 'org'],
|
|
28
|
+
...organizationIdFlagConfig,
|
|
31
29
|
dependsOn: ['stack', 'force'],
|
|
32
30
|
exclusive: ['project-id'],
|
|
33
|
-
hidden: true,
|
|
34
31
|
}),
|
|
35
32
|
stack: Flags.string({
|
|
36
33
|
description: 'Stack name or ID to destroy (defaults to the locally configured Stack)',
|
|
@@ -42,7 +39,7 @@ Use this to clean up test environments or decommission a Stack you no longer nee
|
|
|
42
39
|
}),
|
|
43
40
|
};
|
|
44
41
|
async run() {
|
|
45
|
-
const { success, error } = await blueprintDestroyCore({
|
|
42
|
+
const { success, error, json } = await blueprintDestroyCore({
|
|
46
43
|
bin: this.config.bin,
|
|
47
44
|
log: Logger(this.log.bind(this), this.flags),
|
|
48
45
|
token: this.sanityToken,
|
|
@@ -52,5 +49,6 @@ Use this to clean up test environments or decommission a Stack you no longer nee
|
|
|
52
49
|
});
|
|
53
50
|
if (!success)
|
|
54
51
|
this.error(error);
|
|
52
|
+
return json;
|
|
55
53
|
}
|
|
56
54
|
}
|
|
@@ -32,9 +32,9 @@ Run this command when encountering errors with other Blueprint commands. Use --f
|
|
|
32
32
|
validateResources: this.flags['validate-resources'],
|
|
33
33
|
flags: this.flags,
|
|
34
34
|
});
|
|
35
|
-
const { success, error } = result;
|
|
35
|
+
const { success, error, json } = result;
|
|
36
36
|
if (!success)
|
|
37
37
|
this.error(error);
|
|
38
|
-
return
|
|
38
|
+
return json;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -6,5 +6,5 @@ export default class InfoCommand extends DeployedStackCommand<typeof InfoCommand
|
|
|
6
6
|
static flags: {
|
|
7
7
|
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
};
|
|
9
|
-
run(): Promise<
|
|
9
|
+
run(): Promise<Record<string, unknown> | undefined>;
|
|
10
10
|
}
|
|
@@ -20,7 +20,7 @@ Run 'blueprints stacks' to see all available Stacks in your project or organizat
|
|
|
20
20
|
}),
|
|
21
21
|
};
|
|
22
22
|
async run() {
|
|
23
|
-
const { success, error } = await blueprintInfoCore({
|
|
23
|
+
const { success, error, json } = await blueprintInfoCore({
|
|
24
24
|
bin: this.config.bin,
|
|
25
25
|
log: Logger(this.log.bind(this), this.flags),
|
|
26
26
|
stackId: this.stackId,
|
|
@@ -30,5 +30,6 @@ Run 'blueprints stacks' to see all available Stacks in your project or organizat
|
|
|
30
30
|
});
|
|
31
31
|
if (!success)
|
|
32
32
|
this.error(error);
|
|
33
|
+
return json;
|
|
33
34
|
}
|
|
34
35
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import { baseFlags, RuntimeCommand, unhide } from '../../baseCommands.js';
|
|
2
|
+
import { baseFlags, organizationIdFlagConfig, projectIdFlagConfig, RuntimeCommand, unhide, } 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';
|
|
@@ -38,19 +38,11 @@ After initialization, use 'blueprints plan' to preview changes, then 'blueprints
|
|
|
38
38
|
options: ['json', 'js', 'ts'],
|
|
39
39
|
aliases: ['type'],
|
|
40
40
|
}),
|
|
41
|
-
'project-id': Flags.string({
|
|
42
|
-
|
|
43
|
-
aliases: ['project', 'projectId'],
|
|
44
|
-
}),
|
|
45
|
-
'organization-id': Flags.string({
|
|
46
|
-
description: 'Sanity organization ID used to scope local Blueprint and remote Stack',
|
|
47
|
-
aliases: ['organization', 'organizationId', 'org'],
|
|
48
|
-
hidden: true,
|
|
49
|
-
}),
|
|
41
|
+
'project-id': Flags.string({ ...projectIdFlagConfig }),
|
|
42
|
+
'organization-id': Flags.string({ ...organizationIdFlagConfig }),
|
|
50
43
|
'stack-id': Flags.string({
|
|
51
44
|
description: 'Existing Stack ID used to scope local Blueprint',
|
|
52
45
|
aliases: ['stackId'],
|
|
53
|
-
dependsOn: ['project-id'],
|
|
54
46
|
exclusive: ['stack-name'],
|
|
55
47
|
}),
|
|
56
48
|
'stack-name': Flags.string({
|
|
@@ -6,5 +6,5 @@ export default class PlanCommand extends LocalBlueprintCommand<typeof PlanComman
|
|
|
6
6
|
static flags: {
|
|
7
7
|
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
};
|
|
9
|
-
run(): Promise<
|
|
9
|
+
run(): Promise<Record<string, unknown> | undefined>;
|
|
10
10
|
}
|
|
@@ -11,7 +11,7 @@ Run 'blueprints plan' after making local changes to your Blueprint manifest to v
|
|
|
11
11
|
stack: unhide(stackFlag),
|
|
12
12
|
};
|
|
13
13
|
async run() {
|
|
14
|
-
const { success, error } = await blueprintPlanCore({
|
|
14
|
+
const { success, error, json } = await blueprintPlanCore({
|
|
15
15
|
bin: this.config.bin,
|
|
16
16
|
log: Logger(this.log.bind(this), this.flags),
|
|
17
17
|
token: this.sanityToken,
|
|
@@ -21,5 +21,6 @@ Run 'blueprints plan' after making local changes to your Blueprint manifest to v
|
|
|
21
21
|
});
|
|
22
22
|
if (!success)
|
|
23
23
|
this.error(error);
|
|
24
|
+
return json;
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -6,7 +6,6 @@ export default class PromoteCommand extends DeployedStackCommand<typeof PromoteC
|
|
|
6
6
|
static examples: string[];
|
|
7
7
|
static flags: {
|
|
8
8
|
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
-
'i-know-what-im-doing': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
9
|
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
10
|
};
|
|
12
11
|
run(): Promise<Record<string, unknown> | undefined>;
|
|
@@ -15,17 +15,13 @@ export default class PromoteCommand extends DeployedStackCommand {
|
|
|
15
15
|
description: 'Stack name or ID to promote',
|
|
16
16
|
aliases: ['id'],
|
|
17
17
|
}),
|
|
18
|
-
'i-know-what-im-doing': Flags.boolean({
|
|
19
|
-
description: 'Must be set',
|
|
20
|
-
default: false,
|
|
21
|
-
}),
|
|
22
18
|
force: Flags.boolean({
|
|
23
19
|
description: 'Skip confirmation prompt',
|
|
24
20
|
default: false,
|
|
25
21
|
}),
|
|
26
22
|
};
|
|
27
23
|
async run() {
|
|
28
|
-
const { success, error,
|
|
24
|
+
const { success, error, json } = await blueprintPromoteCore({
|
|
29
25
|
bin: this.config.bin,
|
|
30
26
|
log: Logger(this.log.bind(this), this.flags),
|
|
31
27
|
token: this.sanityToken,
|
|
@@ -40,6 +36,6 @@ export default class PromoteCommand extends DeployedStackCommand {
|
|
|
40
36
|
});
|
|
41
37
|
if (!success)
|
|
42
38
|
this.error(error);
|
|
43
|
-
return
|
|
39
|
+
return json;
|
|
44
40
|
}
|
|
45
41
|
}
|
|
@@ -7,5 +7,5 @@ export default class StacksCommand extends LocalBlueprintCommand<typeof StacksCo
|
|
|
7
7
|
'project-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
'organization-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
};
|
|
10
|
-
run(): Promise<
|
|
10
|
+
run(): Promise<Record<string, unknown> | undefined>;
|
|
11
11
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
2
|
+
import { LocalBlueprintCommand, organizationIdFlagConfig, projectIdFlagConfig, } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintStacksCore } from '../../cores/blueprints/stacks.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
5
|
export default class StacksCommand extends LocalBlueprintCommand {
|
|
@@ -13,20 +13,11 @@ Use this to discover existing Stacks you can scope a local Blueprint to (using '
|
|
|
13
13
|
'<%= config.bin %> <%= command.id %> --organization-id <organizationId>',
|
|
14
14
|
];
|
|
15
15
|
static flags = {
|
|
16
|
-
'project-id': Flags.string({
|
|
17
|
-
|
|
18
|
-
aliases: ['projectId', 'project'],
|
|
19
|
-
exclusive: ['organization-id'],
|
|
20
|
-
}),
|
|
21
|
-
'organization-id': Flags.string({
|
|
22
|
-
description: 'Organization ID to show Stack deployments for',
|
|
23
|
-
aliases: ['organizationId', 'organization', 'org'],
|
|
24
|
-
exclusive: ['project-id'],
|
|
25
|
-
hidden: true,
|
|
26
|
-
}),
|
|
16
|
+
'project-id': Flags.string({ ...projectIdFlagConfig, exclusive: ['organization-id'] }),
|
|
17
|
+
'organization-id': Flags.string({ ...organizationIdFlagConfig, exclusive: ['project-id'] }),
|
|
27
18
|
};
|
|
28
19
|
async run() {
|
|
29
|
-
const { success, error } = await blueprintStacksCore({
|
|
20
|
+
const { success, error, json } = await blueprintStacksCore({
|
|
30
21
|
bin: this.config.bin,
|
|
31
22
|
log: Logger(this.log.bind(this), this.flags),
|
|
32
23
|
token: this.sanityToken,
|
|
@@ -36,5 +27,6 @@ Use this to discover existing Stacks you can scope a local Blueprint to (using '
|
|
|
36
27
|
});
|
|
37
28
|
if (!success)
|
|
38
29
|
this.error(error);
|
|
30
|
+
return json;
|
|
39
31
|
}
|
|
40
32
|
}
|
|
@@ -9,5 +9,5 @@ export default class BuildCommand extends LocalBlueprintCommand<typeof BuildComm
|
|
|
9
9
|
'fn-installer': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
'out-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
};
|
|
12
|
-
run(): Promise<
|
|
12
|
+
run(): Promise<Record<string, unknown> | undefined>;
|
|
13
13
|
}
|
|
@@ -19,7 +19,7 @@ export default class BuildCommand extends LocalBlueprintCommand {
|
|
|
19
19
|
'out-dir': Flags.string({ char: 'o', description: 'Output directory for zip files' }),
|
|
20
20
|
};
|
|
21
21
|
async run() {
|
|
22
|
-
const { success, error } = await functionBuildCore({
|
|
22
|
+
const { success, error, json } = await functionBuildCore({
|
|
23
23
|
bin: this.config.bin,
|
|
24
24
|
log: Logger(this.log.bind(this), this.flags),
|
|
25
25
|
args: { name: this.args.name },
|
|
@@ -29,5 +29,6 @@ export default class BuildCommand extends LocalBlueprintCommand {
|
|
|
29
29
|
});
|
|
30
30
|
if (!success)
|
|
31
31
|
this.error(error);
|
|
32
|
+
return json;
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -8,5 +8,5 @@ export default class EnvAddCommand extends DeployedStackCommand<typeof EnvAddCom
|
|
|
8
8
|
value: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
9
9
|
};
|
|
10
10
|
static examples: string[];
|
|
11
|
-
run(): Promise<
|
|
11
|
+
run(): Promise<Record<string, unknown> | undefined>;
|
|
12
12
|
}
|
|
@@ -16,7 +16,7 @@ Environment variables are useful for API keys, configuration values, and other s
|
|
|
16
16
|
'<%= config.bin %> <%= command.id %> MyFunction API_URL https://api.example.com/',
|
|
17
17
|
];
|
|
18
18
|
async run() {
|
|
19
|
-
const { success, error } = await functionEnvAddCore({
|
|
19
|
+
const { success, error, json } = await functionEnvAddCore({
|
|
20
20
|
bin: this.config.bin,
|
|
21
21
|
log: Logger(this.log.bind(this), this.flags),
|
|
22
22
|
args: this.args,
|
|
@@ -31,5 +31,6 @@ Environment variables are useful for API keys, configuration values, and other s
|
|
|
31
31
|
});
|
|
32
32
|
if (!success)
|
|
33
33
|
this.error(error);
|
|
34
|
+
return json;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
@@ -6,5 +6,5 @@ export default class EnvListCommand extends DeployedStackCommand<typeof EnvListC
|
|
|
6
6
|
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
7
|
};
|
|
8
8
|
static examples: string[];
|
|
9
|
-
run(): Promise<
|
|
9
|
+
run(): Promise<Record<string, unknown> | undefined>;
|
|
10
10
|
}
|
|
@@ -12,7 +12,7 @@ Use 'functions env add' to set variables or 'functions env remove' to delete the
|
|
|
12
12
|
};
|
|
13
13
|
static examples = ['<%= config.bin %> <%= command.id %> MyFunction'];
|
|
14
14
|
async run() {
|
|
15
|
-
const { success, error } = await functionEnvListCore({
|
|
15
|
+
const { success, error, json } = await functionEnvListCore({
|
|
16
16
|
bin: this.config.bin,
|
|
17
17
|
log: Logger(this.log.bind(this), this.flags),
|
|
18
18
|
args: this.args,
|
|
@@ -27,5 +27,6 @@ Use 'functions env add' to set variables or 'functions env remove' to delete the
|
|
|
27
27
|
});
|
|
28
28
|
if (!success)
|
|
29
29
|
this.error(error);
|
|
30
|
+
return json;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -7,5 +7,5 @@ export default class EnvRemoveCommand extends DeployedStackCommand<typeof EnvRem
|
|
|
7
7
|
key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
8
8
|
};
|
|
9
9
|
static examples: string[];
|
|
10
|
-
run(): Promise<
|
|
10
|
+
run(): Promise<Record<string, unknown> | undefined>;
|
|
11
11
|
}
|
|
@@ -13,7 +13,7 @@ Use 'functions env list' to see current variables before removing.`;
|
|
|
13
13
|
};
|
|
14
14
|
static examples = ['<%= config.bin %> <%= command.id %> MyFunction API_URL'];
|
|
15
15
|
async run() {
|
|
16
|
-
const { success, error } = await functionEnvRemoveCore({
|
|
16
|
+
const { success, error, json } = await functionEnvRemoveCore({
|
|
17
17
|
bin: this.config.bin,
|
|
18
18
|
log: Logger(this.log.bind(this), this.flags),
|
|
19
19
|
args: this.args,
|
|
@@ -28,5 +28,6 @@ Use 'functions env list' to see current variables before removing.`;
|
|
|
28
28
|
});
|
|
29
29
|
if (!success)
|
|
30
30
|
this.error(error);
|
|
31
|
+
return json;
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -9,7 +9,6 @@ export default class LogsCommand extends DeployedStackCommand<typeof LogsCommand
|
|
|
9
9
|
static flags: {
|
|
10
10
|
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
-
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
12
|
utc: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
13
|
delete: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
14
|
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
@@ -24,11 +24,6 @@ Use --watch (-w) to stream logs in real-time. Use --delete to clear all logs for
|
|
|
24
24
|
required: false,
|
|
25
25
|
default: 50,
|
|
26
26
|
}),
|
|
27
|
-
json: Flags.boolean({
|
|
28
|
-
char: 'j',
|
|
29
|
-
description: 'Return logs in JSON format',
|
|
30
|
-
required: false,
|
|
31
|
-
}),
|
|
32
27
|
utc: Flags.boolean({
|
|
33
28
|
char: 'u',
|
|
34
29
|
description: 'Show dates in UTC time zone',
|
|
@@ -25,5 +25,5 @@ export default class TestCommand extends LocalBlueprintCommand<typeof TestComman
|
|
|
25
25
|
'with-user-token': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
26
26
|
'media-library-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
27
|
};
|
|
28
|
-
run(): Promise<
|
|
28
|
+
run(): Promise<Record<string, unknown> | undefined>;
|
|
29
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
2
|
+
import { LocalBlueprintCommand, organizationIdFlagConfig, projectIdFlagConfig, } from '../../baseCommands.js';
|
|
3
3
|
import { functionTestCore } from '../../cores/functions/test.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
5
|
export default class TestCommand extends LocalBlueprintCommand {
|
|
@@ -101,17 +101,8 @@ Provide test data via --data (inline JSON), --file (JSON file), or --document-id
|
|
|
101
101
|
description: 'The Sanity dataset to use',
|
|
102
102
|
required: false,
|
|
103
103
|
}),
|
|
104
|
-
'project-id': Flags.string({
|
|
105
|
-
|
|
106
|
-
aliases: ['project', 'projectId'],
|
|
107
|
-
required: false,
|
|
108
|
-
}),
|
|
109
|
-
'organization-id': Flags.string({
|
|
110
|
-
description: 'Sanity Organization ID to use',
|
|
111
|
-
aliases: ['organization', 'organizationId', 'org'],
|
|
112
|
-
required: false,
|
|
113
|
-
hidden: true,
|
|
114
|
-
}),
|
|
104
|
+
'project-id': Flags.string({ ...projectIdFlagConfig }),
|
|
105
|
+
'organization-id': Flags.string({ ...organizationIdFlagConfig }),
|
|
115
106
|
'document-id': Flags.string({
|
|
116
107
|
description: 'Document to fetch and send to function',
|
|
117
108
|
aliases: ['doc', 'documentId'],
|
|
@@ -168,7 +159,7 @@ Provide test data via --data (inline JSON), --file (JSON file), or --document-id
|
|
|
168
159
|
' --document-id-before and --document-id-after');
|
|
169
160
|
}
|
|
170
161
|
}
|
|
171
|
-
const { success, error } = await functionTestCore({
|
|
162
|
+
const { success, error, json } = await functionTestCore({
|
|
172
163
|
bin: this.config.bin,
|
|
173
164
|
log: Logger(this.log.bind(this), this.flags),
|
|
174
165
|
error: (msg, options) => this.error(msg, options),
|
|
@@ -180,5 +171,6 @@ Provide test data via --data (inline JSON), --file (JSON file), or --document-id
|
|
|
180
171
|
});
|
|
181
172
|
if (!success)
|
|
182
173
|
this.error(error);
|
|
174
|
+
return json;
|
|
183
175
|
}
|
|
184
176
|
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -16,7 +16,8 @@ export declare const EVENT_MEDIA_LIBRARY_ASSET_CREATE = "media-library-asset-cre
|
|
|
16
16
|
export declare const EVENT_MEDIA_LIBRARY_ASSET_UPDATE = "media-library-asset-update";
|
|
17
17
|
export declare const EVENT_MEDIA_LIBRARY_ASSET_DELETE = "media-library-asset-delete";
|
|
18
18
|
export declare const EVENT_SCHEDULED = "scheduled-function";
|
|
19
|
-
export declare const FUNCTION_TYPES:
|
|
19
|
+
export declare const FUNCTION_TYPES: readonly ["document-publish", "document-create", "document-update", "document-delete", "media-library-asset-create", "media-library-asset-update", "media-library-asset-delete", "scheduled-function"];
|
|
20
|
+
export type ARRAY_OF_FUNCTION_TYPES = (typeof FUNCTION_TYPES)[number][];
|
|
20
21
|
export declare const PROJECT_SCOPED_FUNCTION_TYPES: ReadonlySet<string>;
|
|
21
22
|
export declare const ORGANIZATION_SCOPED_FUNCTION_TYPES: ReadonlySet<string>;
|
|
22
23
|
export declare const MAX_ASSET_SIZE = 209715200;
|
|
@@ -22,11 +22,11 @@ export async function blueprintConfigCore(options) {
|
|
|
22
22
|
// passing new config without --edit flag is not allowed
|
|
23
23
|
if (providedConfigFlag && !editConfig) {
|
|
24
24
|
log('To update the configuration, use the --edit flag.');
|
|
25
|
-
return { success: true };
|
|
25
|
+
return { success: true, json: blueprintConfig ? { config: blueprintConfig } : undefined };
|
|
26
26
|
}
|
|
27
27
|
if (!editConfig) {
|
|
28
28
|
// no edit; return success early
|
|
29
|
-
return { success: true };
|
|
29
|
+
return { success: true, json: blueprintConfig ? { config: blueprintConfig } : undefined };
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
32
|
if (providedConfigFlag) {
|
|
@@ -36,8 +36,12 @@ export async function blueprintConfigCore(options) {
|
|
|
36
36
|
if (flagProjectId)
|
|
37
37
|
configUpdate.projectId = flagProjectId;
|
|
38
38
|
if (flagStack) {
|
|
39
|
-
const scopeType = flagProjectId
|
|
40
|
-
|
|
39
|
+
const scopeType = flagProjectId
|
|
40
|
+
? 'project'
|
|
41
|
+
: flagOrganizationId
|
|
42
|
+
? 'organization'
|
|
43
|
+
: configScopeType;
|
|
44
|
+
const scopeId = flagProjectId || flagOrganizationId || configScopeId;
|
|
41
45
|
if (scopeType && scopeId) {
|
|
42
46
|
configUpdate.stackId = await resolveStackIdByNameOrId(flagStack, { token, scopeType, scopeId }, log);
|
|
43
47
|
}
|
|
@@ -50,7 +54,7 @@ export async function blueprintConfigCore(options) {
|
|
|
50
54
|
try {
|
|
51
55
|
const newConfig = patchConfigFile(blueprintFilePath, configUpdate);
|
|
52
56
|
printConfig({ configLabel: 'Updated', log, config: newConfig });
|
|
53
|
-
return { success: true };
|
|
57
|
+
return { success: true, json: { config: newConfig } };
|
|
54
58
|
}
|
|
55
59
|
catch {
|
|
56
60
|
// fallback to writeConfigFile if patchConfigFile fails
|
|
@@ -58,7 +62,7 @@ export async function blueprintConfigCore(options) {
|
|
|
58
62
|
try {
|
|
59
63
|
const newConfig = writeConfigFile(blueprintFilePath, configUpdate);
|
|
60
64
|
printConfig({ configLabel: 'Updated', log, config: newConfig });
|
|
61
|
-
return { success: true };
|
|
65
|
+
return { success: true, json: { config: newConfig } };
|
|
62
66
|
}
|
|
63
67
|
catch {
|
|
64
68
|
return { success: false, error: 'Unable to update configuration.' };
|
|
@@ -95,7 +99,7 @@ export async function blueprintConfigCore(options) {
|
|
|
95
99
|
stackId: updatedStackId,
|
|
96
100
|
});
|
|
97
101
|
printConfig({ configLabel: 'Updated', log, config: newConfig });
|
|
98
|
-
return { success: true };
|
|
102
|
+
return { success: true, json: { config: newConfig } };
|
|
99
103
|
}
|
|
100
104
|
catch {
|
|
101
105
|
return { success: false, error: 'Unable to update configuration!' };
|