create-contractor-site 2.2.0 → 2.3.1
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 +144 -143
- package/bin/create-contractor-site.mjs +321 -321
- package/package.json +3 -3
- package/scripts/smoke-test.mjs +1819 -1210
- package/src/copy-template.mjs +296 -286
- package/src/prompts.mjs +461 -461
- package/src/replace-data.mjs +504 -504
- package/src/run-command.mjs +399 -399
- package/src/validate-target.mjs +96 -96
package/README.md
CHANGED
|
@@ -1,144 +1,145 @@
|
|
|
1
|
-
# create-contractor-site
|
|
2
|
-
|
|
3
|
-
Scaffold a client contractor website from the [website-multipages](https://github.com/glacayo/website-multipages) Astro template.
|
|
4
|
-
|
|
5
|
-
**Package version:** `2.
|
|
6
|
-
|
|
7
|
-
The CLI validates the target, copies the template, replaces placeholder values in `src/data/*.json`, installs with **pnpm**, validates data, builds, and initializes git **only after** success.
|
|
8
|
-
|
|
9
|
-
## What's new in 2.
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
1
|
+
# create-contractor-site
|
|
2
|
+
|
|
3
|
+
Scaffold a client contractor website from the [website-multipages](https://github.com/glacayo/website-multipages) Astro template.
|
|
4
|
+
|
|
5
|
+
**Package version:** `2.3.1` · **Default template ref:** `v2.3.1` (`CREATE_CONTRACTOR_TEMPLATE_REF`)
|
|
6
|
+
|
|
7
|
+
The CLI validates the target, copies the template, replaces placeholder values in `src/data/*.json`, installs with **pnpm**, validates data, builds, and initializes git **only after** success.
|
|
8
|
+
|
|
9
|
+
## What's new in 2.3.1
|
|
10
|
+
|
|
11
|
+
- **Supported Astro upgrade** — root `astro` range moved to `^7.3.2` with compatible `@lucide/astro`, `@tailwindcss/vite`, `alpinejs`, `tailwindcss`, `@astrojs/check`, `sharp` (`^0.35.4`), and `zod` refresh; lockfile and CLI smoke tests were updated together.
|
|
12
|
+
- **pnpm CI** — `.github/workflows/ci.yml` runs a frozen-lockfile install, `pnpm run build`, release-guard self-tests, and the capsule-free core CLI smoke on pull requests and `main`.
|
|
13
|
+
- **Trusted publishing infrastructure** — a manual `main`-only `publish.yml` release workflow with release identity/registry guards (`verify-release.mjs`, `test-release-guards.mjs`) and a `docs/releasing.md` runbook; the template root stays `private: true` so only this CLI package can publish.
|
|
14
|
+
- **Capsule-free smoke path** — `SKIP_CAPSULE_TESTS=1` runs the core suite without the optional `tools/smart-image/` capsule, and the smoke suite tolerates an absent capsule directory.
|
|
15
|
+
- **Template clone default** — published fallback uses git ref **`v2.3.1`** unless you set `CREATE_CONTRACTOR_TEMPLATE_ROOT` or `CREATE_CONTRACTOR_TEMPLATE_REF`.
|
|
16
|
+
|
|
17
|
+
Full release notes: repository root [`CHANGELOG.md`](../../CHANGELOG.md).
|
|
18
|
+
|
|
19
|
+
## Requirements
|
|
20
|
+
|
|
21
|
+
- **Node.js** 22+
|
|
22
|
+
- **pnpm** 11.1.2+
|
|
23
|
+
- **git**
|
|
24
|
+
|
|
25
|
+
## Quick start
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm create contractor-site my-client-site
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This downloads and runs `create-contractor-site` from npm. It is equivalent to the explicit `pnpm dlx` form below.
|
|
32
|
+
|
|
33
|
+
### Explicit command
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pnpm dlx create-contractor-site my-client-site
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Local / monorepo development
|
|
40
|
+
|
|
41
|
+
From a checkout of this repository:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
node ./packages/create-contractor-site/bin/create-contractor-site.mjs ../my-client-site
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
By default, the CLI prompts for client details. For a non-interactive smoke run, add `--yes`:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
node ./packages/create-contractor-site/bin/create-contractor-site.mjs --yes ../my-client-site
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Or use the published CLI while pointing it at a local template checkout:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
CREATE_CONTRACTOR_TEMPLATE_ROOT=/path/to/website-multipages \
|
|
57
|
+
pnpm dlx create-contractor-site my-client-site
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## What the CLI does
|
|
61
|
+
|
|
62
|
+
1. Checks that **pnpm** and **git** are available
|
|
63
|
+
2. Resolves the template source (see env vars below)
|
|
64
|
+
3. Validates the target directory and refuses targets equal to or inside the template root
|
|
64
65
|
4. Copies the template into the target directory (denylist excludes `node_modules`, `dist`, `.astro`, `.git`, `.codegraph`, `docs_trash`, `openspec`, `.atl`, `logs`, `*.log`, `.env*`, `package-lock.json`, and `packages/`)
|
|
65
|
-
5. Replaces **values only** in target `src/data/*.json` (schema/shape preserved)
|
|
66
|
-
6. Runs `pnpm install`
|
|
67
|
-
7. Runs `pnpm run validate:data`
|
|
68
|
-
8. Runs `pnpm run build`
|
|
69
|
-
9. Runs `git init` + initial commit **only after** validate and build succeed
|
|
70
|
-
|
|
71
|
-
If install, validate, or build fails, git init is skipped so a broken scaffold is never committed.
|
|
72
|
-
|
|
73
|
-
### After scaffold
|
|
74
|
-
|
|
75
|
-
In the generated client repo:
|
|
76
|
-
|
|
77
|
-
- Treat `src/data/business.json` and `src/data/site.json` as **authoritative client identity**
|
|
78
|
-
- Leftover masonry/hardscape services, blog posts, section copy, and demo assets are **expected seed content** — rewrite them for the real trade; do not treat them as a conflict
|
|
79
|
-
- Keep replacing **values/copy/assets only**; preserve JSON shape and `_instructions`
|
|
80
|
-
- Keep real client PII out of the shared template base (this repo)
|
|
81
|
-
|
|
82
|
-
See the template root `AGENTS.md`, `SKILL.md`, and `README.md` for the full agent/developer workflow. Finish client customization with `pnpm run validate:data` and `pnpm run build`.
|
|
83
|
-
|
|
84
|
-
## Environment variables
|
|
85
|
-
|
|
86
|
-
| Variable | Purpose |
|
|
87
|
-
|----------|---------|
|
|
88
|
-
| `CREATE_CONTRACTOR_SITE_ANSWERS_JSON` | JSON object with client answers for scripted/non-interactive scaffolds |
|
|
89
|
-
| `CREATE_CONTRACTOR_TEMPLATE_ROOT` | Path to a local template checkout (preferred for monorepo/dev) |
|
|
90
|
-
| `CREATE_CONTRACTOR_TEMPLATE_REPO` | Git URL for the published fallback clone (default: this template repo) |
|
|
91
|
-
| `CREATE_CONTRACTOR_TEMPLATE_REF` | Git branch/tag/ref to clone (default: `v2.
|
|
92
|
-
|
|
93
|
-
Template source precedence: `CREATE_CONTRACTOR_TEMPLATE_ROOT` → local monorepo discovery → temporary clone of repo @ ref.
|
|
94
|
-
|
|
95
|
-
### Scripted answers example
|
|
96
|
-
|
|
97
|
-
Trust, payment, hours, social, directory, and website-type fields may be omitted/blank — `buildAnswers` fills defaults. `--yes` omits them for the same parity (including `site_type: multipage`).
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
CREATE_CONTRACTOR_SITE_ANSWERS_JSON='{"businessName":"Acme Masonry","phone":"(757) 555-0199","email":"info@example.com","street":"123 Main St","city":"Virginia Beach","state":"VA","zip":"23451","serviceArea":"Virginia Beach, Norfolk, Chesapeake","primaryServices":["Masonry","Patios"]}' \
|
|
101
|
-
pnpm dlx create-contractor-site my-client-site
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Compact payment/hours/social/directories + website type:
|
|
105
|
-
|
|
106
|
-
```bash
|
|
107
|
-
CREATE_CONTRACTOR_SITE_ANSWERS_JSON='{"businessName":"Acme Masonry","primaryServices":["Masonry"],"paymentMethods":"Cash, Credit Card","hoursWeekday":"8:00 AM - 5:00 PM","hoursSaturday":"Closed","hoursSunday":"Closed","social":"facebook=https://facebook.com/acme,instagram=https://instagram.com/acme","directories":"Google Business|https://g.co/acme,BBB|https://bbb.org/acme","siteType":"one-page"}' \
|
|
108
|
-
pnpm dlx create-contractor-site my-client-site
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
All answer paths (`CREATE_CONTRACTOR_SITE_ANSWERS_JSON`, `--yes`, interactive) go through `buildAnswers`:
|
|
112
|
-
|
|
113
|
-
| Field | JSON key | Blank / omitted |
|
|
114
|
-
|-------|----------|-----------------|
|
|
115
|
-
| Free-estimate wording | `freeEstimate` | `Free On-Site Estimate` |
|
|
116
|
-
| Years of experience | `yearsExperience` | `10+` |
|
|
117
|
-
| License | `license` | `Licensed & Insured` |
|
|
118
|
-
| Insurance | `insurance` | Fully insured with general liability and workers' compensation. |
|
|
119
|
-
| Founded year (optional) | `foundedYear` | `""` — key always written; never removed |
|
|
120
|
-
| Payment methods | `paymentMethods` (CSV string or `string[]`) | `Cash`, `Check`, `Credit Card`, `Financing Available` — never `[]` |
|
|
121
|
-
| Business hours | `hours` (`[{days,time}]` ×3) or compact `hoursWeekday` / `hoursSaturday` / `hoursSunday` | Mon–Fri `7:00 AM - 6:00 PM`, Sat `8:00 AM - 2:00 PM`, Sun `Closed` |
|
|
122
|
-
| Social links | `social` (object or `network=url` CSV) | `{}`; blank keys omitted (`facebook`…`x`) |
|
|
123
|
-
| Directories | `directories` (`[{name,url}]` or `Name\|url` CSV) | none → ≥1 placeholder + `enable_directories: false` (never `[]`) |
|
|
124
|
-
| Website type | `siteType` (`one-page` \| `multipage` \| `seo`; aliases like `one page` / `single-page` / `multi page` / `multi` accepted) | `multipage` — always written to `site.json.site_type` as a canonical value |
|
|
125
|
-
|
|
126
|
-
## pnpm only
|
|
127
|
-
|
|
128
|
-
This project and the scaffolded client sites use **pnpm only**.
|
|
129
|
-
|
|
130
|
-
- Do **not** use `npm install` or `npx` for project setup
|
|
131
|
-
- Package runners (`pnpm create`, `pnpm dlx`) may start the binary; install/build inside the scaffold always use pnpm
|
|
132
|
-
|
|
133
|
-
## Options
|
|
134
|
-
|
|
135
|
-
```text
|
|
136
|
-
create-contractor-site [options] <target-dir>
|
|
137
|
-
|
|
138
|
-
-y, --yes Non-interactive mode with built-in sample answers
|
|
139
|
-
-h, --help Show help
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## License
|
|
143
|
-
|
|
144
|
-
ISC. See the [repository](https://github.com/glacayo/website-multipages) for full template documentation.
|
|
66
|
+
5. Replaces **values only** in target `src/data/*.json` (schema/shape preserved)
|
|
67
|
+
6. Runs `pnpm install`
|
|
68
|
+
7. Runs `pnpm run validate:data`
|
|
69
|
+
8. Runs `pnpm run build`
|
|
70
|
+
9. Runs `git init` + initial commit **only after** validate and build succeed
|
|
71
|
+
|
|
72
|
+
If install, validate, or build fails, git init is skipped so a broken scaffold is never committed.
|
|
73
|
+
|
|
74
|
+
### After scaffold
|
|
75
|
+
|
|
76
|
+
In the generated client repo:
|
|
77
|
+
|
|
78
|
+
- Treat `src/data/business.json` and `src/data/site.json` as **authoritative client identity**
|
|
79
|
+
- Leftover masonry/hardscape services, blog posts, section copy, and demo assets are **expected seed content** — rewrite them for the real trade; do not treat them as a conflict
|
|
80
|
+
- Keep replacing **values/copy/assets only**; preserve JSON shape and `_instructions`
|
|
81
|
+
- Keep real client PII out of the shared template base (this repo)
|
|
82
|
+
|
|
83
|
+
See the template root `AGENTS.md`, `SKILL.md`, and `README.md` for the full agent/developer workflow. Finish client customization with `pnpm run validate:data` and `pnpm run build`.
|
|
84
|
+
|
|
85
|
+
## Environment variables
|
|
86
|
+
|
|
87
|
+
| Variable | Purpose |
|
|
88
|
+
|----------|---------|
|
|
89
|
+
| `CREATE_CONTRACTOR_SITE_ANSWERS_JSON` | JSON object with client answers for scripted/non-interactive scaffolds |
|
|
90
|
+
| `CREATE_CONTRACTOR_TEMPLATE_ROOT` | Path to a local template checkout (preferred for monorepo/dev) |
|
|
91
|
+
| `CREATE_CONTRACTOR_TEMPLATE_REPO` | Git URL for the published fallback clone (default: this template repo) |
|
|
92
|
+
| `CREATE_CONTRACTOR_TEMPLATE_REF` | Git branch/tag/ref to clone (default: `v2.3.1`) |
|
|
93
|
+
|
|
94
|
+
Template source precedence: `CREATE_CONTRACTOR_TEMPLATE_ROOT` → local monorepo discovery → temporary clone of repo @ ref.
|
|
95
|
+
|
|
96
|
+
### Scripted answers example
|
|
97
|
+
|
|
98
|
+
Trust, payment, hours, social, directory, and website-type fields may be omitted/blank — `buildAnswers` fills defaults. `--yes` omits them for the same parity (including `site_type: multipage`).
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
CREATE_CONTRACTOR_SITE_ANSWERS_JSON='{"businessName":"Acme Masonry","phone":"(757) 555-0199","email":"info@example.com","street":"123 Main St","city":"Virginia Beach","state":"VA","zip":"23451","serviceArea":"Virginia Beach, Norfolk, Chesapeake","primaryServices":["Masonry","Patios"]}' \
|
|
102
|
+
pnpm dlx create-contractor-site my-client-site
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Compact payment/hours/social/directories + website type:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
CREATE_CONTRACTOR_SITE_ANSWERS_JSON='{"businessName":"Acme Masonry","primaryServices":["Masonry"],"paymentMethods":"Cash, Credit Card","hoursWeekday":"8:00 AM - 5:00 PM","hoursSaturday":"Closed","hoursSunday":"Closed","social":"facebook=https://facebook.com/acme,instagram=https://instagram.com/acme","directories":"Google Business|https://g.co/acme,BBB|https://bbb.org/acme","siteType":"one-page"}' \
|
|
109
|
+
pnpm dlx create-contractor-site my-client-site
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
All answer paths (`CREATE_CONTRACTOR_SITE_ANSWERS_JSON`, `--yes`, interactive) go through `buildAnswers`:
|
|
113
|
+
|
|
114
|
+
| Field | JSON key | Blank / omitted |
|
|
115
|
+
|-------|----------|-----------------|
|
|
116
|
+
| Free-estimate wording | `freeEstimate` | `Free On-Site Estimate` |
|
|
117
|
+
| Years of experience | `yearsExperience` | `10+` |
|
|
118
|
+
| License | `license` | `Licensed & Insured` |
|
|
119
|
+
| Insurance | `insurance` | Fully insured with general liability and workers' compensation. |
|
|
120
|
+
| Founded year (optional) | `foundedYear` | `""` — key always written; never removed |
|
|
121
|
+
| Payment methods | `paymentMethods` (CSV string or `string[]`) | `Cash`, `Check`, `Credit Card`, `Financing Available` — never `[]` |
|
|
122
|
+
| Business hours | `hours` (`[{days,time}]` ×3) or compact `hoursWeekday` / `hoursSaturday` / `hoursSunday` | Mon–Fri `7:00 AM - 6:00 PM`, Sat `8:00 AM - 2:00 PM`, Sun `Closed` |
|
|
123
|
+
| Social links | `social` (object or `network=url` CSV) | `{}`; blank keys omitted (`facebook`…`x`) |
|
|
124
|
+
| Directories | `directories` (`[{name,url}]` or `Name\|url` CSV) | none → ≥1 placeholder + `enable_directories: false` (never `[]`) |
|
|
125
|
+
| Website type | `siteType` (`one-page` \| `multipage` \| `seo`; aliases like `one page` / `single-page` / `multi page` / `multi` accepted) | `multipage` — always written to `site.json.site_type` as a canonical value |
|
|
126
|
+
|
|
127
|
+
## pnpm only
|
|
128
|
+
|
|
129
|
+
This project and the scaffolded client sites use **pnpm only**.
|
|
130
|
+
|
|
131
|
+
- Do **not** use `npm install` or `npx` for project setup
|
|
132
|
+
- Package runners (`pnpm create`, `pnpm dlx`) may start the binary; install/build inside the scaffold always use pnpm
|
|
133
|
+
|
|
134
|
+
## Options
|
|
135
|
+
|
|
136
|
+
```text
|
|
137
|
+
create-contractor-site [options] <target-dir>
|
|
138
|
+
|
|
139
|
+
-y, --yes Non-interactive mode with built-in sample answers
|
|
140
|
+
-h, --help Show help
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
ISC. See the [repository](https://github.com/glacayo/website-multipages) for full template documentation.
|