monorise 1.7.0-dev.8 → 1.7.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/dist/cli/cli.js CHANGED
@@ -2,19 +2,21 @@
2
2
 
3
3
  // cli.ts
4
4
  import "tsx";
5
- import fs2 from "fs";
6
- import path2 from "path";
5
+ import fs3 from "fs";
6
+ import path3 from "path";
7
7
  import { execSync } from "child_process";
8
8
  import chokidar from "chokidar";
9
9
 
10
10
  // commands/utils/analytics-manifest.ts
11
11
  import { createHash } from "crypto";
12
+ import fs from "fs";
13
+ import path from "path";
12
14
  var lowerKebabCase = /^[a-z]+(?:-[a-z]+)*$/;
13
15
  function normalizeSqlIdentifier(name) {
14
16
  const normalized = name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^a-zA-Z0-9]+/g, "_").replace(/^_+|_+$/g, "").toLowerCase();
15
17
  return /^[a-z_]/.test(normalized) ? normalized : `_${normalized}`;
16
18
  }
17
- function athenaType(schema, path3) {
19
+ function athenaType(schema, path4) {
18
20
  let current = schema;
19
21
  for (; ; ) {
20
22
  const typeName = current._def?.typeName;
@@ -63,7 +65,7 @@ function athenaType(schema, path3) {
63
65
  return "json";
64
66
  }
65
67
  }
66
- function columns(schema, path3) {
68
+ function columns(schema, path4) {
67
69
  let objectSchema = schema;
68
70
  while (!objectSchema.shape && objectSchema._def?.typeName === "ZodEffects") {
69
71
  const innerSchema = objectSchema._def.schema;
@@ -77,14 +79,14 @@ function columns(schema, path3) {
77
79
  const existing = names.get(name);
78
80
  if (existing) {
79
81
  throw new Error(
80
- `Analytics column identifier collision in ${path3}: ${existing} and ${sourceName} both normalize to ${name}.`
82
+ `Analytics column identifier collision in ${path4}: ${existing} and ${sourceName} both normalize to ${name}.`
81
83
  );
82
84
  }
83
85
  names.set(name, sourceName);
84
86
  return {
85
87
  name,
86
88
  sourceName,
87
- type: athenaType(field, `${path3}.${sourceName}`)
89
+ type: athenaType(field, `${path4}.${sourceName}`)
88
90
  };
89
91
  });
90
92
  }
@@ -134,11 +136,29 @@ function validateSchemaEvolution(previous, next) {
134
136
  }
135
137
  }
136
138
  }
139
+ function writeAnalyticsManifest(monoriseOutputDir, configs) {
140
+ const analyticsManifestPath = path.join(monoriseOutputDir, "analytics-manifest.json");
141
+ const manifest = createAnalyticsManifest(configs);
142
+ if (manifest.unnamedMutuals.length) {
143
+ console.warn(
144
+ `Skipping unnamed mutual analytics datasets: ${manifest.unnamedMutuals.join(", ")}.`
145
+ );
146
+ }
147
+ if (fs.existsSync(analyticsManifestPath)) {
148
+ validateSchemaEvolution(
149
+ JSON.parse(fs.readFileSync(analyticsManifestPath, "utf8")),
150
+ manifest
151
+ );
152
+ }
153
+ fs.writeFileSync(analyticsManifestPath, `${JSON.stringify(manifest, null, 2)}
154
+ `);
155
+ }
137
156
  function createAnalyticsManifest(configs) {
138
157
  const datasets = [];
139
158
  const unnamedMutuals = /* @__PURE__ */ new Set();
140
159
  const identifiers = /* @__PURE__ */ new Map();
141
160
  const mutuals = /* @__PURE__ */ new Set();
161
+ const mutualPairs = /* @__PURE__ */ new Map();
142
162
  const addDataset = (kind, name, schema, mutualEntities) => {
143
163
  if (!lowerKebabCase.test(name)) {
144
164
  throw new Error(
@@ -198,11 +218,20 @@ function createAnalyticsManifest(configs) {
198
218
  }
199
219
  if (mutuals.has(mutual)) continue;
200
220
  mutuals.add(mutual);
221
+ const entities = mutual.entities ?? [config.name, field.entityType];
222
+ const pair = [...entities].sort().join("::");
223
+ const existing = mutualPairs.get(pair);
224
+ if (existing) {
225
+ throw new Error(
226
+ `Analytics mutual ${mutual.name} conflicts with ${existing}: both use the ${pair} entity pair.`
227
+ );
228
+ }
229
+ mutualPairs.set(pair, mutual.name);
201
230
  addDataset(
202
231
  "mutual",
203
232
  mutual.name,
204
233
  mutual.mutualDataSchema,
205
- mutual.entities ?? [config.name, field.entityType]
234
+ entities
206
235
  );
207
236
  }
208
237
  }
@@ -218,15 +247,15 @@ function createAnalyticsManifest(configs) {
218
247
  import { fileURLToPath } from "url";
219
248
 
220
249
  // commands/utils/detect-package.ts
221
- import fs from "fs";
222
- import path from "path";
250
+ import fs2 from "fs";
251
+ import path2 from "path";
223
252
  function detectCombinedPackage(startDir) {
224
253
  let dir = startDir;
225
254
  while (true) {
226
- if (fs.existsSync(path.join(dir, "node_modules", "monorise"))) {
255
+ if (fs2.existsSync(path2.join(dir, "node_modules", "monorise"))) {
227
256
  return true;
228
257
  }
229
- const parent = path.dirname(dir);
258
+ const parent = path2.dirname(dir);
230
259
  if (parent === dir) break;
231
260
  dir = parent;
232
261
  }
@@ -255,10 +284,10 @@ var ROOT_TSCONFIG_TEMPLATE = {
255
284
 
256
285
  // cli.ts
257
286
  var __filename = fileURLToPath(import.meta.url);
258
- var __dirname = path2.dirname(__filename);
259
- var TEMPLATES_DIR = path2.join(__dirname, "templates", "files");
287
+ var __dirname = path3.dirname(__filename);
288
+ var TEMPLATES_DIR = path3.join(__dirname, "templates", "files");
260
289
  function readTemplate(filename) {
261
- return fs2.readFileSync(path2.join(TEMPLATES_DIR, filename), "utf-8");
290
+ return fs3.readFileSync(path3.join(TEMPLATES_DIR, filename), "utf-8");
262
291
  }
263
292
  function kebabToCamel(str) {
264
293
  return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
@@ -271,19 +300,19 @@ function execCommand(command, cwd, stdio = "inherit") {
271
300
  execSync(command, { cwd, stdio });
272
301
  }
273
302
  async function generateConfigFile(configDir, monoriseOutputDir, projectRoot) {
274
- const configOutputPath = path2.join(monoriseOutputDir, "config.ts");
303
+ const configOutputPath = path3.join(monoriseOutputDir, "config.ts");
275
304
  const initialConfigContent = `
276
305
  export enum Entity {}
277
306
  export default {};
278
307
  `;
279
- fs2.writeFileSync(configOutputPath, initialConfigContent);
280
- fs2.writeFileSync(
281
- path2.join(monoriseOutputDir, "index.ts"),
308
+ fs3.writeFileSync(configOutputPath, initialConfigContent);
309
+ fs3.writeFileSync(
310
+ path3.join(monoriseOutputDir, "index.ts"),
282
311
  `export * from './config';
283
312
  export { default } from './config';
284
313
  `
285
314
  );
286
- const files = fs2.readdirSync(configDir).filter((file) => file.endsWith(".ts") && file !== "index.ts");
315
+ const files = fs3.readdirSync(configDir).filter((file) => file.endsWith(".ts") && file !== "index.ts");
287
316
  const names = /* @__PURE__ */ new Set();
288
317
  const nameRegex = /^[a-z]+(-[a-z]+)*$/;
289
318
  const imports = [];
@@ -295,10 +324,10 @@ export { default } from './config';
295
324
  const allowedEntityEntries = [];
296
325
  const entityWithEmailAuthEntries = [];
297
326
  const analyticsConfigs = [];
298
- const relativePathToConfigDir = path2.relative(monoriseOutputDir, configDir);
327
+ const relativePathToConfigDir = path3.relative(monoriseOutputDir, configDir);
299
328
  const importPathPrefix = relativePathToConfigDir ? `${relativePathToConfigDir}/` : "./";
300
329
  for (const file of files) {
301
- const fullPath = path2.join(configDir, file);
330
+ const fullPath = path3.join(configDir, file);
302
331
  const module = await import(fullPath);
303
332
  const config = module.default;
304
333
  if (!nameRegex.test(config.name)) {
@@ -392,28 +421,11 @@ const config = {
392
421
  export default config;
393
422
  ${moduleAugmentations}
394
423
  `;
395
- fs2.writeFileSync(configOutputPath, configOutputContent);
396
- const analyticsManifestPath = path2.join(
397
- monoriseOutputDir,
398
- "analytics-manifest.json"
399
- );
400
- const manifest = createAnalyticsManifest(analyticsConfigs);
401
- if (manifest.unnamedMutuals.length) {
402
- console.warn(
403
- `Skipping unnamed mutual analytics datasets: ${manifest.unnamedMutuals.join(", ")}.`
404
- );
405
- }
406
- if (fs2.existsSync(analyticsManifestPath)) {
407
- validateSchemaEvolution(
408
- JSON.parse(fs2.readFileSync(analyticsManifestPath, "utf8")),
409
- manifest
410
- );
411
- }
412
- fs2.writeFileSync(analyticsManifestPath, `${JSON.stringify(manifest, null, 2)}
413
- `);
424
+ fs3.writeFileSync(configOutputPath, configOutputContent);
425
+ writeAnalyticsManifest(monoriseOutputDir, analyticsConfigs);
414
426
  console.log("Successfully generated config.ts!");
415
- const indexOutputPath = path2.join(monoriseOutputDir, "index.ts");
416
- fs2.writeFileSync(
427
+ const indexOutputPath = path3.join(monoriseOutputDir, "index.ts");
428
+ fs3.writeFileSync(
417
429
  indexOutputPath,
418
430
  `export * from './config';
419
431
  export { default } from './config';
@@ -423,21 +435,21 @@ export { default } from './config';
423
435
  return configOutputPath;
424
436
  }
425
437
  async function generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir) {
426
- const handleOutputPath = path2.join(monoriseOutputDir, "handle.ts");
438
+ const handleOutputPath = path3.join(monoriseOutputDir, "handle.ts");
427
439
  const customRoutesPath = monoriseConfig.customRoutes;
428
440
  let routesImportLine = "";
429
441
  let appHandlerPayload = "{}";
430
442
  if (customRoutesPath) {
431
- const absoluteCustomRoutesPath = path2.resolve(
443
+ const absoluteCustomRoutesPath = path3.resolve(
432
444
  projectRoot,
433
445
  customRoutesPath
434
446
  );
435
- if (!fs2.existsSync(absoluteCustomRoutesPath) && !fs2.existsSync(`${absoluteCustomRoutesPath}.ts`) && !fs2.existsSync(`${absoluteCustomRoutesPath}.js`)) {
447
+ if (!fs3.existsSync(absoluteCustomRoutesPath) && !fs3.existsSync(`${absoluteCustomRoutesPath}.ts`) && !fs3.existsSync(`${absoluteCustomRoutesPath}.js`)) {
436
448
  throw new Error(
437
449
  `Custom routes file not found: '${absoluteCustomRoutesPath}'. Please ensure 'customRoutes' in monorise.config.ts points to a valid file.`
438
450
  );
439
451
  }
440
- let relativePathToRoutes = path2.relative(
452
+ let relativePathToRoutes = path3.relative(
441
453
  monoriseOutputDir,
442
454
  absoluteCustomRoutesPath
443
455
  );
@@ -469,30 +481,30 @@ export const tagHandler = coreFactory.tagProcessor;
469
481
  export const treeHandler = coreFactory.prejoinProcessor;
470
482
  export const appHandler = coreFactory.appHandler(${appHandlerPayload});
471
483
  `;
472
- fs2.writeFileSync(handleOutputPath, combinedContent);
484
+ fs3.writeFileSync(handleOutputPath, combinedContent);
473
485
  console.log("Successfully generated handle.ts!");
474
486
  return handleOutputPath;
475
487
  }
476
488
  async function generateFiles(rootPath) {
477
- const baseDir = rootPath ? path2.resolve(rootPath) : process.cwd();
478
- const configFilePathTS = path2.join(baseDir, "monorise.config.ts");
479
- const configFilePathJS = path2.join(baseDir, "monorise.config.js");
489
+ const baseDir = rootPath ? path3.resolve(rootPath) : process.cwd();
490
+ const configFilePathTS = path3.join(baseDir, "monorise.config.ts");
491
+ const configFilePathJS = path3.join(baseDir, "monorise.config.js");
480
492
  let configFilePath;
481
- if (fs2.existsSync(configFilePathTS)) {
493
+ if (fs3.existsSync(configFilePathTS)) {
482
494
  configFilePath = configFilePathTS;
483
- } else if (fs2.existsSync(configFilePathJS)) {
495
+ } else if (fs3.existsSync(configFilePathJS)) {
484
496
  configFilePath = configFilePathJS;
485
497
  } else {
486
498
  throw new Error(
487
499
  "Neither monorise.config.ts nor monorise.config.js found in the root of the project."
488
500
  );
489
501
  }
490
- const projectRoot = path2.dirname(configFilePath);
502
+ const projectRoot = path3.dirname(configFilePath);
491
503
  const monoriseConfigModule = await import(configFilePath);
492
504
  const monoriseConfig = monoriseConfigModule.default;
493
- const configDir = path2.resolve(projectRoot, monoriseConfig.configDir);
494
- const monoriseOutputDir = path2.join(projectRoot, ".monorise");
495
- fs2.mkdirSync(monoriseOutputDir, { recursive: true });
505
+ const configDir = path3.resolve(projectRoot, monoriseConfig.configDir);
506
+ const monoriseOutputDir = path3.join(projectRoot, ".monorise");
507
+ fs3.mkdirSync(monoriseOutputDir, { recursive: true });
496
508
  await generateConfigFile(configDir, monoriseOutputDir, projectRoot);
497
509
  await generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir);
498
510
  return configDir;
@@ -550,29 +562,29 @@ async function runInitCommand(rootPath) {
550
562
  let projectName = "my-app";
551
563
  let projectRoot;
552
564
  if (rootPath) {
553
- projectRoot = path2.resolve(rootPath);
554
- projectName = path2.basename(projectRoot);
565
+ projectRoot = path3.resolve(rootPath);
566
+ projectName = path3.basename(projectRoot);
555
567
  } else {
556
568
  const args = process.argv.slice(2);
557
569
  const nameIndex = args.indexOf("--name");
558
570
  if (nameIndex > -1 && args[nameIndex + 1]) {
559
571
  projectName = args[nameIndex + 1];
560
572
  }
561
- projectRoot = path2.resolve(projectName);
573
+ projectRoot = path3.resolve(projectName);
562
574
  }
563
575
  console.log(`
564
576
  \u{1F680} Creating Monorise project: ${projectName}
565
577
  `);
566
- if (fs2.existsSync(projectRoot)) {
578
+ if (fs3.existsSync(projectRoot)) {
567
579
  console.error(`Error: Directory ${projectName} already exists.`);
568
580
  process.exit(1);
569
581
  }
570
582
  console.log("\u{1F4C1} Creating project structure...");
571
- fs2.mkdirSync(projectRoot, { recursive: true });
572
- fs2.mkdirSync(path2.join(projectRoot, "apps"), { recursive: true });
573
- fs2.mkdirSync(path2.join(projectRoot, "services", "core"), { recursive: true });
574
- fs2.mkdirSync(path2.join(projectRoot, "monorise", "configs"), { recursive: true });
575
- fs2.mkdirSync(path2.join(projectRoot, "monorise", "mutuals"), { recursive: true });
583
+ fs3.mkdirSync(projectRoot, { recursive: true });
584
+ fs3.mkdirSync(path3.join(projectRoot, "apps"), { recursive: true });
585
+ fs3.mkdirSync(path3.join(projectRoot, "services", "core"), { recursive: true });
586
+ fs3.mkdirSync(path3.join(projectRoot, "monorise", "configs"), { recursive: true });
587
+ fs3.mkdirSync(path3.join(projectRoot, "monorise", "mutuals"), { recursive: true });
576
588
  console.log("\u{1F4E6} Initializing root package.json...");
577
589
  const rootPackageJson = {
578
590
  name: projectName,
@@ -581,21 +593,21 @@ async function runInitCommand(rootPath) {
581
593
  private: true,
582
594
  workspaces: ["apps/*", "services/*"]
583
595
  };
584
- fs2.writeFileSync(
585
- path2.join(projectRoot, "package.json"),
596
+ fs3.writeFileSync(
597
+ path3.join(projectRoot, "package.json"),
586
598
  JSON.stringify(rootPackageJson, null, 2)
587
599
  );
588
600
  console.log("\u2699\uFE0F Creating root tsconfig.json...");
589
- fs2.writeFileSync(
590
- path2.join(projectRoot, "tsconfig.json"),
601
+ fs3.writeFileSync(
602
+ path3.join(projectRoot, "tsconfig.json"),
591
603
  JSON.stringify(ROOT_TSCONFIG_TEMPLATE, null, 2)
592
604
  );
593
605
  console.log("\n\u{1F4F1} Creating Next.js app in apps/web...");
594
- const nextAppDir = path2.join(projectRoot, "apps", "web");
606
+ const nextAppDir = path3.join(projectRoot, "apps", "web");
595
607
  try {
596
608
  execCommand(
597
609
  `npx create-next-app@latest web --typescript --tailwind --eslint --app --no-src-dir --import-alias "#/*" --no-turbopack --yes`,
598
- path2.join(projectRoot, "apps")
610
+ path3.join(projectRoot, "apps")
599
611
  );
600
612
  } catch (error) {
601
613
  console.error("Failed to create Next.js app:", error);
@@ -616,28 +628,28 @@ async function runInitCommand(rootPath) {
616
628
  process.exit(1);
617
629
  }
618
630
  console.log("\u2699\uFE0F Creating monorise.config.ts...");
619
- fs2.writeFileSync(
620
- path2.join(projectRoot, "monorise.config.ts"),
631
+ fs3.writeFileSync(
632
+ path3.join(projectRoot, "monorise.config.ts"),
621
633
  readTemplate("monorise.config.ts")
622
634
  );
623
635
  console.log("\u{1F517} Creating team-membership mutual config...");
624
- fs2.writeFileSync(
625
- path2.join(projectRoot, "monorise", "mutuals", "team-membership.ts"),
636
+ fs3.writeFileSync(
637
+ path3.join(projectRoot, "monorise", "mutuals", "team-membership.ts"),
626
638
  readTemplate("team-membership.mutual.ts")
627
639
  );
628
640
  console.log("\u{1F464} Creating starter User entity...");
629
- fs2.writeFileSync(
630
- path2.join(projectRoot, "monorise", "configs", "user.ts"),
641
+ fs3.writeFileSync(
642
+ path3.join(projectRoot, "monorise", "configs", "user.ts"),
631
643
  readTemplate("user-entity.ts")
632
644
  );
633
645
  console.log("\u{1F465} Creating starter Team entity...");
634
- fs2.writeFileSync(
635
- path2.join(projectRoot, "monorise", "configs", "team.ts"),
646
+ fs3.writeFileSync(
647
+ path3.join(projectRoot, "monorise", "configs", "team.ts"),
636
648
  readTemplate("team-entity.ts")
637
649
  );
638
650
  console.log("\u{1F527} Creating services/core/routes.ts...");
639
- fs2.writeFileSync(
640
- path2.join(projectRoot, "services", "core", "routes.ts"),
651
+ fs3.writeFileSync(
652
+ path3.join(projectRoot, "services", "core", "routes.ts"),
641
653
  readTemplate("core-routes.ts")
642
654
  );
643
655
  const servicesPackageJson = {
@@ -645,13 +657,13 @@ async function runInitCommand(rootPath) {
645
657
  version: "0.0.0",
646
658
  type: "module"
647
659
  };
648
- fs2.writeFileSync(
649
- path2.join(projectRoot, "services", "core", "package.json"),
660
+ fs3.writeFileSync(
661
+ path3.join(projectRoot, "services", "core", "package.json"),
650
662
  JSON.stringify(servicesPackageJson, null, 2)
651
663
  );
652
664
  console.log("\u2699\uFE0F Creating sst.config.ts with Monorise...");
653
- const sstConfigPath = path2.join(projectRoot, "sst.config.ts");
654
- fs2.writeFileSync(sstConfigPath, readTemplate("sst.config.ts").replace("{{PROJECT_NAME}}", projectName));
665
+ const sstConfigPath = path3.join(projectRoot, "sst.config.ts");
666
+ fs3.writeFileSync(sstConfigPath, readTemplate("sst.config.ts").replace("{{PROJECT_NAME}}", projectName));
655
667
  console.log("\n\u2601\uFE0F Installing SST providers...");
656
668
  try {
657
669
  execCommand("npx sst install", projectRoot);
@@ -659,63 +671,63 @@ async function runInitCommand(rootPath) {
659
671
  console.warn("Warning: SST install failed, continuing anyway...");
660
672
  }
661
673
  console.log("\u{1F4C4} Creating example page in apps/web...");
662
- const webSrcAppDir = path2.join(projectRoot, "apps", "web", "src", "app");
663
- const webAppDir = path2.join(projectRoot, "apps", "web", "app");
664
- const pagePath = fs2.existsSync(webSrcAppDir) ? path2.join(webSrcAppDir, "page.tsx") : fs2.existsSync(webAppDir) ? path2.join(webAppDir, "page.tsx") : null;
674
+ const webSrcAppDir = path3.join(projectRoot, "apps", "web", "src", "app");
675
+ const webAppDir = path3.join(projectRoot, "apps", "web", "app");
676
+ const pagePath = fs3.existsSync(webSrcAppDir) ? path3.join(webSrcAppDir, "page.tsx") : fs3.existsSync(webAppDir) ? path3.join(webAppDir, "page.tsx") : null;
665
677
  if (pagePath) {
666
678
  try {
667
- fs2.writeFileSync(pagePath, readTemplate("example-page.tsx"));
668
- console.log(`Created example page at ${path2.relative(projectRoot, pagePath)}`);
679
+ fs3.writeFileSync(pagePath, readTemplate("example-page.tsx"));
680
+ console.log(`Created example page at ${path3.relative(projectRoot, pagePath)}`);
669
681
  } catch (error) {
670
682
  console.warn("Warning: Could not create example page:", error);
671
683
  }
672
684
  } else {
673
685
  console.warn("Warning: Could not find apps/web/src/app or apps/web/app directory");
674
686
  }
675
- const webRoot = fs2.existsSync(webSrcAppDir) ? path2.join(projectRoot, "apps", "web", "src") : fs2.existsSync(webAppDir) ? path2.join(projectRoot, "apps", "web") : null;
687
+ const webRoot = fs3.existsSync(webSrcAppDir) ? path3.join(projectRoot, "apps", "web", "src") : fs3.existsSync(webAppDir) ? path3.join(projectRoot, "apps", "web") : null;
676
688
  if (webRoot) {
677
- const appDir = fs2.existsSync(webSrcAppDir) ? webSrcAppDir : webAppDir;
678
- fs2.mkdirSync(path2.join(webRoot, "components", "ui"), { recursive: true });
679
- fs2.mkdirSync(path2.join(webRoot, "lib"), { recursive: true });
689
+ const appDir = fs3.existsSync(webSrcAppDir) ? webSrcAppDir : webAppDir;
690
+ fs3.mkdirSync(path3.join(webRoot, "components", "ui"), { recursive: true });
691
+ fs3.mkdirSync(path3.join(webRoot, "lib"), { recursive: true });
680
692
  console.log("\u{1F310} Creating global components...");
681
- fs2.writeFileSync(
682
- path2.join(webRoot, "components", "global-initializer.tsx"),
693
+ fs3.writeFileSync(
694
+ path3.join(webRoot, "components", "global-initializer.tsx"),
683
695
  readTemplate("global-initializer.tsx")
684
696
  );
685
- fs2.writeFileSync(
686
- path2.join(webRoot, "components", "global-loader.tsx"),
697
+ fs3.writeFileSync(
698
+ path3.join(webRoot, "components", "global-loader.tsx"),
687
699
  readTemplate("global-loader.tsx")
688
700
  );
689
701
  console.log("\u{1F527} Creating lib/utils.ts...");
690
- fs2.writeFileSync(
691
- path2.join(webRoot, "lib", "utils.ts"),
702
+ fs3.writeFileSync(
703
+ path3.join(webRoot, "lib", "utils.ts"),
692
704
  readTemplate("lib-utils.ts")
693
705
  );
694
706
  console.log("\u{1F3A8} Creating shadcn UI components...");
695
- fs2.writeFileSync(
696
- path2.join(webRoot, "components", "ui", "button.tsx"),
707
+ fs3.writeFileSync(
708
+ path3.join(webRoot, "components", "ui", "button.tsx"),
697
709
  readTemplate("ui-button.tsx")
698
710
  );
699
- fs2.writeFileSync(
700
- path2.join(webRoot, "components", "ui", "card.tsx"),
711
+ fs3.writeFileSync(
712
+ path3.join(webRoot, "components", "ui", "card.tsx"),
701
713
  readTemplate("ui-card.tsx")
702
714
  );
703
- fs2.writeFileSync(
704
- path2.join(webRoot, "components", "ui", "input.tsx"),
715
+ fs3.writeFileSync(
716
+ path3.join(webRoot, "components", "ui", "input.tsx"),
705
717
  readTemplate("ui-input.tsx")
706
718
  );
707
- fs2.writeFileSync(
708
- path2.join(webRoot, "components", "ui", "label.tsx"),
719
+ fs3.writeFileSync(
720
+ path3.join(webRoot, "components", "ui", "label.tsx"),
709
721
  readTemplate("ui-label.tsx")
710
722
  );
711
723
  console.log("\u{1F3A8} Setting up shadcn globals.css...");
712
- const globalsCssPath = path2.join(appDir, "globals.css");
713
- fs2.writeFileSync(globalsCssPath, readTemplate("globals.css"));
724
+ const globalsCssPath = path3.join(appDir, "globals.css");
725
+ fs3.writeFileSync(globalsCssPath, readTemplate("globals.css"));
714
726
  console.log("\u{1F4D0} Updating layout.tsx with global components...");
715
- const layoutPath = path2.join(appDir, "layout.tsx");
716
- if (fs2.existsSync(layoutPath)) {
727
+ const layoutPath = path3.join(appDir, "layout.tsx");
728
+ if (fs3.existsSync(layoutPath)) {
717
729
  try {
718
- let layoutContent = fs2.readFileSync(layoutPath, "utf8");
730
+ let layoutContent = fs3.readFileSync(layoutPath, "utf8");
719
731
  const globalImports = `import GlobalInitializer from '#/components/global-initializer';
720
732
  import GlobalLoader from '#/components/global-loader';`;
721
733
  const lastImportIndex = layoutContent.lastIndexOf("import ");
@@ -728,14 +740,14 @@ import GlobalLoader from '#/components/global-loader';`;
728
740
  <GlobalInitializer />
729
741
  <GlobalLoader />`
730
742
  );
731
- fs2.writeFileSync(layoutPath, layoutContent);
743
+ fs3.writeFileSync(layoutPath, layoutContent);
732
744
  } catch (error) {
733
745
  console.warn("Warning: Could not update layout.tsx:", error);
734
746
  }
735
747
  }
736
- const postcssPath = path2.join(projectRoot, "apps", "web", "postcss.config.mjs");
737
- if (fs2.existsSync(postcssPath)) {
738
- fs2.writeFileSync(
748
+ const postcssPath = path3.join(projectRoot, "apps", "web", "postcss.config.mjs");
749
+ if (fs3.existsSync(postcssPath)) {
750
+ fs3.writeFileSync(
739
751
  postcssPath,
740
752
  `const config = {
741
753
  plugins: {
@@ -748,23 +760,23 @@ export default config;
748
760
  );
749
761
  }
750
762
  console.log("\u{1F500} Creating API proxy routes...");
751
- const apiDir = path2.join(appDir, "api");
752
- const catchAllDir = path2.join(apiDir, "[...proxy]");
753
- fs2.mkdirSync(catchAllDir, { recursive: true });
754
- fs2.writeFileSync(
755
- path2.join(apiDir, "proxy-request.ts"),
763
+ const apiDir = path3.join(appDir, "api");
764
+ const catchAllDir = path3.join(apiDir, "[...proxy]");
765
+ fs3.mkdirSync(catchAllDir, { recursive: true });
766
+ fs3.writeFileSync(
767
+ path3.join(apiDir, "proxy-request.ts"),
756
768
  readTemplate("proxy-request.ts")
757
769
  );
758
- fs2.writeFileSync(
759
- path2.join(catchAllDir, "route.ts"),
770
+ fs3.writeFileSync(
771
+ path3.join(catchAllDir, "route.ts"),
760
772
  readTemplate("proxy-route.ts")
761
773
  );
762
774
  }
763
775
  console.log("\u2699\uFE0F Updating apps/web tsconfig.json...");
764
- const webTsconfigPath = path2.join(projectRoot, "apps", "web", "tsconfig.json");
765
- if (fs2.existsSync(webTsconfigPath)) {
776
+ const webTsconfigPath = path3.join(projectRoot, "apps", "web", "tsconfig.json");
777
+ if (fs3.existsSync(webTsconfigPath)) {
766
778
  try {
767
- const webTsconfigContent = fs2.readFileSync(webTsconfigPath, "utf8");
779
+ const webTsconfigContent = fs3.readFileSync(webTsconfigPath, "utf8");
768
780
  const webTsconfig = JSON.parse(webTsconfigContent);
769
781
  if (!webTsconfig.compilerOptions) {
770
782
  webTsconfig.compilerOptions = {};
@@ -775,9 +787,9 @@ export default config;
775
787
  webTsconfig.compilerOptions.paths["#/shared/*"] = ["../../shared/*"];
776
788
  webTsconfig.compilerOptions.paths["#/monorise/*"] = ["../../.monorise/*"];
777
789
  webTsconfig.compilerOptions.paths["#/monorise"] = ["../../.monorise/index"];
778
- const hasSrcDir = fs2.existsSync(path2.join(projectRoot, "apps", "web", "src"));
790
+ const hasSrcDir = fs3.existsSync(path3.join(projectRoot, "apps", "web", "src"));
779
791
  webTsconfig.compilerOptions.paths["#/*"] = [hasSrcDir ? "./src/*" : "./*"];
780
- fs2.writeFileSync(webTsconfigPath, JSON.stringify(webTsconfig, null, 2));
792
+ fs3.writeFileSync(webTsconfigPath, JSON.stringify(webTsconfig, null, 2));
781
793
  } catch (error) {
782
794
  console.warn("Warning: Could not update apps/web tsconfig.json:", error);
783
795
  }
@@ -804,7 +816,7 @@ export default config;
804
816
  console.log(` \u2022 Edit your data model \u2192 monorise/configs/user.ts`);
805
817
  console.log(` (Add fields like phone, role, status to the User entity)`);
806
818
  console.log(
807
- ` \u2022 Build your UI \u2192 ${pagePath ? path2.relative(projectRoot, pagePath) : "apps/web/app/page.tsx"}`
819
+ ` \u2022 Build your UI \u2192 ${pagePath ? path3.relative(projectRoot, pagePath) : "apps/web/app/page.tsx"}`
808
820
  );
809
821
  console.log(` (React components using useEntities and createEntity)`);
810
822
  console.log(` \u2022 Add backend logic \u2192 services/core/routes.ts`);
@@ -823,7 +835,7 @@ async function runDevCommand(configDir, rootPath) {
823
835
  console.log(`Watching for changes in ${configDir}...`);
824
836
  const watcher = chokidar.watch(configDir, {
825
837
  ignored: (watchedPath) => {
826
- const fileName = path2.basename(watchedPath);
838
+ const fileName = path3.basename(watchedPath);
827
839
  return fileName === "index.ts" || // Old name, still ignore in case it exists
828
840
  fileName === "config.ts" || // Generated config file
829
841
  fileName === "processors.ts" || // Generated processors file