@pauldvlp/vp-react-ts-nestjs 0.3.3 → 0.3.5
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 +1 -1
- package/README.md +9 -9
- package/dist/index.js +75 -14
- package/package.json +4 -3
- package/template/_package.json +1 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -36,16 +36,16 @@ vp create @pauldvlp:vp-react-ts-nestjs -- \
|
|
|
36
36
|
|
|
37
37
|
## Options
|
|
38
38
|
|
|
39
|
-
| Option | Type / values | Default | Notes
|
|
40
|
-
| ------------ | ------------- | --------- |
|
|
41
|
-
| `--name` | string | `my-app` | Root project / package name.
|
|
39
|
+
| Option | Type / values | Default | Notes |
|
|
40
|
+
| ------------ | ------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
41
|
+
| `--name` | string | `my-app` | Root project / package name. |
|
|
42
42
|
| `--scope` | string | `@<name>` | npm scope for workspace packages → `@scope/web`, `@scope/api`, `@scope/contracts`. Defaults to the project name prefixed with `@` (e.g. `--name acme` → `@acme`); falls back to `@app`. |
|
|
43
|
-
| `--apiPort` | string | `3000` | Port the NestJS api listens on (substituted into the env default + the web proxy).
|
|
44
|
-
| `--webPort` | string | `5173` | Port the web dev server listens on.
|
|
45
|
-
| `--swagger` | boolean | `false` | Expose Swagger UI at `/docs` and the OpenAPI JSON at `/docs.json` (adds `@nestjs/swagger`).
|
|
46
|
-
| `--serveWeb` | boolean | `false` | Have the api serve the built web app for a single deployable (adds `@nestjs/serve-static`).
|
|
47
|
-
| `--docker` | boolean | `false` | Emit a multi-stage `apps/api/Dockerfile` (+ root `.dockerignore`).
|
|
48
|
-
| `--install` | boolean | `true` | Run `pnpm install` after scaffolding. `false` = files only.
|
|
43
|
+
| `--apiPort` | string | `3000` | Port the NestJS api listens on (substituted into the env default + the web proxy). |
|
|
44
|
+
| `--webPort` | string | `5173` | Port the web dev server listens on. |
|
|
45
|
+
| `--swagger` | boolean | `false` | Expose Swagger UI at `/docs` and the OpenAPI JSON at `/docs.json` (adds `@nestjs/swagger`). |
|
|
46
|
+
| `--serveWeb` | boolean | `false` | Have the api serve the built web app for a single deployable (adds `@nestjs/serve-static`). |
|
|
47
|
+
| `--docker` | boolean | `false` | Emit a multi-stage `apps/api/Dockerfile` (+ root `.dockerignore`). |
|
|
48
|
+
| `--install` | boolean | `true` | Run `pnpm install` after scaffolding. `false` = files only. |
|
|
49
49
|
|
|
50
50
|
## What it scaffolds
|
|
51
51
|
|
package/dist/index.js
CHANGED
|
@@ -103,7 +103,10 @@ function resolveDefault(d, options, directory) {
|
|
|
103
103
|
}
|
|
104
104
|
async function promptForOption(d, def) {
|
|
105
105
|
if (d.type === "boolean") {
|
|
106
|
-
return prompts.confirm({
|
|
106
|
+
return prompts.confirm({
|
|
107
|
+
message: d.message,
|
|
108
|
+
initialValue: def === void 0 ? false : Boolean(def)
|
|
109
|
+
});
|
|
107
110
|
}
|
|
108
111
|
if (d.type === "select") {
|
|
109
112
|
return prompts.select({
|
|
@@ -148,7 +151,11 @@ function initGit(dir) {
|
|
|
148
151
|
} catch {
|
|
149
152
|
identity = ["-c", "user.name=create", "-c", "user.email=create@users.noreply.github.com"];
|
|
150
153
|
}
|
|
151
|
-
execFileSync(
|
|
154
|
+
execFileSync(
|
|
155
|
+
"git",
|
|
156
|
+
[...identity, "commit", "-m", "feat: initialize project", "--no-gpg-sign"],
|
|
157
|
+
{ cwd: dir, stdio: "ignore" }
|
|
158
|
+
);
|
|
152
159
|
} catch {
|
|
153
160
|
}
|
|
154
161
|
}
|
|
@@ -164,7 +171,11 @@ async function runTemplateCLI(template) {
|
|
|
164
171
|
let directory = dirArg;
|
|
165
172
|
if (!directory) {
|
|
166
173
|
if (interactive) {
|
|
167
|
-
const answer = await prompts.text({
|
|
174
|
+
const answer = await prompts.text({
|
|
175
|
+
message: "Where should we create your project?",
|
|
176
|
+
placeholder: "my-app",
|
|
177
|
+
defaultValue: "my-app"
|
|
178
|
+
});
|
|
168
179
|
if (prompts.isCancel(answer)) {
|
|
169
180
|
prompts.cancel("Cancelled.");
|
|
170
181
|
return 2;
|
|
@@ -206,7 +217,11 @@ async function runTemplateCLI(template) {
|
|
|
206
217
|
for (const step of [...creation.scripts].sort((a, b) => a.phase - b.phase)) {
|
|
207
218
|
for (const [program, ...commandArgs] of step.commands) {
|
|
208
219
|
if (!program) continue;
|
|
209
|
-
execFileSync(program, commandArgs, {
|
|
220
|
+
execFileSync(program, commandArgs, {
|
|
221
|
+
cwd: directory,
|
|
222
|
+
stdio: "inherit",
|
|
223
|
+
shell: process.platform === "win32"
|
|
224
|
+
});
|
|
210
225
|
}
|
|
211
226
|
}
|
|
212
227
|
}
|
|
@@ -250,16 +265,55 @@ var template_default = defineTemplate({
|
|
|
250
265
|
},
|
|
251
266
|
options: [
|
|
252
267
|
// Default the name to the target directory the user chose, so they don't retype it.
|
|
253
|
-
{
|
|
268
|
+
{
|
|
269
|
+
key: "name",
|
|
270
|
+
type: "string",
|
|
271
|
+
message: "Root project / package name",
|
|
272
|
+
default: ({ directory }) => dirName(directory),
|
|
273
|
+
validate: validateName
|
|
274
|
+
},
|
|
254
275
|
// Lazily default the package scope to `@<name>` (prefixing `@` unless the name already has one),
|
|
255
276
|
// so it tracks the project name instead of a fixed value. Falls back to `@app` when no name is set.
|
|
256
|
-
{
|
|
277
|
+
{
|
|
278
|
+
key: "scope",
|
|
279
|
+
type: "string",
|
|
280
|
+
message: "npm scope for workspace packages, e.g. @acme (defaults to @<name>)",
|
|
281
|
+
default: ({ options }) => options.name ? toScope(options.name) : "@app",
|
|
282
|
+
validate: validateScope
|
|
283
|
+
},
|
|
257
284
|
// Ports stay strings (validated as integers): they're only ever substituted into config files as text.
|
|
258
|
-
{
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
285
|
+
{
|
|
286
|
+
key: "apiPort",
|
|
287
|
+
type: "string",
|
|
288
|
+
message: "Port the NestJS api listens on",
|
|
289
|
+
default: "3000",
|
|
290
|
+
validate: validatePort
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
key: "webPort",
|
|
294
|
+
type: "string",
|
|
295
|
+
message: "Port the web dev server listens on",
|
|
296
|
+
default: "5173",
|
|
297
|
+
validate: validatePort
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
key: "swagger",
|
|
301
|
+
type: "boolean",
|
|
302
|
+
message: "Expose Swagger UI at /docs on the api",
|
|
303
|
+
default: false
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
key: "serveWeb",
|
|
307
|
+
type: "boolean",
|
|
308
|
+
message: "Have the api serve the built web app (single deployable)",
|
|
309
|
+
default: false
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
key: "docker",
|
|
313
|
+
type: "boolean",
|
|
314
|
+
message: "Add a multi-stage Dockerfile for the api",
|
|
315
|
+
default: false
|
|
316
|
+
},
|
|
263
317
|
{ key: "install", type: "boolean", message: "Install deps after scaffolding", default: true }
|
|
264
318
|
],
|
|
265
319
|
async produce({ options }) {
|
|
@@ -274,7 +328,10 @@ var template_default = defineTemplate({
|
|
|
274
328
|
out = options.swagger ? out.replace("// __SWAGGER_IMPORT__", SWAGGER_IMPORT).replace("// __SWAGGER_SETUP__", swaggerSetup) : out.replace(/^[ \t]*\/\/ __SWAGGER_(IMPORT|SETUP)__\n/gm, "");
|
|
275
329
|
}
|
|
276
330
|
if (rel === APP_MODULE) {
|
|
277
|
-
out = options.serveWeb ? out.replace("// __SERVEWEB_PATH_IMPORT__", "import { join } from 'node:path'\n").replace(
|
|
331
|
+
out = options.serveWeb ? out.replace("// __SERVEWEB_PATH_IMPORT__", "import { join } from 'node:path'\n").replace(
|
|
332
|
+
"// __SERVEWEB_MODULE_IMPORT__",
|
|
333
|
+
"import { ServeStaticModule } from '@nestjs/serve-static'"
|
|
334
|
+
).replace(" // __SERVEWEB_MODULE__", SERVEWEB_MODULE) : out.replace(/^[ \t]*\/\/ __SERVEWEB_[A-Z_]+__\n/gm, "");
|
|
278
335
|
}
|
|
279
336
|
if (rel === "README.md") {
|
|
280
337
|
out = applyDocBlock(out, "SWAGGER", options.swagger);
|
|
@@ -288,7 +345,9 @@ var template_default = defineTemplate({
|
|
|
288
345
|
const deps = { ...pkg.dependencies };
|
|
289
346
|
if (options.swagger) deps["@nestjs/swagger"] = "^11";
|
|
290
347
|
if (options.serveWeb) deps["@nestjs/serve-static"] = "^5";
|
|
291
|
-
pkg.dependencies = Object.fromEntries(
|
|
348
|
+
pkg.dependencies = Object.fromEntries(
|
|
349
|
+
Object.entries(deps).sort(([a], [b]) => a.localeCompare(b))
|
|
350
|
+
);
|
|
292
351
|
});
|
|
293
352
|
}
|
|
294
353
|
if (!options.docker) {
|
|
@@ -303,7 +362,9 @@ var template_default = defineTemplate({
|
|
|
303
362
|
`cd into the project and run \`vp run -r dev\` to start web + api together.`,
|
|
304
363
|
`The web app proxies \`/api\` to the NestJS server on port ${options.apiPort}.`,
|
|
305
364
|
...options.swagger ? [`Swagger UI: http://localhost:${options.apiPort}/docs (OpenAPI JSON at /docs.json).`] : [],
|
|
306
|
-
...options.serveWeb ? [
|
|
365
|
+
...options.serveWeb ? [
|
|
366
|
+
`--serveWeb is on: after \`vp run -r build\`, \`node apps/api/dist/main.js\` serves the web app from the api.`
|
|
367
|
+
] : [],
|
|
307
368
|
options.install ? `Run \`vp check\` to lint, format and type-check the whole workspace.` : `Skipped install. Run \`vp install\`, then \`vp run -r dev\`.`
|
|
308
369
|
]
|
|
309
370
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pauldvlp/vp-react-ts-nestjs",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Vite+ monorepo template: a React web app + a NestJS api (conformed to the Vite+ toolchain) sharing Zod contracts.",
|
|
5
|
-
"author": "
|
|
5
|
+
"author": "Paul Barahona <johanpaulbarahona@gmail.com> (https://github.com/pauldvlp/vp-templates)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/pauldvlp/vp-templates",
|
|
8
8
|
"repository": {
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "esbuild bin/index.ts --bundle --outfile=dist/index.js --format=esm --platform=node --target=node22 --packages=external",
|
|
40
|
-
"dev": "node bin/index.ts"
|
|
40
|
+
"dev": "node bin/index.ts",
|
|
41
|
+
"typecheck": "tsc --noEmit"
|
|
41
42
|
},
|
|
42
43
|
"bin": {
|
|
43
44
|
"vp-react-ts-nestjs": "./dist/index.js"
|