Skip to content

Commit 8f7095f

Browse files
committed
test(create): snap-test the bundled-monorepo create.defaultTemplate path
End-to-end coverage for the gated injection: scaffolding from a `monorepo: true` manifest entry must wire `create.defaultTemplate` back to the org scope, and must run the lifted git-init prompt. The new fixture ships a minimal `@your-org/create@1.0.0` tarball containing a `templates/workspace/` directory with a workspace-style `package.json`, `pnpm-workspace.yaml`, and a `vite.config.ts` that deliberately omits a `create:` block. The test runs `vp create @your-org:workspace --no-interactive --directory my-mono` through the shared `.shared/mock-npm-registry.mjs` and then asserts: - `my-mono/vite.config.ts` has `create: { defaultTemplate: "@your-org" }`, - `pnpm-workspace.yaml` survives `rewriteMonorepo` post-processing, - `my-mono/.git` exists (git-init unification covers this path).
1 parent dff1588 commit 8f7095f

4 files changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"@your-org/create": {
3+
"name": "@your-org/create",
4+
"dist-tags": { "latest": "1.0.0" },
5+
"versions": {
6+
"1.0.0": {
7+
"version": "1.0.0",
8+
"dist": {
9+
"tarball": "{REGISTRY}/@your-org/create/-/create-1.0.0.tgz",
10+
"integrity": "sha512-uIdfZ0qxDoaaESGePfk1CxcdTcfn91L2sqg0EQZelwxnPRFJRCLKaj12l95rXZdsV+e1wSL0XC+ZsKxhI95h+g=="
11+
},
12+
"createConfig": {
13+
"templates": [
14+
{
15+
"name": "workspace",
16+
"description": "Bundled monorepo workspace",
17+
"template": "./templates/workspace",
18+
"monorepo": true
19+
}
20+
]
21+
}
22+
}
23+
}
24+
}
25+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
> node $SNAP_CASES_DIR/.shared/mock-npm-registry.mjs -- vp create @your-org:workspace --no-interactive --directory my-mono # bundled monorepo: extract tarball, scaffold, inject create.defaultTemplate
2+
◇ Scaffolded my-mono
3+
• Node <semver> pnpm <semver>
4+
→ Next: cd my-mono && vp run
5+
6+
> cat my-mono/vite.config.ts # create.defaultTemplate auto-set to @your-org
7+
import { defineConfig } from "vite-plus";
8+
9+
export default defineConfig({
10+
staged: {
11+
"*": "vp check --fix",
12+
},
13+
create: { defaultTemplate: "@your-org" },
14+
fmt: {},
15+
lint: { options: { typeAware: true, typeCheck: true } },
16+
run: { cache: true },
17+
});
18+
19+
> cat my-mono/pnpm-workspace.yaml # workspace markers preserved
20+
packages:
21+
- apps/*
22+
- packages/*
23+
catalog:
24+
vite: npm:@voidzero-dev/vite-plus-core@latest
25+
vitest: npm:@voidzero-dev/vite-plus-test@latest
26+
vite-plus: latest
27+
overrides:
28+
vite: "catalog:"
29+
vitest: "catalog:"
30+
peerDependencyRules:
31+
allowAny:
32+
- vite
33+
- vitest
34+
allowedVersions:
35+
vite: "*"
36+
vitest: "*"
37+
38+
> test -d my-mono/.git && echo 'Git initialized' || echo 'No git' # git-init prompt covers bundled monorepo path
39+
Git initialized
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"commands": [
3+
"node $SNAP_CASES_DIR/.shared/mock-npm-registry.mjs -- vp create @your-org:workspace --no-interactive --directory my-mono # bundled monorepo: extract tarball, scaffold, inject create.defaultTemplate",
4+
"cat my-mono/vite.config.ts # create.defaultTemplate auto-set to @your-org",
5+
"cat my-mono/pnpm-workspace.yaml # workspace markers preserved",
6+
"test -d my-mono/.git && echo 'Git initialized' || echo 'No git' # git-init prompt covers bundled monorepo path"
7+
]
8+
}
Binary file not shown.

0 commit comments

Comments
 (0)