Repository navigation
refactor(create-void): delegate scaffolding to void init
#894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yuikisaito
wants to merge
21
commits into
voidzero-dev:main
Choose a base branch
from
yuikisaito:issue-888
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+497
−77
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2593b1d
fix(create-void): merge pnpm build policy into workspace config
yuikisaito f97f7ab
test(create-void): cover pnpm build policy merging
yuikisaito d511f39
feat(create-void): support --no-install
yuikisaito 74e28a9
feat(void): support --no-install in init
yuikisaito 72cefb4
test(create-void): cover CLI bootstrap commands
yuikisaito 4325273
test(init): cover --no-install scaffolding
yuikisaito 3c5325b
fix(create-void): support no-install with Yarn Classic
yuikisaito 802eadf
revert(create-void): roll back bootstrap and no-install changes
yuikisaito 2e2d917
fix(create-void): run matching Void CLI version via dlx
yuikisaito 2b78392
refactor(create-void): delegate scaffolding to void init
yuikisaito 5828f32
test(create-void): test dlx delegation
yuikisaito 1d59fae
test(create-void): test init delegation
yuikisaito 3aa9ab7
fix(create-void): preserve delegated package manager
yuikisaito 21727f1
fix(init): report skipped migration
yuikisaito 835b15c
Merge main
yuikisaito 3e7724e
style(create-void): fix lint errors
yuikisaito 92bb09b
feat(init): record package manager in devEngines for Vite+ starters
yuikisaito f2620e3
feat(create-void): default to Vite+ toolchain when invoked from vp
yuikisaito f3b8b82
fix(create-void): fix the logic for determining whether to insert dev…
yuikisaito fe860c4
fix(create-void): honor --package-manager when scaffolding Vite+ star…
yuikisaito f4b03f9
fix(create-void): skip install when invoked from vp
yuikisaito File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; | ||
| import { tmpdir } from 'node:os'; | ||
| import { join } from 'node:path'; | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'; | ||
| import { parseInitArgs, runInitCommand } from '../../../void/src/cli/init.ts'; | ||
| import { detectPM, runVoidInit } from '../../src/pm.ts'; | ||
|
|
||
| const VOID_VERSION = JSON.parse( | ||
| readFileSync(join(import.meta.dirname, '..', '..', 'package.json'), 'utf8'), | ||
| ) as { version: string }; | ||
|
|
||
| describe('create-void delegation', () => { | ||
| beforeEach(() => vi.stubEnv('VP_USER_AGENT', '')); | ||
| afterEach(() => vi.unstubAllEnvs()); | ||
|
|
||
| it('writes the npm package manager for an npm create void Vite+ starter', async () => { | ||
| vi.stubEnv('VP_USER_AGENT', ''); | ||
| vi.stubEnv('npm_config_user_agent', 'npm/11.0.0 node/v24.22.1'); | ||
| const root = mkdtempSync(join(tmpdir(), 'create-void-npm-')); | ||
| try { | ||
| expect(detectPM()).toBe('npm'); | ||
|
|
||
| await runVoidInit( | ||
| detectPM(), | ||
| VOID_VERSION.version, | ||
| [ | ||
| '--toolchain', | ||
| 'vite-plus', | ||
| '--framework', | ||
| 'react', | ||
| '--starter', | ||
| 'static', | ||
| '--deploy', | ||
| 'none', | ||
| '--no-install', | ||
| ], | ||
| root, | ||
| async (argv, cwd) => { | ||
| expect(argv).toContain('--package-manager'); | ||
| expect(argv[argv.indexOf('--package-manager') + 1]).toBe('npm'); | ||
| await runInitCommand(cwd!, parseInitArgs(argv.slice(argv.indexOf('init') + 1))); | ||
| }, | ||
| ); | ||
|
|
||
| const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')); | ||
| expect(pkg.devEngines.packageManager).toEqual({ name: 'npm' }); | ||
| } finally { | ||
| rmSync(root, { recursive: true, force: true }); | ||
| } | ||
| }); | ||
|
|
||
| it('delegates to void init in a pnpm workspace member and forwards --no-install', async () => { | ||
| const root = mkdtempSync(join(tmpdir(), 'create-void-workspace-')); | ||
| try { | ||
| const appDirectory = join(root, 'apps', 'my-app'); | ||
| mkdirSync(appDirectory, { recursive: true }); | ||
| writeFileSync(join(root, 'package.json'), JSON.stringify({ name: 'fixture', private: true })); | ||
| writeFileSync( | ||
| join(root, 'pnpm-workspace.yaml'), | ||
| [ | ||
| '# Keep this workspace comment', | ||
| 'packages:', | ||
| ' - apps/*', | ||
| 'allowBuilds:', | ||
| ' esbuild: false # Keep this approval decision', | ||
| ' custom-build: true', | ||
| '', | ||
| ].join('\n'), | ||
| ); | ||
|
|
||
| let invoked = false; | ||
| await runVoidInit( | ||
| 'pnpm', | ||
| VOID_VERSION.version, | ||
| [ | ||
| '--toolchain', | ||
| 'vite', | ||
| '--framework', | ||
| 'react', | ||
| '--starter', | ||
| 'static', | ||
| '--deploy', | ||
| 'none', | ||
| '--no-install', | ||
| ], | ||
| appDirectory, | ||
| async (argv, cwd) => { | ||
| invoked = true; | ||
| expect(argv).toEqual([ | ||
| 'pnpm', | ||
| 'dlx', | ||
| `void@${VOID_VERSION.version}`, | ||
| 'init', | ||
| '--package-manager', | ||
| 'pnpm', | ||
| '--toolchain', | ||
| 'vite', | ||
| '--framework', | ||
| 'react', | ||
| '--starter', | ||
| 'static', | ||
| '--deploy', | ||
| 'none', | ||
| '--no-install', | ||
| ]); | ||
| expect(cwd).toBe(appDirectory); | ||
| await runInitCommand(cwd!, parseInitArgs(argv.slice(4))); | ||
| }, | ||
| ); | ||
| expect(invoked).toBe(true); | ||
|
|
||
| expect(existsSync(join(appDirectory, 'package.json'))).toBe(true); | ||
| expect(existsSync(join(appDirectory, 'pages', 'index.tsx'))).toBe(true); | ||
| expect(existsSync(join(appDirectory, 'pnpm-workspace.yaml'))).toBe(false); | ||
| expect(existsSync(join(appDirectory, 'pnpm-lock.yaml'))).toBe(false); | ||
| expect(existsSync(join(appDirectory, 'package-lock.json'))).toBe(false); | ||
| expect(existsSync(join(appDirectory, 'node_modules'))).toBe(false); | ||
|
|
||
| const updatedWorkspaceConfig = readFileSync(join(root, 'pnpm-workspace.yaml'), 'utf8'); | ||
| expect(updatedWorkspaceConfig).toContain('# Keep this workspace comment'); | ||
| expect(updatedWorkspaceConfig).toContain('esbuild: false # Keep this approval decision'); | ||
| expect(updatedWorkspaceConfig).toContain('custom-build: true'); | ||
| expect(updatedWorkspaceConfig).toContain('better-sqlite3: false'); | ||
| expect(updatedWorkspaceConfig).toContain('sharp: true'); | ||
| expect(updatedWorkspaceConfig).toContain('workerd: true'); | ||
| expect(existsSync(join(root, 'pnpm-lock.yaml'))).toBe(false); | ||
| } finally { | ||
| rmSync(root, { recursive: true, force: true }); | ||
| } | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.