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