@sanity/runtime-cli 17.1.0 → 17.2.0-blueprinit.g62f8017
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 +86 -55
- package/SKILL.md +21 -0
- package/dist/actions/blueprinit/manifest.d.ts +13 -0
- package/dist/actions/blueprinit/manifest.js +57 -0
- package/dist/actions/blueprinit/studio.d.ts +6 -0
- package/dist/actions/blueprinit/studio.js +43 -0
- package/dist/actions/blueprinit/templates.d.ts +34 -0
- package/dist/actions/blueprinit/templates.js +83 -0
- package/dist/actions/blueprinit/workspace.d.ts +15 -0
- package/dist/actions/blueprinit/workspace.js +142 -0
- package/dist/actions/blueprints/assets.d.ts +2 -1
- package/dist/actions/blueprints/assets.js +17 -26
- package/dist/actions/blueprints/blueprint.d.ts +1 -1
- package/dist/actions/blueprints/pre-deploy.d.ts +29 -0
- package/dist/actions/blueprints/pre-deploy.js +164 -0
- package/dist/actions/blueprints/wait-for-operation.js +4 -0
- package/dist/actions/sanity/datasets.d.ts +15 -0
- package/dist/actions/sanity/datasets.js +26 -0
- package/dist/actions/sanity/examples.d.ts +4 -4
- package/dist/baseCommands.d.ts +7 -4
- package/dist/baseCommands.js +17 -0
- package/dist/commands/blueprinit.d.ts +13 -0
- package/dist/commands/blueprinit.js +44 -0
- package/dist/commands/blueprints/add.d.ts +1 -1
- package/dist/commands/blueprints/config.d.ts +1 -1
- package/dist/commands/blueprints/deploy.d.ts +1 -1
- package/dist/commands/blueprints/destroy.d.ts +1 -1
- package/dist/commands/blueprints/doctor.d.ts +0 -1
- package/dist/commands/blueprints/doctor.js +3 -7
- package/dist/commands/blueprints/info.d.ts +1 -1
- package/dist/commands/blueprints/logs.d.ts +1 -1
- package/dist/commands/blueprints/mint-deploy-token.d.ts +1 -1
- package/dist/commands/blueprints/plan.d.ts +1 -1
- package/dist/commands/blueprints/promote.d.ts +1 -1
- package/dist/commands/blueprints/stacks.d.ts +1 -1
- package/dist/commands/functions/add.d.ts +1 -1
- package/dist/commands/functions/build.d.ts +1 -1
- package/dist/commands/functions/dev.d.ts +1 -1
- package/dist/commands/functions/env/add.d.ts +4 -1
- package/dist/commands/functions/env/add.js +6 -2
- package/dist/commands/functions/env/list.d.ts +4 -1
- package/dist/commands/functions/env/list.js +9 -3
- package/dist/commands/functions/env/remove.d.ts +4 -1
- package/dist/commands/functions/env/remove.js +9 -3
- package/dist/commands/functions/logs.d.ts +1 -1
- package/dist/commands/functions/test.d.ts +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/cores/blueprinit/adopt.d.ts +6 -0
- package/dist/cores/blueprinit/adopt.js +90 -0
- package/dist/cores/blueprinit/finish.d.ts +14 -0
- package/dist/cores/blueprinit/finish.js +36 -0
- package/dist/cores/blueprinit/fresh.d.ts +3 -0
- package/dist/cores/blueprinit/fresh.js +88 -0
- package/dist/cores/blueprinit/prompts.d.ts +4 -0
- package/dist/cores/blueprinit/prompts.js +14 -0
- package/dist/cores/blueprinit/selection.d.ts +15 -0
- package/dist/cores/blueprinit/selection.js +63 -0
- package/dist/cores/blueprinit/types.d.ts +13 -0
- package/dist/cores/blueprinit/types.js +1 -0
- package/dist/cores/blueprinit.d.ts +7 -0
- package/dist/cores/blueprinit.js +39 -0
- package/dist/cores/blueprints/deploy.js +18 -65
- package/dist/cores/blueprints/doctor.js +15 -12
- package/dist/cores/functions/build.js +3 -2
- package/dist/cores/functions/test.js +4 -2
- package/dist/server/app.js +8 -2
- package/dist/server/static/favicon-dark.svg +1 -0
- package/dist/server/static/favicon.svg +1 -0
- package/dist/server/static/index.html +1 -1
- package/dist/server/static/vendor/vendor.bundle.js +5 -0
- package/dist/utils/command-skills.d.ts +2 -0
- package/dist/utils/command-skills.js +17 -0
- package/dist/utils/functions/child-process-wrapper.js +13 -171
- package/dist/utils/functions/child-runtime/console.d.ts +1 -0
- package/dist/utils/functions/child-runtime/console.js +50 -0
- package/dist/utils/functions/child-runtime/invoke.d.ts +4 -0
- package/dist/utils/functions/child-runtime/invoke.js +47 -0
- package/dist/utils/functions/child-runtime/resources.d.ts +4 -0
- package/dist/utils/functions/child-runtime/resources.js +59 -0
- package/dist/utils/functions/find-entry-point.d.ts +1 -1
- package/dist/utils/functions/find-entry-point.js +10 -12
- package/dist/utils/functions/invoke/local.js +1 -1
- package/dist/utils/functions/invoke/prepare.d.ts +1 -1
- package/dist/utils/functions/invoke/prepare.js +19 -8
- package/dist/utils/functions/package-json.d.ts +1 -2
- package/dist/utils/functions/package-json.js +4 -6
- package/dist/utils/functions/prepare-asset.d.ts +2 -2
- package/dist/utils/functions/prepare-asset.js +18 -7
- package/dist/utils/functions/resolve-dependencies.d.ts +4 -1
- package/dist/utils/functions/resolve-dependencies.js +5 -6
- package/dist/utils/functions/resource-to-arc.d.ts +1 -1
- package/dist/utils/functions/resource-to-arc.js +4 -5
- package/dist/utils/functions/should-transpile.d.ts +7 -1
- package/dist/utils/functions/should-transpile.js +10 -10
- package/dist/utils/functions/transpile/function.d.ts +4 -1
- package/dist/utils/functions/transpile/function.js +9 -14
- package/dist/utils/functions/transpile/verify-handler.js +1 -1
- package/dist/utils/logger.d.ts +7 -5
- package/dist/utils/logger.js +33 -1
- package/dist/utils/progress.d.ts +5 -0
- package/dist/utils/progress.js +40 -0
- package/dist/utils/studios/prepare-asset.d.ts +6 -0
- package/dist/utils/studios/prepare-asset.js +139 -0
- package/dist/utils/types.d.ts +9 -8
- package/dist/utils/types.js +2 -3
- package/oclif.manifest.json +1218 -931
- package/package.json +33 -24
- package/skills/blueprinit.md +40 -0
package/dist/baseCommands.d.ts
CHANGED
|
@@ -10,10 +10,11 @@ export declare const pathFlagConfig: {
|
|
|
10
10
|
description: string;
|
|
11
11
|
env: string;
|
|
12
12
|
aliases: string[];
|
|
13
|
-
char:
|
|
13
|
+
char: 'p';
|
|
14
14
|
};
|
|
15
15
|
export declare const baseFlags: {
|
|
16
16
|
json: Interfaces.BooleanFlag<boolean>;
|
|
17
|
+
llms: Interfaces.BooleanFlag<boolean>;
|
|
17
18
|
path: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
18
19
|
trace: Interfaces.BooleanFlag<boolean>;
|
|
19
20
|
'validate-resources': Interfaces.BooleanFlag<boolean>;
|
|
@@ -42,6 +43,7 @@ export declare abstract class RuntimeCommand<T extends typeof Command> extends C
|
|
|
42
43
|
protected args: Args<T>;
|
|
43
44
|
static baseFlags: {
|
|
44
45
|
json: Interfaces.BooleanFlag<boolean>;
|
|
46
|
+
llms: Interfaces.BooleanFlag<boolean>;
|
|
45
47
|
path: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
46
48
|
trace: Interfaces.BooleanFlag<boolean>;
|
|
47
49
|
'validate-resources': Interfaces.BooleanFlag<boolean>;
|
|
@@ -112,14 +114,15 @@ export type Need = 'token' | 'blueprint' | 'scope' | 'stackId' | 'deployedStack'
|
|
|
112
114
|
export declare abstract class ResolvedCommand<T extends typeof Command> extends RuntimeCommand<T> {
|
|
113
115
|
static needs: readonly Need[];
|
|
114
116
|
static baseFlags: {
|
|
115
|
-
stack: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
116
|
-
'project-id': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
117
|
-
'organization-id': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
118
117
|
json: Interfaces.BooleanFlag<boolean>;
|
|
118
|
+
llms: Interfaces.BooleanFlag<boolean>;
|
|
119
119
|
path: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
120
120
|
trace: Interfaces.BooleanFlag<boolean>;
|
|
121
121
|
'validate-resources': Interfaces.BooleanFlag<boolean>;
|
|
122
122
|
verbose: Interfaces.BooleanFlag<boolean>;
|
|
123
|
+
stack: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
124
|
+
'project-id': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
125
|
+
'organization-id': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
123
126
|
};
|
|
124
127
|
protected sanityToken: string;
|
|
125
128
|
protected blueprint: ReadBlueprintResult;
|
package/dist/baseCommands.js
CHANGED
|
@@ -6,6 +6,7 @@ import { resolveIds } from './actions/blueprints/resolve.js';
|
|
|
6
6
|
import { getStack, resolveStackIdByNameOrId } from './actions/blueprints/stacks.js';
|
|
7
7
|
import config from './config.js';
|
|
8
8
|
import { CI_SETUP_DOCS_URL } from './constants.js';
|
|
9
|
+
import { commandSkillFilename, readCommandSkill } from './utils/command-skills.js';
|
|
9
10
|
import { presentBlueprintParserErrors } from './utils/display/errors.js';
|
|
10
11
|
import { Logger } from './utils/logger.js';
|
|
11
12
|
import { styleText } from './utils/style-text.js';
|
|
@@ -30,6 +31,10 @@ export const baseFlags = {
|
|
|
30
31
|
// override defaults from oclif's built-in --json flag
|
|
31
32
|
description: 'Format output as json',
|
|
32
33
|
}),
|
|
34
|
+
llms: OclifFlags.boolean({
|
|
35
|
+
description: 'Show agent-oriented guidance for this command',
|
|
36
|
+
aliases: ['skill'],
|
|
37
|
+
}),
|
|
33
38
|
path: OclifFlags.string({
|
|
34
39
|
...pathFlagConfig,
|
|
35
40
|
hidden: true,
|
|
@@ -118,6 +123,18 @@ export class RuntimeCommand extends Command {
|
|
|
118
123
|
return commandHelp.generate();
|
|
119
124
|
}
|
|
120
125
|
async init() {
|
|
126
|
+
if (this.argv.some((arg) => arg === '--llms' || arg === '--skill')) {
|
|
127
|
+
const commandId = this.id ?? this.ctor.id;
|
|
128
|
+
const skill = await readCommandSkill(commandId);
|
|
129
|
+
if (!skill) {
|
|
130
|
+
const commandName = commandId.replaceAll(':', ' ');
|
|
131
|
+
this.error(`No agent guidance is available for \`${commandName}\`.`, {
|
|
132
|
+
suggestions: [`Add it at skills/${commandSkillFilename(commandId)}.`],
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
process.stdout.write(skill.endsWith('\n') ? skill : `${skill}\n`);
|
|
136
|
+
this.exit();
|
|
137
|
+
}
|
|
121
138
|
const { args, flags } = await this.parse({
|
|
122
139
|
flags: this.ctor.flags,
|
|
123
140
|
baseFlags: super.ctor.baseFlags,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RuntimeCommand } from '../baseCommands.js';
|
|
2
|
+
export default class BlueprinitCommand extends RuntimeCommand<typeof BlueprinitCommand> {
|
|
3
|
+
static hidden: boolean;
|
|
4
|
+
static summary: string;
|
|
5
|
+
static description: string;
|
|
6
|
+
static examples: string[];
|
|
7
|
+
static flags: {
|
|
8
|
+
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
'organization-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'project-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<Record<string, unknown> | undefined>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { RuntimeCommand } from '../baseCommands.js';
|
|
3
|
+
import { blueprinitCore } from '../cores/blueprinit.js';
|
|
4
|
+
import { Logger } from '../utils/logger.js';
|
|
5
|
+
export default class BlueprinitCommand extends RuntimeCommand {
|
|
6
|
+
static hidden = true;
|
|
7
|
+
static summary = 'Experimental blueprints-first project init';
|
|
8
|
+
static description = `Scaffolds a Blueprint, Studio, and starter function around an existing Sanity project.
|
|
9
|
+
|
|
10
|
+
This hidden command is an experiment; its interface and generated files are not stable.`;
|
|
11
|
+
static examples = [
|
|
12
|
+
'<%= config.bin %> <%= command.id %>',
|
|
13
|
+
'<%= config.bin %> <%= command.id %> --yes',
|
|
14
|
+
];
|
|
15
|
+
static flags = {
|
|
16
|
+
yes: Flags.boolean({
|
|
17
|
+
char: 'y',
|
|
18
|
+
description: 'Skip confirmation prompts',
|
|
19
|
+
default: false,
|
|
20
|
+
}),
|
|
21
|
+
'organization-id': Flags.string({
|
|
22
|
+
description: 'Organization to use when the account has several',
|
|
23
|
+
aliases: ['organization', 'organizationId', 'org'],
|
|
24
|
+
}),
|
|
25
|
+
'project-id': Flags.string({
|
|
26
|
+
description: 'Project to use when the organization has several',
|
|
27
|
+
aliases: ['project', 'projectId'],
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
async run() {
|
|
31
|
+
const result = await blueprinitCore({
|
|
32
|
+
bin: this.config.bin,
|
|
33
|
+
log: Logger(this.log.bind(this), this.flags),
|
|
34
|
+
flags: {
|
|
35
|
+
yes: this.flags.yes,
|
|
36
|
+
organizationId: this.flags['organization-id'],
|
|
37
|
+
projectId: this.flags['project-id'],
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
if (!result.success)
|
|
41
|
+
this.coreError(result);
|
|
42
|
+
return result.json;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
6
6
|
export default class AddCommand extends ResolvedCommand<typeof AddCommand> {
|
|
7
|
-
static needs: readonly [
|
|
7
|
+
static needs: readonly ['blueprint'];
|
|
8
8
|
static state: string;
|
|
9
9
|
static deprecationOptions: {
|
|
10
10
|
to: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class ConfigCommand extends ResolvedCommand<typeof ConfigCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['token', 'blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class DeployCommand extends ResolvedCommand<typeof DeployCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['deployedStack', 'blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class DestroyCommand extends ResolvedCommand<typeof DestroyCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['scope'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -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
|
-
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
9
|
};
|
|
11
10
|
run(): Promise<Record<string, unknown> | undefined>;
|
|
12
11
|
}
|
|
@@ -7,8 +7,9 @@ export default class DoctorCommand extends RuntimeCommand {
|
|
|
7
7
|
static summary = 'Diagnose potential issues with local Blueprint and remote Stack configuration';
|
|
8
8
|
static description = `Analyzes your local Blueprint and remote Stack configuration for common issues, such as missing authentication, invalid project references, or misconfigured resources.
|
|
9
9
|
|
|
10
|
-
Run this command when encountering errors with other Blueprint commands. Use --fix to interactively resolve detected issues
|
|
11
|
-
|
|
10
|
+
Run this command when encountering errors with other Blueprint commands. Use --fix to interactively resolve detected issues.
|
|
11
|
+
|
|
12
|
+
Supports --json for programmatic consumption of diagnostic results.`;
|
|
12
13
|
static examples = [
|
|
13
14
|
'<%= config.bin %> <%= command.id %>',
|
|
14
15
|
'<%= config.bin %> <%= command.id %> --fix',
|
|
@@ -19,11 +20,6 @@ Run this command when encountering errors with other Blueprint commands. Use --f
|
|
|
19
20
|
description: 'Interactively fix configuration issues',
|
|
20
21
|
default: false,
|
|
21
22
|
}),
|
|
22
|
-
verbose: Flags.boolean({
|
|
23
|
-
description: 'Verbose output; defaults to true',
|
|
24
|
-
default: true,
|
|
25
|
-
allowNo: true,
|
|
26
|
-
}),
|
|
27
23
|
};
|
|
28
24
|
async run() {
|
|
29
25
|
const { token } = config;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class InfoCommand extends ResolvedCommand<typeof InfoCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['deployedStack'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class LogsCommand extends ResolvedCommand<typeof LogsCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['deployedStack'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class MintDeployTokenCommand extends ResolvedCommand<typeof MintDeployTokenCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['scope'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class PlanCommand extends ResolvedCommand<typeof PlanCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['token', 'blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class PromoteCommand extends ResolvedCommand<typeof PromoteCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['deployedStack', 'blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class StacksCommand extends ResolvedCommand<typeof StacksCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['scope'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class AddCommand extends ResolvedCommand<typeof AddCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class BuildCommand extends ResolvedCommand<typeof BuildCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static hidden: boolean;
|
|
6
6
|
static args: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class DevCommand extends ResolvedCommand<typeof DevCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
2
2
|
export default class EnvAddCommand extends ResolvedCommand<typeof EnvAddCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['deployedStack', 'blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static args: {
|
|
@@ -8,6 +8,9 @@ export default class EnvAddCommand extends ResolvedCommand<typeof EnvAddCommand>
|
|
|
8
8
|
key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
9
9
|
value: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
10
10
|
};
|
|
11
|
+
static flags: {
|
|
12
|
+
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
};
|
|
11
14
|
static examples: string[];
|
|
12
15
|
run(): Promise<Record<string, unknown> | undefined>;
|
|
13
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Args } from '@oclif/core';
|
|
2
|
-
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { ResolvedCommand, stackFlagConfig } from '../../../baseCommands.js';
|
|
3
3
|
import { functionEnvAddCore } from '../../../cores/functions/env/add.js';
|
|
4
4
|
import { Logger } from '../../../utils/logger.js';
|
|
5
5
|
export default class EnvAddCommand extends ResolvedCommand {
|
|
@@ -13,8 +13,12 @@ Environment variables are useful for API keys, configuration values, and other s
|
|
|
13
13
|
key: Args.string({ description: 'The name of the environment variable', required: true }),
|
|
14
14
|
value: Args.string({ description: 'The value of the environment variable', required: true }),
|
|
15
15
|
};
|
|
16
|
+
static flags = {
|
|
17
|
+
stack: Flags.string({ ...stackFlagConfig }),
|
|
18
|
+
};
|
|
16
19
|
static examples = [
|
|
17
20
|
'<%= config.bin %> <%= command.id %> MyFunction API_URL https://api.example.com/',
|
|
21
|
+
'<%= config.bin %> <%= command.id %> --stack <name-or-id> MyFunction API_URL https://api.example.com/',
|
|
18
22
|
];
|
|
19
23
|
async run() {
|
|
20
24
|
const result = await functionEnvAddCore({
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
2
2
|
export default class EnvListCommand extends ResolvedCommand<typeof EnvListCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['deployedStack', 'blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static args: {
|
|
7
7
|
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
8
8
|
};
|
|
9
|
+
static flags: {
|
|
10
|
+
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
9
12
|
static examples: string[];
|
|
10
13
|
run(): Promise<Record<string, unknown> | undefined>;
|
|
11
14
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Args } from '@oclif/core';
|
|
2
|
-
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { ResolvedCommand, stackFlagConfig } from '../../../baseCommands.js';
|
|
3
3
|
import { functionEnvListCore } from '../../../cores/functions/env/list.js';
|
|
4
4
|
import { Logger } from '../../../utils/logger.js';
|
|
5
5
|
export default class EnvListCommand extends ResolvedCommand {
|
|
@@ -11,7 +11,13 @@ Use 'functions env add' to set variables or 'functions env remove' to delete the
|
|
|
11
11
|
static args = {
|
|
12
12
|
name: Args.string({ description: 'The name of the Sanity Function', required: true }),
|
|
13
13
|
};
|
|
14
|
-
static
|
|
14
|
+
static flags = {
|
|
15
|
+
stack: Flags.string({ ...stackFlagConfig }),
|
|
16
|
+
};
|
|
17
|
+
static examples = [
|
|
18
|
+
'<%= config.bin %> <%= command.id %> MyFunction',
|
|
19
|
+
'<%= config.bin %> <%= command.id %> --stack <name-or-id> MyFunction',
|
|
20
|
+
];
|
|
15
21
|
async run() {
|
|
16
22
|
const result = await functionEnvListCore({
|
|
17
23
|
bin: this.config.bin,
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
2
2
|
export default class EnvRemoveCommand extends ResolvedCommand<typeof EnvRemoveCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['deployedStack', 'blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static args: {
|
|
7
7
|
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
8
8
|
key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
9
9
|
};
|
|
10
|
+
static flags: {
|
|
11
|
+
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
};
|
|
10
13
|
static examples: string[];
|
|
11
14
|
run(): Promise<Record<string, unknown> | undefined>;
|
|
12
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Args } from '@oclif/core';
|
|
2
|
-
import { ResolvedCommand } from '../../../baseCommands.js';
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { ResolvedCommand, stackFlagConfig } from '../../../baseCommands.js';
|
|
3
3
|
import { functionEnvRemoveCore } from '../../../cores/functions/env/remove.js';
|
|
4
4
|
import { Logger } from '../../../utils/logger.js';
|
|
5
5
|
export default class EnvRemoveCommand extends ResolvedCommand {
|
|
@@ -12,7 +12,13 @@ Use 'functions env list' to see current variables before removing.`;
|
|
|
12
12
|
name: Args.string({ description: 'The name of the Sanity Function', required: true }),
|
|
13
13
|
key: Args.string({ description: 'The name of the environment variable', required: true }),
|
|
14
14
|
};
|
|
15
|
-
static
|
|
15
|
+
static flags = {
|
|
16
|
+
stack: Flags.string({ ...stackFlagConfig }),
|
|
17
|
+
};
|
|
18
|
+
static examples = [
|
|
19
|
+
'<%= config.bin %> <%= command.id %> MyFunction API_URL',
|
|
20
|
+
'<%= config.bin %> <%= command.id %> --stack <name-or-id> MyFunction API_URL',
|
|
21
|
+
];
|
|
16
22
|
async run() {
|
|
17
23
|
const result = await functionEnvRemoveCore({
|
|
18
24
|
bin: this.config.bin,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class LogsCommand extends ResolvedCommand<typeof LogsCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['deployedStack', 'blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static args: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedCommand } from '../../baseCommands.js';
|
|
2
2
|
export default class TestCommand extends ResolvedCommand<typeof TestCommand> {
|
|
3
|
-
static needs: readonly [
|
|
3
|
+
static needs: readonly ['blueprint'];
|
|
4
4
|
static summary: string;
|
|
5
5
|
static description: string;
|
|
6
6
|
static args: {
|
package/dist/constants.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const SANITY_PROJECT = "sanity.project";
|
|
|
9
9
|
export declare const SANITY_PROJECT_CORS = "sanity.project.cors";
|
|
10
10
|
export declare const SANITY_PROJECT_DATASET = "sanity.project.dataset";
|
|
11
11
|
export declare const SANITY_PROJECT_WEBHOOK = "sanity.project.webhook";
|
|
12
|
+
export declare const SANITY_STUDIO = "sanity.studio";
|
|
12
13
|
export declare const EVENT_DOCUMENT_PUBLISH = "document-publish";
|
|
13
14
|
export declare const EVENT_DOCUMENT_CREATE = "document-create";
|
|
14
15
|
export declare const EVENT_DOCUMENT_UPDATE = "document-update";
|
package/dist/constants.js
CHANGED
|
@@ -9,6 +9,7 @@ export const SANITY_PROJECT = 'sanity.project';
|
|
|
9
9
|
export const SANITY_PROJECT_CORS = 'sanity.project.cors';
|
|
10
10
|
export const SANITY_PROJECT_DATASET = 'sanity.project.dataset';
|
|
11
11
|
export const SANITY_PROJECT_WEBHOOK = 'sanity.project.webhook';
|
|
12
|
+
export const SANITY_STUDIO = 'sanity.studio';
|
|
12
13
|
export const EVENT_DOCUMENT_PUBLISH = 'document-publish';
|
|
13
14
|
export const EVENT_DOCUMENT_CREATE = 'document-create';
|
|
14
15
|
export const EVENT_DOCUMENT_UPDATE = 'document-update';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DetectedStudio } from '../../actions/blueprinit/studio.js';
|
|
2
|
+
import type { CoreResult } from '../index.js';
|
|
3
|
+
import type { BlueprinitFlowOptions } from './types.js';
|
|
4
|
+
export declare function adoptFlow(options: BlueprinitFlowOptions & {
|
|
5
|
+
studio: DetectedStudio;
|
|
6
|
+
}): Promise<CoreResult>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { slugify } from '../../actions/blueprinit/manifest.js';
|
|
4
|
+
import { adoptWorkspace } from '../../actions/blueprinit/workspace.js';
|
|
5
|
+
import { listDatasets } from '../../actions/sanity/datasets.js';
|
|
6
|
+
import { groupProjectsByOrganization } from '../../actions/sanity/projects.js';
|
|
7
|
+
import { check } from '../../utils/display/presenters.js';
|
|
8
|
+
import { getLatestNpmVersion } from '../../utils/external/npmjs.js';
|
|
9
|
+
import { isInteractive } from '../../utils/interactive.js';
|
|
10
|
+
import { createStackAndFinish } from './finish.js';
|
|
11
|
+
import { confirmUnlessSkipped, promptForStudioName } from './prompts.js';
|
|
12
|
+
import { findProject } from './selection.js';
|
|
13
|
+
export async function adoptFlow(options) {
|
|
14
|
+
const { bin, dir, flags, log, studio, token } = options;
|
|
15
|
+
if (!studio.projectId || !studio.dataset) {
|
|
16
|
+
return {
|
|
17
|
+
success: false,
|
|
18
|
+
error: `Found ${studio.configFile}, but could not read a projectId and dataset from it.`,
|
|
19
|
+
suggestions: ['Use literal projectId and dataset values in the Studio config.'],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (flags.projectId && flags.projectId !== studio.projectId) {
|
|
23
|
+
return { success: false, error: `The Studio uses project "${studio.projectId}".` };
|
|
24
|
+
}
|
|
25
|
+
log(check(`Studio detected (${studio.configFile})`));
|
|
26
|
+
const grouped = await groupProjectsByOrganization({ token, logger: log });
|
|
27
|
+
if (!grouped.ok) {
|
|
28
|
+
return { success: false, error: `Could not list organizations: ${grouped.error}` };
|
|
29
|
+
}
|
|
30
|
+
const match = findProject(grouped.organizations, studio.projectId);
|
|
31
|
+
if (!match) {
|
|
32
|
+
return {
|
|
33
|
+
success: false,
|
|
34
|
+
error: `Project "${studio.projectId}" from ${studio.configFile} was not found in your account.`,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (flags.organizationId && flags.organizationId !== match.organization.id) {
|
|
38
|
+
return {
|
|
39
|
+
success: false,
|
|
40
|
+
error: `Project "${studio.projectId}" belongs to organization "${match.organization.id}".`,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const datasets = await listDatasets({ token, projectId: match.project.id, logger: log });
|
|
44
|
+
if (!datasets.ok) {
|
|
45
|
+
return { success: false, error: `Could not list datasets: ${datasets.error}` };
|
|
46
|
+
}
|
|
47
|
+
if (!datasets.datasets.some(({ name }) => name === studio.dataset)) {
|
|
48
|
+
return {
|
|
49
|
+
success: false,
|
|
50
|
+
error: `Dataset "${studio.dataset}" was not found in project ${match.project.displayName}.`,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
log(check(`Matches project ${match.project.displayName} (${match.project.id}), dataset ${studio.dataset}`));
|
|
54
|
+
log('');
|
|
55
|
+
const confirmed = await confirmUnlessSkipped(flags, isInteractive, 'Adopt this Studio into a Blueprint?');
|
|
56
|
+
if (!confirmed)
|
|
57
|
+
return { success: false, error: 'Initialization cancelled.' };
|
|
58
|
+
const studioName = await promptForStudioName(flags, isInteractive);
|
|
59
|
+
const stackName = slugify(match.project.displayName) || match.project.id;
|
|
60
|
+
const marker = (file) => (existsSync(join(dir, file)) ? '~' : '+');
|
|
61
|
+
log('Changes:');
|
|
62
|
+
log(" + sanity.blueprint.ts attach project + dataset; adopt Studio at '.'");
|
|
63
|
+
log(` + .sanity/blueprint.config.json org scope, stack ${stackName}`);
|
|
64
|
+
log(` ${marker('.gitignore')} .gitignore`);
|
|
65
|
+
log(` ${marker('package.json')} package.json`);
|
|
66
|
+
log('');
|
|
67
|
+
const adoption = adoptWorkspace({
|
|
68
|
+
dir,
|
|
69
|
+
projectId: match.project.id,
|
|
70
|
+
displayName: match.project.displayName,
|
|
71
|
+
datasetName: studio.dataset,
|
|
72
|
+
stackName,
|
|
73
|
+
studioName,
|
|
74
|
+
blueprintsVersion: await getLatestNpmVersion('@sanity/blueprints', log),
|
|
75
|
+
});
|
|
76
|
+
return await createStackAndFinish({
|
|
77
|
+
...options,
|
|
78
|
+
organizationId: match.organization.id,
|
|
79
|
+
projectId: match.project.id,
|
|
80
|
+
datasetName: studio.dataset,
|
|
81
|
+
stackName,
|
|
82
|
+
blueprintFilePath: adoption.blueprintFilePath,
|
|
83
|
+
files: adoption.files,
|
|
84
|
+
nextSteps: [
|
|
85
|
+
` npx ${bin} blueprints plan`,
|
|
86
|
+
` npx ${bin} blueprints deploy`,
|
|
87
|
+
` npx ${bin} blueprints info`,
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CoreResult } from '../index.js';
|
|
2
|
+
import type { BlueprinitFlowOptions } from './types.js';
|
|
3
|
+
interface FinishOptions extends BlueprinitFlowOptions {
|
|
4
|
+
organizationId: string;
|
|
5
|
+
projectId: string;
|
|
6
|
+
datasetName: string;
|
|
7
|
+
stackName: string;
|
|
8
|
+
blueprintFilePath: string;
|
|
9
|
+
files: string[];
|
|
10
|
+
nextSteps: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function createStackAndFinish(options: FinishOptions): Promise<CoreResult>;
|
|
13
|
+
export declare function alignSteps(steps: Array<[command: string, description?: string]>): string[];
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { writeConfigFile } from '../../actions/blueprints/config.js';
|
|
2
|
+
import { createEmptyStack } from '../../actions/blueprints/stacks.js';
|
|
3
|
+
import { check } from '../../utils/display/presenters.js';
|
|
4
|
+
export async function createStackAndFinish(options) {
|
|
5
|
+
const stack = await createEmptyStack({
|
|
6
|
+
token: options.token,
|
|
7
|
+
scopeType: 'organization',
|
|
8
|
+
scopeId: options.organizationId,
|
|
9
|
+
name: options.stackName,
|
|
10
|
+
logger: options.log,
|
|
11
|
+
});
|
|
12
|
+
writeConfigFile(options.blueprintFilePath, {
|
|
13
|
+
organizationId: options.organizationId,
|
|
14
|
+
stackId: stack.id,
|
|
15
|
+
});
|
|
16
|
+
options.log(check(`Stack ${stack.name} created (org scope)`));
|
|
17
|
+
options.log('');
|
|
18
|
+
options.log('Next steps:');
|
|
19
|
+
for (const step of options.nextSteps)
|
|
20
|
+
options.log(step);
|
|
21
|
+
return {
|
|
22
|
+
success: true,
|
|
23
|
+
json: {
|
|
24
|
+
organizationId: options.organizationId,
|
|
25
|
+
projectId: options.projectId,
|
|
26
|
+
dataset: options.datasetName,
|
|
27
|
+
stackId: stack.id,
|
|
28
|
+
stackName: stack.name,
|
|
29
|
+
files: [...options.files, '.sanity/blueprint.config.json'],
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function alignSteps(steps) {
|
|
34
|
+
const width = Math.max(...steps.map(([command]) => command.length));
|
|
35
|
+
return steps.map(([command, description]) => description ? ` ${command.padEnd(width + 2)}${description}` : ` ${command}`);
|
|
36
|
+
}
|