@configjs/cli 1.0.3 → 1.0.5
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/dist/{check-I62WT7NB.js → check-4Y5YGVVD.js} +6 -3
- package/dist/chunk-5S5KGCVY.js +276 -0
- package/dist/chunk-AMLNK7QR.js +417 -0
- package/dist/{chunk-T4WVSBI6.js → chunk-G5QBS6TL.js} +1 -1
- package/dist/chunk-QGM4M3NI.js +37 -0
- package/dist/{chunk-7ZLAP62L.js → chunk-UB6NBZEM.js} +265 -454
- package/dist/cli.js +23 -4
- package/dist/{install-ML3FB63K.js → install-M6JANAU5.js} +57 -239
- package/dist/installed-BXP7ZWOU.js +41 -0
- package/dist/{list-CBEUUZUI.js → list-HKDWBO2I.js} +3 -1
- package/dist/remove-ZZD67W4M.js +1736 -0
- package/package.json +1 -1
|
@@ -1,59 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
info(message, ...args) {
|
|
14
|
-
if (this.level <= 1 /* INFO */) {
|
|
15
|
-
console.log(pc.blue(`\u2139 ${message}`), ...args);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
success(message, ...args) {
|
|
19
|
-
if (this.level <= 1 /* INFO */) {
|
|
20
|
-
console.log(pc.green(`\u2713 ${message}`), ...args);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
warn(message, ...args) {
|
|
24
|
-
if (this.level <= 2 /* WARN */) {
|
|
25
|
-
console.warn(pc.yellow(`\u26A0 ${message}`), ...args);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
error(message, ...args) {
|
|
29
|
-
if (this.level <= 3 /* ERROR */) {
|
|
30
|
-
console.error(pc.red(`\u2716 ${message}`), ...args);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
step(message) {
|
|
34
|
-
if (this.level <= 1 /* INFO */) {
|
|
35
|
-
console.log(pc.cyan(`
|
|
36
|
-
\u2192 ${message}`));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
box(title, content) {
|
|
40
|
-
if (this.level <= 1 /* INFO */) {
|
|
41
|
-
const maxLength = Math.max(
|
|
42
|
-
title.length,
|
|
43
|
-
...content.map((line) => line.length)
|
|
44
|
-
);
|
|
45
|
-
const border = "\u2500".repeat(maxLength + 4);
|
|
46
|
-
console.log(pc.cyan(`\u250C${border}\u2510`));
|
|
47
|
-
console.log(pc.cyan(`\u2502 ${title.padEnd(maxLength)} \u2502`));
|
|
48
|
-
console.log(pc.cyan(`\u251C${border}\u2524`));
|
|
49
|
-
content.forEach((line) => {
|
|
50
|
-
console.log(pc.cyan(`\u2502 ${line.padEnd(maxLength)} \u2502`));
|
|
51
|
-
});
|
|
52
|
-
console.log(pc.cyan(`\u2514${border}\u2518`));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
var logger = new Logger();
|
|
1
|
+
import {
|
|
2
|
+
checkPathExists,
|
|
3
|
+
ensureDirectory,
|
|
4
|
+
installPackages,
|
|
5
|
+
logger,
|
|
6
|
+
normalizePath,
|
|
7
|
+
readFileContent,
|
|
8
|
+
readPackageJson,
|
|
9
|
+
writeFileContent,
|
|
10
|
+
writePackageJson
|
|
11
|
+
} from "./chunk-5S5KGCVY.js";
|
|
57
12
|
|
|
58
13
|
// src/types/index.ts
|
|
59
14
|
var Category = /* @__PURE__ */ ((Category2) => {
|
|
@@ -72,109 +27,7 @@ var Category = /* @__PURE__ */ ((Category2) => {
|
|
|
72
27
|
})(Category || {});
|
|
73
28
|
|
|
74
29
|
// src/core/config-writer.ts
|
|
75
|
-
import { resolve
|
|
76
|
-
|
|
77
|
-
// src/utils/fs-helpers.ts
|
|
78
|
-
import fs from "fs-extra";
|
|
79
|
-
import { resolve, dirname, extname } from "path";
|
|
80
|
-
function normalizePath(path) {
|
|
81
|
-
return path.replace(/\\/g, "/");
|
|
82
|
-
}
|
|
83
|
-
async function readPackageJson(root) {
|
|
84
|
-
const packageJsonPath = resolve(root, "package.json");
|
|
85
|
-
if (!await fs.pathExists(packageJsonPath)) {
|
|
86
|
-
throw new Error(`package.json not found at ${packageJsonPath}`);
|
|
87
|
-
}
|
|
88
|
-
try {
|
|
89
|
-
const pkg = await fs.readJson(packageJsonPath);
|
|
90
|
-
logger.debug(`Read package.json from ${packageJsonPath}`);
|
|
91
|
-
return pkg;
|
|
92
|
-
} catch (error) {
|
|
93
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
94
|
-
throw new Error(
|
|
95
|
-
`Failed to read package.json: ${errorMessage}. File may be invalid JSON.`
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
async function writePackageJson(root, pkg) {
|
|
100
|
-
const packageJsonPath = resolve(root, "package.json");
|
|
101
|
-
try {
|
|
102
|
-
await fs.writeJson(packageJsonPath, pkg, {
|
|
103
|
-
spaces: 2,
|
|
104
|
-
EOL: "\n"
|
|
105
|
-
});
|
|
106
|
-
logger.debug(`Wrote package.json to ${packageJsonPath}`);
|
|
107
|
-
} catch (error) {
|
|
108
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
109
|
-
throw new Error(`Failed to write package.json: ${errorMessage}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
async function readTsConfig(root) {
|
|
113
|
-
const possiblePaths = [
|
|
114
|
-
resolve(root, "tsconfig.json"),
|
|
115
|
-
resolve(root, "tsconfig.app.json"),
|
|
116
|
-
resolve(root, "tsconfig.node.json")
|
|
117
|
-
];
|
|
118
|
-
for (const tsconfigPath of possiblePaths) {
|
|
119
|
-
if (await fs.pathExists(tsconfigPath)) {
|
|
120
|
-
try {
|
|
121
|
-
const config = await fs.readJson(tsconfigPath);
|
|
122
|
-
logger.debug(`Read tsconfig.json from ${tsconfigPath}`);
|
|
123
|
-
return config;
|
|
124
|
-
} catch (error) {
|
|
125
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
126
|
-
logger.warn(
|
|
127
|
-
`Failed to parse tsconfig.json at ${tsconfigPath}: ${errorMessage}`
|
|
128
|
-
);
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
logger.debug("No tsconfig.json found");
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
async function checkPathExists(path) {
|
|
137
|
-
const fullPath = resolve(path);
|
|
138
|
-
return fs.pathExists(fullPath);
|
|
139
|
-
}
|
|
140
|
-
async function ensureDirectory(path) {
|
|
141
|
-
const fullPath = resolve(path);
|
|
142
|
-
try {
|
|
143
|
-
await fs.ensureDir(fullPath);
|
|
144
|
-
logger.debug(`Ensured directory exists: ${fullPath}`);
|
|
145
|
-
} catch (error) {
|
|
146
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
147
|
-
throw new Error(`Failed to create directory ${fullPath}: ${errorMessage}`);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
async function readFileContent(filePath, encoding = "utf-8") {
|
|
151
|
-
const fullPath = resolve(filePath);
|
|
152
|
-
if (!await fs.pathExists(fullPath)) {
|
|
153
|
-
throw new Error(`File not found: ${fullPath}`);
|
|
154
|
-
}
|
|
155
|
-
try {
|
|
156
|
-
const content = await fs.readFile(fullPath, encoding);
|
|
157
|
-
logger.debug(`Read file: ${fullPath}`);
|
|
158
|
-
return content;
|
|
159
|
-
} catch (error) {
|
|
160
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
161
|
-
throw new Error(`Failed to read file ${fullPath}: ${errorMessage}`);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
async function writeFileContent(filePath, content, encoding = "utf-8") {
|
|
165
|
-
const fullPath = resolve(filePath);
|
|
166
|
-
const parentDir = dirname(fullPath);
|
|
167
|
-
await ensureDirectory(parentDir);
|
|
168
|
-
try {
|
|
169
|
-
await fs.writeFile(fullPath, content, encoding);
|
|
170
|
-
logger.debug(`Wrote file: ${fullPath}`);
|
|
171
|
-
} catch (error) {
|
|
172
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
173
|
-
throw new Error(`Failed to write file ${fullPath}: ${errorMessage}`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// src/core/config-writer.ts
|
|
30
|
+
import { resolve, dirname } from "path";
|
|
178
31
|
var ConfigWriter = class {
|
|
179
32
|
/**
|
|
180
33
|
* @param backupManager - Gestionnaire de backups à utiliser
|
|
@@ -198,7 +51,7 @@ var ConfigWriter = class {
|
|
|
198
51
|
*/
|
|
199
52
|
async writeFile(path, content, options = {}) {
|
|
200
53
|
const { backup = true, ensureDir: shouldEnsureDir = true } = options;
|
|
201
|
-
const fullPath =
|
|
54
|
+
const fullPath = resolve(path);
|
|
202
55
|
const fileExists = await checkPathExists(fullPath);
|
|
203
56
|
if (fileExists && backup) {
|
|
204
57
|
try {
|
|
@@ -212,7 +65,7 @@ var ConfigWriter = class {
|
|
|
212
65
|
}
|
|
213
66
|
}
|
|
214
67
|
if (shouldEnsureDir) {
|
|
215
|
-
const parentDir =
|
|
68
|
+
const parentDir = dirname(fullPath);
|
|
216
69
|
await ensureDirectory(parentDir);
|
|
217
70
|
}
|
|
218
71
|
try {
|
|
@@ -238,7 +91,7 @@ var ConfigWriter = class {
|
|
|
238
91
|
* ```
|
|
239
92
|
*/
|
|
240
93
|
async createFile(path, content, options = {}) {
|
|
241
|
-
const fullPath =
|
|
94
|
+
const fullPath = resolve(path);
|
|
242
95
|
if (await checkPathExists(fullPath)) {
|
|
243
96
|
throw new Error(`File already exists: ${fullPath}`);
|
|
244
97
|
}
|
|
@@ -268,7 +121,7 @@ var ConfigWriter = class {
|
|
|
268
121
|
* ```
|
|
269
122
|
*/
|
|
270
123
|
async modifyPackageJson(projectRoot, modifier) {
|
|
271
|
-
const fullPath =
|
|
124
|
+
const fullPath = resolve(projectRoot);
|
|
272
125
|
let pkg;
|
|
273
126
|
try {
|
|
274
127
|
pkg = await readPackageJson(fullPath);
|
|
@@ -278,7 +131,7 @@ var ConfigWriter = class {
|
|
|
278
131
|
`Failed to read package.json: ${errorMessage}. Make sure you're in a valid project directory.`
|
|
279
132
|
);
|
|
280
133
|
}
|
|
281
|
-
const packageJsonPath =
|
|
134
|
+
const packageJsonPath = resolve(fullPath, "package.json");
|
|
282
135
|
if (this.backupManager.hasBackup(packageJsonPath)) {
|
|
283
136
|
} else {
|
|
284
137
|
try {
|
|
@@ -317,7 +170,7 @@ var ConfigWriter = class {
|
|
|
317
170
|
* ```
|
|
318
171
|
*/
|
|
319
172
|
async appendToFile(path, content, options = {}) {
|
|
320
|
-
const fullPath =
|
|
173
|
+
const fullPath = resolve(path);
|
|
321
174
|
const { backup = true } = options;
|
|
322
175
|
let existingContent = "";
|
|
323
176
|
const fileExists = await checkPathExists(fullPath);
|
|
@@ -361,7 +214,7 @@ var ConfigWriter = class {
|
|
|
361
214
|
* ```
|
|
362
215
|
*/
|
|
363
216
|
async injectImport(filePath, importStatement, options = {}) {
|
|
364
|
-
const fullPath =
|
|
217
|
+
const fullPath = resolve(filePath);
|
|
365
218
|
if (!await checkPathExists(fullPath)) {
|
|
366
219
|
throw new Error(`File not found: ${fullPath}`);
|
|
367
220
|
}
|
|
@@ -398,7 +251,7 @@ var ConfigWriter = class {
|
|
|
398
251
|
};
|
|
399
252
|
|
|
400
253
|
// src/core/backup-manager.ts
|
|
401
|
-
import { resolve as
|
|
254
|
+
import { resolve as resolve2 } from "path";
|
|
402
255
|
var BackupManager = class {
|
|
403
256
|
/**
|
|
404
257
|
* Map des backups : filePath -> content
|
|
@@ -417,7 +270,7 @@ var BackupManager = class {
|
|
|
417
270
|
* ```
|
|
418
271
|
*/
|
|
419
272
|
backup(filePath, content) {
|
|
420
|
-
const fullPath =
|
|
273
|
+
const fullPath = resolve2(filePath);
|
|
421
274
|
if (this.backups.has(fullPath)) {
|
|
422
275
|
logger.debug(`Backup already exists for ${fullPath}, overwriting`);
|
|
423
276
|
}
|
|
@@ -437,7 +290,7 @@ var BackupManager = class {
|
|
|
437
290
|
* ```
|
|
438
291
|
*/
|
|
439
292
|
async backupFromDisk(filePath) {
|
|
440
|
-
const fullPath =
|
|
293
|
+
const fullPath = resolve2(filePath);
|
|
441
294
|
if (!await checkPathExists(fullPath)) {
|
|
442
295
|
throw new Error(`File not found for backup: ${fullPath}`);
|
|
443
296
|
}
|
|
@@ -457,7 +310,7 @@ var BackupManager = class {
|
|
|
457
310
|
* ```
|
|
458
311
|
*/
|
|
459
312
|
async restore(filePath) {
|
|
460
|
-
const fullPath =
|
|
313
|
+
const fullPath = resolve2(filePath);
|
|
461
314
|
const backupContent = this.backups.get(fullPath);
|
|
462
315
|
if (!backupContent) {
|
|
463
316
|
throw new Error(
|
|
@@ -527,7 +380,7 @@ var BackupManager = class {
|
|
|
527
380
|
* ```
|
|
528
381
|
*/
|
|
529
382
|
hasBackup(filePath) {
|
|
530
|
-
const fullPath =
|
|
383
|
+
const fullPath = resolve2(filePath);
|
|
531
384
|
return this.backups.has(fullPath);
|
|
532
385
|
}
|
|
533
386
|
/**
|
|
@@ -545,7 +398,7 @@ var BackupManager = class {
|
|
|
545
398
|
* ```
|
|
546
399
|
*/
|
|
547
400
|
getBackup(filePath) {
|
|
548
|
-
const fullPath =
|
|
401
|
+
const fullPath = resolve2(filePath);
|
|
549
402
|
return this.backups.get(fullPath);
|
|
550
403
|
}
|
|
551
404
|
/**
|
|
@@ -560,7 +413,7 @@ var BackupManager = class {
|
|
|
560
413
|
* ```
|
|
561
414
|
*/
|
|
562
415
|
removeBackup(filePath) {
|
|
563
|
-
const fullPath =
|
|
416
|
+
const fullPath = resolve2(filePath);
|
|
564
417
|
const removed = this.backups.delete(fullPath);
|
|
565
418
|
if (removed) {
|
|
566
419
|
logger.debug(`Removed backup for: ${fullPath}`);
|
|
@@ -613,115 +466,7 @@ var BackupManager = class {
|
|
|
613
466
|
};
|
|
614
467
|
|
|
615
468
|
// src/plugins/routing/react-router.ts
|
|
616
|
-
import { resolve as
|
|
617
|
-
|
|
618
|
-
// src/utils/package-manager.ts
|
|
619
|
-
import { execa } from "execa";
|
|
620
|
-
import fs2 from "fs-extra";
|
|
621
|
-
import { resolve as resolve4, join } from "path";
|
|
622
|
-
async function detectPackageManager(projectRoot) {
|
|
623
|
-
const root = resolve4(projectRoot);
|
|
624
|
-
const lockfiles = [
|
|
625
|
-
{ file: "pnpm-lock.yaml", manager: "pnpm" },
|
|
626
|
-
{ file: "yarn.lock", manager: "yarn" },
|
|
627
|
-
{ file: "package-lock.json", manager: "npm" },
|
|
628
|
-
{ file: "bun.lockb", manager: "bun" }
|
|
629
|
-
];
|
|
630
|
-
for (const { file, manager } of lockfiles) {
|
|
631
|
-
const lockfilePath = join(root, file);
|
|
632
|
-
if (await fs2.pathExists(lockfilePath)) {
|
|
633
|
-
logger.debug(`Detected package manager: ${manager} (found ${file})`);
|
|
634
|
-
return manager;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
logger.debug("No lockfile found, defaulting to npm");
|
|
638
|
-
return "npm";
|
|
639
|
-
}
|
|
640
|
-
async function installPackages(packages, options) {
|
|
641
|
-
if (packages.length === 0) {
|
|
642
|
-
logger.warn("No packages to install");
|
|
643
|
-
return { success: true, packages: [] };
|
|
644
|
-
}
|
|
645
|
-
const {
|
|
646
|
-
packageManager,
|
|
647
|
-
projectRoot,
|
|
648
|
-
dev = false,
|
|
649
|
-
exact = false,
|
|
650
|
-
silent = false
|
|
651
|
-
} = options;
|
|
652
|
-
logger.info(
|
|
653
|
-
`Installing ${packages.length} package(s) with ${packageManager}...`
|
|
654
|
-
);
|
|
655
|
-
try {
|
|
656
|
-
const command = getInstallCommand(packageManager, packages, { dev, exact });
|
|
657
|
-
const cwd = resolve4(projectRoot);
|
|
658
|
-
logger.debug(`Executing: ${command.join(" ")} in ${cwd}`);
|
|
659
|
-
const [cmd, ...args] = command;
|
|
660
|
-
if (!cmd) {
|
|
661
|
-
throw new Error("Command is empty");
|
|
662
|
-
}
|
|
663
|
-
const result = await execa(cmd, args, {
|
|
664
|
-
cwd,
|
|
665
|
-
stdio: silent ? "pipe" : "inherit",
|
|
666
|
-
env: {
|
|
667
|
-
...process.env,
|
|
668
|
-
// Désactiver les prompts interactifs
|
|
669
|
-
npm_config_yes: "true",
|
|
670
|
-
YARN_ENABLE_IMMUTABLE_INSTALLS: "false"
|
|
671
|
-
}
|
|
672
|
-
});
|
|
673
|
-
if (result.exitCode !== 0) {
|
|
674
|
-
throw new Error(`Installation failed with exit code ${result.exitCode}`);
|
|
675
|
-
}
|
|
676
|
-
logger.success(`Successfully installed ${packages.length} package(s)`);
|
|
677
|
-
return {
|
|
678
|
-
success: true,
|
|
679
|
-
packages
|
|
680
|
-
};
|
|
681
|
-
} catch (error) {
|
|
682
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
683
|
-
logger.error(`Failed to install packages: ${errorMessage}`);
|
|
684
|
-
return {
|
|
685
|
-
success: false,
|
|
686
|
-
packages,
|
|
687
|
-
error: errorMessage
|
|
688
|
-
};
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
function getInstallCommand(packageManager, packages, options) {
|
|
692
|
-
const { dev, exact } = options;
|
|
693
|
-
switch (packageManager) {
|
|
694
|
-
case "pnpm":
|
|
695
|
-
return [
|
|
696
|
-
"pnpm",
|
|
697
|
-
"add",
|
|
698
|
-
...dev ? ["-D"] : [],
|
|
699
|
-
...exact ? ["--save-exact"] : [],
|
|
700
|
-
...packages
|
|
701
|
-
];
|
|
702
|
-
case "yarn":
|
|
703
|
-
return [
|
|
704
|
-
"yarn",
|
|
705
|
-
"add",
|
|
706
|
-
...dev ? ["--dev"] : [],
|
|
707
|
-
...exact ? ["--exact"] : [],
|
|
708
|
-
...packages
|
|
709
|
-
];
|
|
710
|
-
case "bun":
|
|
711
|
-
return ["bun", "add", ...dev ? ["--dev"] : [], ...packages];
|
|
712
|
-
case "npm":
|
|
713
|
-
default:
|
|
714
|
-
return [
|
|
715
|
-
"npm",
|
|
716
|
-
"install",
|
|
717
|
-
...dev ? ["--save-dev"] : [],
|
|
718
|
-
...exact ? ["--save-exact"] : [],
|
|
719
|
-
...packages
|
|
720
|
-
];
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
// src/plugins/routing/react-router.ts
|
|
469
|
+
import { resolve as resolve3, join } from "path";
|
|
725
470
|
var reactRouterPlugin = {
|
|
726
471
|
name: "react-router-dom",
|
|
727
472
|
displayName: "React Router",
|
|
@@ -791,12 +536,12 @@ var reactRouterPlugin = {
|
|
|
791
536
|
const backupManager = new BackupManager();
|
|
792
537
|
const writer = new ConfigWriter(backupManager);
|
|
793
538
|
const files = [];
|
|
794
|
-
const srcDir =
|
|
539
|
+
const srcDir = resolve3(ctx.projectRoot, ctx.srcDir);
|
|
795
540
|
const extension = ctx.typescript ? "tsx" : "jsx";
|
|
796
541
|
try {
|
|
797
|
-
const routesDir =
|
|
542
|
+
const routesDir = join(srcDir, "routes");
|
|
798
543
|
await ensureDirectory(routesDir);
|
|
799
|
-
const routerPath =
|
|
544
|
+
const routerPath = join(srcDir, `router.${extension}`);
|
|
800
545
|
const routerContent = ctx.typescript ? getRouterContentTS() : getRouterContentJS();
|
|
801
546
|
await writer.createFile(routerPath, routerContent);
|
|
802
547
|
files.push({
|
|
@@ -806,7 +551,7 @@ var reactRouterPlugin = {
|
|
|
806
551
|
backup: false
|
|
807
552
|
});
|
|
808
553
|
logger.info(`Created router configuration: ${routerPath}`);
|
|
809
|
-
const homeRoutePath =
|
|
554
|
+
const homeRoutePath = join(routesDir, `Home.${extension}`);
|
|
810
555
|
const homeRouteContent = ctx.typescript ? getHomeRouteContentTS() : getHomeRouteContentJS();
|
|
811
556
|
await writer.createFile(homeRoutePath, homeRouteContent);
|
|
812
557
|
files.push({
|
|
@@ -816,7 +561,7 @@ var reactRouterPlugin = {
|
|
|
816
561
|
backup: false
|
|
817
562
|
});
|
|
818
563
|
logger.info(`Created example route: ${homeRoutePath}`);
|
|
819
|
-
const appPath =
|
|
564
|
+
const appPath = join(srcDir, `App.${extension}`);
|
|
820
565
|
const appExists = await checkPathExists(appPath);
|
|
821
566
|
if (appExists) {
|
|
822
567
|
const appContent = await readFileContent(appPath);
|
|
@@ -999,13 +744,31 @@ function injectRouterProvider(content, isTypeScript) {
|
|
|
999
744
|
importLines.splice(lastImportIndex + 1, 0, routerImport.trim());
|
|
1000
745
|
modifiedContent = importLines.join("\n");
|
|
1001
746
|
}
|
|
1002
|
-
const
|
|
747
|
+
const hasProvider = modifiedContent.includes("<Provider");
|
|
748
|
+
const appFunctionRegex = /(export\s+default\s+)?function\s+App\s*\([^)]*\)\s*\{[\s\S]*?return\s+\([\s\S]*?\)\s*;?\s*\n\s*\}/m;
|
|
1003
749
|
if (appFunctionRegex.test(modifiedContent)) {
|
|
1004
750
|
modifiedContent = modifiedContent.replace(appFunctionRegex, (match) => {
|
|
1005
751
|
const signatureMatch = match.match(
|
|
1006
752
|
/((export\s+default\s+)?function\s+App\s*\([^)]*\))/
|
|
1007
753
|
);
|
|
1008
754
|
if (signatureMatch) {
|
|
755
|
+
if (hasProvider) {
|
|
756
|
+
const providerMatch = match.match(
|
|
757
|
+
/<Provider[\s\S]*?>([\s\S]*?)<\/Provider>/m
|
|
758
|
+
);
|
|
759
|
+
if (providerMatch) {
|
|
760
|
+
const providerOpening = match.match(/<Provider[^>]*>/)?.[0] || "";
|
|
761
|
+
const returnStatement2 = ` return (
|
|
762
|
+
${providerOpening}
|
|
763
|
+
<RouterProvider router={router} />
|
|
764
|
+
</Provider>
|
|
765
|
+
)
|
|
766
|
+
`;
|
|
767
|
+
return `${signatureMatch[1]} {
|
|
768
|
+
${returnStatement2}}
|
|
769
|
+
`;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
1009
772
|
const returnStatement = isTypeScript ? " return <RouterProvider router={router} />\n" : " return <RouterProvider router={router} />\n";
|
|
1010
773
|
return `${signatureMatch[1]} {
|
|
1011
774
|
${returnStatement}}
|
|
@@ -1014,16 +777,32 @@ ${returnStatement}}
|
|
|
1014
777
|
return match;
|
|
1015
778
|
});
|
|
1016
779
|
} else {
|
|
1017
|
-
const
|
|
1018
|
-
if (
|
|
1019
|
-
modifiedContent = modifiedContent.replace(
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
780
|
+
const arrowFunctionRegex = /(const|let|var)\s+App\s*=\s*\([^)]*\)\s*=>\s*\{?[\s\S]*?return\s+[\s\S]*?\}?/m;
|
|
781
|
+
if (arrowFunctionRegex.test(modifiedContent)) {
|
|
782
|
+
modifiedContent = modifiedContent.replace(arrowFunctionRegex, (match) => {
|
|
783
|
+
if (hasProvider) {
|
|
784
|
+
const providerMatch = match.match(
|
|
785
|
+
/<Provider[\s\S]*?>([\s\S]*?)<\/Provider>/m
|
|
786
|
+
);
|
|
787
|
+
if (providerMatch) {
|
|
788
|
+
const providerOpening = match.match(/<Provider[^>]*>/)?.[0] || "";
|
|
789
|
+
return `const App = () => {
|
|
790
|
+
return (
|
|
791
|
+
${providerOpening}
|
|
792
|
+
<RouterProvider router={router} />
|
|
793
|
+
</Provider>
|
|
794
|
+
)
|
|
795
|
+
}`;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
return `const App = () => {
|
|
799
|
+
return <RouterProvider router={router} />
|
|
800
|
+
}`;
|
|
801
|
+
});
|
|
1023
802
|
} else {
|
|
1024
803
|
modifiedContent += `
|
|
1025
804
|
|
|
1026
|
-
|
|
805
|
+
const App = () => {
|
|
1027
806
|
return <RouterProvider router={router} />
|
|
1028
807
|
}
|
|
1029
808
|
|
|
@@ -1035,7 +814,7 @@ export default App
|
|
|
1035
814
|
}
|
|
1036
815
|
|
|
1037
816
|
// src/plugins/routing/tanstack-router.ts
|
|
1038
|
-
import { resolve as
|
|
817
|
+
import { resolve as resolve4, join as join2 } from "path";
|
|
1039
818
|
var tanstackRouterPlugin = {
|
|
1040
819
|
name: "@tanstack/react-router",
|
|
1041
820
|
displayName: "TanStack Router",
|
|
@@ -1106,12 +885,12 @@ var tanstackRouterPlugin = {
|
|
|
1106
885
|
const backupManager = new BackupManager();
|
|
1107
886
|
const writer = new ConfigWriter(backupManager);
|
|
1108
887
|
const files = [];
|
|
1109
|
-
const srcDir =
|
|
888
|
+
const srcDir = resolve4(ctx.projectRoot, ctx.srcDir);
|
|
1110
889
|
const extension = ctx.typescript ? "tsx" : "jsx";
|
|
1111
890
|
try {
|
|
1112
|
-
const routesDir =
|
|
891
|
+
const routesDir = join2(srcDir, "routes");
|
|
1113
892
|
await ensureDirectory(routesDir);
|
|
1114
|
-
const rootRoutePath =
|
|
893
|
+
const rootRoutePath = join2(routesDir, `__root.${extension}`);
|
|
1115
894
|
const rootRouteContent = ctx.typescript ? getRootRouteContentTS() : getRootRouteContentJS();
|
|
1116
895
|
await writer.createFile(rootRoutePath, rootRouteContent);
|
|
1117
896
|
files.push({
|
|
@@ -1121,7 +900,7 @@ var tanstackRouterPlugin = {
|
|
|
1121
900
|
backup: false
|
|
1122
901
|
});
|
|
1123
902
|
logger.info(`Created root route: ${rootRoutePath}`);
|
|
1124
|
-
const indexRoutePath =
|
|
903
|
+
const indexRoutePath = join2(routesDir, `index.${extension}`);
|
|
1125
904
|
const indexRouteContent = ctx.typescript ? getIndexRouteContentTS() : getIndexRouteContentJS();
|
|
1126
905
|
await writer.createFile(indexRoutePath, indexRouteContent);
|
|
1127
906
|
files.push({
|
|
@@ -1131,7 +910,7 @@ var tanstackRouterPlugin = {
|
|
|
1131
910
|
backup: false
|
|
1132
911
|
});
|
|
1133
912
|
logger.info(`Created index route: ${indexRoutePath}`);
|
|
1134
|
-
const aboutRoutePath =
|
|
913
|
+
const aboutRoutePath = join2(routesDir, `about.${extension}`);
|
|
1135
914
|
const aboutRouteContent = ctx.typescript ? getAboutRouteContentTS() : getAboutRouteContentJS();
|
|
1136
915
|
await writer.createFile(aboutRoutePath, aboutRouteContent);
|
|
1137
916
|
files.push({
|
|
@@ -1141,7 +920,7 @@ var tanstackRouterPlugin = {
|
|
|
1141
920
|
backup: false
|
|
1142
921
|
});
|
|
1143
922
|
logger.info(`Created about route: ${aboutRoutePath}`);
|
|
1144
|
-
const routerPath =
|
|
923
|
+
const routerPath = join2(srcDir, `router.${extension}`);
|
|
1145
924
|
const routerContent = ctx.typescript ? getRouterContentTS2() : getRouterContentJS2();
|
|
1146
925
|
await writer.createFile(routerPath, routerContent);
|
|
1147
926
|
files.push({
|
|
@@ -1151,7 +930,7 @@ var tanstackRouterPlugin = {
|
|
|
1151
930
|
backup: false
|
|
1152
931
|
});
|
|
1153
932
|
logger.info(`Created router configuration: ${routerPath}`);
|
|
1154
|
-
const appPath =
|
|
933
|
+
const appPath = join2(srcDir, `App.${extension}`);
|
|
1155
934
|
const appExists = await checkPathExists(appPath);
|
|
1156
935
|
if (appExists) {
|
|
1157
936
|
const appContent = await readFileContent(appPath);
|
|
@@ -1467,6 +1246,7 @@ function injectRouterProvider2(content, isTypeScript) {
|
|
|
1467
1246
|
importLines.splice(lastImportIndex + 1, 0, routerImport.trim());
|
|
1468
1247
|
modifiedContent = importLines.join("\n");
|
|
1469
1248
|
}
|
|
1249
|
+
const hasProvider = modifiedContent.includes("<Provider");
|
|
1470
1250
|
const appFunctionRegex = /(export\s+default\s+)?function\s+App\s*\([^)]*\)\s*\{[\s\S]*?\n\s*return\s+\([\s\S]*?\)\s*;?\s*\n\s*\}/m;
|
|
1471
1251
|
if (appFunctionRegex.test(modifiedContent)) {
|
|
1472
1252
|
modifiedContent = modifiedContent.replace(appFunctionRegex, (match) => {
|
|
@@ -1474,6 +1254,23 @@ function injectRouterProvider2(content, isTypeScript) {
|
|
|
1474
1254
|
/((export\s+default\s+)?function\s+App\s*\([^)]*\))/
|
|
1475
1255
|
);
|
|
1476
1256
|
if (signatureMatch) {
|
|
1257
|
+
if (hasProvider) {
|
|
1258
|
+
const providerMatch = match.match(
|
|
1259
|
+
/<Provider[\s\S]*?>([\s\S]*?)<\/Provider>/m
|
|
1260
|
+
);
|
|
1261
|
+
if (providerMatch) {
|
|
1262
|
+
const providerOpening = match.match(/<Provider[^>]*>/)?.[0] || "";
|
|
1263
|
+
const returnStatement2 = ` return (
|
|
1264
|
+
${providerOpening}
|
|
1265
|
+
<RouterProvider router={router} />
|
|
1266
|
+
</Provider>
|
|
1267
|
+
)
|
|
1268
|
+
`;
|
|
1269
|
+
return `${signatureMatch[1]} {
|
|
1270
|
+
${returnStatement2}}
|
|
1271
|
+
`;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1477
1274
|
const returnStatement = isTypeScript ? " return <RouterProvider router={router} />\n" : " return <RouterProvider router={router} />\n";
|
|
1478
1275
|
return `${signatureMatch[1]} {
|
|
1479
1276
|
${returnStatement}}
|
|
@@ -1482,16 +1279,32 @@ ${returnStatement}}
|
|
|
1482
1279
|
return match;
|
|
1483
1280
|
});
|
|
1484
1281
|
} else {
|
|
1485
|
-
const
|
|
1486
|
-
if (
|
|
1487
|
-
modifiedContent = modifiedContent.replace(
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1282
|
+
const arrowFunctionRegex = /(const|let|var)\s+App\s*=\s*\([^)]*\)\s*=>\s*\{?[\s\S]*?return\s+[\s\S]*?\}?/m;
|
|
1283
|
+
if (arrowFunctionRegex.test(modifiedContent)) {
|
|
1284
|
+
modifiedContent = modifiedContent.replace(arrowFunctionRegex, (match) => {
|
|
1285
|
+
if (hasProvider) {
|
|
1286
|
+
const providerMatch = match.match(
|
|
1287
|
+
/<Provider[\s\S]*?>([\s\S]*?)<\/Provider>/m
|
|
1288
|
+
);
|
|
1289
|
+
if (providerMatch) {
|
|
1290
|
+
const providerOpening = match.match(/<Provider[^>]*>/)?.[0] || "";
|
|
1291
|
+
return `const App = () => {
|
|
1292
|
+
return (
|
|
1293
|
+
${providerOpening}
|
|
1294
|
+
<RouterProvider router={router} />
|
|
1295
|
+
</Provider>
|
|
1296
|
+
)
|
|
1297
|
+
}`;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
return `const App = () => {
|
|
1301
|
+
return <RouterProvider router={router} />
|
|
1302
|
+
}`;
|
|
1303
|
+
});
|
|
1491
1304
|
} else {
|
|
1492
1305
|
modifiedContent += `
|
|
1493
1306
|
|
|
1494
|
-
|
|
1307
|
+
const App = () => {
|
|
1495
1308
|
return <RouterProvider router={router} />
|
|
1496
1309
|
}
|
|
1497
1310
|
|
|
@@ -1503,7 +1316,7 @@ export default App
|
|
|
1503
1316
|
}
|
|
1504
1317
|
|
|
1505
1318
|
// src/plugins/state/zustand.ts
|
|
1506
|
-
import { resolve as
|
|
1319
|
+
import { resolve as resolve5, join as join3 } from "path";
|
|
1507
1320
|
var zustandPlugin = {
|
|
1508
1321
|
name: "zustand",
|
|
1509
1322
|
displayName: "Zustand",
|
|
@@ -1569,12 +1382,12 @@ var zustandPlugin = {
|
|
|
1569
1382
|
const backupManager = new BackupManager();
|
|
1570
1383
|
const writer = new ConfigWriter(backupManager);
|
|
1571
1384
|
const files = [];
|
|
1572
|
-
const srcDir =
|
|
1385
|
+
const srcDir = resolve5(ctx.projectRoot, ctx.srcDir);
|
|
1573
1386
|
const extension = ctx.typescript ? "ts" : "js";
|
|
1574
1387
|
try {
|
|
1575
|
-
const storeDir =
|
|
1388
|
+
const storeDir = join3(srcDir, "store");
|
|
1576
1389
|
await ensureDirectory(storeDir);
|
|
1577
|
-
const storePath =
|
|
1390
|
+
const storePath = join3(storeDir, `index.${extension}`);
|
|
1578
1391
|
const storeContent = ctx.typescript ? getStoreContentTS() : getStoreContentJS();
|
|
1579
1392
|
await writer.createFile(storePath, storeContent);
|
|
1580
1393
|
files.push({
|
|
@@ -1585,7 +1398,7 @@ var zustandPlugin = {
|
|
|
1585
1398
|
});
|
|
1586
1399
|
logger.info(`Created Zustand store: ${storePath}`);
|
|
1587
1400
|
if (ctx.typescript) {
|
|
1588
|
-
const hookPath =
|
|
1401
|
+
const hookPath = join3(storeDir, "useStore.ts");
|
|
1589
1402
|
const hookContent = getTypedHookContentTS();
|
|
1590
1403
|
await writer.createFile(hookPath, hookContent);
|
|
1591
1404
|
files.push({
|
|
@@ -1713,7 +1526,7 @@ export const useRemoveAllBears = () =>
|
|
|
1713
1526
|
}
|
|
1714
1527
|
|
|
1715
1528
|
// src/plugins/state/jotai.ts
|
|
1716
|
-
import { resolve as
|
|
1529
|
+
import { resolve as resolve6, join as join4 } from "path";
|
|
1717
1530
|
var jotaiPlugin = {
|
|
1718
1531
|
name: "jotai",
|
|
1719
1532
|
displayName: "Jotai",
|
|
@@ -1782,12 +1595,12 @@ var jotaiPlugin = {
|
|
|
1782
1595
|
const backupManager = new BackupManager();
|
|
1783
1596
|
const writer = new ConfigWriter(backupManager);
|
|
1784
1597
|
const files = [];
|
|
1785
|
-
const srcDir =
|
|
1598
|
+
const srcDir = resolve6(ctx.projectRoot, ctx.srcDir);
|
|
1786
1599
|
const extension = ctx.typescript ? "ts" : "js";
|
|
1787
1600
|
try {
|
|
1788
|
-
const storeDir =
|
|
1601
|
+
const storeDir = join4(srcDir, "store");
|
|
1789
1602
|
await ensureDirectory(storeDir);
|
|
1790
|
-
const atomsPath =
|
|
1603
|
+
const atomsPath = join4(storeDir, `atoms.${extension}`);
|
|
1791
1604
|
const atomsContent = ctx.typescript ? getAtomsContentTS() : getAtomsContentJS();
|
|
1792
1605
|
await writer.createFile(atomsPath, atomsContent);
|
|
1793
1606
|
files.push({
|
|
@@ -1797,7 +1610,7 @@ var jotaiPlugin = {
|
|
|
1797
1610
|
backup: false
|
|
1798
1611
|
});
|
|
1799
1612
|
logger.info(`Created atoms file: ${atomsPath}`);
|
|
1800
|
-
const indexPath =
|
|
1613
|
+
const indexPath = join4(storeDir, `index.${extension}`);
|
|
1801
1614
|
const indexContent = ctx.typescript ? getIndexContentTS() : getIndexContentJS();
|
|
1802
1615
|
await writer.createFile(indexPath, indexContent);
|
|
1803
1616
|
files.push({
|
|
@@ -1807,7 +1620,7 @@ var jotaiPlugin = {
|
|
|
1807
1620
|
backup: false
|
|
1808
1621
|
});
|
|
1809
1622
|
logger.info(`Created store index: ${indexPath}`);
|
|
1810
|
-
const appPath =
|
|
1623
|
+
const appPath = join4(srcDir, `App.${ctx.typescript ? "tsx" : "jsx"}`);
|
|
1811
1624
|
const appExists = await checkPathExists(appPath);
|
|
1812
1625
|
if (appExists) {
|
|
1813
1626
|
const appContent = await readFileContent(appPath);
|
|
@@ -2058,7 +1871,7 @@ export default App
|
|
|
2058
1871
|
}
|
|
2059
1872
|
|
|
2060
1873
|
// src/plugins/state/redux-toolkit.ts
|
|
2061
|
-
import { resolve as
|
|
1874
|
+
import { resolve as resolve7, join as join5 } from "path";
|
|
2062
1875
|
var reduxToolkitPlugin = {
|
|
2063
1876
|
name: "@reduxjs/toolkit",
|
|
2064
1877
|
displayName: "Redux Toolkit",
|
|
@@ -2130,14 +1943,14 @@ var reduxToolkitPlugin = {
|
|
|
2130
1943
|
const backupManager = new BackupManager();
|
|
2131
1944
|
const writer = new ConfigWriter(backupManager);
|
|
2132
1945
|
const files = [];
|
|
2133
|
-
const srcDir =
|
|
1946
|
+
const srcDir = resolve7(ctx.projectRoot, ctx.srcDir);
|
|
2134
1947
|
const extension = ctx.typescript ? "ts" : "js";
|
|
2135
1948
|
try {
|
|
2136
|
-
const storeDir =
|
|
1949
|
+
const storeDir = join5(srcDir, "store");
|
|
2137
1950
|
await ensureDirectory(storeDir);
|
|
2138
|
-
const slicesDir =
|
|
1951
|
+
const slicesDir = join5(storeDir, "slices");
|
|
2139
1952
|
await ensureDirectory(slicesDir);
|
|
2140
|
-
const slicePath =
|
|
1953
|
+
const slicePath = join5(slicesDir, `counterSlice.${extension}`);
|
|
2141
1954
|
const sliceContent = ctx.typescript ? getCounterSliceContentTS() : getCounterSliceContentJS();
|
|
2142
1955
|
await writer.createFile(slicePath, sliceContent);
|
|
2143
1956
|
files.push({
|
|
@@ -2147,7 +1960,7 @@ var reduxToolkitPlugin = {
|
|
|
2147
1960
|
backup: false
|
|
2148
1961
|
});
|
|
2149
1962
|
logger.info(`Created counter slice: ${slicePath}`);
|
|
2150
|
-
const storePath =
|
|
1963
|
+
const storePath = join5(storeDir, `index.${extension}`);
|
|
2151
1964
|
const storeContent = ctx.typescript ? getStoreContentTS2() : getStoreContentJS2();
|
|
2152
1965
|
await writer.createFile(storePath, storeContent);
|
|
2153
1966
|
files.push({
|
|
@@ -2158,7 +1971,7 @@ var reduxToolkitPlugin = {
|
|
|
2158
1971
|
});
|
|
2159
1972
|
logger.info(`Created Redux store: ${storePath}`);
|
|
2160
1973
|
if (ctx.typescript) {
|
|
2161
|
-
const hooksPath =
|
|
1974
|
+
const hooksPath = join5(storeDir, "hooks.ts");
|
|
2162
1975
|
const hooksContent = getTypedHooksContentTS();
|
|
2163
1976
|
await writer.createFile(hooksPath, hooksContent);
|
|
2164
1977
|
files.push({
|
|
@@ -2169,7 +1982,7 @@ var reduxToolkitPlugin = {
|
|
|
2169
1982
|
});
|
|
2170
1983
|
logger.info(`Created typed hooks: ${hooksPath}`);
|
|
2171
1984
|
}
|
|
2172
|
-
const appPath =
|
|
1985
|
+
const appPath = join5(srcDir, `App.${ctx.typescript ? "tsx" : "jsx"}`);
|
|
2173
1986
|
const appExists = await checkPathExists(appPath);
|
|
2174
1987
|
if (appExists) {
|
|
2175
1988
|
const appContent = await readFileContent(appPath);
|
|
@@ -2460,15 +2273,20 @@ function injectProvider2(content, isTypeScript) {
|
|
|
2460
2273
|
importLines.splice(lastImportIndex + 1, 0, storeImport.trim());
|
|
2461
2274
|
modifiedContent = importLines.join("\n");
|
|
2462
2275
|
}
|
|
2463
|
-
const appFunctionRegex = /(export\s+default\s+)?function\s+App\s*\([^)]*\)\s*\{[\s\S]*?\n\s*return\s
|
|
2276
|
+
const appFunctionRegex = /(export\s+default\s+)?function\s+App\s*\([^)]*\)\s*\{[\s\S]*?\n\s*return\s+[\s\S]*?\n\s*\}/m;
|
|
2277
|
+
const normalizeReturn = (returnBlock) => {
|
|
2278
|
+
const raw = returnBlock.replace(/return\s+/, "").trim();
|
|
2279
|
+
const withoutParens = raw.startsWith("(") && raw.endsWith(")") ? raw.slice(1, -1).trim() : raw;
|
|
2280
|
+
return withoutParens;
|
|
2281
|
+
};
|
|
2464
2282
|
if (appFunctionRegex.test(modifiedContent)) {
|
|
2465
2283
|
modifiedContent = modifiedContent.replace(appFunctionRegex, (match) => {
|
|
2466
2284
|
const signatureMatch = match.match(
|
|
2467
2285
|
/((export\s+default\s+)?function\s+App\s*\([^)]*\))/
|
|
2468
2286
|
);
|
|
2469
2287
|
if (signatureMatch) {
|
|
2470
|
-
const returnMatch = match.match(/return
|
|
2471
|
-
const innerContent = returnMatch
|
|
2288
|
+
const returnMatch = match.match(/return[\s\S]*?\n\s*\}/m);
|
|
2289
|
+
const innerContent = returnMatch ? normalizeReturn(returnMatch[0].replace(/\}\s*$/, "")) : "<div>App</div>";
|
|
2472
2290
|
const returnStatement = isTypeScript ? ` return (
|
|
2473
2291
|
<Provider store={store}>
|
|
2474
2292
|
${innerContent.trim()}
|
|
@@ -2487,19 +2305,18 @@ ${returnStatement}}
|
|
|
2487
2305
|
return match;
|
|
2488
2306
|
});
|
|
2489
2307
|
} else {
|
|
2490
|
-
const
|
|
2491
|
-
if (
|
|
2492
|
-
modifiedContent = modifiedContent.replace(
|
|
2493
|
-
const
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
</Provider>
|
|
2498
|
-
)` : `return (
|
|
2308
|
+
const arrowFunctionRegex = /(const|let|var)\s+App\s*=\s*\([^)]*\)\s*=>\s*\{?[\s\S]*?return\s+[\s\S]*?\}?/m;
|
|
2309
|
+
if (arrowFunctionRegex.test(modifiedContent)) {
|
|
2310
|
+
modifiedContent = modifiedContent.replace(arrowFunctionRegex, (match) => {
|
|
2311
|
+
const returnMatch = match.match(/return[\s\S]*/m);
|
|
2312
|
+
const innerContent = returnMatch ? normalizeReturn(returnMatch[0].replace(/\}?\s*$/, "")) : "<div>App</div>";
|
|
2313
|
+
return `const App = () => {
|
|
2314
|
+
return (
|
|
2499
2315
|
<Provider store={store}>
|
|
2500
|
-
${innerContent}
|
|
2316
|
+
${innerContent.trim()}
|
|
2501
2317
|
</Provider>
|
|
2502
|
-
)
|
|
2318
|
+
)
|
|
2319
|
+
}`;
|
|
2503
2320
|
});
|
|
2504
2321
|
} else {
|
|
2505
2322
|
modifiedContent += `
|
|
@@ -2520,7 +2337,7 @@ export default App
|
|
|
2520
2337
|
}
|
|
2521
2338
|
|
|
2522
2339
|
// src/plugins/http/axios.ts
|
|
2523
|
-
import { resolve as
|
|
2340
|
+
import { resolve as resolve8, join as join6 } from "path";
|
|
2524
2341
|
var axiosPlugin = {
|
|
2525
2342
|
name: "axios",
|
|
2526
2343
|
displayName: "Axios",
|
|
@@ -2585,12 +2402,12 @@ var axiosPlugin = {
|
|
|
2585
2402
|
const backupManager = new BackupManager();
|
|
2586
2403
|
const writer = new ConfigWriter(backupManager);
|
|
2587
2404
|
const files = [];
|
|
2588
|
-
const srcDir =
|
|
2405
|
+
const srcDir = resolve8(ctx.projectRoot, ctx.srcDir);
|
|
2589
2406
|
const extension = ctx.typescript ? "ts" : "js";
|
|
2590
2407
|
try {
|
|
2591
|
-
const libDir =
|
|
2408
|
+
const libDir = join6(srcDir, "lib");
|
|
2592
2409
|
await ensureDirectory(libDir);
|
|
2593
|
-
const apiPath =
|
|
2410
|
+
const apiPath = join6(libDir, `api.${extension}`);
|
|
2594
2411
|
const apiContent = ctx.typescript ? getApiContentTS() : getApiContentJS();
|
|
2595
2412
|
await writer.createFile(apiPath, apiContent);
|
|
2596
2413
|
files.push({
|
|
@@ -2601,7 +2418,7 @@ var axiosPlugin = {
|
|
|
2601
2418
|
});
|
|
2602
2419
|
logger.info(`Created Axios instance: ${apiPath}`);
|
|
2603
2420
|
if (ctx.typescript) {
|
|
2604
|
-
const typesPath =
|
|
2421
|
+
const typesPath = join6(libDir, "api-types.ts");
|
|
2605
2422
|
const typesContent = getApiTypesContentTS();
|
|
2606
2423
|
await writer.createFile(typesPath, typesContent);
|
|
2607
2424
|
files.push({
|
|
@@ -2855,7 +2672,7 @@ export interface ApiError {
|
|
|
2855
2672
|
}
|
|
2856
2673
|
|
|
2857
2674
|
// src/plugins/http/tanstack-query.ts
|
|
2858
|
-
import { resolve as
|
|
2675
|
+
import { resolve as resolve9, join as join7 } from "path";
|
|
2859
2676
|
var tanstackQueryPlugin = {
|
|
2860
2677
|
name: "@tanstack/react-query",
|
|
2861
2678
|
displayName: "TanStack Query",
|
|
@@ -2924,12 +2741,12 @@ var tanstackQueryPlugin = {
|
|
|
2924
2741
|
const backupManager = new BackupManager();
|
|
2925
2742
|
const writer = new ConfigWriter(backupManager);
|
|
2926
2743
|
const files = [];
|
|
2927
|
-
const srcDir =
|
|
2744
|
+
const srcDir = resolve9(ctx.projectRoot, ctx.srcDir);
|
|
2928
2745
|
const extension = ctx.typescript ? "ts" : "js";
|
|
2929
2746
|
try {
|
|
2930
|
-
const libDir =
|
|
2747
|
+
const libDir = join7(srcDir, "lib");
|
|
2931
2748
|
await ensureDirectory(libDir);
|
|
2932
|
-
const queryClientPath =
|
|
2749
|
+
const queryClientPath = join7(libDir, `query-client.${extension}`);
|
|
2933
2750
|
const queryClientContent = ctx.typescript ? getQueryClientContentTS() : getQueryClientContentJS();
|
|
2934
2751
|
await writer.createFile(queryClientPath, queryClientContent);
|
|
2935
2752
|
files.push({
|
|
@@ -2939,9 +2756,9 @@ var tanstackQueryPlugin = {
|
|
|
2939
2756
|
backup: false
|
|
2940
2757
|
});
|
|
2941
2758
|
logger.info(`Created query client: ${queryClientPath}`);
|
|
2942
|
-
const queriesDir =
|
|
2759
|
+
const queriesDir = join7(libDir, "queries");
|
|
2943
2760
|
await ensureDirectory(queriesDir);
|
|
2944
|
-
const exampleQueryPath =
|
|
2761
|
+
const exampleQueryPath = join7(queriesDir, `example.${extension}`);
|
|
2945
2762
|
const exampleQueryContent = ctx.typescript ? getExampleQueryContentTS() : getExampleQueryContentJS();
|
|
2946
2763
|
await writer.createFile(exampleQueryPath, exampleQueryContent);
|
|
2947
2764
|
files.push({
|
|
@@ -2951,9 +2768,9 @@ var tanstackQueryPlugin = {
|
|
|
2951
2768
|
backup: false
|
|
2952
2769
|
});
|
|
2953
2770
|
logger.info(`Created example query: ${exampleQueryPath}`);
|
|
2954
|
-
const mutationsDir =
|
|
2771
|
+
const mutationsDir = join7(libDir, "mutations");
|
|
2955
2772
|
await ensureDirectory(mutationsDir);
|
|
2956
|
-
const exampleMutationPath =
|
|
2773
|
+
const exampleMutationPath = join7(mutationsDir, `example.${extension}`);
|
|
2957
2774
|
const exampleMutationContent = ctx.typescript ? getExampleMutationContentTS() : getExampleMutationContentJS();
|
|
2958
2775
|
await writer.createFile(exampleMutationPath, exampleMutationContent);
|
|
2959
2776
|
files.push({
|
|
@@ -2963,7 +2780,7 @@ var tanstackQueryPlugin = {
|
|
|
2963
2780
|
backup: false
|
|
2964
2781
|
});
|
|
2965
2782
|
logger.info(`Created example mutation: ${exampleMutationPath}`);
|
|
2966
|
-
const appPath =
|
|
2783
|
+
const appPath = join7(srcDir, `App.${ctx.typescript ? "tsx" : "jsx"}`);
|
|
2967
2784
|
const appExists = await checkPathExists(appPath);
|
|
2968
2785
|
if (appExists) {
|
|
2969
2786
|
const appContent = await readFileContent(appPath);
|
|
@@ -3405,7 +3222,7 @@ export default App
|
|
|
3405
3222
|
}
|
|
3406
3223
|
|
|
3407
3224
|
// src/plugins/css/tailwindcss.ts
|
|
3408
|
-
import { resolve as
|
|
3225
|
+
import { resolve as resolve10, join as join8 } from "path";
|
|
3409
3226
|
var tailwindcssPlugin = {
|
|
3410
3227
|
name: "tailwindcss",
|
|
3411
3228
|
displayName: "TailwindCSS",
|
|
@@ -3471,10 +3288,10 @@ var tailwindcssPlugin = {
|
|
|
3471
3288
|
const writer = new ConfigWriter(backupManager);
|
|
3472
3289
|
const files = [];
|
|
3473
3290
|
const projectRoot = ctx.projectRoot;
|
|
3474
|
-
const srcDir =
|
|
3291
|
+
const srcDir = resolve10(projectRoot, ctx.srcDir);
|
|
3475
3292
|
const extension = ctx.typescript ? "ts" : "js";
|
|
3476
3293
|
try {
|
|
3477
|
-
const viteConfigPath =
|
|
3294
|
+
const viteConfigPath = join8(projectRoot, `vite.config.${extension}`);
|
|
3478
3295
|
const viteConfigExists = await checkPathExists(viteConfigPath);
|
|
3479
3296
|
if (viteConfigExists) {
|
|
3480
3297
|
const viteConfigContent = await readFileContent(viteConfigPath);
|
|
@@ -3504,10 +3321,10 @@ var tailwindcssPlugin = {
|
|
|
3504
3321
|
logger.info(`Created vite.config.${extension} with TailwindCSS plugin`);
|
|
3505
3322
|
}
|
|
3506
3323
|
const cssFiles = [
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3324
|
+
join8(srcDir, "index.css"),
|
|
3325
|
+
join8(srcDir, "main.css"),
|
|
3326
|
+
join8(srcDir, "app.css"),
|
|
3327
|
+
join8(srcDir, "styles.css")
|
|
3511
3328
|
];
|
|
3512
3329
|
let cssFileModified = false;
|
|
3513
3330
|
for (const cssPath of cssFiles) {
|
|
@@ -3528,7 +3345,7 @@ var tailwindcssPlugin = {
|
|
|
3528
3345
|
}
|
|
3529
3346
|
}
|
|
3530
3347
|
if (!cssFileModified) {
|
|
3531
|
-
const cssPath =
|
|
3348
|
+
const cssPath = join8(srcDir, "index.css");
|
|
3532
3349
|
const cssContent = getCssContent();
|
|
3533
3350
|
await writer.createFile(cssPath, cssContent);
|
|
3534
3351
|
files.push({
|
|
@@ -3663,7 +3480,7 @@ ${content}`;
|
|
|
3663
3480
|
}
|
|
3664
3481
|
|
|
3665
3482
|
// src/plugins/css/styled-components.ts
|
|
3666
|
-
import { resolve as
|
|
3483
|
+
import { resolve as resolve11, join as join9 } from "path";
|
|
3667
3484
|
var styledComponentsPlugin = {
|
|
3668
3485
|
name: "styled-components",
|
|
3669
3486
|
displayName: "Styled Components",
|
|
@@ -3741,12 +3558,12 @@ var styledComponentsPlugin = {
|
|
|
3741
3558
|
const backupManager = new BackupManager();
|
|
3742
3559
|
const writer = new ConfigWriter(backupManager);
|
|
3743
3560
|
const files = [];
|
|
3744
|
-
const srcDir =
|
|
3561
|
+
const srcDir = resolve11(ctx.projectRoot, ctx.srcDir);
|
|
3745
3562
|
const extension = ctx.typescript ? "tsx" : "jsx";
|
|
3746
3563
|
try {
|
|
3747
|
-
const styledDir =
|
|
3564
|
+
const styledDir = join9(srcDir, "components", "styled");
|
|
3748
3565
|
await ensureDirectory(styledDir);
|
|
3749
|
-
const buttonPath =
|
|
3566
|
+
const buttonPath = join9(styledDir, `Button.${extension}`);
|
|
3750
3567
|
const buttonContent = ctx.typescript ? getButtonContentTS() : getButtonContentJS();
|
|
3751
3568
|
await writer.createFile(buttonPath, buttonContent);
|
|
3752
3569
|
files.push({
|
|
@@ -3756,7 +3573,7 @@ var styledComponentsPlugin = {
|
|
|
3756
3573
|
backup: false
|
|
3757
3574
|
});
|
|
3758
3575
|
logger.info(`Created Button component: ${buttonPath}`);
|
|
3759
|
-
const cardPath =
|
|
3576
|
+
const cardPath = join9(styledDir, `Card.${extension}`);
|
|
3760
3577
|
const cardContent = ctx.typescript ? getCardContentTS() : getCardContentJS();
|
|
3761
3578
|
await writer.createFile(cardPath, cardContent);
|
|
3762
3579
|
files.push({
|
|
@@ -3766,7 +3583,7 @@ var styledComponentsPlugin = {
|
|
|
3766
3583
|
backup: false
|
|
3767
3584
|
});
|
|
3768
3585
|
logger.info(`Created Card component: ${cardPath}`);
|
|
3769
|
-
const indexPath =
|
|
3586
|
+
const indexPath = join9(styledDir, `index.${ctx.typescript ? "ts" : "js"}`);
|
|
3770
3587
|
const indexContent = getIndexContent();
|
|
3771
3588
|
await writer.createFile(indexPath, indexContent);
|
|
3772
3589
|
files.push({
|
|
@@ -3987,7 +3804,7 @@ export { Card } from './Card'
|
|
|
3987
3804
|
}
|
|
3988
3805
|
|
|
3989
3806
|
// src/plugins/css/emotion.ts
|
|
3990
|
-
import { resolve as
|
|
3807
|
+
import { resolve as resolve12, join as join10 } from "path";
|
|
3991
3808
|
var emotionPlugin = {
|
|
3992
3809
|
name: "@emotion/react",
|
|
3993
3810
|
displayName: "Emotion",
|
|
@@ -4060,12 +3877,12 @@ var emotionPlugin = {
|
|
|
4060
3877
|
const backupManager = new BackupManager();
|
|
4061
3878
|
const writer = new ConfigWriter(backupManager);
|
|
4062
3879
|
const files = [];
|
|
4063
|
-
const srcDir =
|
|
3880
|
+
const srcDir = resolve12(ctx.projectRoot, ctx.srcDir);
|
|
4064
3881
|
const extension = ctx.typescript ? "tsx" : "jsx";
|
|
4065
3882
|
try {
|
|
4066
|
-
const emotionDir =
|
|
3883
|
+
const emotionDir = join10(srcDir, "components", "emotion");
|
|
4067
3884
|
await ensureDirectory(emotionDir);
|
|
4068
|
-
const buttonPath =
|
|
3885
|
+
const buttonPath = join10(emotionDir, `Button.${extension}`);
|
|
4069
3886
|
const buttonContent = ctx.typescript ? getButtonContentTS2() : getButtonContentJS2();
|
|
4070
3887
|
await writer.createFile(buttonPath, buttonContent);
|
|
4071
3888
|
files.push({
|
|
@@ -4075,7 +3892,7 @@ var emotionPlugin = {
|
|
|
4075
3892
|
backup: false
|
|
4076
3893
|
});
|
|
4077
3894
|
logger.info(`Created Button component: ${buttonPath}`);
|
|
4078
|
-
const cardPath =
|
|
3895
|
+
const cardPath = join10(emotionDir, `Card.${extension}`);
|
|
4079
3896
|
const cardContent = ctx.typescript ? getCardContentTS2() : getCardContentJS2();
|
|
4080
3897
|
await writer.createFile(cardPath, cardContent);
|
|
4081
3898
|
files.push({
|
|
@@ -4085,7 +3902,7 @@ var emotionPlugin = {
|
|
|
4085
3902
|
backup: false
|
|
4086
3903
|
});
|
|
4087
3904
|
logger.info(`Created Card component: ${cardPath}`);
|
|
4088
|
-
const indexPath =
|
|
3905
|
+
const indexPath = join10(
|
|
4089
3906
|
emotionDir,
|
|
4090
3907
|
`index.${ctx.typescript ? "ts" : "js"}`
|
|
4091
3908
|
);
|
|
@@ -4318,7 +4135,7 @@ export { Card } from './Card'
|
|
|
4318
4135
|
}
|
|
4319
4136
|
|
|
4320
4137
|
// src/plugins/css/react-bootstrap.ts
|
|
4321
|
-
import { resolve as
|
|
4138
|
+
import { resolve as resolve13, join as join11 } from "path";
|
|
4322
4139
|
var reactBootstrapPlugin = {
|
|
4323
4140
|
name: "react-bootstrap",
|
|
4324
4141
|
displayName: "React Bootstrap",
|
|
@@ -4387,12 +4204,12 @@ var reactBootstrapPlugin = {
|
|
|
4387
4204
|
const backupManager = new BackupManager();
|
|
4388
4205
|
const writer = new ConfigWriter(backupManager);
|
|
4389
4206
|
const files = [];
|
|
4390
|
-
const srcDir =
|
|
4207
|
+
const srcDir = resolve13(ctx.projectRoot, ctx.srcDir);
|
|
4391
4208
|
const extension = ctx.typescript ? "tsx" : "jsx";
|
|
4392
4209
|
try {
|
|
4393
|
-
const bootstrapDir =
|
|
4210
|
+
const bootstrapDir = join11(srcDir, "components", "bootstrap");
|
|
4394
4211
|
await ensureDirectory(bootstrapDir);
|
|
4395
|
-
const examplePath =
|
|
4212
|
+
const examplePath = join11(bootstrapDir, `Example.${extension}`);
|
|
4396
4213
|
const exampleContent = ctx.typescript ? getExampleContentTS() : getExampleContentJS();
|
|
4397
4214
|
await writer.createFile(examplePath, exampleContent);
|
|
4398
4215
|
files.push({
|
|
@@ -4402,7 +4219,7 @@ var reactBootstrapPlugin = {
|
|
|
4402
4219
|
backup: false
|
|
4403
4220
|
});
|
|
4404
4221
|
logger.info(`Created Bootstrap example: ${examplePath}`);
|
|
4405
|
-
const indexPath =
|
|
4222
|
+
const indexPath = join11(srcDir, `index.${ctx.typescript ? "tsx" : "jsx"}`);
|
|
4406
4223
|
const indexExists = await checkPathExists(indexPath);
|
|
4407
4224
|
if (indexExists) {
|
|
4408
4225
|
const indexContent = await readFileContent(indexPath);
|
|
@@ -4597,7 +4414,7 @@ function injectBootstrapCSS(content) {
|
|
|
4597
4414
|
}
|
|
4598
4415
|
|
|
4599
4416
|
// src/plugins/forms/react-hook-form.ts
|
|
4600
|
-
import { resolve as
|
|
4417
|
+
import { resolve as resolve14, join as join12 } from "path";
|
|
4601
4418
|
var reactHookFormPlugin = {
|
|
4602
4419
|
name: "react-hook-form",
|
|
4603
4420
|
displayName: "React Hook Form",
|
|
@@ -4661,12 +4478,12 @@ var reactHookFormPlugin = {
|
|
|
4661
4478
|
const backupManager = new BackupManager();
|
|
4662
4479
|
const writer = new ConfigWriter(backupManager);
|
|
4663
4480
|
const files = [];
|
|
4664
|
-
const srcDir =
|
|
4481
|
+
const srcDir = resolve14(ctx.projectRoot, ctx.srcDir);
|
|
4665
4482
|
const extension = ctx.typescript ? "tsx" : "jsx";
|
|
4666
4483
|
try {
|
|
4667
|
-
const formsDir =
|
|
4484
|
+
const formsDir = join12(srcDir, "components", "forms");
|
|
4668
4485
|
await ensureDirectory(formsDir);
|
|
4669
|
-
const exampleFormPath =
|
|
4486
|
+
const exampleFormPath = join12(formsDir, `ExampleForm.${extension}`);
|
|
4670
4487
|
const exampleFormContent = ctx.typescript ? getExampleFormContentTS() : getExampleFormContentJS();
|
|
4671
4488
|
await writer.createFile(exampleFormPath, exampleFormContent);
|
|
4672
4489
|
files.push({
|
|
@@ -4676,7 +4493,7 @@ var reactHookFormPlugin = {
|
|
|
4676
4493
|
backup: false
|
|
4677
4494
|
});
|
|
4678
4495
|
logger.info(`Created example form: ${exampleFormPath}`);
|
|
4679
|
-
const validatedFormPath =
|
|
4496
|
+
const validatedFormPath = join12(formsDir, `ValidatedForm.${extension}`);
|
|
4680
4497
|
const validatedFormContent = ctx.typescript ? getValidatedFormContentTS() : getValidatedFormContentJS();
|
|
4681
4498
|
await writer.createFile(validatedFormPath, validatedFormContent);
|
|
4682
4499
|
files.push({
|
|
@@ -4686,7 +4503,7 @@ var reactHookFormPlugin = {
|
|
|
4686
4503
|
backup: false
|
|
4687
4504
|
});
|
|
4688
4505
|
logger.info(`Created validated form: ${validatedFormPath}`);
|
|
4689
|
-
const indexPath =
|
|
4506
|
+
const indexPath = join12(formsDir, `index.${ctx.typescript ? "ts" : "js"}`);
|
|
4690
4507
|
const indexContent = ctx.typescript ? getIndexContentTS3() : getIndexContentJS3();
|
|
4691
4508
|
await writer.createFile(indexPath, indexContent);
|
|
4692
4509
|
files.push({
|
|
@@ -5122,7 +4939,7 @@ export { ValidatedForm } from './ValidatedForm'
|
|
|
5122
4939
|
}
|
|
5123
4940
|
|
|
5124
4941
|
// src/plugins/forms/zod.ts
|
|
5125
|
-
import { join as
|
|
4942
|
+
import { join as join13 } from "path";
|
|
5126
4943
|
var zodPlugin = {
|
|
5127
4944
|
name: "zod",
|
|
5128
4945
|
displayName: "Zod",
|
|
@@ -5187,11 +5004,11 @@ var zodPlugin = {
|
|
|
5187
5004
|
const backupManager = new BackupManager();
|
|
5188
5005
|
const writer = new ConfigWriter(backupManager);
|
|
5189
5006
|
const files = [];
|
|
5190
|
-
const srcDir =
|
|
5007
|
+
const srcDir = join13(ctx.projectRoot, ctx.srcDir);
|
|
5191
5008
|
try {
|
|
5192
|
-
const schemasDir =
|
|
5009
|
+
const schemasDir = join13(srcDir, "lib", "schemas");
|
|
5193
5010
|
await ensureDirectory(schemasDir);
|
|
5194
|
-
const userSchemaPath =
|
|
5011
|
+
const userSchemaPath = join13(
|
|
5195
5012
|
schemasDir,
|
|
5196
5013
|
`user.${ctx.typescript ? "ts" : "js"}`
|
|
5197
5014
|
);
|
|
@@ -5204,7 +5021,7 @@ var zodPlugin = {
|
|
|
5204
5021
|
backup: false
|
|
5205
5022
|
});
|
|
5206
5023
|
logger.info(`Created user schema: ${userSchemaPath}`);
|
|
5207
|
-
const indexPath =
|
|
5024
|
+
const indexPath = join13(
|
|
5208
5025
|
schemasDir,
|
|
5209
5026
|
`index.${ctx.typescript ? "ts" : "js"}`
|
|
5210
5027
|
);
|
|
@@ -5314,7 +5131,7 @@ function getIndexContentJS4() {
|
|
|
5314
5131
|
}
|
|
5315
5132
|
|
|
5316
5133
|
// src/plugins/ui/shadcn-ui.ts
|
|
5317
|
-
import { join as
|
|
5134
|
+
import { join as join14 } from "path";
|
|
5318
5135
|
var shadcnUiPlugin = {
|
|
5319
5136
|
name: "shadcn-ui",
|
|
5320
5137
|
displayName: "Shadcn/ui",
|
|
@@ -5401,7 +5218,7 @@ var shadcnUiPlugin = {
|
|
|
5401
5218
|
const writer = new ConfigWriter(backupManager);
|
|
5402
5219
|
const files = [];
|
|
5403
5220
|
const projectRoot = ctx.projectRoot;
|
|
5404
|
-
const srcDir =
|
|
5221
|
+
const srcDir = join14(projectRoot, ctx.srcDir);
|
|
5405
5222
|
try {
|
|
5406
5223
|
const tailwindInstalled = ctx.dependencies["tailwindcss"] !== void 0 || ctx.devDependencies["tailwindcss"] !== void 0;
|
|
5407
5224
|
if (!tailwindInstalled) {
|
|
@@ -5414,7 +5231,7 @@ var shadcnUiPlugin = {
|
|
|
5414
5231
|
message: "TailwindCSS is required for Shadcn/ui. Please install TailwindCSS first."
|
|
5415
5232
|
};
|
|
5416
5233
|
}
|
|
5417
|
-
const componentsJsonPath =
|
|
5234
|
+
const componentsJsonPath = join14(projectRoot, "components.json");
|
|
5418
5235
|
const componentsJsonExists = await checkPathExists(componentsJsonPath);
|
|
5419
5236
|
if (componentsJsonExists) {
|
|
5420
5237
|
logger.warn("components.json already exists, skipping creation");
|
|
@@ -5429,9 +5246,9 @@ var shadcnUiPlugin = {
|
|
|
5429
5246
|
});
|
|
5430
5247
|
logger.info(`Created components.json: ${componentsJsonPath}`);
|
|
5431
5248
|
}
|
|
5432
|
-
const libDir =
|
|
5249
|
+
const libDir = join14(srcDir, "lib");
|
|
5433
5250
|
await ensureDirectory(libDir);
|
|
5434
|
-
const utilsPath =
|
|
5251
|
+
const utilsPath = join14(libDir, `utils.${ctx.typescript ? "ts" : "js"}`);
|
|
5435
5252
|
const utilsExists = await checkPathExists(utilsPath);
|
|
5436
5253
|
if (utilsExists) {
|
|
5437
5254
|
logger.warn(
|
|
@@ -5461,9 +5278,9 @@ var shadcnUiPlugin = {
|
|
|
5461
5278
|
});
|
|
5462
5279
|
logger.info(`Created utils file: ${utilsPath}`);
|
|
5463
5280
|
}
|
|
5464
|
-
const uiDir =
|
|
5281
|
+
const uiDir = join14(srcDir, "components", "ui");
|
|
5465
5282
|
await ensureDirectory(uiDir);
|
|
5466
|
-
const buttonPath =
|
|
5283
|
+
const buttonPath = join14(uiDir, `button.${ctx.typescript ? "tsx" : "jsx"}`);
|
|
5467
5284
|
const buttonExists = await checkPathExists(buttonPath);
|
|
5468
5285
|
if (!buttonExists) {
|
|
5469
5286
|
const buttonContent = ctx.typescript ? getButtonContentTS3() : getButtonContentJS3();
|
|
@@ -5476,7 +5293,7 @@ var shadcnUiPlugin = {
|
|
|
5476
5293
|
});
|
|
5477
5294
|
logger.info(`Created Button component: ${buttonPath}`);
|
|
5478
5295
|
}
|
|
5479
|
-
const cssPath =
|
|
5296
|
+
const cssPath = join14(srcDir, "index.css");
|
|
5480
5297
|
const cssExists = await checkPathExists(cssPath);
|
|
5481
5298
|
if (cssExists) {
|
|
5482
5299
|
const cssContent = await readFileContent(cssPath);
|
|
@@ -5786,7 +5603,7 @@ function getShadcnCSSVariables() {
|
|
|
5786
5603
|
}
|
|
5787
5604
|
|
|
5788
5605
|
// src/plugins/ui/radix-ui.ts
|
|
5789
|
-
import { join as
|
|
5606
|
+
import { join as join15 } from "path";
|
|
5790
5607
|
var radixUiPlugin = {
|
|
5791
5608
|
name: "radix-ui",
|
|
5792
5609
|
displayName: "Radix UI",
|
|
@@ -5863,12 +5680,12 @@ var radixUiPlugin = {
|
|
|
5863
5680
|
const backupManager = new BackupManager();
|
|
5864
5681
|
const writer = new ConfigWriter(backupManager);
|
|
5865
5682
|
const files = [];
|
|
5866
|
-
const srcDir =
|
|
5683
|
+
const srcDir = join15(ctx.projectRoot, ctx.srcDir);
|
|
5867
5684
|
const extension = ctx.typescript ? "tsx" : "jsx";
|
|
5868
5685
|
try {
|
|
5869
|
-
const radixDir =
|
|
5686
|
+
const radixDir = join15(srcDir, "components", "radix");
|
|
5870
5687
|
await ensureDirectory(radixDir);
|
|
5871
|
-
const dialogPath =
|
|
5688
|
+
const dialogPath = join15(radixDir, `Dialog.${extension}`);
|
|
5872
5689
|
const dialogContent = ctx.typescript ? getDialogContentTS() : getDialogContentJS();
|
|
5873
5690
|
await writer.createFile(dialogPath, dialogContent);
|
|
5874
5691
|
files.push({
|
|
@@ -5878,7 +5695,7 @@ var radixUiPlugin = {
|
|
|
5878
5695
|
backup: false
|
|
5879
5696
|
});
|
|
5880
5697
|
logger.info(`Created Dialog component: ${dialogPath}`);
|
|
5881
|
-
const dropdownMenuPath =
|
|
5698
|
+
const dropdownMenuPath = join15(radixDir, `DropdownMenu.${extension}`);
|
|
5882
5699
|
const dropdownMenuContent = ctx.typescript ? getDropdownMenuContentTS() : getDropdownMenuContentJS();
|
|
5883
5700
|
await writer.createFile(dropdownMenuPath, dropdownMenuContent);
|
|
5884
5701
|
files.push({
|
|
@@ -5888,7 +5705,7 @@ var radixUiPlugin = {
|
|
|
5888
5705
|
backup: false
|
|
5889
5706
|
});
|
|
5890
5707
|
logger.info(`Created DropdownMenu component: ${dropdownMenuPath}`);
|
|
5891
|
-
const indexPath =
|
|
5708
|
+
const indexPath = join15(radixDir, `index.${ctx.typescript ? "ts" : "js"}`);
|
|
5892
5709
|
const indexContent = ctx.typescript ? getIndexContentTS5() : getIndexContentJS5();
|
|
5893
5710
|
await writer.createFile(indexPath, indexContent);
|
|
5894
5711
|
files.push({
|
|
@@ -6516,7 +6333,7 @@ export {
|
|
|
6516
6333
|
}
|
|
6517
6334
|
|
|
6518
6335
|
// src/plugins/ui/react-icons.ts
|
|
6519
|
-
import { join as
|
|
6336
|
+
import { join as join16 } from "path";
|
|
6520
6337
|
var reactIconsPlugin = {
|
|
6521
6338
|
name: "react-icons",
|
|
6522
6339
|
displayName: "React Icons",
|
|
@@ -6581,11 +6398,11 @@ var reactIconsPlugin = {
|
|
|
6581
6398
|
const backupManager = new BackupManager();
|
|
6582
6399
|
const writer = new ConfigWriter(backupManager);
|
|
6583
6400
|
const files = [];
|
|
6584
|
-
const srcDir =
|
|
6401
|
+
const srcDir = join16(ctx.projectRoot, ctx.srcDir);
|
|
6585
6402
|
try {
|
|
6586
|
-
const iconsDir =
|
|
6403
|
+
const iconsDir = join16(srcDir, "components", "icons");
|
|
6587
6404
|
await ensureDirectory(iconsDir);
|
|
6588
|
-
const iconExamplePath =
|
|
6405
|
+
const iconExamplePath = join16(
|
|
6589
6406
|
iconsDir,
|
|
6590
6407
|
`IconExample.${ctx.typescript ? "tsx" : "jsx"}`
|
|
6591
6408
|
);
|
|
@@ -6598,7 +6415,7 @@ var reactIconsPlugin = {
|
|
|
6598
6415
|
backup: false
|
|
6599
6416
|
});
|
|
6600
6417
|
logger.info(`Created icon example: ${iconExamplePath}`);
|
|
6601
|
-
const indexPath =
|
|
6418
|
+
const indexPath = join16(iconsDir, `index.${ctx.typescript ? "ts" : "js"}`);
|
|
6602
6419
|
const indexContent = ctx.typescript ? getIndexContentTS6() : getIndexContentJS6();
|
|
6603
6420
|
await writer.createFile(indexPath, indexContent);
|
|
6604
6421
|
files.push({
|
|
@@ -6714,7 +6531,7 @@ export { MdHome, MdSettings, MdSearch } from 'react-icons/md'
|
|
|
6714
6531
|
}
|
|
6715
6532
|
|
|
6716
6533
|
// src/plugins/ui/react-hot-toast.ts
|
|
6717
|
-
import { join as
|
|
6534
|
+
import { join as join17 } from "path";
|
|
6718
6535
|
var reactHotToastPlugin = {
|
|
6719
6536
|
name: "react-hot-toast",
|
|
6720
6537
|
displayName: "React Hot Toast",
|
|
@@ -6778,12 +6595,12 @@ var reactHotToastPlugin = {
|
|
|
6778
6595
|
const backupManager = new BackupManager();
|
|
6779
6596
|
const writer = new ConfigWriter(backupManager);
|
|
6780
6597
|
const files = [];
|
|
6781
|
-
const srcDir =
|
|
6598
|
+
const srcDir = join17(ctx.projectRoot, ctx.srcDir);
|
|
6782
6599
|
const extension = ctx.typescript ? "tsx" : "jsx";
|
|
6783
6600
|
try {
|
|
6784
|
-
const appPath =
|
|
6785
|
-
const mainPath =
|
|
6786
|
-
const indexPath =
|
|
6601
|
+
const appPath = join17(srcDir, `App.${extension}`);
|
|
6602
|
+
const mainPath = join17(srcDir, `main.${extension}`);
|
|
6603
|
+
const indexPath = join17(srcDir, `index.${extension}`);
|
|
6787
6604
|
let targetPath = null;
|
|
6788
6605
|
let targetContent = "";
|
|
6789
6606
|
if (await checkPathExists(appPath)) {
|
|
@@ -6813,7 +6630,7 @@ var reactHotToastPlugin = {
|
|
|
6813
6630
|
logger.warn("Toaster already configured in the app");
|
|
6814
6631
|
}
|
|
6815
6632
|
} else {
|
|
6816
|
-
const newAppPath =
|
|
6633
|
+
const newAppPath = join17(srcDir, `App.${extension}`);
|
|
6817
6634
|
const newAppContent = ctx.typescript ? getAppContentTS6() : getAppContentJS6();
|
|
6818
6635
|
await writer.createFile(newAppPath, newAppContent);
|
|
6819
6636
|
files.push({
|
|
@@ -6910,7 +6727,7 @@ export default App
|
|
|
6910
6727
|
}
|
|
6911
6728
|
|
|
6912
6729
|
// src/plugins/animation/framer-motion.ts
|
|
6913
|
-
import { join as
|
|
6730
|
+
import { join as join18 } from "path";
|
|
6914
6731
|
var framerMotionPlugin = {
|
|
6915
6732
|
name: "framer-motion",
|
|
6916
6733
|
displayName: "Framer Motion",
|
|
@@ -6975,11 +6792,11 @@ var framerMotionPlugin = {
|
|
|
6975
6792
|
const backupManager = new BackupManager();
|
|
6976
6793
|
const writer = new ConfigWriter(backupManager);
|
|
6977
6794
|
const files = [];
|
|
6978
|
-
const srcDir =
|
|
6795
|
+
const srcDir = join18(ctx.projectRoot, ctx.srcDir);
|
|
6979
6796
|
try {
|
|
6980
|
-
const animationDir =
|
|
6797
|
+
const animationDir = join18(srcDir, "components", "animation");
|
|
6981
6798
|
await ensureDirectory(animationDir);
|
|
6982
|
-
const animatedBoxPath =
|
|
6799
|
+
const animatedBoxPath = join18(
|
|
6983
6800
|
animationDir,
|
|
6984
6801
|
`AnimatedBox.${ctx.typescript ? "tsx" : "jsx"}`
|
|
6985
6802
|
);
|
|
@@ -6992,7 +6809,7 @@ var framerMotionPlugin = {
|
|
|
6992
6809
|
backup: false
|
|
6993
6810
|
});
|
|
6994
6811
|
logger.info(`Created animated box example: ${animatedBoxPath}`);
|
|
6995
|
-
const indexPath =
|
|
6812
|
+
const indexPath = join18(
|
|
6996
6813
|
animationDir,
|
|
6997
6814
|
`index.${ctx.typescript ? "ts" : "js"}`
|
|
6998
6815
|
);
|
|
@@ -7141,7 +6958,7 @@ function getIndexContentJS7() {
|
|
|
7141
6958
|
}
|
|
7142
6959
|
|
|
7143
6960
|
// src/plugins/tooling/eslint.ts
|
|
7144
|
-
import { join as
|
|
6961
|
+
import { join as join19 } from "path";
|
|
7145
6962
|
var eslintPlugin = {
|
|
7146
6963
|
name: "eslint",
|
|
7147
6964
|
displayName: "ESLint",
|
|
@@ -7217,7 +7034,7 @@ var eslintPlugin = {
|
|
|
7217
7034
|
const files = [];
|
|
7218
7035
|
const projectRoot = ctx.projectRoot;
|
|
7219
7036
|
try {
|
|
7220
|
-
const eslintConfigPath =
|
|
7037
|
+
const eslintConfigPath = join19(projectRoot, "eslint.config.js");
|
|
7221
7038
|
const eslintConfigExists = await checkPathExists(eslintConfigPath);
|
|
7222
7039
|
if (eslintConfigExists) {
|
|
7223
7040
|
logger.warn("eslint.config.js already exists, skipping creation");
|
|
@@ -7232,7 +7049,7 @@ var eslintPlugin = {
|
|
|
7232
7049
|
});
|
|
7233
7050
|
logger.info(`Created ESLint config: ${eslintConfigPath}`);
|
|
7234
7051
|
}
|
|
7235
|
-
const packageJsonPath =
|
|
7052
|
+
const packageJsonPath = join19(projectRoot, "package.json");
|
|
7236
7053
|
const packageJsonExists = await checkPathExists(packageJsonPath);
|
|
7237
7054
|
if (packageJsonExists) {
|
|
7238
7055
|
const packageJsonContent = await readFileContent(packageJsonPath);
|
|
@@ -7391,7 +7208,7 @@ export default [
|
|
|
7391
7208
|
}
|
|
7392
7209
|
|
|
7393
7210
|
// src/plugins/tooling/prettier.ts
|
|
7394
|
-
import { join as
|
|
7211
|
+
import { join as join20 } from "path";
|
|
7395
7212
|
var prettierPlugin = {
|
|
7396
7213
|
name: "prettier",
|
|
7397
7214
|
displayName: "Prettier",
|
|
@@ -7457,7 +7274,7 @@ var prettierPlugin = {
|
|
|
7457
7274
|
const files = [];
|
|
7458
7275
|
const projectRoot = ctx.projectRoot;
|
|
7459
7276
|
try {
|
|
7460
|
-
const prettierrcPath =
|
|
7277
|
+
const prettierrcPath = join20(projectRoot, ".prettierrc.json");
|
|
7461
7278
|
const prettierrcExists = await checkPathExists(prettierrcPath);
|
|
7462
7279
|
if (prettierrcExists) {
|
|
7463
7280
|
logger.warn(".prettierrc.json already exists, skipping creation");
|
|
@@ -7472,7 +7289,7 @@ var prettierPlugin = {
|
|
|
7472
7289
|
});
|
|
7473
7290
|
logger.info(`Created Prettier config: ${prettierrcPath}`);
|
|
7474
7291
|
}
|
|
7475
|
-
const prettierignorePath =
|
|
7292
|
+
const prettierignorePath = join20(projectRoot, ".prettierignore");
|
|
7476
7293
|
const prettierignoreExists = await checkPathExists(prettierignorePath);
|
|
7477
7294
|
if (prettierignoreExists) {
|
|
7478
7295
|
logger.warn(".prettierignore already exists, skipping creation");
|
|
@@ -7487,7 +7304,7 @@ var prettierPlugin = {
|
|
|
7487
7304
|
});
|
|
7488
7305
|
logger.info(`Created .prettierignore: ${prettierignorePath}`);
|
|
7489
7306
|
}
|
|
7490
|
-
const packageJsonPath =
|
|
7307
|
+
const packageJsonPath = join20(projectRoot, "package.json");
|
|
7491
7308
|
const packageJsonExists = await checkPathExists(packageJsonPath);
|
|
7492
7309
|
if (packageJsonExists) {
|
|
7493
7310
|
const packageJsonContent = await readFileContent(packageJsonPath);
|
|
@@ -7581,8 +7398,8 @@ pnpm-lock.yaml
|
|
|
7581
7398
|
}
|
|
7582
7399
|
|
|
7583
7400
|
// src/plugins/tooling/husky.ts
|
|
7584
|
-
import { join as
|
|
7585
|
-
import { execa
|
|
7401
|
+
import { join as join21 } from "path";
|
|
7402
|
+
import { execa } from "execa";
|
|
7586
7403
|
var huskyPlugin = {
|
|
7587
7404
|
name: "husky",
|
|
7588
7405
|
displayName: "Husky",
|
|
@@ -7649,7 +7466,7 @@ var huskyPlugin = {
|
|
|
7649
7466
|
const files = [];
|
|
7650
7467
|
const projectRoot = ctx.projectRoot;
|
|
7651
7468
|
try {
|
|
7652
|
-
const gitDir =
|
|
7469
|
+
const gitDir = join21(projectRoot, ".git");
|
|
7653
7470
|
const gitExists = await checkPathExists(gitDir);
|
|
7654
7471
|
if (!gitExists) {
|
|
7655
7472
|
logger.warn(
|
|
@@ -7661,9 +7478,9 @@ var huskyPlugin = {
|
|
|
7661
7478
|
message: "Git repository not found. Please initialize Git first."
|
|
7662
7479
|
};
|
|
7663
7480
|
}
|
|
7664
|
-
const huskyDir =
|
|
7481
|
+
const huskyDir = join21(projectRoot, ".husky");
|
|
7665
7482
|
await ensureDirectory(huskyDir);
|
|
7666
|
-
const preCommitPath =
|
|
7483
|
+
const preCommitPath = join21(huskyDir, "pre-commit");
|
|
7667
7484
|
const preCommitExists = await checkPathExists(preCommitPath);
|
|
7668
7485
|
if (!preCommitExists) {
|
|
7669
7486
|
const preCommitContent = getPreCommitContent();
|
|
@@ -7676,7 +7493,7 @@ var huskyPlugin = {
|
|
|
7676
7493
|
});
|
|
7677
7494
|
logger.info(`Created pre-commit hook: ${preCommitPath}`);
|
|
7678
7495
|
}
|
|
7679
|
-
const prePushPath =
|
|
7496
|
+
const prePushPath = join21(huskyDir, "pre-push");
|
|
7680
7497
|
const prePushExists = await checkPathExists(prePushPath);
|
|
7681
7498
|
if (!prePushExists) {
|
|
7682
7499
|
const prePushContent = getPrePushContent();
|
|
@@ -7689,7 +7506,7 @@ var huskyPlugin = {
|
|
|
7689
7506
|
});
|
|
7690
7507
|
logger.info(`Created pre-push hook: ${prePushPath}`);
|
|
7691
7508
|
}
|
|
7692
|
-
const packageJsonPath =
|
|
7509
|
+
const packageJsonPath = join21(projectRoot, "package.json");
|
|
7693
7510
|
const packageJsonExists = await checkPathExists(packageJsonPath);
|
|
7694
7511
|
if (packageJsonExists) {
|
|
7695
7512
|
const packageJsonContent = await readFileContent(packageJsonPath);
|
|
@@ -7713,7 +7530,7 @@ var huskyPlugin = {
|
|
|
7713
7530
|
}
|
|
7714
7531
|
}
|
|
7715
7532
|
try {
|
|
7716
|
-
await
|
|
7533
|
+
await execa("npx", ["husky", "init"], {
|
|
7717
7534
|
cwd: projectRoot,
|
|
7718
7535
|
stdio: "inherit"
|
|
7719
7536
|
});
|
|
@@ -7769,7 +7586,7 @@ npm run test:unit
|
|
|
7769
7586
|
}
|
|
7770
7587
|
|
|
7771
7588
|
// src/plugins/utils/date-fns.ts
|
|
7772
|
-
import { join as
|
|
7589
|
+
import { join as join22 } from "path";
|
|
7773
7590
|
var dateFnsPlugin = {
|
|
7774
7591
|
name: "date-fns",
|
|
7775
7592
|
displayName: "date-fns",
|
|
@@ -7833,11 +7650,11 @@ var dateFnsPlugin = {
|
|
|
7833
7650
|
const backupManager = new BackupManager();
|
|
7834
7651
|
const writer = new ConfigWriter(backupManager);
|
|
7835
7652
|
const files = [];
|
|
7836
|
-
const srcDir =
|
|
7653
|
+
const srcDir = join22(ctx.projectRoot, ctx.srcDir);
|
|
7837
7654
|
try {
|
|
7838
|
-
const utilsDir =
|
|
7655
|
+
const utilsDir = join22(srcDir, "lib", "utils");
|
|
7839
7656
|
await ensureDirectory(utilsDir);
|
|
7840
|
-
const dateUtilsPath =
|
|
7657
|
+
const dateUtilsPath = join22(
|
|
7841
7658
|
utilsDir,
|
|
7842
7659
|
`date.${ctx.typescript ? "ts" : "js"}`
|
|
7843
7660
|
);
|
|
@@ -8053,7 +7870,7 @@ export function getMinutesDifference(date1, date2) {
|
|
|
8053
7870
|
}
|
|
8054
7871
|
|
|
8055
7872
|
// src/plugins/testing/react-testing-library.ts
|
|
8056
|
-
import { join as
|
|
7873
|
+
import { join as join23 } from "path";
|
|
8057
7874
|
var reactTestingLibraryPlugin = {
|
|
8058
7875
|
name: "react-testing-library",
|
|
8059
7876
|
displayName: "React Testing Library",
|
|
@@ -8123,9 +7940,9 @@ var reactTestingLibraryPlugin = {
|
|
|
8123
7940
|
const writer = new ConfigWriter(backupManager);
|
|
8124
7941
|
const files = [];
|
|
8125
7942
|
const projectRoot = ctx.projectRoot;
|
|
8126
|
-
const srcDir =
|
|
7943
|
+
const srcDir = join23(projectRoot, ctx.srcDir);
|
|
8127
7944
|
try {
|
|
8128
|
-
const setupTestsPath =
|
|
7945
|
+
const setupTestsPath = join23(
|
|
8129
7946
|
projectRoot,
|
|
8130
7947
|
`setupTests.${ctx.typescript ? "ts" : "js"}`
|
|
8131
7948
|
);
|
|
@@ -8141,9 +7958,9 @@ var reactTestingLibraryPlugin = {
|
|
|
8141
7958
|
});
|
|
8142
7959
|
logger.info(`Created setupTests file: ${setupTestsPath}`);
|
|
8143
7960
|
}
|
|
8144
|
-
const testDir =
|
|
7961
|
+
const testDir = join23(srcDir, "components", "__tests__");
|
|
8145
7962
|
await ensureDirectory(testDir);
|
|
8146
|
-
const exampleTestPath =
|
|
7963
|
+
const exampleTestPath = join23(
|
|
8147
7964
|
testDir,
|
|
8148
7965
|
`Example.test.${ctx.typescript ? "tsx" : "jsx"}`
|
|
8149
7966
|
);
|
|
@@ -8159,7 +7976,7 @@ var reactTestingLibraryPlugin = {
|
|
|
8159
7976
|
});
|
|
8160
7977
|
logger.info(`Created example test: ${exampleTestPath}`);
|
|
8161
7978
|
}
|
|
8162
|
-
const vitestConfigPath =
|
|
7979
|
+
const vitestConfigPath = join23(projectRoot, "vitest.config.ts");
|
|
8163
7980
|
const vitestConfigExists = await checkPathExists(vitestConfigPath);
|
|
8164
7981
|
if (vitestConfigExists) {
|
|
8165
7982
|
logger.info(
|
|
@@ -8379,12 +8196,6 @@ if (validatedRegistry.length !== pluginRegistry.length) {
|
|
|
8379
8196
|
}
|
|
8380
8197
|
|
|
8381
8198
|
export {
|
|
8382
|
-
logger,
|
|
8383
|
-
readPackageJson,
|
|
8384
|
-
readTsConfig,
|
|
8385
|
-
checkPathExists,
|
|
8386
|
-
detectPackageManager,
|
|
8387
|
-
installPackages,
|
|
8388
8199
|
ConfigWriter,
|
|
8389
8200
|
BackupManager,
|
|
8390
8201
|
pluginRegistry,
|