Skip to content

feat(init): moving templates for init to new cli#290

Merged
mttdnt merged 6 commits intomainfrom
feature/sdk-388/moving-init-templates
Jan 16, 2026
Merged

feat(init): moving templates for init to new cli#290
mttdnt merged 6 commits intomainfrom
feature/sdk-388/moving-init-templates

Conversation

@mttdnt
Copy link
Contributor

@mttdnt mttdnt commented Jan 15, 2026

Description

Copied over any recent changes to templates, and moved them over, this is to make the final init pr 180 files smaller...

@mttdnt mttdnt requested a review from a team as a code owner January 15, 2026 17:26
@mttdnt mttdnt requested review from ryanbonial and removed request for a team January 15, 2026 17:26
@linear
Copy link

linear bot commented Jan 15, 2026

SDK-388 Migrate init command to new CLI

const helpText = `
Options
  -y, --yes Use unattended mode, accepting defaults and using only flags for choices
  --project <projectId> Project ID to use for the studio
  --organization <organizationId> Organization ID to use for the project
  --dataset <dataset> Dataset name for the studio
  --dataset-default Set up a project with a public dataset named "production"
  --output-path <path> Path to write studio project to
  --template <template> Project template to use [default: "clean"]
  --bare Skip the Studio initialization and only print the selected project ID and dataset name to stdout
  --env <filename> Write environment variables to file [default: ".env"]
  --provider <provider> Login provider to use
  --visibility <mode> Visibility mode for dataset (public/private)
  --create-project <name> Create a new project with the given name
  --project-plan <name> Optionally select a plan for a new project
  --coupon <name> Optionally select a coupon for a new project (cannot be used with --project-plan)
  --no-typescript Do not use TypeScript for template files
  --package-manager <name> Specify which package manager to use [allowed: ${allowedPackageManagersString}]
  --no-auto-updates Disable auto updates of studio versions

Examples
  # Initialize a new project, prompt for required information along the way
  sanity init

  # Initialize a new project with a public dataset named "production"
  sanity init --dataset-default

  # Initialize a project with the given project ID and dataset to the given path
  sanity init -y --project abc123 --dataset production --output-path ~/myproj

  # Initialize a project with the given project ID and dataset using the moviedb
  # template to the given path
  sanity init -y --project abc123 --dataset staging --template moviedb --output-path .

  # Create a brand new project with name "Movies Unlimited"
  sanity init -y \\
    --create-project "Movies Unlimited" \\
    --dataset moviedb \\
    --visibility private \\
    --template moviedb \\
    --output-path /Users/espenh/movies-unlimited
`

@claude
Copy link

claude bot commented Jan 15, 2026

Claude finished @mttdnt's task in 2m 51s —— View job


Review Complete

Issues Found

1. CSS Bug in ExampleComponent.css (Line 51)

The file has a CSS typo that was copied from the original templates:

justify-container: center;  // ❌ Invalid CSS property

Should be:

justify-content: center;  // ✅ Correct property

Location: packages/@sanity/cli/templates/app-quickstart/src/ExampleComponent.css:51

This bug existed in the original templates and was carried over during the move. It won't cause errors but the style won't apply.

2. Clarify package.json "files" field (Reviewer's comment)

The commit message 3f4f7fa says "copy to dist on build" but only adds ./templates to the files array. The reviewer (binoy14) is questioning whether copying templates to dist is necessary since including ./templates in the files field already makes them available in the published package.

The files field specifies what gets included when publishing to npm. If templates are at the root level (./templates), they don't need to be copied to ./dist - they'll be included directly. Verify whether:

  • Templates are meant to stay at packages/@sanity/cli/templates/
  • Or if they should be copied to packages/@sanity/cli/dist/templates/

The current setup includes them from their source location, which seems correct.

3. Run Prettier on Templates (Reviewer's comment)

As binoy14 noted, prettier needs to be run on the template files:

cd packages/@sanity/cli && npx prettier --write templates/

The lintstaged config was already updated to handle templates, but the files need an initial formatting pass.


@github-actions
Copy link

github-actions bot commented Jan 15, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 70.9% 5489 / 7741
🔵 Statements 70.26% 5630 / 8013
🔵 Functions 57.83% 819 / 1416
🔵 Branches 58.87% 2454 / 4168
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/@sanity/cli/templates/app-sanity-ui/src/SanityUI.tsx 0% 100% 0% 0% 5-21
packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopType.ts 0% 100% 100% 0% 3-15
Generated in workflow #1510 for commit c9ba48e by the Vitest Coverage Report Action

@mttdnt mttdnt changed the title feat(init): moving templates for init to new clie feat(init): moving templates for init to new cli Jan 15, 2026
@mttdnt mttdnt requested a review from a team January 15, 2026 17:49
Copy link
Contributor

@binoy14 binoy14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to run prettier against the templates. You can run this from the root cd packages/@sanity/cli && npx prettier --write templates/

"scripts": {
"build": "swc --delete-dir-on-start --strip-leading-paths --out-dir dist/ src",
"postbuild": "pnpm run manifest:generate",
"postbuild": "pnpm run manifest:generate && cp -r templates dist/templates",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to copy the templates to dist if the files above is including it.

@mttdnt mttdnt force-pushed the feature/sdk-388/moving-init-templates branch from 0b96744 to c9ba48e Compare January 15, 2026 22:07
@mttdnt mttdnt requested a review from binoy14 January 15, 2026 22:13
@mttdnt mttdnt merged commit fd42cd5 into main Jan 16, 2026
21 checks passed
@mttdnt mttdnt deleted the feature/sdk-388/moving-init-templates branch January 16, 2026 16:14
@squiggler-legacy squiggler-legacy bot mentioned this pull request Jan 16, 2026
@squiggler-app squiggler-app bot mentioned this pull request Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants