@sanity/runtime-cli 17.21.6-blueprinit.gc247877 → 17.21.6-next.g34627a4

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.
Files changed (70) hide show
  1. package/README.md +19 -19
  2. package/dist/actions/blueprints/assets.d.ts +2 -1
  3. package/dist/actions/blueprints/assets.js +8 -2
  4. package/dist/actions/blueprints/pre-deploy.d.ts +1 -1
  5. package/dist/actions/blueprints/pre-deploy.js +38 -5
  6. package/dist/actions/blueprints/process-assets.d.ts +3 -0
  7. package/dist/actions/blueprints/process-assets.js +13 -4
  8. package/dist/cores/blueprints/deploy.js +2 -1
  9. package/dist/utils/bundles/prepare-asset.d.ts +6 -2
  10. package/dist/utils/bundles/prepare-asset.js +10 -2
  11. package/dist/utils/bundles/resolve-resource-bindings.d.ts +10 -0
  12. package/dist/utils/bundles/resolve-resource-bindings.js +37 -0
  13. package/dist/utils/functions/blocked-modules.d.ts +14 -0
  14. package/dist/utils/functions/blocked-modules.js +41 -0
  15. package/dist/utils/functions/prepare-asset.js +5 -0
  16. package/dist/utils/functions/transpile/function.js +4 -1
  17. package/dist/utils/icons/prepare-asset.d.ts +10 -0
  18. package/dist/utils/icons/prepare-asset.js +40 -0
  19. package/dist/utils/types.d.ts +17 -2
  20. package/oclif.manifest.json +1 -152
  21. package/package.json +3 -3
  22. package/dist/actions/blueprinit/manifest.d.ts +0 -52
  23. package/dist/actions/blueprinit/manifest.js +0 -139
  24. package/dist/actions/blueprinit/quote.d.ts +0 -6
  25. package/dist/actions/blueprinit/quote.js +0 -8
  26. package/dist/actions/blueprinit/studio.d.ts +0 -6
  27. package/dist/actions/blueprinit/studio.js +0 -43
  28. package/dist/actions/blueprinit/templates.d.ts +0 -73
  29. package/dist/actions/blueprinit/templates.js +0 -143
  30. package/dist/actions/blueprinit/versions.d.ts +0 -8
  31. package/dist/actions/blueprinit/versions.js +0 -11
  32. package/dist/actions/blueprinit/workspace.d.ts +0 -36
  33. package/dist/actions/blueprinit/workspace.js +0 -174
  34. package/dist/actions/sanity/create-project.d.ts +0 -19
  35. package/dist/actions/sanity/create-project.js +0 -32
  36. package/dist/actions/sanity/datasets.d.ts +0 -15
  37. package/dist/actions/sanity/datasets.js +0 -26
  38. package/dist/commands/init.d.ts +0 -21
  39. package/dist/commands/init.js +0 -82
  40. package/dist/cores/blueprinit/adopt.d.ts +0 -6
  41. package/dist/cores/blueprinit/adopt.js +0 -137
  42. package/dist/cores/blueprinit/columns.d.ts +0 -26
  43. package/dist/cores/blueprinit/columns.js +0 -27
  44. package/dist/cores/blueprinit/finish.d.ts +0 -15
  45. package/dist/cores/blueprinit/finish.js +0 -72
  46. package/dist/cores/blueprinit/fresh.d.ts +0 -3
  47. package/dist/cores/blueprinit/fresh.js +0 -230
  48. package/dist/cores/blueprinit/naming.d.ts +0 -27
  49. package/dist/cores/blueprinit/naming.js +0 -43
  50. package/dist/cores/blueprinit/preview.d.ts +0 -34
  51. package/dist/cores/blueprinit/preview.js +0 -118
  52. package/dist/cores/blueprinit/project-choice.d.ts +0 -28
  53. package/dist/cores/blueprinit/project-choice.js +0 -82
  54. package/dist/cores/blueprinit/prompts.d.ts +0 -13
  55. package/dist/cores/blueprinit/prompts.js +0 -42
  56. package/dist/cores/blueprinit/results.d.ts +0 -8
  57. package/dist/cores/blueprinit/results.js +0 -4
  58. package/dist/cores/blueprinit/selection.d.ts +0 -15
  59. package/dist/cores/blueprinit/selection.js +0 -90
  60. package/dist/cores/blueprinit/stack-name.d.ts +0 -39
  61. package/dist/cores/blueprinit/stack-name.js +0 -56
  62. package/dist/cores/blueprinit/target.d.ts +0 -33
  63. package/dist/cores/blueprinit/target.js +0 -80
  64. package/dist/cores/blueprinit/types.d.ts +0 -20
  65. package/dist/cores/blueprinit/types.js +0 -1
  66. package/dist/cores/blueprinit.d.ts +0 -7
  67. package/dist/cores/blueprinit.js +0 -64
  68. package/dist/utils/display/intro.d.ts +0 -6
  69. package/dist/utils/display/intro.js +0 -63
  70. package/skills/init.md +0 -199
@@ -1,143 +0,0 @@
1
- import { STARTER_DOCUMENT_TYPE, STARTER_FUNCTION_NAME } from './manifest.js';
2
- import { quote } from './quote.js';
3
- export function renderStudioConfig(options) {
4
- return `import {defineConfig} from 'sanity'
5
- import {structureTool} from 'sanity/structure'
6
- import {visionTool} from '@sanity/vision'
7
- import {schemaTypes} from './schemaTypes'
8
-
9
- export default defineConfig({
10
- name: 'default',
11
- title: ${quote(options.displayName)},
12
- projectId: ${quote(options.projectId)},
13
- dataset: ${quote(options.datasetName)},
14
- plugins: [structureTool(), visionTool()],
15
- schema: {types: schemaTypes},
16
- })
17
- `;
18
- }
19
- /**
20
- * `sanity dev` and `sanity build` read the project and dataset from here, not from
21
- * `sanity.config.ts`, and fail with `No CLI config found` when the file is absent.
22
- *
23
- * `sanity init` also writes a `deployment.autoUpdates` block. It is left out because it only
24
- * affects `sanity deploy`, and the Blueprint's `defineStudio` already declares auto-updates.
25
- */
26
- export function renderStudioCliConfig(options) {
27
- return `import {defineCliConfig} from 'sanity/cli'
28
-
29
- export default defineCliConfig({
30
- api: {
31
- projectId: ${quote(options.projectId)},
32
- dataset: ${quote(options.datasetName)},
33
- },
34
- })
35
- `;
36
- }
37
- export const STUDIO_SCHEMA_TYPES = `import {post} from './post'
38
-
39
- export const schemaTypes = [post]
40
- `;
41
- export const STUDIO_POST_TYPE = `import {defineField, defineType} from 'sanity'
42
-
43
- export const post = defineType({
44
- name: '${STARTER_DOCUMENT_TYPE}',
45
- title: 'Post',
46
- type: 'document',
47
- fields: [
48
- defineField({name: 'title', type: 'string', validation: (rule) => rule.required()}),
49
- // The ${STARTER_FUNCTION_NAME} function fills this when it is empty.
50
- defineField({name: 'slug', type: 'slug', options: {source: 'title'}}),
51
- defineField({name: 'publishedAt', title: 'Published at', type: 'datetime'}),
52
- defineField({name: 'body', type: 'text'}),
53
- ],
54
- })
55
- `;
56
- export const FUNCTION_SET_SLUG = `import {createClient} from '@sanity/client'
57
- import {documentEventHandler} from '@sanity/functions'
58
-
59
- const slugify = (title: string) =>
60
- title
61
- .toLowerCase()
62
- .replace(/[^a-z0-9]+/g, '-')
63
- .replace(/^-+|-+$/g, '')
64
- .slice(0, 96)
65
-
66
- export const handler = documentEventHandler(async ({context, event}) => {
67
- const {_id, title, slug} = event.data
68
- if (!title || slug?.current) return
69
-
70
- // useCdn: false because this handler writes; the default warns and reads from the edge cache
71
- const client = createClient({
72
- apiVersion: '2025-05-01',
73
- useCdn: false,
74
- ...context.clientOptions,
75
- })
76
- const current = slugify(title)
77
- await client.patch(_id).set({slug: {_type: 'slug', current}}).commit()
78
-
79
- console.log(\`Set slug for \${_id}: \${current}\`)
80
- })
81
- `;
82
- /**
83
- * Versions `sanity init` pins itself, in `studioDependencies` in `@sanity/cli`.
84
- *
85
- * `sanity` and `@sanity/vision` are resolved at scaffold time instead, the way that command
86
- * resolves them, so a Studio here matches the one `sanity init` would have written.
87
- */
88
- const REACT_VERSION = '^19.2.4';
89
- const STYLED_COMPONENTS_VERSION = '^6.1.18';
90
- const TYPES_REACT_VERSION = '^19.2.14';
91
- const TYPESCRIPT_VERSION = '^5.8';
92
- export const studioPackageJson = (name, versions) => ({
93
- name,
94
- version: '1.0.0',
95
- private: true,
96
- license: 'UNLICENSED',
97
- keywords: ['sanity'],
98
- // The Blueprint deploys this Studio, so there is no `sanity deploy` script.
99
- // Running one would create a second hosted Studio that the Stack does not own.
100
- scripts: {
101
- dev: 'sanity dev',
102
- build: 'sanity build',
103
- },
104
- dependencies: {
105
- '@sanity/vision': versions.vision,
106
- react: REACT_VERSION,
107
- 'react-dom': REACT_VERSION,
108
- sanity: versions.sanity,
109
- 'styled-components': STYLED_COMPONENTS_VERSION,
110
- },
111
- devDependencies: {
112
- '@types/react': TYPES_REACT_VERSION,
113
- typescript: TYPESCRIPT_VERSION,
114
- },
115
- });
116
- /** Copied from `templates/shared/tsconfig.json` in `@sanity/cli`. */
117
- export const STUDIO_TSCONFIG = {
118
- compilerOptions: {
119
- target: 'ES2017',
120
- lib: ['dom', 'dom.iterable', 'esnext'],
121
- allowJs: true,
122
- skipLibCheck: true,
123
- strict: true,
124
- forceConsistentCasingInFileNames: true,
125
- module: 'Preserve',
126
- moduleDetection: 'force',
127
- isolatedModules: true,
128
- jsx: 'preserve',
129
- incremental: true,
130
- },
131
- include: ['**/*.ts', '**/*.tsx'],
132
- exclude: ['node_modules'],
133
- };
134
- export const functionPackageJson = (name) => ({
135
- name,
136
- version: '0.1.0',
137
- private: true,
138
- type: 'module',
139
- dependencies: {
140
- '@sanity/client': '^8',
141
- '@sanity/functions': '^1',
142
- },
143
- });
@@ -1,8 +0,0 @@
1
- import type { Logger } from '../../utils/logger.js';
2
- /**
3
- * The latest version as a caret range, the form `sanity init` writes.
4
- *
5
- * `getLatestNpmVersion` answers `latest` when the registry cannot be read, and `^latest`
6
- * is not a range, so that answer passes through unchanged.
7
- */
8
- export declare function getLatestNpmRange(pkg: string, logger: Logger): Promise<string>;
@@ -1,11 +0,0 @@
1
- import { getLatestNpmVersion } from '../../utils/external/npmjs.js';
2
- /**
3
- * The latest version as a caret range, the form `sanity init` writes.
4
- *
5
- * `getLatestNpmVersion` answers `latest` when the registry cannot be read, and `^latest`
6
- * is not a range, so that answer passes through unchanged.
7
- */
8
- export async function getLatestNpmRange(pkg, logger) {
9
- const version = await getLatestNpmVersion(pkg, logger);
10
- return version === 'latest' ? version : `^${version}`;
11
- }
@@ -1,36 +0,0 @@
1
- import { type DatasetAction } from './manifest.js';
2
- import { type StudioVersions } from './templates.js';
3
- export interface WorkspaceOptions {
4
- dir: string;
5
- projectId: string;
6
- displayName: string;
7
- datasetName: string;
8
- /** Attach a dataset the project already has, or create one. Defaults to attach. */
9
- datasetAction?: DatasetAction;
10
- /** Set when this run created the project, which has no CORS origins of its own yet. */
11
- createsProject?: boolean;
12
- stackName: string;
13
- /** Blueprint-local name for the attached project resource. */
14
- projectName: string;
15
- studioName: string;
16
- studioSlug: string;
17
- studioOrigin: string;
18
- blueprintsVersion: string;
19
- }
20
- export interface ScaffoldOptions extends WorkspaceOptions {
21
- /** Resolved at scaffold time, the way `sanity init` resolves its own Studio versions. */
22
- studioVersions: StudioVersions;
23
- }
24
- export interface WorkspaceResult {
25
- blueprintFilePath: string;
26
- files: string[];
27
- }
28
- export declare function scaffoldWorkspace(options: ScaffoldOptions): WorkspaceResult;
29
- export declare function adoptWorkspace(options: WorkspaceOptions): WorkspaceResult;
30
- /**
31
- * Script that starts one Studio's dev server, named for its directory so a workspace with
32
- * several Studios gets one script each.
33
- */
34
- export declare function studioDevScript(studioName: string): string;
35
- /** Script that starts the function emulator. One emulator serves every function. */
36
- export declare const FUNCTIONS_DEV_SCRIPT = "dev:functions";
@@ -1,174 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
- import { dirname, join, posix } from 'node:path';
3
- import { renderBlueprint, STARTER_FUNCTION_NAME, studioSourcePath, } from './manifest.js';
4
- import { FUNCTION_SET_SLUG, functionPackageJson, renderStudioCliConfig, renderStudioConfig, STUDIO_POST_TYPE, STUDIO_SCHEMA_TYPES, STUDIO_TSCONFIG, studioPackageJson, } from './templates.js';
5
- const GITIGNORE_ENTRY = '# Sanity Blueprints\n.sanity/';
6
- const DEFAULT_GITIGNORE = `node_modules
7
- .env
8
-
9
- ${GITIGNORE_ENTRY}
10
- `;
11
- export function scaffoldWorkspace(options) {
12
- const { dir, studioName, studioVersions } = options;
13
- assertTargetsAvailable(dir, [
14
- studioSourcePath(studioName),
15
- posix.join('functions', STARTER_FUNCTION_NAME),
16
- ]);
17
- // `sanity` is not a dependency of this root package, but `sanity` the Studio package brings
18
- // `@sanity/cli` with it, and npm hoists its bin here. That is what serves `functions dev`.
19
- const packageJson = preparePackageJson(options, ['studios/*', 'functions/*'], {
20
- [studioDevScript(studioName)]: `npm run dev -w ${studioSourcePath(studioName)}`,
21
- [FUNCTIONS_DEV_SCRIPT]: 'sanity functions dev',
22
- });
23
- const files = [];
24
- const write = createWriter(dir, files);
25
- const blueprintFilePath = write('sanity.blueprint.ts', renderBlueprint({
26
- ...manifestOptions(options),
27
- studioRoot: `./${studioSourcePath(studioName)}`,
28
- withFunction: true,
29
- }));
30
- write(posix.join('studios', studioName, 'package.json'), formatJson(studioPackageJson(studioName, studioVersions)));
31
- write(posix.join('studios', studioName, 'tsconfig.json'), formatJson(STUDIO_TSCONFIG));
32
- write(posix.join('studios', studioName, 'sanity.config.ts'), renderStudioConfig(options));
33
- write(posix.join('studios', studioName, 'sanity.cli.ts'), renderStudioCliConfig(options));
34
- write(posix.join('studios', studioName, 'schemaTypes', 'index.ts'), STUDIO_SCHEMA_TYPES);
35
- write(posix.join('studios', studioName, 'schemaTypes', 'post.ts'), STUDIO_POST_TYPE);
36
- write(posix.join('studios', studioName, 'static', '.gitkeep'), '');
37
- write(posix.join('functions', STARTER_FUNCTION_NAME, 'package.json'), formatJson(functionPackageJson(STARTER_FUNCTION_NAME)));
38
- write(posix.join('functions', STARTER_FUNCTION_NAME, 'index.ts'), FUNCTION_SET_SLUG);
39
- writePreparedRootFiles(dir, packageJson, files);
40
- return { blueprintFilePath, files };
41
- }
42
- export function adoptWorkspace(options) {
43
- const { dir } = options;
44
- const packageJson = preparePackageJson(options, []);
45
- const files = [];
46
- const write = createWriter(dir, files);
47
- const blueprintFilePath = write('sanity.blueprint.ts', renderBlueprint({ ...manifestOptions(options), studioRoot: '.', withFunction: false }));
48
- writePreparedRootFiles(dir, packageJson, files);
49
- return { blueprintFilePath, files };
50
- }
51
- function manifestOptions(options) {
52
- return {
53
- projectName: options.projectName,
54
- displayName: options.displayName,
55
- projectId: options.projectId,
56
- datasetName: options.datasetName,
57
- datasetAction: options.datasetAction ?? 'attach',
58
- withLocalCors: options.createsProject ?? false,
59
- studioName: options.studioName,
60
- studioSlug: options.studioSlug,
61
- studioOrigin: options.studioOrigin,
62
- };
63
- }
64
- function assertTargetsAvailable(dir, paths) {
65
- const conflicts = paths.filter((path) => existsSync(join(dir, path)));
66
- if (conflicts.length > 0) {
67
- throw new Error(`Refusing to overwrite existing paths: ${conflicts.join(', ')}`);
68
- }
69
- }
70
- function createWriter(dir, files) {
71
- return (relativePath, content) => {
72
- const filePath = join(dir, relativePath);
73
- mkdirSync(dirname(filePath), { recursive: true });
74
- writeFileSync(filePath, content);
75
- files.push(relativePath);
76
- return filePath;
77
- };
78
- }
79
- function writePreparedRootFiles(dir, packageJson, files) {
80
- if (writeGitignore(dir))
81
- files.push('.gitignore');
82
- writeFileSync(join(dir, 'package.json'), formatJson(packageJson));
83
- files.push('package.json');
84
- }
85
- function writeGitignore(dir) {
86
- const filePath = join(dir, '.gitignore');
87
- if (!existsSync(filePath)) {
88
- writeFileSync(filePath, DEFAULT_GITIGNORE);
89
- return true;
90
- }
91
- const existing = readFileSync(filePath, 'utf8');
92
- if (existing.split(/\r?\n/).some((line) => line.trim() === '.sanity/'))
93
- return false;
94
- writeFileSync(filePath, `${existing.trimEnd()}\n\n${GITIGNORE_ENTRY}\n`);
95
- return true;
96
- }
97
- /**
98
- * Script that starts one Studio's dev server, named for its directory so a workspace with
99
- * several Studios gets one script each.
100
- */
101
- export function studioDevScript(studioName) {
102
- return `dev:${studioName}`;
103
- }
104
- /** Script that starts the function emulator. One emulator serves every function. */
105
- export const FUNCTIONS_DEV_SCRIPT = 'dev:functions';
106
- function preparePackageJson(options, requiredWorkspaces, scripts = {}) {
107
- const filePath = join(options.dir, 'package.json');
108
- const parsed = existsSync(filePath)
109
- ? JSON.parse(readFileSync(filePath, 'utf8'))
110
- : {
111
- name: options.stackName,
112
- version: '0.1.0',
113
- private: true,
114
- type: 'module',
115
- };
116
- if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
117
- throw new Error('The existing package.json must contain a JSON object.');
118
- }
119
- const packageJson = parsed;
120
- addWorkspaces(packageJson, requiredWorkspaces);
121
- addScripts(packageJson, scripts);
122
- addBlueprintsDependency(packageJson, options.blueprintsVersion);
123
- return packageJson;
124
- }
125
- /** Add scripts that are not already defined. An existing script of the same name wins. */
126
- function addScripts(packageJson, scripts) {
127
- const entries = Object.entries(scripts);
128
- if (entries.length === 0)
129
- return;
130
- const existing = recordOrEmpty(packageJson.scripts);
131
- const added = { ...existing };
132
- for (const [name, command] of entries) {
133
- if (!(name in added))
134
- added[name] = command;
135
- }
136
- packageJson.scripts = added;
137
- }
138
- function addWorkspaces(packageJson, required) {
139
- if (required.length === 0)
140
- return;
141
- if (!packageJson.workspaces) {
142
- packageJson.workspaces = required;
143
- return;
144
- }
145
- if (Array.isArray(packageJson.workspaces)) {
146
- packageJson.workspaces = [...new Set([...packageJson.workspaces, ...required])];
147
- return;
148
- }
149
- // Neither falsy nor an array by now, so the only supported shape left is {packages: []}.
150
- const workspaces = packageJson.workspaces;
151
- if (typeof workspaces === 'object' && Array.isArray(workspaces.packages)) {
152
- workspaces.packages = [...new Set([...workspaces.packages, ...required])];
153
- return;
154
- }
155
- throw new Error('Cannot add generated packages to the existing package.json workspaces.');
156
- }
157
- function addBlueprintsDependency(packageJson, blueprintsVersion) {
158
- const dependencies = recordOrEmpty(packageJson.dependencies);
159
- const devDependencies = recordOrEmpty(packageJson.devDependencies);
160
- if (dependencies['@sanity/blueprints'] || devDependencies['@sanity/blueprints'])
161
- return;
162
- packageJson.devDependencies = {
163
- ...devDependencies,
164
- '@sanity/blueprints': blueprintsVersion,
165
- };
166
- }
167
- function recordOrEmpty(value) {
168
- return value && typeof value === 'object' && !Array.isArray(value)
169
- ? value
170
- : {};
171
- }
172
- function formatJson(value) {
173
- return `${JSON.stringify(value, null, 2)}\n`;
174
- }
@@ -1,19 +0,0 @@
1
- import type { Logger } from '../../utils/logger.js';
2
- import type { ActionResponse } from '../../utils/types.js';
3
- import { type Project } from './projects.js';
4
- export interface CreateProjectResult extends ActionResponse {
5
- project?: Project;
6
- }
7
- /**
8
- * Create a project in an organization.
9
- *
10
- * `createDefaultCorsOrigin` is false because the Blueprint declares the only origin the
11
- * hosted Studio needs. The Blueprints project provider sends the same field for the same
12
- * reason. No dataset comes back: this endpoint creates none, so the Blueprint creates it.
13
- */
14
- export declare function createProject({ token, organizationId, displayName, logger, }: {
15
- token: string;
16
- organizationId: string;
17
- displayName: string;
18
- logger: Logger;
19
- }): Promise<CreateProjectResult>;
@@ -1,32 +0,0 @@
1
- import { createTracedFetch } from '../../utils/traced-fetch.js';
2
- import { projectsApiPath } from './projects.js';
3
- /**
4
- * Create a project in an organization.
5
- *
6
- * `createDefaultCorsOrigin` is false because the Blueprint declares the only origin the
7
- * hosted Studio needs. The Blueprints project provider sends the same field for the same
8
- * reason. No dataset comes back: this endpoint creates none, so the Blueprint creates it.
9
- */
10
- export async function createProject({ token, organizationId, displayName, logger, }) {
11
- const fetchFn = createTracedFetch(logger);
12
- try {
13
- const response = await fetchFn(projectsApiPath, {
14
- method: 'POST',
15
- headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
16
- body: JSON.stringify({
17
- displayName,
18
- organizationId,
19
- createDefaultCorsOrigin: false,
20
- metadata: { integration: 'blueprints' },
21
- }),
22
- });
23
- const body = await response.json();
24
- if (!response.ok) {
25
- return { ok: false, error: body?.error?.message || body?.message || `HTTP ${response.status}` };
26
- }
27
- return { ok: true, error: null, project: body };
28
- }
29
- catch (error) {
30
- return { ok: false, error: error instanceof Error ? error.message : String(error) };
31
- }
32
- }
@@ -1,15 +0,0 @@
1
- import type { Logger } from '../../utils/logger.js';
2
- import type { ActionResponse } from '../../utils/types.js';
3
- export interface Dataset {
4
- name: string;
5
- aclMode: string;
6
- }
7
- interface ListDatasetsResponse extends ActionResponse {
8
- datasets: Dataset[];
9
- }
10
- export declare function listDatasets({ token, projectId, logger, }: {
11
- token: string;
12
- projectId: string;
13
- logger: Logger;
14
- }): Promise<ListDatasetsResponse>;
15
- export {};
@@ -1,26 +0,0 @@
1
- import { createTracedFetch } from '../../utils/traced-fetch.js';
2
- import { projectsApiPath } from './projects.js';
3
- export async function listDatasets({ token, projectId, logger, }) {
4
- const fetchFn = createTracedFetch(logger);
5
- const url = `${projectsApiPath}/${encodeURIComponent(projectId)}/datasets`;
6
- const response = await fetchFn(url, {
7
- method: 'GET',
8
- headers: {
9
- Authorization: `Bearer ${token}`,
10
- 'Content-Type': 'application/json',
11
- },
12
- });
13
- const body = await response.json();
14
- if (!response.ok) {
15
- return {
16
- ok: false,
17
- error: body.error?.message ?? response.statusText,
18
- datasets: [],
19
- };
20
- }
21
- return {
22
- ok: true,
23
- error: null,
24
- datasets: body,
25
- };
26
- }
@@ -1,21 +0,0 @@
1
- import { RuntimeCommand } from '../baseCommands.js';
2
- export default class InitCommand extends RuntimeCommand<typeof InitCommand> {
3
- static hidden: boolean;
4
- static summary: string;
5
- static description: string;
6
- static examples: string[];
7
- static args: {
8
- directory: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
9
- };
10
- static flags: {
11
- llms: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
- yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
- 'organization-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
- 'project-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
- 'create-project': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
- dataset: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
- 'stack-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
- 'studio-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
- };
20
- run(): Promise<Record<string, unknown> | undefined>;
21
- }
@@ -1,82 +0,0 @@
1
- import { resolve } from 'node:path';
2
- import { Args, Flags } from '@oclif/core';
3
- import { llmsFlagConfig } from '@sanity-labs/oclif-plugin-skills-flag';
4
- import { RuntimeCommand } from '../baseCommands.js';
5
- import { blueprinitCore } from '../cores/blueprinit.js';
6
- import { playIntro } from '../utils/display/intro.js';
7
- import { Logger } from '../utils/logger.js';
8
- export default class InitCommand extends RuntimeCommand {
9
- static hidden = true;
10
- static summary = 'Experimental blueprints-first project init';
11
- static description = `Scaffolds a Blueprint, Studio, and starter function around a Sanity project.
12
-
13
- Use a project you already have, or create one with --create-project. A new project has no
14
- datasets, so the Blueprint creates the dataset rather than attaching it.
15
-
16
- Pass a directory to scaffold into it. Without one, an interactive run asks where the files go.
17
-
18
- This hidden command is an experiment; its interface and generated files are not stable.`;
19
- static examples = [
20
- '<%= config.bin %> <%= command.id %>',
21
- '<%= config.bin %> <%= command.id %> ./my-workspace',
22
- '<%= config.bin %> <%= command.id %> --yes',
23
- '<%= config.bin %> <%= command.id %> --project-id <id> --dataset <name> --yes',
24
- '<%= config.bin %> <%= command.id %> --create-project "My Shop" --yes',
25
- ];
26
- static args = {
27
- directory: Args.string({
28
- description: 'Directory to initialize. Interactive runs are asked for one instead.',
29
- required: false,
30
- }),
31
- };
32
- static flags = {
33
- llms: Flags.boolean(llmsFlagConfig),
34
- yes: Flags.boolean({
35
- char: 'y',
36
- description: 'Skip confirmation prompts',
37
- default: false,
38
- }),
39
- 'organization-id': Flags.string({
40
- description: 'Organization to use when the account has several',
41
- aliases: ['organization', 'organizationId', 'org'],
42
- }),
43
- 'project-id': Flags.string({
44
- description: 'Project to use when the organization has several',
45
- aliases: ['project', 'projectId'],
46
- }),
47
- 'create-project': Flags.string({
48
- description: 'Create a project with this display name instead of using an existing one',
49
- aliases: ['createProject', 'new-project'],
50
- exclusive: ['project-id'],
51
- }),
52
- dataset: Flags.string({
53
- description: 'Dataset to attach, or to create alongside a new project',
54
- }),
55
- 'stack-name': Flags.string({
56
- description: 'Name for the new organization-scoped Stack, and the hosted Studio slug',
57
- }),
58
- 'studio-name': Flags.string({
59
- description: 'Blueprint-local name for the Studio resource and its directory',
60
- }),
61
- };
62
- async run() {
63
- await playIntro({ json: this.jsonEnabled() });
64
- const result = await blueprinitCore({
65
- bin: this.config.bin,
66
- dir: this.args.directory ? resolve(this.args.directory) : undefined,
67
- log: Logger(this.log.bind(this), this.flags),
68
- flags: {
69
- yes: this.flags.yes,
70
- organizationId: this.flags['organization-id'],
71
- projectId: this.flags['project-id'],
72
- createProject: this.flags['create-project'],
73
- datasetName: this.flags.dataset,
74
- stackName: this.flags['stack-name'],
75
- studioName: this.flags['studio-name'],
76
- },
77
- });
78
- if (!result.success)
79
- this.coreError(result);
80
- return result.json;
81
- }
82
- }
@@ -1,6 +0,0 @@
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>;