create-nxpress-app 1.0.6 → 1.0.7

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.
Files changed (2) hide show
  1. package/dist/index.js +65 -29
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12,6 +12,40 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
12
12
  const path_1 = __importDefault(require("path"));
13
13
  const util_1 = require("util");
14
14
  const execAsync = (0, util_1.promisify)(child_process_1.exec);
15
+ const deps = ["@nxpress/core"];
16
+ const devDeps = ["@types/express", "@types/node", "typescript"];
17
+ function getInstallCommands(pm, depsList, devDepsList) {
18
+ const depsStr = depsList.join(" ");
19
+ const devDepsStr = devDepsList.join(" ");
20
+ switch (pm) {
21
+ case "npm":
22
+ return {
23
+ depsCmd: `npm install ${depsStr}`,
24
+ devDepsCmd: `npm install -D ${devDepsStr}`,
25
+ };
26
+ case "yarn":
27
+ return {
28
+ depsCmd: `yarn add ${depsStr}`,
29
+ devDepsCmd: `yarn add -D ${devDepsStr}`,
30
+ };
31
+ case "bun":
32
+ return {
33
+ depsCmd: `bun add ${depsStr}`,
34
+ devDepsCmd: `bun add -d ${devDepsStr}`,
35
+ };
36
+ case "deno":
37
+ return {
38
+ depsCmd: `deno add ${depsStr}`,
39
+ devDepsCmd: `deno add -D ${devDepsStr}`,
40
+ };
41
+ case "pnpm":
42
+ default:
43
+ return {
44
+ depsCmd: `pnpm add ${depsStr}`,
45
+ devDepsCmd: `pnpm add -D ${devDepsStr}`,
46
+ };
47
+ }
48
+ }
15
49
  const program = new commander_1.Command();
16
50
  program
17
51
  .name("create-nxpress-app")
@@ -23,7 +57,7 @@ program
23
57
  .option("--app-dir <dir>", "Directory for application routes")
24
58
  .option("--components-dir <dir>", "Directory for components")
25
59
  .option("--public-dir <dir>", "Directory for static assets")
26
- .option("--skip-install", "Skip installing dependencies", false)
60
+ .option("--pkg-manager <pm>", "Package manager (pnpm, npm, yarn, bun, deno)")
27
61
  .action(async (projectDirArg, options) => {
28
62
  console.log();
29
63
  (0, prompts_1.intro)(chalk_1.default.bgCyan.black(" Create Nxpress App "));
@@ -135,17 +169,27 @@ program
135
169
  publicDirName = pubRes;
136
170
  }
137
171
  }
138
- let shouldInstall = !options.skipInstall;
139
- if (!options.skipInstall && process.stdin.isTTY) {
140
- const res = await (0, prompts_1.confirm)({
141
- message: "Install dependencies using pnpm?",
142
- initialValue: true,
172
+ let pkgManager = options.pkgManager;
173
+ if (process.stdin.isTTY && !options.pkgManager) {
174
+ const selectedPm = await (0, prompts_1.select)({
175
+ message: "Which package manager do you want to use?",
176
+ options: [
177
+ { value: "pnpm", label: "pnpm (Default)", hint: "Fast & disk space efficient" },
178
+ { value: "npm", label: "npm", hint: "Default Node.js package manager" },
179
+ { value: "yarn", label: "yarn", hint: "Classic/Berry package manager" },
180
+ { value: "bun", label: "bun", hint: "Ultra-fast runtime & package manager" },
181
+ { value: "deno", label: "deno", hint: "Modern JavaScript/TypeScript runtime" },
182
+ ],
183
+ initialValue: "pnpm",
143
184
  });
144
- if ((0, prompts_1.isCancel)(res)) {
185
+ if ((0, prompts_1.isCancel)(selectedPm)) {
145
186
  (0, prompts_1.cancel)("Operation cancelled.");
146
187
  process.exit(0);
147
188
  }
148
- shouldInstall = res;
189
+ pkgManager = selectedPm;
190
+ }
191
+ if (!pkgManager) {
192
+ pkgManager = "pnpm";
149
193
  }
150
194
  const s = (0, prompts_1.spinner)();
151
195
  s.start("Scaffolding project...");
@@ -249,10 +293,9 @@ app.listen(PORT, () => {
249
293
  });
250
294
  `;
251
295
  fs_extra_1.default.writeFileSync(path_1.default.join(targetPath, "server.ts"), serverTsContent);
252
- const pkgVersion = "1.0.5";
253
296
  // nxpress.config.json
254
297
  const nxConfig = {
255
- $schema: `https://unpkg.com/@nxpress/core@${pkgVersion}/schema.json`,
298
+ $schema: `https://unpkg.com/@nxpress/core@latest/schema.json`,
256
299
  port,
257
300
  engine: engine === "handlebars" ? "hbs" : engine,
258
301
  appDir: appDirName,
@@ -270,14 +313,6 @@ app.listen(PORT, () => {
270
313
  build: "tsc",
271
314
  start: "nxpress start",
272
315
  },
273
- dependencies: {
274
- "@nxpress/core": `^${pkgVersion}`,
275
- },
276
- devDependencies: {
277
- "@types/express": "^5.0.6",
278
- "@types/node": "^26.1.1",
279
- typescript: "^7.0.2",
280
- },
281
316
  };
282
317
  fs_extra_1.default.writeFileSync(path_1.default.join(targetPath, "package.json"), JSON.stringify(projectPkgJson, null, 2));
283
318
  // tsconfig.json for target project
@@ -303,20 +338,21 @@ dist
303
338
  `;
304
339
  fs_extra_1.default.writeFileSync(path_1.default.join(targetPath, ".gitignore"), gitignoreContent);
305
340
  s.stop("Project structure created successfully.");
306
- if (shouldInstall) {
307
- const instSpinner = (0, prompts_1.spinner)();
308
- instSpinner.start("Installing dependencies with pnpm...");
309
- try {
310
- await execAsync("pnpm install", { cwd: targetPath });
311
- instSpinner.stop("Dependencies installed successfully.");
312
- }
313
- catch (err) {
314
- instSpinner.stop("Failed to install dependencies automatically.");
315
- }
341
+ const instSpinner = (0, prompts_1.spinner)();
342
+ instSpinner.start(`Installing dependencies with ${pkgManager}...`);
343
+ try {
344
+ const { depsCmd, devDepsCmd } = getInstallCommands(pkgManager, deps, devDeps);
345
+ await execAsync(depsCmd, { cwd: targetPath });
346
+ await execAsync(devDepsCmd, { cwd: targetPath });
347
+ instSpinner.stop("Dependencies installed successfully.");
348
+ }
349
+ catch (err) {
350
+ instSpinner.stop("Failed to install dependencies automatically.");
316
351
  }
352
+ const devCmd = pkgManager === "npm" ? "npm run dev" : `${pkgManager} dev`;
317
353
  (0, prompts_1.outro)(`Project created in ${chalk_1.default.cyan(projectDir)}!\n\n` +
318
354
  `Next steps:\n` +
319
355
  ` ${chalk_1.default.cyan(`cd ${projectDir}`)}\n` +
320
- ` ${chalk_1.default.cyan("pnpm dev")}`);
356
+ ` ${chalk_1.default.cyan(devCmd)}`);
321
357
  });
322
358
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nxpress-app",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "CLI tool to create Nxpress applications",
5
5
  "main": "dist/index.js",
6
6
  "bin": {