create-nersh 0.1.6 → 0.3.0
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 +187 -0
- package/dist/index.mjs +169 -40
- package/package.json +4 -3
- package/templates/default-site.json +858 -0
- package/templates/next/app/globals.css +19 -0
- package/templates/next/components.json +23 -0
- package/templates/next/package.json.tmpl +5 -3
- package/templates/next/postcss.config.mjs +8 -0
- package/templates/next/site.json +0 -121
- package/templates/next/src/components/site/SafeEmbed.tsx +0 -72
- package/templates/next/src/components/site/SiteButton.tsx +0 -65
- package/templates/next/src/components/site/SiteCard.tsx +0 -46
- package/templates/next/src/components/site/SiteCodeBlock.tsx +0 -56
- package/templates/next/src/components/site/SiteHeading.tsx +0 -50
- package/templates/next/src/components/site/SiteMobileSlider.tsx +0 -71
- package/templates/next/src/components/site/SiteSectionShell.tsx +0 -91
- package/templates/next/src/components/site/SiteStructuralContext.tsx +0 -52
- package/templates/next/src/lib/brandContext.ts +0 -65
- package/templates/next/src/lib/codeBlock.ts +0 -76
- package/templates/next/src/lib/componentLibrary/providers/shadcn/components.ts +0 -146
- package/templates/next/src/lib/componentLibrary/resolveComponent.ts +0 -35
- package/templates/next/src/lib/componentLibrary/schema.ts +0 -219
- package/templates/next/src/lib/embeds/index.ts +0 -232
- package/templates/next/src/lib/humanize.ts +0 -58
- package/templates/next/src/lib/sectionItems.ts +0 -48
- package/templates/next/src/lib/sectionSurface.ts +0 -70
- package/templates/next/src/lib/utils.ts +0 -6
- package/templates/next/src/registry.ts +0 -16
- package/templates/next/src/sections/about/Component.tsx +0 -51
- package/templates/next/src/sections/about/index.ts +0 -7
- package/templates/next/src/sections/about/meta.ts +0 -8
- package/templates/next/src/sections/about/schema.ts +0 -38
- package/templates/next/src/sections/about/writeCopy.ts +0 -10
- package/templates/next/src/sections/copyHelpers.ts +0 -59
- package/templates/next/src/sections/features/Component.tsx +0 -122
- package/templates/next/src/sections/features/index.ts +0 -7
- package/templates/next/src/sections/features/meta.ts +0 -14
- package/templates/next/src/sections/features/schema.ts +0 -23
- package/templates/next/src/sections/features/writeCopy.ts +0 -18
- package/templates/next/src/sections/footer/Component.tsx +0 -103
- package/templates/next/src/sections/footer/index.ts +0 -7
- package/templates/next/src/sections/footer/meta.ts +0 -8
- package/templates/next/src/sections/footer/schema.ts +0 -39
- package/templates/next/src/sections/footer/writeCopy.ts +0 -31
- package/templates/next/src/sections/marketing-hero/Component.tsx +0 -187
- package/templates/next/src/sections/marketing-hero/index.ts +0 -7
- package/templates/next/src/sections/marketing-hero/meta.ts +0 -13
- package/templates/next/src/sections/marketing-hero/schema.ts +0 -106
- package/templates/next/src/sections/marketing-hero/writeCopy.ts +0 -18
- package/templates/next/src/sections/navbar/Component.tsx +0 -53
- package/templates/next/src/sections/navbar/index.ts +0 -7
- package/templates/next/src/sections/navbar/meta.ts +0 -8
- package/templates/next/src/sections/navbar/schema.ts +0 -50
- package/templates/next/src/sections/navbar/writeCopy.ts +0 -16
- package/templates/next/src/sections/pricing/Component.tsx +0 -125
- package/templates/next/src/sections/pricing/index.ts +0 -7
- package/templates/next/src/sections/pricing/meta.ts +0 -12
- package/templates/next/src/sections/pricing/schema.ts +0 -25
- package/templates/next/src/sections/pricing/writeCopy.ts +0 -22
- package/templates/next/src/sections/siteLayoutClasses.ts +0 -9
- package/templates/next/src/sections/types.ts +0 -119
package/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# create-nersh
|
|
2
|
+
|
|
3
|
+
Scaffold a shadcn project that pulls its sections from the `@nertia` registry. You own the code, you rent the renderer.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm create nersh@latest my-site
|
|
7
|
+
cd my-site
|
|
8
|
+
npm run dev
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The scaffolder installs your dependencies and then runs the shadcn CLI, so by the time it returns your sections are real files in `src/sections/`.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## What you get
|
|
16
|
+
|
|
17
|
+
A Next.js 15 project with:
|
|
18
|
+
|
|
19
|
+
- A `site.json` describing your layout: sections, skin, copy slots
|
|
20
|
+
- A `components.json` with `@nertia` registered, so `npx shadcn add @nertia/<anything>` works from day one
|
|
21
|
+
- The foundation, one theme and one item per section installed from the registry into `src/`
|
|
22
|
+
- A generated `src/registry.ts` mapping every section id in your `site.json` to its component
|
|
23
|
+
- `@nersh/render` as a thin runtime dep that resolves the skin, the tokens and the layout
|
|
24
|
+
- Tailwind v4 wired to scan the render package for class names
|
|
25
|
+
|
|
26
|
+
The default scaffold is the catalogue marketing page: header, hero, features, pricing, testimonials, FAQ, lead form, footer.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Flags
|
|
31
|
+
|
|
32
|
+
| Flag | Default | What it does |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| `--skin <id>` | the site's own `skinId`, else `zinc` | Overwrites `site.json`'s `skinId` and picks the `@nertia/theme-<id>` item |
|
|
35
|
+
| `--site <path>` | the bundled catalogue default | Scaffolds from your own `site.json` or a `.nertia.json` export |
|
|
36
|
+
| `--registry <url template>` | `https://ner.sh/r/{name}.json` | Where `@nertia` items are fetched from. Point it at a local server to test |
|
|
37
|
+
| `--render-package <spec>` | `^0.3.0` | Any npm spec, including a tarball path, for the `@nersh/render` dependency |
|
|
38
|
+
| `--no-install` | off | Skips `npm install` and the shadcn add. Prints the command to run yourself |
|
|
39
|
+
|
|
40
|
+
Valid skins: `zinc`, `slate`, `stone`, `gray`, `neutral`, `mauve`, `olive`, `mist`, `taupe`, `blue`, `green`, `orange`, `red`, `rose`, `violet`, `amber`, `yellow`, `lime`, `emerald`, `teal`, `cyan`, `sky`, `indigo`, `purple`, `fuchsia`, `pink`.
|
|
41
|
+
|
|
42
|
+
Only those have a `@nertia/theme-<id>` item. An invalid `--skin` is rejected outright; a `--site` file naming a non-preset skin (a client recipe skin, a design system builder id) falls back to `zinc` with a line in the summary, because a missing theme item would fail the whole `shadcn add` batch and install nothing.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Bring your own site
|
|
47
|
+
|
|
48
|
+
Export a site from nertia.ai and scaffold from it:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm create nersh@latest my-site -- --site ./my-site.nertia.json
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
A `.nertia.json` export and a renderer `site.json` are both accepted. The scaffolder normalizes the export into `site.json` (sections nest under `composition`) and writes it at the project root.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## What gets installed from the registry
|
|
59
|
+
|
|
60
|
+
For every section id in your `site.json`, the scaffolder runs:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx shadcn@latest add --yes --overwrite \
|
|
64
|
+
@nertia/foundation \
|
|
65
|
+
@nertia/theme-<skin> \
|
|
66
|
+
@nertia/<section id> ...
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- `@nertia/foundation` brings the shared primitives, the tokens and the layout classes
|
|
70
|
+
- `@nertia/theme-<skin>` writes the `:root`, `.dark` and `@theme inline` blocks into `app/globals.css`
|
|
71
|
+
- Each `@nertia/<section id>` copies that section into `src/sections/<id>/`
|
|
72
|
+
|
|
73
|
+
Every item lands under `src/`, which is why the template's `tsconfig.json` maps `@/*` to `./src/*`.
|
|
74
|
+
|
|
75
|
+
### Not yet portable
|
|
76
|
+
|
|
77
|
+
Only the foundation leaves (`block-*`) and wrappers (`layout-*`) are registry items today. A `site.json` that still uses a monolith section (`navbar`, `footer`, `marketing-hero`, `features`, `pricing`, `about`) gets a line like:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
Not yet portable (these sections stay hosted-only until the cutover): footer, navbar
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Those sections are skipped, not fatal. They stay out of `src/registry.ts` and keep rendering on nertia.ai until they are ported.
|
|
84
|
+
|
|
85
|
+
### Dark mode
|
|
86
|
+
|
|
87
|
+
`@nertia/theme-<skin>` writes its dark values under a `.dark` class, the shadcn convention. Hosted nertia.ai pages switch on `prefers-color-scheme` instead, so a scaffolded project renders light only until something adds `class="dark"` to `<html>` (by hand, or with a library like `next-themes`).
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Project structure
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
my-site/
|
|
95
|
+
├── app/
|
|
96
|
+
│ ├── globals.css # Tailwind v4 entry, tw-animate-css, @source for @nersh/render
|
|
97
|
+
│ ├── layout.tsx
|
|
98
|
+
│ └── page.tsx # <SiteRenderer site={site} registry={registry} />
|
|
99
|
+
├── src/
|
|
100
|
+
│ ├── registry.ts # Generated: section id to component
|
|
101
|
+
│ └── sections/ # Installed from @nertia. You own these files
|
|
102
|
+
├── components.json # shadcn config with the @nertia registry
|
|
103
|
+
├── site.json # Layout, skin, and copy for your site
|
|
104
|
+
├── package.json # Your name, @nersh/render, the shadcn CLI
|
|
105
|
+
├── next.config.ts
|
|
106
|
+
├── postcss.config.mjs # @tailwindcss/postcss, the Tailwind v4 pipeline
|
|
107
|
+
└── tsconfig.json # @/* maps to ./src/*, which is where registry files land
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Everything above `src/sections/` is written by the scaffolder. `src/sections/` arrives from the registry on the first `shadcn add`.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Customize
|
|
115
|
+
|
|
116
|
+
### Change the skin
|
|
117
|
+
|
|
118
|
+
Edit `site.json`, `skinId` field, then pull the matching theme:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npx shadcn@latest add --yes --overwrite @nertia/theme-rose
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Edit copy
|
|
125
|
+
|
|
126
|
+
Copy slots live in `site.json` under `"copy"`, keyed by instance id:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"copy": {
|
|
131
|
+
"hero-heading-d2.text": "Your headline here",
|
|
132
|
+
"hero-sub-d2.text": "Supporting copy",
|
|
133
|
+
"hero-cta-d2.label": "Get started"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Add a section
|
|
139
|
+
|
|
140
|
+
Add it to `composition.sections` in `site.json`, install the item, and add the mapping to `src/registry.ts`:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
npx shadcn@latest add --yes @nertia/block-quote
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Edit a section
|
|
147
|
+
|
|
148
|
+
Sections live in `src/sections/<id>/Component.tsx`. Edit directly. A registry update never touches them unless you ask for `--overwrite`.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Deploy to Vercel
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
npx vercel
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Next.js output works on any host.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Update @nersh/render
|
|
163
|
+
|
|
164
|
+
The renderer is a normal npm dep:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
npm update @nersh/render
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Your sections are never touched by an update. Only the renderer changes.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## How the render loop works
|
|
175
|
+
|
|
176
|
+
`@nersh/render` exports `SiteRenderer`. It reads your `site.json`, resolves each section from your `registry`, applies the skin tokens as CSS custom properties, and renders the layout. Your `globals.css` has one line that tells Tailwind to scan the render package so its utility classes are generated:
|
|
177
|
+
|
|
178
|
+
```css
|
|
179
|
+
@source "../node_modules/@nersh/render/dist";
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Related
|
|
185
|
+
|
|
186
|
+
- [`@nersh/render`](https://www.npmjs.com/package/@nersh/render) the renderer your project depends on
|
|
187
|
+
- [nertia.ai](https://nertia.ai) the browser-based builder that writes the same `site.json`
|
package/dist/index.mjs
CHANGED
|
@@ -5,12 +5,92 @@ import {
|
|
|
5
5
|
cpSync,
|
|
6
6
|
existsSync,
|
|
7
7
|
mkdirSync,
|
|
8
|
-
readFileSync,
|
|
8
|
+
readFileSync as readFileSync2,
|
|
9
9
|
readdirSync,
|
|
10
10
|
unlinkSync,
|
|
11
|
-
writeFileSync
|
|
11
|
+
writeFileSync as writeFileSync2
|
|
12
12
|
} from "fs";
|
|
13
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
14
|
+
import path2 from "path";
|
|
15
|
+
|
|
16
|
+
// src/registryFile.ts
|
|
17
|
+
function pascal(id) {
|
|
18
|
+
return id.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
19
|
+
}
|
|
20
|
+
function registryFileSource(ids, unported = []) {
|
|
21
|
+
const lines = [
|
|
22
|
+
`import type { SectionRegistry } from '@nersh/render';`,
|
|
23
|
+
...ids.map((id) => `import { Component as ${pascal(id)} } from '@/sections/${id}/Component';`),
|
|
24
|
+
"",
|
|
25
|
+
"export const registry: SectionRegistry = {",
|
|
26
|
+
...ids.map((id) => ` '${id}': ${pascal(id)},`),
|
|
27
|
+
"};"
|
|
28
|
+
];
|
|
29
|
+
if (unported.length > 0) {
|
|
30
|
+
lines.push("", `// Not yet portable (hosted only until the cutover): ${unported.join(", ")}`);
|
|
31
|
+
}
|
|
32
|
+
lines.push("");
|
|
33
|
+
return lines.join("\n");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/sectionIds.ts
|
|
37
|
+
function sectionIdsOf(site) {
|
|
38
|
+
const ids = /* @__PURE__ */ new Set();
|
|
39
|
+
const walk = (nodes) => {
|
|
40
|
+
for (const node of nodes) {
|
|
41
|
+
ids.add(node.id);
|
|
42
|
+
if (node.children) walk(node.children);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
walk(site.composition.sections);
|
|
46
|
+
return [...ids].sort();
|
|
47
|
+
}
|
|
48
|
+
function partitionIds(ids) {
|
|
49
|
+
const portable = ids.filter((id) => id.startsWith("block-") || id.startsWith("layout-")).sort();
|
|
50
|
+
const unported = ids.filter((id) => !portable.includes(id)).sort();
|
|
51
|
+
return { portable, unported };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/shadcn.ts
|
|
55
|
+
import { execFileSync } from "child_process";
|
|
56
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
13
57
|
import path from "path";
|
|
58
|
+
function shadcnAddArgs(items) {
|
|
59
|
+
return ["shadcn@latest", "add", "--yes", "--overwrite", ...items];
|
|
60
|
+
}
|
|
61
|
+
function writeComponentsJson(projectDir, registryUrl) {
|
|
62
|
+
const file = path.join(projectDir, "components.json");
|
|
63
|
+
const components = JSON.parse(readFileSync(file, "utf-8"));
|
|
64
|
+
components.registries = { ...components.registries, "@nertia": registryUrl };
|
|
65
|
+
writeFileSync(file, JSON.stringify(components, null, 2) + "\n");
|
|
66
|
+
}
|
|
67
|
+
function runShadcnAdd(projectDir, items, registryUrl) {
|
|
68
|
+
writeComponentsJson(projectDir, registryUrl);
|
|
69
|
+
execFileSync("npx", shadcnAddArgs(items), { cwd: projectDir, stdio: "inherit" });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/siteJson.ts
|
|
73
|
+
function isRenderSite(input) {
|
|
74
|
+
return typeof input === "object" && input !== null && "composition" in input && typeof input.composition?.id === "string";
|
|
75
|
+
}
|
|
76
|
+
function isExported(input) {
|
|
77
|
+
return typeof input === "object" && input !== null && Array.isArray(input.sections) && typeof input.slug === "string";
|
|
78
|
+
}
|
|
79
|
+
function toRenderSite(input) {
|
|
80
|
+
if (isRenderSite(input)) return input;
|
|
81
|
+
if (!isExported(input)) throw new Error("Expected a site.json or .nertia.json export");
|
|
82
|
+
return {
|
|
83
|
+
slug: input.slug,
|
|
84
|
+
mode: "builder",
|
|
85
|
+
status: "draft",
|
|
86
|
+
skinId: input.skinId ?? "zinc",
|
|
87
|
+
composition: { id: input.compositionId ?? input.slug, sections: input.sections },
|
|
88
|
+
copy: input.copy ?? {},
|
|
89
|
+
ds: input.ds ?? {}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/index.ts
|
|
14
94
|
var VALID_SKINS = [
|
|
15
95
|
"zinc",
|
|
16
96
|
"slate",
|
|
@@ -39,63 +119,112 @@ var VALID_SKINS = [
|
|
|
39
119
|
"fuchsia",
|
|
40
120
|
"pink"
|
|
41
121
|
];
|
|
122
|
+
var DEFAULT_REGISTRY = "https://ner.sh/r/{name}.json";
|
|
123
|
+
var DEFAULT_RENDER_PACKAGE = "^0.3.0";
|
|
124
|
+
var USAGE = "Usage: create-nersh <project-name> [--skin <id>] [--site <path>] [--registry <url template>] [--render-package <spec>] [--no-install]";
|
|
42
125
|
function die(msg) {
|
|
43
126
|
console.error(msg);
|
|
44
127
|
process.exit(1);
|
|
45
128
|
}
|
|
129
|
+
function readSite(sitePath) {
|
|
130
|
+
if (!existsSync(sitePath)) die(`No site file at ${sitePath}`);
|
|
131
|
+
try {
|
|
132
|
+
return toRenderSite(JSON.parse(readFileSync2(sitePath, "utf-8")));
|
|
133
|
+
} catch (err) {
|
|
134
|
+
return die(`Could not read ${sitePath}: ${err.message}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
46
137
|
function main() {
|
|
47
138
|
const args = process.argv.slice(2);
|
|
48
139
|
const flags = {};
|
|
140
|
+
let noInstall = false;
|
|
49
141
|
const positional = [];
|
|
50
142
|
for (let i = 0; i < args.length; i++) {
|
|
51
|
-
|
|
143
|
+
const arg = args[i];
|
|
144
|
+
if (arg === "--no-install") {
|
|
145
|
+
noInstall = true;
|
|
146
|
+
} else if (arg === "--skin" && args[i + 1]) {
|
|
52
147
|
flags.skin = args[++i];
|
|
53
|
-
} else if (args[i]
|
|
54
|
-
|
|
148
|
+
} else if (arg === "--site" && args[i + 1]) {
|
|
149
|
+
flags.site = args[++i];
|
|
150
|
+
} else if (arg === "--registry" && args[i + 1]) {
|
|
151
|
+
flags.registry = args[++i];
|
|
152
|
+
} else if (arg === "--render-package" && args[i + 1]) {
|
|
153
|
+
flags.renderPackage = args[++i];
|
|
154
|
+
} else if (arg.startsWith("--")) {
|
|
155
|
+
die(`Unknown flag: ${arg}
|
|
156
|
+
${USAGE}`);
|
|
55
157
|
} else {
|
|
56
|
-
positional.push(
|
|
158
|
+
positional.push(arg);
|
|
57
159
|
}
|
|
58
160
|
}
|
|
59
161
|
const projectName = positional[0];
|
|
60
|
-
if (!projectName) die(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
die(`Invalid skin "${skinId}". Valid skins: ${VALID_SKINS.join(", ")}`);
|
|
162
|
+
if (!projectName) die(USAGE);
|
|
163
|
+
if (flags.skin && !VALID_SKINS.includes(flags.skin)) {
|
|
164
|
+
die(`Invalid skin "${flags.skin}". Valid skins: ${VALID_SKINS.join(", ")}`);
|
|
64
165
|
}
|
|
166
|
+
const registryUrl = flags.registry ?? DEFAULT_REGISTRY;
|
|
167
|
+
const renderPackage = flags.renderPackage ?? DEFAULT_RENDER_PACKAGE;
|
|
65
168
|
const cwd = process.cwd();
|
|
66
|
-
const projectDir =
|
|
67
|
-
if (existsSync(projectDir)) {
|
|
68
|
-
|
|
69
|
-
if (entries.length > 0) {
|
|
70
|
-
die(`Directory "${projectName}" already exists and is not empty.`);
|
|
71
|
-
}
|
|
169
|
+
const projectDir = path2.resolve(cwd, projectName);
|
|
170
|
+
if (existsSync(projectDir) && readdirSync(projectDir).length > 0) {
|
|
171
|
+
die(`Directory "${projectName}" already exists and is not empty.`);
|
|
72
172
|
}
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
const tmplPath = path.join(projectDir, "package.json.tmpl");
|
|
77
|
-
const pkgContent = readFileSync(tmplPath, "utf-8").replace(
|
|
78
|
-
/\{\{PROJECT_NAME\}\}/g,
|
|
79
|
-
projectName
|
|
173
|
+
const templatesDir = path2.resolve(import.meta.dirname, "../templates");
|
|
174
|
+
const site = readSite(
|
|
175
|
+
flags.site ? path2.resolve(cwd, flags.site) : path2.join(templatesDir, "default-site.json")
|
|
80
176
|
);
|
|
81
|
-
|
|
177
|
+
if (flags.skin) site.skinId = flags.skin;
|
|
178
|
+
const requestedSkin = site.skinId || "zinc";
|
|
179
|
+
const skinIsPreset = VALID_SKINS.includes(requestedSkin);
|
|
180
|
+
const skinId = skinIsPreset ? requestedSkin : "zinc";
|
|
181
|
+
if (!skinIsPreset) site.skinId = skinId;
|
|
182
|
+
const { portable, unported } = partitionIds(sectionIdsOf(site));
|
|
183
|
+
const items = [
|
|
184
|
+
"@nertia/foundation",
|
|
185
|
+
`@nertia/theme-${skinId}`,
|
|
186
|
+
...portable.map((id) => `@nertia/${id}`)
|
|
187
|
+
];
|
|
188
|
+
mkdirSync(projectDir, { recursive: true });
|
|
189
|
+
cpSync(path2.join(templatesDir, "next"), projectDir, { recursive: true });
|
|
190
|
+
const tmplPath = path2.join(projectDir, "package.json.tmpl");
|
|
191
|
+
const pkgContent = readFileSync2(tmplPath, "utf-8").replace(/\{\{PROJECT_NAME\}\}/g, projectName).replace(/\{\{RENDER_PACKAGE\}\}/g, renderPackage);
|
|
192
|
+
writeFileSync2(path2.join(projectDir, "package.json"), pkgContent);
|
|
82
193
|
unlinkSync(tmplPath);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
194
|
+
writeFileSync2(path2.join(projectDir, "site.json"), JSON.stringify(site, null, 2) + "\n");
|
|
195
|
+
writeComponentsJson(projectDir, registryUrl);
|
|
196
|
+
mkdirSync(path2.join(projectDir, "src"), { recursive: true });
|
|
197
|
+
writeFileSync2(path2.join(projectDir, "src/registry.ts"), registryFileSource(portable, unported));
|
|
198
|
+
if (!noInstall) {
|
|
199
|
+
execFileSync2("npm", ["install"], { cwd: projectDir, stdio: "inherit" });
|
|
200
|
+
runShadcnAdd(projectDir, items, registryUrl);
|
|
88
201
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
npm
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
`);
|
|
202
|
+
const nextSteps = [` cd ${projectName}`];
|
|
203
|
+
if (noInstall) {
|
|
204
|
+
nextSteps.push(" npm install", ` npx ${shadcnAddArgs(items).join(" ")}`);
|
|
205
|
+
}
|
|
206
|
+
nextSteps.push(" npm run dev");
|
|
207
|
+
console.log("");
|
|
208
|
+
console.log(`Created ${projectName} at ${projectDir}`);
|
|
209
|
+
console.log("");
|
|
210
|
+
console.log(`Registry: ${registryUrl}`);
|
|
211
|
+
console.log(`Skin: ${skinId}`);
|
|
212
|
+
console.log(`Sections from @nertia (${portable.length}): ${portable.join(", ") || "none"}`);
|
|
213
|
+
if (!skinIsPreset) {
|
|
214
|
+
console.log(
|
|
215
|
+
`Skin "${requestedSkin}" is not a preset; the scaffold uses zinc (edit site.json to change it).`
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
if (unported.length > 0) {
|
|
219
|
+
console.log(
|
|
220
|
+
`Not yet portable (these sections stay hosted-only until the cutover): ${unported.join(", ")}`
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
console.log("");
|
|
224
|
+
console.log(nextSteps.join("\n"));
|
|
225
|
+
console.log("");
|
|
226
|
+
console.log("Your site renders at http://localhost:3000");
|
|
227
|
+
console.log("Sections land in src/sections/ from the registry. You own the code.");
|
|
228
|
+
console.log("Change the skin in site.json (skinId field).");
|
|
100
229
|
}
|
|
101
230
|
main();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-nersh",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Scaffold a
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Scaffold a shadcn project that pulls its sections from the @nertia registry",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "nersh <ps2pdx@gmail.com>",
|
|
7
7
|
"repository": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"files": ["dist", "templates"],
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "tsup"
|
|
20
|
+
"build": "tsup",
|
|
21
|
+
"prepublishOnly": "npm run build"
|
|
21
22
|
}
|
|
22
23
|
}
|