create-bw-app 0.3.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.
Files changed (41) hide show
  1. package/README.md +34 -0
  2. package/bin/create-bw-app.mjs +9 -0
  3. package/package.json +27 -0
  4. package/src/cli.mjs +78 -0
  5. package/src/constants.mjs +114 -0
  6. package/src/generator.mjs +821 -0
  7. package/template/base/app/bootstrap/page.tsx +75 -0
  8. package/template/base/app/globals.css +545 -0
  9. package/template/base/app/layout.tsx +16 -0
  10. package/template/base/app/page.tsx +144 -0
  11. package/template/base/app/playground/auth/auth-playground.tsx +112 -0
  12. package/template/base/app/playground/auth/page.tsx +5 -0
  13. package/template/base/app/playground/layout.tsx +41 -0
  14. package/template/base/app/preview/app-shell/page.tsx +11 -0
  15. package/template/base/app/preview/app-shell-preview.tsx +185 -0
  16. package/template/base/config/bootstrap.ts +125 -0
  17. package/template/base/config/brand.ts +21 -0
  18. package/template/base/config/client.ts +18 -0
  19. package/template/base/config/env.ts +64 -0
  20. package/template/base/config/modules.ts +62 -0
  21. package/template/base/next-env.d.ts +6 -0
  22. package/template/base/public/brand/logo-dark.svg +7 -0
  23. package/template/base/public/brand/logo-light.svg +7 -0
  24. package/template/base/public/brand/logo-mark.svg +5 -0
  25. package/template/base/tsconfig.json +36 -0
  26. package/template/modules/admin/app/api/admin/users/roles/route.ts +6 -0
  27. package/template/modules/admin/app/api/admin/users/route.ts +6 -0
  28. package/template/modules/admin/app/playground/admin/page.tsx +102 -0
  29. package/template/modules/crm/app/playground/crm/page.tsx +103 -0
  30. package/template/modules/projects/app/playground/projects/page.tsx +93 -0
  31. package/template/site/base/app/globals.css +68 -0
  32. package/template/site/base/app/layout.tsx +17 -0
  33. package/template/site/base/app/page.tsx +165 -0
  34. package/template/site/base/components/ui/badge.tsx +28 -0
  35. package/template/site/base/components/ui/button.tsx +52 -0
  36. package/template/site/base/components/ui/card.tsx +28 -0
  37. package/template/site/base/components.json +17 -0
  38. package/template/site/base/lib/utils.ts +6 -0
  39. package/template/site/base/next-env.d.ts +6 -0
  40. package/template/site/base/postcss.config.mjs +7 -0
  41. package/template/site/base/tsconfig.json +23 -0
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # create-bw-app
2
+
3
+ Create a new BrightWeb app from either the platform or site starter.
4
+
5
+ ## Local workspace usage
6
+
7
+ From the BrightWeb platform repo root:
8
+
9
+ ```bash
10
+ pnpm create:client
11
+ pnpm create:client -- --template site
12
+ ```
13
+
14
+ ## Future published usage
15
+
16
+ Once this package is published to npm:
17
+
18
+ ```bash
19
+ pnpm dlx create-bw-app
20
+ npm create bw-app@latest
21
+ ```
22
+
23
+ ## Template behavior
24
+
25
+ - prompts for app type: `platform` or `site`
26
+ - prompts for project name
27
+ - prompts for optional modules with a checkbox list when using the platform template
28
+ - prompts to install dependencies immediately
29
+ - copies a clean Next.js starter template
30
+ - platform apps include BrightWeb auth, shell, and optional business modules
31
+ - site apps include Next.js, Tailwind CSS, and local shadcn-style component primitives
32
+ - writes `package.json`, `next.config.ts`, `.gitignore`, and `README.md` for both templates
33
+ - platform apps also write `.env.example` and `.env.local`
34
+ - supports repo-local `workspace:*` wiring and future published dependency wiring
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runCreateBwAppCli } from "../src/cli.mjs";
4
+
5
+ runCreateBwAppCli(process.argv.slice(2)).catch((error) => {
6
+ const message = error instanceof Error ? error.message : "Unknown error";
7
+ console.error(`\ncreate-bw-app failed: ${message}`);
8
+ process.exitCode = 1;
9
+ });
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "create-bw-app",
3
+ "private": false,
4
+ "version": "0.3.0",
5
+ "type": "module",
6
+ "bin": "bin/create-bw-app.mjs",
7
+ "files": [
8
+ "bin",
9
+ "src",
10
+ "template",
11
+ "README.md"
12
+ ],
13
+ "license": "MIT",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/BWLeoRibeiro/brightweb-platform.git"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "engines": {
22
+ "node": ">=20"
23
+ },
24
+ "dependencies": {
25
+ "@inquirer/prompts": "^7.0.0"
26
+ }
27
+ }
package/src/cli.mjs ADDED
@@ -0,0 +1,78 @@
1
+ import { HELP_TEXT } from "./constants.mjs";
2
+ import { createBrightwebClientApp } from "./generator.mjs";
3
+
4
+ function toCamelCase(flagName) {
5
+ return flagName.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
6
+ }
7
+
8
+ function parseArgv(argv) {
9
+ const options = {};
10
+
11
+ for (let index = 0; index < argv.length; index += 1) {
12
+ const token = argv[index];
13
+
14
+ if (token === "--") {
15
+ continue;
16
+ }
17
+
18
+ if (!token.startsWith("--")) continue;
19
+ if (token === "--help") {
20
+ options.help = true;
21
+ continue;
22
+ }
23
+
24
+ if (token === "--install") {
25
+ options.install = true;
26
+ continue;
27
+ }
28
+
29
+ if (token === "--no-install") {
30
+ options.install = false;
31
+ continue;
32
+ }
33
+
34
+ if (token === "--yes") {
35
+ options.yes = true;
36
+ continue;
37
+ }
38
+
39
+ if (token === "--dry-run") {
40
+ options.dryRun = true;
41
+ continue;
42
+ }
43
+
44
+ const [rawKey, inlineValue] = token.slice(2).split("=", 2);
45
+ const key = toCamelCase(rawKey);
46
+ const nextValue = inlineValue ?? argv[index + 1];
47
+
48
+ if (inlineValue == null) {
49
+ index += 1;
50
+ }
51
+
52
+ options[key] = nextValue;
53
+ }
54
+
55
+ return options;
56
+ }
57
+
58
+ export async function runCreateBwAppCli(argv = process.argv.slice(2), runtimeOptions = {}) {
59
+ const argvOptions = parseArgv(argv);
60
+
61
+ if (argvOptions.help) {
62
+ process.stdout.write(`${HELP_TEXT}\n`);
63
+ return;
64
+ }
65
+
66
+ try {
67
+ await createBrightwebClientApp(argvOptions, runtimeOptions);
68
+ } catch (error) {
69
+ const message = error instanceof Error ? error.message : "Unknown error";
70
+ if (message.includes("User force closed the prompt with SIGINT")) {
71
+ console.error("\nCancelled. Use Ctrl+C to exit an interactive prompt.\n");
72
+ process.exitCode = 1;
73
+ return;
74
+ }
75
+ console.error(`\n${runtimeOptions.failurePrefix || "create-bw-app failed"}: ${message}`);
76
+ process.exitCode = 1;
77
+ }
78
+ }
@@ -0,0 +1,114 @@
1
+ export const CLI_PACKAGE_NAME = "create-bw-app";
2
+ export const CLI_DISPLAY_NAME = "create-bw-app";
3
+
4
+ export const TEMPLATE_OPTIONS = [
5
+ {
6
+ key: "platform",
7
+ label: "Platform app",
8
+ description: "Authenticated BrightWeb app shell with optional business modules.",
9
+ },
10
+ {
11
+ key: "site",
12
+ label: "Site",
13
+ description: "Standalone Next.js + Tailwind site starter with a local UI layer.",
14
+ },
15
+ ];
16
+
17
+ export const SELECTABLE_MODULES = [
18
+ {
19
+ key: "crm",
20
+ label: "CRM",
21
+ packageName: "@brightweblabs/module-crm",
22
+ templateFolder: "crm",
23
+ envKey: "NEXT_PUBLIC_ENABLE_CRM",
24
+ },
25
+ {
26
+ key: "projects",
27
+ label: "Projects",
28
+ packageName: "@brightweblabs/module-projects",
29
+ templateFolder: "projects",
30
+ envKey: "NEXT_PUBLIC_ENABLE_PROJECTS",
31
+ },
32
+ {
33
+ key: "admin",
34
+ label: "Admin",
35
+ packageName: "@brightweblabs/module-admin",
36
+ templateFolder: "admin",
37
+ envKey: "NEXT_PUBLIC_ENABLE_ADMIN",
38
+ },
39
+ ];
40
+
41
+ export const CORE_PACKAGES = [
42
+ "@brightweblabs/app-shell",
43
+ "@brightweblabs/core-auth",
44
+ "@brightweblabs/infra",
45
+ "@brightweblabs/ui",
46
+ ];
47
+
48
+ export const APP_DEPENDENCY_DEFAULTS = {
49
+ "@brightweblabs/app-shell": "^0.1.1",
50
+ "@brightweblabs/core-auth": "^0.1.1",
51
+ "@brightweblabs/infra": "^0.1.0",
52
+ "@brightweblabs/module-admin": "^0.1.1",
53
+ "@brightweblabs/module-crm": "^0.1.1",
54
+ "@brightweblabs/module-projects": "^0.1.1",
55
+ "@brightweblabs/ui": "^0.1.0",
56
+ "lucide-react": "^0.562.0",
57
+ "next": "16.1.1",
58
+ "react": "19.2.3",
59
+ "react-dom": "19.2.3",
60
+ };
61
+
62
+ export const SITE_DEPENDENCY_DEFAULTS = {
63
+ "class-variance-authority": "^0.7.1",
64
+ "clsx": "^2.1.1",
65
+ "lucide-react": "^0.562.0",
66
+ "next": "16.1.1",
67
+ "react": "19.2.3",
68
+ "react-dom": "19.2.3",
69
+ "tailwind-merge": "^3.4.0",
70
+ };
71
+
72
+ export const APP_DEV_DEPENDENCY_DEFAULTS = {
73
+ "@types/node": "^20",
74
+ "@types/react": "^19",
75
+ "@types/react-dom": "^19",
76
+ "typescript": "^5",
77
+ };
78
+
79
+ export const SITE_DEV_DEPENDENCY_DEFAULTS = {
80
+ "@tailwindcss/postcss": "^4.0.0",
81
+ "@types/node": "^20",
82
+ "@types/react": "^19",
83
+ "@types/react-dom": "^19",
84
+ "postcss": "^8.4.31",
85
+ "tailwindcss": "^4.0.0",
86
+ "typescript": "^5",
87
+ };
88
+
89
+ export const DEFAULTS = {
90
+ productNameSuffix: "Platform",
91
+ tagline: "A configurable Brightweb starter app for new client instances.",
92
+ contactEmail: "hello@example.com",
93
+ supportEmail: "support@example.com",
94
+ primaryHex: "#1f7a45",
95
+ };
96
+
97
+ export const HELP_TEXT = `
98
+ Usage:
99
+ create-bw-app [options]
100
+
101
+ Options:
102
+ --template <platform|site> Scaffold a platform app or a standalone site
103
+ --name, --slug <name> Project name and default directory name
104
+ --modules <list> Comma-separated modules: crm,projects,admin
105
+ --output-dir <path> Parent folder for the generated app
106
+ --target-dir <path> Exact output directory, bypassing slug folder creation
107
+ --workspace-root <path> BrightWeb workspace root for local mode
108
+ --dependency-mode <mode> "workspace" or "published"
109
+ --install Install dependencies after scaffolding
110
+ --no-install Skip dependency installation
111
+ --yes Accept defaults for any missing optional prompt
112
+ --dry-run Print planned actions without writing files
113
+ --help Show this help message
114
+ `.trim();