@codefast/cli 0.3.1-canary.8 → 0.3.1
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/CHANGELOG.md +162 -0
- package/dist/index.cjs +1106 -631
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1099 -625
- package/dist/index.js.map +1 -1
- package/package.json +9 -7
package/dist/index.js
CHANGED
|
@@ -1,136 +1,124 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_inversify__ from "inversify";
|
|
2
3
|
import * as __WEBPACK_EXTERNAL_MODULE_commander__ from "commander";
|
|
3
|
-
import * as
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__ from "node:process";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__ from "node:child_process";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE_zod__ from "zod";
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
6
9
|
import * as __WEBPACK_EXTERNAL_MODULE_node_readline_91c31510__ from "node:readline";
|
|
7
|
-
import * as __WEBPACK_EXTERNAL_MODULE_glob__ from "glob";
|
|
8
10
|
import * as __WEBPACK_EXTERNAL_MODULE_ts_morph_07c7ce60__ from "ts-morph";
|
|
11
|
+
import * as __WEBPACK_EXTERNAL_MODULE_glob__ from "glob";
|
|
9
12
|
import * as __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__ from "lodash-es";
|
|
10
|
-
import * as __WEBPACK_EXTERNAL_MODULE_zod__ from "zod";
|
|
11
13
|
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
const TYPES = {
|
|
15
|
+
ProjectRepository: Symbol.for("ProjectRepository"),
|
|
16
|
+
PackageRepository: Symbol.for("PackageRepository"),
|
|
17
|
+
FileSystemPort: Symbol.for("FileSystemPort"),
|
|
18
|
+
CommandExecutorPort: Symbol.for("CommandExecutorPort"),
|
|
19
|
+
PromptPort: Symbol.for("PromptPort"),
|
|
20
|
+
AnalysisPort: Symbol.for("AnalysisPort"),
|
|
21
|
+
PackageInfoService: Symbol.for("PackageInfoService"),
|
|
22
|
+
DependencyConfigService: Symbol.for("DependencyConfigService"),
|
|
23
|
+
ConfigService: Symbol.for("ConfigService"),
|
|
24
|
+
FileSystemUtility: Symbol.for("FileSystemUtility"),
|
|
25
|
+
CreateProjectUseCase: Symbol.for("CreateProjectUseCase"),
|
|
26
|
+
UpdateExportsUseCase: Symbol.for("UpdateExportsUseCase"),
|
|
27
|
+
CreateProjectCommand: Symbol.for("CreateProjectCommand"),
|
|
28
|
+
UpdateExportsCommand: Symbol.for("UpdateExportsCommand"),
|
|
29
|
+
CLIAdapter: Symbol.for("CLIAdapter")
|
|
30
|
+
};
|
|
31
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
32
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
33
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
34
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
36
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
console.log(`📝 Created ${filePath}`);
|
|
37
|
+
function _ts_metadata(k, v) {
|
|
38
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
31
39
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
error: "Project name cannot be empty or contain only whitespace."
|
|
36
|
-
};
|
|
37
|
-
if (name.length > 100) return {
|
|
38
|
-
valid: false,
|
|
39
|
-
error: "Project name is too long (maximum 100 characters)."
|
|
40
|
-
};
|
|
41
|
-
const npmNameRegex = /^[a-z0-9-~][a-z0-9-._~]*$/;
|
|
42
|
-
if (!npmNameRegex.test(name)) return {
|
|
43
|
-
valid: false,
|
|
44
|
-
error: "Project name must be URL-friendly (letters, numbers, hyphens, underscores, dots; no @ or scoped packages)."
|
|
45
|
-
};
|
|
46
|
-
if ("." === name || ".." === name) return {
|
|
47
|
-
valid: false,
|
|
48
|
-
error: "Project name cannot be '.' or '..'."
|
|
49
|
-
};
|
|
50
|
-
const reservedNames = /^(?<reserved>CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;
|
|
51
|
-
if (reservedNames.test(name)) return {
|
|
52
|
-
valid: false,
|
|
53
|
-
error: `Project name "${name}" is a reserved system name.`
|
|
40
|
+
function _ts_param(paramIndex, decorator) {
|
|
41
|
+
return function(target, key) {
|
|
42
|
+
decorator(target, key, paramIndex);
|
|
54
43
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
try {
|
|
61
|
-
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].accessSync(process.cwd(), __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].constants.W_OK);
|
|
62
|
-
} catch {
|
|
63
|
-
return {
|
|
64
|
-
valid: false,
|
|
65
|
-
error: "Cannot create project: No write permission in current directory."
|
|
66
|
-
};
|
|
44
|
+
}
|
|
45
|
+
class CreateProjectCommand {
|
|
46
|
+
constructor(createProjectUseCase){
|
|
47
|
+
this.createProjectUseCase = createProjectUseCase;
|
|
67
48
|
}
|
|
68
|
-
|
|
69
|
-
|
|
49
|
+
getCommand() {
|
|
50
|
+
return new __WEBPACK_EXTERNAL_MODULE_commander__.Command().name("create-project").description("Create a new Next.js project with TypeScript, TailwindCSS, and linting setup").argument("[project-name]", "Name of the project to create").action(async (projectName)=>{
|
|
51
|
+
await this.createProjectUseCase.execute(projectName);
|
|
52
|
+
__WEBPACK_EXTERNAL_MODULE_node_process_786449bf__["default"].exit(0);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
CreateProjectCommand = _ts_decorate([
|
|
57
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)(),
|
|
58
|
+
_ts_param(0, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.CreateProjectUseCase)),
|
|
59
|
+
_ts_metadata("design:type", Function),
|
|
60
|
+
_ts_metadata("design:paramtypes", [
|
|
61
|
+
"undefined" == typeof CreateProjectUseCase ? Object : CreateProjectUseCase
|
|
62
|
+
])
|
|
63
|
+
], CreateProjectCommand);
|
|
64
|
+
function update_exports_command_ts_decorate(decorators, target, key, desc) {
|
|
65
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
66
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
67
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
68
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
69
|
+
}
|
|
70
|
+
function update_exports_command_ts_metadata(k, v) {
|
|
71
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
72
|
+
}
|
|
73
|
+
function update_exports_command_ts_param(paramIndex, decorator) {
|
|
74
|
+
return function(target, key) {
|
|
75
|
+
decorator(target, key, paramIndex);
|
|
70
76
|
};
|
|
71
77
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const confirm = await utils_prompt("Do you want to continue configuring this existing project? [Y/n]: ");
|
|
86
|
-
if ("" === confirm || "y" === confirm.toLowerCase()) {
|
|
87
|
-
const packageJson = JSON.parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(packageJsonPath, "utf8"));
|
|
88
|
-
const projectName = packageJson.name ?? await getValidProjectName(projectNameArg);
|
|
89
|
-
return {
|
|
90
|
-
projectName,
|
|
91
|
-
packageJsonExists
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
console.log("Aborting...");
|
|
95
|
-
throw new Error("User aborted the operation.");
|
|
78
|
+
class UpdateExportsCommand {
|
|
79
|
+
constructor(updateExportsUseCase){
|
|
80
|
+
this.updateExportsUseCase = updateExportsUseCase;
|
|
81
|
+
}
|
|
82
|
+
getCommand() {
|
|
83
|
+
return new __WEBPACK_EXTERNAL_MODULE_commander__.Command().name("update-exports").description("Updates exports for all packages").option("-p, --package <package>", "Filter by package name").option("-d, --dry-run", "Run without making changes").option("-c, --config <path>", "Path to configuration file").action(async (options)=>{
|
|
84
|
+
await this.updateExportsUseCase.execute({
|
|
85
|
+
packageFilter: options.package,
|
|
86
|
+
dryRun: Boolean(options.dryRun),
|
|
87
|
+
configPath: options.config
|
|
88
|
+
});
|
|
89
|
+
__WEBPACK_EXTERNAL_MODULE_node_process_786449bf__.exit(0);
|
|
90
|
+
});
|
|
96
91
|
}
|
|
97
|
-
const projectName = await getValidProjectName(projectNameArg);
|
|
98
|
-
return {
|
|
99
|
-
projectName,
|
|
100
|
-
packageJsonExists
|
|
101
|
-
};
|
|
102
92
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
path: ".vercelignore",
|
|
133
|
-
content: `#-------------------------------------------------------------------------------
|
|
93
|
+
UpdateExportsCommand = update_exports_command_ts_decorate([
|
|
94
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)(),
|
|
95
|
+
update_exports_command_ts_param(0, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.UpdateExportsUseCase)),
|
|
96
|
+
update_exports_command_ts_metadata("design:type", Function),
|
|
97
|
+
update_exports_command_ts_metadata("design:paramtypes", [
|
|
98
|
+
"undefined" == typeof UpdateExportsUseCase ? Object : UpdateExportsUseCase
|
|
99
|
+
])
|
|
100
|
+
], UpdateExportsCommand);
|
|
101
|
+
function handleError(error, defaultMessage) {
|
|
102
|
+
const message = error instanceof Error ? error.message : defaultMessage;
|
|
103
|
+
console.error(`
|
|
104
|
+
\u{274C} ${message}`);
|
|
105
|
+
}
|
|
106
|
+
function config_service_ts_decorate(decorators, target, key, desc) {
|
|
107
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
108
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
109
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
110
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
111
|
+
}
|
|
112
|
+
class ConfigService {
|
|
113
|
+
getConfigGroups() {
|
|
114
|
+
return this.configGroups;
|
|
115
|
+
}
|
|
116
|
+
constructor(){
|
|
117
|
+
this.configGroups = {
|
|
118
|
+
deployment: [
|
|
119
|
+
{
|
|
120
|
+
path: ".vercelignore",
|
|
121
|
+
content: `#-------------------------------------------------------------------------------
|
|
134
122
|
# Dependencies and package managers
|
|
135
123
|
#-------------------------------------------------------------------------------
|
|
136
124
|
|
|
@@ -196,13 +184,13 @@ Thumbs.db
|
|
|
196
184
|
# Vercel deployment configuration
|
|
197
185
|
.vercel
|
|
198
186
|
`,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
187
|
+
description: "Ignore files that should not be deployed to Vercel"
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
formatting: [
|
|
191
|
+
{
|
|
192
|
+
path: "prettier.config.mjs",
|
|
193
|
+
content: `/**
|
|
206
194
|
* @see https://prettier.io/docs/en/configuration.html
|
|
207
195
|
* @type {import('prettier').Config}
|
|
208
196
|
*/
|
|
@@ -215,11 +203,11 @@ const config = {
|
|
|
215
203
|
|
|
216
204
|
export default config;
|
|
217
205
|
`,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
206
|
+
description: "Prettier configuration for source code formatting"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
path: ".editorconfig",
|
|
210
|
+
content: `# https://editorconfig.org
|
|
223
211
|
root = true
|
|
224
212
|
|
|
225
213
|
[*]
|
|
@@ -243,13 +231,31 @@ indent_style = tab
|
|
|
243
231
|
# Keep in sync with rustfmt
|
|
244
232
|
indent_size = 4
|
|
245
233
|
`,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
234
|
+
description: "Editor configuration for source code formatting"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
path: ".prettierignore",
|
|
238
|
+
content: `# changesets
|
|
239
|
+
.changeset
|
|
240
|
+
|
|
241
|
+
# debug
|
|
242
|
+
npm-debug.log*
|
|
243
|
+
yarn-debug.log*
|
|
244
|
+
yarn-error.log*
|
|
245
|
+
.pnpm-debug.log*
|
|
246
|
+
|
|
247
|
+
# lock files
|
|
248
|
+
package-lock.json
|
|
249
|
+
yarn.lock
|
|
250
|
+
pnpm-lock.yaml
|
|
251
|
+
`,
|
|
252
|
+
description: ""
|
|
253
|
+
}
|
|
254
|
+
],
|
|
255
|
+
linting: [
|
|
256
|
+
{
|
|
257
|
+
path: "commitlint.config.mjs",
|
|
258
|
+
content: `/**
|
|
253
259
|
* @see https://commitlint.js.org/reference/configuration.html
|
|
254
260
|
* @type {import('@commitlint/types').UserConfig}
|
|
255
261
|
*/
|
|
@@ -257,16 +263,18 @@ const config = {
|
|
|
257
263
|
extends: ["@commitlint/config-conventional"],
|
|
258
264
|
rules: {
|
|
259
265
|
"body-max-line-length": [2, "always", 350],
|
|
266
|
+
"header-max-length": [2, "always", 150],
|
|
260
267
|
},
|
|
261
268
|
};
|
|
262
269
|
|
|
263
270
|
export default config;
|
|
264
271
|
`,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
272
|
+
description: "Commitlint configuration"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
path: "eslint.config.mjs",
|
|
276
|
+
content: `import { config } from "@codefast/eslint-config/next";
|
|
277
|
+
|
|
270
278
|
/**
|
|
271
279
|
* @see https://eslint.org/docs/latest/use/configure/configuration-files
|
|
272
280
|
* @type {import('eslint').Linter.Config[]}
|
|
@@ -275,11 +283,12 @@ const eslintConfig = [...config];
|
|
|
275
283
|
|
|
276
284
|
export default eslintConfig;
|
|
277
285
|
`,
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
286
|
+
description: "ESLint configuration for the project"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
path: "lint-staged.config.mjs",
|
|
290
|
+
content: `import { relative } from "node:path";
|
|
291
|
+
|
|
283
292
|
/**
|
|
284
293
|
* Builds an ESLint command with the given filenames.
|
|
285
294
|
*
|
|
@@ -303,13 +312,13 @@ const config = {
|
|
|
303
312
|
|
|
304
313
|
export default config;
|
|
305
314
|
`,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
315
|
+
description: "Configure lint-staged for pre-commit checks"
|
|
316
|
+
}
|
|
317
|
+
],
|
|
318
|
+
styles: [
|
|
319
|
+
{
|
|
320
|
+
path: "src/lib/fonts.ts",
|
|
321
|
+
content: `import { cn } from "@codefast/ui";
|
|
313
322
|
import { Geist, Geist_Mono as GeistMono } from "next/font/google";
|
|
314
323
|
|
|
315
324
|
const fontGeistSans = Geist({
|
|
@@ -324,11 +333,11 @@ const fontGeistMono = GeistMono({
|
|
|
324
333
|
|
|
325
334
|
export const fontVariables = cn(fontGeistSans.variable, fontGeistMono.variable);
|
|
326
335
|
`,
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
336
|
+
description: "Font configuration for the application"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
path: "src/app/globals.css",
|
|
340
|
+
content: `@import "tailwindcss";
|
|
332
341
|
|
|
333
342
|
@import "@codefast/ui/styles.css";
|
|
334
343
|
|
|
@@ -340,6 +349,7 @@ export const fontVariables = cn(fontGeistSans.variable, fontGeistMono.variable);
|
|
|
340
349
|
:root {
|
|
341
350
|
--font-sans: var(--font-geist-sans);
|
|
342
351
|
--font-mono: var(--font-geist-mono);
|
|
352
|
+
|
|
343
353
|
--input: var(--color-neutral-200);
|
|
344
354
|
--border: var(--color-neutral-200);
|
|
345
355
|
--ring: var(--color-neutral-400);
|
|
@@ -373,7 +383,8 @@ export const fontVariables = cn(fontGeistSans.variable, fontGeistMono.variable);
|
|
|
373
383
|
--chart-4: var(--color-amber-600);
|
|
374
384
|
--chart-5: var(--color-amber-500);
|
|
375
385
|
}
|
|
376
|
-
|
|
386
|
+
|
|
387
|
+
.dark {
|
|
377
388
|
--input: var(--color-neutral-700);
|
|
378
389
|
--border: --alpha(var(--color-neutral-700) / 50%);
|
|
379
390
|
--ring: var(--color-neutral-500);
|
|
@@ -409,523 +420,986 @@ export const fontVariables = cn(fontGeistSans.variable, fontGeistMono.variable);
|
|
|
409
420
|
}
|
|
410
421
|
}
|
|
411
422
|
`,
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
};
|
|
416
|
-
function updatePostcssConfig(projectDir) {
|
|
417
|
-
const postcssConfigPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, "postcss.config.mjs");
|
|
418
|
-
if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(postcssConfigPath)) return void console.warn(`⚠️ postcss.config.mjs not found, skipping update.`);
|
|
419
|
-
let content = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(postcssConfigPath, "utf8");
|
|
420
|
-
const typeComment = `/** @type {import('postcss-load-config').Config} */\n`;
|
|
421
|
-
if (content.includes(typeComment)) console.log(`📝 postcss.config.mjs already contains type comment, no changes made.`);
|
|
422
|
-
else {
|
|
423
|
-
content = content.replace("const config = {", `${typeComment}const config = {`);
|
|
424
|
-
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(postcssConfigPath, content);
|
|
425
|
-
console.log(`📝 Updated postcss.config.mjs with type comment.`);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
function updateLayoutFile(projectDir) {
|
|
429
|
-
const layoutPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, "src/app/layout.tsx");
|
|
430
|
-
if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(layoutPath)) return void console.warn(`⚠️ src/app/layout.tsx not found, skipping update.`);
|
|
431
|
-
let content = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(layoutPath, "utf8");
|
|
432
|
-
if (content.includes('<html className={cn(fontVariables, "antialiased")} lang="en">')) return void console.log(`📝 src/app/layout.tsx already uses fontVariables in html tag, no changes made.`);
|
|
433
|
-
const newImports = `import type { Metadata } from "next";
|
|
434
|
-
|
|
435
|
-
import { cn } from "@codefast/ui";
|
|
436
|
-
|
|
437
|
-
import { fontVariables } from "@/lib/fonts";
|
|
438
|
-
import "@/app/globals.css";`;
|
|
439
|
-
content = content.replaceAll(/import\s+{[^}]+}\s+from\s+["']next\/font\/google["'];\s*/g, "");
|
|
440
|
-
content = content.replace(/const\s+geistSans\s*=[^;]+;\s*const\s+geistMono\s*=[^;]+;\s*/, "");
|
|
441
|
-
content = content.replace(/import\s+type\s+{[^}]+}\s+from\s+["']next["'];\s*import\s+["']\.\/globals\.css["'];\s*/, newImports);
|
|
442
|
-
const htmlRegex = /<html\s+lang="en"\s*>/;
|
|
443
|
-
const newHtml = '<html className={cn(fontVariables, "antialiased")} lang="en">';
|
|
444
|
-
content = content.replace(htmlRegex, newHtml);
|
|
445
|
-
const bodyRegex = /<body\s+className={`[^`]*`}\s*>/;
|
|
446
|
-
const newBody = "<body>";
|
|
447
|
-
content = content.replace(bodyRegex, newBody);
|
|
448
|
-
try {
|
|
449
|
-
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(layoutPath, content);
|
|
450
|
-
console.log(`📝 Updated src/app/layout.tsx to use fontVariables in html tag and removed className from body`);
|
|
451
|
-
} catch (error) {
|
|
452
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
453
|
-
console.warn(`⚠️ Failed to update src/app/layout.tsx: ${errorMessage}`);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
function updatePackageJson(projectDir) {
|
|
457
|
-
const packageJsonPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, "package.json");
|
|
458
|
-
const packageJson = JSON.parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(packageJsonPath, "utf8"));
|
|
459
|
-
packageJson.scripts = {
|
|
460
|
-
...packageJson.scripts,
|
|
461
|
-
"deploy:preview": "vercel deploy --archive=tgz",
|
|
462
|
-
"deploy:prod": "vercel deploy --archive=tgz --prod",
|
|
463
|
-
format: 'prettier --write "**/*.{js,mjs,jsx,ts,tsx,json,css,md,mdx}"',
|
|
464
|
-
"format:check": 'prettier --check "**/*.{js,mjs,jsx,ts,tsx,json,css,md,mdx}"',
|
|
465
|
-
lint: "next lint --fix --max-warnings 0",
|
|
466
|
-
"lint:check": "next lint --max-warnings 0",
|
|
467
|
-
"package:install": "pnpm install",
|
|
468
|
-
"package:outdated": "pnpm outdated",
|
|
469
|
-
"package:upgrade": "pnpm update --latest",
|
|
470
|
-
preview: "pnpm build && pnpm start"
|
|
471
|
-
};
|
|
472
|
-
packageJson["simple-git-hooks"] = {
|
|
473
|
-
"pre-commit": "pnpm lint-staged",
|
|
474
|
-
"commit-msg": "pnpm commitlint --edit"
|
|
475
|
-
};
|
|
476
|
-
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
477
|
-
console.log(`📝 Updated package.json`);
|
|
478
|
-
}
|
|
479
|
-
function createConfigFiles(projectDir) {
|
|
480
|
-
console.log(`\n📝 Creating configuration files...`);
|
|
481
|
-
for (const [category, configs] of Object.entries(configGroups)){
|
|
482
|
-
console.log(`\n📂 Setting up ${category} configurations:`);
|
|
483
|
-
for (const { path: filePath, content, description } of configs){
|
|
484
|
-
const fullPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, filePath);
|
|
485
|
-
const dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(fullPath);
|
|
486
|
-
if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(dir)) __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].mkdirSync(dir, {
|
|
487
|
-
recursive: true
|
|
488
|
-
});
|
|
489
|
-
writeConfigFile(fullPath, content);
|
|
490
|
-
if (description) console.log(` ℹ️ ${filePath}: ${description}`);
|
|
491
|
-
}
|
|
423
|
+
description: "Global CSS variables for the application"
|
|
424
|
+
}
|
|
425
|
+
]
|
|
426
|
+
};
|
|
492
427
|
}
|
|
493
428
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
const packageJsonPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join(process.cwd(), "package.json");
|
|
503
|
-
if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.existsSync(packageJsonPath)) return void console.warn(`⚠️ package.json not found, skipping cleanup.`);
|
|
504
|
-
let packageJson;
|
|
505
|
-
try {
|
|
506
|
-
packageJson = JSON.parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.readFileSync(packageJsonPath, "utf8"));
|
|
507
|
-
} catch (error) {
|
|
508
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
509
|
-
console.warn(`⚠️ Error reading package.json: ${errorMessage}, skipping cleanup.`);
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
const dependencies = packageJson.dependencies ?? {};
|
|
513
|
-
const devDependencies = packageJson.devDependencies ?? {};
|
|
514
|
-
const packagesToRemove = PACKAGES_TO_REMOVE.filter((pkg)=>pkg in dependencies || pkg in devDependencies);
|
|
515
|
-
if (packagesToRemove.length > 0) runCommand(`pnpm remove ${packagesToRemove.join(" ")}`);
|
|
516
|
-
else console.log(`ℹ️ No unnecessary packages found in package.json to remove.`);
|
|
517
|
-
}
|
|
518
|
-
function checkEnvironment() {
|
|
519
|
-
try {
|
|
520
|
-
(0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.execSync)("pnpm --version", {
|
|
521
|
-
stdio: "ignore"
|
|
522
|
-
});
|
|
523
|
-
} catch {
|
|
524
|
-
console.error(`❌ PNPM chưa được cài đặt. Vui lòng cài đặt PNPM trước.`);
|
|
525
|
-
process.exit(1);
|
|
526
|
-
}
|
|
429
|
+
ConfigService = config_service_ts_decorate([
|
|
430
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)()
|
|
431
|
+
], ConfigService);
|
|
432
|
+
function create_project_use_case_ts_decorate(decorators, target, key, desc) {
|
|
433
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
434
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
435
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
436
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
527
437
|
}
|
|
528
|
-
function
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
438
|
+
function create_project_use_case_ts_metadata(k, v) {
|
|
439
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
440
|
+
}
|
|
441
|
+
function create_project_use_case_ts_param(paramIndex, decorator) {
|
|
442
|
+
return function(target, key) {
|
|
443
|
+
decorator(target, key, paramIndex);
|
|
444
|
+
};
|
|
532
445
|
}
|
|
533
|
-
|
|
534
|
-
|
|
446
|
+
class create_project_use_case_CreateProjectUseCase {
|
|
447
|
+
constructor(projectRepository, fileSystemPort, commandExecutorPort, promptPort, configService){
|
|
448
|
+
this.projectRepository = projectRepository;
|
|
449
|
+
this.fileSystemPort = fileSystemPort;
|
|
450
|
+
this.commandExecutorPort = commandExecutorPort;
|
|
451
|
+
this.promptPort = promptPort;
|
|
452
|
+
this.configService = configService;
|
|
453
|
+
}
|
|
454
|
+
async execute(projectName) {
|
|
535
455
|
try {
|
|
536
|
-
checkEnvironment();
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
console.log(`📂 Moved to ${projectName}`);
|
|
543
|
-
}
|
|
544
|
-
updateLayoutFile(process.cwd());
|
|
545
|
-
updatePostcssConfig(process.cwd());
|
|
546
|
-
installDependencies();
|
|
547
|
-
cleanupPackages();
|
|
548
|
-
createConfigFiles(process.cwd());
|
|
549
|
-
updatePackageJson(process.cwd());
|
|
550
|
-
console.log(`\n🔄 Activating git hooks...`);
|
|
551
|
-
runCommand("pnpm simple-git-hooks");
|
|
552
|
-
console.log(`\n📝 Formatting files with Prettier...`);
|
|
553
|
-
runCommand("pnpm format");
|
|
554
|
-
console.log(`\n✅ Project ${packageJsonExists ? "configured" : "created"} successfully!`);
|
|
555
|
-
console.log(`- Project: ${projectName}`);
|
|
556
|
-
console.log("- Next.js with TypeScript");
|
|
557
|
-
console.log("- TailwindCSS and @codefast/ui");
|
|
558
|
-
console.log("- ESLint, Prettier, Commitlint, and Git Hooks");
|
|
559
|
-
console.log("- Lint-staged for pre-commit checks");
|
|
560
|
-
console.log(`\n📁 Project directory: ${process.cwd()}`);
|
|
561
|
-
console.log(`\n🚀 To start development:`);
|
|
562
|
-
console.log(`cd ${projectName} && pnpm dev`);
|
|
456
|
+
this.commandExecutorPort.checkEnvironment();
|
|
457
|
+
const project = await this.checkExistingProject(projectName);
|
|
458
|
+
const configGroups = this.configService.getConfigGroups();
|
|
459
|
+
this.createOrConfigureProject(project, configGroups);
|
|
460
|
+
this.displaySuccessMessage(project);
|
|
461
|
+
return project;
|
|
563
462
|
} catch (error) {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
process.exit(1);
|
|
463
|
+
handleError(error, "Failed to create or configure project");
|
|
464
|
+
throw error;
|
|
567
465
|
} finally{
|
|
568
|
-
|
|
466
|
+
this.promptPort.close();
|
|
569
467
|
}
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
function makeRegexPrefixesToRemove(prefixes) {
|
|
573
|
-
const prefixPattern = prefixes.join("|");
|
|
574
|
-
return new RegExp(`^.?\\/?(?:${prefixPattern})\\/(.*)$`);
|
|
575
|
-
}
|
|
576
|
-
function processExportPath(modulePath, regexPattern) {
|
|
577
|
-
let processedPath = modulePath;
|
|
578
|
-
const match = processedPath.match(regexPattern);
|
|
579
|
-
if (match) {
|
|
580
|
-
const remainingPath = match[1];
|
|
581
|
-
processedPath = remainingPath.startsWith("./") ? remainingPath : `./${remainingPath}`;
|
|
582
|
-
}
|
|
583
|
-
return processedPath;
|
|
584
|
-
}
|
|
585
|
-
function analyzeImports(indexFilePath, packageConfig) {
|
|
586
|
-
const project = new __WEBPACK_EXTERNAL_MODULE_ts_morph_07c7ce60__.Project();
|
|
587
|
-
let sourceFile;
|
|
588
|
-
try {
|
|
589
|
-
sourceFile = project.addSourceFileAtPath(indexFilePath);
|
|
590
|
-
} catch (error) {
|
|
591
|
-
console.error(`Error loading source file at ${indexFilePath}:`, error);
|
|
592
|
-
return {
|
|
593
|
-
imports: []
|
|
594
|
-
};
|
|
595
468
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
if (parts.length < 2) continue;
|
|
607
|
-
let directory;
|
|
608
|
-
if (parts.length <= 1) directory = ".";
|
|
609
|
-
else {
|
|
610
|
-
directory = parts.slice(0, -1).join("/");
|
|
611
|
-
if (directory.startsWith("./")) directory = directory.slice(2);
|
|
469
|
+
async checkExistingProject(projectNameArg) {
|
|
470
|
+
return await this.projectRepository.checkExistingProject(projectNameArg);
|
|
471
|
+
}
|
|
472
|
+
createOrConfigureProject(project, configGroups) {
|
|
473
|
+
if (!project.packageJsonExists) {
|
|
474
|
+
console.log(`
|
|
475
|
+
\u{1F680} Starting project creation for ${project.name}...\n`);
|
|
476
|
+
this.projectRepository.createNextProject(project.name);
|
|
477
|
+
process.chdir(project.name);
|
|
478
|
+
console.log(`\u{1F4C2} Moved to ${project.name}`);
|
|
612
479
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
480
|
+
this.updateProjectFiles(project.directory);
|
|
481
|
+
this.commandExecutorPort.installDependencies();
|
|
482
|
+
this.commandExecutorPort.cleanupPackages();
|
|
483
|
+
this.fileSystemPort.createConfigFiles(project.directory, configGroups);
|
|
484
|
+
this.projectRepository.updateNextConfig(project.directory);
|
|
485
|
+
this.projectRepository.updatePackageJson(project.directory);
|
|
486
|
+
this.commandExecutorPort.enableGitHooks();
|
|
487
|
+
this.commandExecutorPort.runFormatter();
|
|
488
|
+
this.commandExecutorPort.runLinter();
|
|
621
489
|
}
|
|
622
|
-
|
|
623
|
-
|
|
490
|
+
updateProjectFiles(projectDir) {
|
|
491
|
+
this.projectRepository.updateLayoutFile(projectDir);
|
|
492
|
+
this.projectRepository.updatePageFile(projectDir);
|
|
493
|
+
this.projectRepository.updatePostcssConfig(projectDir);
|
|
494
|
+
}
|
|
495
|
+
displaySuccessMessage(project) {
|
|
496
|
+
console.log(`
|
|
497
|
+
\u{2705} Project ${project.packageJsonExists ? "configured" : "created"} successfully!`);
|
|
498
|
+
console.log(`- Project: ${project.name}`);
|
|
499
|
+
console.log("- Next.js with TypeScript");
|
|
500
|
+
console.log("- TailwindCSS and @codefast/ui");
|
|
501
|
+
console.log("- ESLint, Prettier, Commitlint, and Git Hooks");
|
|
502
|
+
console.log("- Lint-staged for pre-commit checks");
|
|
503
|
+
console.log(`
|
|
504
|
+
\u{1F4C1} Project directory: ${process.cwd()}`);
|
|
505
|
+
console.log(`
|
|
506
|
+
\u{1F680} To start development:`);
|
|
507
|
+
console.log(`${project.packageJsonExists ? `cd ${project.name} && ` : ""}pnpm dev`);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
create_project_use_case_CreateProjectUseCase = create_project_use_case_ts_decorate([
|
|
511
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)(),
|
|
512
|
+
create_project_use_case_ts_param(0, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.ProjectRepository)),
|
|
513
|
+
create_project_use_case_ts_param(1, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.FileSystemPort)),
|
|
514
|
+
create_project_use_case_ts_param(2, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.CommandExecutorPort)),
|
|
515
|
+
create_project_use_case_ts_param(3, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.PromptPort)),
|
|
516
|
+
create_project_use_case_ts_param(4, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.ConfigService)),
|
|
517
|
+
create_project_use_case_ts_metadata("design:type", Function),
|
|
518
|
+
create_project_use_case_ts_metadata("design:paramtypes", [
|
|
519
|
+
"undefined" == typeof ProjectRepositoryInterface ? Object : ProjectRepositoryInterface,
|
|
520
|
+
"undefined" == typeof FileSystemPort ? Object : FileSystemPort,
|
|
521
|
+
"undefined" == typeof CommandExecutorPort ? Object : CommandExecutorPort,
|
|
522
|
+
"undefined" == typeof PromptPort ? Object : PromptPort,
|
|
523
|
+
void 0 === ConfigService ? Object : ConfigService
|
|
524
|
+
])
|
|
525
|
+
], create_project_use_case_CreateProjectUseCase);
|
|
526
|
+
function update_exports_use_case_ts_decorate(decorators, target, key, desc) {
|
|
527
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
528
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
529
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
530
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
531
|
+
}
|
|
532
|
+
function update_exports_use_case_ts_metadata(k, v) {
|
|
533
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
534
|
+
}
|
|
535
|
+
function update_exports_use_case_ts_param(paramIndex, decorator) {
|
|
536
|
+
return function(target, key) {
|
|
537
|
+
decorator(target, key, paramIndex);
|
|
624
538
|
};
|
|
625
539
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
540
|
+
class update_exports_use_case_UpdateExportsUseCase {
|
|
541
|
+
constructor(packageRepository){
|
|
542
|
+
this.packageRepository = packageRepository;
|
|
543
|
+
}
|
|
544
|
+
async execute(options) {
|
|
545
|
+
try {
|
|
546
|
+
console.info("\u2662\u2012 Searching for packages...");
|
|
547
|
+
const packageJsonPaths = await this.packageRepository.findAllPackages(options.configPath);
|
|
548
|
+
if (0 === packageJsonPaths.length) return void console.warn("No packages found.");
|
|
549
|
+
console.log(` Found ${packageJsonPaths.length} packages.`);
|
|
550
|
+
let successCount = 0;
|
|
551
|
+
let skipCount = 0;
|
|
552
|
+
let errorCount = 0;
|
|
553
|
+
for (const packageJsonPath of packageJsonPaths){
|
|
554
|
+
const result = this.packageRepository.processPackage(packageJsonPath, options);
|
|
555
|
+
if (result) successCount++;
|
|
556
|
+
else if (options.packageFilter) skipCount++;
|
|
557
|
+
else errorCount++;
|
|
558
|
+
}
|
|
559
|
+
console.log("\u2662\u2012 Completed exports update.\n");
|
|
560
|
+
console.info(`Stats: ${successCount} succeeded, ${skipCount} skipped, ${errorCount} failed`);
|
|
561
|
+
} catch (error) {
|
|
562
|
+
handleError(error, "Error processing packages");
|
|
563
|
+
throw error;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
update_exports_use_case_UpdateExportsUseCase = update_exports_use_case_ts_decorate([
|
|
568
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)(),
|
|
569
|
+
update_exports_use_case_ts_param(0, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.PackageRepository)),
|
|
570
|
+
update_exports_use_case_ts_metadata("design:type", Function),
|
|
571
|
+
update_exports_use_case_ts_metadata("design:paramtypes", [
|
|
572
|
+
"undefined" == typeof PackageRepository ? Object : PackageRepository
|
|
573
|
+
])
|
|
574
|
+
], update_exports_use_case_UpdateExportsUseCase);
|
|
575
|
+
function cli_adapter_ts_decorate(decorators, target, key, desc) {
|
|
576
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
577
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
578
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
579
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
580
|
+
}
|
|
581
|
+
function cli_adapter_ts_metadata(k, v) {
|
|
582
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
583
|
+
}
|
|
584
|
+
function cli_adapter_ts_param(paramIndex, decorator) {
|
|
585
|
+
return function(target, key) {
|
|
586
|
+
decorator(target, key, paramIndex);
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
class CLIAdapter {
|
|
590
|
+
constructor(createProjectCommand, updateExportsCommand, packageInfoService){
|
|
591
|
+
this.createProjectCommand = createProjectCommand;
|
|
592
|
+
this.updateExportsCommand = updateExportsCommand;
|
|
593
|
+
this.packageInfoService = packageInfoService;
|
|
594
|
+
}
|
|
595
|
+
initialize() {
|
|
596
|
+
const program = new __WEBPACK_EXTERNAL_MODULE_commander__.Command();
|
|
597
|
+
program.name("codefast").description("CodeFast CLI - A development toolkit for CodeFast.").version(this.packageInfoService.getPackageVersion(), "-v, --version", "display CLI version").addCommand(this.createProjectCommand.getCommand()).addCommand(this.updateExportsCommand.getCommand()).parse(process.argv);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
CLIAdapter = cli_adapter_ts_decorate([
|
|
601
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)(),
|
|
602
|
+
cli_adapter_ts_param(0, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.CreateProjectCommand)),
|
|
603
|
+
cli_adapter_ts_param(1, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.UpdateExportsCommand)),
|
|
604
|
+
cli_adapter_ts_param(2, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.PackageInfoService)),
|
|
605
|
+
cli_adapter_ts_metadata("design:type", Function),
|
|
606
|
+
cli_adapter_ts_metadata("design:paramtypes", [
|
|
607
|
+
void 0 === CreateProjectCommand ? Object : CreateProjectCommand,
|
|
608
|
+
void 0 === UpdateExportsCommand ? Object : UpdateExportsCommand,
|
|
609
|
+
"undefined" == typeof PackageInfoServiceInterface ? Object : PackageInfoServiceInterface
|
|
610
|
+
])
|
|
611
|
+
], CLIAdapter);
|
|
612
|
+
const packageConfigSchema = __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
613
|
+
cjsOutputPattern: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("Output pattern for CommonJS format, e.g., './dist/cjs/{dir}/{name}.cjs'"),
|
|
614
|
+
esmOutputPattern: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("Output pattern for ESM format, e.g., './dist/esm/{dir}/{name}.js'"),
|
|
615
|
+
packageJsonPath: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("Path to the package.json file, e.g., 'package.json'"),
|
|
616
|
+
srcIndexPath: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("Path to the source index file, e.g., 'src/index.ts'"),
|
|
617
|
+
typesOutputCjsPattern: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("Output pattern for CommonJS type declarations, e.g., './dist/types/{dir}/{name}.d.cts'"),
|
|
618
|
+
typesOutputPattern: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("Output pattern for type declarations, e.g., './dist/types/{dir}/{name}.d.ts'"),
|
|
619
|
+
exportPathPrefixesToRemove: __WEBPACK_EXTERNAL_MODULE_zod__.z.array(__WEBPACK_EXTERNAL_MODULE_zod__.z.string()).optional().describe("Prefixes to remove from export paths, e.g., ['components']")
|
|
634
620
|
});
|
|
635
|
-
const
|
|
636
|
-
customPackageConfigs: __WEBPACK_EXTERNAL_MODULE_zod__.z.record(__WEBPACK_EXTERNAL_MODULE_zod__.z.string(),
|
|
637
|
-
defaultPackageConfig:
|
|
638
|
-
packagesGlob: __WEBPACK_EXTERNAL_MODULE_zod__.z.string()
|
|
621
|
+
const scriptConfigSchema = __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
622
|
+
customPackageConfigs: __WEBPACK_EXTERNAL_MODULE_zod__.z.record(__WEBPACK_EXTERNAL_MODULE_zod__.z.string(), packageConfigSchema.partial()).describe("Custom configurations for specific packages"),
|
|
623
|
+
defaultPackageConfig: packageConfigSchema.describe("Default configuration applied to all packages unless overridden"),
|
|
624
|
+
packagesGlob: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("Glob pattern to find package.json files, e.g., './packages/**/package.json'")
|
|
639
625
|
});
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
626
|
+
__WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
627
|
+
directory: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("Directory containing the import, e.g., 'components'"),
|
|
628
|
+
exportPath: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("Resolved export path from the directory, e.g., './button'"),
|
|
629
|
+
name: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("Name of the import, e.g., 'Button'"),
|
|
630
|
+
originalPath: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("Original unresolved path, e.g., './components/button'")
|
|
631
|
+
});
|
|
632
|
+
const exportConfigSchema = __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
633
|
+
import: __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
634
|
+
default: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("ESM default export path"),
|
|
635
|
+
types: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("ESM types export path")
|
|
636
|
+
}),
|
|
637
|
+
require: __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
638
|
+
default: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("CommonJS default export path"),
|
|
639
|
+
types: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("CommonJS types export path")
|
|
640
|
+
})
|
|
641
|
+
});
|
|
642
|
+
const PackageExportsSchema = __WEBPACK_EXTERNAL_MODULE_zod__.z.record(__WEBPACK_EXTERNAL_MODULE_zod__.z.string(), __WEBPACK_EXTERNAL_MODULE_zod__.z.union([
|
|
643
|
+
exportConfigSchema,
|
|
644
|
+
__WEBPACK_EXTERNAL_MODULE_zod__.z.string()
|
|
645
|
+
]));
|
|
646
|
+
const packageJsonSchema = __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
647
|
+
dependencies: __WEBPACK_EXTERNAL_MODULE_zod__.z.record(__WEBPACK_EXTERNAL_MODULE_zod__.z.string(), __WEBPACK_EXTERNAL_MODULE_zod__.z.string()).optional().describe("List of runtime dependencies with their versions"),
|
|
648
|
+
devDependencies: __WEBPACK_EXTERNAL_MODULE_zod__.z.record(__WEBPACK_EXTERNAL_MODULE_zod__.z.string(), __WEBPACK_EXTERNAL_MODULE_zod__.z.string()).optional().describe("List of development dependencies with their versions"),
|
|
649
|
+
exports: PackageExportsSchema.optional().describe("Export mappings for the package"),
|
|
650
|
+
name: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("Name of the package"),
|
|
651
|
+
scripts: __WEBPACK_EXTERNAL_MODULE_zod__.z.record(__WEBPACK_EXTERNAL_MODULE_zod__.z.string(), __WEBPACK_EXTERNAL_MODULE_zod__.z.string()).describe("Script commands defined for the package"),
|
|
652
|
+
"simple-git-hooks": __WEBPACK_EXTERNAL_MODULE_zod__.z.record(__WEBPACK_EXTERNAL_MODULE_zod__.z.string(), __WEBPACK_EXTERNAL_MODULE_zod__.z.string()).optional().describe("Git hooks configuration for the package"),
|
|
653
|
+
version: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().optional().describe("Version of the package")
|
|
654
|
+
}).catchall(__WEBPACK_EXTERNAL_MODULE_zod__.z.unknown());
|
|
655
|
+
function node_command_executor_adapter_ts_decorate(decorators, target, key, desc) {
|
|
656
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
657
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
658
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
659
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
660
|
+
}
|
|
661
|
+
function node_command_executor_adapter_ts_metadata(k, v) {
|
|
662
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
663
|
+
}
|
|
664
|
+
function node_command_executor_adapter_ts_param(paramIndex, decorator) {
|
|
665
|
+
return function(target, key) {
|
|
666
|
+
decorator(target, key, paramIndex);
|
|
670
667
|
};
|
|
671
668
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
},
|
|
688
|
-
"@codefast/style-guide": {
|
|
689
|
-
exportPathPrefixesToRemove: [
|
|
690
|
-
"configs"
|
|
691
|
-
]
|
|
669
|
+
class NodeCommandExecutorAdapter {
|
|
670
|
+
constructor(fileSystemPort, dependencyConfigService){
|
|
671
|
+
this.fileSystemPort = fileSystemPort;
|
|
672
|
+
this.dependencyConfigService = dependencyConfigService;
|
|
673
|
+
}
|
|
674
|
+
runCommand(command) {
|
|
675
|
+
(0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.execSync)(command, {
|
|
676
|
+
stdio: "inherit"
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
checkEnvironment() {
|
|
680
|
+
try {
|
|
681
|
+
this.runCommand("pnpm --version");
|
|
682
|
+
} catch {
|
|
683
|
+
throw new Error("PNPM is not installed. Please install PNPM first.");
|
|
692
684
|
}
|
|
693
685
|
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
const
|
|
700
|
-
const
|
|
701
|
-
|
|
686
|
+
installDependencies() {
|
|
687
|
+
console.log(`
|
|
688
|
+
\u{1F4DA} Installing dependencies...`);
|
|
689
|
+
const mainDependencies = this.dependencyConfigService.getMainDependencies();
|
|
690
|
+
if (mainDependencies.length > 0) this.runCommand(`pnpm add ${mainDependencies.join(" ")}`);
|
|
691
|
+
const devDependencies = this.dependencyConfigService.getDevDependencies();
|
|
692
|
+
const allDevDependencies = Object.values(devDependencies).flat().join(" ");
|
|
693
|
+
if (allDevDependencies) this.runCommand(`pnpm add -D ${allDevDependencies}`);
|
|
694
|
+
}
|
|
695
|
+
cleanupPackages() {
|
|
696
|
+
console.log(`
|
|
697
|
+
\u{1F9F9} Cleaning up unnecessary packages...`);
|
|
698
|
+
const packageJsonPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), "package.json");
|
|
699
|
+
if (!this.fileSystemPort.exists(packageJsonPath)) return void console.warn(`\u{26A0}\u{FE0F} package.json not found, skipping cleanup.`);
|
|
700
|
+
let packageJson;
|
|
701
|
+
try {
|
|
702
|
+
packageJson = packageJsonSchema.parse(JSON.parse(this.fileSystemPort.readFile(packageJsonPath)));
|
|
703
|
+
} catch (error) {
|
|
704
|
+
console.warn(`\u{26A0}\u{FE0F} Error reading package.json: ${error instanceof Error ? error.message : "Unknown error"}, skipping cleanup.`);
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
const dependencies = packageJson.dependencies ?? {};
|
|
708
|
+
const devDependencies = packageJson.devDependencies ?? {};
|
|
709
|
+
const packagesToRemove = this.dependencyConfigService.getPackagesToRemove().filter((pkg)=>pkg in dependencies || pkg in devDependencies);
|
|
710
|
+
if (packagesToRemove.length > 0) this.runCommand(`pnpm remove ${packagesToRemove.join(" ")}`);
|
|
711
|
+
else console.log(`\u{2139}\u{FE0F} No unnecessary packages found in package.json to remove.`);
|
|
712
|
+
}
|
|
713
|
+
enableGitHooks() {
|
|
714
|
+
console.log(`
|
|
715
|
+
\u{1F504} Activating git hooks...`);
|
|
716
|
+
this.runCommand("pnpm simple-git-hooks");
|
|
717
|
+
}
|
|
718
|
+
runFormatter() {
|
|
719
|
+
console.log(`
|
|
720
|
+
\u{1F4DD} Formatting files with Prettier...`);
|
|
721
|
+
this.runCommand("pnpm format");
|
|
722
|
+
}
|
|
723
|
+
runLinter() {
|
|
724
|
+
console.log(`
|
|
725
|
+
\u{1F50D} Running ESLint to check code style...`);
|
|
726
|
+
this.runCommand("pnpm lint");
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
NodeCommandExecutorAdapter = node_command_executor_adapter_ts_decorate([
|
|
730
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)(),
|
|
731
|
+
node_command_executor_adapter_ts_param(0, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.FileSystemPort)),
|
|
732
|
+
node_command_executor_adapter_ts_param(1, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.DependencyConfigService)),
|
|
733
|
+
node_command_executor_adapter_ts_metadata("design:type", Function),
|
|
734
|
+
node_command_executor_adapter_ts_metadata("design:paramtypes", [
|
|
735
|
+
"undefined" == typeof FileSystemPort ? Object : FileSystemPort,
|
|
736
|
+
"undefined" == typeof DependencyConfigServiceInterface ? Object : DependencyConfigServiceInterface
|
|
737
|
+
])
|
|
738
|
+
], NodeCommandExecutorAdapter);
|
|
739
|
+
function node_file_system_adapter_ts_decorate(decorators, target, key, desc) {
|
|
740
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
741
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
742
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
743
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
744
|
+
}
|
|
745
|
+
class NodeFileSystemAdapter {
|
|
746
|
+
exists(filePath) {
|
|
702
747
|
return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(filePath);
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
},
|
|
709
|
-
readJsonFile (filePath) {
|
|
748
|
+
}
|
|
749
|
+
access(filePath) {
|
|
750
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].accessSync(filePath, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].constants.W_OK);
|
|
751
|
+
}
|
|
752
|
+
readFile(filePath) {
|
|
710
753
|
try {
|
|
711
|
-
|
|
712
|
-
return JSON.parse(content);
|
|
754
|
+
return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(filePath, "utf8");
|
|
713
755
|
} catch (error) {
|
|
714
|
-
|
|
715
|
-
return null;
|
|
756
|
+
throw new Error(`Failed to read file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
716
757
|
}
|
|
717
|
-
}
|
|
718
|
-
|
|
758
|
+
}
|
|
759
|
+
writeFile(filePath, content) {
|
|
719
760
|
try {
|
|
720
|
-
|
|
721
|
-
|
|
761
|
+
const dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(filePath);
|
|
762
|
+
this.createDirectory(dir);
|
|
763
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(filePath, content);
|
|
722
764
|
} catch (error) {
|
|
723
|
-
|
|
724
|
-
return false;
|
|
765
|
+
throw new Error(`Failed to write to file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
725
766
|
}
|
|
726
|
-
},
|
|
727
|
-
getAnalysisDir (packageDir) {
|
|
728
|
-
const outputDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(packageDir, EXPORTS_ANALYSIS_DIR);
|
|
729
|
-
this.ensureDirectoryExists(outputDir);
|
|
730
|
-
return outputDir;
|
|
731
|
-
},
|
|
732
|
-
createBackupFilename (baseFilename) {
|
|
733
|
-
const timestamp = new Date().toISOString().replaceAll(/[:.]/g, "-");
|
|
734
|
-
return `${baseFilename}.backup.${timestamp}`;
|
|
735
767
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
768
|
+
createDirectory(dirPath) {
|
|
769
|
+
if (!this.exists(dirPath)) __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].mkdirSync(dirPath, {
|
|
770
|
+
recursive: true
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
writeConfigFile(filePath, content) {
|
|
774
|
+
this.writeFile(filePath, content);
|
|
775
|
+
console.log(`\u{1F4DD} Created ${filePath}`);
|
|
776
|
+
}
|
|
777
|
+
createConfigFiles(projectDir, configGroups) {
|
|
778
|
+
console.log(`
|
|
779
|
+
\u{1F4DD} Creating configuration files...`);
|
|
780
|
+
for (const [category, configs] of Object.entries(configGroups)){
|
|
781
|
+
console.log(`
|
|
782
|
+
\u{1F4C2} Setting up ${category} configurations:`);
|
|
783
|
+
for (const config of configs){
|
|
784
|
+
const fullPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, config.path);
|
|
785
|
+
this.writeConfigFile(fullPath, config.content);
|
|
786
|
+
if (config.description) console.log(`\u{2139}\u{FE0F} ${config.path}: ${config.description}`);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
756
789
|
}
|
|
757
790
|
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
function
|
|
762
|
-
|
|
763
|
-
|
|
791
|
+
NodeFileSystemAdapter = node_file_system_adapter_ts_decorate([
|
|
792
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)()
|
|
793
|
+
], NodeFileSystemAdapter);
|
|
794
|
+
function node_prompt_adapter_ts_decorate(decorators, target, key, desc) {
|
|
795
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
796
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
797
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
798
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
764
799
|
}
|
|
765
|
-
function
|
|
766
|
-
|
|
800
|
+
function node_prompt_adapter_ts_metadata(k, v) {
|
|
801
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
767
802
|
}
|
|
768
|
-
|
|
769
|
-
|
|
803
|
+
class NodePromptAdapter {
|
|
804
|
+
constructor(){
|
|
805
|
+
this.rl = __WEBPACK_EXTERNAL_MODULE_node_readline_91c31510__["default"].createInterface({
|
|
806
|
+
input: process.stdin,
|
|
807
|
+
output: process.stdout
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
async prompt(message) {
|
|
811
|
+
return new Promise((resolve)=>{
|
|
812
|
+
this.rl.question(message, (answer)=>{
|
|
813
|
+
resolve(answer.trim());
|
|
814
|
+
});
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
close() {
|
|
818
|
+
this.rl.close();
|
|
819
|
+
}
|
|
770
820
|
}
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
821
|
+
NodePromptAdapter = node_prompt_adapter_ts_decorate([
|
|
822
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)(),
|
|
823
|
+
node_prompt_adapter_ts_metadata("design:type", Function),
|
|
824
|
+
node_prompt_adapter_ts_metadata("design:paramtypes", [])
|
|
825
|
+
], NodePromptAdapter);
|
|
826
|
+
function ts_morph_analysis_adapter_ts_decorate(decorators, target, key, desc) {
|
|
827
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
828
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
829
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
830
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
774
831
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
832
|
+
class TsMorphAnalysisAdapter {
|
|
833
|
+
analyzeImports(indexFilePath, packageConfig) {
|
|
834
|
+
const project = new __WEBPACK_EXTERNAL_MODULE_ts_morph_07c7ce60__.Project();
|
|
835
|
+
let sourceFile;
|
|
836
|
+
try {
|
|
837
|
+
sourceFile = project.addSourceFileAtPath(indexFilePath);
|
|
838
|
+
} catch (error) {
|
|
839
|
+
console.error(`Error loading source file at ${indexFilePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
840
|
+
return {
|
|
841
|
+
imports: []
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
const imports = [];
|
|
845
|
+
const prefixesToRemove = packageConfig.exportPathPrefixesToRemove ?? [];
|
|
846
|
+
const regexPattern = new RegExp(`^.?\\/?(?:${prefixesToRemove.join("|")})\\/(.*)$`);
|
|
847
|
+
for (const exportDecl of sourceFile.getExportDeclarations()){
|
|
848
|
+
let moduleSpecifier = exportDecl.getModuleSpecifierValue();
|
|
849
|
+
if (!moduleSpecifier) continue;
|
|
850
|
+
if (moduleSpecifier.startsWith("@/")) moduleSpecifier = `./${moduleSpecifier.slice(2)}`;
|
|
851
|
+
const isExternal = !moduleSpecifier.startsWith(".");
|
|
852
|
+
if (isExternal) continue;
|
|
853
|
+
const parts = moduleSpecifier.split("/").filter(Boolean);
|
|
854
|
+
if (parts.length < 2) continue;
|
|
855
|
+
let directory = parts.length <= 1 ? "." : parts.slice(0, -1).join("/");
|
|
856
|
+
if (directory.startsWith("./")) directory = directory.slice(2);
|
|
857
|
+
const name = parts.at(-1) ?? "";
|
|
858
|
+
const exportPath = this.processExportPath(moduleSpecifier, regexPattern);
|
|
859
|
+
imports.push({
|
|
860
|
+
originalPath: moduleSpecifier,
|
|
861
|
+
directory,
|
|
862
|
+
name,
|
|
863
|
+
exportPath
|
|
864
|
+
});
|
|
787
865
|
}
|
|
866
|
+
return {
|
|
867
|
+
imports
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
processExportPath(modulePath, regexPattern) {
|
|
871
|
+
const match = modulePath.match(regexPattern);
|
|
872
|
+
if (match) {
|
|
873
|
+
const remainingPath = match[1];
|
|
874
|
+
return remainingPath.startsWith("./") ? remainingPath : `./${remainingPath}`;
|
|
875
|
+
}
|
|
876
|
+
return modulePath;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
TsMorphAnalysisAdapter = ts_morph_analysis_adapter_ts_decorate([
|
|
880
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)()
|
|
881
|
+
], TsMorphAnalysisAdapter);
|
|
882
|
+
function file_system_package_repository_ts_decorate(decorators, target, key, desc) {
|
|
883
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
884
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
885
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
886
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
887
|
+
}
|
|
888
|
+
function file_system_package_repository_ts_metadata(k, v) {
|
|
889
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
890
|
+
}
|
|
891
|
+
function file_system_package_repository_ts_param(paramIndex, decorator) {
|
|
892
|
+
return function(target, key) {
|
|
893
|
+
decorator(target, key, paramIndex);
|
|
788
894
|
};
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
895
|
+
}
|
|
896
|
+
class FileSystemPackageRepository {
|
|
897
|
+
constructor(fileSystemPort, analysisPort, fileSystemUtility){
|
|
898
|
+
this.fileSystemPort = fileSystemPort;
|
|
899
|
+
this.analysisPort = analysisPort;
|
|
900
|
+
this.fileSystemUtility = fileSystemUtility;
|
|
901
|
+
this.DEFAULT_IGNORE_PATTERN = [
|
|
902
|
+
"**/node_modules/**"
|
|
903
|
+
];
|
|
904
|
+
this.cachedConfig = null;
|
|
905
|
+
this.defaultConfig = {
|
|
906
|
+
packagesGlob: "./packages/**/package.json",
|
|
907
|
+
defaultPackageConfig: {
|
|
908
|
+
cjsOutputPattern: "./dist/cjs/{dir}/{name}.cjs",
|
|
909
|
+
esmOutputPattern: "./dist/esm/{dir}/{name}.js",
|
|
910
|
+
packageJsonPath: "package.json",
|
|
911
|
+
srcIndexPath: "src/index.ts",
|
|
912
|
+
typesOutputCjsPattern: "./dist/types/{dir}/{name}.d.ts",
|
|
913
|
+
typesOutputPattern: "./dist/types/{dir}/{name}.d.ts"
|
|
800
914
|
},
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
915
|
+
customPackageConfigs: {
|
|
916
|
+
"@codefast/ui": {
|
|
917
|
+
exportPathPrefixesToRemove: [
|
|
918
|
+
"components"
|
|
919
|
+
]
|
|
920
|
+
},
|
|
921
|
+
"@codefast/style-guide": {
|
|
922
|
+
exportPathPrefixesToRemove: [
|
|
923
|
+
"configs"
|
|
924
|
+
]
|
|
925
|
+
}
|
|
804
926
|
}
|
|
805
927
|
};
|
|
806
928
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
console.
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
console.
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
console.
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
console.
|
|
855
|
-
|
|
929
|
+
async findAllPackages(configPath) {
|
|
930
|
+
const config = this.getConfig(configPath);
|
|
931
|
+
return await (0, __WEBPACK_EXTERNAL_MODULE_glob__.glob)(config.packagesGlob, {
|
|
932
|
+
ignore: this.DEFAULT_IGNORE_PATTERN
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
processPackage(packageJsonPath, options) {
|
|
936
|
+
const packageDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(packageJsonPath);
|
|
937
|
+
let packageJson;
|
|
938
|
+
try {
|
|
939
|
+
packageJson = JSON.parse(this.fileSystemPort.readFile(packageJsonPath));
|
|
940
|
+
} catch (error) {
|
|
941
|
+
console.error(`Failed to parse ${packageJsonPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
942
|
+
return false;
|
|
943
|
+
}
|
|
944
|
+
const packageName = packageJson.name;
|
|
945
|
+
if (options.packageFilter && packageName !== options.packageFilter) {
|
|
946
|
+
console.debug(`Skipping ${packageName} (does not match filter)`);
|
|
947
|
+
return false;
|
|
948
|
+
}
|
|
949
|
+
console.info(`\u{2662}\u{2012} Processing package: ${packageName}`);
|
|
950
|
+
const config = this.getConfig(options.configPath);
|
|
951
|
+
const packageConfig = this.getPackageConfig(packageName, config);
|
|
952
|
+
const srcIndexPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(packageDir, packageConfig.srcIndexPath);
|
|
953
|
+
if (!this.fileSystemPort.exists(srcIndexPath)) {
|
|
954
|
+
console.error(`\u{23B9} \u{26D4}\u{FE0E} Source file not found at ${srcIndexPath}`);
|
|
955
|
+
return false;
|
|
956
|
+
}
|
|
957
|
+
console.info(`\u{23B9} Analyzing imports from ${srcIndexPath}...`);
|
|
958
|
+
const analysis = this.analyzeImports(srcIndexPath, packageConfig);
|
|
959
|
+
if (0 === analysis.imports.length) {
|
|
960
|
+
console.warn(`\u{23B9} \u{26D4}\u{FE0E} No imports found to analyze in ${packageName}`);
|
|
961
|
+
return false;
|
|
962
|
+
}
|
|
963
|
+
console.log(`\u{23B9} Analysis complete. Found ${analysis.imports.length} subpath exports.`);
|
|
964
|
+
this.saveExportsAnalysis(packageDir, analysis);
|
|
965
|
+
const newExports = this.generateExports(packageName, analysis.imports, packageJson.exports ?? {}, config);
|
|
966
|
+
const currentExportsCount = packageJson.exports ? Object.keys(packageJson.exports).length : 0;
|
|
967
|
+
const newExportsCount = Object.keys(newExports).length;
|
|
968
|
+
console.info(`\u{23B9} Exports: ${currentExportsCount} -> ${newExportsCount}`);
|
|
969
|
+
if (options.dryRun) {
|
|
970
|
+
this.saveExportsPreview(packageDir, newExports);
|
|
971
|
+
console.warn(`\u{23B9} Saved exports preview to .exports-analysis`);
|
|
972
|
+
console.warn(`\u{23B9} Dry run: no changes saved for ${packageName}`);
|
|
973
|
+
return true;
|
|
974
|
+
}
|
|
975
|
+
this.fileSystemUtility.backupFile(packageJsonPath, ".exports-analysis");
|
|
976
|
+
console.log(`\u{23B9} Backed up ${packageJsonPath}`);
|
|
977
|
+
const updatedPackageJson = {
|
|
978
|
+
...packageJson,
|
|
979
|
+
exports: newExports
|
|
980
|
+
};
|
|
981
|
+
this.fileSystemPort.writeFile(packageJsonPath, `${JSON.stringify(updatedPackageJson, null, 2)}\n`);
|
|
982
|
+
console.log(`\u{23B9} Updated exports for ${packageName}`);
|
|
856
983
|
return true;
|
|
857
984
|
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
985
|
+
analyzeImports(indexFilePath, packageConfig) {
|
|
986
|
+
return this.analysisPort.analyzeImports(indexFilePath, packageConfig);
|
|
987
|
+
}
|
|
988
|
+
generateExports(packageName, imports, existingExports, config) {
|
|
989
|
+
const packageConfig = this.getPackageConfig(packageName, config);
|
|
990
|
+
const exports = {
|
|
991
|
+
".": existingExports["."] ?? {
|
|
992
|
+
import: {
|
|
993
|
+
default: "./dist/esm/index.js",
|
|
994
|
+
types: "./dist/types/index.d.ts"
|
|
995
|
+
},
|
|
996
|
+
require: {
|
|
997
|
+
default: "./dist/cjs/index.cjs",
|
|
998
|
+
types: "./dist/types/index.d.cts"
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
if (existingExports["./styles.css"]) exports["./styles.css"] = existingExports["./styles.css"];
|
|
1003
|
+
for (const importPath of imports){
|
|
1004
|
+
const { directory, name, exportPath } = importPath;
|
|
1005
|
+
const esmOutput = this.formatOutputPath(packageConfig.esmOutputPattern, directory, name);
|
|
1006
|
+
const cjsOutput = this.formatOutputPath(packageConfig.cjsOutputPattern, directory, name);
|
|
1007
|
+
const typesOutput = this.formatOutputPath(packageConfig.typesOutputPattern, directory, name);
|
|
1008
|
+
const typesCjsOutput = this.formatOutputPath(packageConfig.typesOutputCjsPattern, directory, name);
|
|
1009
|
+
exports[exportPath] = {
|
|
1010
|
+
import: {
|
|
1011
|
+
default: esmOutput,
|
|
1012
|
+
types: typesOutput
|
|
1013
|
+
},
|
|
1014
|
+
require: {
|
|
1015
|
+
default: cjsOutput,
|
|
1016
|
+
types: typesCjsOutput
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
return exports;
|
|
1021
|
+
}
|
|
1022
|
+
getConfig(configPath) {
|
|
1023
|
+
if (this.cachedConfig && !configPath) return this.cachedConfig;
|
|
1024
|
+
const userConfig = this.loadConfigFile(configPath);
|
|
1025
|
+
const config = (0, __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__.merge)({}, this.defaultConfig, userConfig);
|
|
1026
|
+
if (!configPath) this.cachedConfig = config;
|
|
1027
|
+
return config;
|
|
1028
|
+
}
|
|
1029
|
+
loadConfigFile(configPath) {
|
|
1030
|
+
if (!configPath) return {};
|
|
1031
|
+
try {
|
|
1032
|
+
const fullPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(configPath);
|
|
1033
|
+
if (!this.fileSystemPort.exists(fullPath)) {
|
|
1034
|
+
console.warn(`Configuration file not found at ${fullPath}`);
|
|
1035
|
+
return {};
|
|
1036
|
+
}
|
|
1037
|
+
const configContent = this.fileSystemPort.readFile(fullPath);
|
|
1038
|
+
return scriptConfigSchema.parse(JSON.parse(configContent));
|
|
1039
|
+
} catch (error) {
|
|
1040
|
+
console.error(`Error reading configuration file: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1041
|
+
return {};
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
getPackageConfig(packageName, config) {
|
|
1045
|
+
const customConfig = config.customPackageConfigs[packageName] ?? {};
|
|
1046
|
+
return {
|
|
1047
|
+
...config.defaultPackageConfig,
|
|
1048
|
+
...customConfig
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
formatOutputPath(pattern, directory, name) {
|
|
1052
|
+
const dirPart = "." === directory ? "" : `${directory}/`;
|
|
1053
|
+
return pattern.replace("{dir}/", dirPart).replace("{dir}", directory).replace("{name}", name);
|
|
1054
|
+
}
|
|
1055
|
+
saveExportsAnalysis(packageDir, analysis) {
|
|
1056
|
+
const outputDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(packageDir, ".exports-analysis");
|
|
1057
|
+
this.fileSystemPort.createDirectory(outputDir);
|
|
1058
|
+
this.fileSystemPort.writeFile(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(outputDir, "exports-analysis.json"), JSON.stringify(analysis, null, 2));
|
|
1059
|
+
}
|
|
1060
|
+
saveExportsPreview(packageDir, exports) {
|
|
1061
|
+
const outputDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(packageDir, ".exports-analysis");
|
|
1062
|
+
this.fileSystemPort.createDirectory(outputDir);
|
|
1063
|
+
this.fileSystemPort.writeFile(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(outputDir, "exports-preview.json"), JSON.stringify(exports, null, 2));
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
FileSystemPackageRepository = file_system_package_repository_ts_decorate([
|
|
1067
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)(),
|
|
1068
|
+
file_system_package_repository_ts_param(0, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.FileSystemPort)),
|
|
1069
|
+
file_system_package_repository_ts_param(1, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.AnalysisPort)),
|
|
1070
|
+
file_system_package_repository_ts_param(2, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.FileSystemUtility)),
|
|
1071
|
+
file_system_package_repository_ts_metadata("design:type", Function),
|
|
1072
|
+
file_system_package_repository_ts_metadata("design:paramtypes", [
|
|
1073
|
+
"undefined" == typeof FileSystemPort ? Object : FileSystemPort,
|
|
1074
|
+
"undefined" == typeof AnalysisPort ? Object : AnalysisPort,
|
|
1075
|
+
"undefined" == typeof FileSystemUtility ? Object : FileSystemUtility
|
|
1076
|
+
])
|
|
1077
|
+
], FileSystemPackageRepository);
|
|
1078
|
+
const projectSchema = __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
1079
|
+
name: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().min(1, "Project name cannot be empty").max(100, "Project name is too long (maximum 100 characters)").regex(/^[a-z0-9-~][a-z0-9-._~]*$/, {
|
|
1080
|
+
message: "Project name must be URL-friendly (letters, numbers, hyphens, underscores, dots; no @ or scoped packages)"
|
|
1081
|
+
}).refine((name)=>"." !== name && ".." !== name, {
|
|
1082
|
+
message: "Project name cannot be '.' or '..'"
|
|
1083
|
+
}).refine((name)=>!/^(?<reserved>CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i.test(name), {
|
|
1084
|
+
message: "Project name is a reserved system name"
|
|
1085
|
+
}),
|
|
1086
|
+
directory: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().describe("Project directory path"),
|
|
1087
|
+
packageJsonExists: __WEBPACK_EXTERNAL_MODULE_zod__.z.boolean().describe("Whether package.json exists in the project directory")
|
|
1088
|
+
});
|
|
1089
|
+
function file_system_project_repository_ts_decorate(decorators, target, key, desc) {
|
|
1090
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1091
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
1092
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1093
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1094
|
+
}
|
|
1095
|
+
function file_system_project_repository_ts_metadata(k, v) {
|
|
1096
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
1097
|
+
}
|
|
1098
|
+
function file_system_project_repository_ts_param(paramIndex, decorator) {
|
|
1099
|
+
return function(target, key) {
|
|
1100
|
+
decorator(target, key, paramIndex);
|
|
862
1101
|
};
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
1102
|
+
}
|
|
1103
|
+
class FileSystemProjectRepository {
|
|
1104
|
+
constructor(fileSystemPort, commandExecutorPort, promptPort, fileSystemUtility){
|
|
1105
|
+
this.fileSystemPort = fileSystemPort;
|
|
1106
|
+
this.commandExecutorPort = commandExecutorPort;
|
|
1107
|
+
this.promptPort = promptPort;
|
|
1108
|
+
this.fileSystemUtility = fileSystemUtility;
|
|
866
1109
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
let skipCount = 0;
|
|
879
|
-
let errorCount = 0;
|
|
880
|
-
for (const packageJsonPath of packageJsonPaths){
|
|
881
|
-
const result = processPackage(packageJsonPath, options);
|
|
882
|
-
if (result) successCount++;
|
|
883
|
-
else if (options.packageFilter) skipCount++;
|
|
884
|
-
else errorCount++;
|
|
1110
|
+
async checkExistingProject(projectName) {
|
|
1111
|
+
let fullPath = process.cwd();
|
|
1112
|
+
let name = "";
|
|
1113
|
+
const packageJsonPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), "package.json");
|
|
1114
|
+
const packageJsonExists = this.fileSystemPort.exists(packageJsonPath);
|
|
1115
|
+
if (packageJsonExists) {
|
|
1116
|
+
const result = packageJsonSchema.safeParse(JSON.parse(this.fileSystemPort.readFile(packageJsonPath)));
|
|
1117
|
+
if (result.success) name = result.data.name;
|
|
1118
|
+
} else {
|
|
1119
|
+
name = await this.getValidProjectName(projectName);
|
|
1120
|
+
fullPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(process.cwd(), name);
|
|
885
1121
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
throw error;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
function createUpdateExportsCommand(program) {
|
|
894
|
-
program.command("update-exports").description("Updates exports for all packages").option("-p, --package <package>", "Filter by package name").option("-d, --dry-run", "Run without making changes").option("-c, --config <path>", "Path to configuration file").action(async (options)=>{
|
|
895
|
-
const processorOptions = {
|
|
896
|
-
packageFilter: options.package,
|
|
897
|
-
dryRun: Boolean(options.dryRun),
|
|
898
|
-
configPath: options.config
|
|
1122
|
+
return {
|
|
1123
|
+
name,
|
|
1124
|
+
directory: fullPath,
|
|
1125
|
+
packageJsonExists
|
|
899
1126
|
};
|
|
1127
|
+
}
|
|
1128
|
+
createNextProject(projectName) {
|
|
1129
|
+
const flags = '--ts --tailwind --eslint --app --turbo --use-pnpm --src-dir --turbopack --import-alias "@/*"';
|
|
1130
|
+
this.commandExecutorPort.runCommand(`npx create-next-app@latest ${projectName} ${flags}`);
|
|
1131
|
+
}
|
|
1132
|
+
updateLayoutFile(projectDir) {
|
|
1133
|
+
const layoutPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, "src", "app", "layout.tsx");
|
|
1134
|
+
const htmlTarget = '<html className={cn(fontVariables, "antialiased")} lang="en">';
|
|
1135
|
+
this.fileSystemUtility.updateFileIfNeeded(layoutPath, (content)=>content.includes(htmlTarget), (content)=>{
|
|
1136
|
+
const newImports = `import type { Metadata } from "next";
|
|
1137
|
+
import type { JSX, ReactNode } from "react";
|
|
1138
|
+
import { cn } from "@codefast/ui";
|
|
1139
|
+
import { fontVariables } from "@/lib/fonts";
|
|
1140
|
+
import "@/app/globals.css";`;
|
|
1141
|
+
let result = content;
|
|
1142
|
+
result = result.replaceAll(/import\s+{[^}]+}\s+from\s+["']next\/font\/google["'];\s*/g, "");
|
|
1143
|
+
result = result.replace(/const\s+geistSans\s*=[^;]+;\s*const\s+geistMono\s*=[^;]+;\s*/, "");
|
|
1144
|
+
result = result.replace(/import\s+type\s+{[^}]+}\s+from\s+["']next["'];\s*import\s+["']\.\/globals\.css["'];\s*/, newImports);
|
|
1145
|
+
result = result.replace(/export default function RootLayout\({\s*children,\s*}\s*:\s*Readonly<{\s*children:\s*React\.ReactNode;\s*}>\)\s*{/, "export default function RootLayout({ children }: Readonly<{ children: ReactNode }>): JSX.Element {");
|
|
1146
|
+
result = result.replace(/<html\s+lang="en"\s*>/, htmlTarget);
|
|
1147
|
+
result = result.replace(/<body\s+className={`[^`]*`}\s*>/, "<body>");
|
|
1148
|
+
return result;
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
updatePageFile(projectDir) {
|
|
1152
|
+
const pagePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, "src", "app", "page.tsx");
|
|
1153
|
+
this.fileSystemUtility.updateFileIfNeeded(pagePath, (content)=>content.includes("): JSX.Element"), (content)=>{
|
|
1154
|
+
let result = content;
|
|
1155
|
+
if (!result.includes("import type { JSX }")) result = result.includes("import type {") ? result.replace(/import type {(?<types>[^}]+)} from "react";/, 'import type {$1, JSX } from "react";') : result.includes("import {") ? result.replace(/import {/, 'import type { JSX } from "react";\n\nimport {') : `import type { JSX } from "react";\n\n${result}`;
|
|
1156
|
+
result = result.replace(/export default function Home\(\) {/, "export default function Home(): JSX.Element {");
|
|
1157
|
+
return result;
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
updatePostcssConfig(projectDir) {
|
|
1161
|
+
const postcssConfigPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, "postcss.config.mjs");
|
|
1162
|
+
const typeComment = `/** @type {import('postcss-load-config').Config} */\n`;
|
|
1163
|
+
this.fileSystemUtility.updateFileIfNeeded(postcssConfigPath, (content)=>content.includes(typeComment), (content)=>content.replace("const config = {", `${typeComment}const config = {`));
|
|
1164
|
+
}
|
|
1165
|
+
updateNextConfig(projectDir) {
|
|
1166
|
+
const nextConfigPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, "next.config.ts");
|
|
1167
|
+
const optimizePackagesConfig = 'optimizePackageImports: ["@codefast/ui"]';
|
|
1168
|
+
this.fileSystemUtility.updateFileIfNeeded(nextConfigPath, (content)=>content.includes(optimizePackagesConfig), (content)=>content.replace(/const nextConfig: NextConfig = \{/, `const nextConfig: NextConfig = {
|
|
1169
|
+
experimental: {
|
|
1170
|
+
optimizePackageImports: ["@codefast/ui"],
|
|
1171
|
+
},`));
|
|
1172
|
+
}
|
|
1173
|
+
updatePackageJson(projectDir) {
|
|
1174
|
+
const packageJsonPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, "package.json");
|
|
1175
|
+
if (!this.fileSystemPort.exists(packageJsonPath)) return void console.warn(`\u{26A0}\u{FE0F} package.json not found, skipping update.`);
|
|
1176
|
+
let packageJson;
|
|
900
1177
|
try {
|
|
901
|
-
|
|
1178
|
+
packageJson = packageJsonSchema.parse(JSON.parse(this.fileSystemPort.readFile(packageJsonPath)));
|
|
1179
|
+
} catch {
|
|
1180
|
+
console.warn(`Failed to parse ${packageJsonPath}, skipping update.`);
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
packageJson.scripts = {
|
|
1184
|
+
...packageJson.scripts,
|
|
1185
|
+
"check-types": "tsc --noEmit",
|
|
1186
|
+
"deploy:preview": "vercel deploy --archive=tgz",
|
|
1187
|
+
"deploy:prod": "vercel deploy --archive=tgz --prod",
|
|
1188
|
+
format: "prettier --write --ignore-unknown .",
|
|
1189
|
+
"format:check": "prettier --check --ignore-unknown .",
|
|
1190
|
+
lint: "next lint --fix --max-warnings 0",
|
|
1191
|
+
"lint:check": "next lint --max-warnings 0",
|
|
1192
|
+
"package:install": "pnpm install",
|
|
1193
|
+
"package:outdated": "pnpm outdated",
|
|
1194
|
+
"package:upgrade": "pnpm update --latest",
|
|
1195
|
+
preview: "pnpm build && pnpm start"
|
|
1196
|
+
};
|
|
1197
|
+
packageJson["simple-git-hooks"] = {
|
|
1198
|
+
"pre-commit": "pnpm lint-staged",
|
|
1199
|
+
"commit-msg": "pnpm commitlint --edit"
|
|
1200
|
+
};
|
|
1201
|
+
this.fileSystemPort.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
1202
|
+
console.log(`\u{1F4DD} Updated ${packageJsonPath}`);
|
|
1203
|
+
}
|
|
1204
|
+
async getValidProjectName(initialName, attempts = 0, maxAttempts = 3) {
|
|
1205
|
+
const projectName = initialName ?? await this.promptPort.prompt("Enter project name: ");
|
|
1206
|
+
const result = projectSchema.safeParse({
|
|
1207
|
+
name: projectName,
|
|
1208
|
+
directory: "",
|
|
1209
|
+
packageJsonExists: false
|
|
1210
|
+
});
|
|
1211
|
+
if (result.success) {
|
|
1212
|
+
const fullPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(process.cwd(), projectName);
|
|
1213
|
+
if (this.fileSystemPort.exists(fullPath)) throw new Error(`A directory named "${projectName}" already exists.`);
|
|
1214
|
+
try {
|
|
1215
|
+
this.fileSystemPort.access(process.cwd());
|
|
1216
|
+
} catch {
|
|
1217
|
+
throw new Error("Cannot create project: No write permission in current directory.");
|
|
1218
|
+
}
|
|
1219
|
+
return projectName;
|
|
1220
|
+
}
|
|
1221
|
+
if (attempts >= maxAttempts - 1) throw new Error("Exceeded maximum attempts to enter a valid project name.");
|
|
1222
|
+
console.error(`\u{274C} ${result.error.message} (${maxAttempts - attempts - 1} attempts remaining)`);
|
|
1223
|
+
return this.getValidProjectName(void 0, attempts + 1, maxAttempts);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
FileSystemProjectRepository = file_system_project_repository_ts_decorate([
|
|
1227
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)(),
|
|
1228
|
+
file_system_project_repository_ts_param(0, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.FileSystemPort)),
|
|
1229
|
+
file_system_project_repository_ts_param(1, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.CommandExecutorPort)),
|
|
1230
|
+
file_system_project_repository_ts_param(2, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.PromptPort)),
|
|
1231
|
+
file_system_project_repository_ts_param(3, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.FileSystemUtility)),
|
|
1232
|
+
file_system_project_repository_ts_metadata("design:type", Function),
|
|
1233
|
+
file_system_project_repository_ts_metadata("design:paramtypes", [
|
|
1234
|
+
"undefined" == typeof FileSystemPort ? Object : FileSystemPort,
|
|
1235
|
+
"undefined" == typeof CommandExecutorPort ? Object : CommandExecutorPort,
|
|
1236
|
+
"undefined" == typeof PromptPort ? Object : PromptPort,
|
|
1237
|
+
"undefined" == typeof FileSystemUtility ? Object : FileSystemUtility
|
|
1238
|
+
])
|
|
1239
|
+
], FileSystemProjectRepository);
|
|
1240
|
+
function dependency_config_service_ts_decorate(decorators, target, key, desc) {
|
|
1241
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1242
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
1243
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1244
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1245
|
+
}
|
|
1246
|
+
class DependencyConfigService {
|
|
1247
|
+
getMainDependencies() {
|
|
1248
|
+
return this.MAIN_DEPENDENCIES;
|
|
1249
|
+
}
|
|
1250
|
+
getDevDependencies() {
|
|
1251
|
+
return this.DEV_DEPENDENCIES;
|
|
1252
|
+
}
|
|
1253
|
+
getPackagesToRemove() {
|
|
1254
|
+
return this.PACKAGES_TO_REMOVE;
|
|
1255
|
+
}
|
|
1256
|
+
constructor(){
|
|
1257
|
+
this.MAIN_DEPENDENCIES = [
|
|
1258
|
+
"@codefast/ui",
|
|
1259
|
+
"@codefast/hooks",
|
|
1260
|
+
"recharts",
|
|
1261
|
+
"react-hook-form",
|
|
1262
|
+
"next-themes",
|
|
1263
|
+
"date-fns",
|
|
1264
|
+
"lucide-react"
|
|
1265
|
+
];
|
|
1266
|
+
this.DEV_DEPENDENCIES = {
|
|
1267
|
+
commitLint: [
|
|
1268
|
+
"@commitlint/cli",
|
|
1269
|
+
"@commitlint/config-conventional",
|
|
1270
|
+
"@commitlint/types"
|
|
1271
|
+
],
|
|
1272
|
+
gitTools: [
|
|
1273
|
+
"simple-git-hooks"
|
|
1274
|
+
],
|
|
1275
|
+
formatting: [
|
|
1276
|
+
"prettier",
|
|
1277
|
+
"prettier-plugin-packagejson",
|
|
1278
|
+
"prettier-plugin-tailwindcss",
|
|
1279
|
+
"lint-staged"
|
|
1280
|
+
],
|
|
1281
|
+
linting: [
|
|
1282
|
+
"@codefast/eslint-config"
|
|
1283
|
+
]
|
|
1284
|
+
};
|
|
1285
|
+
this.PACKAGES_TO_REMOVE = [
|
|
1286
|
+
"@eslint/eslintrc",
|
|
1287
|
+
"eslint-config-next"
|
|
1288
|
+
];
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
DependencyConfigService = dependency_config_service_ts_decorate([
|
|
1292
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)()
|
|
1293
|
+
], DependencyConfigService);
|
|
1294
|
+
function node_package_info_service_ts_decorate(decorators, target, key, desc) {
|
|
1295
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1296
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
1297
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1298
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1299
|
+
}
|
|
1300
|
+
function node_package_info_service_ts_metadata(k, v) {
|
|
1301
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
1302
|
+
}
|
|
1303
|
+
function node_package_info_service_ts_param(paramIndex, decorator) {
|
|
1304
|
+
return function(target, key) {
|
|
1305
|
+
decorator(target, key, paramIndex);
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
class NodePackageInfoService {
|
|
1309
|
+
constructor(fileSystemPort){
|
|
1310
|
+
this.fileSystemPort = fileSystemPort;
|
|
1311
|
+
}
|
|
1312
|
+
getPackageVersion() {
|
|
1313
|
+
try {
|
|
1314
|
+
const __filename = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(import.meta.url);
|
|
1315
|
+
const __dirname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(__filename);
|
|
1316
|
+
const packageJsonPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(__dirname, "..", "package.json");
|
|
1317
|
+
const packageJsonResult = packageJsonSchema.parse(JSON.parse(this.fileSystemPort.readFile(packageJsonPath)));
|
|
1318
|
+
return packageJsonResult.version ?? "0.0.0";
|
|
902
1319
|
} catch (error) {
|
|
903
|
-
console.error
|
|
904
|
-
|
|
1320
|
+
console.warn(`Failed to read package version: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1321
|
+
return "unknown";
|
|
905
1322
|
}
|
|
906
|
-
}
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
NodePackageInfoService = node_package_info_service_ts_decorate([
|
|
1326
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)(),
|
|
1327
|
+
node_package_info_service_ts_param(0, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.FileSystemPort)),
|
|
1328
|
+
node_package_info_service_ts_metadata("design:type", Function),
|
|
1329
|
+
node_package_info_service_ts_metadata("design:paramtypes", [
|
|
1330
|
+
"undefined" == typeof FileSystemPort ? Object : FileSystemPort
|
|
1331
|
+
])
|
|
1332
|
+
], NodePackageInfoService);
|
|
1333
|
+
function file_system_utility_ts_decorate(decorators, target, key, desc) {
|
|
1334
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1335
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
1336
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1337
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
907
1338
|
}
|
|
908
|
-
function
|
|
909
|
-
|
|
910
|
-
const __dirname = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(__filename);
|
|
911
|
-
const packageJsonPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.resolve)(__dirname, "../package.json");
|
|
912
|
-
return JSON.parse((0, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.readFileSync)(packageJsonPath, "utf8"));
|
|
1339
|
+
function file_system_utility_ts_metadata(k, v) {
|
|
1340
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
913
1341
|
}
|
|
914
|
-
function
|
|
915
|
-
return
|
|
1342
|
+
function file_system_utility_ts_param(paramIndex, decorator) {
|
|
1343
|
+
return function(target, key) {
|
|
1344
|
+
decorator(target, key, paramIndex);
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
class file_system_utility_FileSystemUtility {
|
|
1348
|
+
constructor(fileSystemPort){
|
|
1349
|
+
this.fileSystemPort = fileSystemPort;
|
|
1350
|
+
}
|
|
1351
|
+
updateFileIfNeeded(filePath, checkFn, updateFn) {
|
|
1352
|
+
if (!this.fileSystemPort.exists(filePath)) return;
|
|
1353
|
+
const currentContent = this.fileSystemPort.readFile(filePath);
|
|
1354
|
+
if (checkFn(currentContent)) return void console.log(`\u{2139}\u{FE0F} ${filePath} is already up to date`);
|
|
1355
|
+
try {
|
|
1356
|
+
const updatedContent = updateFn(currentContent);
|
|
1357
|
+
this.fileSystemPort.writeFile(filePath, updatedContent);
|
|
1358
|
+
console.log(`\u{1F4DD} Updated ${filePath}`);
|
|
1359
|
+
} catch (error) {
|
|
1360
|
+
console.warn(`\u{26A0}\u{FE0F} Failed to update ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
backupFile(filePath, backupDir) {
|
|
1364
|
+
try {
|
|
1365
|
+
const content = this.fileSystemPort.readFile(filePath);
|
|
1366
|
+
const baseName = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filePath);
|
|
1367
|
+
const timestamp = new Date().toISOString().replaceAll(/[:.]/g, "-");
|
|
1368
|
+
const backupPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(filePath), backupDir, `${baseName}.backup.${timestamp}`);
|
|
1369
|
+
this.fileSystemPort.createDirectory(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(backupPath));
|
|
1370
|
+
this.fileSystemPort.writeFile(backupPath, content);
|
|
1371
|
+
} catch (error) {
|
|
1372
|
+
console.error(`Error backing up ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
916
1375
|
}
|
|
1376
|
+
file_system_utility_FileSystemUtility = file_system_utility_ts_decorate([
|
|
1377
|
+
(0, __WEBPACK_EXTERNAL_MODULE_inversify__.injectable)(),
|
|
1378
|
+
file_system_utility_ts_param(0, (0, __WEBPACK_EXTERNAL_MODULE_inversify__.inject)(TYPES.FileSystemPort)),
|
|
1379
|
+
file_system_utility_ts_metadata("design:type", Function),
|
|
1380
|
+
file_system_utility_ts_metadata("design:paramtypes", [
|
|
1381
|
+
"undefined" == typeof FileSystemPort ? Object : FileSystemPort
|
|
1382
|
+
])
|
|
1383
|
+
], file_system_utility_FileSystemUtility);
|
|
1384
|
+
const container = new __WEBPACK_EXTERNAL_MODULE_inversify__.Container();
|
|
1385
|
+
container.bind(TYPES.ProjectRepository).to(FileSystemProjectRepository).inSingletonScope();
|
|
1386
|
+
container.bind(TYPES.PackageRepository).to(FileSystemPackageRepository).inSingletonScope();
|
|
1387
|
+
container.bind(TYPES.PackageInfoService).to(NodePackageInfoService).inSingletonScope();
|
|
1388
|
+
container.bind(TYPES.DependencyConfigService).to(DependencyConfigService).inSingletonScope();
|
|
1389
|
+
container.bind(TYPES.ConfigService).to(ConfigService).inSingletonScope();
|
|
1390
|
+
container.bind(TYPES.FileSystemPort).to(NodeFileSystemAdapter).inSingletonScope();
|
|
1391
|
+
container.bind(TYPES.CommandExecutorPort).to(NodeCommandExecutorAdapter).inSingletonScope();
|
|
1392
|
+
container.bind(TYPES.PromptPort).to(NodePromptAdapter).inSingletonScope();
|
|
1393
|
+
container.bind(TYPES.AnalysisPort).to(TsMorphAnalysisAdapter).inSingletonScope();
|
|
1394
|
+
container.bind(TYPES.CreateProjectUseCase).to(create_project_use_case_CreateProjectUseCase).inSingletonScope();
|
|
1395
|
+
container.bind(TYPES.UpdateExportsUseCase).to(update_exports_use_case_UpdateExportsUseCase).inSingletonScope();
|
|
1396
|
+
container.bind(TYPES.CreateProjectCommand).to(CreateProjectCommand).inSingletonScope();
|
|
1397
|
+
container.bind(TYPES.UpdateExportsCommand).to(UpdateExportsCommand).inSingletonScope();
|
|
1398
|
+
container.bind(TYPES.CLIAdapter).to(CLIAdapter).inSingletonScope();
|
|
1399
|
+
container.bind(TYPES.FileSystemUtility).to(file_system_utility_FileSystemUtility).inSingletonScope();
|
|
917
1400
|
function main() {
|
|
918
|
-
const
|
|
919
|
-
|
|
920
|
-
createUpdateExportsCommand(program);
|
|
921
|
-
createProjectCommand(program);
|
|
922
|
-
program.action(()=>{
|
|
923
|
-
console.log('Use "codefast create-project" to create a new Next.js project.');
|
|
924
|
-
console.log('Use "codefast update-exports" to update exports.');
|
|
925
|
-
console.log('Run "codefast --help" to see all available commands.');
|
|
926
|
-
program.help();
|
|
927
|
-
});
|
|
928
|
-
program.parse(process.argv);
|
|
1401
|
+
const cliAdapter = container.get(TYPES.CLIAdapter);
|
|
1402
|
+
cliAdapter.initialize();
|
|
929
1403
|
}
|
|
930
1404
|
main();
|
|
931
1405
|
|