create-lego-one 2.0.12 → 2.0.13

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 (78) hide show
  1. package/dist/index.cjs +34 -0
  2. package/dist/index.cjs.map +1 -1
  3. package/package.json +1 -1
  4. package/template/.cursor/rules/rules.mdc +639 -0
  5. package/template/.dockerignore +58 -0
  6. package/template/.env.example +18 -0
  7. package/template/.eslintignore +5 -0
  8. package/template/.eslintrc.js +28 -0
  9. package/template/.prettierignore +6 -0
  10. package/template/.prettierrc +11 -0
  11. package/template/CLAUDE.md +634 -0
  12. package/template/Dockerfile +67 -0
  13. package/template/PROMPT.md +457 -0
  14. package/template/README.md +325 -0
  15. package/template/docker-compose.yml +48 -0
  16. package/template/docker-entrypoint.sh +23 -0
  17. package/template/docs/checkpoints/.template.md +64 -0
  18. package/template/docs/checkpoints/framework/01-infrastructure-setup.md +132 -0
  19. package/template/docs/checkpoints/framework/02-pocketbase-setup.md +155 -0
  20. package/template/docs/checkpoints/framework/03-host-kernel.md +170 -0
  21. package/template/docs/checkpoints/framework/04-auth-system.md +163 -0
  22. package/template/docs/checkpoints/framework/phase-05-multitenancy-rbac.md +223 -0
  23. package/template/docs/checkpoints/framework/phase-06-ui-components.md +260 -0
  24. package/template/docs/checkpoints/framework/phase-07-communication-system.md +276 -0
  25. package/template/docs/checkpoints/framework/phase-08-plugin-system.md +91 -0
  26. package/template/docs/checkpoints/framework/phase-09-dashboard-plugin.md +111 -0
  27. package/template/docs/checkpoints/framework/phase-10-todo-plugin.md +169 -0
  28. package/template/docs/checkpoints/framework/phase-11-testing.md +264 -0
  29. package/template/docs/checkpoints/framework/phase-12-deployment.md +294 -0
  30. package/template/docs/checkpoints/framework/phase-13-documentation.md +312 -0
  31. package/template/docs/framework/plans/00-index.md +164 -0
  32. package/template/docs/framework/plans/01-infrastructure-setup.md +855 -0
  33. package/template/docs/framework/plans/02-pocketbase-setup.md +1374 -0
  34. package/template/docs/framework/plans/03-host-kernel.md +1518 -0
  35. package/template/docs/framework/plans/04-auth-system.md +1466 -0
  36. package/template/docs/framework/plans/05-multitenancy-rbac.md +1527 -0
  37. package/template/docs/framework/plans/06-ui-components.md +1478 -0
  38. package/template/docs/framework/plans/07-communication-system.md +1106 -0
  39. package/template/docs/framework/plans/08-plugin-system.md +1179 -0
  40. package/template/docs/framework/plans/09-dashboard-plugin.md +1137 -0
  41. package/template/docs/framework/plans/10-todo-plugin.md +1343 -0
  42. package/template/docs/framework/plans/11-testing.md +935 -0
  43. package/template/docs/framework/plans/12-deployment.md +896 -0
  44. package/template/docs/framework/prompts/0-boilerplate-modernjs.md +151 -0
  45. package/template/docs/framework/research/00-modernjs-audit.md +488 -0
  46. package/template/docs/framework/research/01-system-blueprint.md +721 -0
  47. package/template/docs/framework/research/02-data-migration-protocol.md +699 -0
  48. package/template/docs/framework/research/03-host-setup.md +714 -0
  49. package/template/docs/framework/research/04-plugin-architecture.md +645 -0
  50. package/template/docs/framework/research/05-slot-injection-pattern.md +671 -0
  51. package/template/docs/framework/research/06-cli-strategy.md +615 -0
  52. package/template/docs/framework/research/07-deployment.md +629 -0
  53. package/template/docs/framework/research/README.md +282 -0
  54. package/template/docs/framework/setup/00-index.md +210 -0
  55. package/template/docs/framework/setup/01-framework-structure.md +308 -0
  56. package/template/docs/framework/setup/02-development-workflow.md +405 -0
  57. package/template/docs/framework/setup/03-environment-setup.md +215 -0
  58. package/template/docs/framework/setup/04-kernel-architecture.md +499 -0
  59. package/template/docs/framework/setup/05-plugin-system.md +620 -0
  60. package/template/docs/framework/setup/06-communication-patterns.md +451 -0
  61. package/template/docs/framework/setup/07-plugin-development.md +582 -0
  62. package/template/docs/framework/setup/08-component-library.md +658 -0
  63. package/template/docs/framework/setup/09-data-integration.md +609 -0
  64. package/template/docs/framework/setup/10-auth-rbac.md +497 -0
  65. package/template/docs/framework/setup/11-hooks-api.md +393 -0
  66. package/template/docs/framework/setup/12-components-api.md +665 -0
  67. package/template/docs/framework/setup/13-deployment-guide.md +566 -0
  68. package/template/docs/framework/setup/README.md +548 -0
  69. package/template/host/package.json +1 -1
  70. package/template/nginx.conf +72 -0
  71. package/template/package.json +1 -1
  72. package/template/packages/plugins/@lego/plugin-dashboard/package.json +1 -1
  73. package/template/packages/plugins/@lego/plugin-todo/package.json +1 -1
  74. package/template/pocketbase/CHANGELOG.md +911 -0
  75. package/template/pocketbase/LICENSE.md +17 -0
  76. package/template/scripts/create-plugin.js +221 -0
  77. package/template/scripts/deploy.sh +56 -0
  78. package/template/tsconfig.base.json +26 -0
@@ -0,0 +1,17 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) 2022 - present, Gani Georgiev
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software
5
+ and associated documentation files (the "Software"), to deal in the Software without restriction,
6
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
7
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
8
+ is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or
11
+ substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
14
+ BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,221 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const args = process.argv.slice(2);
7
+
8
+ if (args.length === 0) {
9
+ console.error('Usage: node scripts/create-plugin.js <plugin-name>');
10
+ process.exit(1);
11
+ }
12
+
13
+ const pluginName = args[0].startsWith('plugin-')
14
+ ? args[0]
15
+ : `plugin-${args[0]}`;
16
+ const pluginPascal = pluginName
17
+ .split('-')
18
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
19
+ .join('');
20
+
21
+ const pluginDir = path.join(process.cwd(), 'packages/plugins/@lego', pluginName);
22
+
23
+ // Create plugin directory
24
+ fs.mkdirSync(pluginDir, { recursive: true });
25
+ fs.mkdirSync(path.join(pluginDir, 'src'));
26
+ fs.mkdirSync(path.join(pluginDir, 'src/pages'));
27
+ fs.mkdirSync(path.join(pluginDir, 'src/components'));
28
+ fs.mkdirSync(path.join(pluginDir, 'src/hooks'));
29
+ fs.mkdirSync(path.join(pluginDir, 'src/lib'));
30
+
31
+ // Create package.json
32
+ const packageJson = {
33
+ name: `@lego/${pluginName}`,
34
+ version: '1.0.0',
35
+ private: true,
36
+ type: 'module',
37
+ exports: {
38
+ '.': './src/main.tsx',
39
+ './plugin.config': './plugin.config.ts',
40
+ },
41
+ scripts: {
42
+ dev: 'modern dev',
43
+ build: 'modern build',
44
+ preview: 'modern preview',
45
+ lint: 'eslint src',
46
+ typecheck: 'tsc --noEmit',
47
+ },
48
+ dependencies: {
49
+ '@modern-js/runtime': '^2.0.0',
50
+ 'react': '^18.3.0',
51
+ 'react-dom': '^18.3.0',
52
+ },
53
+ devDependencies: {
54
+ '@modern-js/app-tools': '^2.0.0',
55
+ '@modern-js/plugin-garfish': '^2.0.0',
56
+ '@types/react': '^18.3.0',
57
+ '@types/react-dom': '^18.3.0',
58
+ typescript: '^5.3.0',
59
+ },
60
+ };
61
+
62
+ fs.writeFileSync(
63
+ path.join(pluginDir, 'package.json'),
64
+ JSON.stringify(packageJson, null, 2)
65
+ );
66
+
67
+ // Create plugin.config.ts
68
+ const pluginConfig = `import { definePluginConfig } from '@lego/kernel/plugin-config';
69
+
70
+ export default definePluginConfig({
71
+ name: '@lego/${pluginName}',
72
+ version: '1.0.0',
73
+ displayName: '${pluginPascal}',
74
+ description: 'A plugin for ${pluginName}',
75
+
76
+ slots: {
77
+ 'sidebar:nav': {
78
+ component: './src/components/SidebarLink',
79
+ order: 100,
80
+ },
81
+ },
82
+ });
83
+ `;
84
+
85
+ fs.writeFileSync(path.join(pluginDir, 'plugin.config.ts'), pluginConfig);
86
+
87
+ // Create modern.config.ts
88
+ const modernConfig = `import { appTools, defineConfig } from '@modern-js/app-tools';
89
+ import { garfishPlugin } from '@modern-js/plugin-garfish';
90
+
91
+ // Get next available port starting from 3001
92
+ const basePort = 3001 + parseInt(process.env.PLUGIN_INDEX || '0');
93
+
94
+ export default defineConfig({
95
+ dev: {
96
+ port: basePort,
97
+ },
98
+ runtime: {
99
+ router: true,
100
+ },
101
+ deploy: {
102
+ microFrontend: true,
103
+ },
104
+ plugins: [appTools(), garfishPlugin()],
105
+ source: {
106
+ alias: {
107
+ '@': './src',
108
+ },
109
+ },
110
+ });
111
+ `;
112
+
113
+ fs.writeFileSync(path.join(pluginDir, 'modern.config.ts'), modernConfig);
114
+
115
+ // Create tsconfig.json
116
+ const tsconfig = {
117
+ extends: '../../tsconfig.base.json',
118
+ compilerOptions: {
119
+ composite: true,
120
+ outDir: './dist',
121
+ rootDir: './src',
122
+ },
123
+ include: ['src'],
124
+ };
125
+
126
+ fs.writeFileSync(path.join(pluginDir, 'tsconfig.json'), JSON.stringify(tsconfig, null, 2));
127
+
128
+ // Create main App.tsx
129
+ const appTsx = `import { BrowserRouter, Routes, Route } from '@modern-js/runtime/router';
130
+
131
+ interface PluginAppProps {
132
+ basename?: string;
133
+ }
134
+
135
+ export default function PluginApp({ basename }: PluginAppProps) {
136
+ const routerBasename = basename || '/';
137
+
138
+ return (
139
+ <BrowserRouter basename={routerBasename}>
140
+ <Routes>
141
+ <Route index element={<div>TODO: Implement ${pluginPascal}</div>} />
142
+ </Routes>
143
+ </BrowserRouter>
144
+ );
145
+ }
146
+ `;
147
+
148
+ fs.writeFileSync(path.join(pluginDir, 'src/App.tsx'), appTsx);
149
+
150
+ // Create main.tsx entry point
151
+ const mainTsx = `import React from 'react';
152
+ import ReactDOM from 'react-dom/client';
153
+ import App from './App';
154
+
155
+ ReactDOM.createRoot(document.getElementById('root')!).render(
156
+ <React.StrictMode>
157
+ <App />
158
+ </React.StrictMode>
159
+ );
160
+ `;
161
+
162
+ fs.writeFileSync(path.join(pluginDir, 'src/main.tsx'), mainTsx);
163
+
164
+ // Create basic SidebarLink component
165
+ const sidebarLink = `import { Link } from '@modern-js/runtime/router';
166
+
167
+ export function SidebarLink() {
168
+ return (
169
+ <Link
170
+ to="/${pluginName.replace('plugin-', '')}"
171
+ className="flex items-center gap-2 px-3 py-2 text-sm rounded-md hover:bg-accent hover:text-accent-foreground"
172
+ >
173
+ <span>${pluginPascal}</span>
174
+ </Link>
175
+ );
176
+ }
177
+ `;
178
+
179
+ fs.writeFileSync(path.join(pluginDir, 'src/components/SidebarLink.tsx'), sidebarLink);
180
+
181
+ // Create HTML template
182
+ const html = `<!DOCTYPE html>
183
+ <html lang="en">
184
+ <head>
185
+ <meta charset="UTF-8" />
186
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
187
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
188
+ <title>${pluginPascal}</title>
189
+ </head>
190
+ <body>
191
+ <div id="root"></div>
192
+ <script type="module" src="/src/main.tsx"></script>
193
+ </body>
194
+ </html>
195
+ `;
196
+
197
+ fs.writeFileSync(path.join(pluginDir, 'src/index.html'), html);
198
+
199
+ console.log(`✅ Plugin created: packages/plugins/@lego/${pluginName}`);
200
+ console.log(``);
201
+ console.log(`Next steps:`);
202
+ console.log(` 1. cd packages/plugins/@lego/${pluginName}`);
203
+ console.log(` 2. pnpm install`);
204
+ console.log(` 3. pnpm run dev`);
205
+
206
+ // Update root tsconfig.json to include new plugin
207
+ const rootTsconfig = JSON.parse(fs.readFileSync('tsconfig.json', 'utf8'));
208
+ rootTsconfig.references.push({
209
+ path: `./packages/plugins/@lego/${pluginName}`,
210
+ });
211
+ fs.writeFileSync('tsconfig.json', JSON.stringify(rootTsconfig, null, 2));
212
+
213
+ // Update pnpm-workspace.yaml
214
+ const workspaceContent = fs.readFileSync('pnpm-workspace.yaml', 'utf8');
215
+ if (!workspaceContent.includes(pluginName)) {
216
+ const newWorkspace = workspaceContent.replace(
217
+ /(packages:\/\s*@lego\/\*)/,
218
+ `$1\n - '${pluginName}'`
219
+ );
220
+ fs.writeFileSync('pnpm-workspace.yaml', newWorkspace);
221
+ }
@@ -0,0 +1,56 @@
1
+ #!/bin/bash
2
+
3
+ # Lego-One Deployment Script
4
+ # Usage: ./scripts/deploy.sh [environment]
5
+ # environment: development, staging, production (default: production)
6
+
7
+ set -e
8
+
9
+ ENVIRONMENT=${1:-production}
10
+ APP_NAME="lego-one"
11
+ DOCKER_IMAGE="${APP_NAME}:latest"
12
+
13
+ echo "🚀 Deploying Lego-One to ${ENVIRONMENT}..."
14
+
15
+ # Load environment variables
16
+ if [ -f ".env.${ENVIRONMENT}" ]; then
17
+ echo "Loading environment variables from .env.${ENVIRONMENT}"
18
+ export $(cat ".env.${ENVIRONMENT}" | grep -v '^#' | xargs)
19
+ elif [ -f ".env" ]; then
20
+ echo "Loading environment variables from .env"
21
+ export $(cat ".env" | grep -v '^#' | xargs)
22
+ else
23
+ echo "⚠️ Warning: No .env file found"
24
+ fi
25
+
26
+ # Build Docker image
27
+ echo "Building Docker image..."
28
+ docker build -t ${DOCKER_IMAGE} .
29
+
30
+ # Tag image for environment
31
+ docker tag ${DOCKER_IMAGE} ${APP_NAME}:${ENVIRONMENT}
32
+
33
+ # Stop existing container
34
+ echo "Stopping existing containers..."
35
+ docker-compose down 2>/dev/null || true
36
+
37
+ # Start new containers
38
+ echo "Starting containers..."
39
+ docker-compose up -d
40
+
41
+ # Wait for application to be ready
42
+ echo "Waiting for application to be ready..."
43
+ sleep 10
44
+
45
+ # Run health check
46
+ echo "Running health check..."
47
+ if curl -f http://localhost > /dev/null 2>&1; then
48
+ echo "✅ Deployment successful!"
49
+ echo "Application is running at: http://localhost"
50
+ else
51
+ echo "❌ Health check failed"
52
+ docker-compose logs
53
+ exit 1
54
+ fi
55
+
56
+ echo "✨ Deployment complete!"
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "resolveJsonModule": true,
8
+ "allowJs": true,
9
+ "strict": true,
10
+ "noEmit": true,
11
+ "esModuleInterop": true,
12
+ "skipLibCheck": true,
13
+ "forceConsistentCasingInFileNames": true,
14
+ "isolatedModules": true,
15
+ "jsx": "react-jsx",
16
+ "jsxImportSource": "react",
17
+ "allowImportingTsExtensions": true,
18
+ "noUnusedLocals": true,
19
+ "noUnusedParameters": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+ "baseUrl": ".",
22
+ "paths": {
23
+ "@/*": ["./src/*"]
24
+ }
25
+ }
26
+ }