create-warlock 5.24.0 → 5.25.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/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ All notable changes to `create-warlock` are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
6
6
 
7
+ ## 5.25.0 - 2026-09-28
8
+
9
+ ### Changed
10
+
11
+ - The generated app's README is rewritten for the current template: `dev` / `build` / `start`, migrations, generators, the web stack vs API-only, `warlock add`, tests and the AI agent skills.
12
+ - The generated database config explains `autoGenerateId` and when to turn it off for an existing `_id`-only MongoDB.
13
+ - **Removed broken template scripts:** `gen.v` (called a command that doesn't exist), `gen.md` (duplicate of `gen.m`), `serve` (POSIX-only `nohup`, and tied to one package manager) and `lf` (needed `dos2unix`). Use `npm run build && npm run start` instead of `serve`.
14
+
15
+ ### Fixed
16
+
17
+ - `docs/new-module.md` in the generated app named `warlock create.module`; it is `warlock generate.module`.
18
+
7
19
  ## 5.24.0 - 2026-09-27
8
20
 
9
21
  ### Changed
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) Hassan Zohdy
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) Hassan Zohdy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,72 +1,72 @@
1
- # Create Warlock
2
-
3
- This package is used to generate a [Warlock.js](https://warlock.js.org) project.
4
-
5
- ## Usage
6
-
7
- Run the following command:
8
-
9
- ```bash
10
- npx create-warlock
11
- ```
12
-
13
- Or
14
-
15
- ```bash
16
- yarn create warlock
17
- ```
18
-
19
- Or
20
-
21
- ```bash
22
- pnpm create warlock
23
- ```
24
-
25
- Then follow the instructions, it is easy as that!
26
-
27
- ### Flags
28
-
29
- `create-warlock` is fully headless: every prompt has a flag that answers it,
30
- `--yes` takes the default for anything you leave unset, and it works with no
1
+ # Create Warlock
2
+
3
+ This package is used to generate a [Warlock.js](https://warlock.js.org) project.
4
+
5
+ ## Usage
6
+
7
+ Run the following command:
8
+
9
+ ```bash
10
+ npx create-warlock
11
+ ```
12
+
13
+ Or
14
+
15
+ ```bash
16
+ yarn create warlock
17
+ ```
18
+
19
+ Or
20
+
21
+ ```bash
22
+ pnpm create warlock
23
+ ```
24
+
25
+ Then follow the instructions, it is easy as that!
26
+
27
+ ### Flags
28
+
29
+ `create-warlock` is fully headless: every prompt has a flag that answers it,
30
+ `--yes` takes the default for anything you leave unset, and it works with no
31
31
  terminal at all (CI, a script, an agent). With a terminal and neither `--yes` nor `--interactive`, it asks for API-only
32
32
  or full-stack web, then for a database unless `--db` or `--no-db` already
33
33
  answered that choice. The stack is the only choice that changes the generated
34
34
  app's shape. Everything else below is a flag with a default; a summary of what
35
- was decided prints after scaffolding, along with how to change each one.
36
-
37
- | Flag | Description | Default |
38
- | --- | --- | --- |
39
- | `--name=<name>` | Project name (or the first positional arg) | required — prompted with a TTY, otherwise fails naming this flag |
40
- | `--stack=<api\|web>` | API-only or full-stack web; the structural choice | `api` |
41
- | `--db=<driver>` / `--no-db` | Database driver (`postgres`, `mongodb`, …), or skip one entirely | `mongodb` |
42
- | `--features=<list>` | Comma-separated feature keys (e.g. `test,herald`) | none (or `["web"]` when `--stack=web` and `--features` is not given) |
43
- | `--ai=<list>` | Comma-separated AI provider keys (e.g. `openai,anthropic`) | none |
44
- | `--pm=<manager>` | Package manager (`npm`, `yarn`, `pnpm`, `bun`) | inferred from the invoking agent (`npm_config_user_agent`) or the system |
45
- | `--agents=<list>` | Comma-separated [agent-kit](https://mongez.js.org/agent-kit) targets | `claude` |
46
- | `--git` / `--no-git` | Force-enable or force-disable git initialization | `false` |
47
- | `--jwt` / `--no-jwt` | Force-enable or force-disable JWT secret generation | `false` |
48
- | `-y`, `--yes` | Skip every prompt and take defaults for anything unset | `false` |
49
- | `--interactive`, `--customize` | Restore the full long-form interactive wizard | `false` |
50
- | `-h`, `--help` | Print usage (every flag + its default) and exit | — |
51
- | `-v`, `--version` | Print the installed version and exit | — |
52
-
53
- ```bash
54
- create-warlock my-app --db=postgres --features=test,herald --yes
55
- create-warlock --help # print every flag with its default, no scaffolding runs
56
- create-warlock --version # print the installed version and exit
57
- create-warlock my-app --interactive # the full long-form wizard, one prompt at a time
58
- ```
59
-
60
- `--help` and `--version` exit before any prompt, filesystem write, or network
61
- call — including before a positional project name or any other flag is
62
- honoured.
63
-
64
- `--agents` validates against the agent-kit targets published at
65
- [mongez.js.org/agent-kit/llms.txt](https://mongez.js.org/agent-kit/llms.txt)
66
- (cached locally after the first successful lookup); `claude`, the default,
67
- always works offline. An unrecognized target fails the run with the full list
68
- of valid targets rather than silently falling back.
69
-
35
+ was decided prints after scaffolding, along with how to change each one.
36
+
37
+ | Flag | Description | Default |
38
+ | --- | --- | --- |
39
+ | `--name=<name>` | Project name (or the first positional arg) | required — prompted with a TTY, otherwise fails naming this flag |
40
+ | `--stack=<api\|web>` | API-only or full-stack web; the structural choice | `api` |
41
+ | `--db=<driver>` / `--no-db` | Database driver (`postgres`, `mongodb`, …), or skip one entirely | `mongodb` |
42
+ | `--features=<list>` | Comma-separated feature keys (e.g. `test,herald`) | none (or `["web"]` when `--stack=web` and `--features` is not given) |
43
+ | `--ai=<list>` | Comma-separated AI provider keys (e.g. `openai,anthropic`) | none |
44
+ | `--pm=<manager>` | Package manager (`npm`, `yarn`, `pnpm`, `bun`) | inferred from the invoking agent (`npm_config_user_agent`) or the system |
45
+ | `--agents=<list>` | Comma-separated [agent-kit](https://mongez.js.org/agent-kit) targets | `claude` |
46
+ | `--git` / `--no-git` | Force-enable or force-disable git initialization | `false` |
47
+ | `--jwt` / `--no-jwt` | Force-enable or force-disable JWT secret generation | `false` |
48
+ | `-y`, `--yes` | Skip every prompt and take defaults for anything unset | `false` |
49
+ | `--interactive`, `--customize` | Restore the full long-form interactive wizard | `false` |
50
+ | `-h`, `--help` | Print usage (every flag + its default) and exit | — |
51
+ | `-v`, `--version` | Print the installed version and exit | — |
52
+
53
+ ```bash
54
+ create-warlock my-app --db=postgres --features=test,herald --yes
55
+ create-warlock --help # print every flag with its default, no scaffolding runs
56
+ create-warlock --version # print the installed version and exit
57
+ create-warlock my-app --interactive # the full long-form wizard, one prompt at a time
58
+ ```
59
+
60
+ `--help` and `--version` exit before any prompt, filesystem write, or network
61
+ call — including before a positional project name or any other flag is
62
+ honoured.
63
+
64
+ `--agents` validates against the agent-kit targets published at
65
+ [mongez.js.org/agent-kit/llms.txt](https://mongez.js.org/agent-kit/llms.txt)
66
+ (cached locally after the first successful lookup); `claude`, the default,
67
+ always works offline. An unrecognized target fails the run with the full list
68
+ of valid targets rather than silently falling back.
69
+
70
70
  ### Interactive database and AI choices
71
71
 
72
72
  The default interactive flow offers the same database choices as Customize:
@@ -83,45 +83,45 @@ conflict and asks for the AI choices again, keeping the non-**None** choices
83
83
  for correction. Headless `--ai` flags keep their existing provider/capability
84
84
  key behavior.
85
85
 
86
- ## Developing this package locally
87
-
88
- `bin/create-app.js` imports `../esm/index.mjs` — a build output, not the
89
- TypeScript source under `src/`. There is no `esm/` directory in the checkout,
90
- so **the local bin only works after a build has produced it.** Running
91
- `node bin/create-app.js` (or the linked `create-warlock` bin) against a fresh
92
- checkout fails with a module-not-found error until that build step has run.
93
- During development, use `npm run start` (`tsx ./index.dev.ts`), which runs the
94
- TypeScript source directly and needs no build.
95
-
96
- ### The manifest is rewritten at publish time — on purpose
97
-
98
- `package.json` in this checkout declares:
99
-
100
- - `"main"/"module"/"typings": "./src/index.ts"` — pointing at TypeScript
101
- source, not the compiled `esm/` output the published bin actually imports;
102
- - `"@warlock.js/fs": "*"` — a wildcard, not a real semver range.
103
-
104
- Neither is a bug. This package is published in lockstep with the rest of the
105
- `@warlock.js/*` family; the release tooling compiles `src/` to `esm/` and
106
- rewrites both the entry-point fields and every `@warlock.js/*` dependency to
107
- the version being released, as the last step before `npm publish`. Outside
108
- that tooling — i.e. everywhere in this checkout — those fields stay as
109
- source-pointers and wildcards deliberately, so local development never has to
110
- chase a version that has not been cut yet.
111
-
112
- **Coverage seam:** the rewrite itself lives in release tooling outside this
113
- package's write fence, so nothing under `specs/` exercises it. `specs/`
114
- proves the CLI's own behavior (flag parsing, `--help`/`--version`,
115
- `createNewApp` wiring); it does not — and cannot, from in here — assert that
116
- the publish step produces a correct `esm/index.mjs` or correctly rewritten
117
- dependency versions. That remains unresolved from this package's fence and
118
- should be verified against a real published (or `--install-links`) install,
119
- not from source.
120
-
121
- ## CI
122
-
123
- `.github/workflows/ci.yml` runs two jobs:
124
-
86
+ ## Developing this package locally
87
+
88
+ `bin/create-app.js` imports `../esm/index.mjs` — a build output, not the
89
+ TypeScript source under `src/`. There is no `esm/` directory in the checkout,
90
+ so **the local bin only works after a build has produced it.** Running
91
+ `node bin/create-app.js` (or the linked `create-warlock` bin) against a fresh
92
+ checkout fails with a module-not-found error until that build step has run.
93
+ During development, use `npm run start` (`tsx ./index.dev.ts`), which runs the
94
+ TypeScript source directly and needs no build.
95
+
96
+ ### The manifest is rewritten at publish time — on purpose
97
+
98
+ `package.json` in this checkout declares:
99
+
100
+ - `"main"/"module"/"typings": "./src/index.ts"` — pointing at TypeScript
101
+ source, not the compiled `esm/` output the published bin actually imports;
102
+ - `"@warlock.js/fs": "*"` — a wildcard, not a real semver range.
103
+
104
+ Neither is a bug. This package is published in lockstep with the rest of the
105
+ `@warlock.js/*` family; the release tooling compiles `src/` to `esm/` and
106
+ rewrites both the entry-point fields and every `@warlock.js/*` dependency to
107
+ the version being released, as the last step before `npm publish`. Outside
108
+ that tooling — i.e. everywhere in this checkout — those fields stay as
109
+ source-pointers and wildcards deliberately, so local development never has to
110
+ chase a version that has not been cut yet.
111
+
112
+ **Coverage seam:** the rewrite itself lives in release tooling outside this
113
+ package's write fence, so nothing under `specs/` exercises it. `specs/`
114
+ proves the CLI's own behavior (flag parsing, `--help`/`--version`,
115
+ `createNewApp` wiring); it does not — and cannot, from in here — assert that
116
+ the publish step produces a correct `esm/index.mjs` or correctly rewritten
117
+ dependency versions. That remains unresolved from this package's fence and
118
+ should be verified against a real published (or `--install-links`) install,
119
+ not from source.
120
+
121
+ ## CI
122
+
123
+ `.github/workflows/ci.yml` runs two jobs:
124
+
125
125
  - **`specs`** — on pushes to `main`/`master` and on pull requests: `node scripts/check-resolver-boundaries.mjs`
126
126
  (below), a smoke test that the built CLI's `--version` output matches `package.json`, then
127
127
  `npm run test:standalone`. This excludes only the source-bound template typecheck, which
@@ -131,25 +131,25 @@ not from source.
131
131
  it, and runs that project's own `tsc --noEmit` (`npm run typecheck:scaffold`; see the
132
132
  header of `scripts/typecheck-scaffold.mjs` for why this can't be done by typechecking
133
133
  `templates/warlock/` in place). This registry-backed consumer check remains mandatory.
134
-
135
- Both jobs also run nightly (`cron "0 4 * * *"`) and on `workflow_dispatch`, in addition to
136
- push/PR — `scaffold-typecheck` installs the framework from the registry, so a framework
137
- release alone can turn it red without anyone touching this repo, and the nightly run is what
138
- surfaces that the same day rather than when the next contributor happens to run it.
139
-
140
- ### Resolver-boundary check
141
-
142
- `scripts/check-resolver-boundaries.mjs` treats every `package.json` in the checkout as an
143
- independent publish boundary. It walks each package's `tsconfig.json` `compilerOptions.paths`
144
- and any `vite.config.*` / `vitest.config.*` alias, and fails (exit 1, one line per violation)
145
- if a target resolves outside that package's own directory. An alias inside the package (e.g.
146
- pointing `app/*` at its own `src/*`) is fine; one that reaches into a sibling checkout is not
147
- — it resolves in this monorepo today and breaks the moment the package is installed on its
148
- own, which nothing else here catches before publish. Run it directly with
149
- `node scripts/check-resolver-boundaries.mjs [root]` (defaults to this package's root); its
150
- pure logic is exported as `findResolverBoundaryViolations` and covered by
151
- `specs/resolver-boundaries.spec.ts`.
152
-
153
- ## License
154
-
155
- This project is licensed under the MIT License.
134
+
135
+ Both jobs also run nightly (`cron "0 4 * * *"`) and on `workflow_dispatch`, in addition to
136
+ push/PR — `scaffold-typecheck` installs the framework from the registry, so a framework
137
+ release alone can turn it red without anyone touching this repo, and the nightly run is what
138
+ surfaces that the same day rather than when the next contributor happens to run it.
139
+
140
+ ### Resolver-boundary check
141
+
142
+ `scripts/check-resolver-boundaries.mjs` treats every `package.json` in the checkout as an
143
+ independent publish boundary. It walks each package's `tsconfig.json` `compilerOptions.paths`
144
+ and any `vite.config.*` / `vitest.config.*` alias, and fails (exit 1, one line per violation)
145
+ if a target resolves outside that package's own directory. An alias inside the package (e.g.
146
+ pointing `app/*` at its own `src/*`) is fine; one that reaches into a sibling checkout is not
147
+ — it resolves in this monorepo today and breaks the moment the package is installed on its
148
+ own, which nothing else here catches before publish. Run it directly with
149
+ `node scripts/check-resolver-boundaries.mjs [root]` (defaults to this package's root); its
150
+ pure logic is exported as `findResolverBoundaryViolations` and covered by
151
+ `specs/resolver-boundaries.spec.ts`.
152
+
153
+ ## License
154
+
155
+ This project is licensed under the MIT License.
@@ -1 +1 @@
1
- {"version":3,"file":"get-app-path.mjs","names":["path"],"sources":["../../../../../../../create-warlock/src/commands/create-new-app/get-app-path.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport { directoryExists } from \"@warlock.js/fs\";\r\nimport * as path from \"path\";\r\n\r\nexport default function getAppPath(appName: string) {\r\n const appPath: string = path.resolve(process.cwd(), appName);\r\n\r\n if (directoryExists(appPath)) {\r\n console.log(\r\n colors.redBright(\r\n `${process.cwd()} has an existing directory \\`${colors.cyan(\r\n appName,\r\n )}\\`, please choose another app name or another directory to run the command from.`,\r\n ),\r\n );\r\n\r\n process.exit(1);\r\n }\r\n\r\n return appPath;\r\n}\r\n"],"mappings":";;;;;AAIA,SAAwB,WAAW,SAAiB;CAClD,MAAM,UAAkBA,OAAK,QAAQ,QAAQ,IAAI,GAAG,OAAO;CAE3D,IAAI,gBAAgB,OAAO,GAAG;EAC5B,QAAQ,IACN,OAAO,UACL,GAAG,QAAQ,IAAI,EAAE,+BAA+B,OAAO,KACrD,OACF,EAAE,iFACJ,CACF;EAEA,QAAQ,KAAK,CAAC;CAChB;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"get-app-path.mjs","names":["path"],"sources":["../../../../../../../create-warlock/src/commands/create-new-app/get-app-path.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { directoryExists } from \"@warlock.js/fs\";\nimport * as path from \"path\";\n\nexport default function getAppPath(appName: string) {\n const appPath: string = path.resolve(process.cwd(), appName);\n\n if (directoryExists(appPath)) {\n console.log(\n colors.redBright(\n `${process.cwd()} has an existing directory \\`${colors.cyan(\n appName,\n )}\\`, please choose another app name or another directory to run the command from.`,\n ),\n );\n\n process.exit(1);\n }\n\n return appPath;\n}\n"],"mappings":";;;;;AAIA,SAAwB,WAAW,SAAiB;CAClD,MAAM,UAAkBA,OAAK,QAAQ,QAAQ,IAAI,GAAG,OAAO;CAE3D,IAAI,gBAAgB,OAAO,GAAG;EAC5B,QAAQ,IACN,OAAO,UACL,GAAG,QAAQ,IAAI,EAAE,+BAA+B,OAAO,KACrD,OACF,EAAE,iFACJ,CACF;EAEA,QAAQ,KAAK,CAAC;CAChB;CAEA,OAAO;AACT"}
@@ -47,6 +47,12 @@ const features = [
47
47
  hint: "Runtime sitemap.xml generation from the page registry — requires app.publicUrl or PUBLIC_APP_URL (pulls web)",
48
48
  group: "Rendering & Mail"
49
49
  },
50
+ {
51
+ key: "devtools",
52
+ label: "Devtools (/__warlock)",
53
+ hint: "Development-only dashboard: request timeline, queries + EXPLAIN, N+1 warnings, dev mailbox, logs, cache, routes — installed as a dev dependency, never runs in production",
54
+ group: "Rendering & Mail"
55
+ },
50
56
  {
51
57
  key: "react",
52
58
  label: "React (rendering & mails)",
@@ -1 +1 @@
1
- {"version":3,"file":"features-map.mjs","names":[],"sources":["../../../../../../create-warlock/src/features/features-map.ts"],"sourcesContent":["/**\r\n * Presentation manifest for the scaffolder's feature prompts.\r\n *\r\n * This file is **display metadata only** — keys, labels, hints, grouping, and\r\n * default selections. It deliberately holds NO dependency names or versions:\r\n * the single source of truth for what each feature installs is the `add`\r\n * command's feature map in `@warlock.js/core`\r\n * (`src/generations/add-command.action.ts`). The scaffolder collects the\r\n * selections here and delegates the actual install to `warlock add`, so the\r\n * two never drift on versions again.\r\n *\r\n * Every `key` below MUST exist in core’s `allowedFeatures`. That guard now\r\n * EXISTS: `builder/scripts/check-feature-parity.ts`, run by every publishing\r\n * script in `builder/package.json`, so a release aborts before `pkgist` starts.\r\n * It could not live in this repo: this package deliberately does not depend on\r\n * `@warlock.js/core`, and our own CI checks out only this repo, so core’s keys\r\n * are not present here to compare against. `builder` sits above both and\r\n * imports each by relative path, adding no dependency edge in either direction.\r\n *\r\n * A subset assertion ALONE is not enough and has already let a\r\n * bug ship: `--features=web,tailwind` was rejected with \"Unknown feature(s):\r\n * tailwind\" because `tailwind` and `shadcn` existed in core and were missing\r\n * from THIS file — a direction a scaffolder ⊆ core check cannot see. The guard\r\n * has to run both ways:\r\n *\r\n * 1. scaffolder ⊆ core — catches a typo or a key core renamed.\r\n * 2. core ⊆ scaffolder + an explicit omission list — catches a feature core\r\n * gained that never became scaffoldable.\r\n *\r\n * The two lists are not equal and should not be forced to be. As of this\r\n * writing core holds 28 keys and this file offers 24; the other four are\r\n * deliberate and are the entire allow-list direction (2) needs:\r\n * `mongodb`, `postgres`, `mysql` (the database driver has its own select) and\r\n * `ai` (pulled automatically by every `ai-*` key's `requires`). Anything beyond\r\n * those four is a gap, not a decision, and should fail the build.\r\n */\r\n\r\nexport type FeatureGroup =\r\n | \"Auth & Access\"\r\n | \"Rendering & Mail\"\r\n | \"Media\"\r\n | \"Storage & Cache\"\r\n | \"Jobs & Messaging\"\r\n | \"Realtime\"\r\n | \"API Docs\"\r\n | \"Tooling\";\r\n\r\nexport type FeatureOption = {\r\n /** Must match a key in core's `add` feature map. */\r\n key: string;\r\n label: string;\r\n hint: string;\r\n group: FeatureGroup;\r\n defaultSelected?: boolean;\r\n};\r\n\r\n/**\r\n * Optional features offered in the general multiselect step. The database\r\n * driver (its own select) and AI providers + capability packages (their own\r\n * step) are intentionally NOT here — they have dedicated prompts.\r\n */\r\nexport const features: FeatureOption[] = [\r\n // Auth & Access\r\n {\r\n key: \"access\",\r\n label: \"Access (authorization)\",\r\n hint: \"RBAC permission checks, ABAC policies, and roles — pairs with auth\",\r\n group: \"Auth & Access\",\r\n },\r\n {\r\n key: \"auth-google\",\r\n label: \"Google sign-in\",\r\n hint: \"Google OAuth sign-in for @warlock.js/auth\",\r\n group: \"Auth & Access\",\r\n },\r\n {\r\n key: \"auth-passkeys\",\r\n label: \"Passkey sign-in\",\r\n hint: \"WebAuthn passkey login for @warlock.js/auth\",\r\n group: \"Auth & Access\",\r\n },\r\n\r\n // Rendering & Mail\r\n {\r\n key: \"web\",\r\n label: \"Web (SSR React pages)\",\r\n hint: \"Server-rendered React pages on the same server as your API — scaffolds src/web and registers the connector\",\r\n group: \"Rendering & Mail\",\r\n },\r\n {\r\n key: \"tailwind\",\r\n label: \"Tailwind CSS\",\r\n hint: \"Tailwind v4 for the SSR page layer — creates src/web/app.css (the CSS-first config) and wires it through Vite (pulls web)\",\r\n group: \"Rendering & Mail\",\r\n },\r\n {\r\n key: \"shadcn\",\r\n label: \"shadcn/ui prerequisites\",\r\n hint: \"components.json, cn(), design tokens, and the web/* tsconfig path so `npx shadcn add <component>` works first time (pulls tailwind)\",\r\n group: \"Rendering & Mail\",\r\n },\r\n {\r\n key: \"sitemap\",\r\n label: \"Sitemap\",\r\n hint: \"Runtime sitemap.xml generation from the page registry — requires app.publicUrl or PUBLIC_APP_URL (pulls web)\",\r\n group: \"Rendering & Mail\",\r\n },\r\n {\r\n key: \"react\",\r\n label: \"React (rendering & mails)\",\r\n hint: \"React + ReactDOM for non-interactive rendering and HTML/email generation\",\r\n group: \"Rendering & Mail\",\r\n defaultSelected: true,\r\n },\r\n {\r\n key: \"react-email\",\r\n label: \"React Email\",\r\n hint: \"Build email templates with React + Tailwind (pulls react + mail)\",\r\n group: \"Rendering & Mail\",\r\n },\r\n {\r\n key: \"mail\",\r\n label: \"Mail (Nodemailer)\",\r\n hint: \"Send emails via SMTP\",\r\n group: \"Rendering & Mail\",\r\n },\r\n {\r\n key: \"ses\",\r\n label: \"Amazon SES\",\r\n hint: \"Send emails via the AWS SES API\",\r\n group: \"Rendering & Mail\",\r\n },\r\n\r\n // Media\r\n {\r\n key: \"image\",\r\n label: \"Image processing (Sharp)\",\r\n hint: \"Resize, convert, and optimize images\",\r\n group: \"Media\",\r\n },\r\n\r\n // Storage & Cache\r\n {\r\n key: \"s3\",\r\n label: \"S3 storage\",\r\n hint: \"AWS S3 for cloud file storage\",\r\n group: \"Storage & Cache\",\r\n },\r\n {\r\n key: \"redis\",\r\n label: \"Redis cache\",\r\n hint: \"Redis driver for the cache layer\",\r\n group: \"Storage & Cache\",\r\n },\r\n\r\n // Jobs & Messaging\r\n {\r\n key: \"scheduler\",\r\n label: \"Scheduler\",\r\n hint: \"Background tasks and cron jobs\",\r\n group: \"Jobs & Messaging\",\r\n },\r\n {\r\n key: \"queue\",\r\n label: \"Queue (BullMQ)\",\r\n hint: \"Durable Redis-backed background jobs with retries and workers\",\r\n group: \"Jobs & Messaging\",\r\n },\r\n {\r\n key: \"bull-board\",\r\n label: \"Bull Board (queue dashboard)\",\r\n hint: \"Web dashboard for inspecting queues and jobs — enabled outside production only, and refuses to mount unguarded (pulls queue)\",\r\n group: \"Jobs & Messaging\",\r\n },\r\n {\r\n key: \"herald\",\r\n label: \"Herald (RabbitMQ)\",\r\n hint: \"Message broker for event-driven architecture\",\r\n group: \"Jobs & Messaging\",\r\n },\r\n {\r\n key: \"notifications\",\r\n label: \"Notifications\",\r\n hint: \"Multi-channel notifications — mail + in-app database, preferences, idempotency\",\r\n group: \"Jobs & Messaging\",\r\n },\r\n\r\n // Realtime\r\n {\r\n key: \"socket\",\r\n label: \"Socket.IO\",\r\n hint: \"Realtime websocket server\",\r\n group: \"Realtime\",\r\n },\r\n\r\n // API Docs (swagger / postman / openapi) — not shipped yet; they will arrive\r\n // together in the unified @warlock.js/api-docs package. Re-add the selection\r\n // once that package exists. (Removed so the wizard can't offer unbuilt features.)\r\n\r\n // Tooling\r\n {\r\n key: \"test\",\r\n label: \"Testing (Vitest)\",\r\n hint: \"Vitest + coverage + per-worker DB/cache test setup\",\r\n group: \"Tooling\",\r\n },\r\n];\r\n\r\nexport type AiProviderOption = {\r\n /** Must match a provider/package key in core's `add` feature map. */\r\n key: string;\r\n label: string;\r\n hint: string;\r\n};\r\n\r\n/**\r\n * AI providers offered in the dedicated AI step. Selecting any of these pulls\r\n * the core `@warlock.js/ai` package automatically via the provider's `requires`\r\n * in core's feature map — the scaffolder never lists `ai` as a standalone pick.\r\n *\r\n * Keys are `ai-`prefixed to mirror core's renamed provider feature keys\r\n * (`ai-openai` → `@warlock.js/ai-openai`, etc.).\r\n */\r\nexport const aiProviders: AiProviderOption[] = [\r\n { key: \"ai-openai\", label: \"OpenAI\", hint: \"GPT models via the OpenAI API\" },\r\n {\r\n key: \"ai-google\",\r\n label: \"Google (Gemini)\",\r\n hint: \"Gemini models via Google AI\",\r\n },\r\n {\r\n key: \"ai-anthropic\",\r\n label: \"Anthropic (Claude)\",\r\n hint: \"Claude models via the Anthropic API\",\r\n },\r\n {\r\n key: \"ai-bedrock\",\r\n label: \"AWS Bedrock\",\r\n hint: \"Foundation models via Amazon Bedrock\",\r\n },\r\n { key: \"ai-ollama\", label: \"Ollama\", hint: \"Local models via Ollama\" },\r\n];\r\n\r\n/**\r\n * AI capability packages offered alongside the providers in the dedicated AI\r\n * step. These are the satellite packages that sit on top of the core\r\n * `@warlock.js/ai` toolkit (each pulls the core `ai` package via its `requires`\r\n * in core's feature map, same as the providers).\r\n */\r\nexport const aiPackages: AiProviderOption[] = [\r\n {\r\n key: \"ai-tools\",\r\n label: \"AI Tools\",\r\n hint: \"Ready-made agent tools (web search, fetch, HTTP, calculator, date-time) + MCP client/server\",\r\n },\r\n {\r\n key: \"ai-panoptic\",\r\n label: \"AI Observability (Panoptic)\",\r\n hint: \"Tracing + exporters + a zero-setup local dashboard\",\r\n },\r\n {\r\n key: \"ai-workspace\",\r\n label: \"AI Workspace\",\r\n hint: \"Policy-jailed filesystem + shell for coding agents\",\r\n },\r\n];\r\n\r\n/**\r\n * Feature options for the multiselect prompt, ordered by group with the group\r\n * surfaced in the hint (keeps a flat list scannable without group widgets).\r\n */\r\nexport function getFeatureOptions() {\r\n return features.map(feature => ({\r\n value: feature.key,\r\n label: feature.label,\r\n hint: `${feature.group} — ${feature.hint}`,\r\n }));\r\n}\r\n\r\n/**\r\n * Keys pre-checked in the feature multiselect.\r\n */\r\nexport function getDefaultFeatureKeys(): string[] {\r\n return features\r\n .filter(feature => feature.defaultSelected)\r\n .map(feature => feature.key);\r\n}\r\n\r\n/**\r\n * AI provider options for the dedicated AI multiselect step.\r\n */\r\nexport function getAiProviderOptions() {\r\n return aiProviders.map(provider => ({\r\n value: provider.key,\r\n label: provider.label,\r\n hint: provider.hint,\r\n }));\r\n}\r\n\r\n/**\r\n * AI capability package options for the dedicated AI multiselect step. Offered\r\n * together with the providers (see `getAiProviderOptions`).\r\n */\r\nexport function getAiPackageOptions() {\r\n return aiPackages.map(pkg => ({\r\n value: pkg.key,\r\n label: pkg.label,\r\n hint: pkg.hint,\r\n }));\r\n}\r\n\r\n/**\r\n * Every selectable key the scaffolder knows about (features + AI providers +\r\n * AI capability packages). Used to validate `--features` / `--ai` flags in\r\n * non-interactive mode.\r\n */\r\nexport function getAllFeatureKeys(): string[] {\r\n return [\r\n ...features.map(feature => feature.key),\r\n ...aiProviders.map(provider => provider.key),\r\n ...aiPackages.map(pkg => pkg.key),\r\n ];\r\n}\r\n"],"mappings":";;;;;;AA6DA,MAAa,WAA4B;CAEvC;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CAGA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;EACP,iBAAiB;CACnB;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CAGA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CAGA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CAGA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CAGA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CAOA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;AACF;;;;;;;;;AAiBA,MAAa,cAAkC;CAC7C;EAAE,KAAK;EAAa,OAAO;EAAU,MAAM;CAAgC;CAC3E;EACE,KAAK;EACL,OAAO;EACP,MAAM;CACR;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;CACR;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;CACR;CACA;EAAE,KAAK;EAAa,OAAO;EAAU,MAAM;CAA0B;AACvE;;;;;;;AAQA,MAAa,aAAiC;CAC5C;EACE,KAAK;EACL,OAAO;EACP,MAAM;CACR;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;CACR;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;CACR;AACF;;;;;AAMA,SAAgB,oBAAoB;CAClC,OAAO,SAAS,KAAI,aAAY;EAC9B,OAAO,QAAQ;EACf,OAAO,QAAQ;EACf,MAAM,GAAG,QAAQ,MAAM,KAAK,QAAQ;CACtC,EAAE;AACJ;;;;AAKA,SAAgB,wBAAkC;CAChD,OAAO,SACJ,QAAO,YAAW,QAAQ,eAAe,CAAC,CAC1C,KAAI,YAAW,QAAQ,GAAG;AAC/B;;;;AAKA,SAAgB,uBAAuB;CACrC,OAAO,YAAY,KAAI,cAAa;EAClC,OAAO,SAAS;EAChB,OAAO,SAAS;EAChB,MAAM,SAAS;CACjB,EAAE;AACJ;;;;;AAMA,SAAgB,sBAAsB;CACpC,OAAO,WAAW,KAAI,SAAQ;EAC5B,OAAO,IAAI;EACX,OAAO,IAAI;EACX,MAAM,IAAI;CACZ,EAAE;AACJ;;;;;;AAOA,SAAgB,oBAA8B;CAC5C,OAAO;EACL,GAAG,SAAS,KAAI,YAAW,QAAQ,GAAG;EACtC,GAAG,YAAY,KAAI,aAAY,SAAS,GAAG;EAC3C,GAAG,WAAW,KAAI,QAAO,IAAI,GAAG;CAClC;AACF"}
1
+ {"version":3,"file":"features-map.mjs","names":[],"sources":["../../../../../../create-warlock/src/features/features-map.ts"],"sourcesContent":["/**\n * Presentation manifest for the scaffolder's feature prompts.\n *\n * This file is **display metadata only** — keys, labels, hints, grouping, and\n * default selections. It deliberately holds NO dependency names or versions:\n * the single source of truth for what each feature installs is the `add`\n * command's feature map in `@warlock.js/core`\n * (`src/generations/add-command.action.ts`). The scaffolder collects the\n * selections here and delegates the actual install to `warlock add`, so the\n * two never drift on versions again.\n *\n * Every `key` below MUST exist in core’s `allowedFeatures`. That guard now\n * EXISTS: `builder/scripts/check-feature-parity.ts`, run by every publishing\n * script in `builder/package.json`, so a release aborts before `pkgist` starts.\n * It could not live in this repo: this package deliberately does not depend on\n * `@warlock.js/core`, and our own CI checks out only this repo, so core’s keys\n * are not present here to compare against. `builder` sits above both and\n * imports each by relative path, adding no dependency edge in either direction.\n *\n * A subset assertion ALONE is not enough and has already let a\n * bug ship: `--features=web,tailwind` was rejected with \"Unknown feature(s):\n * tailwind\" because `tailwind` and `shadcn` existed in core and were missing\n * from THIS file — a direction a scaffolder ⊆ core check cannot see. The guard\n * has to run both ways:\n *\n * 1. scaffolder ⊆ core — catches a typo or a key core renamed.\n * 2. core ⊆ scaffolder + an explicit omission list — catches a feature core\n * gained that never became scaffoldable.\n *\n * The two lists are not equal and should not be forced to be. As of this\n * writing core holds 28 keys and this file offers 24; the other four are\n * deliberate and are the entire allow-list direction (2) needs:\n * `mongodb`, `postgres`, `mysql` (the database driver has its own select) and\n * `ai` (pulled automatically by every `ai-*` key's `requires`). Anything beyond\n * those four is a gap, not a decision, and should fail the build.\n */\n\nexport type FeatureGroup =\n | \"Auth & Access\"\n | \"Rendering & Mail\"\n | \"Media\"\n | \"Storage & Cache\"\n | \"Jobs & Messaging\"\n | \"Realtime\"\n | \"API Docs\"\n | \"Tooling\";\n\nexport type FeatureOption = {\n /** Must match a key in core's `add` feature map. */\n key: string;\n label: string;\n hint: string;\n group: FeatureGroup;\n defaultSelected?: boolean;\n};\n\n/**\n * Optional features offered in the general multiselect step. The database\n * driver (its own select) and AI providers + capability packages (their own\n * step) are intentionally NOT here — they have dedicated prompts.\n */\nexport const features: FeatureOption[] = [\n // Auth & Access\n {\n key: \"access\",\n label: \"Access (authorization)\",\n hint: \"RBAC permission checks, ABAC policies, and roles — pairs with auth\",\n group: \"Auth & Access\",\n },\n {\n key: \"auth-google\",\n label: \"Google sign-in\",\n hint: \"Google OAuth sign-in for @warlock.js/auth\",\n group: \"Auth & Access\",\n },\n {\n key: \"auth-passkeys\",\n label: \"Passkey sign-in\",\n hint: \"WebAuthn passkey login for @warlock.js/auth\",\n group: \"Auth & Access\",\n },\n\n // Rendering & Mail\n {\n key: \"web\",\n label: \"Web (SSR React pages)\",\n hint: \"Server-rendered React pages on the same server as your API — scaffolds src/web and registers the connector\",\n group: \"Rendering & Mail\",\n },\n {\n key: \"tailwind\",\n label: \"Tailwind CSS\",\n hint: \"Tailwind v4 for the SSR page layer — creates src/web/app.css (the CSS-first config) and wires it through Vite (pulls web)\",\n group: \"Rendering & Mail\",\n },\n {\n key: \"shadcn\",\n label: \"shadcn/ui prerequisites\",\n hint: \"components.json, cn(), design tokens, and the web/* tsconfig path so `npx shadcn add <component>` works first time (pulls tailwind)\",\n group: \"Rendering & Mail\",\n },\n {\n key: \"sitemap\",\n label: \"Sitemap\",\n hint: \"Runtime sitemap.xml generation from the page registry — requires app.publicUrl or PUBLIC_APP_URL (pulls web)\",\n group: \"Rendering & Mail\",\n },\n {\n key: \"devtools\",\n label: \"Devtools (/__warlock)\",\n hint: \"Development-only dashboard: request timeline, queries + EXPLAIN, N+1 warnings, dev mailbox, logs, cache, routes — installed as a dev dependency, never runs in production\",\n group: \"Rendering & Mail\",\n },\n {\n key: \"react\",\n label: \"React (rendering & mails)\",\n hint: \"React + ReactDOM for non-interactive rendering and HTML/email generation\",\n group: \"Rendering & Mail\",\n defaultSelected: true,\n },\n {\n key: \"react-email\",\n label: \"React Email\",\n hint: \"Build email templates with React + Tailwind (pulls react + mail)\",\n group: \"Rendering & Mail\",\n },\n {\n key: \"mail\",\n label: \"Mail (Nodemailer)\",\n hint: \"Send emails via SMTP\",\n group: \"Rendering & Mail\",\n },\n {\n key: \"ses\",\n label: \"Amazon SES\",\n hint: \"Send emails via the AWS SES API\",\n group: \"Rendering & Mail\",\n },\n\n // Media\n {\n key: \"image\",\n label: \"Image processing (Sharp)\",\n hint: \"Resize, convert, and optimize images\",\n group: \"Media\",\n },\n\n // Storage & Cache\n {\n key: \"s3\",\n label: \"S3 storage\",\n hint: \"AWS S3 for cloud file storage\",\n group: \"Storage & Cache\",\n },\n {\n key: \"redis\",\n label: \"Redis cache\",\n hint: \"Redis driver for the cache layer\",\n group: \"Storage & Cache\",\n },\n\n // Jobs & Messaging\n {\n key: \"scheduler\",\n label: \"Scheduler\",\n hint: \"Background tasks and cron jobs\",\n group: \"Jobs & Messaging\",\n },\n {\n key: \"queue\",\n label: \"Queue (BullMQ)\",\n hint: \"Durable Redis-backed background jobs with retries and workers\",\n group: \"Jobs & Messaging\",\n },\n {\n key: \"bull-board\",\n label: \"Bull Board (queue dashboard)\",\n hint: \"Web dashboard for inspecting queues and jobs — enabled outside production only, and refuses to mount unguarded (pulls queue)\",\n group: \"Jobs & Messaging\",\n },\n {\n key: \"herald\",\n label: \"Herald (RabbitMQ)\",\n hint: \"Message broker for event-driven architecture\",\n group: \"Jobs & Messaging\",\n },\n {\n key: \"notifications\",\n label: \"Notifications\",\n hint: \"Multi-channel notifications — mail + in-app database, preferences, idempotency\",\n group: \"Jobs & Messaging\",\n },\n\n // Realtime\n {\n key: \"socket\",\n label: \"Socket.IO\",\n hint: \"Realtime websocket server\",\n group: \"Realtime\",\n },\n\n // API Docs (swagger / postman / openapi) — not shipped yet; they will arrive\n // together in the unified @warlock.js/api-docs package. Re-add the selection\n // once that package exists. (Removed so the wizard can't offer unbuilt features.)\n\n // Tooling\n {\n key: \"test\",\n label: \"Testing (Vitest)\",\n hint: \"Vitest + coverage + per-worker DB/cache test setup\",\n group: \"Tooling\",\n },\n];\n\nexport type AiProviderOption = {\n /** Must match a provider/package key in core's `add` feature map. */\n key: string;\n label: string;\n hint: string;\n};\n\n/**\n * AI providers offered in the dedicated AI step. Selecting any of these pulls\n * the core `@warlock.js/ai` package automatically via the provider's `requires`\n * in core's feature map — the scaffolder never lists `ai` as a standalone pick.\n *\n * Keys are `ai-`prefixed to mirror core's renamed provider feature keys\n * (`ai-openai` → `@warlock.js/ai-openai`, etc.).\n */\nexport const aiProviders: AiProviderOption[] = [\n { key: \"ai-openai\", label: \"OpenAI\", hint: \"GPT models via the OpenAI API\" },\n {\n key: \"ai-google\",\n label: \"Google (Gemini)\",\n hint: \"Gemini models via Google AI\",\n },\n {\n key: \"ai-anthropic\",\n label: \"Anthropic (Claude)\",\n hint: \"Claude models via the Anthropic API\",\n },\n {\n key: \"ai-bedrock\",\n label: \"AWS Bedrock\",\n hint: \"Foundation models via Amazon Bedrock\",\n },\n { key: \"ai-ollama\", label: \"Ollama\", hint: \"Local models via Ollama\" },\n];\n\n/**\n * AI capability packages offered alongside the providers in the dedicated AI\n * step. These are the satellite packages that sit on top of the core\n * `@warlock.js/ai` toolkit (each pulls the core `ai` package via its `requires`\n * in core's feature map, same as the providers).\n */\nexport const aiPackages: AiProviderOption[] = [\n {\n key: \"ai-tools\",\n label: \"AI Tools\",\n hint: \"Ready-made agent tools (web search, fetch, HTTP, calculator, date-time) + MCP client/server\",\n },\n {\n key: \"ai-panoptic\",\n label: \"AI Observability (Panoptic)\",\n hint: \"Tracing + exporters + a zero-setup local dashboard\",\n },\n {\n key: \"ai-workspace\",\n label: \"AI Workspace\",\n hint: \"Policy-jailed filesystem + shell for coding agents\",\n },\n];\n\n/**\n * Feature options for the multiselect prompt, ordered by group with the group\n * surfaced in the hint (keeps a flat list scannable without group widgets).\n */\nexport function getFeatureOptions() {\n return features.map(feature => ({\n value: feature.key,\n label: feature.label,\n hint: `${feature.group} — ${feature.hint}`,\n }));\n}\n\n/**\n * Keys pre-checked in the feature multiselect.\n */\nexport function getDefaultFeatureKeys(): string[] {\n return features\n .filter(feature => feature.defaultSelected)\n .map(feature => feature.key);\n}\n\n/**\n * AI provider options for the dedicated AI multiselect step.\n */\nexport function getAiProviderOptions() {\n return aiProviders.map(provider => ({\n value: provider.key,\n label: provider.label,\n hint: provider.hint,\n }));\n}\n\n/**\n * AI capability package options for the dedicated AI multiselect step. Offered\n * together with the providers (see `getAiProviderOptions`).\n */\nexport function getAiPackageOptions() {\n return aiPackages.map(pkg => ({\n value: pkg.key,\n label: pkg.label,\n hint: pkg.hint,\n }));\n}\n\n/**\n * Every selectable key the scaffolder knows about (features + AI providers +\n * AI capability packages). Used to validate `--features` / `--ai` flags in\n * non-interactive mode.\n */\nexport function getAllFeatureKeys(): string[] {\n return [\n ...features.map(feature => feature.key),\n ...aiProviders.map(provider => provider.key),\n ...aiPackages.map(pkg => pkg.key),\n ];\n}\n"],"mappings":";;;;;;AA6DA,MAAa,WAA4B;CAEvC;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CAGA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;EACP,iBAAiB;CACnB;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CAGA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CAGA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CAGA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;CACT;CACA;EACE,KAAK;EACL,OAAO;EACP,MAAM;EAC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J;;;;;;AAOA,SAAgB,oBAA8B;CAC5C,OAAO;EACL,GAAG,SAAS,KAAI,YAAW,QAAQ,GAAG;EACtC,GAAG,YAAY,KAAI,aAAY,SAAS,GAAG;EAC3C,GAAG,WAAW,KAAI,QAAO,IAAI,GAAG;CAClC;AACF"}
@@ -76,8 +76,9 @@ var App = class {
76
76
  return await initializeGitRepository(this.path);
77
77
  }
78
78
  /**
79
- * Write the project's `package.json`: the project name, the chosen package
80
- * manager, and the version of every `@warlock.js/*` dependency.
79
+ * Write the project's `package.json`: the project name and the version of
80
+ * every `@warlock.js/*` dependency. No template script names a package
81
+ * manager, so nothing here depends on the one the user chose.
81
82
  *
82
83
  * `versions` comes from {@link resolveWarlockVersions} — versions the
83
84
  * registry has confirmed exist. It is optional because the fluent chain is
@@ -89,10 +90,8 @@ var App = class {
89
90
  * so an unverified pin resolves to nothing and the install dies with ETARGET.
90
91
  */
91
92
  updatePackageJson(versions = {}) {
92
- const packageManager = getPackageManager();
93
93
  const pkg = this.package.replace("name", this.name.replaceAll("/", "-"));
94
94
  const content = pkg.content;
95
- if (typeof content.scripts?.serve === "string") content.scripts.serve = content.scripts.serve.replaceAll("yarn", packageManager);
96
95
  const warlockVersion = getJsonFile(packageRoot("package.json")).version;
97
96
  const defaultRange = fallbackRange(warlockVersion);
98
97
  for (const field of ["dependencies", "devDependencies"]) {
@@ -1 +1 @@
1
- {"version":3,"file":"app.mjs","names":[],"sources":["../../../../../../create-warlock/src/helpers/app.ts"],"sourcesContent":["import {\n copyDirectory,\n copyFile,\n fileExists,\n getFile,\n getJsonFile,\n putFile,\n putJsonFile,\n renameFile,\n} from \"@warlock.js/fs\";\nimport { existsSync, rmSync, unlinkSync } from \"node:fs\";\nimport path from \"path\";\nimport { Application, AppOptions } from \"../commands/create-new-app/types\";\nimport { getDatabaseDriver } from \"../features/database-drivers\";\nimport { executeCommand, runCommand } from \"./exec\";\nimport { insertImportInSortedPosition } from \"./insert-import\";\nimport { getPackageManager } from \"./package-manager\";\nimport { packageRoot, Template, template } from \"./paths\";\nimport {\n mergePnpmBuildApprovals,\n requiredPnpmBuildApprovals,\n} from \"./pnpm-build-approvals\";\nimport { fallbackRange } from \"./warlock-versions\";\n\n/**\n * Environment for every install the scaffolder spawns.\n *\n * A shell that exports `NODE_ENV=production` makes the package managers skip\n * every devDependency — and still exit 0. The scaffolded project needs its dev\n * toolchain (typescript, vitest, eslint) to be usable at all, so the install\n * child is pinned to `development` regardless of the ambient environment. A\n * silently incomplete install that reports success is the exact failure mode\n * this file exists to prevent.\n */\nexport function installEnvironment(): NodeJS.ProcessEnv {\n return { NODE_ENV: \"development\" };\n}\n\n/** True when any ancestor of `targetPath` (starting at its parent) has a pnpm-workspace.yaml. */\nexport function isInsidePnpmWorkspace(targetPath: string): boolean {\n let dir = path.dirname(path.resolve(targetPath));\n\n while (true) {\n if (existsSync(path.join(dir, \"pnpm-workspace.yaml\"))) return true;\n const parent = path.dirname(dir);\n if (parent === dir) return false;\n dir = parent;\n }\n}\n\nexport class App {\n /**\n * Resolved files\n */\n protected files: Record<string, FileManager> = {};\n\n /**\n * Resolved JSON files\n */\n protected jsonFiles: Record<string, JsonFileManager> = {};\n\n public isInstalled = false;\n\n public constructor(protected app: Application) {}\n\n public get options(): AppOptions {\n return this.app.options;\n }\n\n public use(templateName: Template) {\n copyDirectory(template(templateName), this.path);\n\n if (fileExists(this.path + \"/.env.example\")) {\n copyFile(this.path + \"/.env.example\", this.path + \"/.env\");\n }\n\n renameFile(this.path + \"/_.gitignore\", this.path + \"/.gitignore\");\n\n // Inside an existing pnpm workspace the parent owns the policy; a per-app\n // workspace file would nest a second workspace root.\n if (isInsidePnpmWorkspace(this.path)) {\n rmSync(path.join(this.path, \"pnpm-workspace.yaml\"), { force: true });\n }\n\n return this;\n }\n\n public init() {\n return this;\n }\n\n public terminate() {\n // No longer using outro, using showSuccessScreen instead\n }\n\n public install() {\n return runCommand(getPackageManager(), [\"install\"], this.path, {\n env: installEnvironment(),\n });\n }\n\n /** Record native build approvals before pnpm installs selected feature dependencies. */\n public approveSelectedFeatureBuilds(features: readonly string[]) {\n if (getPackageManager() !== \"pnpm\") return this;\n const packages = requiredPnpmBuildApprovals(features);\n if (packages.length === 0) return this;\n const workspacePath = path.join(this.path, \"pnpm-workspace.yaml\");\n if (!fileExists(workspacePath)) return this;\n const current = getFile(workspacePath) as string;\n putFile(workspacePath, mergePnpmBuildApprovals(current, packages));\n return this;\n }\n\n public async exec(command: string) {\n const [commandName, ...optionsList] = command.split(\" \");\n return await executeCommand(commandName, optionsList, this.path);\n }\n\n public async git() {\n const { initializeGitRepository } =\n await import(\"./project-builder-helpers\");\n return await initializeGitRepository(this.path);\n }\n\n /**\n * Write the project's `package.json`: the project name, the chosen package\n * manager, and the version of every `@warlock.js/*` dependency.\n *\n * `versions` comes from {@link resolveWarlockVersions} — versions the\n * registry has confirmed exist. It is optional because the fluent chain is\n * synchronous; without it every sibling gets the caret range floored to the\n * scaffolder's major, which is always satisfiable by a published release.\n *\n * What it must NEVER do again is stamp the scaffolder's own version blind:\n * the release tooling bumps that version on every build, published or not,\n * so an unverified pin resolves to nothing and the install dies with ETARGET.\n */\n public updatePackageJson(versions: Record<string, string> = {}) {\n const packageManager = getPackageManager();\n\n const pkg = this.package.replace(\"name\", this.name.replaceAll(\"/\", \"-\"));\n\n const content: any = pkg.content;\n\n // Substitute the chosen package manager ONLY into the fields the template\n // writes it into literally — the `serve` script — by path, never with a\n // blanket substring replace over the serialized JSON. A raw\n // `replaceAll(\"yarn\", pm)` rewrites every occurrence of the substring\n // \"yarn\" anywhere in the document, so a project named `my-yarn-app`, or any\n // dependency/path containing \"yarn\", is silently corrupted (`--pm=npm`\n // turned `my-yarn-app` into `my-npm-app`). Field-scoped rewriting is also\n // order-independent: the name lives in `content.name` and this token lives\n // in `scripts.serve`, a disjoint field that cannot collide with the name\n // substitution above regardless of which runs first.\n if (typeof content.scripts?.serve === \"string\") {\n content.scripts.serve = content.scripts.serve.replaceAll(\n \"yarn\",\n packageManager,\n );\n }\n\n const warlockVersion: string = (\n getJsonFile(packageRoot(\"package.json\")) as { version: string }\n ).version;\n const defaultRange = fallbackRange(warlockVersion);\n\n for (const field of [\"dependencies\", \"devDependencies\"] as const) {\n const deps = content[field] as Record<string, string> | undefined;\n if (!deps) continue;\n\n for (const dependency of Object.keys(deps)) {\n if (dependency.startsWith(\"@warlock.js/\")) {\n deps[dependency] = versions[dependency] ?? defaultRange;\n }\n }\n }\n\n pkg.save();\n\n return this;\n }\n\n /**\n * Configure the chosen database driver: wire `DB_DRIVER` / `DB_PORT` into\n * `.env`, AND pin the driver's npm package (`mongodb` / `pg`) into the\n * project's `package.json` dependencies.\n *\n * The dependency is written HERE — before the base `yarn install` — so the\n * driver is pulled deterministically by the very first install. We do NOT\n * rely on the post-copy `warlock add <driver> --no-install` + separate\n * batched install, which can be skipped or fail and leave the driver\n * missing (the \"mongodb package is not installed\" runtime error).\n */\n public configureDatabaseEnv(driverValue: string) {\n const driver = getDatabaseDriver(driverValue);\n\n if (!driver) return this;\n\n // Pin the driver package into dependencies (idempotent — never downgrade).\n const packageJsonPath = path.resolve(this.path, \"package.json\");\n const packageJson = getJsonFile(packageJsonPath) as {\n dependencies?: Record<string, string>;\n };\n packageJson.dependencies = packageJson.dependencies ?? {};\n if (!packageJson.dependencies[driver.package]) {\n packageJson.dependencies[driver.package] = driver.packageVersion;\n putJsonFile(packageJsonPath, packageJson);\n }\n\n // Both files carry the driver defaults: `.env` is what runs, `.env.example`\n // is what the next developer copies.\n for (const fileName of [\".env\", \".env.example\"]) {\n const envPath = this.path + \"/\" + fileName;\n if (!fileExists(envPath)) continue;\n\n let envContent = getFile(envPath) as string;\n\n envContent = envContent.replace(\n /DB_PORT=\\d+/,\n `DB_PORT=${driver.defaultPort}`,\n );\n\n if (envContent.includes(\"DB_DRIVER=\")) {\n envContent = envContent.replace(\n /DB_DRIVER=\\w*/,\n `DB_DRIVER=${driver.value}`,\n );\n } else {\n envContent = envContent.replace(\n /DB_PORT=\\d+/,\n `DB_PORT=${driver.defaultPort}\\nDB_DRIVER=${driver.value}`,\n );\n }\n\n // DB_AUTH is Mongo's authSource; no other driver reads it.\n if (driver.value !== \"mongodb\") {\n envContent = envContent.replace(/^DB_AUTH=.*\\r?\\n?/m, \"\");\n }\n\n putFile(envPath, envContent);\n }\n\n return this;\n }\n\n /**\n * Write the correct `src/config/database.ts` for the chosen driver and remove\n * every per-driver variant so the scaffold ships exactly one config file.\n *\n * The template ships a Mongo-shaped `database.ts` (the default) plus a\n * `database.postgres.ts` variant. Mongo keeps the default in place; Postgres\n * overwrites `database.ts` with the Postgres-shaped variant (typed\n * `ConnectionOptions`, `driver: \"postgres\"`, port 5432, no Mongo-only keys —\n * no `authSource`, `driverOptions`, `replicaSet`, `randomIncrement` /\n * `initialId`). Either way the `.postgres` variant file is deleted afterwards\n * so no leftover config ships in the generated project.\n *\n * For Postgres it also corrects the working `.env`: the Mongo template ships\n * `DB_AUTH=admin`, an `authSource` value Postgres ignores and its config no\n * longer reads, so the line is dropped to keep `.env` and the config in sync.\n * The port is rewritten by {@link configureDatabaseEnv} (driver defaultPort),\n * which runs alongside this in the same branch.\n */\n public configureDatabaseConfig(driverValue: string) {\n const configDir = path.resolve(this.path, \"src/config\");\n const databasePath = path.resolve(configDir, \"database.ts\");\n const postgresVariantPath = path.resolve(configDir, \"database.postgres.ts\");\n\n if (driverValue === \"postgres\" && fileExists(postgresVariantPath)) {\n putFile(databasePath, getFile(postgresVariantPath) as string);\n\n const envPath = this.path + \"/.env\";\n\n if (fileExists(envPath)) {\n const envContent = getFile(envPath) as string;\n // Drop the Mongo-only DB_AUTH line entirely (its whole line, so no blank\n // gap is left behind). Postgres has no authSource concept.\n putFile(envPath, envContent.replace(/^DB_AUTH=.*\\r?\\n?/m, \"\"));\n }\n }\n\n // Whatever the driver, no per-driver variant may survive into the scaffold.\n if (fileExists(postgresVariantPath)) {\n unlinkSync(postgresVariantPath);\n }\n\n return this;\n }\n\n /**\n * Remove the database layer for a \"no database\" scaffold.\n *\n * Deletes `src/config/database.ts` (and a `.tsx` / per-driver variant if\n * present) from the freshly-copied template. The framework's database\n * connector is config-gated on that file — with it gone,\n * `config.get(\"database\")` is undefined and the connector no-ops, so the app\n * boots with no database wired and no driver package pulled. The `DB_*` lines\n * in `.env` are left in place (harmless: no config reads them) as a ready\n * template for adding a database back later.\n */\n public removeDatabaseConfig() {\n const configDir = path.resolve(this.path, \"src/config\");\n\n for (const fileName of [\n \"database.ts\",\n \"database.tsx\",\n \"database.postgres.ts\",\n ]) {\n const filePath = path.resolve(configDir, fileName);\n\n if (fileExists(filePath)) {\n unlinkSync(filePath);\n }\n }\n\n return this;\n }\n\n /**\n * Configure the web starter only when the web feature owns `/`.\n *\n * A dependency-free HTTP response is retained without web; otherwise the\n * SSR page loader owns the route.\n * Exactly one survives the scaffold: web projects keep the SSR page and API\n * example; every other project keeps the dependency-free JSON controller.\n */\n public configureWebStarter(useWeb: boolean) {\n const remove = (relativePath: string) => {\n const target = path.resolve(this.path, relativePath);\n if (existsSync(target)) rmSync(target, { recursive: true, force: true });\n };\n\n if (!useWeb) {\n for (const entry of [\n \"src/web\",\n \"src/app/contact\",\n \"src/app/locale\",\n \"src/shared/contact.schema.ts\",\n \"src/shared/locale.schema.ts\",\n \"src/shared/locales.ts\",\n \"postcss.config.mjs\",\n \"skills/web-code-standards\",\n ]) {\n remove(entry);\n }\n\n const agentsPath = path.resolve(this.path, \"AGENTS.md\");\n const agents = getFile(agentsPath) as string;\n putFile(\n agentsPath,\n agents.replace(/^.*\\*\\*web-code-standards\\*\\*.*\\r?\\n/m, \"\"),\n );\n\n const tsconfigPath = path.resolve(this.path, \"tsconfig.json\");\n const tsconfig = getFile(tsconfigPath) as string;\n putFile(\n tsconfigPath,\n tsconfig\n .replace(' \"web/*\": [\"./src/web/*\"],\\n', \"\")\n .replace(' \"@shared/*\": [\"./src/shared/*\"]\\n', \"\"),\n );\n\n return this;\n }\n\n // The SSR page owns `/`; its loader still uses src/app/home/services.\n remove(\"src/app/home/controllers/home-page.controller.ts\");\n remove(\"src/app/home/routes.ts\");\n\n const packageJsonPath = path.resolve(this.path, \"package.json\");\n const packageJson = getJsonFile(packageJsonPath) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n packageJson.dependencies = {\n ...packageJson.dependencies,\n \"@mongez/http\": \"^3.5.0\",\n \"@mongez/react-form\": \"^4.0.0\",\n };\n packageJson.devDependencies = {\n ...packageJson.devDependencies,\n \"@tailwindcss/postcss\": \"^4.1.16\",\n tailwindcss: \"^4.1.16\",\n };\n putJsonFile(packageJsonPath, packageJson);\n\n const configPath = path.resolve(this.path, \"warlock.config.ts\");\n const config = getFile(configPath) as string;\n if (!config.includes('\"@warlock.js/web/connector\"')) {\n // Inserted in sorted position, not prepended. The generated app formats\n // with `prettier-plugin-organize-imports`, so an import pushed to the top\n // of a file that already imports `@warlock.js/auth` and `@warlock.js/core`\n // is out of order the moment it is written — and the developer meets it as\n // a `prettier/prettier` error on their first `warlock dev`, in a file they\n // did not write.\n const withConnector = insertImportInSortedPosition(\n config,\n 'import { webConnector } from \"@warlock.js/web/connector\";',\n \"@warlock.js/web/connector\",\n );\n\n putFile(\n configPath,\n withConnector.replace(\n \"export default defineConfig({\",\n \"export default defineConfig({\\n connectors: [webConnector()],\",\n ),\n );\n }\n\n return this;\n }\n\n /**\n * Record non-default `agent-kit` targets into the generated `package.json`'s\n * `agentKit.targets` block.\n *\n * The template's own `postinstall` (`agent-kit init && agent-kit sync`)\n * already targets `claude` with no flags, so the single-target default case\n * needs no template edit at all — this only writes when the selection is\n * anything else, keeping the scaffold diff-free for the common path.\n */\n public configureAgentKitTargets(agents: string[]) {\n const isDefault = agents.length === 1 && agents[0] === \"claude\";\n if (isDefault) return this;\n\n const packageJsonPath = path.resolve(this.path, \"package.json\");\n if (!fileExists(packageJsonPath)) return this;\n\n const packageJson = getJsonFile(packageJsonPath) as {\n agentKit?: { targets?: string[] };\n };\n packageJson.agentKit = { ...packageJson.agentKit, targets: agents };\n putJsonFile(packageJsonPath, packageJson);\n\n return this;\n }\n\n /**\n * Install the selected optional features by delegating to the project's own\n * `warlock add`. `--no-install` records every dependency in package.json and\n * ejects configs / scripts / setup hooks WITHOUT installing — the caller runs\n * one batched install afterwards. Versions come from core's feature map, so\n * the scaffolder never duplicates them.\n *\n * `--no-install` is passed LAST on purpose: the CLI parser treats the\n * positional after a bare flag as that flag's value, so it must follow the\n * feature list, not precede it.\n */\n public async installFeatures(features: string[]) {\n if (features.length === 0) return true;\n\n return this.exec(`npx warlock add ${features.join(\" \")} --no-install`);\n }\n\n /**\n * Force a single copy of `vite` when the project ends up with BOTH `vite`\n * (written by the `web` feature) and `vitest` (always in the template).\n *\n * `vitest` depends on vite through a wide range of its own\n * (`^6 || ^7 || ^8`), which resolves to a DIFFERENT major than the range the\n * feature map pins. Yarn 1 then has to nest the second copy under\n * `vitest/node_modules` and dies on its own linker invariant:\n *\n * error Invariant Violation: could not find a copy of vite to link in\n * <project>/node_modules/vitest/node_modules\n *\n * It aborts BEFORE `node_modules/.bin` is written, so `warlock` is never\n * linked and the very first `yarn dev` fails with \"'warlock' is not\n * recognized\". npm and pnpm nest happily and never hit this — for them the\n * `overrides` twin below is one copy instead of two, not a crash fix.\n *\n * The pin is READ BACK from whatever range the project's own package.json\n * declares, never re-stated as a literal here: the feature map in\n * `@warlock.js/core` owns the version, and a second copy of it would drift\n * the moment that one moves.\n *\n * Returns whether a pin was written, so the caller (and its spec) can assert\n * it instead of assuming it.\n */\n public pinViteResolution() {\n const packageJsonPath = path.resolve(this.path, \"package.json\");\n\n if (!fileExists(packageJsonPath)) return false;\n\n const packageJson = getJsonFile(packageJsonPath) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n resolutions?: Record<string, string>;\n overrides?: Record<string, string>;\n };\n\n const declaredRange = (name: string) =>\n packageJson.dependencies?.[name] ?? packageJson.devDependencies?.[name];\n\n const viteRange = declaredRange(\"vite\");\n\n // No vite, or no vitest to conflict with it — nothing to pin. Writing a\n // resolution for a package the project does not depend on would only\n // freeze a transitive tree nobody asked us to freeze.\n if (!viteRange || !declaredRange(\"vitest\")) return false;\n\n // yarn 1 / yarn berry read `resolutions`; npm 8+ and pnpm read `overrides`.\n packageJson.resolutions = { ...packageJson.resolutions, vite: viteRange };\n packageJson.overrides = { ...packageJson.overrides, vite: viteRange };\n\n putJsonFile(packageJsonPath, packageJson);\n\n return true;\n }\n\n /**\n * Get package json file\n */\n public get package() {\n return this.json(\"package.json\");\n }\n\n public updateDotEnv() {\n this.file(\".env\").replaceAll(\"appName\", this.name).save();\n\n return this;\n }\n\n /**\n * Get env file to update\n */\n public get env() {\n return this.file(\".env\");\n }\n\n public get name() {\n return this.app.appName;\n }\n\n public get path() {\n return this.app.appPath;\n }\n\n public file(relativePath: string) {\n const fullPath = path.resolve(this.path, relativePath);\n\n if (!this.files[fullPath]) {\n this.files[fullPath] = file(fullPath);\n }\n\n return this.files[fullPath];\n }\n\n public json(relativePath: string): JsonFileManager {\n const fullPath = path.resolve(this.path, relativePath);\n\n if (!this.jsonFiles[fullPath]) {\n this.jsonFiles[fullPath] = jsonFile(fullPath);\n }\n\n return this.jsonFiles[fullPath];\n }\n}\n\nexport function app(app: Application) {\n return new App(app);\n}\n\nexport class FileManager {\n public content!: string;\n public constructor(protected filePath: string) {\n this.parseContent();\n }\n\n protected parseContent() {\n this.content = getFile(this.filePath) as string;\n }\n\n public replace(search: string, replace: string) {\n this.content = this.content.replace(search, replace);\n\n return this;\n }\n\n public replaceAll(search: string, replace: string) {\n this.content = this.content.replaceAll(search, replace);\n\n return this;\n }\n\n public save() {\n putFile(this.filePath, this.content);\n }\n}\n\nexport class JsonFileManager extends FileManager {\n protected parseContent() {\n this.content = getJsonFile(this.filePath);\n }\n\n public save() {\n putJsonFile(this.filePath, this.content);\n }\n\n public has(key: string) {\n return this.content[key] !== undefined;\n }\n\n public replace(key: string, value: any) {\n this.content[key] = value;\n\n return this;\n }\n\n public replaceAll(key: string, value: any) {\n const contentAsString = JSON.stringify(this.content);\n\n this.content = JSON.parse(contentAsString.replaceAll(key, value));\n\n return this;\n }\n}\n\nexport function file(path: string) {\n return new FileManager(path);\n}\n\nexport function jsonFile(path: string) {\n return new JsonFileManager(path);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,qBAAwC;CACtD,OAAO,EAAE,UAAU,cAAc;AACnC;;AAGA,SAAgB,sBAAsB,YAA6B;CACjE,IAAI,MAAM,KAAK,QAAQ,KAAK,QAAQ,UAAU,CAAC;CAE/C,OAAO,MAAM;EACX,IAAI,WAAW,KAAK,KAAK,KAAK,qBAAqB,CAAC,GAAG,OAAO;EAC9D,MAAM,SAAS,KAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KAAK,OAAO;EAC3B,MAAM;CACR;AACF;AAEA,IAAa,MAAb,MAAiB;CAaf,AAAO,YAAY,AAAU,KAAkB;EAAlB;eATkB,CAAC;mBAKO,CAAC;qBAEnC;CAE2B;CAEhD,IAAW,UAAsB;EAC/B,OAAO,KAAK,IAAI;CAClB;CAEA,AAAO,IAAI,cAAwB;EACjC,cAAc,SAAS,YAAY,GAAG,KAAK,IAAI;EAE/C,IAAI,WAAW,KAAK,OAAO,eAAe,GACxC,SAAS,KAAK,OAAO,iBAAiB,KAAK,OAAO,OAAO;EAG3D,WAAW,KAAK,OAAO,gBAAgB,KAAK,OAAO,aAAa;EAIhE,IAAI,sBAAsB,KAAK,IAAI,GACjC,OAAO,KAAK,KAAK,KAAK,MAAM,qBAAqB,GAAG,EAAE,OAAO,KAAK,CAAC;EAGrE,OAAO;CACT;CAEA,AAAO,OAAO;EACZ,OAAO;CACT;CAEA,AAAO,YAAY,CAEnB;CAEA,AAAO,UAAU;EACf,OAAO,WAAW,kBAAkB,GAAG,CAAC,SAAS,GAAG,KAAK,MAAM,EAC7D,KAAK,mBAAmB,EAC1B,CAAC;CACH;;CAGA,AAAO,6BAA6B,UAA6B;EAC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ACzC,MAAM,kBAAkB,KAAK,UAAU,KAAK,OAAO;EAEnD,KAAK,UAAU,KAAK,MAAM,gBAAgB,WAAW,KAAK,KAAK,CAAC;EAEhE,OAAO;CACT;AACF;AAEA,SAAgB,KAAK,MAAc;CACjC,OAAO,IAAI,YAAY,IAAI;AAC7B;AAEA,SAAgB,SAAS,MAAc;CACrC,OAAO,IAAI,gBAAgB,IAAI;AACjC"}
1
+ {"version":3,"file":"app.mjs","names":[],"sources":["../../../../../../create-warlock/src/helpers/app.ts"],"sourcesContent":["import {\n copyDirectory,\n copyFile,\n fileExists,\n getFile,\n getJsonFile,\n putFile,\n putJsonFile,\n renameFile,\n} from \"@warlock.js/fs\";\nimport { existsSync, rmSync, unlinkSync } from \"node:fs\";\nimport path from \"path\";\nimport { Application, AppOptions } from \"../commands/create-new-app/types\";\nimport { getDatabaseDriver } from \"../features/database-drivers\";\nimport { executeCommand, runCommand } from \"./exec\";\nimport { insertImportInSortedPosition } from \"./insert-import\";\nimport { getPackageManager } from \"./package-manager\";\nimport { packageRoot, Template, template } from \"./paths\";\nimport {\n mergePnpmBuildApprovals,\n requiredPnpmBuildApprovals,\n} from \"./pnpm-build-approvals\";\nimport { fallbackRange } from \"./warlock-versions\";\n\n/**\n * Environment for every install the scaffolder spawns.\n *\n * A shell that exports `NODE_ENV=production` makes the package managers skip\n * every devDependency — and still exit 0. The scaffolded project needs its dev\n * toolchain (typescript, vitest, eslint) to be usable at all, so the install\n * child is pinned to `development` regardless of the ambient environment. A\n * silently incomplete install that reports success is the exact failure mode\n * this file exists to prevent.\n */\nexport function installEnvironment(): NodeJS.ProcessEnv {\n return { NODE_ENV: \"development\" };\n}\n\n/** True when any ancestor of `targetPath` (starting at its parent) has a pnpm-workspace.yaml. */\nexport function isInsidePnpmWorkspace(targetPath: string): boolean {\n let dir = path.dirname(path.resolve(targetPath));\n\n while (true) {\n if (existsSync(path.join(dir, \"pnpm-workspace.yaml\"))) return true;\n const parent = path.dirname(dir);\n if (parent === dir) return false;\n dir = parent;\n }\n}\n\nexport class App {\n /**\n * Resolved files\n */\n protected files: Record<string, FileManager> = {};\n\n /**\n * Resolved JSON files\n */\n protected jsonFiles: Record<string, JsonFileManager> = {};\n\n public isInstalled = false;\n\n public constructor(protected app: Application) {}\n\n public get options(): AppOptions {\n return this.app.options;\n }\n\n public use(templateName: Template) {\n copyDirectory(template(templateName), this.path);\n\n if (fileExists(this.path + \"/.env.example\")) {\n copyFile(this.path + \"/.env.example\", this.path + \"/.env\");\n }\n\n renameFile(this.path + \"/_.gitignore\", this.path + \"/.gitignore\");\n\n // Inside an existing pnpm workspace the parent owns the policy; a per-app\n // workspace file would nest a second workspace root.\n if (isInsidePnpmWorkspace(this.path)) {\n rmSync(path.join(this.path, \"pnpm-workspace.yaml\"), { force: true });\n }\n\n return this;\n }\n\n public init() {\n return this;\n }\n\n public terminate() {\n // No longer using outro, using showSuccessScreen instead\n }\n\n public install() {\n return runCommand(getPackageManager(), [\"install\"], this.path, {\n env: installEnvironment(),\n });\n }\n\n /** Record native build approvals before pnpm installs selected feature dependencies. */\n public approveSelectedFeatureBuilds(features: readonly string[]) {\n if (getPackageManager() !== \"pnpm\") return this;\n const packages = requiredPnpmBuildApprovals(features);\n if (packages.length === 0) return this;\n const workspacePath = path.join(this.path, \"pnpm-workspace.yaml\");\n if (!fileExists(workspacePath)) return this;\n const current = getFile(workspacePath) as string;\n putFile(workspacePath, mergePnpmBuildApprovals(current, packages));\n return this;\n }\n\n public async exec(command: string) {\n const [commandName, ...optionsList] = command.split(\" \");\n return await executeCommand(commandName, optionsList, this.path);\n }\n\n public async git() {\n const { initializeGitRepository } =\n await import(\"./project-builder-helpers\");\n return await initializeGitRepository(this.path);\n }\n\n /**\n * Write the project's `package.json`: the project name and the version of\n * every `@warlock.js/*` dependency. No template script names a package\n * manager, so nothing here depends on the one the user chose.\n *\n * `versions` comes from {@link resolveWarlockVersions} — versions the\n * registry has confirmed exist. It is optional because the fluent chain is\n * synchronous; without it every sibling gets the caret range floored to the\n * scaffolder's major, which is always satisfiable by a published release.\n *\n * What it must NEVER do again is stamp the scaffolder's own version blind:\n * the release tooling bumps that version on every build, published or not,\n * so an unverified pin resolves to nothing and the install dies with ETARGET.\n */\n public updatePackageJson(versions: Record<string, string> = {}) {\n const pkg = this.package.replace(\"name\", this.name.replaceAll(\"/\", \"-\"));\n\n const content: any = pkg.content;\n\n const warlockVersion: string = (\n getJsonFile(packageRoot(\"package.json\")) as { version: string }\n ).version;\n const defaultRange = fallbackRange(warlockVersion);\n\n for (const field of [\"dependencies\", \"devDependencies\"] as const) {\n const deps = content[field] as Record<string, string> | undefined;\n if (!deps) continue;\n\n for (const dependency of Object.keys(deps)) {\n if (dependency.startsWith(\"@warlock.js/\")) {\n deps[dependency] = versions[dependency] ?? defaultRange;\n }\n }\n }\n\n pkg.save();\n\n return this;\n }\n\n /**\n * Configure the chosen database driver: wire `DB_DRIVER` / `DB_PORT` into\n * `.env`, AND pin the driver's npm package (`mongodb` / `pg`) into the\n * project's `package.json` dependencies.\n *\n * The dependency is written HERE — before the base `yarn install` — so the\n * driver is pulled deterministically by the very first install. We do NOT\n * rely on the post-copy `warlock add <driver> --no-install` + separate\n * batched install, which can be skipped or fail and leave the driver\n * missing (the \"mongodb package is not installed\" runtime error).\n */\n public configureDatabaseEnv(driverValue: string) {\n const driver = getDatabaseDriver(driverValue);\n\n if (!driver) return this;\n\n // Pin the driver package into dependencies (idempotent — never downgrade).\n const packageJsonPath = path.resolve(this.path, \"package.json\");\n const packageJson = getJsonFile(packageJsonPath) as {\n dependencies?: Record<string, string>;\n };\n packageJson.dependencies = packageJson.dependencies ?? {};\n if (!packageJson.dependencies[driver.package]) {\n packageJson.dependencies[driver.package] = driver.packageVersion;\n putJsonFile(packageJsonPath, packageJson);\n }\n\n // Both files carry the driver defaults: `.env` is what runs, `.env.example`\n // is what the next developer copies.\n for (const fileName of [\".env\", \".env.example\"]) {\n const envPath = this.path + \"/\" + fileName;\n if (!fileExists(envPath)) continue;\n\n let envContent = getFile(envPath) as string;\n\n envContent = envContent.replace(\n /DB_PORT=\\d+/,\n `DB_PORT=${driver.defaultPort}`,\n );\n\n if (envContent.includes(\"DB_DRIVER=\")) {\n envContent = envContent.replace(\n /DB_DRIVER=\\w*/,\n `DB_DRIVER=${driver.value}`,\n );\n } else {\n envContent = envContent.replace(\n /DB_PORT=\\d+/,\n `DB_PORT=${driver.defaultPort}\\nDB_DRIVER=${driver.value}`,\n );\n }\n\n // DB_AUTH is Mongo's authSource; no other driver reads it.\n if (driver.value !== \"mongodb\") {\n envContent = envContent.replace(/^DB_AUTH=.*\\r?\\n?/m, \"\");\n }\n\n putFile(envPath, envContent);\n }\n\n return this;\n }\n\n /**\n * Write the correct `src/config/database.ts` for the chosen driver and remove\n * every per-driver variant so the scaffold ships exactly one config file.\n *\n * The template ships a Mongo-shaped `database.ts` (the default) plus a\n * `database.postgres.ts` variant. Mongo keeps the default in place; Postgres\n * overwrites `database.ts` with the Postgres-shaped variant (typed\n * `ConnectionOptions`, `driver: \"postgres\"`, port 5432, no Mongo-only keys —\n * no `authSource`, `driverOptions`, `replicaSet`, `randomIncrement` /\n * `initialId`). Either way the `.postgres` variant file is deleted afterwards\n * so no leftover config ships in the generated project.\n *\n * For Postgres it also corrects the working `.env`: the Mongo template ships\n * `DB_AUTH=admin`, an `authSource` value Postgres ignores and its config no\n * longer reads, so the line is dropped to keep `.env` and the config in sync.\n * The port is rewritten by {@link configureDatabaseEnv} (driver defaultPort),\n * which runs alongside this in the same branch.\n */\n public configureDatabaseConfig(driverValue: string) {\n const configDir = path.resolve(this.path, \"src/config\");\n const databasePath = path.resolve(configDir, \"database.ts\");\n const postgresVariantPath = path.resolve(configDir, \"database.postgres.ts\");\n\n if (driverValue === \"postgres\" && fileExists(postgresVariantPath)) {\n putFile(databasePath, getFile(postgresVariantPath) as string);\n\n const envPath = this.path + \"/.env\";\n\n if (fileExists(envPath)) {\n const envContent = getFile(envPath) as string;\n // Drop the Mongo-only DB_AUTH line entirely (its whole line, so no blank\n // gap is left behind). Postgres has no authSource concept.\n putFile(envPath, envContent.replace(/^DB_AUTH=.*\\r?\\n?/m, \"\"));\n }\n }\n\n // Whatever the driver, no per-driver variant may survive into the scaffold.\n if (fileExists(postgresVariantPath)) {\n unlinkSync(postgresVariantPath);\n }\n\n return this;\n }\n\n /**\n * Remove the database layer for a \"no database\" scaffold.\n *\n * Deletes `src/config/database.ts` (and a `.tsx` / per-driver variant if\n * present) from the freshly-copied template. The framework's database\n * connector is config-gated on that file — with it gone,\n * `config.get(\"database\")` is undefined and the connector no-ops, so the app\n * boots with no database wired and no driver package pulled. The `DB_*` lines\n * in `.env` are left in place (harmless: no config reads them) as a ready\n * template for adding a database back later.\n */\n public removeDatabaseConfig() {\n const configDir = path.resolve(this.path, \"src/config\");\n\n for (const fileName of [\n \"database.ts\",\n \"database.tsx\",\n \"database.postgres.ts\",\n ]) {\n const filePath = path.resolve(configDir, fileName);\n\n if (fileExists(filePath)) {\n unlinkSync(filePath);\n }\n }\n\n return this;\n }\n\n /**\n * Configure the web starter only when the web feature owns `/`.\n *\n * A dependency-free HTTP response is retained without web; otherwise the\n * SSR page loader owns the route.\n * Exactly one survives the scaffold: web projects keep the SSR page and API\n * example; every other project keeps the dependency-free JSON controller.\n */\n public configureWebStarter(useWeb: boolean) {\n const remove = (relativePath: string) => {\n const target = path.resolve(this.path, relativePath);\n if (existsSync(target)) rmSync(target, { recursive: true, force: true });\n };\n\n if (!useWeb) {\n for (const entry of [\n \"src/web\",\n \"src/app/contact\",\n \"src/app/locale\",\n \"src/shared/contact.schema.ts\",\n \"src/shared/locale.schema.ts\",\n \"src/shared/locales.ts\",\n \"postcss.config.mjs\",\n \"skills/web-code-standards\",\n ]) {\n remove(entry);\n }\n\n const agentsPath = path.resolve(this.path, \"AGENTS.md\");\n const agents = getFile(agentsPath) as string;\n putFile(\n agentsPath,\n agents.replace(/^.*\\*\\*web-code-standards\\*\\*.*\\r?\\n/m, \"\"),\n );\n\n const tsconfigPath = path.resolve(this.path, \"tsconfig.json\");\n const tsconfig = getFile(tsconfigPath) as string;\n putFile(\n tsconfigPath,\n tsconfig\n .replace(' \"web/*\": [\"./src/web/*\"],\\n', \"\")\n .replace(' \"@shared/*\": [\"./src/shared/*\"]\\n', \"\"),\n );\n\n return this;\n }\n\n // The SSR page owns `/`; its loader still uses src/app/home/services.\n remove(\"src/app/home/controllers/home-page.controller.ts\");\n remove(\"src/app/home/routes.ts\");\n\n const packageJsonPath = path.resolve(this.path, \"package.json\");\n const packageJson = getJsonFile(packageJsonPath) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n packageJson.dependencies = {\n ...packageJson.dependencies,\n \"@mongez/http\": \"^3.5.0\",\n \"@mongez/react-form\": \"^4.0.0\",\n };\n packageJson.devDependencies = {\n ...packageJson.devDependencies,\n \"@tailwindcss/postcss\": \"^4.1.16\",\n tailwindcss: \"^4.1.16\",\n };\n putJsonFile(packageJsonPath, packageJson);\n\n const configPath = path.resolve(this.path, \"warlock.config.ts\");\n const config = getFile(configPath) as string;\n if (!config.includes('\"@warlock.js/web/connector\"')) {\n // Inserted in sorted position, not prepended. The generated app formats\n // with `prettier-plugin-organize-imports`, so an import pushed to the top\n // of a file that already imports `@warlock.js/auth` and `@warlock.js/core`\n // is out of order the moment it is written — and the developer meets it as\n // a `prettier/prettier` error on their first `warlock dev`, in a file they\n // did not write.\n const withConnector = insertImportInSortedPosition(\n config,\n 'import { webConnector } from \"@warlock.js/web/connector\";',\n \"@warlock.js/web/connector\",\n );\n\n putFile(\n configPath,\n withConnector.replace(\n \"export default defineConfig({\",\n \"export default defineConfig({\\n connectors: [webConnector()],\",\n ),\n );\n }\n\n return this;\n }\n\n /**\n * Record non-default `agent-kit` targets into the generated `package.json`'s\n * `agentKit.targets` block.\n *\n * The template's own `postinstall` (`agent-kit init && agent-kit sync`)\n * already targets `claude` with no flags, so the single-target default case\n * needs no template edit at all — this only writes when the selection is\n * anything else, keeping the scaffold diff-free for the common path.\n */\n public configureAgentKitTargets(agents: string[]) {\n const isDefault = agents.length === 1 && agents[0] === \"claude\";\n if (isDefault) return this;\n\n const packageJsonPath = path.resolve(this.path, \"package.json\");\n if (!fileExists(packageJsonPath)) return this;\n\n const packageJson = getJsonFile(packageJsonPath) as {\n agentKit?: { targets?: string[] };\n };\n packageJson.agentKit = { ...packageJson.agentKit, targets: agents };\n putJsonFile(packageJsonPath, packageJson);\n\n return this;\n }\n\n /**\n * Install the selected optional features by delegating to the project's own\n * `warlock add`. `--no-install` records every dependency in package.json and\n * ejects configs / scripts / setup hooks WITHOUT installing — the caller runs\n * one batched install afterwards. Versions come from core's feature map, so\n * the scaffolder never duplicates them.\n *\n * `--no-install` is passed LAST on purpose: the CLI parser treats the\n * positional after a bare flag as that flag's value, so it must follow the\n * feature list, not precede it.\n */\n public async installFeatures(features: string[]) {\n if (features.length === 0) return true;\n\n return this.exec(`npx warlock add ${features.join(\" \")} --no-install`);\n }\n\n /**\n * Force a single copy of `vite` when the project ends up with BOTH `vite`\n * (written by the `web` feature) and `vitest` (always in the template).\n *\n * `vitest` depends on vite through a wide range of its own\n * (`^6 || ^7 || ^8`), which resolves to a DIFFERENT major than the range the\n * feature map pins. Yarn 1 then has to nest the second copy under\n * `vitest/node_modules` and dies on its own linker invariant:\n *\n * error Invariant Violation: could not find a copy of vite to link in\n * <project>/node_modules/vitest/node_modules\n *\n * It aborts BEFORE `node_modules/.bin` is written, so `warlock` is never\n * linked and the very first `yarn dev` fails with \"'warlock' is not\n * recognized\". npm and pnpm nest happily and never hit this — for them the\n * `overrides` twin below is one copy instead of two, not a crash fix.\n *\n * The pin is READ BACK from whatever range the project's own package.json\n * declares, never re-stated as a literal here: the feature map in\n * `@warlock.js/core` owns the version, and a second copy of it would drift\n * the moment that one moves.\n *\n * Returns whether a pin was written, so the caller (and its spec) can assert\n * it instead of assuming it.\n */\n public pinViteResolution() {\n const packageJsonPath = path.resolve(this.path, \"package.json\");\n\n if (!fileExists(packageJsonPath)) return false;\n\n const packageJson = getJsonFile(packageJsonPath) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n resolutions?: Record<string, string>;\n overrides?: Record<string, string>;\n };\n\n const declaredRange = (name: string) =>\n packageJson.dependencies?.[name] ?? packageJson.devDependencies?.[name];\n\n const viteRange = declaredRange(\"vite\");\n\n // No vite, or no vitest to conflict with it — nothing to pin. Writing a\n // resolution for a package the project does not depend on would only\n // freeze a transitive tree nobody asked us to freeze.\n if (!viteRange || !declaredRange(\"vitest\")) return false;\n\n // yarn 1 / yarn berry read `resolutions`; npm 8+ and pnpm read `overrides`.\n packageJson.resolutions = { ...packageJson.resolutions, vite: viteRange };\n packageJson.overrides = { ...packageJson.overrides, vite: viteRange };\n\n putJsonFile(packageJsonPath, packageJson);\n\n return true;\n }\n\n /**\n * Get package json file\n */\n public get package() {\n return this.json(\"package.json\");\n }\n\n public updateDotEnv() {\n this.file(\".env\").replaceAll(\"appName\", this.name).save();\n\n return this;\n }\n\n /**\n * Get env file to update\n */\n public get env() {\n return this.file(\".env\");\n }\n\n public get name() {\n return this.app.appName;\n }\n\n public get path() {\n return this.app.appPath;\n }\n\n public file(relativePath: string) {\n const fullPath = path.resolve(this.path, relativePath);\n\n if (!this.files[fullPath]) {\n this.files[fullPath] = file(fullPath);\n }\n\n return this.files[fullPath];\n }\n\n public json(relativePath: string): JsonFileManager {\n const fullPath = path.resolve(this.path, relativePath);\n\n if (!this.jsonFiles[fullPath]) {\n this.jsonFiles[fullPath] = jsonFile(fullPath);\n }\n\n return this.jsonFiles[fullPath];\n }\n}\n\nexport function app(app: Application) {\n return new App(app);\n}\n\nexport class FileManager {\n public content!: string;\n public constructor(protected filePath: string) {\n this.parseContent();\n }\n\n protected parseContent() {\n this.content = getFile(this.filePath) as string;\n }\n\n public replace(search: string, replace: string) {\n this.content = this.content.replace(search, replace);\n\n return this;\n }\n\n public replaceAll(search: string, replace: string) {\n this.content = this.content.replaceAll(search, replace);\n\n return this;\n }\n\n public save() {\n putFile(this.filePath, this.content);\n }\n}\n\nexport class JsonFileManager extends FileManager {\n protected parseContent() {\n this.content = getJsonFile(this.filePath);\n }\n\n public save() {\n putJsonFile(this.filePath, this.content);\n }\n\n public has(key: string) {\n return this.content[key] !== undefined;\n }\n\n public replace(key: string, value: any) {\n this.content[key] = value;\n\n return this;\n }\n\n public replaceAll(key: string, value: any) {\n const contentAsString = JSON.stringify(this.content);\n\n this.content = JSON.parse(contentAsString.replaceAll(key, value));\n\n return this;\n }\n}\n\nexport function file(path: string) {\n return new FileManager(path);\n}\n\nexport function jsonFile(path: string) {\n return new JsonFileManager(path);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,qBAAwC;CACtD,OAAO,EAAE,UAAU,cAAc;AACnC;;AAGA,SAAgB,sBAAsB,YAA6B;CACjE,IAAI,MAAM,KAAK,QAAQ,KAAK,QAAQ,UAAU,CAAC;CAE/C,OAAO,MAAM;EACX,IAAI,WAAW,KAAK,KAAK,KAAK,qBAAqB,CAAC,GAAG,OAAO;EAC9D,MAAM,SAAS,KAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KAAK,OAAO;EAC3B,MAAM;CACR;AACF;AAEA,IAAa,MAAb,MAAiB;CAaf,AAAO,YAAY,AAAU,KAAkB;EAAlB;eATkB,CAAC;mBAKO,CAAC;qBAEnC;CAE2B;CAEhD,IAAW,UAAsB;EAC/B,OAAO,KAAK,IAAI;CAClB;CAEA,AAAO,IAAI,cAAwB;EACjC,cAAc,SAAS,YAAY,GAAG,KAAK,IAAI;EAE/C,IAAI,WAAW,KAAK,OAAO,eAAe,GACxC,SAAS,KAAK,OAAO,iBAAiB,KAAK,OAAO,OAAO;EAG3D,WAAW,KAAK,OAAO,gBAAgB,KAAK,OAAO,aAAa;EAIhE,IAAI,sBAAsB,KAAK,IAAI,GACjC,OAAO,KAAK,KAAK,KAAK,MAAM,qBAAqB,GAAG,EAAE,OAAO,KAAK,CAAC;EAGrE,OAAO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,KAAa,OAAY;EACtC,KAAK,QAAQ,OAAO;EAEpB,OAAO;CACT;CAEA,AAAO,WAAW,KAAa,OAAY;EACzC,MAAM,kBAAkB,KAAK,UAAU,KAAK,OAAO;EAEnD,KAAK,UAAU,KAAK,MAAM,gBAAgB,WAAW,KAAK,KAAK,CAAC;EAEhE,OAAO;CACT;AACF;AAEA,SAAgB,KAAK,MAAc;CACjC,OAAO,IAAI,YAAY,IAAI;AAC7B;AAEA,SAAgB,SAAS,MAAc;CACrC,OAAO,IAAI,gBAAgB,IAAI;AACjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"package-manager.mjs","names":[],"sources":["../../../../../../create-warlock/src/helpers/package-manager.ts"],"sourcesContent":["import { exec, execSync } from \"child_process\";\r\nimport { promisify } from \"util\";\r\nimport detectPackageManager from \"which-pm-runs\";\r\n\r\nconst execAsync = promisify(exec);\r\n\r\nlet detectedPackageManager: string | undefined;\r\nlet cachedSystemManagers: string[] | undefined;\r\nlet cachedPreferredManager: string | undefined;\r\n\r\n/**\r\n * The only package managers `--pm` may select. This value reaches `spawn()`\r\n * as the executable to run and is spliced into the generated\r\n * `package.json`'s scripts — an allow-list here is a hard security\r\n * boundary, not just input hygiene, so it stays a fixed literal list\r\n * rather than anything derived from user input or the running environment.\r\n */\r\nexport const ALLOWED_PACKAGE_MANAGERS = [\"npm\", \"yarn\", \"pnpm\", \"bun\"] as const;\r\n\r\nexport type AllowedPackageManager = (typeof ALLOWED_PACKAGE_MANAGERS)[number];\r\n\r\n/** Whether `value` is one of the allow-listed package managers. */\r\nexport function isValidPackageManager(\r\n value: string,\r\n): value is AllowedPackageManager {\r\n return (ALLOWED_PACKAGE_MANAGERS as readonly string[]).includes(value);\r\n}\r\n\r\nexport function getPackageManager() {\r\n if (detectedPackageManager) {\r\n return detectedPackageManager;\r\n }\r\n\r\n return getPreferredPackageManager();\r\n}\r\n\r\n/**\r\n * Check if a package manager is installed\r\n */\r\nfunction isInstalled(manager: string): boolean {\r\n try {\r\n execSync(`${manager} --version`, { stdio: \"ignore\" });\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Check if a package manager is installed (async)\r\n */\r\nasync function checkManager(manager: string): Promise<boolean> {\r\n try {\r\n await execAsync(`${manager} --version`);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Every allow-listed manager that has to be PROBED. npm is excluded because\r\n * it is assumed present.\r\n *\r\n * Both detectors read this one list. They used to hold their own literal\r\n * copies, and the copies drifted: `bun` reached the allow-list and `--help`\r\n * without reaching either probe, so `--pm=bun` passed the spelling check and\r\n * then could never appear among the options that would honour it.\r\n */\r\nconst PROBED_PACKAGE_MANAGERS = ALLOWED_PACKAGE_MANAGERS.filter(\r\n manager => manager !== \"npm\",\r\n);\r\n\r\nconst PREFERRED_PACKAGE_MANAGERS = [\"pnpm\", \"yarn\", \"npm\"] as const;\r\n\r\n/**\r\n * A running non-npm manager is already usable. Every fallback must be present\r\n * in the detector's installed set, so both sync and async paths agree.\r\n */\r\nfunction preferredPackageManager(\r\n isAvailable: (manager: AllowedPackageManager) => boolean,\r\n): string {\r\n const runningPm = detectPackageManager()?.name;\r\n if (runningPm && runningPm !== \"npm\" && isValidPackageManager(runningPm)) {\r\n return runningPm;\r\n }\r\n\r\n return PREFERRED_PACKAGE_MANAGERS.find(isAvailable) ?? \"npm\";\r\n}\r\n\r\n/**\r\n * Detect available package managers asynchronously and cache results\r\n */\r\nexport async function detectPackageManagers() {\r\n const found = await Promise.all(PROBED_PACKAGE_MANAGERS.map(checkManager));\r\n const available = PROBED_PACKAGE_MANAGERS.filter((_, index) => found[index]);\r\n const managers = [\"npm\", ...available];\r\n\r\n cachedSystemManagers = managers;\r\n cachedPreferredManager = preferredPackageManager(manager =>\r\n managers.includes(manager),\r\n );\r\n}\r\n\r\n/**\r\n * Get available package managers on the system\r\n */\r\nexport function getSystemPackageManagers(): string[] {\r\n if (cachedSystemManagers) return cachedSystemManagers;\r\n\r\n // Same list the async detector probes, so the two can no longer disagree\r\n // about which managers exist. npm is assumed to be always available.\r\n return [\"npm\", ...PROBED_PACKAGE_MANAGERS.filter(isInstalled)];\r\n}\r\n\r\n/**\r\n * Get the preferred package manager based on priority\r\n */\r\nexport function getPreferredPackageManager(): string {\r\n if (cachedPreferredManager) return cachedPreferredManager;\r\n return preferredPackageManager(\r\n manager => manager === \"npm\" || isInstalled(manager),\r\n );\r\n}\r\n\r\nexport function setPackageManager(packageManager: string) {\r\n detectedPackageManager = packageManager;\r\n}\r\n\r\nexport function installCommand() {\r\n return `${getPackageManager()} install`;\r\n}\r\n\r\nexport function startCommand() {\r\n if (getPackageManager() === \"npm\") return \"npm run dev\";\r\n\r\n return `${getPackageManager()} dev`;\r\n}\r\n\r\nexport function runPackageManagerCommand(command: string) {\r\n const packageManager = getPackageManager();\r\n\r\n if (packageManager === \"npm\") return `npm run ${command}`;\r\n\r\n return `${packageManager} ${command}`;\r\n}\r\n"],"mappings":";;;;;AAIA,MAAM,YAAY,UAAU,IAAI;AAEhC,IAAI;AACJ,IAAI;AACJ,IAAI;;;;;;;;AASJ,MAAa,2BAA2B;CAAC;CAAO;CAAQ;CAAQ;AAAK;;AAKrE,SAAgB,sBACd,OACgC;CAChC,OAAQ,yBAA+C,SAAS,KAAK;AACvE;AAEA,SAAgB,oBAAoB;CAClC,IAAI,wBACF,OAAO;CAGT,OAAO,2BAA2B;AACpC;;;;AAKA,SAAS,YAAY,SAA0B;CAC7C,IAAI;EACF,SAAS,GAAG,QAAQ,aAAa,EAAE,OAAO,SAAS,CAAC;EACpD,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;AAKA,eAAe,aAAa,SAAmC;CAC7D,IAAI;EACF,MAAM,UAAU,GAAG,QAAQ,WAAW;EACtC,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;;AAWA,MAAM,0BAA0B,yBAAyB,QACvD,YAAW,YAAY,KACzB;AAEA,MAAM,6BAA6B;CAAC;CAAQ;CAAQ;AAAK;;;;;AAMzD,SAAS,wBACP,aACQ;CACR,MAAM,YAAY,qBAAqB,CAAC,EAAE;CAC1C,IAAI,aAAa,cAAc,SAAS,sBAAsB,SAAS,GACrE,OAAO;CAGT,OAAO,2BAA2B,KAAK,WAAW,KAAK;AACzD;;;;AAKA,eAAsB,wBAAwB;CAC5C,MAAM,QAAQ,MAAM,QAAQ,IAAI,wBAAwB,IAAI,YAAY,CAAC;CAEzE,MAAM,WAAW,CAAC,OAAO,GADP,wBAAwB,QAAQ,GAAG,UAAU,MAAM,MACjC,CAAC;CAErC,uBAAuB;CACvB,yBAAyB,yBAAwB,YAC/C,SAAS,SAAS,OAAO,CAC3B;AACF;;;;AAKA,SAAgB,2BAAqC;CACnD,IAAI,sBAAsB,OAAO;CAIjC,OAAO,CAAC,OAAO,GAAG,wBAAwB,OAAO,WAAW,CAAC;AAC/D;;;;AAKA,SAAgB,6BAAqC;CACnD,IAAI,wBAAwB,OAAO;CACnC,OAAO,yBACL,YAAW,YAAY,SAAS,YAAY,OAAO,CACrD;AACF;AAEA,SAAgB,kBAAkB,gBAAwB;CACxD,yBAAyB;AAC3B;AAYA,SAAgB,yBAAyB,SAAiB;CACxD,MAAM,iBAAiB,kBAAkB;CAEzC,IAAI,mBAAmB,OAAO,OAAO,WAAW;CAEhD,OAAO,GAAG,eAAe,GAAG;AAC9B"}
1
+ {"version":3,"file":"package-manager.mjs","names":[],"sources":["../../../../../../create-warlock/src/helpers/package-manager.ts"],"sourcesContent":["import { exec, execSync } from \"child_process\";\nimport { promisify } from \"util\";\nimport detectPackageManager from \"which-pm-runs\";\n\nconst execAsync = promisify(exec);\n\nlet detectedPackageManager: string | undefined;\nlet cachedSystemManagers: string[] | undefined;\nlet cachedPreferredManager: string | undefined;\n\n/**\n * The only package managers `--pm` may select. This value reaches `spawn()`\n * as the executable to run and is spliced into the generated\n * `package.json`'s scripts — an allow-list here is a hard security\n * boundary, not just input hygiene, so it stays a fixed literal list\n * rather than anything derived from user input or the running environment.\n */\nexport const ALLOWED_PACKAGE_MANAGERS = [\"npm\", \"yarn\", \"pnpm\", \"bun\"] as const;\n\nexport type AllowedPackageManager = (typeof ALLOWED_PACKAGE_MANAGERS)[number];\n\n/** Whether `value` is one of the allow-listed package managers. */\nexport function isValidPackageManager(\n value: string,\n): value is AllowedPackageManager {\n return (ALLOWED_PACKAGE_MANAGERS as readonly string[]).includes(value);\n}\n\nexport function getPackageManager() {\n if (detectedPackageManager) {\n return detectedPackageManager;\n }\n\n return getPreferredPackageManager();\n}\n\n/**\n * Check if a package manager is installed\n */\nfunction isInstalled(manager: string): boolean {\n try {\n execSync(`${manager} --version`, { stdio: \"ignore\" });\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Check if a package manager is installed (async)\n */\nasync function checkManager(manager: string): Promise<boolean> {\n try {\n await execAsync(`${manager} --version`);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Every allow-listed manager that has to be PROBED. npm is excluded because\n * it is assumed present.\n *\n * Both detectors read this one list. They used to hold their own literal\n * copies, and the copies drifted: `bun` reached the allow-list and `--help`\n * without reaching either probe, so `--pm=bun` passed the spelling check and\n * then could never appear among the options that would honour it.\n */\nconst PROBED_PACKAGE_MANAGERS = ALLOWED_PACKAGE_MANAGERS.filter(\n manager => manager !== \"npm\",\n);\n\nconst PREFERRED_PACKAGE_MANAGERS = [\"pnpm\", \"yarn\", \"npm\"] as const;\n\n/**\n * A running non-npm manager is already usable. Every fallback must be present\n * in the detector's installed set, so both sync and async paths agree.\n */\nfunction preferredPackageManager(\n isAvailable: (manager: AllowedPackageManager) => boolean,\n): string {\n const runningPm = detectPackageManager()?.name;\n if (runningPm && runningPm !== \"npm\" && isValidPackageManager(runningPm)) {\n return runningPm;\n }\n\n return PREFERRED_PACKAGE_MANAGERS.find(isAvailable) ?? \"npm\";\n}\n\n/**\n * Detect available package managers asynchronously and cache results\n */\nexport async function detectPackageManagers() {\n const found = await Promise.all(PROBED_PACKAGE_MANAGERS.map(checkManager));\n const available = PROBED_PACKAGE_MANAGERS.filter((_, index) => found[index]);\n const managers = [\"npm\", ...available];\n\n cachedSystemManagers = managers;\n cachedPreferredManager = preferredPackageManager(manager =>\n managers.includes(manager),\n );\n}\n\n/**\n * Get available package managers on the system\n */\nexport function getSystemPackageManagers(): string[] {\n if (cachedSystemManagers) return cachedSystemManagers;\n\n // Same list the async detector probes, so the two can no longer disagree\n // about which managers exist. npm is assumed to be always available.\n return [\"npm\", ...PROBED_PACKAGE_MANAGERS.filter(isInstalled)];\n}\n\n/**\n * Get the preferred package manager based on priority\n */\nexport function getPreferredPackageManager(): string {\n if (cachedPreferredManager) return cachedPreferredManager;\n return preferredPackageManager(\n manager => manager === \"npm\" || isInstalled(manager),\n );\n}\n\nexport function setPackageManager(packageManager: string) {\n detectedPackageManager = packageManager;\n}\n\nexport function installCommand() {\n return `${getPackageManager()} install`;\n}\n\nexport function startCommand() {\n if (getPackageManager() === \"npm\") return \"npm run dev\";\n\n return `${getPackageManager()} dev`;\n}\n\nexport function runPackageManagerCommand(command: string) {\n const packageManager = getPackageManager();\n\n if (packageManager === \"npm\") return `npm run ${command}`;\n\n return `${packageManager} ${command}`;\n}\n"],"mappings":";;;;;AAIA,MAAM,YAAY,UAAU,IAAI;AAEhC,IAAI;AACJ,IAAI;AACJ,IAAI;;;;;;;;AASJ,MAAa,2BAA2B;CAAC;CAAO;CAAQ;CAAQ;AAAK;;AAKrE,SAAgB,sBACd,OACgC;CAChC,OAAQ,yBAA+C,SAAS,KAAK;AACvE;AAEA,SAAgB,oBAAoB;CAClC,IAAI,wBACF,OAAO;CAGT,OAAO,2BAA2B;AACpC;;;;AAKA,SAAS,YAAY,SAA0B;CAC7C,IAAI;EACF,SAAS,GAAG,QAAQ,aAAa,EAAE,OAAO,SAAS,CAAC;EACpD,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;AAKA,eAAe,aAAa,SAAmC;CAC7D,IAAI;EACF,MAAM,UAAU,GAAG,QAAQ,WAAW;EACtC,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;;AAWA,MAAM,0BAA0B,yBAAyB,QACvD,YAAW,YAAY,KACzB;AAEA,MAAM,6BAA6B;CAAC;CAAQ;CAAQ;AAAK;;;;;AAMzD,SAAS,wBACP,aACQ;CACR,MAAM,YAAY,qBAAqB,CAAC,EAAE;CAC1C,IAAI,aAAa,cAAc,SAAS,sBAAsB,SAAS,GACrE,OAAO;CAGT,OAAO,2BAA2B,KAAK,WAAW,KAAK;AACzD;;;;AAKA,eAAsB,wBAAwB;CAC5C,MAAM,QAAQ,MAAM,QAAQ,IAAI,wBAAwB,IAAI,YAAY,CAAC;CAEzE,MAAM,WAAW,CAAC,OAAO,GADP,wBAAwB,QAAQ,GAAG,UAAU,MAAM,MACjC,CAAC;CAErC,uBAAuB;CACvB,yBAAyB,yBAAwB,YAC/C,SAAS,SAAS,OAAO,CAC3B;AACF;;;;AAKA,SAAgB,2BAAqC;CACnD,IAAI,sBAAsB,OAAO;CAIjC,OAAO,CAAC,OAAO,GAAG,wBAAwB,OAAO,WAAW,CAAC;AAC/D;;;;AAKA,SAAgB,6BAAqC;CACnD,IAAI,wBAAwB,OAAO;CACnC,OAAO,yBACL,YAAW,YAAY,SAAS,YAAY,OAAO,CACrD;AACF;AAEA,SAAgB,kBAAkB,gBAAwB;CACxD,yBAAyB;AAC3B;AAYA,SAAgB,yBAAyB,SAAiB;CACxD,MAAM,iBAAiB,kBAAkB;CAEzC,IAAI,mBAAmB,OAAO,OAAO,WAAW;CAEhD,OAAO,GAAG,eAAe,GAAG;AAC9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"paths.mjs","names":[],"sources":["../../../../../../create-warlock/src/helpers/paths.ts"],"sourcesContent":["import path from \"path\";\r\nimport { fileURLToPath } from \"url\";\r\n\r\nconst __filename = fileURLToPath(import.meta.url);\r\n\r\nconst __dirname = path.dirname(__filename);\r\n\r\nexport type Template = \"warlock\";\r\n\r\nexport function template(templateName: Template): string {\r\n return path.resolve(__dirname, \"../\", \"../\", \"templates\", templateName);\r\n}\r\n\r\nexport function packageRoot(...paths: string[]): string {\r\n return path.resolve(__dirname, \"../\", \"../\", ...paths);\r\n}\r\n"],"mappings":";;;;AAGA,MAAM,aAAa,cAAc,OAAO,KAAK,GAAG;AAEhD,MAAM,YAAY,KAAK,QAAQ,UAAU;AAIzC,SAAgB,SAAS,cAAgC;CACvD,OAAO,KAAK,QAAQ,WAAW,OAAO,OAAO,aAAa,YAAY;AACxE;AAEA,SAAgB,YAAY,GAAG,OAAyB;CACtD,OAAO,KAAK,QAAQ,WAAW,OAAO,OAAO,GAAG,KAAK;AACvD"}
1
+ {"version":3,"file":"paths.mjs","names":[],"sources":["../../../../../../create-warlock/src/helpers/paths.ts"],"sourcesContent":["import path from \"path\";\nimport { fileURLToPath } from \"url\";\n\nconst __filename = fileURLToPath(import.meta.url);\n\nconst __dirname = path.dirname(__filename);\n\nexport type Template = \"warlock\";\n\nexport function template(templateName: Template): string {\n return path.resolve(__dirname, \"../\", \"../\", \"templates\", templateName);\n}\n\nexport function packageRoot(...paths: string[]): string {\n return path.resolve(__dirname, \"../\", \"../\", ...paths);\n}\n"],"mappings":";;;;AAGA,MAAM,aAAa,cAAc,OAAO,KAAK,GAAG;AAEhD,MAAM,YAAY,KAAK,QAAQ,UAAU;AAIzC,SAAgB,SAAS,cAAgC;CACvD,OAAO,KAAK,QAAQ,WAAW,OAAO,OAAO,aAAa,YAAY;AACxE;AAEA,SAAgB,YAAY,GAAG,OAAyB;CACtD,OAAO,KAAK,QAAQ,WAAW,OAAO,OAAO,GAAG,KAAK;AACvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"project-builder-helpers.mjs","names":[],"sources":["../../../../../../create-warlock/src/helpers/project-builder-helpers.ts"],"sourcesContent":["import { outro } from \"@clack/prompts\";\r\nimport { colors } from \"@mongez/copper\";\r\nimport {\r\n copyDirectory,\r\n getFile,\r\n getJsonFile,\r\n putFile,\r\n putJsonFile,\r\n renameFile,\r\n} from \"@warlock.js/fs\";\r\nimport path from \"path\";\r\nimport { executeCommand } from \"./exec\";\r\nimport { startCommand } from \"./package-manager\";\r\nimport { Template, template } from \"./paths\";\r\n\r\n/**\r\n * Bootstrap the project's git repository.\r\n *\r\n * Returns `false` as soon as a step fails, and leaves that step's captured\r\n * output where the caller can claim it with `takeLastCommandOutput()`. It used\r\n * to `return true` unconditionally, which meant a machine without git printed\r\n * \"Grimoire initialized!\" over a directory that was not a repository.\r\n */\r\nexport async function initializeGitRepository(appPath: string) {\r\n const steps: string[][] = [\r\n // initialize git repository\r\n [\"init\"],\r\n // switching to `main` branch\r\n [\"checkout\", \"-b\", \"main\"],\r\n // add files\r\n [\"add\", \".\"],\r\n // commit files\r\n [\"commit\", \"-m\", \"Initial commit\"],\r\n ];\r\n\r\n for (const args of steps) {\r\n const succeeded = await executeCommand(`git`, args, appPath);\r\n\r\n if (!succeeded) return false;\r\n }\r\n\r\n return true;\r\n}\r\n\r\nexport async function updateEnvFile(appPath: string, appName: string) {\r\n // update package.json file\r\n const packageJson: any = getJsonFile(path.resolve(appPath, \"package.json\"));\r\n\r\n packageJson.name = appName;\r\n\r\n putJsonFile(path.resolve(appPath, \"package.json\"), packageJson);\r\n\r\n // update env file\r\n const dotEnv = getFile(path.resolve(appPath, \".env\"))\r\n .replace(\"AppName\", appName)\r\n .replace(\r\n \"AppCodeName\",\r\n appName\r\n .split(/-|_/g)\r\n .map(word => word[0])\r\n .join(\"\"),\r\n );\r\n\r\n putFile(path.resolve(appPath, \".env\"), dotEnv);\r\n\r\n // update .env.production file\r\n let dotEnvProduction = getFile(path.resolve(appPath, \".env.shared\"));\r\n\r\n dotEnvProduction = dotEnvProduction.replace(\"AppName\", appName).replace(\r\n \"AppCodeName\",\r\n appName\r\n .split(/-|_/g)\r\n .map(word => word[0])\r\n .join(\"\"),\r\n );\r\n\r\n putFile(path.resolve(appPath, \".env.shared\"), dotEnvProduction);\r\n}\r\n\r\nexport async function copyTemplateFiles(\r\n templateName: Template,\r\n appPath: string,\r\n _appName: string,\r\n) {\r\n // copy project files\r\n copyDirectory(template(templateName), appPath);\r\n\r\n // replace _.gitignore to\r\n renameFile(\r\n path.resolve(appPath, \"_.gitignore\"),\r\n path.resolve(appPath, \".gitignore\"),\r\n );\r\n}\r\n\r\nexport async function allDone(appName: string) {\r\n outro(\r\n \"Awesome! Your project is ready to rock! \" +\r\n \"Run the following command to start development:\",\r\n );\r\n\r\n console.log(colors.cyan(`cd ${appName} && ${startCommand()}`));\r\n\r\n console.log();\r\n\r\n console.log(\r\n `Pro tip: Install the ${colors.yellow(\r\n \"Generator Z\",\r\n )} extension in VSCode for helpful code snippets and productivity boosters!`,\r\n );\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,eAAsB,wBAAwB,SAAiB;CAY7D,KAAK,MAAM,QAAQ;EATjB,CAAC,MAAM;EAEP;GAAC;GAAY;GAAM;EAAM;EAEzB,CAAC,OAAO,GAAG;EAEX;GAAC;GAAU;GAAM;EAAgB;CAGZ,GAGrB,IAAI,CAAC,MAFmB,eAAe,OAAO,MAAM,OAAO,GAE3C,OAAO;CAGzB,OAAO;AACT"}
1
+ {"version":3,"file":"project-builder-helpers.mjs","names":[],"sources":["../../../../../../create-warlock/src/helpers/project-builder-helpers.ts"],"sourcesContent":["import { outro } from \"@clack/prompts\";\nimport { colors } from \"@mongez/copper\";\nimport {\n copyDirectory,\n getFile,\n getJsonFile,\n putFile,\n putJsonFile,\n renameFile,\n} from \"@warlock.js/fs\";\nimport path from \"path\";\nimport { executeCommand } from \"./exec\";\nimport { startCommand } from \"./package-manager\";\nimport { Template, template } from \"./paths\";\n\n/**\n * Bootstrap the project's git repository.\n *\n * Returns `false` as soon as a step fails, and leaves that step's captured\n * output where the caller can claim it with `takeLastCommandOutput()`. It used\n * to `return true` unconditionally, which meant a machine without git printed\n * \"Grimoire initialized!\" over a directory that was not a repository.\n */\nexport async function initializeGitRepository(appPath: string) {\n const steps: string[][] = [\n // initialize git repository\n [\"init\"],\n // switching to `main` branch\n [\"checkout\", \"-b\", \"main\"],\n // add files\n [\"add\", \".\"],\n // commit files\n [\"commit\", \"-m\", \"Initial commit\"],\n ];\n\n for (const args of steps) {\n const succeeded = await executeCommand(`git`, args, appPath);\n\n if (!succeeded) return false;\n }\n\n return true;\n}\n\nexport async function updateEnvFile(appPath: string, appName: string) {\n // update package.json file\n const packageJson: any = getJsonFile(path.resolve(appPath, \"package.json\"));\n\n packageJson.name = appName;\n\n putJsonFile(path.resolve(appPath, \"package.json\"), packageJson);\n\n // update env file\n const dotEnv = getFile(path.resolve(appPath, \".env\"))\n .replace(\"AppName\", appName)\n .replace(\n \"AppCodeName\",\n appName\n .split(/-|_/g)\n .map(word => word[0])\n .join(\"\"),\n );\n\n putFile(path.resolve(appPath, \".env\"), dotEnv);\n\n // update .env.production file\n let dotEnvProduction = getFile(path.resolve(appPath, \".env.shared\"));\n\n dotEnvProduction = dotEnvProduction.replace(\"AppName\", appName).replace(\n \"AppCodeName\",\n appName\n .split(/-|_/g)\n .map(word => word[0])\n .join(\"\"),\n );\n\n putFile(path.resolve(appPath, \".env.shared\"), dotEnvProduction);\n}\n\nexport async function copyTemplateFiles(\n templateName: Template,\n appPath: string,\n _appName: string,\n) {\n // copy project files\n copyDirectory(template(templateName), appPath);\n\n // replace _.gitignore to\n renameFile(\n path.resolve(appPath, \"_.gitignore\"),\n path.resolve(appPath, \".gitignore\"),\n );\n}\n\nexport async function allDone(appName: string) {\n outro(\n \"Awesome! Your project is ready to rock! \" +\n \"Run the following command to start development:\",\n );\n\n console.log(colors.cyan(`cd ${appName} && ${startCommand()}`));\n\n console.log();\n\n console.log(\n `Pro tip: Install the ${colors.yellow(\n \"Generator Z\",\n )} extension in VSCode for helpful code snippets and productivity boosters!`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,eAAsB,wBAAwB,SAAiB;CAY7D,KAAK,MAAM,QAAQ;EATjB,CAAC,MAAM;EAEP;GAAC;GAAY;GAAM;EAAM;EAEzB,CAAC,OAAO,GAAG;EAEX;GAAC;GAAU;GAAM;EAAgB;CAGZ,GAGrB,IAAI,CAAC,MAFmB,eAAe,OAAO,MAAM,OAAO,GAE3C,OAAO;CAGzB,OAAO;AACT"}
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "dependencies": {
13
13
  "@clack/prompts": "^0.7.0",
14
14
  "@mongez/copper": "^2.1.3",
15
- "@warlock.js/fs": "5.24.0",
15
+ "@warlock.js/fs": "5.25.0",
16
16
  "@mongez/reinforcements": "^4.0.2",
17
17
  "cross-spawn": "^7.0.3",
18
18
  "rimraf": "^6.0.1",
@@ -21,7 +21,7 @@
21
21
  "engines": {
22
22
  "node": ">=22.13"
23
23
  },
24
- "version": "5.24.0",
24
+ "version": "5.25.0",
25
25
  "type": "module",
26
26
  "main": "./esm/index.mjs",
27
27
  "module": "./esm/index.mjs",
@@ -1,4 +1,4 @@
1
- node_modules
2
- dist
3
-
4
-
1
+ node_modules
2
+ dist
3
+
4
+
@@ -1,57 +1,148 @@
1
- # Warlock.js
1
+ # Warlock.js app
2
2
 
3
- A Blazing fast Nodejs framework to build comprehensive APIs.
3
+ A [Warlock.js](https://warlock.js.org) application — a TypeScript framework for
4
+ building APIs and, optionally, server-rendered React pages on the same server.
4
5
 
5
- For more knowledge about Warlock js, please visit Full documentation is in [Official Documentation](https://warlock.js.org).
6
+ Full documentation: [warlock.js.org](https://warlock.js.org).
6
7
 
7
- ## Start Development Server
8
+ ## Requirements
8
9
 
9
- To start the development server, run the following command
10
+ - Node.js **22.13** or newer
11
+ - The database you picked when scaffolding (MongoDB or PostgreSQL), running and
12
+ reachable with the settings in `.env` — skip this if you scaffolded with no
13
+ database
10
14
 
11
- ```bash
12
- yarn start
13
- ```
15
+ ## Getting started
14
16
 
15
- OR
17
+ The scaffolder already installed dependencies and created `.env` from
18
+ `.env.example`. Start the development server:
16
19
 
17
20
  ```bash
18
- npm start
21
+ npm run dev
19
22
  ```
20
23
 
21
- ## Build for Production
24
+ The app listens on `http://localhost:2030` by default (`HTTP_PORT` in `.env`).
25
+ It restarts on file changes.
26
+
27
+ > The commands below use `npm run`. Use your package manager's equivalent —
28
+ > `pnpm dev`, `yarn dev`, `bun run dev` — if you picked another one.
22
29
 
23
- To build the project for production, run the following command
30
+ ## Scripts
31
+
32
+ | Command | What it does |
33
+ | --- | --- |
34
+ | `npm run dev` | Development server with live reload |
35
+ | `npm run build` | Type-check and build for production |
36
+ | `npm run start` | Run the production build (run `build` first) |
37
+ | `npm run migrate` | Run pending database migrations |
38
+ | `npm run migrate.fresh` | Drop everything and re-run all migrations |
39
+ | `npm run migrate.list` | List migrations and their status |
40
+ | `npm run seed` | Run the database seeders |
41
+ | `npm run jwt` | Generate a JWT secret into `.env` |
42
+ | `npm run tsc` | Type-check without building |
43
+ | `npm run lint` | ESLint, auto-fixing what it can |
44
+ | `npm run format` | Prettier over `src/` |
45
+ | `npm run skills:sync` | Refresh the AI agent skills (see below) |
46
+
47
+ The `warlock` CLI has more than the scripts expose — run `npx warlock --help`
48
+ for the full list. Two worth knowing:
24
49
 
25
50
  ```bash
26
- yarn build
51
+ npx warlock routes # every registered route, with filters (--method, --path, --name)
52
+ npx warlock doctor # boots the app read-only and reports on routes, config, connectors and drivers
27
53
  ```
28
54
 
29
- OR
55
+ ## Production
30
56
 
31
57
  ```bash
32
58
  npm run build
59
+ npm run start
33
60
  ```
34
61
 
35
- ## Start Production Server
62
+ `start` prints its "started" line only once the server is actually serving.
63
+ Set `NODE_ENV=production` and your production `.env` values on the host.
36
64
 
37
- After building the project, run the following command to start the production server
65
+ ## Project structure
66
+
67
+ ```
68
+ src/
69
+ ├── app/ # one module per domain (users, auth, posts, …)
70
+ │ └── <module>/
71
+ │ ├── main.ts # module entry, auto-loaded
72
+ │ ├── routes.ts # the module's routes, auto-loaded
73
+ │ ├── controllers/
74
+ │ ├── services/
75
+ │ ├── models/ # models + their migrations
76
+ │ ├── repositories/
77
+ │ ├── resources/ # response shaping
78
+ │ └── schema/ # request validation
79
+ ├── config/ # app, database, cache, http, mail, storage, …
80
+ └── web/ # SSR pages — only when you chose the web stack
81
+ warlock.config.ts # framework configuration
82
+ storage/ # local file storage
83
+ .env # environment (not committed)
84
+ ```
85
+
86
+ The example modules (`users`, `auth`, `posts`) are there to show the patterns —
87
+ keep, change or delete them.
88
+
89
+ ## Generating code
38
90
 
39
91
  ```bash
40
- yarn prod
92
+ npm run gen -- <module> # a whole module
93
+ npm run gen.c -- <module>/<name> # controller
94
+ npm run gen.s -- <module>/<name> # service
95
+ npm run gen.m -- <module>/<name> # model
96
+ npm run gen.r -- <module>/<name> # repository
97
+ npm run gen.rs -- <module>/<name> # resource
98
+ npm run gen.mig -- <module>/<model> # migration for a model
41
99
  ```
42
100
 
43
- To run it in background, run the following command
101
+ ## Web pages (web stack only)
102
+
103
+ If you scaffolded with the web stack, `src/web` holds server-rendered React
104
+ pages served by the same process as the API:
105
+
106
+ - `src/web/root.tsx` — the HTML document every page renders inside
107
+ - `src/web/home/index.page.tsx` — the page at `/`
108
+ - `src/web/404.page.tsx` — the not-found page
109
+ - `*.page.tsx` files under `src/web` are pages; the folder path is the URL
110
+
111
+ Styles live in imported CSS files (`src/web/app.css`). The API-only stack has no
112
+ `src/web`; add it later with `npx warlock add web`.
113
+
114
+ ## Adding features later
115
+
116
+ Anything you didn't pick when scaffolding can be added afterwards:
44
117
 
45
118
  ```bash
46
- yarn serve
119
+ npx warlock add test # Vitest, plus test / test:watch / test:coverage scripts
120
+ npx warlock add redis queue # several at once
47
121
  ```
48
122
 
49
- > Please note that you should have nohup installed on your system to run the server in background
123
+ Run `npx warlock add --list` for the available features.
50
124
 
51
125
  ## Tests
52
126
 
53
- To run tests, run the following command
127
+ Tests need the `test` feature. If you picked it, run:
54
128
 
55
129
  ```bash
56
- yarn test
130
+ npm test
57
131
  ```
132
+
133
+ Otherwise add it with `npx warlock add test`.
134
+
135
+ ## AI coding agents
136
+
137
+ This project ships instructions and skills for AI coding agents:
138
+
139
+ - `AGENTS.md` — the source of truth for agent instructions. Tool-specific files
140
+ (`CLAUDE.md`, …) are generated from it; edit `AGENTS.md`, then run
141
+ `npm run skills:sync`.
142
+ - `skills/` — project conventions (code standards, API design, testing, …).
143
+ Package skills for every `@warlock.js/*` dependency are synced in on install.
144
+
145
+ ## Learn more
146
+
147
+ - [Documentation](https://warlock.js.org)
148
+ - [Changelog](https://warlock.js.org/changelog)
@@ -3,7 +3,7 @@
3
3
  You can create a new module using the following command:
4
4
 
5
5
  ```bash
6
- warlock create.module <module-name>
6
+ warlock generate.module <module-name>
7
7
  ```
8
8
 
9
9
  Each module should consist of the following structure:
@@ -17,18 +17,14 @@
17
17
  "gen.m": "warlock generate.model",
18
18
  "gen.c": "warlock generate.controller",
19
19
  "gen.mig": "warlock generate.migration",
20
- "gen.md": "warlock generate.model",
21
20
  "gen.r": "warlock generate.repository",
22
21
  "gen.rs": "warlock generate.resource",
23
- "gen.v": "warlock generate.validation",
24
- "serve": "yarn build && nohup warlock start > /dev/null 2>&1",
25
22
  "lint": "npx eslint --fix ./src --max-warnings=0",
26
23
  "format": "npx prettier --write ./src/**/*.{js,jsx,ts,tsx,css,md,json} --config ./.prettierrc.json",
27
24
  "tsc": "warlock generate.typings && npx tsc --noEmit",
28
25
  "postinstall": "agent-kit init && agent-kit sync || echo skills-sync-skipped",
29
26
  "skills:sync": "agent-kit sync",
30
- "skills:watch": "agent-kit watch",
31
- "lf": "find . -type d ( -name 'node_modules' -o -name '.git' ) -prune -o -type f -exec dos2unix {} ;"
27
+ "skills:watch": "agent-kit watch"
32
28
  },
33
29
  "dependencies": {
34
30
  "@mongez/reinforcements": "^4.0.2",
@@ -17,6 +17,9 @@ const databaseConfigurations: ConnectionOptions<MongoDriverOptions, MongoClientO
17
17
  uri: env("DB_URL"),
18
18
 
19
19
  driverOptions: {
20
+ // Cascade assigns sequential numeric `id`s on insert alongside Mongo's `_id`.
21
+ // Turn this off for an existing database whose documents only have `_id`, then
22
+ // set each model's primaryKey to "_id".
20
23
  autoGenerateId: true,
21
24
  counterCollection: "counters",
22
25
  },