@idevconn/create-icore 0.3.1 → 0.4.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/dist/cli.js CHANGED
@@ -225,6 +225,7 @@ Re-run with @latest to refresh:
225
225
 
226
226
  // src/lib/scaffold.ts
227
227
  import { copyFile, mkdir, readdir, readFile as readFile2, stat, writeFile, rm } from "fs/promises";
228
+ import { readFileSync } from "fs";
228
229
  import { join as join2 } from "path";
229
230
  import { spawnSync } from "child_process";
230
231
  var IGNORE_TOP = /* @__PURE__ */ new Set([
@@ -283,6 +284,19 @@ async function writeUploadEnv(targetDir, opts) {
283
284
  }
284
285
  await writeFile(join2(targetDir, "apps/microservices/upload/.env"), next);
285
286
  }
287
+ async function writeNotesEnv(targetDir, opts) {
288
+ if (opts.example === "none") return;
289
+ const envExample = join2(targetDir, "apps/microservices/notes/.env.example");
290
+ try {
291
+ const env = await readFile2(envExample, "utf8");
292
+ let next = env.replace(/^NOTES_TRANSPORT=.*$/m, `NOTES_TRANSPORT=${opts.transport}`);
293
+ if (opts.transport !== "tcp") {
294
+ next = next.replace(/^# (NOTES_(?:REDIS|NATS)_URL=)/m, "$1");
295
+ }
296
+ await writeFile(join2(targetDir, "apps/microservices/notes/.env"), next);
297
+ } catch {
298
+ }
299
+ }
286
300
  async function writeGatewayEnv(targetDir, opts) {
287
301
  const envExample = join2(targetDir, "apps/api/.env.example");
288
302
  const env = await readFile2(envExample, "utf8");
@@ -649,15 +663,30 @@ function gitInit(cwd, projectName) {
649
663
  { cwd, stdio: "inherit" }
650
664
  );
651
665
  }
666
+ function resolveYarnBin(cwd) {
667
+ try {
668
+ const yarnrc = readFileSync(join2(cwd, ".yarnrc.yml"), "utf8");
669
+ const match = yarnrc.match(/^yarnPath:\s*(.+)$/m);
670
+ if (match?.[1]) return join2(cwd, match[1].trim());
671
+ } catch {
672
+ }
673
+ return join2(cwd, ".yarn", "releases", "yarn-4.5.0.cjs");
674
+ }
652
675
  function runInstall(cwd, pm) {
653
- const [cmd, ...args] = pm === "npm" ? ["npm", "install"] : pm === "pnpm" ? ["pnpm", "install"] : ["yarn", "install"];
654
- spawnSync(cmd, args, { cwd, stdio: "inherit" });
676
+ if (pm === "yarn") {
677
+ spawnSync("node", [resolveYarnBin(cwd), "install"], { cwd, stdio: "inherit" });
678
+ } else if (pm === "npm") {
679
+ spawnSync("npm", ["install"], { cwd, stdio: "inherit" });
680
+ } else {
681
+ spawnSync("pnpm", ["install"], { cwd, stdio: "inherit" });
682
+ }
655
683
  }
656
684
  async function scaffold(opts, templatesDir2) {
657
685
  await copyTree(templatesDir2, opts.targetDir);
658
686
  await rewriteRootPackageJson(opts.targetDir, opts);
659
687
  await writeAuthEnv(opts.targetDir, opts);
660
688
  await writeUploadEnv(opts.targetDir, opts);
689
+ await writeNotesEnv(opts.targetDir, opts);
661
690
  await writePaymentEnv(opts.targetDir, opts);
662
691
  await writeGatewayEnv(opts.targetDir, opts);
663
692
  await writeRootEnv(opts.targetDir, opts);
package/dist/index.cjs CHANGED
@@ -41,6 +41,7 @@ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
41
41
 
42
42
  // src/lib/scaffold.ts
43
43
  var import_promises = require("fs/promises");
44
+ var import_node_fs = require("fs");
44
45
  var import_node_path = require("path");
45
46
  var import_node_child_process = require("child_process");
46
47
  var IGNORE_TOP = /* @__PURE__ */ new Set([
@@ -99,6 +100,19 @@ async function writeUploadEnv(targetDir, opts) {
99
100
  }
100
101
  await (0, import_promises.writeFile)((0, import_node_path.join)(targetDir, "apps/microservices/upload/.env"), next);
101
102
  }
103
+ async function writeNotesEnv(targetDir, opts) {
104
+ if (opts.example === "none") return;
105
+ const envExample = (0, import_node_path.join)(targetDir, "apps/microservices/notes/.env.example");
106
+ try {
107
+ const env = await (0, import_promises.readFile)(envExample, "utf8");
108
+ let next = env.replace(/^NOTES_TRANSPORT=.*$/m, `NOTES_TRANSPORT=${opts.transport}`);
109
+ if (opts.transport !== "tcp") {
110
+ next = next.replace(/^# (NOTES_(?:REDIS|NATS)_URL=)/m, "$1");
111
+ }
112
+ await (0, import_promises.writeFile)((0, import_node_path.join)(targetDir, "apps/microservices/notes/.env"), next);
113
+ } catch {
114
+ }
115
+ }
102
116
  async function writeGatewayEnv(targetDir, opts) {
103
117
  const envExample = (0, import_node_path.join)(targetDir, "apps/api/.env.example");
104
118
  const env = await (0, import_promises.readFile)(envExample, "utf8");
@@ -465,15 +479,30 @@ function gitInit(cwd, projectName) {
465
479
  { cwd, stdio: "inherit" }
466
480
  );
467
481
  }
482
+ function resolveYarnBin(cwd) {
483
+ try {
484
+ const yarnrc = (0, import_node_fs.readFileSync)((0, import_node_path.join)(cwd, ".yarnrc.yml"), "utf8");
485
+ const match = yarnrc.match(/^yarnPath:\s*(.+)$/m);
486
+ if (match?.[1]) return (0, import_node_path.join)(cwd, match[1].trim());
487
+ } catch {
488
+ }
489
+ return (0, import_node_path.join)(cwd, ".yarn", "releases", "yarn-4.5.0.cjs");
490
+ }
468
491
  function runInstall(cwd, pm) {
469
- const [cmd, ...args] = pm === "npm" ? ["npm", "install"] : pm === "pnpm" ? ["pnpm", "install"] : ["yarn", "install"];
470
- (0, import_node_child_process.spawnSync)(cmd, args, { cwd, stdio: "inherit" });
492
+ if (pm === "yarn") {
493
+ (0, import_node_child_process.spawnSync)("node", [resolveYarnBin(cwd), "install"], { cwd, stdio: "inherit" });
494
+ } else if (pm === "npm") {
495
+ (0, import_node_child_process.spawnSync)("npm", ["install"], { cwd, stdio: "inherit" });
496
+ } else {
497
+ (0, import_node_child_process.spawnSync)("pnpm", ["install"], { cwd, stdio: "inherit" });
498
+ }
471
499
  }
472
500
  async function scaffold(opts, templatesDir) {
473
501
  await copyTree(templatesDir, opts.targetDir);
474
502
  await rewriteRootPackageJson(opts.targetDir, opts);
475
503
  await writeAuthEnv(opts.targetDir, opts);
476
504
  await writeUploadEnv(opts.targetDir, opts);
505
+ await writeNotesEnv(opts.targetDir, opts);
477
506
  await writePaymentEnv(opts.targetDir, opts);
478
507
  await writeGatewayEnv(opts.targetDir, opts);
479
508
  await writeRootEnv(opts.targetDir, opts);
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // src/lib/scaffold.ts
2
2
  import { copyFile, mkdir, readdir, readFile, stat, writeFile, rm } from "fs/promises";
3
+ import { readFileSync } from "fs";
3
4
  import { join } from "path";
4
5
  import { spawnSync } from "child_process";
5
6
  var IGNORE_TOP = /* @__PURE__ */ new Set([
@@ -58,6 +59,19 @@ async function writeUploadEnv(targetDir, opts) {
58
59
  }
59
60
  await writeFile(join(targetDir, "apps/microservices/upload/.env"), next);
60
61
  }
62
+ async function writeNotesEnv(targetDir, opts) {
63
+ if (opts.example === "none") return;
64
+ const envExample = join(targetDir, "apps/microservices/notes/.env.example");
65
+ try {
66
+ const env = await readFile(envExample, "utf8");
67
+ let next = env.replace(/^NOTES_TRANSPORT=.*$/m, `NOTES_TRANSPORT=${opts.transport}`);
68
+ if (opts.transport !== "tcp") {
69
+ next = next.replace(/^# (NOTES_(?:REDIS|NATS)_URL=)/m, "$1");
70
+ }
71
+ await writeFile(join(targetDir, "apps/microservices/notes/.env"), next);
72
+ } catch {
73
+ }
74
+ }
61
75
  async function writeGatewayEnv(targetDir, opts) {
62
76
  const envExample = join(targetDir, "apps/api/.env.example");
63
77
  const env = await readFile(envExample, "utf8");
@@ -424,15 +438,30 @@ function gitInit(cwd, projectName) {
424
438
  { cwd, stdio: "inherit" }
425
439
  );
426
440
  }
441
+ function resolveYarnBin(cwd) {
442
+ try {
443
+ const yarnrc = readFileSync(join(cwd, ".yarnrc.yml"), "utf8");
444
+ const match = yarnrc.match(/^yarnPath:\s*(.+)$/m);
445
+ if (match?.[1]) return join(cwd, match[1].trim());
446
+ } catch {
447
+ }
448
+ return join(cwd, ".yarn", "releases", "yarn-4.5.0.cjs");
449
+ }
427
450
  function runInstall(cwd, pm) {
428
- const [cmd, ...args] = pm === "npm" ? ["npm", "install"] : pm === "pnpm" ? ["pnpm", "install"] : ["yarn", "install"];
429
- spawnSync(cmd, args, { cwd, stdio: "inherit" });
451
+ if (pm === "yarn") {
452
+ spawnSync("node", [resolveYarnBin(cwd), "install"], { cwd, stdio: "inherit" });
453
+ } else if (pm === "npm") {
454
+ spawnSync("npm", ["install"], { cwd, stdio: "inherit" });
455
+ } else {
456
+ spawnSync("pnpm", ["install"], { cwd, stdio: "inherit" });
457
+ }
430
458
  }
431
459
  async function scaffold(opts, templatesDir) {
432
460
  await copyTree(templatesDir, opts.targetDir);
433
461
  await rewriteRootPackageJson(opts.targetDir, opts);
434
462
  await writeAuthEnv(opts.targetDir, opts);
435
463
  await writeUploadEnv(opts.targetDir, opts);
464
+ await writeNotesEnv(opts.targetDir, opts);
436
465
  await writePaymentEnv(opts.targetDir, opts);
437
466
  await writeGatewayEnv(opts.targetDir, opts);
438
467
  await writeRootEnv(opts.targetDir, opts);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idevconn/create-icore",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "description": "Bootstrap a new project from the iCore scaffold (Nx + NestJS + React + Vite + shadcn/Tailwind, swappable auth + storage providers).",
5
5
  "license": "Apache-2.0",
6
6
  "author": "iDEVconn",