@monorise/cli 4.0.0 → 4.1.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 +302 -116
- package/dist/cli.js.map +1 -1
- package/dist/templates/files/core-routes.ts +22 -0
- package/dist/templates/files/example-page.tsx +103 -0
- package/dist/templates/files/global-initializer.tsx +16 -0
- package/dist/templates/files/global-loader.tsx +45 -0
- package/dist/templates/files/globals.css +72 -0
- package/dist/templates/files/lib-utils.ts +6 -0
- package/dist/templates/files/monorise.config.ts +7 -0
- package/dist/templates/files/proxy-request.ts +49 -0
- package/dist/templates/files/proxy-route.ts +22 -0
- package/dist/templates/files/sst.config.ts +30 -0
- package/dist/templates/files/team-entity.ts +37 -0
- package/dist/templates/files/team-membership.mutual.ts +16 -0
- package/dist/templates/files/ui-button.tsx +65 -0
- package/dist/templates/files/ui-card.tsx +103 -0
- package/dist/templates/files/ui-input.tsx +19 -0
- package/dist/templates/files/ui-label.tsx +24 -0
- package/dist/templates/files/user-entity.ts +43 -0
- package/package.json +7 -2
package/dist/cli.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
// cli.ts
|
|
4
4
|
import "tsx";
|
|
5
|
-
import "tsconfig-paths/register.js";
|
|
6
5
|
import fs2 from "fs";
|
|
7
6
|
import path2 from "path";
|
|
7
|
+
import { execSync } from "child_process";
|
|
8
8
|
import chokidar from "chokidar";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
9
10
|
|
|
10
11
|
// commands/utils/detect-package.ts
|
|
11
12
|
import fs from "fs";
|
|
@@ -23,19 +24,56 @@ function detectCombinedPackage(startDir) {
|
|
|
23
24
|
return false;
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
// templates/root-tsconfig.ts
|
|
28
|
+
var ROOT_TSCONFIG_TEMPLATE = {
|
|
29
|
+
compilerOptions: {
|
|
30
|
+
target: "ES2022",
|
|
31
|
+
module: "ESNext",
|
|
32
|
+
moduleResolution: "bundler",
|
|
33
|
+
esModuleInterop: true,
|
|
34
|
+
strict: true,
|
|
35
|
+
skipLibCheck: true,
|
|
36
|
+
jsx: "preserve",
|
|
37
|
+
paths: {
|
|
38
|
+
"#/shared/*": ["./shared/*"],
|
|
39
|
+
"#/monorise/*": ["./.monorise/*"],
|
|
40
|
+
"#/monorise": ["./.monorise/index"]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
include: ["**/*.ts", ".monorise/**/*.ts"],
|
|
44
|
+
exclude: ["node_modules", "apps"]
|
|
45
|
+
};
|
|
46
|
+
|
|
26
47
|
// cli.ts
|
|
48
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
49
|
+
var __dirname = path2.dirname(__filename);
|
|
50
|
+
var TEMPLATES_DIR = path2.join(__dirname, "templates", "files");
|
|
51
|
+
function readTemplate(filename) {
|
|
52
|
+
return fs2.readFileSync(path2.join(TEMPLATES_DIR, filename), "utf-8");
|
|
53
|
+
}
|
|
27
54
|
function kebabToCamel(str) {
|
|
28
55
|
return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
29
56
|
}
|
|
30
57
|
function kebabToPascal(kebab) {
|
|
31
58
|
return kebab.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
32
59
|
}
|
|
60
|
+
function execCommand(command, cwd, stdio = "inherit") {
|
|
61
|
+
console.log(`Running: ${command}`);
|
|
62
|
+
execSync(command, { cwd, stdio });
|
|
63
|
+
}
|
|
33
64
|
async function generateConfigFile(configDir, monoriseOutputDir, projectRoot) {
|
|
34
65
|
const configOutputPath = path2.join(monoriseOutputDir, "config.ts");
|
|
35
66
|
const initialConfigContent = `
|
|
36
67
|
export enum Entity {}
|
|
68
|
+
export default {};
|
|
37
69
|
`;
|
|
38
70
|
fs2.writeFileSync(configOutputPath, initialConfigContent);
|
|
71
|
+
fs2.writeFileSync(
|
|
72
|
+
path2.join(monoriseOutputDir, "index.ts"),
|
|
73
|
+
`export * from './config';
|
|
74
|
+
export { default } from './config';
|
|
75
|
+
`
|
|
76
|
+
);
|
|
39
77
|
const files = fs2.readdirSync(configDir).filter((file) => file.endsWith(".ts") && file !== "index.ts");
|
|
40
78
|
const names = /* @__PURE__ */ new Set();
|
|
41
79
|
const nameRegex = /^[a-z]+(-[a-z]+)*$/;
|
|
@@ -145,6 +183,14 @@ ${moduleAugmentations}
|
|
|
145
183
|
`;
|
|
146
184
|
fs2.writeFileSync(configOutputPath, configOutputContent);
|
|
147
185
|
console.log("Successfully generated config.ts!");
|
|
186
|
+
const indexOutputPath = path2.join(monoriseOutputDir, "index.ts");
|
|
187
|
+
fs2.writeFileSync(
|
|
188
|
+
indexOutputPath,
|
|
189
|
+
`export * from './config';
|
|
190
|
+
export { default } from './config';
|
|
191
|
+
`
|
|
192
|
+
);
|
|
193
|
+
console.log("Successfully generated index.ts!");
|
|
148
194
|
return configOutputPath;
|
|
149
195
|
}
|
|
150
196
|
async function generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir) {
|
|
@@ -162,20 +208,6 @@ async function generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir
|
|
|
162
208
|
`Custom routes file not found: '${absoluteCustomRoutesPath}'. Please ensure 'customRoutes' in monorise.config.ts points to a valid file.`
|
|
163
209
|
);
|
|
164
210
|
}
|
|
165
|
-
let routesModule;
|
|
166
|
-
try {
|
|
167
|
-
routesModule = await import(absoluteCustomRoutesPath);
|
|
168
|
-
} catch (e) {
|
|
169
|
-
throw new Error(
|
|
170
|
-
`Failed to load custom routes file at '${absoluteCustomRoutesPath}'. Ensure it's a valid JavaScript/TypeScript module. Error: ${e.message}`
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
const routesExport = routesModule.default;
|
|
174
|
-
if (!routesExport || routesExport === null || typeof routesExport === "object" && !("get" in routesExport && "post" in routesExport && "use" in routesExport)) {
|
|
175
|
-
throw new Error(
|
|
176
|
-
`Custom routes file at '${absoluteCustomRoutesPath}' must default export an instance of Hono (or an object with .get, .post, .use methods). Or a function that consume the dependency container provided by route handler.`
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
211
|
let relativePathToRoutes = path2.relative(
|
|
180
212
|
monoriseOutputDir,
|
|
181
213
|
absoluteCustomRoutesPath
|
|
@@ -278,123 +310,277 @@ var MONORISE_LOGO = `
|
|
|
278
310
|
|
|
279
311
|
`;
|
|
280
312
|
async function runInitCommand(rootPath) {
|
|
281
|
-
const projectRoot = rootPath ? path2.resolve(rootPath) : process.cwd();
|
|
282
313
|
console.log(MONORISE_LOGO);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
// custom route file should export default an Hono object.
|
|
289
|
-
// customRoutes: './path/to/custom/routes.ts'
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
export default config;
|
|
293
|
-
`;
|
|
294
|
-
if (!fs2.existsSync(monoriseConfigTsPath)) {
|
|
295
|
-
fs2.writeFileSync(monoriseConfigTsPath, monoriseConfigContent.trimStart());
|
|
296
|
-
console.log(`Created ${path2.relative(projectRoot, monoriseConfigTsPath)}`);
|
|
314
|
+
let projectName = "my-app";
|
|
315
|
+
let projectRoot;
|
|
316
|
+
if (rootPath) {
|
|
317
|
+
projectRoot = path2.resolve(rootPath);
|
|
318
|
+
projectName = path2.basename(projectRoot);
|
|
297
319
|
} else {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
)
|
|
320
|
+
const args = process.argv.slice(2);
|
|
321
|
+
const nameIndex = args.indexOf("--name");
|
|
322
|
+
if (nameIndex > -1 && args[nameIndex + 1]) {
|
|
323
|
+
projectName = args[nameIndex + 1];
|
|
324
|
+
}
|
|
325
|
+
projectRoot = path2.resolve(projectName);
|
|
301
326
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
.
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
327
|
+
console.log(`
|
|
328
|
+
\u{1F680} Creating Monorise project: ${projectName}
|
|
329
|
+
`);
|
|
330
|
+
if (fs2.existsSync(projectRoot)) {
|
|
331
|
+
console.error(`Error: Directory ${projectName} already exists.`);
|
|
332
|
+
process.exit(1);
|
|
333
|
+
}
|
|
334
|
+
console.log("\u{1F4C1} Creating project structure...");
|
|
335
|
+
fs2.mkdirSync(projectRoot, { recursive: true });
|
|
336
|
+
fs2.mkdirSync(path2.join(projectRoot, "apps"), { recursive: true });
|
|
337
|
+
fs2.mkdirSync(path2.join(projectRoot, "services", "core"), { recursive: true });
|
|
338
|
+
fs2.mkdirSync(path2.join(projectRoot, "monorise", "configs"), { recursive: true });
|
|
339
|
+
fs2.mkdirSync(path2.join(projectRoot, "monorise", "mutuals"), { recursive: true });
|
|
340
|
+
console.log("\u{1F4E6} Initializing root package.json...");
|
|
341
|
+
const rootPackageJson = {
|
|
342
|
+
name: projectName,
|
|
343
|
+
version: "0.0.0",
|
|
344
|
+
type: "module",
|
|
345
|
+
private: true,
|
|
346
|
+
workspaces: ["apps/*", "services/*"]
|
|
347
|
+
};
|
|
348
|
+
fs2.writeFileSync(
|
|
349
|
+
path2.join(projectRoot, "package.json"),
|
|
350
|
+
JSON.stringify(rootPackageJson, null, 2)
|
|
351
|
+
);
|
|
352
|
+
console.log("\u2699\uFE0F Creating root tsconfig.json...");
|
|
353
|
+
fs2.writeFileSync(
|
|
354
|
+
path2.join(projectRoot, "tsconfig.json"),
|
|
355
|
+
JSON.stringify(ROOT_TSCONFIG_TEMPLATE, null, 2)
|
|
356
|
+
);
|
|
357
|
+
console.log("\n\u{1F4F1} Creating Next.js app in apps/web...");
|
|
358
|
+
const nextAppDir = path2.join(projectRoot, "apps", "web");
|
|
359
|
+
try {
|
|
360
|
+
execCommand(
|
|
361
|
+
`npx create-next-app@latest web --typescript --tailwind --eslint --app --no-src-dir --import-alias "#/*" --no-turbopack --yes`,
|
|
362
|
+
path2.join(projectRoot, "apps")
|
|
333
363
|
);
|
|
364
|
+
} catch (error) {
|
|
365
|
+
console.error("Failed to create Next.js app:", error);
|
|
366
|
+
process.exit(1);
|
|
334
367
|
}
|
|
335
|
-
|
|
336
|
-
|
|
368
|
+
console.log("\n\u2601\uFE0F Installing SST v4...");
|
|
369
|
+
try {
|
|
370
|
+
execCommand("npm install sst@^4 --save-dev", projectRoot);
|
|
371
|
+
} catch (error) {
|
|
372
|
+
console.error("Failed to install SST:", error);
|
|
373
|
+
process.exit(1);
|
|
374
|
+
}
|
|
375
|
+
console.log("\n\u{1F4E6} Installing dependencies (monorise, hono, zod, shadcn utilities)...");
|
|
376
|
+
try {
|
|
377
|
+
execCommand("npm install monorise hono zod clsx class-variance-authority radix-ui lucide-react tailwind-merge react-hook-form @hookform/resolvers", projectRoot);
|
|
378
|
+
} catch (error) {
|
|
379
|
+
console.error("Failed to install dependencies:", error);
|
|
380
|
+
process.exit(1);
|
|
381
|
+
}
|
|
382
|
+
console.log("\u2699\uFE0F Creating monorise.config.ts...");
|
|
383
|
+
fs2.writeFileSync(
|
|
384
|
+
path2.join(projectRoot, "monorise.config.ts"),
|
|
385
|
+
readTemplate("monorise.config.ts")
|
|
386
|
+
);
|
|
387
|
+
console.log("\u{1F517} Creating team-membership mutual config...");
|
|
388
|
+
fs2.writeFileSync(
|
|
389
|
+
path2.join(projectRoot, "monorise", "mutuals", "team-membership.ts"),
|
|
390
|
+
readTemplate("team-membership.mutual.ts")
|
|
391
|
+
);
|
|
392
|
+
console.log("\u{1F464} Creating starter User entity...");
|
|
393
|
+
fs2.writeFileSync(
|
|
394
|
+
path2.join(projectRoot, "monorise", "configs", "user.ts"),
|
|
395
|
+
readTemplate("user-entity.ts")
|
|
396
|
+
);
|
|
397
|
+
console.log("\u{1F465} Creating starter Team entity...");
|
|
398
|
+
fs2.writeFileSync(
|
|
399
|
+
path2.join(projectRoot, "monorise", "configs", "team.ts"),
|
|
400
|
+
readTemplate("team-entity.ts")
|
|
401
|
+
);
|
|
402
|
+
console.log("\u{1F527} Creating services/core/routes.ts...");
|
|
403
|
+
fs2.writeFileSync(
|
|
404
|
+
path2.join(projectRoot, "services", "core", "routes.ts"),
|
|
405
|
+
readTemplate("core-routes.ts")
|
|
406
|
+
);
|
|
407
|
+
const servicesPackageJson = {
|
|
408
|
+
name: "@my-app/services",
|
|
409
|
+
version: "0.0.0",
|
|
410
|
+
type: "module"
|
|
411
|
+
};
|
|
412
|
+
fs2.writeFileSync(
|
|
413
|
+
path2.join(projectRoot, "services", "core", "package.json"),
|
|
414
|
+
JSON.stringify(servicesPackageJson, null, 2)
|
|
415
|
+
);
|
|
416
|
+
console.log("\u2699\uFE0F Creating sst.config.ts with Monorise...");
|
|
417
|
+
const sstConfigPath = path2.join(projectRoot, "sst.config.ts");
|
|
418
|
+
fs2.writeFileSync(sstConfigPath, readTemplate("sst.config.ts").replace("{{PROJECT_NAME}}", projectName));
|
|
419
|
+
console.log("\n\u2601\uFE0F Installing SST providers...");
|
|
420
|
+
try {
|
|
421
|
+
execCommand("npx sst install", projectRoot);
|
|
422
|
+
} catch (error) {
|
|
423
|
+
console.warn("Warning: SST install failed, continuing anyway...");
|
|
424
|
+
}
|
|
425
|
+
console.log("\u{1F4C4} Creating example page in apps/web...");
|
|
426
|
+
const webSrcAppDir = path2.join(projectRoot, "apps", "web", "src", "app");
|
|
427
|
+
const webAppDir = path2.join(projectRoot, "apps", "web", "app");
|
|
428
|
+
const pagePath = fs2.existsSync(webSrcAppDir) ? path2.join(webSrcAppDir, "page.tsx") : fs2.existsSync(webAppDir) ? path2.join(webAppDir, "page.tsx") : null;
|
|
429
|
+
if (pagePath) {
|
|
337
430
|
try {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
431
|
+
fs2.writeFileSync(pagePath, readTemplate("example-page.tsx"));
|
|
432
|
+
console.log(`Created example page at ${path2.relative(projectRoot, pagePath)}`);
|
|
433
|
+
} catch (error) {
|
|
434
|
+
console.warn("Warning: Could not create example page:", error);
|
|
435
|
+
}
|
|
436
|
+
} else {
|
|
437
|
+
console.warn("Warning: Could not find apps/web/src/app or apps/web/app directory");
|
|
438
|
+
}
|
|
439
|
+
const webRoot = fs2.existsSync(webSrcAppDir) ? path2.join(projectRoot, "apps", "web", "src") : fs2.existsSync(webAppDir) ? path2.join(projectRoot, "apps", "web") : null;
|
|
440
|
+
if (webRoot) {
|
|
441
|
+
const appDir = fs2.existsSync(webSrcAppDir) ? webSrcAppDir : webAppDir;
|
|
442
|
+
fs2.mkdirSync(path2.join(webRoot, "components", "ui"), { recursive: true });
|
|
443
|
+
fs2.mkdirSync(path2.join(webRoot, "lib"), { recursive: true });
|
|
444
|
+
console.log("\u{1F310} Creating global components...");
|
|
445
|
+
fs2.writeFileSync(
|
|
446
|
+
path2.join(webRoot, "components", "global-initializer.tsx"),
|
|
447
|
+
readTemplate("global-initializer.tsx")
|
|
448
|
+
);
|
|
449
|
+
fs2.writeFileSync(
|
|
450
|
+
path2.join(webRoot, "components", "global-loader.tsx"),
|
|
451
|
+
readTemplate("global-loader.tsx")
|
|
452
|
+
);
|
|
453
|
+
console.log("\u{1F527} Creating lib/utils.ts...");
|
|
454
|
+
fs2.writeFileSync(
|
|
455
|
+
path2.join(webRoot, "lib", "utils.ts"),
|
|
456
|
+
readTemplate("lib-utils.ts")
|
|
457
|
+
);
|
|
458
|
+
console.log("\u{1F3A8} Creating shadcn UI components...");
|
|
459
|
+
fs2.writeFileSync(
|
|
460
|
+
path2.join(webRoot, "components", "ui", "button.tsx"),
|
|
461
|
+
readTemplate("ui-button.tsx")
|
|
462
|
+
);
|
|
463
|
+
fs2.writeFileSync(
|
|
464
|
+
path2.join(webRoot, "components", "ui", "card.tsx"),
|
|
465
|
+
readTemplate("ui-card.tsx")
|
|
466
|
+
);
|
|
467
|
+
fs2.writeFileSync(
|
|
468
|
+
path2.join(webRoot, "components", "ui", "input.tsx"),
|
|
469
|
+
readTemplate("ui-input.tsx")
|
|
470
|
+
);
|
|
471
|
+
fs2.writeFileSync(
|
|
472
|
+
path2.join(webRoot, "components", "ui", "label.tsx"),
|
|
473
|
+
readTemplate("ui-label.tsx")
|
|
474
|
+
);
|
|
475
|
+
console.log("\u{1F3A8} Setting up shadcn globals.css...");
|
|
476
|
+
const globalsCssPath = path2.join(appDir, "globals.css");
|
|
477
|
+
fs2.writeFileSync(globalsCssPath, readTemplate("globals.css"));
|
|
478
|
+
console.log("\u{1F4D0} Updating layout.tsx with global components...");
|
|
479
|
+
const layoutPath = path2.join(appDir, "layout.tsx");
|
|
480
|
+
if (fs2.existsSync(layoutPath)) {
|
|
481
|
+
try {
|
|
482
|
+
let layoutContent = fs2.readFileSync(layoutPath, "utf8");
|
|
483
|
+
const globalImports = `import GlobalInitializer from '#/components/global-initializer';
|
|
484
|
+
import GlobalLoader from '#/components/global-loader';`;
|
|
485
|
+
const lastImportIndex = layoutContent.lastIndexOf("import ");
|
|
486
|
+
const lineEnd = layoutContent.indexOf("\n", lastImportIndex);
|
|
487
|
+
layoutContent = layoutContent.slice(0, lineEnd + 1) + globalImports + "\n" + layoutContent.slice(lineEnd + 1);
|
|
488
|
+
layoutContent = layoutContent.replace(
|
|
489
|
+
/(<body[^>]*>)/,
|
|
490
|
+
`$1
|
|
491
|
+
<div id="loader-portal" />
|
|
492
|
+
<GlobalInitializer />
|
|
493
|
+
<GlobalLoader />`
|
|
349
494
|
);
|
|
495
|
+
fs2.writeFileSync(layoutPath, layoutContent);
|
|
496
|
+
} catch (error) {
|
|
497
|
+
console.warn("Warning: Could not update layout.tsx:", error);
|
|
350
498
|
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
499
|
+
}
|
|
500
|
+
const postcssPath = path2.join(projectRoot, "apps", "web", "postcss.config.mjs");
|
|
501
|
+
if (fs2.existsSync(postcssPath)) {
|
|
502
|
+
fs2.writeFileSync(
|
|
503
|
+
postcssPath,
|
|
504
|
+
`const config = {
|
|
505
|
+
plugins: {
|
|
506
|
+
'@tailwindcss/postcss': {},
|
|
507
|
+
},
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
export default config;
|
|
511
|
+
`
|
|
355
512
|
);
|
|
356
513
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
514
|
+
console.log("\u{1F500} Creating API proxy routes...");
|
|
515
|
+
const apiDir = path2.join(appDir, "api");
|
|
516
|
+
const catchAllDir = path2.join(apiDir, "[...proxy]");
|
|
517
|
+
fs2.mkdirSync(catchAllDir, { recursive: true });
|
|
518
|
+
fs2.writeFileSync(
|
|
519
|
+
path2.join(apiDir, "proxy-request.ts"),
|
|
520
|
+
readTemplate("proxy-request.ts")
|
|
521
|
+
);
|
|
522
|
+
fs2.writeFileSync(
|
|
523
|
+
path2.join(catchAllDir, "route.ts"),
|
|
524
|
+
readTemplate("proxy-route.ts")
|
|
360
525
|
);
|
|
361
526
|
}
|
|
362
|
-
|
|
363
|
-
|
|
527
|
+
console.log("\u2699\uFE0F Updating apps/web tsconfig.json...");
|
|
528
|
+
const webTsconfigPath = path2.join(projectRoot, "apps", "web", "tsconfig.json");
|
|
529
|
+
if (fs2.existsSync(webTsconfigPath)) {
|
|
364
530
|
try {
|
|
365
|
-
const
|
|
366
|
-
const
|
|
367
|
-
if (!
|
|
368
|
-
|
|
369
|
-
}
|
|
370
|
-
if (!tsconfig.compilerOptions.paths) {
|
|
371
|
-
tsconfig.compilerOptions.paths = {};
|
|
531
|
+
const webTsconfigContent = fs2.readFileSync(webTsconfigPath, "utf8");
|
|
532
|
+
const webTsconfig = JSON.parse(webTsconfigContent);
|
|
533
|
+
if (!webTsconfig.compilerOptions) {
|
|
534
|
+
webTsconfig.compilerOptions = {};
|
|
372
535
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
if (!tsconfig.compilerOptions.paths[pathKey]) {
|
|
376
|
-
tsconfig.compilerOptions.paths[pathKey] = pathValue;
|
|
377
|
-
fs2.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2));
|
|
378
|
-
console.log(
|
|
379
|
-
`Added '${pathKey}' path alias in ${path2.relative(projectRoot, tsconfigPath)}`
|
|
380
|
-
);
|
|
381
|
-
} else {
|
|
382
|
-
console.log(
|
|
383
|
-
`'${pathKey}' path alias already set in ${path2.relative(projectRoot, tsconfigPath)}. Skipping.`
|
|
384
|
-
);
|
|
536
|
+
if (!webTsconfig.compilerOptions.paths) {
|
|
537
|
+
webTsconfig.compilerOptions.paths = {};
|
|
385
538
|
}
|
|
539
|
+
webTsconfig.compilerOptions.paths["#/shared/*"] = ["../../shared/*"];
|
|
540
|
+
webTsconfig.compilerOptions.paths["#/monorise/*"] = ["../../.monorise/*"];
|
|
541
|
+
webTsconfig.compilerOptions.paths["#/monorise"] = ["../../.monorise/index"];
|
|
542
|
+
const hasSrcDir = fs2.existsSync(path2.join(projectRoot, "apps", "web", "src"));
|
|
543
|
+
webTsconfig.compilerOptions.paths["#/*"] = [hasSrcDir ? "./src/*" : "./*"];
|
|
544
|
+
fs2.writeFileSync(webTsconfigPath, JSON.stringify(webTsconfig, null, 2));
|
|
386
545
|
} catch (error) {
|
|
387
|
-
console.error
|
|
388
|
-
`Error updating ${path2.relative(projectRoot, tsconfigPath)}:`,
|
|
389
|
-
error
|
|
390
|
-
);
|
|
546
|
+
console.warn("Warning: Could not update apps/web tsconfig.json:", error);
|
|
391
547
|
}
|
|
392
|
-
} else {
|
|
393
|
-
console.warn(
|
|
394
|
-
`Warning: ${path2.relative(projectRoot, tsconfigPath)} not found. Cannot add path alias.`
|
|
395
|
-
);
|
|
396
548
|
}
|
|
397
|
-
console.log("Monorise
|
|
549
|
+
console.log("\n\u{1F528} Running initial Monorise build...");
|
|
550
|
+
try {
|
|
551
|
+
execCommand("npx monorise build", projectRoot);
|
|
552
|
+
} catch (error) {
|
|
553
|
+
console.warn("Warning: Initial monorise build failed. You can run it manually later.");
|
|
554
|
+
}
|
|
555
|
+
console.log("\n" + "=".repeat(60));
|
|
556
|
+
console.log("\u2705 Monorise project created successfully!");
|
|
557
|
+
console.log("=".repeat(60));
|
|
558
|
+
console.log(`
|
|
559
|
+
\u{1F4C1} Project structure:`);
|
|
560
|
+
console.log(` ${projectName}/`);
|
|
561
|
+
console.log(` \u251C\u2500\u2500 apps/web/ # Next.js frontend`);
|
|
562
|
+
console.log(` \u251C\u2500\u2500 services/core/ # Backend routes (Hono)`);
|
|
563
|
+
console.log(` \u251C\u2500\u2500 monorise/configs/ # Entity definitions (User, Team)`);
|
|
564
|
+
console.log(` \u251C\u2500\u2500 monorise/mutuals/ # Shared mutual relationship configs`);
|
|
565
|
+
console.log(` \u2514\u2500\u2500 .monorise/ # Generated files`);
|
|
566
|
+
console.log(`
|
|
567
|
+
\u{1F4C2} Where to start coding:`);
|
|
568
|
+
console.log(` \u2022 Edit your data model \u2192 monorise/configs/user.ts`);
|
|
569
|
+
console.log(` (Add fields like phone, role, status to the User entity)`);
|
|
570
|
+
console.log(
|
|
571
|
+
` \u2022 Build your UI \u2192 ${pagePath ? path2.relative(projectRoot, pagePath) : "apps/web/app/page.tsx"}`
|
|
572
|
+
);
|
|
573
|
+
console.log(` (React components using useEntities and createEntity)`);
|
|
574
|
+
console.log(` \u2022 Add backend logic \u2192 services/core/routes.ts`);
|
|
575
|
+
console.log(` (Custom API endpoints with Hono)`);
|
|
576
|
+
console.log(` \u2022 See the User <-> Team relationship \u2192 monorise/mutuals/team-membership.ts`);
|
|
577
|
+
console.log(` (createMutualConfig \u2014 shared schema, referenced from both entity configs)`);
|
|
578
|
+
console.log(`
|
|
579
|
+
\u{1F680} Next steps:`);
|
|
580
|
+
console.log(` cd ${projectName}`);
|
|
581
|
+
console.log(` npx sst dev`);
|
|
582
|
+
console.log("\n\u{1F4DA} Documentation: https://monorise.dev");
|
|
583
|
+
console.log("");
|
|
398
584
|
}
|
|
399
585
|
async function runDevCommand(configDir, rootPath) {
|
|
400
586
|
console.log(MONORISE_LOGO);
|
|
@@ -465,10 +651,10 @@ async function main() {
|
|
|
465
651
|
} else if (command === "build") {
|
|
466
652
|
await runBuildCommand(rootPath);
|
|
467
653
|
} else if (command === "init") {
|
|
468
|
-
await runInitCommand(
|
|
654
|
+
await runInitCommand();
|
|
469
655
|
} else {
|
|
470
656
|
console.error(
|
|
471
|
-
"Unknown command. Usage
|
|
657
|
+
"Unknown command. Usage:\n monorise dev [--config-root <path>]\n monorise build [--config-root <path>]\n monorise init [--name <project-name>]"
|
|
472
658
|
);
|
|
473
659
|
process.exit(1);
|
|
474
660
|
}
|