partweave 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,201 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Agrim Sigdel
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
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Agrim Sigdel
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,16 @@
1
+ partweave
2
+ Copyright 2026 Agrim Sigdel
3
+
4
+ Created and maintained by Agrim Sigdel <sigdelagrim35@gmail.com>.
5
+ Source: https://github.com/Agrim-Sigdel/partweave
6
+
7
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
8
+
9
+ "partweave" is a trademark of Agrim Sigdel. The Apache License grants no
10
+ trademark rights (see Section 6): forks and derivative works must not use the
11
+ "partweave" name, logo, or branding to identify themselves or to market a
12
+ derived product. You may of course state, factually, that your work is derived
13
+ from or built on partweave.
14
+
15
+ Per Section 4(d) of the Apache License, this NOTICE (and the attribution above)
16
+ must be reproduced in any redistribution or derivative work.
package/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # partweave — a modular full-stack scaffolder
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/partweave.svg)](https://www.npmjs.com/package/partweave)
4
+ [![CI](https://github.com/Agrim-Sigdel/partweave/actions/workflows/ci.yml/badge.svg)](https://github.com/Agrim-Sigdel/partweave/actions/workflows/ci.yml)
5
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
6
+ [![Node](https://img.shields.io/node/v/partweave.svg)](https://www.npmjs.com/package/partweave)
7
+
3
8
  Generate new projects that contain **only the parts you pick** — a Django server, a
4
9
  Next.js web app, an Expo mobile app, and cross-cutting components (auth, storage, docker,
5
10
  CI) — all wired together.
@@ -113,6 +118,19 @@ pnpm --filter partweave typecheck # typecheck the engine
113
118
  The generator locates the catalog by walking up from the CLI to find `modules/`.
114
119
  Override with `PARTWEAVE_MODULES_DIR=/path/to/modules`.
115
120
 
121
+ See **[CONTRIBUTING.md](CONTRIBUTING.md)** for the full setup, project layout, the checks CI
122
+ enforces, and how to add a component.
123
+
124
+ ## Contributing
125
+
126
+ Contributions are welcome! The highest-leverage change is usually **a new component** — a
127
+ folder under `modules/` with a `module.json`, no engine changes required.
128
+
129
+ - Read [CONTRIBUTING.md](CONTRIBUTING.md) and the [module contract](docs/module-contract.md).
130
+ - Be kind — this project follows a [Code of Conduct](CODE_OF_CONDUCT.md).
131
+ - Found a security issue? See [SECURITY.md](SECURITY.md) — please report it privately.
132
+ - Release notes live in [CHANGELOG.md](CHANGELOG.md).
133
+
116
134
  ## Releasing
117
135
 
118
136
  The CLI is published to npm as [`partweave`](https://www.npmjs.com/package/partweave).
@@ -124,6 +142,23 @@ npm version patch --workspace partweave # bump version + create a matching git
124
142
  git push --follow-tags # push the tag → CI publishes to npm
125
143
  ```
126
144
 
127
- > One-time setup: add an `NPM_TOKEN` (an npm "Automation" access token) to the repo's
128
- > **Settings Secrets and variables Actions**. The `prepack` script copies `modules/` +
129
- > README + LICENSE into the package, so `npm publish` ships a self-contained CLI.
145
+ > The `prepack` script copies `modules/`, README, LICENSE + NOTICE into the package, so
146
+ > `npm publish` ships a self-contained CLI. Auth is via npm Trusted Publishing (OIDC) —
147
+ > no `NPM_TOKEN` secret is needed (see [`publish.yml`](.github/workflows/publish.yml)).
148
+
149
+ ## Author
150
+
151
+ Created and maintained by **Agrim Sigdel** — <sigdelagrim35@gmail.com>.
152
+
153
+ If you build something with partweave, a mention or a link back is always appreciated.
154
+
155
+ ## License
156
+
157
+ Licensed under the [Apache License 2.0](LICENSE) — permissive and free for commercial use.
158
+
159
+ - **Projects you generate are yours.** partweave copies template code into your project; you
160
+ own that output and carry no obligation back to this repo.
161
+ - **Attribution (Apache §4d):** redistributing partweave itself — or a fork of it — must keep
162
+ the [`LICENSE`](LICENSE) and [`NOTICE`](NOTICE) files intact.
163
+ - **Trademark (Apache §6):** the **partweave** name and branding are reserved. You may fork
164
+ and even sell the code, but not market a derivative under the "partweave" name.
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/commands/create.ts
4
+ import { spawnSync as spawnSync3 } from "child_process";
4
5
  import { existsSync as existsSync5, readdirSync as readdirSync3 } from "fs";
5
6
  import { basename, resolve as resolve3 } from "path";
6
- import { intro, log, note, outro, spinner } from "@clack/prompts";
7
+ import { confirm as confirm3, intro, isCancel as isCancel3, log as log2, note, outro, spinner as spinner2 } from "@clack/prompts";
7
8
  import pc2 from "picocolors";
8
9
 
9
10
  // src/compose.ts
@@ -42,6 +43,13 @@ function parseDep(dep) {
42
43
  }
43
44
  return { name: dep, version: "latest" };
44
45
  }
46
+ function normalizeWorkspaceDeps(deps, workspaceRange) {
47
+ return deps.map((dep) => {
48
+ const { name, version } = parseDep(dep);
49
+ if (version.startsWith("workspace:")) return `${name}@${workspaceRange}`;
50
+ return dep;
51
+ });
52
+ }
45
53
  function mergePackageJsonDeps(pkgJson, deps, field = "dependencies") {
46
54
  if (deps.length === 0) return pkgJson;
47
55
  const pkg = JSON.parse(pkgJson);
@@ -180,7 +188,8 @@ function jsPmProfile(name) {
180
188
  runAll: (script) => `npm run ${script} --workspaces --if-present`,
181
189
  packageManagerField: null,
182
190
  usesWorkspaceYaml: false,
183
- needsHoistNpmrc: false
191
+ needsHoisting: false,
192
+ workspaceRange: "*"
184
193
  };
185
194
  }
186
195
  return {
@@ -190,7 +199,8 @@ function jsPmProfile(name) {
190
199
  runAll: (script) => `pnpm -r ${script}`,
191
200
  packageManagerField: PNPM_VERSION,
192
201
  usesWorkspaceYaml: true,
193
- needsHoistNpmrc: true
202
+ needsHoisting: true,
203
+ workspaceRange: "workspace:*"
194
204
  };
195
205
  }
196
206
  var PIP_SYNC = "python3 -m venv .venv && .venv/bin/python -m pip install -U pip && .venv/bin/python scripts/sync_deps.py";
@@ -210,6 +220,34 @@ function pyPmProfile(name) {
210
220
  needsSyncScript: false
211
221
  };
212
222
  }
223
+ function jsPmInstallPlan(pm) {
224
+ if (pm === "npm") return null;
225
+ return {
226
+ label: "Enabling pnpm via corepack",
227
+ cmd: "corepack",
228
+ args: ["enable", "pnpm"],
229
+ hint: "corepack enable pnpm (or: npm i -g pnpm)"
230
+ };
231
+ }
232
+ function pyPmInstallPlan(pm) {
233
+ if (pm === "pip") return null;
234
+ if (process.platform === "win32") {
235
+ const ps = "irm https://astral.sh/uv/install.ps1 | iex";
236
+ return {
237
+ label: "Installing uv",
238
+ cmd: "powershell",
239
+ args: ["-ExecutionPolicy", "Bypass", "-c", ps],
240
+ hint: `powershell -ExecutionPolicy Bypass -c "${ps}"`
241
+ };
242
+ }
243
+ const sh = "curl -LsSf https://astral.sh/uv/install.sh | sh";
244
+ return {
245
+ label: "Installing uv",
246
+ cmd: "sh",
247
+ args: ["-c", sh],
248
+ hint: sh
249
+ };
250
+ }
213
251
  function hasCommand(cmd) {
214
252
  try {
215
253
  const probe = process.platform === "win32" ? spawnSync("where", [cmd], { stdio: "ignore" }) : spawnSync("sh", ["-c", `command -v ${cmd}`], { stdio: "ignore" });
@@ -239,75 +277,231 @@ function buildJsWorkspace(ctx) {
239
277
  if (!jsPmProfile(ctx.jsPm).usesWorkspaceYaml) return null;
240
278
  const members = jsMembers(ctx);
241
279
  if (members.length === 0) return null;
242
- return "packages:\n" + members.map((m) => ` - "${m}"`).join("\n") + "\n";
280
+ let out = "packages:\n" + members.map((m) => ` - "${m}"`).join("\n") + "\n";
281
+ if (ctx.hasMobile && jsPmProfile(ctx.jsPm).needsHoisting) {
282
+ out += "\n# Expo / React Native need a flat node_modules layout.\nnodeLinker: hoisted\nshamefullyHoist: true\n";
283
+ }
284
+ return out;
243
285
  }
244
- function buildRootPackageJson(ctx) {
286
+ function buildRootPackageJson(ctx, hasDocker) {
245
287
  const anyJs = ctx.hasWeb || ctx.hasMobile || ctx.hasShared;
246
- if (!anyJs) return null;
288
+ if (!anyJs && !ctx.hasServer) return null;
247
289
  const pm = jsPmProfile(ctx.jsPm);
248
- const scripts = {};
249
- if (ctx.hasWeb) scripts["dev:web"] = pm.run("web", "dev");
250
- if (ctx.hasMobile) scripts["dev:mobile"] = pm.run("mobile", "start");
251
- if (ctx.hasApiClient) scripts["gen:api"] = pm.run("@app/api-client", "generate");
252
- scripts["typecheck"] = pm.runAll("typecheck");
290
+ const t = (task) => `node scripts/run.mjs ${task}`;
291
+ const scripts = { bootstrap: t("bootstrap"), dev: t("dev") };
292
+ if (ctx.hasWeb) scripts["web"] = t("web");
293
+ if (ctx.hasMobile) scripts["mobile"] = t("mobile");
294
+ if (ctx.hasServer) {
295
+ scripts["server"] = t("server");
296
+ scripts["migrate"] = t("migrate");
297
+ scripts["superuser"] = t("superuser");
298
+ if (hasDocker) {
299
+ scripts["db:up"] = t("db:up");
300
+ scripts["db:down"] = t("db:down");
301
+ }
302
+ }
303
+ if (ctx.hasApiClient) scripts["gen:api"] = t("gen:api");
304
+ if (anyJs) scripts["typecheck"] = pm.runAll("typecheck");
253
305
  const pkg = {
254
306
  name: ctx.projectSlug,
255
307
  version: "0.1.0",
256
308
  private: true
257
309
  };
258
- if (pm.packageManagerField) pkg.packageManager = pm.packageManagerField;
259
- if (!pm.usesWorkspaceYaml) pkg.workspaces = jsMembers(ctx);
310
+ if (anyJs && pm.packageManagerField) pkg.packageManager = pm.packageManagerField;
311
+ if (anyJs && !pm.usesWorkspaceYaml) pkg.workspaces = jsMembers(ctx);
260
312
  pkg.scripts = scripts;
261
- pkg.devDependencies = { typescript: "^5.7.2" };
313
+ if (anyJs) pkg.devDependencies = { typescript: "^5.7.2" };
314
+ if (anyJs && ctx.jsPm === "pnpm") {
315
+ const allowed = {};
316
+ if (ctx.hasMobile) {
317
+ Object.assign(allowed, {
318
+ abab: "2",
319
+ domexception: "4",
320
+ glob: "7",
321
+ inflight: "1",
322
+ rimraf: "3",
323
+ uuid: "7"
324
+ });
325
+ }
326
+ if (ctx.hasWeb || ctx.hasMobile) {
327
+ allowed["whatwg-encoding"] = ctx.hasWeb && ctx.hasMobile ? "2 || 3" : ctx.hasWeb ? "3" : "2";
328
+ }
329
+ if (Object.keys(allowed).length > 0) {
330
+ pkg.pnpm = { allowedDeprecatedVersions: allowed };
331
+ }
332
+ }
262
333
  return JSON.stringify(pkg, null, 2) + "\n";
263
334
  }
335
+ function buildTaskRunner(ctx, hasDocker) {
336
+ const anyJs = ctx.hasWeb || ctx.hasMobile || ctx.hasShared;
337
+ const npm = ctx.jsPm === "npm";
338
+ const pip = ctx.pyPm === "pip";
339
+ const jsInstall = npm ? `run("npm", ["install"])` : `run("pnpm", ["install"])`;
340
+ const jsRun = (pkg, script) => npm ? `run("npm", ["run", "${script}", "-w", "${pkg}"])` : `run("pnpm", ["--filter", "${pkg}", "${script}"])`;
341
+ const pyManage = (...sub) => {
342
+ const args = sub.map((s) => `"${s}"`).join(", ");
343
+ return ctx.pyPm === "uv" ? `run("uv", ["run", "python", "manage.py", ${args}], SERVER)` : `run(venvPy, ["manage.py", ${args}], SERVER)`;
344
+ };
345
+ const serverDev = ctx.pyPm === "uv" ? `["uv", ["run", "python", "manage.py", "runserver", "0.0.0.0:8000"], SERVER]` : `[venvPy, ["manage.py", "runserver", "0.0.0.0:8000"], SERVER]`;
346
+ const jsDevTuple = (pkg, script) => npm ? `["npm", ["run", "${script}", "-w", "${pkg}"]]` : `["pnpm", ["--filter", "${pkg}", "${script}"]]`;
347
+ const devTuples = [];
348
+ if (ctx.hasServer) devTuples.push(serverDev);
349
+ if (ctx.hasWeb) devTuples.push(jsDevTuple("web", "dev"));
350
+ if (ctx.hasMobile) devTuples.push(jsDevTuple("mobile", "start"));
351
+ const needsParallel = devTuples.length > 1;
352
+ const L = [];
353
+ L.push(
354
+ `#!/usr/bin/env node`,
355
+ `// ${ctx.projectName} \u2014 cross-platform task runner (generated by partweave).`,
356
+ `// Run a task on any OS: node scripts/run.mjs <task>`,
357
+ `// Also available as: npm run <task> \xB7 make <task> (on macOS/Linux)`,
358
+ needsParallel ? `import { spawn, spawnSync } from "node:child_process";` : `import { spawnSync } from "node:child_process";`,
359
+ `import { existsSync } from "node:fs";`,
360
+ ``,
361
+ `const isWin = process.platform === "win32";`,
362
+ `const SERVER = { cwd: "apps/server" };`
363
+ );
364
+ if (ctx.hasServer && pip) {
365
+ L.push(`const venvPy = isWin ? ".venv\\\\Scripts\\\\python.exe" : ".venv/bin/python";`);
366
+ }
367
+ L.push(
368
+ ``,
369
+ `// Windows must spawn Node's .cmd shims through a shell; POSIX doesn't.`,
370
+ `function run(cmd, args = [], opts = {}) {`,
371
+ ` const r = spawnSync(cmd, args, { stdio: "inherit", shell: isWin, ...opts });`,
372
+ ` if (r.error) { console.error("\\u2716 " + cmd + ": " + r.error.message); process.exit(1); }`,
373
+ ` if (r.status) process.exit(r.status);`,
374
+ `}`,
375
+ `function has(cmd) {`,
376
+ ` const p = isWin`,
377
+ ` ? spawnSync("where", [cmd], { stdio: "ignore" })`,
378
+ ` : spawnSync("sh", ["-c", "command -v " + cmd], { stdio: "ignore" });`,
379
+ ` return p.status === 0;`,
380
+ `}`,
381
+ ``
382
+ );
383
+ if (needsParallel) {
384
+ L.push(
385
+ `// Run several long-lived dev servers at once; Ctrl-C stops them all.`,
386
+ `function parallel(specs) {`,
387
+ ` const kids = specs.map(([cmd, args, opts = {}]) =>`,
388
+ ` spawn(cmd, args, { stdio: "inherit", shell: isWin, ...opts }));`,
389
+ ` const stop = () => kids.forEach((k) => k.kill());`,
390
+ ` process.on("SIGINT", stop);`,
391
+ ` process.on("SIGTERM", stop);`,
392
+ ` kids.forEach((k) => k.on("exit", (code) => { if (code) { stop(); process.exit(code); } }));`,
393
+ `}`,
394
+ ``
395
+ );
396
+ }
397
+ const ensure = [];
398
+ if (anyJs && ctx.jsPm === "pnpm") {
399
+ ensure.push(
400
+ ` if (!has("pnpm")) {`,
401
+ ` console.log("pnpm not found \\u2014 enabling it via corepack\\u2026");`,
402
+ ` spawnSync("corepack", ["enable", "pnpm"], { stdio: "inherit", shell: isWin });`,
403
+ ` if (!has("pnpm")) { console.error("Could not enable pnpm. Install it with: npm i -g pnpm"); process.exit(1); }`,
404
+ ` }`
405
+ );
406
+ }
407
+ if (ctx.hasServer && ctx.pyPm === "uv") {
408
+ ensure.push(
409
+ ` if (!has("uv")) {`,
410
+ ` console.error("uv not found. Install it, then re-run bootstrap:\\n " + (isWin`,
411
+ ` ? 'powershell -ExecutionPolicy Bypass -c "irm https://astral.sh/uv/install.ps1 | iex"'`,
412
+ ` : "curl -LsSf https://astral.sh/uv/install.sh | sh"));`,
413
+ ` process.exit(1);`,
414
+ ` }`
415
+ );
416
+ }
417
+ if (ctx.hasServer && pip) {
418
+ ensure.push(
419
+ ` if (!has("python3") && !has("python")) { console.error("Python 3 not found. Install Python 3.12+ and re-run."); process.exit(1); }`
420
+ );
421
+ }
422
+ L.push(
423
+ `function ensureTools() {`,
424
+ ...ensure.length ? ensure : [` // npm and pip ship with Node and Python respectively.`],
425
+ `}`,
426
+ ``
427
+ );
428
+ if (ctx.hasServer && pip) {
429
+ L.push(
430
+ `function pipSync() {`,
431
+ ` const py = has("python3") ? "python3" : "python";`,
432
+ ` run(py, ["-m", "venv", ".venv"], SERVER);`,
433
+ ` run(venvPy, ["-m", "pip", "install", "-U", "pip"], SERVER);`,
434
+ ` run(venvPy, ["scripts/sync_deps.py"], SERVER);`,
435
+ `}`,
436
+ ``
437
+ );
438
+ }
439
+ L.push(`const tasks = {`);
440
+ const boot = [` ensureTools();`];
441
+ if (anyJs) boot.push(` ${jsInstall};`);
442
+ if (ctx.hasServer) boot.push(pip ? ` pipSync();` : ` run("uv", ["sync"], SERVER);`);
443
+ L.push(` bootstrap() {`, ...boot, ` },`);
444
+ if (devTuples.length === 1) {
445
+ L.push(` dev() { const [c, a, o = {}] = ${devTuples[0]}; run(c, a, o); },`);
446
+ } else if (devTuples.length > 1) {
447
+ L.push(` dev() { parallel([${devTuples.join(", ")}]); },`);
448
+ }
449
+ if (ctx.hasWeb) L.push(` web() { ${jsRun("web", "dev")}; },`);
450
+ if (ctx.hasMobile) L.push(` mobile() { ${jsRun("mobile", "start")}; },`);
451
+ if (ctx.hasServer) {
452
+ L.push(` server() { ${pyManage("runserver", "0.0.0.0:8000")}; },`);
453
+ L.push(` migrate() { ${pyManage("migrate")}; },`);
454
+ L.push(` superuser() { ${pyManage("createsuperuser")}; },`);
455
+ if (hasDocker) {
456
+ L.push(
457
+ ` "db:up"() {`,
458
+ ` if (spawnSync("docker", ["info"], { stdio: "ignore", shell: isWin }).status) {`,
459
+ ` console.error("Docker isn't running \\u2014 start Docker Desktop and retry."); process.exit(1);`,
460
+ ` }`,
461
+ ` const env = existsSync(".env") ? ["--env-file", ".env"] : [];`,
462
+ ` run("docker", ["compose", ...env, "-f", "infra/docker-compose.yml", "up", "-d", "db"]);`,
463
+ ` },`,
464
+ ` "db:down"() { run("docker", ["compose", "-f", "infra/docker-compose.yml", "down"]); },`
465
+ );
466
+ }
467
+ }
468
+ if (ctx.hasApiClient) L.push(` "gen:api"() { ${jsRun("@app/api-client", "generate")}; },`);
469
+ L.push(`};`, ``);
470
+ L.push(
471
+ `const task = process.argv[2];`,
472
+ `if (!task || !Object.hasOwn(tasks, task)) {`,
473
+ ` console.log("Tasks: " + Object.keys(tasks).join(", "));`,
474
+ ` process.exit(task ? 1 : 0);`,
475
+ `}`,
476
+ `tasks[task]();`,
477
+ ``
478
+ );
479
+ return L.join("\n");
480
+ }
264
481
  function buildMakefile(ctx, hasDocker) {
265
- const js = jsPmProfile(ctx.jsPm);
266
- const py = pyPmProfile(ctx.pyPm);
267
482
  const L = [];
268
483
  const phony = [];
269
- const add = (name, body, help) => {
484
+ const add = (name, task, help) => {
270
485
  phony.push(name);
271
- L.push(`${name}: ## ${help}`);
272
- for (const line of body) L.push(` ${line}`);
273
- L.push("");
486
+ L.push(`${name}: ## ${help}`, ` node scripts/run.mjs ${task}`, "");
274
487
  };
275
- L.push("# " + ctx.projectName + " \u2014 dev tasks");
488
+ L.push("# " + ctx.projectName + " \u2014 dev tasks (wrappers around scripts/run.mjs)");
276
489
  L.push(".DEFAULT_GOAL := help");
277
490
  L.push("");
278
- const bootstrap = [];
279
- if (ctx.hasWeb || ctx.hasMobile || ctx.hasShared) bootstrap.push(js.install);
280
- if (ctx.hasServer) bootstrap.push(`cd apps/server && ${py.syncInServer}`);
281
- if (bootstrap.length) add("bootstrap", bootstrap, "install all dependencies");
491
+ add("bootstrap", "bootstrap", "install all dependencies");
492
+ add("dev", "dev", "run all dev servers");
282
493
  if (ctx.hasServer) {
283
494
  if (hasDocker) {
284
- add(
285
- "db-up",
286
- [
287
- `@docker info >/dev/null 2>&1 || { echo "Docker isn't running \u2014 start Docker Desktop and wait for it to be ready, then retry."; exit 1; }`,
288
- // Load the project's .env (if present) so POSTGRES_* there drive the container.
289
- "docker compose $$([ -f .env ] && echo --env-file .env) -f infra/docker-compose.yml up -d db"
290
- ],
291
- "start Postgres (needs Docker running)"
292
- );
293
- add("db-down", ["docker compose -f infra/docker-compose.yml down"], "stop Postgres");
495
+ add("db-up", "db:up", "start Postgres (needs Docker running)");
496
+ add("db-down", "db:down", "stop Postgres");
294
497
  }
295
- add("migrate", [`cd apps/server && ${py.run("python manage.py migrate")}`], "run migrations");
296
- add(
297
- "server",
298
- [`cd apps/server && ${py.run("python manage.py runserver 0.0.0.0:8000")}`],
299
- "run the Django dev server"
300
- );
301
- add(
302
- "superuser",
303
- [`cd apps/server && ${py.run("python manage.py createsuperuser")}`],
304
- "create an admin user"
305
- );
498
+ add("migrate", "migrate", "run migrations");
499
+ add("server", "server", "run the Django dev server");
500
+ add("superuser", "superuser", "create an admin user");
306
501
  }
307
- if (ctx.hasWeb) add("web", [js.run("web", "dev")], "run the Next.js dev server");
308
- if (ctx.hasMobile) add("mobile", [js.run("mobile", "start")], "run the Expo dev server");
309
- if (ctx.hasApiClient)
310
- add("gen-api", [js.run("@app/api-client", "generate")], "regenerate the typed API client");
502
+ if (ctx.hasWeb) add("web", "web", "run the Next.js dev server");
503
+ if (ctx.hasMobile) add("mobile", "mobile", "run the Expo dev server");
504
+ if (ctx.hasApiClient) add("gen-api", "gen:api", "regenerate the typed API client");
311
505
  L.push(
312
506
  "help: ## show this help",
313
507
  ` @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \\033[36m%-12s\\033[0m %s\\n", $$1, $$2}'`,
@@ -354,16 +548,6 @@ function buildTsconfigBase(ctx) {
354
548
  2
355
549
  ) + "\n";
356
550
  }
357
- function buildNpmrc(ctx) {
358
- if (!ctx.hasMobile) return null;
359
- if (!jsPmProfile(ctx.jsPm).needsHoistNpmrc) return null;
360
- return [
361
- "# Expo / React Native need a flat node_modules layout.",
362
- "node-linker=hoisted",
363
- "shamefully-hoist=true",
364
- ""
365
- ].join("\n");
366
- }
367
551
  function buildBaseEnv(ctx) {
368
552
  const lines = [
369
553
  "# Environment for " + ctx.projectName,
@@ -494,7 +678,10 @@ ${jsCiSteps(ctx)}
494
678
  function buildReadme(ctx, modules) {
495
679
  const parts = [];
496
680
  parts.push(`# ${ctx.projectName}`, "", ctx.description, "");
497
- parts.push("Generated with **partweave** \u2014 a modular full-stack scaffolder.", "");
681
+ parts.push(
682
+ "Generated with [partweave](https://github.com/Agrim-Sigdel/partweave) \u2014 a modular full-stack scaffolder by Agrim Sigdel.",
683
+ ""
684
+ );
498
685
  parts.push("## What's inside", "");
499
686
  if (ctx.hasServer) parts.push(`- \`apps/server\` \u2014 Django + DRF API (managed by \`${ctx.pyPm}\`)`);
500
687
  if (ctx.hasWeb) parts.push("- `apps/web` \u2014 Next.js web app");
@@ -507,10 +694,22 @@ function buildReadme(ctx, modules) {
507
694
  for (const m of modules) parts.push(`- **${m.manifest.title}** \u2014 ${m.manifest.description ?? ""}`);
508
695
  parts.push("");
509
696
  }
510
- parts.push("## Getting started", "", "```sh", "make bootstrap");
511
- if (ctx.hasServer) parts.push("make db-up && make migrate", "make server # http://localhost:8000");
512
- if (ctx.hasWeb) parts.push("make web # http://localhost:3000");
513
- if (ctx.hasMobile) parts.push("make mobile # Expo dev server");
697
+ parts.push(
698
+ "## Getting started",
699
+ "",
700
+ "These `npm run` tasks work the same on macOS, Linux, and Windows (they wrap",
701
+ "`scripts/run.mjs`). On macOS/Linux you can also use `make <task>`.",
702
+ "",
703
+ "```sh",
704
+ "npm run bootstrap"
705
+ );
706
+ const hasDocker = modules.some((m) => m.manifest.id === "docker");
707
+ if (ctx.hasServer) {
708
+ if (hasDocker) parts.push("npm run db:up # start Postgres (needs Docker)");
709
+ parts.push("npm run migrate", "npm run server # http://localhost:8000");
710
+ }
711
+ if (ctx.hasWeb) parts.push("npm run web # http://localhost:3000");
712
+ if (ctx.hasMobile) parts.push("npm run mobile # Expo dev server");
514
713
  parts.push("```", "");
515
714
  parts.push("Copy `.env.example` to `.env` and fill in values before running.", "");
516
715
  return parts.join("\n");
@@ -729,7 +928,7 @@ function injectIntoFiles(index, anchorId, lines, targetLabel) {
729
928
  writeFileSync2(file, next);
730
929
  }
731
930
  }
732
- function applyWiring(outDir, targets, modules) {
931
+ function applyWiring(outDir, targets, modules, workspaceRange) {
733
932
  const indexes = /* @__PURE__ */ new Map();
734
933
  for (const t of targets) {
735
934
  indexes.set(t, buildAnchorIndex(join2(outDir, TARGET_DEST[t])));
@@ -753,7 +952,7 @@ function applyWiring(outDir, targets, modules) {
753
952
  if (existsSync2(pkgPath)) {
754
953
  const merged = mergePackageJsonDeps(
755
954
  readFileSync2(pkgPath, "utf8"),
756
- wiring.deps
955
+ normalizeWorkspaceDeps(wiring.deps, workspaceRange)
757
956
  );
758
957
  writeFileSync2(pkgPath, merged);
759
958
  }
@@ -774,17 +973,16 @@ function applyEnv(outDir, modules) {
774
973
  function writeStructuralRootFiles(outDir, ctx, modules) {
775
974
  const workspace = buildJsWorkspace(ctx);
776
975
  if (workspace) writeFileEnsured(join2(outDir, "pnpm-workspace.yaml"), workspace);
777
- const rootPkg = buildRootPackageJson(ctx);
976
+ const hasDocker = modules.some((m) => m.manifest.id === "docker");
977
+ const rootPkg = buildRootPackageJson(ctx, hasDocker);
778
978
  if (rootPkg) writeFileEnsured(join2(outDir, "package.json"), rootPkg);
779
979
  const turbo = buildTurboJson(ctx);
780
980
  if (turbo) writeFileEnsured(join2(outDir, "turbo.json"), turbo);
781
981
  const tsbase = buildTsconfigBase(ctx);
782
982
  if (tsbase) writeFileEnsured(join2(outDir, "tsconfig.base.json"), tsbase);
783
- const npmrc = buildNpmrc(ctx);
784
- if (npmrc) writeFileEnsured(join2(outDir, ".npmrc"), npmrc);
785
983
  const pipSync = buildPipSyncScript(ctx);
786
984
  if (pipSync) writeFileEnsured(join2(outDir, "apps/server/scripts/sync_deps.py"), pipSync);
787
- const hasDocker = modules.some((m) => m.manifest.id === "docker");
985
+ writeFileEnsured(join2(outDir, "scripts/run.mjs"), buildTaskRunner(ctx, hasDocker));
788
986
  writeFileEnsured(join2(outDir, "Makefile"), buildMakefile(ctx, hasDocker));
789
987
  writeFileEnsured(join2(outDir, ".env.example"), buildBaseEnv(ctx));
790
988
  }
@@ -814,7 +1012,7 @@ function compose(opts) {
814
1012
  }
815
1013
  }
816
1014
  }
817
- applyWiring(outDir, wireTargets, modules);
1015
+ applyWiring(outDir, wireTargets, modules, jsPmProfile(ctx.jsPm).workspaceRange);
818
1016
  applyEnv(outDir, modules);
819
1017
  if (selection.modules.includes("ci")) {
820
1018
  for (const [rel, content] of Object.entries(buildCiWorkflows(ctx))) {
@@ -831,6 +1029,43 @@ function compose(opts) {
831
1029
  return { written, notes };
832
1030
  }
833
1031
 
1032
+ // src/preflight.ts
1033
+ import { spawnSync as spawnSync2 } from "child_process";
1034
+ import { confirm, isCancel, log, spinner } from "@clack/prompts";
1035
+ function runInstall(plan, probe) {
1036
+ const s = spinner();
1037
+ s.start(plan.label);
1038
+ const r = spawnSync2(plan.cmd, plan.args, {
1039
+ stdio: ["ignore", "ignore", "inherit"],
1040
+ shell: process.platform === "win32"
1041
+ });
1042
+ const ok = r.status === 0 && hasCommand(probe);
1043
+ s.stop(ok ? `${probe} is ready` : `Could not install ${probe}`);
1044
+ return ok;
1045
+ }
1046
+ async function ensurePm(chosen, fallback, plan, opts) {
1047
+ if (hasCommand(chosen)) return chosen;
1048
+ if (!plan) return chosen;
1049
+ let doInstall = opts.install === true;
1050
+ if (opts.interactive) {
1051
+ const answer = await confirm({
1052
+ message: `${chosen} isn't installed. Install it now? (${plan.hint})`
1053
+ });
1054
+ doInstall = !isCancel(answer) && answer === true;
1055
+ }
1056
+ if (doInstall && runInstall(plan, chosen)) return chosen;
1057
+ log.warn(
1058
+ `Using ${fallback} instead of ${chosen}. To use ${chosen} later, run: ${plan.hint}`
1059
+ );
1060
+ return fallback;
1061
+ }
1062
+ function ensureJsPm(pm, opts) {
1063
+ return ensurePm(pm, "npm", jsPmInstallPlan(pm), opts);
1064
+ }
1065
+ function ensurePyPm(pm, opts) {
1066
+ return ensurePm(pm, "pip", pyPmInstallPlan(pm), opts);
1067
+ }
1068
+
834
1069
  // src/registry.ts
835
1070
  import { readdirSync as readdirSync2, readFileSync as readFileSync3, statSync as statSync2 } from "fs";
836
1071
  import { join as join4 } from "path";
@@ -1004,8 +1239,8 @@ Enable the required app(s) or drop the component(s).`
1004
1239
  // src/prompts.ts
1005
1240
  import {
1006
1241
  cancel,
1007
- confirm,
1008
- isCancel,
1242
+ confirm as confirm2,
1243
+ isCancel as isCancel2,
1009
1244
  multiselect,
1010
1245
  select,
1011
1246
  text
@@ -1014,7 +1249,7 @@ import pc from "picocolors";
1014
1249
  import { resolve as resolve2 } from "path";
1015
1250
  var MULTI_HINT = pc.dim("\u2191/\u2193 move \xB7 space toggle \xB7 a all \xB7 enter confirm");
1016
1251
  function bail(v) {
1017
- if (isCancel(v)) {
1252
+ if (isCancel2(v)) {
1018
1253
  cancel("Cancelled.");
1019
1254
  process.exit(0);
1020
1255
  }
@@ -1092,7 +1327,7 @@ async function promptCreate(registry, defaults) {
1092
1327
  bail(pyRaw);
1093
1328
  pyPm = pyRaw;
1094
1329
  }
1095
- const ok = await confirm({
1330
+ const ok = await confirm2({
1096
1331
  message: `Scaffold ${apps.join(" + ")}${modules.length ? " with " + modules.join(", ") : ""} into ${outDir}?`
1097
1332
  });
1098
1333
  bail(ok);
@@ -1107,7 +1342,7 @@ async function promptCreate(registry, defaults) {
1107
1342
  function resolvePm(value, allowed, detect, flag) {
1108
1343
  if (value === void 0) return detect();
1109
1344
  if (allowed.includes(value)) return value;
1110
- log.error(`Invalid ${flag} "${value}". Choose one of: ${allowed.join(", ")}.`);
1345
+ log2.error(`Invalid ${flag} "${value}". Choose one of: ${allowed.join(", ")}.`);
1111
1346
  process.exit(1);
1112
1347
  }
1113
1348
  function appsFromFlags(flags) {
@@ -1149,26 +1384,33 @@ async function runCreate(flags) {
1149
1384
  });
1150
1385
  }
1151
1386
  if (existsSync5(choices.outDir) && readdirSync3(choices.outDir).length > 0 && !flags.force) {
1152
- log.error(`${choices.outDir} exists and is not empty. Use --force to override.`);
1387
+ log2.error(`${choices.outDir} exists and is not empty. Use --force to override.`);
1153
1388
  process.exit(1);
1154
1389
  }
1390
+ const ensureOpts = { interactive: !nonInteractive, install: flags.install };
1391
+ if (choices.apps.includes("web") || choices.apps.includes("mobile")) {
1392
+ choices.jsPm = await ensureJsPm(choices.jsPm, ensureOpts);
1393
+ }
1394
+ if (choices.apps.includes("server")) {
1395
+ choices.pyPm = await ensurePyPm(choices.pyPm, ensureOpts);
1396
+ }
1155
1397
  let resolved;
1156
1398
  try {
1157
1399
  resolved = resolveModules(registry, choices.modules);
1158
1400
  } catch (err) {
1159
- log.error(err.message);
1401
+ log2.error(err.message);
1160
1402
  process.exit(1);
1161
1403
  }
1162
1404
  if (resolved.autoAdded.length) {
1163
- log.info(`Added required components: ${resolved.autoAdded.join(", ")}`);
1405
+ log2.info(`Added required components: ${resolved.autoAdded.join(", ")}`);
1164
1406
  }
1165
1407
  try {
1166
1408
  validateApps(registry, resolved.modules, choices.apps);
1167
1409
  } catch (err) {
1168
- log.error(err.message);
1410
+ log2.error(err.message);
1169
1411
  process.exit(1);
1170
1412
  }
1171
- const s = spinner();
1413
+ const s = spinner2();
1172
1414
  s.start("Scaffolding");
1173
1415
  let result;
1174
1416
  try {
@@ -1190,7 +1432,7 @@ async function runCreate(flags) {
1190
1432
  });
1191
1433
  } catch (err) {
1192
1434
  s.stop("Failed");
1193
- log.error(err.message);
1435
+ log2.error(err.message);
1194
1436
  process.exit(1);
1195
1437
  }
1196
1438
  s.stop(`Created ${result.written.length} files`);
@@ -1201,25 +1443,52 @@ async function runCreate(flags) {
1201
1443
  jsPm: choices.jsPm,
1202
1444
  pyPm: choices.pyPm
1203
1445
  });
1446
+ let installed = false;
1447
+ if (nonInteractive) {
1448
+ installed = flags.install === true;
1449
+ } else {
1450
+ const ans = await confirm3({ message: "Install dependencies now?" });
1451
+ installed = !isCancel3(ans) && ans === true;
1452
+ }
1453
+ if (installed) {
1454
+ log2.step("Installing dependencies (npm run bootstrap)\u2026");
1455
+ const r = spawnSync3("node", ["scripts/run.mjs", "bootstrap"], {
1456
+ cwd: choices.outDir,
1457
+ stdio: "inherit"
1458
+ });
1459
+ if (r.status) {
1460
+ log2.warn("bootstrap didn't finish cleanly \u2014 run `npm run bootstrap` in the project to retry.");
1461
+ installed = false;
1462
+ }
1463
+ }
1204
1464
  const rel = basename(choices.outDir);
1205
- const steps = [`cd ${rel}`, "make bootstrap"];
1206
- if (choices.apps.includes("server")) steps.push("make db-up && make migrate", "make server");
1207
- if (choices.apps.includes("web")) steps.push("make web");
1208
- if (choices.apps.includes("mobile")) steps.push("make mobile");
1209
- note(steps.join("\n"), "Next steps");
1465
+ const hasDocker = resolved.modules.includes("docker");
1466
+ const steps = [`cd ${rel}`];
1467
+ if (!installed) steps.push("npm run bootstrap");
1468
+ if (choices.apps.includes("server")) {
1469
+ steps.push(hasDocker ? "npm run db:up && npm run migrate" : "npm run migrate");
1470
+ steps.push("npm run server");
1471
+ }
1472
+ if (choices.apps.includes("web")) steps.push("npm run web");
1473
+ if (choices.apps.includes("mobile")) steps.push("npm run mobile");
1474
+ note(
1475
+ steps.join("\n") + "\n\n" + pc2.dim("These work on macOS, Linux & Windows. On macOS/Linux, `make <task>` works too."),
1476
+ "Next steps"
1477
+ );
1210
1478
  if (result.notes.length) note(result.notes.join("\n"), "Notes");
1211
1479
  outro(pc2.green("Done."));
1212
1480
  }
1213
1481
 
1214
1482
  export {
1215
- DEFAULT_JS_PM,
1216
- DEFAULT_PY_PM,
1217
- jsPmProfile,
1218
- pyPmProfile,
1483
+ jsPmInstallPlan,
1484
+ pyPmInstallPlan,
1485
+ hasCommand,
1219
1486
  APPS,
1220
1487
  buildContext,
1221
1488
  selectedTargets,
1222
1489
  compose,
1490
+ ensureJsPm,
1491
+ ensurePyPm,
1223
1492
  Registry,
1224
1493
  readProjectManifest,
1225
1494
  writeProjectManifest,
@@ -1227,4 +1496,4 @@ export {
1227
1496
  validateApps,
1228
1497
  runCreate
1229
1498
  };
1230
- //# sourceMappingURL=chunk-2IGBGILB.js.map
1499
+ //# sourceMappingURL=chunk-ANKGMR2Z.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCreate
4
- } from "./chunk-2IGBGILB.js";
4
+ } from "./chunk-ANKGMR2Z.js";
5
5
 
6
6
  // src/create-bin.ts
7
7
  import { Command } from "commander";
package/dist/index.js CHANGED
@@ -1,20 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  APPS,
4
- DEFAULT_JS_PM,
5
- DEFAULT_PY_PM,
6
4
  Registry,
7
5
  buildContext,
8
6
  compose,
9
- jsPmProfile,
10
- pyPmProfile,
7
+ ensureJsPm,
8
+ ensurePyPm,
9
+ hasCommand,
10
+ jsPmInstallPlan,
11
+ pyPmInstallPlan,
11
12
  readProjectManifest,
12
13
  resolveModules,
13
14
  runCreate,
14
15
  selectedTargets,
15
16
  validateApps,
16
17
  writeProjectManifest
17
- } from "./chunk-2IGBGILB.js";
18
+ } from "./chunk-ANKGMR2Z.js";
18
19
 
19
20
  // src/index.ts
20
21
  import { Command } from "commander";
@@ -54,13 +55,9 @@ async function runAdd(ids, flags) {
54
55
  let manifest = pm;
55
56
  if (appIds.length) manifest = addApps(registry, dir, manifest, appIds);
56
57
  if (moduleIds.length) manifest = addModules(registry, dir, manifest, moduleIds);
57
- const js = jsPmProfile(manifest.jsPm ?? DEFAULT_JS_PM);
58
- const py = pyPmProfile(manifest.pyPm ?? DEFAULT_PY_PM);
59
- const reinstall = [];
60
- if (manifest.apps.some((a) => a === "web" || a === "mobile")) reinstall.push(js.install);
61
- if (manifest.apps.includes("server"))
62
- reinstall.push(`cd apps/server && ${py.syncInServer} && ${py.run("python manage.py migrate")}`);
63
- if (reinstall.length) note(reinstall.join("\n"), "Sync deps");
58
+ const reinstall = ["npm run bootstrap"];
59
+ if (manifest.apps.includes("server")) reinstall.push("npm run migrate");
60
+ note(reinstall.join("\n"), "Sync deps");
64
61
  outro(pc.green("Done."));
65
62
  }
66
63
  function addApps(registry, dir, pm, appIds) {
@@ -135,17 +132,62 @@ function addModules(registry, dir, pm, moduleIds) {
135
132
  return updated;
136
133
  }
137
134
 
135
+ // src/commands/doctor.ts
136
+ import { spawnSync } from "child_process";
137
+ import { resolve as resolve2 } from "path";
138
+ import { intro as intro2, note as note2, outro as outro2 } from "@clack/prompts";
139
+ import pc2 from "picocolors";
140
+ function version(cmd) {
141
+ const r = spawnSync(cmd, ["--version"], { encoding: "utf8" });
142
+ if (r.error || r.status !== 0) return null;
143
+ return (r.stdout || r.stderr || "").trim().split("\n")[0] ?? "";
144
+ }
145
+ async function runDoctor(flags) {
146
+ intro2(pc2.bgCyan(pc2.black(" partweave ")) + pc2.dim(" doctor"));
147
+ const dir = resolve2(flags.dir ?? process.cwd());
148
+ const project = readProjectManifest(dir);
149
+ const rows = [];
150
+ const check = (label, cmd, optional = false) => {
151
+ const v = version(cmd);
152
+ const ok = v !== null;
153
+ const mark = ok ? pc2.green("\u2713") : optional ? pc2.yellow("\u25CB") : pc2.red("\u2717");
154
+ const detail = ok ? pc2.dim(v) : pc2.dim(optional ? "not found (optional)" : "not found");
155
+ rows.push(`${mark} ${label.padEnd(9)} ${detail}`);
156
+ return ok;
157
+ };
158
+ check("node", "node");
159
+ check("npm", "npm");
160
+ check("pnpm", "pnpm", true);
161
+ check("uv", "uv", true);
162
+ check("python", process.platform === "win32" ? "python" : "python3", true);
163
+ check("docker", "docker", true);
164
+ check("make", "make", true);
165
+ note2(rows.join("\n"), project ? `Environment for ${project.name}` : "Environment");
166
+ const jsPm = project?.jsPm ?? "pnpm";
167
+ const pyPm = project?.pyPm ?? "uv";
168
+ if (jsPmInstallPlan(jsPm) && !hasCommand(jsPm)) {
169
+ await ensureJsPm(jsPm, { interactive: true });
170
+ }
171
+ if (pyPmInstallPlan(pyPm) && !hasCommand(pyPm)) {
172
+ await ensurePyPm(pyPm, { interactive: true });
173
+ }
174
+ outro2(pc2.green("Done."));
175
+ }
176
+
138
177
  // src/index.ts
139
178
  function buildProgram() {
140
179
  const program = new Command();
141
180
  program.name("partweave").description("A modular full-stack scaffolder \u2014 pick parts, generate only that code.").version("0.1.0");
142
- program.command("create", { isDefault: true }).argument("[name]", "project name").description("Scaffold a new project").option("-d, --dir <path>", "target directory").option("--server", "include the Django server").option("--no-server", "exclude the server").option("--web", "include the Next.js web app").option("--no-web", "exclude the web app").option("--mobile", "include the Expo mobile app").option("--no-mobile", "exclude the mobile app").option("--with <ids>", "comma-separated component ids (e.g. auth,docker,ci)").option("--js-pm <pm>", "JS package manager: pnpm | npm (default: auto-detect)").option("--py-pm <pm>", "Python package manager: uv | pip (default: auto-detect)").option("-y, --yes", "skip prompts; use flags/defaults").option("-f, --force", "write into a non-empty directory").action(async (name, opts) => {
181
+ program.command("create", { isDefault: true }).argument("[name]", "project name").description("Scaffold a new project").option("-d, --dir <path>", "target directory").option("--server", "include the Django server").option("--no-server", "exclude the server").option("--web", "include the Next.js web app").option("--no-web", "exclude the web app").option("--mobile", "include the Expo mobile app").option("--no-mobile", "exclude the mobile app").option("--with <ids>", "comma-separated component ids (e.g. auth,docker,ci)").option("--js-pm <pm>", "JS package manager: pnpm | npm (default: auto-detect)").option("--py-pm <pm>", "Python package manager: uv | pip (default: auto-detect)").option("-y, --yes", "skip prompts; use flags/defaults").option("-f, --force", "write into a non-empty directory").option("--install", "install dependencies after scaffolding (default: ask, off with --yes)").action(async (name, opts) => {
143
182
  const flags = { ...opts, name: name ?? opts.name };
144
183
  await runCreate(flags);
145
184
  });
146
185
  program.command("add").argument("<items...>", "apps (server/web/mobile) or component ids to add").description("Add an app or component to an existing generated project").option("-d, --dir <path>", "project directory (default: cwd)").action(async (items, opts) => {
147
186
  await runAdd(items, opts);
148
187
  });
188
+ program.command("doctor").description("Check your environment and install any missing package managers").option("-d, --dir <path>", "project directory (default: cwd)").action(async (opts) => {
189
+ await runDoctor(opts);
190
+ });
149
191
  return program;
150
192
  }
151
193
  async function main(argv = process.argv) {
@@ -159,6 +201,7 @@ export {
159
201
  buildProgram,
160
202
  main,
161
203
  runAdd,
162
- runCreate
204
+ runCreate,
205
+ runDoctor
163
206
  };
164
207
  //# sourceMappingURL=index.js.map
@@ -13,6 +13,24 @@ config.resolver.nodeModulesPaths = [
13
13
  path.resolve(projectRoot, "node_modules"),
14
14
  path.resolve(workspaceRoot, "node_modules"),
15
15
  ];
16
- config.resolver.disableHierarchicalLookup = true;
16
+ // Keep Metro's default hierarchical node_modules lookup ON: under npm (and any
17
+ // non-hoisted install) some Expo sub-deps (e.g. expo-asset) resolve from
18
+ // expo/node_modules, and disabling the walk-up breaks bundling them.
19
+
20
+ // Keep test files out of the native bundle. Expo Router builds a require.context
21
+ // over the whole app/ directory, so a colocated `*.test.tsx` would otherwise get
22
+ // bundled — dragging in @testing-library/react-native and Node built-ins
23
+ // (console, util) that don't exist in the RN runtime, and failing the build.
24
+ // Metro's blockList removes them from resolution (and thus from require.context);
25
+ // Jest doesn't read this config, so `npm test` still finds and runs them.
26
+ config.resolver.blockList = [
27
+ ...(Array.isArray(config.resolver.blockList)
28
+ ? config.resolver.blockList
29
+ : config.resolver.blockList
30
+ ? [config.resolver.blockList]
31
+ : []),
32
+ /\.(test|spec)\.[jt]sx?$/,
33
+ /[/\\]__tests__[/\\]/,
34
+ ];
17
35
 
18
36
  module.exports = config;
@@ -29,8 +29,10 @@
29
29
  "@testing-library/react-native": "^13.2.0",
30
30
  "@types/jest": "^29.5.14",
31
31
  "@types/react": "~19.1.10",
32
+ "babel-preset-expo": "~54.0.7",
32
33
  "jest": "^29.7.0",
33
34
  "jest-expo": "~54.0.0",
35
+ "react-test-renderer": "19.1.0",
34
36
  "typescript": "~5.9.2"
35
37
  }
36
38
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "partweave",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "A modular full-stack scaffolder — pick the parts you need (Django server, Next.js web, Expo mobile) and generate only that code, wired together.",
5
5
  "type": "module",
6
- "license": "MIT",
6
+ "license": "Apache-2.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
10
- "author": "Agrim Sigdel",
10
+ "author": "Agrim Sigdel <sigdelagrim35@gmail.com>",
11
11
  "homepage": "https://github.com/Agrim-Sigdel/partweave#readme",
12
12
  "repository": {
13
13
  "type": "git",
@@ -41,7 +41,8 @@
41
41
  "dist/**/*.js",
42
42
  "modules",
43
43
  "README.md",
44
- "LICENSE"
44
+ "LICENSE",
45
+ "NOTICE"
45
46
  ],
46
47
  "scripts": {
47
48
  "build": "tsup",