create-lumen 1.0.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 (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +115 -0
  3. package/bin/cli.js +17 -0
  4. package/package.json +42 -0
  5. package/src/cleanup.js +7 -0
  6. package/src/config-cache.js +27 -0
  7. package/src/configure.js +161 -0
  8. package/src/confirm-empty-folder.js +45 -0
  9. package/src/css.js +59 -0
  10. package/src/dependencies.js +101 -0
  11. package/src/injector.js +276 -0
  12. package/src/main.js +197 -0
  13. package/src/prompts.js +232 -0
  14. package/src/readme.js +178 -0
  15. package/src/scaffold.js +29 -0
  16. package/src/utils/dev-server.js +34 -0
  17. package/src/utils/fs.js +74 -0
  18. package/src/utils/pkg-manager.js +17 -0
  19. package/src/utils/yarn-v1.js +10 -0
  20. package/templates/architectures/component-based/main.jsx +10 -0
  21. package/templates/architectures/component-based/main.tsx +10 -0
  22. package/templates/architectures/component-based/src/App.jsx +11 -0
  23. package/templates/architectures/component-based/src/App.tsx +11 -0
  24. package/templates/architectures/component-based/src/components/common/Button.jsx +30 -0
  25. package/templates/architectures/component-based/src/components/common/Button.tsx +35 -0
  26. package/templates/architectures/component-based/src/components/common/index.js +1 -0
  27. package/templates/architectures/component-based/src/components/common/index.ts +1 -0
  28. package/templates/architectures/component-based/src/components/form/.gitkeep +0 -0
  29. package/templates/architectures/component-based/src/components/layout/.gitkeep +0 -0
  30. package/templates/architectures/component-based/src/config/constants.js +2 -0
  31. package/templates/architectures/component-based/src/config/constants.ts +2 -0
  32. package/templates/architectures/component-based/src/config/routes.js +7 -0
  33. package/templates/architectures/component-based/src/config/routes.ts +7 -0
  34. package/templates/architectures/component-based/src/context/AppContext.jsx +13 -0
  35. package/templates/architectures/component-based/src/context/AppContext.tsx +13 -0
  36. package/templates/architectures/component-based/src/hooks/index.js +1 -0
  37. package/templates/architectures/component-based/src/hooks/index.ts +1 -0
  38. package/templates/architectures/component-based/src/hooks/useLocalStorage.jsx +28 -0
  39. package/templates/architectures/component-based/src/hooks/useLocalStorage.ts +28 -0
  40. package/templates/architectures/component-based/src/layouts/MainLayout.jsx +29 -0
  41. package/templates/architectures/component-based/src/layouts/MainLayout.tsx +33 -0
  42. package/templates/architectures/component-based/src/layouts/index.js +1 -0
  43. package/templates/architectures/component-based/src/layouts/index.ts +1 -0
  44. package/templates/architectures/component-based/src/pages/Home/Home.jsx +16 -0
  45. package/templates/architectures/component-based/src/pages/Home/Home.tsx +16 -0
  46. package/templates/architectures/component-based/src/pages/Home/index.js +1 -0
  47. package/templates/architectures/component-based/src/pages/Home/index.ts +1 -0
  48. package/templates/architectures/component-based/src/routes/index.jsx +11 -0
  49. package/templates/architectures/component-based/src/routes/index.tsx +11 -0
  50. package/templates/architectures/component-based/src/services/.gitkeep +0 -0
  51. package/templates/architectures/component-based/src/store/.gitkeep +0 -0
  52. package/templates/architectures/component-based/src/styles/globals.css +7 -0
  53. package/templates/architectures/component-based/src/utils/cn.jsx +3 -0
  54. package/templates/architectures/component-based/src/utils/cn.ts +3 -0
  55. package/templates/architectures/component-based/src/utils/index.js +1 -0
  56. package/templates/architectures/component-based/src/utils/index.ts +1 -0
  57. package/templates/architectures/feature-based/main.jsx +10 -0
  58. package/templates/architectures/feature-based/main.tsx +10 -0
  59. package/templates/architectures/feature-based/scripts/create-feature.mjs +65 -0
  60. package/templates/architectures/feature-based/src/app/App.jsx +10 -0
  61. package/templates/architectures/feature-based/src/app/App.tsx +10 -0
  62. package/templates/architectures/feature-based/src/app/providers/ThemeProvider.jsx +5 -0
  63. package/templates/architectures/feature-based/src/app/providers/ThemeProvider.tsx +5 -0
  64. package/templates/architectures/feature-based/src/components/ui/Button.jsx +23 -0
  65. package/templates/architectures/feature-based/src/components/ui/Button.tsx +28 -0
  66. package/templates/architectures/feature-based/src/components/ui/index.js +1 -0
  67. package/templates/architectures/feature-based/src/components/ui/index.ts +1 -0
  68. package/templates/architectures/feature-based/src/config/constants.js +2 -0
  69. package/templates/architectures/feature-based/src/config/constants.ts +2 -0
  70. package/templates/architectures/feature-based/src/features/home/components/.gitkeep +0 -0
  71. package/templates/architectures/feature-based/src/features/home/hooks/.gitkeep +0 -0
  72. package/templates/architectures/feature-based/src/features/home/index.js +1 -0
  73. package/templates/architectures/feature-based/src/features/home/index.ts +1 -0
  74. package/templates/architectures/feature-based/src/features/home/interfaces/.gitkeep +0 -0
  75. package/templates/architectures/feature-based/src/features/home/layouts/.gitkeep +0 -0
  76. package/templates/architectures/feature-based/src/features/home/pages/HomePage.jsx +14 -0
  77. package/templates/architectures/feature-based/src/features/home/pages/HomePage.tsx +14 -0
  78. package/templates/architectures/feature-based/src/features/home/services/.gitkeep +0 -0
  79. package/templates/architectures/feature-based/src/features/home/store/.gitkeep +0 -0
  80. package/templates/architectures/feature-based/src/hooks/index.js +1 -0
  81. package/templates/architectures/feature-based/src/hooks/index.ts +1 -0
  82. package/templates/architectures/feature-based/src/hooks/useLocalStorage.jsx +28 -0
  83. package/templates/architectures/feature-based/src/hooks/useLocalStorage.ts +28 -0
  84. package/templates/architectures/feature-based/src/lib/.gitkeep +0 -0
  85. package/templates/architectures/feature-based/src/stores/.gitkeep +0 -0
  86. package/templates/architectures/feature-based/src/styles/globals.css +1 -0
  87. package/templates/architectures/feature-based/src/types/index.js +13 -0
  88. package/templates/architectures/feature-based/src/types/index.ts +11 -0
  89. package/templates/architectures/feature-based/src/utils/cn.jsx +3 -0
  90. package/templates/architectures/feature-based/src/utils/cn.ts +6 -0
  91. package/templates/architectures/feature-based/src/utils/index.js +1 -0
  92. package/templates/architectures/feature-based/src/utils/index.ts +1 -0
  93. package/templates/conditional/axios/component-based/src/services/axios.jsx +19 -0
  94. package/templates/conditional/axios/component-based/src/services/axios.ts +19 -0
  95. package/templates/conditional/axios/component-based/src/services/index.js +1 -0
  96. package/templates/conditional/axios/component-based/src/services/index.ts +1 -0
  97. package/templates/conditional/axios/feature-based/src/lib/axios.jsx +19 -0
  98. package/templates/conditional/axios/feature-based/src/lib/axios.ts +19 -0
  99. package/templates/conditional/axios/feature-based/src/lib/index.js +1 -0
  100. package/templates/conditional/axios/feature-based/src/lib/index.ts +1 -0
  101. package/templates/conditional/icons/huge/component-based/src/pages/Home/Home.jsx +20 -0
  102. package/templates/conditional/icons/huge/component-based/src/pages/Home/Home.tsx +20 -0
  103. package/templates/conditional/icons/huge/feature-based/src/features/home/pages/HomePage.jsx +20 -0
  104. package/templates/conditional/icons/huge/feature-based/src/features/home/pages/HomePage.tsx +20 -0
  105. package/templates/conditional/icons/lucide/component-based/src/pages/Home/Home.jsx +20 -0
  106. package/templates/conditional/icons/lucide/component-based/src/pages/Home/Home.tsx +20 -0
  107. package/templates/conditional/icons/lucide/feature-based/src/features/home/pages/HomePage.jsx +20 -0
  108. package/templates/conditional/icons/lucide/feature-based/src/features/home/pages/HomePage.tsx +20 -0
  109. package/templates/conditional/linting/eslint/eslint.config.js +31 -0
  110. package/templates/conditional/linting/eslint/eslint.config.ts +28 -0
  111. package/templates/conditional/linting/oxlint/oxlintrc.json +9 -0
  112. package/templates/conditional/router/component-based/src/App.jsx +11 -0
  113. package/templates/conditional/router/component-based/src/App.tsx +11 -0
  114. package/templates/conditional/router/component-based/src/routes/index.jsx +13 -0
  115. package/templates/conditional/router/component-based/src/routes/index.tsx +13 -0
  116. package/templates/conditional/router/feature-based/src/app/App.jsx +6 -0
  117. package/templates/conditional/router/feature-based/src/app/App.tsx +6 -0
  118. package/templates/conditional/router/feature-based/src/app/router.jsx +13 -0
  119. package/templates/conditional/router/feature-based/src/app/router.tsx +13 -0
  120. package/templates/conditional/state/redux/component-based/src/context/StoreProvider.jsx +7 -0
  121. package/templates/conditional/state/redux/component-based/src/context/StoreProvider.tsx +7 -0
  122. package/templates/conditional/state/redux/component-based/src/pages/Home/counterSlice.jsx +20 -0
  123. package/templates/conditional/state/redux/component-based/src/pages/Home/counterSlice.ts +20 -0
  124. package/templates/conditional/state/redux/component-based/src/store/hooks.js +4 -0
  125. package/templates/conditional/state/redux/component-based/src/store/hooks.ts +4 -0
  126. package/templates/conditional/state/redux/component-based/src/store/index.js +8 -0
  127. package/templates/conditional/state/redux/component-based/src/store/index.ts +11 -0
  128. package/templates/conditional/state/redux/feature-based/src/app/providers/StoreProvider.jsx +7 -0
  129. package/templates/conditional/state/redux/feature-based/src/app/providers/StoreProvider.tsx +7 -0
  130. package/templates/conditional/state/redux/feature-based/src/features/home/store/counterSlice.jsx +20 -0
  131. package/templates/conditional/state/redux/feature-based/src/features/home/store/counterSlice.ts +20 -0
  132. package/templates/conditional/state/redux/feature-based/src/stores/hooks.js +4 -0
  133. package/templates/conditional/state/redux/feature-based/src/stores/hooks.ts +4 -0
  134. package/templates/conditional/state/redux/feature-based/src/stores/index.js +8 -0
  135. package/templates/conditional/state/redux/feature-based/src/stores/index.ts +11 -0
  136. package/templates/conditional/state/zustand/component-based/src/store/useCounterStore.jsx +9 -0
  137. package/templates/conditional/state/zustand/component-based/src/store/useCounterStore.ts +9 -0
  138. package/templates/conditional/state/zustand/feature-based/src/stores/useCounterStore.jsx +9 -0
  139. package/templates/conditional/state/zustand/feature-based/src/stores/useCounterStore.ts +9 -0
  140. package/templates/conditional/testing/jest/jest.config.js +12 -0
  141. package/templates/conditional/testing/jest/jest.config.ts +13 -0
  142. package/templates/conditional/testing/jest/jest.setup.js +1 -0
  143. package/templates/conditional/testing/jest/jest.setup.ts +1 -0
  144. package/templates/conditional/testing/jest/src/__tests__/App.test.jsx +9 -0
  145. package/templates/conditional/testing/jest/src/__tests__/App.test.tsx +9 -0
  146. package/templates/conditional/testing/vitest/src/__tests__/App.test.jsx +10 -0
  147. package/templates/conditional/testing/vitest/src/__tests__/App.test.tsx +10 -0
  148. package/templates/conditional/testing/vitest/src/test/setup.js +1 -0
  149. package/templates/conditional/testing/vitest/src/test/setup.ts +1 -0
  150. package/templates/conditional/testing/vitest/vitest.config.js +18 -0
  151. package/templates/conditional/testing/vitest/vitest.config.ts +18 -0
  152. package/templates/css/bootstrap/src/index.css +1 -0
  153. package/templates/css/none/src/index.css +18 -0
  154. package/templates/css/tailwind/src/index.css +1 -0
  155. package/templates/css/tailwind/vite.config.js +15 -0
  156. package/templates/css/tailwind/vite.config.ts +15 -0
package/src/readme.js ADDED
@@ -0,0 +1,178 @@
1
+ import { writeFileRecursive } from "./utils/fs.js";
2
+ import path from "path";
3
+
4
+ function buildBuiltWith(responses) {
5
+ const items = ["[React](https://reactjs.org/) + [Vite](https://vitejs.dev/)"];
6
+
7
+ if (responses.language === "ts") {
8
+ items.push("[TypeScript](https://www.typescriptlang.org/)");
9
+ }
10
+
11
+ if (responses.cssFramework === "tailwind") {
12
+ items.push("[Tailwind CSS](https://tailwindcss.com/)");
13
+ } else if (responses.cssFramework === "bootstrap") {
14
+ items.push("[Bootstrap](https://getbootstrap.com/)");
15
+ }
16
+
17
+ if (responses.router) {
18
+ items.push("[React Router](https://reactrouter.com/)");
19
+ }
20
+
21
+ if (responses.stateManagement === "redux") {
22
+ items.push("[Redux Toolkit](https://redux-toolkit.js.org/)");
23
+ } else if (responses.stateManagement === "zustand") {
24
+ items.push("[Zustand](https://zustand-demo.pmnd.rs/)");
25
+ }
26
+
27
+ if (responses.iconLibrary === "lucide") {
28
+ items.push("[Lucide Icons](https://lucide.dev/)");
29
+ } else if (responses.iconLibrary === "huge") {
30
+ items.push("[Huge Icons](https://hugeicons.com/)");
31
+ }
32
+
33
+ if (responses.axios) {
34
+ items.push("[Axios](https://axios-http.com/)");
35
+ }
36
+
37
+ if (responses.testing === "vitest") {
38
+ items.push("[Vitest](https://vitest.dev/)");
39
+ } else if (responses.testing === "jest") {
40
+ items.push("[Jest](https://jestjs.io/)");
41
+ }
42
+
43
+ if (responses.linter === "eslint") {
44
+ items.push("[ESLint](https://eslint.org/)");
45
+ } else if (responses.linter === "oxlint") {
46
+ items.push("[Oxlint](https://oxc.rs/)");
47
+ }
48
+
49
+ return items.map((item) => `- ${item}`).join("\n");
50
+ }
51
+
52
+ function buildScripts(responses) {
53
+ const rows = [
54
+ "| `npm run dev` | Start development server |",
55
+ "| `npm run build` | Build for production |",
56
+ "| `npm run preview` | Preview production build |",
57
+ ];
58
+
59
+ if (responses.testing !== "none") {
60
+ rows.push("| `npm run test` | Run tests |");
61
+ }
62
+
63
+ if (responses.linter === "eslint") {
64
+ rows.push("| `npm run lint` | Run ESLint |");
65
+ rows.push("| `npm run lint:fix` | Run ESLint with auto-fix |");
66
+ } else if (responses.linter === "oxlint") {
67
+ rows.push("| `npm run lint` | Run Oxlint |");
68
+ }
69
+
70
+ return rows.join("\n");
71
+ }
72
+
73
+ function buildProjectStructure(architecture) {
74
+ if (architecture === "feature-based") {
75
+ return `src/
76
+ ├── app/ # App shell and providers
77
+ ├── components/ # Shared UI components
78
+ ├── config/ # Constants and configuration
79
+ ├── features/ # Feature modules (pages, hooks, api)
80
+ ├── hooks/ # Shared custom hooks
81
+ ├── stores/ # Global state stores
82
+ ├── types/ # TypeScript type definitions
83
+ └── utils/ # Utility functions`;
84
+ }
85
+
86
+ return `src/
87
+ ├── components/ # Reusable UI components (common, form, layout)
88
+ ├── config/ # Constants and route definitions
89
+ ├── context/ # React context providers
90
+ ├── hooks/ # Shared custom hooks
91
+ ├── layouts/ # Page layout wrappers
92
+ ├── pages/ # Page-level components
93
+ ├── routes/ # Route definitions
94
+ ├── services/ # API service layer
95
+ ├── store/ # State store
96
+ ├── styles/ # Global styles
97
+ └── utils/ # Utility functions`;
98
+ }
99
+
100
+ function buildLicense() {
101
+ const year = new Date().getFullYear();
102
+ return `MIT License
103
+
104
+ Copyright (c) ${year}
105
+
106
+ Permission is hereby granted, free of charge, to any person obtaining a copy
107
+ of this software and associated documentation files (the "Software"), to deal
108
+ in the Software without restriction, including without limitation the rights
109
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
110
+ copies of the Software, and to permit persons to whom the Software is
111
+ furnished to do so, subject to the following conditions:
112
+
113
+ The above copyright notice and this permission notice shall be included in all
114
+ copies or substantial portions of the Software.
115
+
116
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
117
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
118
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
119
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
120
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
121
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
122
+ SOFTWARE.
123
+ `;
124
+ }
125
+
126
+ function buildReadme(projectName, responses) {
127
+ const builtWith = buildBuiltWith(responses);
128
+ const scripts = buildScripts(responses);
129
+ const structure = buildProjectStructure(responses.architecture);
130
+
131
+ return `# ${projectName}
132
+
133
+ <!-- TODO: Add a short description of your project -->
134
+
135
+ ## Built With
136
+
137
+ ${builtWith}
138
+
139
+ ## Getting Started
140
+
141
+ \`\`\`sh
142
+ npm install
143
+ npm run dev
144
+ \`\`\`
145
+
146
+ ## Scripts
147
+
148
+ | Script | Description |
149
+ |--------|-------------|
150
+ ${scripts}
151
+
152
+ ## Project Structure
153
+
154
+ <!-- TODO: Update this to match your actual structure -->
155
+
156
+ \`\`\`
157
+ ${structure}
158
+ \`\`\`
159
+
160
+ ## Authors
161
+
162
+ - **Your Name** - [@your_twitter](https://twitter.com/your_twitter) - your@email.com
163
+
164
+ See also the list of [contributors](https://github.com/your_username/${projectName}/graphs/contributors) who participated in this project.
165
+
166
+ ## License
167
+
168
+ Distributed under the MIT License. See \`LICENSE\` for more information.
169
+ `;
170
+ }
171
+
172
+ export async function generateReadme(projectPath, projectName, responses) {
173
+ const readmeContent = buildReadme(projectName, responses);
174
+ const licenseContent = buildLicense();
175
+
176
+ await writeFileRecursive(path.join(projectPath, "README.md"), readmeContent);
177
+ await writeFileRecursive(path.join(projectPath, "LICENSE"), licenseContent);
178
+ }
@@ -0,0 +1,29 @@
1
+ import path from "path";
2
+ import { execa } from "execa";
3
+ import { isYarnV1 } from "./utils/yarn-v1.js";
4
+
5
+ export async function runViteCreate(projectPath, projectName, pkg, language) {
6
+ const useYarn = pkg === "yarn";
7
+ const isYarn1 = useYarn && isYarnV1();
8
+ const useNpm = pkg === "npm";
9
+ const template = language === "ts" ? "react-ts" : "react";
10
+
11
+ const createArgs = [
12
+ "create",
13
+ isYarn1 ? "vite" : "vite@latest",
14
+ projectName,
15
+ useNpm && "--",
16
+ "--template",
17
+ template,
18
+ ].filter(Boolean);
19
+
20
+ await execa(pkg, createArgs, { stdio: "pipe", cwd: path.dirname(projectPath) });
21
+ }
22
+
23
+ export async function runBaseInstall(projectPath, pkg) {
24
+ await execa(pkg, ["install"], { stdio: "pipe", cwd: projectPath });
25
+ }
26
+
27
+ export async function runGitInit(projectPath) {
28
+ await execa("git", ["init"], { stdio: "pipe", cwd: projectPath });
29
+ }
@@ -0,0 +1,34 @@
1
+ import { isCancel, select } from "@clack/prompts";
2
+ import chalk from "chalk";
3
+ import { execa } from "execa";
4
+
5
+ export async function handleDevServer(pkg, projectName) {
6
+ const startDev = await select({
7
+ message: "Start the development server?",
8
+ options: [
9
+ { label: "Yes", value: true },
10
+ { label: "No", value: false },
11
+ ],
12
+ initialValue: true,
13
+ });
14
+
15
+ if (isCancel(startDev)) {
16
+ printNextSteps(projectName, pkg);
17
+ return;
18
+ }
19
+
20
+ if (startDev) {
21
+ console.log(chalk.green("\nStarting dev server...\n"));
22
+ await execa(pkg, ["run", "dev"], { stdio: "inherit" });
23
+ } else {
24
+ printNextSteps(projectName, pkg);
25
+ }
26
+ }
27
+
28
+ function printNextSteps(projectName, pkg) {
29
+ console.log(chalk.bold("\nNext steps:"));
30
+ if (projectName !== ".") {
31
+ console.log(chalk.gray(` cd ${projectName}`));
32
+ }
33
+ console.log(chalk.gray(` ${pkg} run dev\n`));
34
+ }
@@ -0,0 +1,74 @@
1
+ import {
2
+ access,
3
+ readdir,
4
+ readFile,
5
+ rm,
6
+ stat,
7
+ unlink,
8
+ writeFile,
9
+ mkdir,
10
+ copyFile,
11
+ } from "fs/promises";
12
+ import path from "path";
13
+
14
+ export async function deleteIfExists(filePath) {
15
+ try {
16
+ await access(filePath);
17
+ const s = await stat(filePath);
18
+ if (s.isDirectory()) {
19
+ await rm(filePath, { recursive: true, force: true });
20
+ } else {
21
+ await unlink(filePath);
22
+ }
23
+ } catch {
24
+ // doesn't exist, skip
25
+ }
26
+ }
27
+
28
+ export async function cleanDir(dirPath) {
29
+ try {
30
+ await access(dirPath);
31
+ const files = await readdir(dirPath);
32
+ for (const file of files) {
33
+ const target = path.join(dirPath, file);
34
+ const s = await stat(target);
35
+ if (s.isDirectory()) {
36
+ await rm(target, { recursive: true, force: true });
37
+ } else {
38
+ await unlink(target);
39
+ }
40
+ }
41
+ } catch {
42
+ // doesn't exist, skip
43
+ }
44
+ }
45
+
46
+ export async function copyDirRecursive(srcDir, destDir, filterFn) {
47
+ await mkdir(destDir, { recursive: true });
48
+ const entries = await readdir(srcDir, { withFileTypes: true });
49
+
50
+ for (const entry of entries) {
51
+ const srcPath = path.join(srcDir, entry.name);
52
+ const destPath = path.join(destDir, entry.name);
53
+
54
+ if (filterFn && !filterFn(entry.name, srcPath)) {
55
+ continue;
56
+ }
57
+
58
+ if (entry.isDirectory()) {
59
+ await copyDirRecursive(srcPath, destPath, filterFn);
60
+ } else {
61
+ await copyFile(srcPath, destPath);
62
+ }
63
+ }
64
+ }
65
+
66
+ export async function writeFileRecursive(filePath, content) {
67
+ const dir = path.dirname(filePath);
68
+ await mkdir(dir, { recursive: true });
69
+ await writeFile(filePath, content, "utf8");
70
+ }
71
+
72
+ export async function readFileContent(filePath) {
73
+ return readFile(filePath, "utf8");
74
+ }
@@ -0,0 +1,17 @@
1
+ export function getPkgManager() {
2
+ const ua = process.env.npm_config_user_agent || "";
3
+ const execPath = process.env.npm_execpath || "";
4
+ const argv0 = process.argv[1] || "";
5
+
6
+ if (ua.startsWith("yarn")) return "yarn";
7
+ if (ua.startsWith("pnpm")) return "pnpm";
8
+ if (ua.startsWith("bun")) return "bun";
9
+ if (execPath.includes("yarn")) return "yarn";
10
+ if (execPath.includes("pnpm")) return "pnpm";
11
+ if (execPath.includes("bun")) return "bun";
12
+ if (argv0.includes("yarn")) return "yarn";
13
+ if (argv0.includes("pnpm")) return "pnpm";
14
+ if (argv0.includes("bun")) return "bun";
15
+
16
+ return "npm";
17
+ }
@@ -0,0 +1,10 @@
1
+ import { execaSync } from "execa";
2
+
3
+ export function isYarnV1() {
4
+ try {
5
+ const { stdout } = execaSync("yarn", ["-v"]);
6
+ return stdout.trim().startsWith("1.");
7
+ } catch {
8
+ return false;
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import ReactDOM from "react-dom/client";
3
+ import App from "./App";
4
+ import "./styles/globals.css";
5
+
6
+ ReactDOM.createRoot(document.getElementById("root")).render(
7
+ <React.StrictMode>
8
+ <App />
9
+ </React.StrictMode>
10
+ );
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import ReactDOM from "react-dom/client";
3
+ import App from "./App";
4
+ import "./styles/globals.css";
5
+
6
+ ReactDOM.createRoot(document.getElementById("root")).render(
7
+ <React.StrictMode>
8
+ <App />
9
+ </React.StrictMode>
10
+ );
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { MainLayout } from "@/layouts/MainLayout";
3
+ import { HomePage } from "@/pages/Home/Home";
4
+
5
+ export default function App() {
6
+ return (
7
+ <MainLayout>
8
+ <HomePage />
9
+ </MainLayout>
10
+ );
11
+ }
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { MainLayout } from "@/layouts/MainLayout";
3
+ import { HomePage } from "@/pages/Home/Home";
4
+
5
+ export default function App() {
6
+ return (
7
+ <MainLayout>
8
+ <HomePage />
9
+ </MainLayout>
10
+ );
11
+ }
@@ -0,0 +1,30 @@
1
+ import React from "react";
2
+
3
+ export function Button({
4
+ variant = "primary",
5
+ children,
6
+ className,
7
+ ...props
8
+ }) {
9
+ const styles = {
10
+ primary: { backgroundColor: "#2563eb", color: "white" },
11
+ secondary: { backgroundColor: "#e5e7eb", color: "#1f2937" },
12
+ };
13
+
14
+ return (
15
+ <button
16
+ style={{
17
+ padding: "8px 16px",
18
+ borderRadius: "8px",
19
+ fontWeight: 500,
20
+ border: "none",
21
+ cursor: "pointer",
22
+ ...styles[variant],
23
+ }}
24
+ className={className}
25
+ {...props}
26
+ >
27
+ {children}
28
+ </button>
29
+ );
30
+ }
@@ -0,0 +1,35 @@
1
+ import React from "react";
2
+
3
+ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
4
+ variant?: "primary" | "secondary";
5
+ children: React.ReactNode;
6
+ }
7
+
8
+ export function Button({
9
+ variant = "primary",
10
+ children,
11
+ className,
12
+ ...props
13
+ }: ButtonProps) {
14
+ const styles = {
15
+ primary: { backgroundColor: "#2563eb", color: "white" },
16
+ secondary: { backgroundColor: "#e5e7eb", color: "#1f2937" },
17
+ };
18
+
19
+ return (
20
+ <button
21
+ style={{
22
+ padding: "8px 16px",
23
+ borderRadius: "8px",
24
+ fontWeight: 500,
25
+ border: "none",
26
+ cursor: "pointer",
27
+ ...styles[variant],
28
+ }}
29
+ className={className}
30
+ {...props}
31
+ >
32
+ {children}
33
+ </button>
34
+ );
35
+ }
@@ -0,0 +1 @@
1
+ export { Button } from "./Button";
@@ -0,0 +1 @@
1
+ export { Button } from "./Button";
@@ -0,0 +1,2 @@
1
+ export const APP_NAME = "Lumen";
2
+ export const API_BASE_URL = import.meta.env.VITE_API_URL || "http://localhost:3000";
@@ -0,0 +1,2 @@
1
+ export const APP_NAME = "Lumen";
2
+ export const API_BASE_URL = import.meta.env.VITE_API_URL || "http://localhost:3000";
@@ -0,0 +1,7 @@
1
+ export const ROUTES = {
2
+ HOME: "/",
3
+ ABOUT: "/about",
4
+ LOGIN: "/login",
5
+ DASHBOARD: "/dashboard",
6
+ SETTINGS: "/settings",
7
+ };
@@ -0,0 +1,7 @@
1
+ export const ROUTES = {
2
+ HOME: "/",
3
+ ABOUT: "/about",
4
+ LOGIN: "/login",
5
+ DASHBOARD: "/dashboard",
6
+ SETTINGS: "/settings",
7
+ };
@@ -0,0 +1,13 @@
1
+ import React, { createContext, useState } from "react";
2
+
3
+ export const AppContext = createContext(null);
4
+
5
+ export function AppProvider({ children }) {
6
+ const [theme, setTheme] = useState("light");
7
+
8
+ return (
9
+ <AppContext.Provider value={{ theme, setTheme }}>
10
+ {children}
11
+ </AppContext.Provider>
12
+ );
13
+ }
@@ -0,0 +1,13 @@
1
+ import React, { createContext, useState, useEffect } from "react";
2
+
3
+ export const AppContext = createContext(null);
4
+
5
+ export function AppProvider({ children }) {
6
+ const [theme, setTheme] = useState("light");
7
+
8
+ return (
9
+ <AppContext.Provider value={{ theme, setTheme }}>
10
+ {children}
11
+ </AppContext.Provider>
12
+ );
13
+ }
@@ -0,0 +1 @@
1
+ export { useLocalStorage } from "./useLocalStorage";
@@ -0,0 +1 @@
1
+ export { useLocalStorage } from "./useLocalStorage";
@@ -0,0 +1,28 @@
1
+ import { useState, useCallback } from "react";
2
+
3
+ export function useLocalStorage(key, initialValue) {
4
+ const [storedValue, setStoredValue] = useState(() => {
5
+ try {
6
+ const item = window.localStorage.getItem(key);
7
+ return item ? JSON.parse(item) : initialValue;
8
+ } catch {
9
+ return initialValue;
10
+ }
11
+ });
12
+
13
+ const setValue = useCallback(
14
+ (value) => {
15
+ try {
16
+ const valueToStore =
17
+ value instanceof Function ? value(storedValue) : value;
18
+ setStoredValue(valueToStore);
19
+ window.localStorage.setItem(key, JSON.stringify(valueToStore));
20
+ } catch (error) {
21
+ console.error(error);
22
+ }
23
+ },
24
+ [key, storedValue]
25
+ );
26
+
27
+ return [storedValue, setValue];
28
+ }
@@ -0,0 +1,28 @@
1
+ import { useState, useCallback } from "react";
2
+
3
+ export function useLocalStorage(key, initialValue) {
4
+ const [storedValue, setStoredValue] = useState(() => {
5
+ try {
6
+ const item = window.localStorage.getItem(key);
7
+ return item ? JSON.parse(item) : initialValue;
8
+ } catch {
9
+ return initialValue;
10
+ }
11
+ });
12
+
13
+ const setValue = useCallback(
14
+ (value) => {
15
+ try {
16
+ const valueToStore =
17
+ value instanceof Function ? value(storedValue) : value;
18
+ setStoredValue(valueToStore);
19
+ window.localStorage.setItem(key, JSON.stringify(valueToStore));
20
+ } catch (error) {
21
+ console.error(error);
22
+ }
23
+ },
24
+ [key, storedValue]
25
+ );
26
+
27
+ return [storedValue, setValue];
28
+ }
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+
3
+ export function MainLayout({ children }) {
4
+ return (
5
+ <div style={{ minHeight: "100vh", display: "flex", flexDirection: "column" }}>
6
+ <header
7
+ style={{
8
+ padding: "16px 24px",
9
+ borderBottom: "1px solid #e5e7eb",
10
+ }}
11
+ >
12
+ <h2 style={{ fontSize: "1.25rem", fontWeight: 600 }}>Lumen</h2>
13
+ </header>
14
+ <main style={{ flex: 1, padding: "24px", display: "flex", alignItems: "center", justifyContent: "center" }}>
15
+ {children}
16
+ </main>
17
+ <footer
18
+ style={{
19
+ padding: "16px 24px",
20
+ borderTop: "1px solid #e5e7eb",
21
+ textAlign: "center",
22
+ color: "#6b7280",
23
+ }}
24
+ >
25
+ <p>Built with Lumen</p>
26
+ </footer>
27
+ </div>
28
+ );
29
+ }
@@ -0,0 +1,33 @@
1
+ import React from "react";
2
+
3
+ interface MainLayoutProps {
4
+ children: React.ReactNode;
5
+ }
6
+
7
+ export function MainLayout({ children }: MainLayoutProps) {
8
+ return (
9
+ <div style={{ minHeight: "100vh", display: "flex", flexDirection: "column" }}>
10
+ <header
11
+ style={{
12
+ padding: "16px 24px",
13
+ borderBottom: "1px solid #e5e7eb",
14
+ }}
15
+ >
16
+ <h2 style={{ fontSize: "1.25rem", fontWeight: 600 }}>Lumen</h2>
17
+ </header>
18
+ <main style={{ flex: 1, padding: "24px", display: "flex", alignItems: "center", justifyContent: "center" }}>
19
+ {children}
20
+ </main>
21
+ <footer
22
+ style={{
23
+ padding: "16px 24px",
24
+ borderTop: "1px solid #e5e7eb",
25
+ textAlign: "center",
26
+ color: "#6b7280",
27
+ }}
28
+ >
29
+ <p>Built with Lumen</p>
30
+ </footer>
31
+ </div>
32
+ );
33
+ }
@@ -0,0 +1 @@
1
+ export { MainLayout } from "./MainLayout";
@@ -0,0 +1 @@
1
+ export { MainLayout } from "./MainLayout";