@shivasankaran18/stackd 1.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.
Files changed (109) hide show
  1. package/.github/workflows/ci.yml +30 -0
  2. package/LICENSE +21 -0
  3. package/README.md +115 -0
  4. package/apps/cli/package.json +32 -0
  5. package/apps/cli/src/cli.ts +271 -0
  6. package/apps/cli/src/commands/create.ts +162 -0
  7. package/apps/cli/src/scripts/Auth/jwt.ts +83 -0
  8. package/apps/cli/src/scripts/Auth/nextAuth.ts +146 -0
  9. package/apps/cli/src/scripts/Auth/passport.ts +234 -0
  10. package/apps/cli/src/scripts/backend/django.ts +30 -0
  11. package/apps/cli/src/scripts/backend/expressjs.ts +72 -0
  12. package/apps/cli/src/scripts/backend/expressts.ts +95 -0
  13. package/apps/cli/src/scripts/frontend/angularjs.ts +0 -0
  14. package/apps/cli/src/scripts/frontend/angularts.ts +29 -0
  15. package/apps/cli/src/scripts/frontend/nextjs.ts +72 -0
  16. package/apps/cli/src/scripts/frontend/reactjs.ts +36 -0
  17. package/apps/cli/src/scripts/frontend/reactts.ts +34 -0
  18. package/apps/cli/src/scripts/frontend/vuejs.ts +43 -0
  19. package/apps/cli/src/scripts/frontend/vuets.ts +53 -0
  20. package/apps/cli/src/scripts/orms/drizzleSetup.ts +102 -0
  21. package/apps/cli/src/scripts/orms/mongoSetup.ts +68 -0
  22. package/apps/cli/src/scripts/orms/prismaSetup.ts +14 -0
  23. package/apps/cli/src/scripts/ui/shadcn.ts +228 -0
  24. package/apps/cli/src/scripts/ui/tailwindcss.ts +126 -0
  25. package/apps/cli/tsconfig.json +111 -0
  26. package/apps/web/app/api/auth/[...nextauth]/route.ts +7 -0
  27. package/apps/web/app/api/scaffold/route.ts +274 -0
  28. package/apps/web/app/favicon.ico +0 -0
  29. package/apps/web/app/fonts/GeistMonoVF.woff +0 -0
  30. package/apps/web/app/fonts/GeistVF.woff +0 -0
  31. package/apps/web/app/globals.css +158 -0
  32. package/apps/web/app/home/page.tsx +22 -0
  33. package/apps/web/app/layout.tsx +35 -0
  34. package/apps/web/app/page.module.css +188 -0
  35. package/apps/web/app/page.tsx +1 -0
  36. package/apps/web/app/providers.tsx +9 -0
  37. package/apps/web/app/scaffold/page.tsx +472 -0
  38. package/apps/web/components/Sidebar.tsx +108 -0
  39. package/apps/web/components/theme-provider.tsx +9 -0
  40. package/apps/web/components/ui/button.tsx +57 -0
  41. package/apps/web/components/ui/card.tsx +76 -0
  42. package/apps/web/components/ui/dropdown-menu.tsx +200 -0
  43. package/apps/web/components/ui/input.tsx +22 -0
  44. package/apps/web/components/ui/label.tsx +26 -0
  45. package/apps/web/components/ui/scroll-area.tsx +48 -0
  46. package/apps/web/components/ui/sonner.tsx +31 -0
  47. package/apps/web/components/ui/steps.tsx +36 -0
  48. package/apps/web/components/ui/switch.tsx +29 -0
  49. package/apps/web/components.json +21 -0
  50. package/apps/web/eslint.config.js +4 -0
  51. package/apps/web/lib/auth.ts +35 -0
  52. package/apps/web/lib/redis.ts +13 -0
  53. package/apps/web/lib/utils.ts +8 -0
  54. package/apps/web/next-env.d.ts +5 -0
  55. package/apps/web/next.config.js +4 -0
  56. package/apps/web/package.json +52 -0
  57. package/apps/web/postcss.config.js +6 -0
  58. package/apps/web/public/file-text.svg +3 -0
  59. package/apps/web/public/globe.svg +10 -0
  60. package/apps/web/public/next.svg +1 -0
  61. package/apps/web/public/turborepo-dark.svg +19 -0
  62. package/apps/web/public/turborepo-light.svg +19 -0
  63. package/apps/web/public/vercel.svg +10 -0
  64. package/apps/web/public/window.svg +3 -0
  65. package/apps/web/tailwind.config.js +65 -0
  66. package/apps/web/tsconfig.json +23 -0
  67. package/apps/web/types/global.d.ts +4 -0
  68. package/docker-compose.yml +14 -0
  69. package/package.json +55 -0
  70. package/packages/eslint-config/README.md +3 -0
  71. package/packages/eslint-config/base.js +32 -0
  72. package/packages/eslint-config/next.js +49 -0
  73. package/packages/eslint-config/package.json +24 -0
  74. package/packages/eslint-config/react-internal.js +39 -0
  75. package/packages/scripts/Auth/jwt.ts +83 -0
  76. package/packages/scripts/Auth/nextAuth.ts +146 -0
  77. package/packages/scripts/Auth/passport.ts +234 -0
  78. package/packages/scripts/backend/django.ts +30 -0
  79. package/packages/scripts/backend/expressjs.ts +72 -0
  80. package/packages/scripts/backend/expressts.ts +95 -0
  81. package/packages/scripts/frontend/angularjs.ts +0 -0
  82. package/packages/scripts/frontend/angularts.ts +29 -0
  83. package/packages/scripts/frontend/nextjs.ts +72 -0
  84. package/packages/scripts/frontend/reactjs.ts +36 -0
  85. package/packages/scripts/frontend/reactts.ts +34 -0
  86. package/packages/scripts/frontend/vuejs.ts +43 -0
  87. package/packages/scripts/frontend/vuets.ts +53 -0
  88. package/packages/scripts/orms/drizzleSetup.ts +102 -0
  89. package/packages/scripts/orms/mongoSetup.ts +68 -0
  90. package/packages/scripts/orms/prismaSetup.ts +14 -0
  91. package/packages/scripts/ui/shadcn.ts +228 -0
  92. package/packages/scripts/ui/tailwindcss.ts +126 -0
  93. package/packages/typescript-config/base.json +19 -0
  94. package/packages/typescript-config/nextjs.json +12 -0
  95. package/packages/typescript-config/package.json +9 -0
  96. package/packages/typescript-config/react-library.json +7 -0
  97. package/packages/ui/eslint.config.mjs +4 -0
  98. package/packages/ui/package.json +27 -0
  99. package/packages/ui/src/button.tsx +20 -0
  100. package/packages/ui/src/card.tsx +27 -0
  101. package/packages/ui/src/code.tsx +11 -0
  102. package/packages/ui/tsconfig.json +8 -0
  103. package/packages/ui/turbo/generators/config.ts +30 -0
  104. package/packages/ui/turbo/generators/templates/component.hbs +8 -0
  105. package/stackd.ts +134 -0
  106. package/start-web.sh +5 -0
  107. package/tsconfig.json +111 -0
  108. package/tsconfig.tsbuildinfo +1 -0
  109. package/turbo.json +21 -0
@@ -0,0 +1,126 @@
1
+ import { writeFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { execSync } from 'child_process';
4
+ import { existsSync } from 'fs';
5
+ import { mkdir } from 'fs/promises';
6
+
7
+ export async function setupTailwindCSS(
8
+ config: any,
9
+ projectDir: string,
10
+ emitLog: (log: string) => void
11
+ ) {
12
+ try {
13
+ const frontendDir = join(projectDir, 'frontend');
14
+ const srcDir = join(frontendDir, 'src');
15
+
16
+ // Ensure directories exist
17
+ if (!existsSync(frontendDir)) {
18
+ emitLog('Creating frontend directory...');
19
+ await mkdir(frontendDir, { recursive: true });
20
+ }
21
+
22
+ if (!existsSync(srcDir)) {
23
+ emitLog('Creating src directory...');
24
+ await mkdir(srcDir, { recursive: true });
25
+ }
26
+
27
+ // Initialize package.json if it doesn't exist
28
+ if (!existsSync(join(frontendDir, 'package.json'))) {
29
+ emitLog('Initializing package.json...');
30
+ execSync('npm init -y', {
31
+ cwd: frontendDir,
32
+ stdio: 'inherit'
33
+ });
34
+ }
35
+
36
+ // Install dependencies using npm directly
37
+ emitLog('Installing Tailwind CSS dependencies...');
38
+ execSync('npm install tailwindcss@latest postcss@latest autoprefixer@latest --save-dev', {
39
+ cwd: frontendDir,
40
+ stdio: 'inherit'
41
+ });
42
+
43
+ // Create tailwind.config.js manually instead of using npx
44
+ emitLog('Creating Tailwind configuration...');
45
+ const tailwindConfig = generateTailwindConfig(config.frontend);
46
+ await writeFile(
47
+ join(frontendDir, 'tailwind.config.js'),
48
+ tailwindConfig
49
+ );
50
+
51
+ // Create postcss.config.js
52
+ emitLog('Creating PostCSS configuration...');
53
+ const postcssConfig = `
54
+ module.exports = {
55
+ plugins: {
56
+ tailwindcss: {},
57
+ autoprefixer: {},
58
+ },
59
+ }`;
60
+ await writeFile(
61
+ join(frontendDir, 'postcss.config.js'),
62
+ postcssConfig
63
+ );
64
+
65
+ // Add Tailwind directives to CSS
66
+ emitLog('Creating CSS file with Tailwind directives...');
67
+ const tailwindDirectives = `
68
+ @tailwind base;
69
+ @tailwind components;
70
+ @tailwind utilities;
71
+ `;
72
+ await writeFile(
73
+ join(srcDir, 'index.css'),
74
+ tailwindDirectives
75
+ );
76
+
77
+ emitLog('✅ Tailwind CSS setup completed successfully!');
78
+ } catch (error) {
79
+ emitLog(`❌ Error setting up Tailwind CSS: ${error instanceof Error ? error.message : 'Unknown error'}`);
80
+ throw error;
81
+ }
82
+ }
83
+
84
+ function generateTailwindConfig(framework: string): string {
85
+ const baseConfig = {
86
+ content: [
87
+ "./index.html",
88
+ "./src/**/*.{js,ts,jsx,tsx}",
89
+ ],
90
+ theme: {
91
+ extend: {
92
+ colors: {
93
+ background: 'hsl(var(--background))',
94
+ foreground: 'hsl(var(--foreground))',
95
+ },
96
+ },
97
+ },
98
+ plugins: [],
99
+ };
100
+
101
+ switch (framework) {
102
+ case 'react-ts':
103
+ case 'react':
104
+ baseConfig.content = [
105
+ "./index.html",
106
+ "./src/**/*.{js,ts,jsx,tsx}",
107
+ ];
108
+ break;
109
+ case 'vue-ts':
110
+ case 'vue':
111
+ baseConfig.content = [
112
+ "./index.html",
113
+ "./src/**/*.{vue,js,ts,jsx,tsx}",
114
+ ];
115
+ break;
116
+ case 'django':
117
+ baseConfig.content = [
118
+ "./templates/**/*.html",
119
+ "./static/**/*.{js,ts}",
120
+ ];
121
+ break;
122
+ }
123
+
124
+ return `/** @type {import('tailwindcss').Config} */
125
+ module.exports = ${JSON.stringify(baseConfig, null, 2)}`;
126
+ }
@@ -0,0 +1,111 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
17
+ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
18
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
+
27
+ /* Modules */
28
+ "module": "ESNext", /* Specify what module code is generated. */
29
+ // "rootDir": "./", /* Specify the root folder within your source files. */
30
+ "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
31
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
+ // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
39
+ // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
40
+ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
41
+ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
42
+ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
43
+ // "noUncheckedSideEffectImports": true, /* Check side effect imports. */
44
+ // "resolveJsonModule": true, /* Enable importing .json files. */
45
+ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
46
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
47
+
48
+ /* JavaScript Support */
49
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
50
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
51
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
52
+
53
+ /* Emit */
54
+ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
55
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
56
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
57
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
58
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
59
+ // "noEmit": true, /* Disable emitting files from a compilation. */
60
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
61
+ // "outDir": "./", /* Specify an output folder for all emitted files. */
62
+ // "removeComments": true, /* Disable emitting comments. */
63
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
64
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
65
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
66
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
67
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
68
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
69
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
70
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
71
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
72
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
73
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
74
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
75
+
76
+ /* Interop Constraints */
77
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
78
+ // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
79
+ // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
80
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
81
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
82
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
83
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
84
+
85
+ /* Type Checking */
86
+ "strict": true, /* Enable all strict type-checking options. */
87
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
88
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
89
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
90
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
91
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
92
+ // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
93
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
94
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
95
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
96
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
97
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
98
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
99
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
100
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
101
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
102
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
103
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
104
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
105
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
106
+
107
+ /* Completeness */
108
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
109
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
110
+ }
111
+ }
@@ -0,0 +1,7 @@
1
+ import NextAuth from "next-auth"
2
+ import { authOptions } from "../../../../lib/auth"
3
+
4
+ //@ts-ignore
5
+ const handler = NextAuth(authOptions)
6
+
7
+ export { handler as GET, handler as POST }
@@ -0,0 +1,274 @@
1
+ import { NextRequest, NextResponse } from 'next/server'
2
+ import { mkdir } from 'node:fs/promises'
3
+ import { join } from 'node:path'
4
+ import { createReactTS } from '../../../../../packages/scripts/frontend/reactts'
5
+ import { createReactJS } from '../../../../../packages/scripts/frontend/reactjs'
6
+ import { createExpressTS } from '../../../../../packages/scripts/backend/expressts'
7
+ import { createExpressJS } from '../../../../../packages/scripts/backend/expressjs'
8
+ import { setupPrisma } from '../../../../../packages/scripts/orms/prismaSetup'
9
+ import { createVueJS } from '../../../../../packages/scripts/frontend/vuejs'
10
+ // import { createNextJS } from '../../../../../packages/scripts/frontend/nextjs'
11
+ import { createVueTS } from '../../../../../packages/scripts/frontend/vuets'
12
+ import { jwtAuthts , jwtAuthdjango} from '../../../../../packages/scripts/Auth/jwt'
13
+ import path from 'path'
14
+ import fs from 'fs/promises'
15
+ import { installDjangoDependencies } from '../../../../../packages/scripts/backend/django'
16
+ import createAngularTS from '../../../../../packages/scripts/frontend/angularts'
17
+ import { setupNextAuth } from '../../../../../packages/scripts/Auth/nextAuth'
18
+ import { setupPassport } from '../../../../../packages/scripts/Auth/passport'
19
+ import { setupMongoose } from '../../../../../packages/scripts/orms/mongoSetup'
20
+ import { setupDrizzle } from '../../../../../packages/scripts/orms/drizzleSetup'
21
+ import { setupTailwindCSS } from '../../../../../packages/scripts/ui/tailwindcss'
22
+ import { setupShadcn } from '../../../../../packages/scripts/ui/shadcn'
23
+ import simpleGit from 'simple-git'
24
+
25
+
26
+
27
+
28
+ const encoder = new TextEncoder();
29
+
30
+ export async function POST(req: NextRequest) {
31
+ try {
32
+ const config = await req.json()
33
+
34
+ console.log(config)
35
+ const projectDir = join(config.projectPath, config.projectName)
36
+ await mkdir(projectDir, { recursive: true })
37
+ const git = simpleGit(projectDir);
38
+ git.init()
39
+ .then(() => console.log('Initialized a new Git repository'))
40
+ .catch(err => console.error('Error:', err));
41
+
42
+ if(config.giturl) {
43
+ await git.remote(['add', 'origin', config.giturl]).then(() => console.log('Remote added')).catch(err => console.error('Error:', err));
44
+ }
45
+ const emitLog = (message: string) => {
46
+ console.log(`[Emit Logs]: ${message}`);
47
+ global.logs = global.logs || [];
48
+ global.logs.push(message);
49
+ };
50
+
51
+ switch(config.frontend) {
52
+ case 'react-ts':
53
+ await createReactTS(config, projectDir,emitLog)
54
+ break
55
+ case 'react':
56
+ await createReactJS(config, projectDir,emitLog)
57
+ break
58
+ // case 'nextjs':
59
+ // await createNextJS(config, projectDir, emitLog);
60
+ // break;
61
+ case 'django':
62
+ await installDjangoDependencies(projectDir);
63
+ break;
64
+ case 'vue':
65
+ await createVueJS(config, projectDir,emitLog)
66
+ break
67
+ case 'vue-ts':
68
+ await createVueTS(config, projectDir,emitLog)
69
+ break
70
+ case 'angularts':
71
+ await createAngularTS(config, projectDir)
72
+ break
73
+ default:
74
+ throw new Error(`Unsupported frontend`)
75
+ }
76
+
77
+ switch(config.backend) {
78
+ case 'express-ts':
79
+ await createExpressTS(config, projectDir,emitLog)
80
+ break
81
+ case 'express':
82
+ console.log("Creating the backend")
83
+ await createExpressJS(config, projectDir,emitLog)
84
+ break
85
+ case 'django':
86
+ await installDjangoDependencies(projectDir);
87
+ break
88
+ // case 'nextjs':
89
+ // await createNextJS(config, projectDir, emitLog);
90
+ // break;
91
+ default:
92
+ throw new Error(`Unsupported backend`)
93
+ }
94
+
95
+ switch(config.auth) {
96
+ case 'jwt':
97
+ await jwtAuthts(config, projectDir,emitLog);
98
+ break
99
+ case 'nextauth':
100
+ await setupNextAuth(config, projectDir,emitLog);
101
+ break
102
+ case 'passport':
103
+ await setupPassport(config, projectDir,emitLog);
104
+ break
105
+ default:
106
+ throw new Error(`Unsupported auth`)
107
+ }
108
+ switch(config.orm) {
109
+ case 'drizzle':
110
+ await setupDrizzle(config, projectDir,emitLog);
111
+ break
112
+ case 'prisma':
113
+ await setupPrisma(config, projectDir,emitLog);
114
+ break
115
+ case 'mongoose':
116
+ await setupMongoose(config, projectDir,emitLog);
117
+ break
118
+ default:
119
+ throw new Error(`Unsupported orm`)
120
+ }
121
+ const gitignore = `
122
+ # Dependencies
123
+ node_modules
124
+ .pnp
125
+ .pnp.js
126
+
127
+ # Production
128
+ dist
129
+ build
130
+
131
+ # Environment
132
+ .env
133
+ .env.local
134
+ .env.development.local
135
+ .env.test.local
136
+ .env.production.local
137
+
138
+ # Logs
139
+ npm-debug.log*
140
+ yarn-debug.log*
141
+ yarn-error.log*
142
+
143
+ # Editor
144
+ .vscode
145
+ .idea
146
+ *.swp
147
+ *.swo
148
+
149
+ # OS
150
+ .DS_Store
151
+ Thumbs.db
152
+ `
153
+ switch (config.backend) {
154
+ case 'express-ts':
155
+ await jwtAuthts(config, projectDir,emitLog);
156
+ break;
157
+ case 'express':
158
+ await jwtAuthts(config,projectDir,emitLog);
159
+ break;
160
+ case 'django':
161
+ await jwtAuthdjango(config, projectDir,emitLog);
162
+ break;
163
+ default:
164
+ break;
165
+ }
166
+ switch(config.ui) {
167
+ case 'tailwind':
168
+ await setupTailwindCSS(config, projectDir,emitLog);
169
+ break;
170
+ case 'shadcn':
171
+ await setupTailwindCSS(config, projectDir,emitLog);
172
+ await setupShadcn(config, projectDir,emitLog);
173
+ break;
174
+ default:
175
+ break;
176
+ }
177
+ return NextResponse.json({
178
+ success: true,
179
+ projectPath: projectDir,
180
+ instructions: {
181
+ setup: [
182
+ `cd ${projectDir}`,
183
+ 'npm install',
184
+ 'npm run install:all',
185
+ 'npm run dev'
186
+ ]
187
+ }
188
+ })
189
+
190
+ } catch (error) {
191
+ console.error('Error:', error)
192
+ return NextResponse.json(
193
+ {
194
+ error: 'Failed to generate project',
195
+ details: error instanceof Error ? error.message : 'Unknown error'
196
+ },
197
+ { status: 500 }
198
+ )
199
+ }
200
+ }
201
+
202
+ export async function GET() {
203
+ const stream = new ReadableStream({
204
+ start(controller) {
205
+ const interval = setInterval(() => {
206
+ if (global.logs?.length) {
207
+ const log = global.logs.shift();
208
+ const data = `data: ${log}\n\n`;
209
+ controller.enqueue(encoder.encode(data));
210
+ }
211
+ }, 100);
212
+
213
+ return () => clearInterval(interval);
214
+ },
215
+ });
216
+
217
+ return new Response(stream, {
218
+ headers: {
219
+ 'Content-Type': 'text/event-stream',
220
+ 'Cache-Control': 'no-cache',
221
+ 'Connection': 'keep-alive',
222
+ },
223
+ });
224
+ }
225
+
226
+ async function configureDjangoFiles(projectPath: string) {
227
+
228
+ const settingsPath = path.join(projectPath, 'core', 'settings.py');
229
+ const urlsPath = path.join(projectPath, 'core', 'urls.py');
230
+
231
+ try {
232
+
233
+ let settingsContent = await fs.readFile(settingsPath, 'utf8');
234
+ const restFrameworkSettings = `
235
+
236
+ REST_FRAMEWORK = {
237
+ 'DEFAULT_AUTHENTICATION_CLASSES': [
238
+ 'rest_framework_simplejwt.authentication.JWTAuthentication',
239
+ ],
240
+ }
241
+ `;
242
+ const installedAppsIndex = settingsContent.indexOf('INSTALLED_APPS');
243
+ const insertPosition = settingsContent.indexOf(']', installedAppsIndex) + 1;
244
+ settingsContent =
245
+ settingsContent.slice(0, insertPosition) +
246
+ restFrameworkSettings +
247
+ settingsContent.slice(insertPosition);
248
+
249
+ await fs.writeFile(settingsPath, settingsContent, 'utf8');
250
+
251
+ let urlsContent = await fs.readFile(urlsPath, 'utf8');
252
+ const newUrlsContent = `from django.contrib import admin
253
+ from django.urls import path, include
254
+ from rest_framework_simplejwt import views as jwt_views
255
+
256
+ urlpatterns = [
257
+ path('admin/', admin.site.urls),
258
+ path('api/token/',
259
+ jwt_views.TokenObtainPairView.as_view(),
260
+ name='token_obtain_pair'),
261
+ path('api/token/refresh/',
262
+ jwt_views.TokenRefreshView.as_view(),
263
+ name='token_refresh'),
264
+ path('', include('main.urls')),
265
+ ]
266
+ `;
267
+ await fs.writeFile(urlsPath, newUrlsContent, 'utf8');
268
+
269
+ } catch (error) {
270
+ console.error('Error configuring Django files:', error);
271
+ throw error;
272
+ }
273
+ }
274
+
Binary file
Binary file