@monorise/cli 3.0.3 → 4.1.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.js +295 -102
- 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,13 +24,43 @@ 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 = `
|
|
@@ -145,6 +176,14 @@ ${moduleAugmentations}
|
|
|
145
176
|
`;
|
|
146
177
|
fs2.writeFileSync(configOutputPath, configOutputContent);
|
|
147
178
|
console.log("Successfully generated config.ts!");
|
|
179
|
+
const indexOutputPath = path2.join(monoriseOutputDir, "index.ts");
|
|
180
|
+
fs2.writeFileSync(
|
|
181
|
+
indexOutputPath,
|
|
182
|
+
`export * from './config';
|
|
183
|
+
export { default } from './config';
|
|
184
|
+
`
|
|
185
|
+
);
|
|
186
|
+
console.log("Successfully generated index.ts!");
|
|
148
187
|
return configOutputPath;
|
|
149
188
|
}
|
|
150
189
|
async function generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir) {
|
|
@@ -278,123 +317,277 @@ var MONORISE_LOGO = `
|
|
|
278
317
|
|
|
279
318
|
`;
|
|
280
319
|
async function runInitCommand(rootPath) {
|
|
281
|
-
const projectRoot = rootPath ? path2.resolve(rootPath) : process.cwd();
|
|
282
320
|
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)}`);
|
|
321
|
+
let projectName = "my-app";
|
|
322
|
+
let projectRoot;
|
|
323
|
+
if (rootPath) {
|
|
324
|
+
projectRoot = path2.resolve(rootPath);
|
|
325
|
+
projectName = path2.basename(projectRoot);
|
|
297
326
|
} else {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
)
|
|
327
|
+
const args = process.argv.slice(2);
|
|
328
|
+
const nameIndex = args.indexOf("--name");
|
|
329
|
+
if (nameIndex > -1 && args[nameIndex + 1]) {
|
|
330
|
+
projectName = args[nameIndex + 1];
|
|
331
|
+
}
|
|
332
|
+
projectRoot = path2.resolve(projectName);
|
|
301
333
|
}
|
|
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
|
-
|
|
334
|
+
console.log(`
|
|
335
|
+
\u{1F680} Creating Monorise project: ${projectName}
|
|
336
|
+
`);
|
|
337
|
+
if (fs2.existsSync(projectRoot)) {
|
|
338
|
+
console.error(`Error: Directory ${projectName} already exists.`);
|
|
339
|
+
process.exit(1);
|
|
340
|
+
}
|
|
341
|
+
console.log("\u{1F4C1} Creating project structure...");
|
|
342
|
+
fs2.mkdirSync(projectRoot, { recursive: true });
|
|
343
|
+
fs2.mkdirSync(path2.join(projectRoot, "apps"), { recursive: true });
|
|
344
|
+
fs2.mkdirSync(path2.join(projectRoot, "services", "core"), { recursive: true });
|
|
345
|
+
fs2.mkdirSync(path2.join(projectRoot, "monorise", "configs"), { recursive: true });
|
|
346
|
+
fs2.mkdirSync(path2.join(projectRoot, "monorise", "mutuals"), { recursive: true });
|
|
347
|
+
console.log("\u{1F4E6} Initializing root package.json...");
|
|
348
|
+
const rootPackageJson = {
|
|
349
|
+
name: projectName,
|
|
350
|
+
version: "0.0.0",
|
|
351
|
+
type: "module",
|
|
352
|
+
private: true,
|
|
353
|
+
workspaces: ["apps/*", "services/*"]
|
|
354
|
+
};
|
|
355
|
+
fs2.writeFileSync(
|
|
356
|
+
path2.join(projectRoot, "package.json"),
|
|
357
|
+
JSON.stringify(rootPackageJson, null, 2)
|
|
358
|
+
);
|
|
359
|
+
console.log("\u2699\uFE0F Creating root tsconfig.json...");
|
|
360
|
+
fs2.writeFileSync(
|
|
361
|
+
path2.join(projectRoot, "tsconfig.json"),
|
|
362
|
+
JSON.stringify(ROOT_TSCONFIG_TEMPLATE, null, 2)
|
|
363
|
+
);
|
|
364
|
+
console.log("\n\u{1F4F1} Creating Next.js app in apps/web...");
|
|
365
|
+
const nextAppDir = path2.join(projectRoot, "apps", "web");
|
|
366
|
+
try {
|
|
367
|
+
execCommand(
|
|
368
|
+
`npx create-next-app@latest web --typescript --tailwind --eslint --app --no-src-dir --import-alias "#/*" --no-turbopack --yes`,
|
|
369
|
+
path2.join(projectRoot, "apps")
|
|
333
370
|
);
|
|
371
|
+
} catch (error) {
|
|
372
|
+
console.error("Failed to create Next.js app:", error);
|
|
373
|
+
process.exit(1);
|
|
374
|
+
}
|
|
375
|
+
console.log("\n\u2601\uFE0F Installing SST v4...");
|
|
376
|
+
try {
|
|
377
|
+
execCommand("npm install sst@^4 --save-dev", projectRoot);
|
|
378
|
+
} catch (error) {
|
|
379
|
+
console.error("Failed to install SST:", error);
|
|
380
|
+
process.exit(1);
|
|
381
|
+
}
|
|
382
|
+
console.log("\n\u{1F4E6} Installing dependencies (monorise, hono, zod, shadcn utilities)...");
|
|
383
|
+
try {
|
|
384
|
+
execCommand("npm install monorise hono zod clsx class-variance-authority radix-ui lucide-react tailwind-merge react-hook-form @hookform/resolvers", projectRoot);
|
|
385
|
+
} catch (error) {
|
|
386
|
+
console.error("Failed to install dependencies:", error);
|
|
387
|
+
process.exit(1);
|
|
388
|
+
}
|
|
389
|
+
console.log("\u2699\uFE0F Creating monorise.config.ts...");
|
|
390
|
+
fs2.writeFileSync(
|
|
391
|
+
path2.join(projectRoot, "monorise.config.ts"),
|
|
392
|
+
readTemplate("monorise.config.ts")
|
|
393
|
+
);
|
|
394
|
+
console.log("\u{1F517} Creating team-membership mutual config...");
|
|
395
|
+
fs2.writeFileSync(
|
|
396
|
+
path2.join(projectRoot, "monorise", "mutuals", "team-membership.ts"),
|
|
397
|
+
readTemplate("team-membership.mutual.ts")
|
|
398
|
+
);
|
|
399
|
+
console.log("\u{1F464} Creating starter User entity...");
|
|
400
|
+
fs2.writeFileSync(
|
|
401
|
+
path2.join(projectRoot, "monorise", "configs", "user.ts"),
|
|
402
|
+
readTemplate("user-entity.ts")
|
|
403
|
+
);
|
|
404
|
+
console.log("\u{1F465} Creating starter Team entity...");
|
|
405
|
+
fs2.writeFileSync(
|
|
406
|
+
path2.join(projectRoot, "monorise", "configs", "team.ts"),
|
|
407
|
+
readTemplate("team-entity.ts")
|
|
408
|
+
);
|
|
409
|
+
console.log("\u{1F527} Creating services/core/routes.ts...");
|
|
410
|
+
fs2.writeFileSync(
|
|
411
|
+
path2.join(projectRoot, "services", "core", "routes.ts"),
|
|
412
|
+
readTemplate("core-routes.ts")
|
|
413
|
+
);
|
|
414
|
+
const servicesPackageJson = {
|
|
415
|
+
name: "@my-app/services",
|
|
416
|
+
version: "0.0.0",
|
|
417
|
+
type: "module"
|
|
418
|
+
};
|
|
419
|
+
fs2.writeFileSync(
|
|
420
|
+
path2.join(projectRoot, "services", "core", "package.json"),
|
|
421
|
+
JSON.stringify(servicesPackageJson, null, 2)
|
|
422
|
+
);
|
|
423
|
+
console.log("\u2699\uFE0F Creating sst.config.ts with Monorise...");
|
|
424
|
+
const sstConfigPath = path2.join(projectRoot, "sst.config.ts");
|
|
425
|
+
fs2.writeFileSync(sstConfigPath, readTemplate("sst.config.ts").replace("{{PROJECT_NAME}}", projectName));
|
|
426
|
+
console.log("\n\u2601\uFE0F Installing SST providers...");
|
|
427
|
+
try {
|
|
428
|
+
execCommand("npx sst install", projectRoot);
|
|
429
|
+
} catch (error) {
|
|
430
|
+
console.warn("Warning: SST install failed, continuing anyway...");
|
|
334
431
|
}
|
|
335
|
-
|
|
336
|
-
|
|
432
|
+
console.log("\u{1F4C4} Creating example page in apps/web...");
|
|
433
|
+
const webSrcAppDir = path2.join(projectRoot, "apps", "web", "src", "app");
|
|
434
|
+
const webAppDir = path2.join(projectRoot, "apps", "web", "app");
|
|
435
|
+
const pagePath = fs2.existsSync(webSrcAppDir) ? path2.join(webSrcAppDir, "page.tsx") : fs2.existsSync(webAppDir) ? path2.join(webAppDir, "page.tsx") : null;
|
|
436
|
+
if (pagePath) {
|
|
337
437
|
try {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
438
|
+
fs2.writeFileSync(pagePath, readTemplate("example-page.tsx"));
|
|
439
|
+
console.log(`Created example page at ${path2.relative(projectRoot, pagePath)}`);
|
|
440
|
+
} catch (error) {
|
|
441
|
+
console.warn("Warning: Could not create example page:", error);
|
|
442
|
+
}
|
|
443
|
+
} else {
|
|
444
|
+
console.warn("Warning: Could not find apps/web/src/app or apps/web/app directory");
|
|
445
|
+
}
|
|
446
|
+
const webRoot = fs2.existsSync(webSrcAppDir) ? path2.join(projectRoot, "apps", "web", "src") : fs2.existsSync(webAppDir) ? path2.join(projectRoot, "apps", "web") : null;
|
|
447
|
+
if (webRoot) {
|
|
448
|
+
const appDir = fs2.existsSync(webSrcAppDir) ? webSrcAppDir : webAppDir;
|
|
449
|
+
fs2.mkdirSync(path2.join(webRoot, "components", "ui"), { recursive: true });
|
|
450
|
+
fs2.mkdirSync(path2.join(webRoot, "lib"), { recursive: true });
|
|
451
|
+
console.log("\u{1F310} Creating global components...");
|
|
452
|
+
fs2.writeFileSync(
|
|
453
|
+
path2.join(webRoot, "components", "global-initializer.tsx"),
|
|
454
|
+
readTemplate("global-initializer.tsx")
|
|
455
|
+
);
|
|
456
|
+
fs2.writeFileSync(
|
|
457
|
+
path2.join(webRoot, "components", "global-loader.tsx"),
|
|
458
|
+
readTemplate("global-loader.tsx")
|
|
459
|
+
);
|
|
460
|
+
console.log("\u{1F527} Creating lib/utils.ts...");
|
|
461
|
+
fs2.writeFileSync(
|
|
462
|
+
path2.join(webRoot, "lib", "utils.ts"),
|
|
463
|
+
readTemplate("lib-utils.ts")
|
|
464
|
+
);
|
|
465
|
+
console.log("\u{1F3A8} Creating shadcn UI components...");
|
|
466
|
+
fs2.writeFileSync(
|
|
467
|
+
path2.join(webRoot, "components", "ui", "button.tsx"),
|
|
468
|
+
readTemplate("ui-button.tsx")
|
|
469
|
+
);
|
|
470
|
+
fs2.writeFileSync(
|
|
471
|
+
path2.join(webRoot, "components", "ui", "card.tsx"),
|
|
472
|
+
readTemplate("ui-card.tsx")
|
|
473
|
+
);
|
|
474
|
+
fs2.writeFileSync(
|
|
475
|
+
path2.join(webRoot, "components", "ui", "input.tsx"),
|
|
476
|
+
readTemplate("ui-input.tsx")
|
|
477
|
+
);
|
|
478
|
+
fs2.writeFileSync(
|
|
479
|
+
path2.join(webRoot, "components", "ui", "label.tsx"),
|
|
480
|
+
readTemplate("ui-label.tsx")
|
|
481
|
+
);
|
|
482
|
+
console.log("\u{1F3A8} Setting up shadcn globals.css...");
|
|
483
|
+
const globalsCssPath = path2.join(appDir, "globals.css");
|
|
484
|
+
fs2.writeFileSync(globalsCssPath, readTemplate("globals.css"));
|
|
485
|
+
console.log("\u{1F4D0} Updating layout.tsx with global components...");
|
|
486
|
+
const layoutPath = path2.join(appDir, "layout.tsx");
|
|
487
|
+
if (fs2.existsSync(layoutPath)) {
|
|
488
|
+
try {
|
|
489
|
+
let layoutContent = fs2.readFileSync(layoutPath, "utf8");
|
|
490
|
+
const globalImports = `import GlobalInitializer from '#/components/global-initializer';
|
|
491
|
+
import GlobalLoader from '#/components/global-loader';`;
|
|
492
|
+
const lastImportIndex = layoutContent.lastIndexOf("import ");
|
|
493
|
+
const lineEnd = layoutContent.indexOf("\n", lastImportIndex);
|
|
494
|
+
layoutContent = layoutContent.slice(0, lineEnd + 1) + globalImports + "\n" + layoutContent.slice(lineEnd + 1);
|
|
495
|
+
layoutContent = layoutContent.replace(
|
|
496
|
+
/(<body[^>]*>)/,
|
|
497
|
+
`$1
|
|
498
|
+
<div id="loader-portal" />
|
|
499
|
+
<GlobalInitializer />
|
|
500
|
+
<GlobalLoader />`
|
|
349
501
|
);
|
|
502
|
+
fs2.writeFileSync(layoutPath, layoutContent);
|
|
503
|
+
} catch (error) {
|
|
504
|
+
console.warn("Warning: Could not update layout.tsx:", error);
|
|
350
505
|
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
506
|
+
}
|
|
507
|
+
const postcssPath = path2.join(projectRoot, "apps", "web", "postcss.config.mjs");
|
|
508
|
+
if (fs2.existsSync(postcssPath)) {
|
|
509
|
+
fs2.writeFileSync(
|
|
510
|
+
postcssPath,
|
|
511
|
+
`const config = {
|
|
512
|
+
plugins: {
|
|
513
|
+
'@tailwindcss/postcss': {},
|
|
514
|
+
},
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
export default config;
|
|
518
|
+
`
|
|
355
519
|
);
|
|
356
520
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
521
|
+
console.log("\u{1F500} Creating API proxy routes...");
|
|
522
|
+
const apiDir = path2.join(appDir, "api");
|
|
523
|
+
const catchAllDir = path2.join(apiDir, "[...proxy]");
|
|
524
|
+
fs2.mkdirSync(catchAllDir, { recursive: true });
|
|
525
|
+
fs2.writeFileSync(
|
|
526
|
+
path2.join(apiDir, "proxy-request.ts"),
|
|
527
|
+
readTemplate("proxy-request.ts")
|
|
528
|
+
);
|
|
529
|
+
fs2.writeFileSync(
|
|
530
|
+
path2.join(catchAllDir, "route.ts"),
|
|
531
|
+
readTemplate("proxy-route.ts")
|
|
360
532
|
);
|
|
361
533
|
}
|
|
362
|
-
|
|
363
|
-
|
|
534
|
+
console.log("\u2699\uFE0F Updating apps/web tsconfig.json...");
|
|
535
|
+
const webTsconfigPath = path2.join(projectRoot, "apps", "web", "tsconfig.json");
|
|
536
|
+
if (fs2.existsSync(webTsconfigPath)) {
|
|
364
537
|
try {
|
|
365
|
-
const
|
|
366
|
-
const
|
|
367
|
-
if (!
|
|
368
|
-
|
|
538
|
+
const webTsconfigContent = fs2.readFileSync(webTsconfigPath, "utf8");
|
|
539
|
+
const webTsconfig = JSON.parse(webTsconfigContent);
|
|
540
|
+
if (!webTsconfig.compilerOptions) {
|
|
541
|
+
webTsconfig.compilerOptions = {};
|
|
369
542
|
}
|
|
370
|
-
if (!
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
const pathKey = "#/monorise/*";
|
|
374
|
-
const pathValue = ["./.monorise/*"];
|
|
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
|
-
);
|
|
543
|
+
if (!webTsconfig.compilerOptions.paths) {
|
|
544
|
+
webTsconfig.compilerOptions.paths = {};
|
|
385
545
|
}
|
|
546
|
+
webTsconfig.compilerOptions.paths["#/shared/*"] = ["../../shared/*"];
|
|
547
|
+
webTsconfig.compilerOptions.paths["#/monorise/*"] = ["../../.monorise/*"];
|
|
548
|
+
webTsconfig.compilerOptions.paths["#/monorise"] = ["../../.monorise/index"];
|
|
549
|
+
const hasSrcDir = fs2.existsSync(path2.join(projectRoot, "apps", "web", "src"));
|
|
550
|
+
webTsconfig.compilerOptions.paths["#/*"] = [hasSrcDir ? "./src/*" : "./*"];
|
|
551
|
+
fs2.writeFileSync(webTsconfigPath, JSON.stringify(webTsconfig, null, 2));
|
|
386
552
|
} catch (error) {
|
|
387
|
-
console.error
|
|
388
|
-
`Error updating ${path2.relative(projectRoot, tsconfigPath)}:`,
|
|
389
|
-
error
|
|
390
|
-
);
|
|
553
|
+
console.warn("Warning: Could not update apps/web tsconfig.json:", error);
|
|
391
554
|
}
|
|
392
|
-
} else {
|
|
393
|
-
console.warn(
|
|
394
|
-
`Warning: ${path2.relative(projectRoot, tsconfigPath)} not found. Cannot add path alias.`
|
|
395
|
-
);
|
|
396
555
|
}
|
|
397
|
-
console.log("Monorise
|
|
556
|
+
console.log("\n\u{1F528} Running initial Monorise build...");
|
|
557
|
+
try {
|
|
558
|
+
execCommand("npx monorise build", projectRoot);
|
|
559
|
+
} catch (error) {
|
|
560
|
+
console.warn("Warning: Initial monorise build failed. You can run it manually later.");
|
|
561
|
+
}
|
|
562
|
+
console.log("\n" + "=".repeat(60));
|
|
563
|
+
console.log("\u2705 Monorise project created successfully!");
|
|
564
|
+
console.log("=".repeat(60));
|
|
565
|
+
console.log(`
|
|
566
|
+
\u{1F4C1} Project structure:`);
|
|
567
|
+
console.log(` ${projectName}/`);
|
|
568
|
+
console.log(` \u251C\u2500\u2500 apps/web/ # Next.js frontend`);
|
|
569
|
+
console.log(` \u251C\u2500\u2500 services/core/ # Backend routes (Hono)`);
|
|
570
|
+
console.log(` \u251C\u2500\u2500 monorise/configs/ # Entity definitions (User, Team)`);
|
|
571
|
+
console.log(` \u251C\u2500\u2500 monorise/mutuals/ # Shared mutual relationship configs`);
|
|
572
|
+
console.log(` \u2514\u2500\u2500 .monorise/ # Generated files`);
|
|
573
|
+
console.log(`
|
|
574
|
+
\u{1F4C2} Where to start coding:`);
|
|
575
|
+
console.log(` \u2022 Edit your data model \u2192 monorise/configs/user.ts`);
|
|
576
|
+
console.log(` (Add fields like phone, role, status to the User entity)`);
|
|
577
|
+
console.log(
|
|
578
|
+
` \u2022 Build your UI \u2192 ${pagePath ? path2.relative(projectRoot, pagePath) : "apps/web/app/page.tsx"}`
|
|
579
|
+
);
|
|
580
|
+
console.log(` (React components using useEntities and createEntity)`);
|
|
581
|
+
console.log(` \u2022 Add backend logic \u2192 services/core/routes.ts`);
|
|
582
|
+
console.log(` (Custom API endpoints with Hono)`);
|
|
583
|
+
console.log(` \u2022 See the User <-> Team relationship \u2192 monorise/mutuals/team-membership.ts`);
|
|
584
|
+
console.log(` (createMutualConfig \u2014 shared schema, referenced from both entity configs)`);
|
|
585
|
+
console.log(`
|
|
586
|
+
\u{1F680} Next steps:`);
|
|
587
|
+
console.log(` cd ${projectName}`);
|
|
588
|
+
console.log(` npx sst dev`);
|
|
589
|
+
console.log("\n\u{1F4DA} Documentation: https://monorise.dev");
|
|
590
|
+
console.log("");
|
|
398
591
|
}
|
|
399
592
|
async function runDevCommand(configDir, rootPath) {
|
|
400
593
|
console.log(MONORISE_LOGO);
|
|
@@ -465,10 +658,10 @@ async function main() {
|
|
|
465
658
|
} else if (command === "build") {
|
|
466
659
|
await runBuildCommand(rootPath);
|
|
467
660
|
} else if (command === "init") {
|
|
468
|
-
await runInitCommand(
|
|
661
|
+
await runInitCommand();
|
|
469
662
|
} else {
|
|
470
663
|
console.error(
|
|
471
|
-
"Unknown command. Usage
|
|
664
|
+
"Unknown command. Usage:\n monorise dev [--config-root <path>]\n monorise build [--config-root <path>]\n monorise init [--name <project-name>]"
|
|
472
665
|
);
|
|
473
666
|
process.exit(1);
|
|
474
667
|
}
|