stackkit 0.3.5 → 0.3.6
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/README.md +50 -42
- package/dist/cli/add.js +122 -56
- package/dist/cli/create.d.ts +2 -0
- package/dist/cli/create.js +271 -95
- package/dist/cli/doctor.js +1 -0
- package/dist/cli/list.d.ts +1 -1
- package/dist/cli/list.js +6 -4
- package/dist/index.js +234 -191
- package/dist/lib/constants.d.ts +4 -0
- package/dist/lib/constants.js +4 -0
- package/dist/lib/discovery/module-discovery.d.ts +4 -0
- package/dist/lib/discovery/module-discovery.js +56 -0
- package/dist/lib/generation/code-generator.d.ts +11 -2
- package/dist/lib/generation/code-generator.js +42 -3
- package/dist/lib/generation/generator-utils.js +3 -1
- package/dist/lib/pm/package-manager.js +16 -13
- package/dist/lib/ui/logger.js +3 -2
- package/dist/lib/utils/path-resolver.d.ts +2 -0
- package/dist/lib/utils/path-resolver.js +8 -0
- package/dist/meta.json +8312 -0
- package/modules/auth/better-auth/files/{shared → express}/config/env.ts +48 -50
- package/modules/auth/better-auth/files/express/middlewares/authorize.ts +20 -1
- package/modules/auth/better-auth/files/express/modules/auth.controller.ts +349 -0
- package/modules/auth/better-auth/files/express/modules/{auth/auth.route.ts → auth.route.ts} +9 -4
- package/modules/auth/better-auth/files/express/modules/auth.service.ts +664 -0
- package/modules/auth/better-auth/files/express/modules/{auth/auth.type.ts → auth.type.ts} +22 -9
- package/modules/auth/better-auth/files/{shared/mongoose/auth/helper.ts → express/mongo-modules/auth.helper.ts} +11 -1
- package/modules/auth/better-auth/files/express/types/express.d.ts +11 -0
- package/modules/auth/better-auth/files/nextjs/api-route.ts +74 -0
- package/modules/auth/better-auth/files/nextjs/dashboard/pages/(user)/page.tsx +6 -0
- package/modules/auth/better-auth/files/nextjs/dashboard/pages/admin/page.tsx +6 -0
- package/modules/auth/better-auth/files/nextjs/dashboard/pages/layout.tsx +48 -0
- package/modules/auth/better-auth/files/nextjs/dashboard/pages/my-profile/page.tsx +5 -0
- package/modules/auth/better-auth/files/nextjs/features/services/auth.service.ts +102 -0
- package/modules/auth/better-auth/files/nextjs/layout/layout.tsx +13 -0
- package/modules/auth/better-auth/files/nextjs/lib/axios/http.ts +158 -0
- package/modules/auth/better-auth/files/nextjs/lib/env.ts +35 -0
- package/modules/auth/better-auth/files/nextjs/lib/utils/auth.ts +75 -0
- package/modules/auth/better-auth/files/nextjs/lib/utils/cookie.ts +29 -0
- package/modules/auth/better-auth/files/nextjs/lib/utils/jwt.ts +28 -0
- package/modules/auth/better-auth/files/nextjs/lib/utils/token.ts +49 -0
- package/modules/auth/better-auth/files/nextjs/pages/forgot-password/page.tsx +5 -0
- package/modules/auth/better-auth/files/nextjs/pages/layout.tsx +11 -0
- package/modules/auth/better-auth/files/nextjs/pages/login/page.tsx +9 -0
- package/modules/auth/better-auth/files/nextjs/pages/register/page.tsx +5 -0
- package/modules/auth/better-auth/files/nextjs/pages/reset-password/page.tsx +10 -0
- package/modules/auth/better-auth/files/nextjs/pages/verify-email/page.tsx +10 -0
- package/modules/auth/better-auth/files/nextjs/proxy.ts +154 -42
- package/modules/auth/better-auth/files/nextjs/theme/providers/theme-provider.tsx +11 -0
- package/modules/auth/better-auth/files/nextjs/types/api.types.ts +18 -0
- package/modules/auth/better-auth/files/react/components/protected-route.tsx +39 -0
- package/modules/auth/better-auth/files/react/components/route-guards.tsx +13 -0
- package/modules/auth/better-auth/files/react/dashboard/admin/pages/overview.tsx +3 -0
- package/modules/auth/better-auth/files/react/dashboard/pages/overview.tsx +3 -0
- package/modules/auth/better-auth/files/react/features/pages/forgot-password.tsx +5 -0
- package/modules/auth/better-auth/files/react/features/pages/login.tsx +5 -0
- package/modules/auth/better-auth/files/react/features/pages/my-profile.tsx +5 -0
- package/modules/auth/better-auth/files/react/features/pages/oauth-callback.tsx +59 -0
- package/modules/auth/better-auth/files/react/features/pages/register.tsx +5 -0
- package/modules/auth/better-auth/files/react/features/pages/reset-password.tsx +10 -0
- package/modules/auth/better-auth/files/react/features/pages/verify-email.tsx +10 -0
- package/modules/auth/better-auth/files/react/layout/dashboard-layout.tsx +54 -0
- package/modules/auth/better-auth/files/react/lib/axios/http.ts +68 -0
- package/modules/auth/better-auth/files/react/lib/env.ts +25 -0
- package/modules/auth/better-auth/files/react/router.tsx +73 -0
- package/modules/auth/better-auth/files/react/theme/components/providers/theme-provider-context.ts +13 -0
- package/modules/auth/better-auth/files/react/theme/components/providers/theme-provider.tsx +51 -0
- package/modules/auth/better-auth/files/react/theme/hooks/use-theme.ts +8 -0
- package/modules/auth/better-auth/files/shared/features/components/change-password-dialog.tsx +113 -0
- package/modules/auth/better-auth/files/shared/features/components/forgot-password-form.tsx +84 -0
- package/modules/auth/better-auth/files/shared/features/components/login-form.tsx +134 -0
- package/modules/auth/better-auth/files/shared/features/components/my-profile.tsx +147 -0
- package/modules/auth/better-auth/files/shared/features/components/profile-form.tsx +205 -0
- package/modules/auth/better-auth/files/shared/features/components/register-form.tsx +100 -0
- package/modules/auth/better-auth/files/shared/features/components/reset-password-form.tsx +111 -0
- package/modules/auth/better-auth/files/shared/features/components/social-login-buttons.tsx +47 -0
- package/modules/auth/better-auth/files/shared/features/components/user-profile-menu.tsx +106 -0
- package/modules/auth/better-auth/files/shared/features/components/verify-email-form.tsx +110 -0
- package/modules/auth/better-auth/files/shared/features/queries/auth.mutations.tsx +312 -0
- package/modules/auth/better-auth/files/shared/features/queries/auth.querie.ts +19 -0
- package/modules/auth/better-auth/files/shared/features/services/auth.api.ts +81 -0
- package/modules/auth/better-auth/files/shared/features/types/auth.type.ts +47 -0
- package/modules/auth/better-auth/files/shared/features/validators/change-password.validator.ts +18 -0
- package/modules/auth/better-auth/files/shared/features/validators/forgot.validator.ts +7 -0
- package/modules/auth/better-auth/files/shared/features/validators/login.validator.ts +14 -0
- package/modules/auth/better-auth/files/shared/features/validators/profile.validator.ts +8 -0
- package/modules/auth/better-auth/files/shared/features/validators/register.validator.ts +9 -0
- package/modules/auth/better-auth/files/shared/features/validators/reset.validator.ts +9 -0
- package/modules/auth/better-auth/files/shared/features/validators/verify.validator.ts +8 -0
- package/modules/auth/better-auth/files/shared/lib/auth-client.ts +2 -1
- package/modules/auth/better-auth/files/shared/lib/auth.ts +5 -19
- package/modules/auth/better-auth/files/shared/lib/constant/dashboard.ts +90 -0
- package/modules/auth/better-auth/files/shared/theme/mode-toggle.tsx +30 -0
- package/modules/auth/better-auth/files/shared/ui/shadcn/components/dashboard/dashboard-header.tsx +94 -0
- package/modules/auth/better-auth/files/shared/ui/shadcn/components/dashboard/dashboard-sidebar.tsx +255 -0
- package/modules/auth/better-auth/files/shared/ui/shadcn/components/footer.tsx +35 -0
- package/modules/auth/better-auth/files/shared/ui/shadcn/components/navbar.tsx +145 -0
- package/modules/auth/better-auth/files/shared/ui/shadcn/form-field/input-field.tsx +440 -0
- package/modules/auth/better-auth/files/shared/utils/email.ts +2 -17
- package/modules/auth/better-auth/generator.json +172 -51
- package/modules/auth/better-auth/module.json +2 -2
- package/modules/components/files/shared/hooks/use-file-upload.ts +412 -0
- package/modules/components/files/shared/lib/utils/url-helpers.ts +110 -0
- package/modules/components/files/shared/shadcn/dashboard/data-table-column-selector.tsx +52 -0
- package/modules/components/files/shared/shadcn/dashboard/data-table-footer.tsx +156 -0
- package/modules/components/files/shared/shadcn/dashboard/data-table.tsx +405 -0
- package/modules/components/files/shared/shadcn/global/form-field/input-field.tsx +440 -0
- package/modules/components/files/shared/shadcn/global/form-field/media-uploader-field.tsx +745 -0
- package/modules/components/files/shared/shadcn/global/form-field/multi-select-field.tsx +207 -0
- package/modules/components/files/shared/shadcn/global/form-field/select-field.tsx +247 -0
- package/modules/components/files/shared/shadcn/global/form-field/textarea-field.tsx +277 -0
- package/modules/components/files/shared/shadcn/global/form-field/tiptap-editor-field.tsx +35 -0
- package/modules/components/files/shared/shadcn/global/no-results.tsx +41 -0
- package/modules/components/files/shared/shadcn/tiptap-editor/editor-menu-bar.tsx +217 -0
- package/modules/components/files/shared/shadcn/tiptap-editor/tiptap-editor.tsx +104 -0
- package/modules/components/files/shared/url/load-more.tsx +93 -0
- package/modules/components/files/shared/url/search-bar.tsx +131 -0
- package/modules/components/files/shared/url/sort-select.tsx +118 -0
- package/modules/components/files/shared/url/url-tabs.tsx +77 -0
- package/modules/components/generator.json +109 -0
- package/modules/components/module.json +11 -0
- package/modules/database/mongoose/generator.json +3 -14
- package/modules/database/mongoose/module.json +2 -2
- package/modules/database/prisma/generator.json +6 -12
- package/modules/database/prisma/module.json +2 -2
- package/modules/storage/cloudinary/files/express/config/env.ts +65 -0
- package/modules/storage/cloudinary/files/express/config/media.ts +103 -0
- package/modules/storage/cloudinary/files/express/modules/media/media.controller.ts +59 -0
- package/modules/storage/cloudinary/files/express/modules/media/media.route.ts +29 -0
- package/modules/storage/cloudinary/files/express/modules/media/media.service.ts +113 -0
- package/modules/storage/cloudinary/files/express/modules/media/media.type.ts +32 -0
- package/modules/storage/cloudinary/generator.json +34 -0
- package/modules/storage/cloudinary/module.json +11 -0
- package/modules/ui/shadcn/generator.json +21 -0
- package/modules/ui/shadcn/module.json +11 -0
- package/package.json +24 -26
- package/templates/express/README.md +11 -16
- package/templates/express/src/config/env.ts +7 -5
- package/templates/nextjs/README.md +13 -18
- package/templates/nextjs/app/favicon.ico +0 -0
- package/templates/nextjs/app/layout.tsx +6 -4
- package/templates/nextjs/components/providers/query-provider.tsx +3 -0
- package/templates/nextjs/env.example +3 -1
- package/templates/nextjs/lib/axios/http.ts +23 -0
- package/templates/nextjs/lib/env.ts +7 -5
- package/templates/nextjs/package.json +2 -1
- package/templates/nextjs/template.json +1 -2
- package/templates/react/README.md +9 -14
- package/templates/react/index.html +1 -1
- package/templates/react/package.json +1 -1
- package/templates/react/src/assets/favicon.ico +0 -0
- package/templates/react/src/components/providers/query-provider.tsx +38 -0
- package/templates/react/src/{shared/components → components}/seo.tsx +4 -8
- package/templates/react/src/lib/axios/http.ts +24 -0
- package/templates/react/src/main.tsx +8 -11
- package/templates/react/src/{features/about/pages → pages}/about.tsx +1 -1
- package/templates/react/src/{features/home/pages → pages}/home.tsx +1 -1
- package/templates/react/src/router.tsx +6 -6
- package/templates/react/src/vite-env.d.ts +2 -1
- package/templates/react/template.json +0 -1
- package/templates/react/tsconfig.app.json +6 -0
- package/templates/react/tsconfig.json +7 -1
- package/templates/react/vite.config.ts +12 -0
- package/modules/auth/authjs/files/nextjs/api/auth/[...nextauth]/route.ts +0 -3
- package/modules/auth/authjs/files/nextjs/proxy.ts +0 -1
- package/modules/auth/authjs/files/shared/lib/auth.ts +0 -119
- package/modules/auth/authjs/files/shared/prisma/schema.prisma +0 -61
- package/modules/auth/authjs/generator.json +0 -64
- package/modules/auth/authjs/module.json +0 -13
- package/modules/auth/better-auth/files/express/modules/auth/auth.controller.ts +0 -264
- package/modules/auth/better-auth/files/express/modules/auth/auth.service.ts +0 -549
- package/modules/auth/better-auth/files/express/templates/google-redirect.ejs +0 -24
- package/modules/auth/better-auth/files/nextjs/api/auth/[...all]/route.ts +0 -4
- package/modules/auth/better-auth/files/nextjs/lib/auth/auth-guards.ts +0 -31
- package/modules/auth/better-auth/files/nextjs/templates/email-otp.tsx +0 -74
- package/templates/nextjs/lib/api/http.ts +0 -40
- package/templates/react/public/vite.svg +0 -1
- package/templates/react/src/app/layouts/dashboard-layout.tsx +0 -8
- package/templates/react/src/app/layouts/public-layout.tsx +0 -5
- package/templates/react/src/app/providers.tsx +0 -20
- package/templates/react/src/app/router.tsx +0 -21
- package/templates/react/src/assets/react.svg +0 -1
- package/templates/react/src/shared/api/http.ts +0 -39
- package/templates/react/src/shared/components/loading.tsx +0 -8
- package/templates/react/src/shared/lib/query-client.ts +0 -12
- package/templates/react/src/utils/storage.ts +0 -35
- package/templates/react/src/utils/utils.ts +0 -3
- /package/modules/auth/better-auth/files/{shared/mongoose/auth/constants.ts → express/mongo-modules/auth.constants.ts} +0 -0
- /package/templates/nextjs/app/{page.tsx → (public)/(root)/page.tsx} +0 -0
- /package/templates/react/src/{shared/components → components}/error-boundary.tsx +0 -0
- /package/templates/react/src/{shared/components → components}/layout.tsx +0 -0
- /package/templates/react/src/{shared/pages → pages}/not-found.tsx +0 -0
package/dist/lib/constants.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export declare const MODULE_CATEGORIES: {
|
|
|
31
31
|
DATABASE: "database";
|
|
32
32
|
AUTH: "auth";
|
|
33
33
|
FRAMEWORK: "framework";
|
|
34
|
+
UI: "ui";
|
|
35
|
+
STORAGE: "storage";
|
|
34
36
|
};
|
|
35
37
|
export declare const DIRECTORY_NAMES: {
|
|
36
38
|
readonly MODULES: "modules";
|
|
@@ -80,6 +82,8 @@ export declare const DISPLAY_NAMES: {
|
|
|
80
82
|
readonly database: "Database";
|
|
81
83
|
readonly auth: "Auth";
|
|
82
84
|
readonly framework: "Framework";
|
|
85
|
+
readonly ui: "UI";
|
|
86
|
+
readonly storage: "Storage";
|
|
83
87
|
};
|
|
84
88
|
export declare const ERROR_MESSAGES: {
|
|
85
89
|
readonly NO_PACKAGE_JSON: "No package.json found in current directory or any parent directory.";
|
package/dist/lib/constants.js
CHANGED
|
@@ -27,6 +27,8 @@ exports.MODULE_CATEGORIES = {
|
|
|
27
27
|
DATABASE: "database",
|
|
28
28
|
AUTH: "auth",
|
|
29
29
|
FRAMEWORK: "framework",
|
|
30
|
+
UI: "ui",
|
|
31
|
+
STORAGE: "storage",
|
|
30
32
|
};
|
|
31
33
|
exports.DIRECTORY_NAMES = {
|
|
32
34
|
MODULES: "modules",
|
|
@@ -81,6 +83,8 @@ exports.DISPLAY_NAMES = {
|
|
|
81
83
|
[exports.MODULE_CATEGORIES.DATABASE]: "Database",
|
|
82
84
|
[exports.MODULE_CATEGORIES.AUTH]: "Auth",
|
|
83
85
|
[exports.MODULE_CATEGORIES.FRAMEWORK]: "Framework",
|
|
86
|
+
[exports.MODULE_CATEGORIES.UI]: "UI",
|
|
87
|
+
[exports.MODULE_CATEGORIES.STORAGE]: "Storage",
|
|
84
88
|
};
|
|
85
89
|
exports.ERROR_MESSAGES = {
|
|
86
90
|
NO_PACKAGE_JSON: "No package.json found in current directory or any parent directory.",
|
|
@@ -25,6 +25,9 @@ export interface DiscoveredModules {
|
|
|
25
25
|
frameworks: ModuleMetadata[];
|
|
26
26
|
databases: ModuleMetadata[];
|
|
27
27
|
auth: ModuleMetadata[];
|
|
28
|
+
ui?: ModuleMetadata[];
|
|
29
|
+
storage?: ModuleMetadata[];
|
|
30
|
+
components?: ModuleMetadata[];
|
|
28
31
|
}
|
|
29
32
|
export declare function discoverModules(modulesDir: string): Promise<DiscoveredModules>;
|
|
30
33
|
export declare function getValidDatabaseOptions(databases: ModuleMetadata[]): string[];
|
|
@@ -32,6 +35,7 @@ export declare function getValidAuthOptions(authModules: ModuleMetadata[]): stri
|
|
|
32
35
|
export declare function getCompatibleAuthOptions(authModules: ModuleMetadata[], framework: string, database: string, frameworksMeta?: ModuleMetadata[]): Array<{
|
|
33
36
|
name: string;
|
|
34
37
|
value: string;
|
|
38
|
+
description?: string;
|
|
35
39
|
}>;
|
|
36
40
|
export declare function getDatabaseChoices(databases: ModuleMetadata[], framework: string): Array<{
|
|
37
41
|
name: string;
|
|
@@ -100,6 +100,61 @@ async function discoverModules(modulesDir) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
+
// discover UI modules (modules/ui)
|
|
104
|
+
const uiDir = path_1.default.join(modulesDir, "ui");
|
|
105
|
+
if (await fs_extra_1.default.pathExists(uiDir)) {
|
|
106
|
+
discovered.ui = [];
|
|
107
|
+
const uiModules = await fs_extra_1.default.readdir(uiDir);
|
|
108
|
+
for (const moduleName of uiModules) {
|
|
109
|
+
const modulePath = path_1.default.join(uiDir, moduleName);
|
|
110
|
+
const moduleJsonPath = path_1.default.join(modulePath, "module.json");
|
|
111
|
+
if (await fs_extra_1.default.pathExists(moduleJsonPath)) {
|
|
112
|
+
const metadata = await readJsonSafe(moduleJsonPath);
|
|
113
|
+
if (metadata) {
|
|
114
|
+
if (!metadata.name)
|
|
115
|
+
metadata.name = moduleName;
|
|
116
|
+
if (!metadata.displayName)
|
|
117
|
+
metadata.displayName = moduleName;
|
|
118
|
+
discovered.ui.push(metadata);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// discover storage/provider modules (modules/storage)
|
|
124
|
+
const storageDir = path_1.default.join(modulesDir, "storage");
|
|
125
|
+
if (await fs_extra_1.default.pathExists(storageDir)) {
|
|
126
|
+
discovered.storage = [];
|
|
127
|
+
const storageModules = await fs_extra_1.default.readdir(storageDir);
|
|
128
|
+
for (const moduleName of storageModules) {
|
|
129
|
+
const modulePath = path_1.default.join(storageDir, moduleName);
|
|
130
|
+
const moduleJsonPath = path_1.default.join(modulePath, "module.json");
|
|
131
|
+
if (await fs_extra_1.default.pathExists(moduleJsonPath)) {
|
|
132
|
+
const metadata = await readJsonSafe(moduleJsonPath);
|
|
133
|
+
if (metadata) {
|
|
134
|
+
if (!metadata.name)
|
|
135
|
+
metadata.name = moduleName;
|
|
136
|
+
if (!metadata.displayName)
|
|
137
|
+
metadata.displayName = moduleName;
|
|
138
|
+
discovered.storage.push(metadata);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// discover frontend components module (flat: modules/components/module.json)
|
|
144
|
+
const componentsDir = path_1.default.join(modulesDir, "components");
|
|
145
|
+
if (await fs_extra_1.default.pathExists(componentsDir)) {
|
|
146
|
+
const moduleJsonPath = path_1.default.join(componentsDir, "module.json");
|
|
147
|
+
if (await fs_extra_1.default.pathExists(moduleJsonPath)) {
|
|
148
|
+
const metadata = await readJsonSafe(moduleJsonPath);
|
|
149
|
+
if (metadata) {
|
|
150
|
+
if (!metadata.name)
|
|
151
|
+
metadata.name = "components";
|
|
152
|
+
if (!metadata.displayName)
|
|
153
|
+
metadata.displayName = "Components";
|
|
154
|
+
discovered.components = [metadata];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
103
158
|
return discovered;
|
|
104
159
|
}
|
|
105
160
|
function getValidDatabaseOptions(databases) {
|
|
@@ -154,6 +209,7 @@ function getCompatibleAuthOptions(authModules, framework, database, frameworksMe
|
|
|
154
209
|
compatible.push({
|
|
155
210
|
name: auth.displayName,
|
|
156
211
|
value: auth.name,
|
|
212
|
+
description: auth.description || "",
|
|
157
213
|
});
|
|
158
214
|
}
|
|
159
215
|
compatible.push({ name: "None", value: "none" });
|
|
@@ -6,6 +6,10 @@ export interface GenerationContext {
|
|
|
6
6
|
features?: string[];
|
|
7
7
|
combo?: string;
|
|
8
8
|
prismaProvider?: string;
|
|
9
|
+
packageManager?: string;
|
|
10
|
+
ui?: string;
|
|
11
|
+
storageProvider?: string;
|
|
12
|
+
components?: boolean;
|
|
9
13
|
[key: string]: unknown;
|
|
10
14
|
}
|
|
11
15
|
export interface TemplateCondition {
|
|
@@ -19,6 +23,10 @@ type SelectedModules = {
|
|
|
19
23
|
database?: string;
|
|
20
24
|
auth?: string;
|
|
21
25
|
prismaProvider?: string;
|
|
26
|
+
ui?: string;
|
|
27
|
+
storageProvider?: string;
|
|
28
|
+
packageManager?: string;
|
|
29
|
+
components?: boolean;
|
|
22
30
|
};
|
|
23
31
|
export interface Operation {
|
|
24
32
|
type: "create-file" | "patch-file" | "add-dependency" | "add-script" | "add-env" | "run-command";
|
|
@@ -48,7 +56,7 @@ export interface PatchOperation {
|
|
|
48
56
|
}
|
|
49
57
|
export interface GeneratorConfig {
|
|
50
58
|
name: string;
|
|
51
|
-
type: "framework" | "database" | "auth";
|
|
59
|
+
type: "framework" | "database" | "auth" | "ui" | "storage" | "components";
|
|
52
60
|
priority: number;
|
|
53
61
|
operations?: Operation[];
|
|
54
62
|
dependencies?: Record<string, string>;
|
|
@@ -90,7 +98,8 @@ export declare class AdvancedCodeGenerator {
|
|
|
90
98
|
frameworks: string[];
|
|
91
99
|
databases: string[];
|
|
92
100
|
auths: string[];
|
|
101
|
+
components: string[];
|
|
93
102
|
};
|
|
94
|
-
registerGenerator(type: "framework" | "database" | "auth", name: string, config: GeneratorConfig): void;
|
|
103
|
+
registerGenerator(type: "framework" | "database" | "auth" | "ui" | "storage" | "components", name: string, config: GeneratorConfig): void;
|
|
95
104
|
}
|
|
96
105
|
export {};
|
|
@@ -63,13 +63,29 @@ class AdvancedCodeGenerator {
|
|
|
63
63
|
isGeneratorSelected(genType, name, selectedModules) {
|
|
64
64
|
return ((genType === "framework" && name === selectedModules.framework) ||
|
|
65
65
|
(genType === "database" && name === selectedModules.database) ||
|
|
66
|
-
(genType === "auth" && name === selectedModules.auth)
|
|
66
|
+
(genType === "auth" && name === selectedModules.auth) ||
|
|
67
|
+
(genType === "ui" && name === selectedModules.ui) ||
|
|
68
|
+
(genType === "storage" && name === selectedModules.storageProvider) ||
|
|
69
|
+
(genType === "components" && selectedModules.components === true));
|
|
67
70
|
}
|
|
68
71
|
async loadGenerators(modulesPath) {
|
|
69
|
-
const moduleTypes = ["auth", "database"];
|
|
72
|
+
const moduleTypes = ["auth", "database", "ui", "storage", "components"];
|
|
70
73
|
for (const type of moduleTypes) {
|
|
71
74
|
const typePath = path.join(modulesPath, type);
|
|
72
75
|
if (await fs.pathExists(typePath)) {
|
|
76
|
+
// Check for flat module (generator.json at type root, e.g. modules/components/generator.json)
|
|
77
|
+
const flatGeneratorPath = path.join(typePath, "generator.json");
|
|
78
|
+
if (await fs.pathExists(flatGeneratorPath)) {
|
|
79
|
+
try {
|
|
80
|
+
const config = await fs.readJson(flatGeneratorPath);
|
|
81
|
+
await (0, generator_utils_1.mergeModuleIntoGeneratorConfig)(config, typePath);
|
|
82
|
+
this.generators.set(`${type}:${type}`, config);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// skip
|
|
86
|
+
}
|
|
87
|
+
continue; // skip subdir scanning for this type
|
|
88
|
+
}
|
|
73
89
|
const modules = await fs.readdir(typePath);
|
|
74
90
|
for (const moduleName of modules) {
|
|
75
91
|
const generatorPath = path.join(typePath, moduleName, "generator.json");
|
|
@@ -218,6 +234,25 @@ class AdvancedCodeGenerator {
|
|
|
218
234
|
.replace(/^\n+/, "")
|
|
219
235
|
.replace(/\n+$/, "");
|
|
220
236
|
}
|
|
237
|
+
const rawCond = condition.trim();
|
|
238
|
+
if (rawCond) {
|
|
239
|
+
if (rawCond.startsWith("!")) {
|
|
240
|
+
const varName = rawCond.slice(1).trim().replace(/['"]/g, "");
|
|
241
|
+
const val = context[varName];
|
|
242
|
+
const isTruthy = !!val && !(Array.isArray(val) && val.length === 0);
|
|
243
|
+
const contentToProcess = !isTruthy ? blockContent : elseContent || "";
|
|
244
|
+
return this.processTemplateRecursive(contentToProcess, context)
|
|
245
|
+
.replace(/^\n+/, "")
|
|
246
|
+
.replace(/\n+$/, "");
|
|
247
|
+
}
|
|
248
|
+
const varNameSimple = rawCond.replace(/['"]/g, "");
|
|
249
|
+
const val = context[varNameSimple];
|
|
250
|
+
const isTruthy = !!val && !(Array.isArray(val) && val.length === 0);
|
|
251
|
+
const contentToProcess = isTruthy ? blockContent : elseContent || "";
|
|
252
|
+
return this.processTemplateRecursive(contentToProcess, context)
|
|
253
|
+
.replace(/^\n+/, "")
|
|
254
|
+
.replace(/\n+$/, "");
|
|
255
|
+
}
|
|
221
256
|
return "";
|
|
222
257
|
});
|
|
223
258
|
content = content.replace(/\{\{#switch\s+([^}]+)\}\}([\s\S]*?)\{\{\/switch\}\}/g, (match, varName, switchContent) => {
|
|
@@ -905,6 +940,7 @@ class AdvancedCodeGenerator {
|
|
|
905
940
|
const frameworks = [];
|
|
906
941
|
const databases = [];
|
|
907
942
|
const auths = [];
|
|
943
|
+
const components = [];
|
|
908
944
|
for (const [key] of this.generators) {
|
|
909
945
|
const [type, name] = key.split(":");
|
|
910
946
|
switch (type) {
|
|
@@ -917,9 +953,12 @@ class AdvancedCodeGenerator {
|
|
|
917
953
|
case "auth":
|
|
918
954
|
auths.push(name);
|
|
919
955
|
break;
|
|
956
|
+
case "components":
|
|
957
|
+
components.push(name);
|
|
958
|
+
break;
|
|
920
959
|
}
|
|
921
960
|
}
|
|
922
|
-
return { frameworks, databases, auths };
|
|
961
|
+
return { frameworks, databases, auths, components };
|
|
923
962
|
}
|
|
924
963
|
registerGenerator(type, name, config) {
|
|
925
964
|
this.generators.set(`${type}:${name}`, config);
|
|
@@ -122,7 +122,9 @@ function locateOperationSource(generatorType, generatorName, sourceRel) {
|
|
|
122
122
|
const templatesPath = path.join(packageRoot, "templates");
|
|
123
123
|
const moduleBasePath = generatorType === "framework"
|
|
124
124
|
? path.join(templatesPath, generatorName)
|
|
125
|
-
:
|
|
125
|
+
: generatorType === generatorName
|
|
126
|
+
? path.join(modulesPath, generatorType)
|
|
127
|
+
: path.join(modulesPath, generatorType, generatorName);
|
|
126
128
|
return path.join(moduleBasePath, "files", sourceRel);
|
|
127
129
|
}
|
|
128
130
|
exports.default = {
|
|
@@ -32,16 +32,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.detectPackageManager = detectPackageManager;
|
|
40
37
|
exports.installDependencies = installDependencies;
|
|
41
38
|
exports.addDependencies = addDependencies;
|
|
42
39
|
exports.initGit = initGit;
|
|
43
40
|
const detect_package_manager_1 = require("detect-package-manager");
|
|
44
|
-
const execa_1 =
|
|
41
|
+
const execa_1 = require("execa");
|
|
45
42
|
const fs = __importStar(require("fs-extra"));
|
|
46
43
|
const path = __importStar(require("path"));
|
|
47
44
|
const constants_1 = require("../constants");
|
|
@@ -77,7 +74,7 @@ async function installDependencies(cwd, pm, maxRetries = 2) {
|
|
|
77
74
|
let lastError = null;
|
|
78
75
|
async function isAvailable(pmCheck) {
|
|
79
76
|
try {
|
|
80
|
-
await (0, execa_1.
|
|
77
|
+
await (0, execa_1.execa)(pmCheck, ["--version"], { cwd, stdio: "pipe", timeout: 2000 });
|
|
81
78
|
return true;
|
|
82
79
|
}
|
|
83
80
|
catch {
|
|
@@ -100,7 +97,7 @@ async function installDependencies(cwd, pm, maxRetries = 2) {
|
|
|
100
97
|
logger_1.logger.debug(`Retry attempt ${attempt} for ${pmCandidate}`);
|
|
101
98
|
await new Promise((resolve) => setTimeout(resolve, constants_1.TIMEOUTS.RETRY_DELAY_BASE * attempt));
|
|
102
99
|
}
|
|
103
|
-
await (0, execa_1.
|
|
100
|
+
await (0, execa_1.execa)(pmCandidate, args, { cwd, stdio, timeout: packageInstallTimeout });
|
|
104
101
|
succeeded = true;
|
|
105
102
|
break;
|
|
106
103
|
}
|
|
@@ -153,7 +150,7 @@ async function addDependencies(cwd, pm, packages, dev = false) {
|
|
|
153
150
|
throw new Error(`Unsupported package manager: ${pm}`);
|
|
154
151
|
}
|
|
155
152
|
logger_1.logger.debug(`Running: ${pm} ${args.join(" ")}`);
|
|
156
|
-
await (0, execa_1.
|
|
153
|
+
await (0, execa_1.execa)(pm, args, { cwd, stdio, timeout: constants_1.TIMEOUTS.PACKAGE_INSTALL });
|
|
157
154
|
spinner.succeed(`Dependencies added successfully`);
|
|
158
155
|
}
|
|
159
156
|
catch (error) {
|
|
@@ -179,7 +176,7 @@ function isValidPackageName(packageName) {
|
|
|
179
176
|
async function initGit(cwd) {
|
|
180
177
|
const spinner = logger_1.logger.startSpinner("Initializing git repository...");
|
|
181
178
|
try {
|
|
182
|
-
await (0, execa_1.
|
|
179
|
+
await (0, execa_1.execa)("git", ["--version"], { cwd, stdio: "pipe" });
|
|
183
180
|
}
|
|
184
181
|
catch {
|
|
185
182
|
spinner.fail("Git is not installed");
|
|
@@ -196,12 +193,18 @@ async function initGit(cwd) {
|
|
|
196
193
|
return;
|
|
197
194
|
}
|
|
198
195
|
const run = async (stdio) => {
|
|
199
|
-
await (0, execa_1.
|
|
200
|
-
await (0, execa_1.default)("git", ["add", "."], { cwd, stdio });
|
|
196
|
+
await (0, execa_1.execa)("git", ["init"], { cwd, stdio });
|
|
201
197
|
try {
|
|
202
|
-
await (0, execa_1.
|
|
203
|
-
|
|
204
|
-
|
|
198
|
+
await (0, execa_1.execa)("git", ["branch", "-M", "main"], { cwd, stdio });
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
// Ignore if branch rename fails (older git versions)
|
|
202
|
+
}
|
|
203
|
+
await (0, execa_1.execa)("git", ["add", "."], { cwd, stdio });
|
|
204
|
+
try {
|
|
205
|
+
await (0, execa_1.execa)("git", ["config", "user.name"], { cwd, stdio: "pipe" });
|
|
206
|
+
await (0, execa_1.execa)("git", ["config", "user.email"], { cwd, stdio: "pipe" });
|
|
207
|
+
await (0, execa_1.execa)("git", ["commit", "-m", "Initial commit from StackKit"], { cwd, stdio });
|
|
205
208
|
}
|
|
206
209
|
catch {
|
|
207
210
|
logger_1.logger.debug("Git config not found, skipping initial commit");
|
package/dist/lib/ui/logger.js
CHANGED
|
@@ -30,8 +30,9 @@ class Logger {
|
|
|
30
30
|
}
|
|
31
31
|
error(message, error) {
|
|
32
32
|
process.stderr.write(chalk_1.default.red("✖") + " " + message + "\n");
|
|
33
|
-
if (error
|
|
34
|
-
|
|
33
|
+
if (error) {
|
|
34
|
+
const stack = error.stack || error.message;
|
|
35
|
+
process.stderr.write(chalk_1.default.gray("[STACK]") + " " + stack + "\n");
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
warn(message) {
|
|
@@ -7,3 +7,5 @@ export declare function getModuleFilesPath(category: string, moduleName: string)
|
|
|
7
7
|
export declare function getTemplateJsonPath(frameworkName: string): string;
|
|
8
8
|
export declare function getDatabaseModulesPath(): string;
|
|
9
9
|
export declare function getAuthModulesPath(): string;
|
|
10
|
+
export declare function getUiModulesPath(): string;
|
|
11
|
+
export declare function getStorageModulesPath(): string;
|
|
@@ -12,6 +12,8 @@ exports.getModuleFilesPath = getModuleFilesPath;
|
|
|
12
12
|
exports.getTemplateJsonPath = getTemplateJsonPath;
|
|
13
13
|
exports.getDatabaseModulesPath = getDatabaseModulesPath;
|
|
14
14
|
exports.getAuthModulesPath = getAuthModulesPath;
|
|
15
|
+
exports.getUiModulesPath = getUiModulesPath;
|
|
16
|
+
exports.getStorageModulesPath = getStorageModulesPath;
|
|
15
17
|
const path_1 = __importDefault(require("path"));
|
|
16
18
|
const constants_1 = require("../constants");
|
|
17
19
|
const package_root_1 = require("./package-root");
|
|
@@ -42,3 +44,9 @@ function getDatabaseModulesPath() {
|
|
|
42
44
|
function getAuthModulesPath() {
|
|
43
45
|
return path_1.default.join(getModulesPath(), constants_1.MODULE_CATEGORIES.AUTH);
|
|
44
46
|
}
|
|
47
|
+
function getUiModulesPath() {
|
|
48
|
+
return path_1.default.join(getModulesPath(), constants_1.MODULE_CATEGORIES.UI);
|
|
49
|
+
}
|
|
50
|
+
function getStorageModulesPath() {
|
|
51
|
+
return path_1.default.join(getModulesPath(), constants_1.MODULE_CATEGORIES.STORAGE);
|
|
52
|
+
}
|