@configjs/cli 1.0.3 → 1.0.4
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-OTK3GSIY.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-7ZLAP62L.js → chunk-GICPMTU2.js} +247 -440
- package/dist/chunk-QGM4M3NI.js +37 -0
- package/dist/cli.js +23 -4
- package/dist/{install-ML3FB63K.js → install-LJAWO26W.js} +57 -239
- package/dist/installed-BXP7ZWOU.js +41 -0
- package/dist/{list-CBEUUZUI.js → list-QC4T762H.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);
|
|
@@ -2520,7 +2333,7 @@ export default App
|
|
|
2520
2333
|
}
|
|
2521
2334
|
|
|
2522
2335
|
// src/plugins/http/axios.ts
|
|
2523
|
-
import { resolve as
|
|
2336
|
+
import { resolve as resolve8, join as join6 } from "path";
|
|
2524
2337
|
var axiosPlugin = {
|
|
2525
2338
|
name: "axios",
|
|
2526
2339
|
displayName: "Axios",
|
|
@@ -2585,12 +2398,12 @@ var axiosPlugin = {
|
|
|
2585
2398
|
const backupManager = new BackupManager();
|
|
2586
2399
|
const writer = new ConfigWriter(backupManager);
|
|
2587
2400
|
const files = [];
|
|
2588
|
-
const srcDir =
|
|
2401
|
+
const srcDir = resolve8(ctx.projectRoot, ctx.srcDir);
|
|
2589
2402
|
const extension = ctx.typescript ? "ts" : "js";
|
|
2590
2403
|
try {
|
|
2591
|
-
const libDir =
|
|
2404
|
+
const libDir = join6(srcDir, "lib");
|
|
2592
2405
|
await ensureDirectory(libDir);
|
|
2593
|
-
const apiPath =
|
|
2406
|
+
const apiPath = join6(libDir, `api.${extension}`);
|
|
2594
2407
|
const apiContent = ctx.typescript ? getApiContentTS() : getApiContentJS();
|
|
2595
2408
|
await writer.createFile(apiPath, apiContent);
|
|
2596
2409
|
files.push({
|
|
@@ -2601,7 +2414,7 @@ var axiosPlugin = {
|
|
|
2601
2414
|
});
|
|
2602
2415
|
logger.info(`Created Axios instance: ${apiPath}`);
|
|
2603
2416
|
if (ctx.typescript) {
|
|
2604
|
-
const typesPath =
|
|
2417
|
+
const typesPath = join6(libDir, "api-types.ts");
|
|
2605
2418
|
const typesContent = getApiTypesContentTS();
|
|
2606
2419
|
await writer.createFile(typesPath, typesContent);
|
|
2607
2420
|
files.push({
|
|
@@ -2855,7 +2668,7 @@ export interface ApiError {
|
|
|
2855
2668
|
}
|
|
2856
2669
|
|
|
2857
2670
|
// src/plugins/http/tanstack-query.ts
|
|
2858
|
-
import { resolve as
|
|
2671
|
+
import { resolve as resolve9, join as join7 } from "path";
|
|
2859
2672
|
var tanstackQueryPlugin = {
|
|
2860
2673
|
name: "@tanstack/react-query",
|
|
2861
2674
|
displayName: "TanStack Query",
|
|
@@ -2924,12 +2737,12 @@ var tanstackQueryPlugin = {
|
|
|
2924
2737
|
const backupManager = new BackupManager();
|
|
2925
2738
|
const writer = new ConfigWriter(backupManager);
|
|
2926
2739
|
const files = [];
|
|
2927
|
-
const srcDir =
|
|
2740
|
+
const srcDir = resolve9(ctx.projectRoot, ctx.srcDir);
|
|
2928
2741
|
const extension = ctx.typescript ? "ts" : "js";
|
|
2929
2742
|
try {
|
|
2930
|
-
const libDir =
|
|
2743
|
+
const libDir = join7(srcDir, "lib");
|
|
2931
2744
|
await ensureDirectory(libDir);
|
|
2932
|
-
const queryClientPath =
|
|
2745
|
+
const queryClientPath = join7(libDir, `query-client.${extension}`);
|
|
2933
2746
|
const queryClientContent = ctx.typescript ? getQueryClientContentTS() : getQueryClientContentJS();
|
|
2934
2747
|
await writer.createFile(queryClientPath, queryClientContent);
|
|
2935
2748
|
files.push({
|
|
@@ -2939,9 +2752,9 @@ var tanstackQueryPlugin = {
|
|
|
2939
2752
|
backup: false
|
|
2940
2753
|
});
|
|
2941
2754
|
logger.info(`Created query client: ${queryClientPath}`);
|
|
2942
|
-
const queriesDir =
|
|
2755
|
+
const queriesDir = join7(libDir, "queries");
|
|
2943
2756
|
await ensureDirectory(queriesDir);
|
|
2944
|
-
const exampleQueryPath =
|
|
2757
|
+
const exampleQueryPath = join7(queriesDir, `example.${extension}`);
|
|
2945
2758
|
const exampleQueryContent = ctx.typescript ? getExampleQueryContentTS() : getExampleQueryContentJS();
|
|
2946
2759
|
await writer.createFile(exampleQueryPath, exampleQueryContent);
|
|
2947
2760
|
files.push({
|
|
@@ -2951,9 +2764,9 @@ var tanstackQueryPlugin = {
|
|
|
2951
2764
|
backup: false
|
|
2952
2765
|
});
|
|
2953
2766
|
logger.info(`Created example query: ${exampleQueryPath}`);
|
|
2954
|
-
const mutationsDir =
|
|
2767
|
+
const mutationsDir = join7(libDir, "mutations");
|
|
2955
2768
|
await ensureDirectory(mutationsDir);
|
|
2956
|
-
const exampleMutationPath =
|
|
2769
|
+
const exampleMutationPath = join7(mutationsDir, `example.${extension}`);
|
|
2957
2770
|
const exampleMutationContent = ctx.typescript ? getExampleMutationContentTS() : getExampleMutationContentJS();
|
|
2958
2771
|
await writer.createFile(exampleMutationPath, exampleMutationContent);
|
|
2959
2772
|
files.push({
|
|
@@ -2963,7 +2776,7 @@ var tanstackQueryPlugin = {
|
|
|
2963
2776
|
backup: false
|
|
2964
2777
|
});
|
|
2965
2778
|
logger.info(`Created example mutation: ${exampleMutationPath}`);
|
|
2966
|
-
const appPath =
|
|
2779
|
+
const appPath = join7(srcDir, `App.${ctx.typescript ? "tsx" : "jsx"}`);
|
|
2967
2780
|
const appExists = await checkPathExists(appPath);
|
|
2968
2781
|
if (appExists) {
|
|
2969
2782
|
const appContent = await readFileContent(appPath);
|
|
@@ -3405,7 +3218,7 @@ export default App
|
|
|
3405
3218
|
}
|
|
3406
3219
|
|
|
3407
3220
|
// src/plugins/css/tailwindcss.ts
|
|
3408
|
-
import { resolve as
|
|
3221
|
+
import { resolve as resolve10, join as join8 } from "path";
|
|
3409
3222
|
var tailwindcssPlugin = {
|
|
3410
3223
|
name: "tailwindcss",
|
|
3411
3224
|
displayName: "TailwindCSS",
|
|
@@ -3471,10 +3284,10 @@ var tailwindcssPlugin = {
|
|
|
3471
3284
|
const writer = new ConfigWriter(backupManager);
|
|
3472
3285
|
const files = [];
|
|
3473
3286
|
const projectRoot = ctx.projectRoot;
|
|
3474
|
-
const srcDir =
|
|
3287
|
+
const srcDir = resolve10(projectRoot, ctx.srcDir);
|
|
3475
3288
|
const extension = ctx.typescript ? "ts" : "js";
|
|
3476
3289
|
try {
|
|
3477
|
-
const viteConfigPath =
|
|
3290
|
+
const viteConfigPath = join8(projectRoot, `vite.config.${extension}`);
|
|
3478
3291
|
const viteConfigExists = await checkPathExists(viteConfigPath);
|
|
3479
3292
|
if (viteConfigExists) {
|
|
3480
3293
|
const viteConfigContent = await readFileContent(viteConfigPath);
|
|
@@ -3504,10 +3317,10 @@ var tailwindcssPlugin = {
|
|
|
3504
3317
|
logger.info(`Created vite.config.${extension} with TailwindCSS plugin`);
|
|
3505
3318
|
}
|
|
3506
3319
|
const cssFiles = [
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3320
|
+
join8(srcDir, "index.css"),
|
|
3321
|
+
join8(srcDir, "main.css"),
|
|
3322
|
+
join8(srcDir, "app.css"),
|
|
3323
|
+
join8(srcDir, "styles.css")
|
|
3511
3324
|
];
|
|
3512
3325
|
let cssFileModified = false;
|
|
3513
3326
|
for (const cssPath of cssFiles) {
|
|
@@ -3528,7 +3341,7 @@ var tailwindcssPlugin = {
|
|
|
3528
3341
|
}
|
|
3529
3342
|
}
|
|
3530
3343
|
if (!cssFileModified) {
|
|
3531
|
-
const cssPath =
|
|
3344
|
+
const cssPath = join8(srcDir, "index.css");
|
|
3532
3345
|
const cssContent = getCssContent();
|
|
3533
3346
|
await writer.createFile(cssPath, cssContent);
|
|
3534
3347
|
files.push({
|
|
@@ -3663,7 +3476,7 @@ ${content}`;
|
|
|
3663
3476
|
}
|
|
3664
3477
|
|
|
3665
3478
|
// src/plugins/css/styled-components.ts
|
|
3666
|
-
import { resolve as
|
|
3479
|
+
import { resolve as resolve11, join as join9 } from "path";
|
|
3667
3480
|
var styledComponentsPlugin = {
|
|
3668
3481
|
name: "styled-components",
|
|
3669
3482
|
displayName: "Styled Components",
|
|
@@ -3741,12 +3554,12 @@ var styledComponentsPlugin = {
|
|
|
3741
3554
|
const backupManager = new BackupManager();
|
|
3742
3555
|
const writer = new ConfigWriter(backupManager);
|
|
3743
3556
|
const files = [];
|
|
3744
|
-
const srcDir =
|
|
3557
|
+
const srcDir = resolve11(ctx.projectRoot, ctx.srcDir);
|
|
3745
3558
|
const extension = ctx.typescript ? "tsx" : "jsx";
|
|
3746
3559
|
try {
|
|
3747
|
-
const styledDir =
|
|
3560
|
+
const styledDir = join9(srcDir, "components", "styled");
|
|
3748
3561
|
await ensureDirectory(styledDir);
|
|
3749
|
-
const buttonPath =
|
|
3562
|
+
const buttonPath = join9(styledDir, `Button.${extension}`);
|
|
3750
3563
|
const buttonContent = ctx.typescript ? getButtonContentTS() : getButtonContentJS();
|
|
3751
3564
|
await writer.createFile(buttonPath, buttonContent);
|
|
3752
3565
|
files.push({
|
|
@@ -3756,7 +3569,7 @@ var styledComponentsPlugin = {
|
|
|
3756
3569
|
backup: false
|
|
3757
3570
|
});
|
|
3758
3571
|
logger.info(`Created Button component: ${buttonPath}`);
|
|
3759
|
-
const cardPath =
|
|
3572
|
+
const cardPath = join9(styledDir, `Card.${extension}`);
|
|
3760
3573
|
const cardContent = ctx.typescript ? getCardContentTS() : getCardContentJS();
|
|
3761
3574
|
await writer.createFile(cardPath, cardContent);
|
|
3762
3575
|
files.push({
|
|
@@ -3766,7 +3579,7 @@ var styledComponentsPlugin = {
|
|
|
3766
3579
|
backup: false
|
|
3767
3580
|
});
|
|
3768
3581
|
logger.info(`Created Card component: ${cardPath}`);
|
|
3769
|
-
const indexPath =
|
|
3582
|
+
const indexPath = join9(styledDir, `index.${ctx.typescript ? "ts" : "js"}`);
|
|
3770
3583
|
const indexContent = getIndexContent();
|
|
3771
3584
|
await writer.createFile(indexPath, indexContent);
|
|
3772
3585
|
files.push({
|
|
@@ -3987,7 +3800,7 @@ export { Card } from './Card'
|
|
|
3987
3800
|
}
|
|
3988
3801
|
|
|
3989
3802
|
// src/plugins/css/emotion.ts
|
|
3990
|
-
import { resolve as
|
|
3803
|
+
import { resolve as resolve12, join as join10 } from "path";
|
|
3991
3804
|
var emotionPlugin = {
|
|
3992
3805
|
name: "@emotion/react",
|
|
3993
3806
|
displayName: "Emotion",
|
|
@@ -4060,12 +3873,12 @@ var emotionPlugin = {
|
|
|
4060
3873
|
const backupManager = new BackupManager();
|
|
4061
3874
|
const writer = new ConfigWriter(backupManager);
|
|
4062
3875
|
const files = [];
|
|
4063
|
-
const srcDir =
|
|
3876
|
+
const srcDir = resolve12(ctx.projectRoot, ctx.srcDir);
|
|
4064
3877
|
const extension = ctx.typescript ? "tsx" : "jsx";
|
|
4065
3878
|
try {
|
|
4066
|
-
const emotionDir =
|
|
3879
|
+
const emotionDir = join10(srcDir, "components", "emotion");
|
|
4067
3880
|
await ensureDirectory(emotionDir);
|
|
4068
|
-
const buttonPath =
|
|
3881
|
+
const buttonPath = join10(emotionDir, `Button.${extension}`);
|
|
4069
3882
|
const buttonContent = ctx.typescript ? getButtonContentTS2() : getButtonContentJS2();
|
|
4070
3883
|
await writer.createFile(buttonPath, buttonContent);
|
|
4071
3884
|
files.push({
|
|
@@ -4075,7 +3888,7 @@ var emotionPlugin = {
|
|
|
4075
3888
|
backup: false
|
|
4076
3889
|
});
|
|
4077
3890
|
logger.info(`Created Button component: ${buttonPath}`);
|
|
4078
|
-
const cardPath =
|
|
3891
|
+
const cardPath = join10(emotionDir, `Card.${extension}`);
|
|
4079
3892
|
const cardContent = ctx.typescript ? getCardContentTS2() : getCardContentJS2();
|
|
4080
3893
|
await writer.createFile(cardPath, cardContent);
|
|
4081
3894
|
files.push({
|
|
@@ -4085,7 +3898,7 @@ var emotionPlugin = {
|
|
|
4085
3898
|
backup: false
|
|
4086
3899
|
});
|
|
4087
3900
|
logger.info(`Created Card component: ${cardPath}`);
|
|
4088
|
-
const indexPath =
|
|
3901
|
+
const indexPath = join10(
|
|
4089
3902
|
emotionDir,
|
|
4090
3903
|
`index.${ctx.typescript ? "ts" : "js"}`
|
|
4091
3904
|
);
|
|
@@ -4318,7 +4131,7 @@ export { Card } from './Card'
|
|
|
4318
4131
|
}
|
|
4319
4132
|
|
|
4320
4133
|
// src/plugins/css/react-bootstrap.ts
|
|
4321
|
-
import { resolve as
|
|
4134
|
+
import { resolve as resolve13, join as join11 } from "path";
|
|
4322
4135
|
var reactBootstrapPlugin = {
|
|
4323
4136
|
name: "react-bootstrap",
|
|
4324
4137
|
displayName: "React Bootstrap",
|
|
@@ -4387,12 +4200,12 @@ var reactBootstrapPlugin = {
|
|
|
4387
4200
|
const backupManager = new BackupManager();
|
|
4388
4201
|
const writer = new ConfigWriter(backupManager);
|
|
4389
4202
|
const files = [];
|
|
4390
|
-
const srcDir =
|
|
4203
|
+
const srcDir = resolve13(ctx.projectRoot, ctx.srcDir);
|
|
4391
4204
|
const extension = ctx.typescript ? "tsx" : "jsx";
|
|
4392
4205
|
try {
|
|
4393
|
-
const bootstrapDir =
|
|
4206
|
+
const bootstrapDir = join11(srcDir, "components", "bootstrap");
|
|
4394
4207
|
await ensureDirectory(bootstrapDir);
|
|
4395
|
-
const examplePath =
|
|
4208
|
+
const examplePath = join11(bootstrapDir, `Example.${extension}`);
|
|
4396
4209
|
const exampleContent = ctx.typescript ? getExampleContentTS() : getExampleContentJS();
|
|
4397
4210
|
await writer.createFile(examplePath, exampleContent);
|
|
4398
4211
|
files.push({
|
|
@@ -4402,7 +4215,7 @@ var reactBootstrapPlugin = {
|
|
|
4402
4215
|
backup: false
|
|
4403
4216
|
});
|
|
4404
4217
|
logger.info(`Created Bootstrap example: ${examplePath}`);
|
|
4405
|
-
const indexPath =
|
|
4218
|
+
const indexPath = join11(srcDir, `index.${ctx.typescript ? "tsx" : "jsx"}`);
|
|
4406
4219
|
const indexExists = await checkPathExists(indexPath);
|
|
4407
4220
|
if (indexExists) {
|
|
4408
4221
|
const indexContent = await readFileContent(indexPath);
|
|
@@ -4597,7 +4410,7 @@ function injectBootstrapCSS(content) {
|
|
|
4597
4410
|
}
|
|
4598
4411
|
|
|
4599
4412
|
// src/plugins/forms/react-hook-form.ts
|
|
4600
|
-
import { resolve as
|
|
4413
|
+
import { resolve as resolve14, join as join12 } from "path";
|
|
4601
4414
|
var reactHookFormPlugin = {
|
|
4602
4415
|
name: "react-hook-form",
|
|
4603
4416
|
displayName: "React Hook Form",
|
|
@@ -4661,12 +4474,12 @@ var reactHookFormPlugin = {
|
|
|
4661
4474
|
const backupManager = new BackupManager();
|
|
4662
4475
|
const writer = new ConfigWriter(backupManager);
|
|
4663
4476
|
const files = [];
|
|
4664
|
-
const srcDir =
|
|
4477
|
+
const srcDir = resolve14(ctx.projectRoot, ctx.srcDir);
|
|
4665
4478
|
const extension = ctx.typescript ? "tsx" : "jsx";
|
|
4666
4479
|
try {
|
|
4667
|
-
const formsDir =
|
|
4480
|
+
const formsDir = join12(srcDir, "components", "forms");
|
|
4668
4481
|
await ensureDirectory(formsDir);
|
|
4669
|
-
const exampleFormPath =
|
|
4482
|
+
const exampleFormPath = join12(formsDir, `ExampleForm.${extension}`);
|
|
4670
4483
|
const exampleFormContent = ctx.typescript ? getExampleFormContentTS() : getExampleFormContentJS();
|
|
4671
4484
|
await writer.createFile(exampleFormPath, exampleFormContent);
|
|
4672
4485
|
files.push({
|
|
@@ -4676,7 +4489,7 @@ var reactHookFormPlugin = {
|
|
|
4676
4489
|
backup: false
|
|
4677
4490
|
});
|
|
4678
4491
|
logger.info(`Created example form: ${exampleFormPath}`);
|
|
4679
|
-
const validatedFormPath =
|
|
4492
|
+
const validatedFormPath = join12(formsDir, `ValidatedForm.${extension}`);
|
|
4680
4493
|
const validatedFormContent = ctx.typescript ? getValidatedFormContentTS() : getValidatedFormContentJS();
|
|
4681
4494
|
await writer.createFile(validatedFormPath, validatedFormContent);
|
|
4682
4495
|
files.push({
|
|
@@ -4686,7 +4499,7 @@ var reactHookFormPlugin = {
|
|
|
4686
4499
|
backup: false
|
|
4687
4500
|
});
|
|
4688
4501
|
logger.info(`Created validated form: ${validatedFormPath}`);
|
|
4689
|
-
const indexPath =
|
|
4502
|
+
const indexPath = join12(formsDir, `index.${ctx.typescript ? "ts" : "js"}`);
|
|
4690
4503
|
const indexContent = ctx.typescript ? getIndexContentTS3() : getIndexContentJS3();
|
|
4691
4504
|
await writer.createFile(indexPath, indexContent);
|
|
4692
4505
|
files.push({
|
|
@@ -5122,7 +4935,7 @@ export { ValidatedForm } from './ValidatedForm'
|
|
|
5122
4935
|
}
|
|
5123
4936
|
|
|
5124
4937
|
// src/plugins/forms/zod.ts
|
|
5125
|
-
import { join as
|
|
4938
|
+
import { join as join13 } from "path";
|
|
5126
4939
|
var zodPlugin = {
|
|
5127
4940
|
name: "zod",
|
|
5128
4941
|
displayName: "Zod",
|
|
@@ -5187,11 +5000,11 @@ var zodPlugin = {
|
|
|
5187
5000
|
const backupManager = new BackupManager();
|
|
5188
5001
|
const writer = new ConfigWriter(backupManager);
|
|
5189
5002
|
const files = [];
|
|
5190
|
-
const srcDir =
|
|
5003
|
+
const srcDir = join13(ctx.projectRoot, ctx.srcDir);
|
|
5191
5004
|
try {
|
|
5192
|
-
const schemasDir =
|
|
5005
|
+
const schemasDir = join13(srcDir, "lib", "schemas");
|
|
5193
5006
|
await ensureDirectory(schemasDir);
|
|
5194
|
-
const userSchemaPath =
|
|
5007
|
+
const userSchemaPath = join13(
|
|
5195
5008
|
schemasDir,
|
|
5196
5009
|
`user.${ctx.typescript ? "ts" : "js"}`
|
|
5197
5010
|
);
|
|
@@ -5204,7 +5017,7 @@ var zodPlugin = {
|
|
|
5204
5017
|
backup: false
|
|
5205
5018
|
});
|
|
5206
5019
|
logger.info(`Created user schema: ${userSchemaPath}`);
|
|
5207
|
-
const indexPath =
|
|
5020
|
+
const indexPath = join13(
|
|
5208
5021
|
schemasDir,
|
|
5209
5022
|
`index.${ctx.typescript ? "ts" : "js"}`
|
|
5210
5023
|
);
|
|
@@ -5314,7 +5127,7 @@ function getIndexContentJS4() {
|
|
|
5314
5127
|
}
|
|
5315
5128
|
|
|
5316
5129
|
// src/plugins/ui/shadcn-ui.ts
|
|
5317
|
-
import { join as
|
|
5130
|
+
import { join as join14 } from "path";
|
|
5318
5131
|
var shadcnUiPlugin = {
|
|
5319
5132
|
name: "shadcn-ui",
|
|
5320
5133
|
displayName: "Shadcn/ui",
|
|
@@ -5401,7 +5214,7 @@ var shadcnUiPlugin = {
|
|
|
5401
5214
|
const writer = new ConfigWriter(backupManager);
|
|
5402
5215
|
const files = [];
|
|
5403
5216
|
const projectRoot = ctx.projectRoot;
|
|
5404
|
-
const srcDir =
|
|
5217
|
+
const srcDir = join14(projectRoot, ctx.srcDir);
|
|
5405
5218
|
try {
|
|
5406
5219
|
const tailwindInstalled = ctx.dependencies["tailwindcss"] !== void 0 || ctx.devDependencies["tailwindcss"] !== void 0;
|
|
5407
5220
|
if (!tailwindInstalled) {
|
|
@@ -5414,7 +5227,7 @@ var shadcnUiPlugin = {
|
|
|
5414
5227
|
message: "TailwindCSS is required for Shadcn/ui. Please install TailwindCSS first."
|
|
5415
5228
|
};
|
|
5416
5229
|
}
|
|
5417
|
-
const componentsJsonPath =
|
|
5230
|
+
const componentsJsonPath = join14(projectRoot, "components.json");
|
|
5418
5231
|
const componentsJsonExists = await checkPathExists(componentsJsonPath);
|
|
5419
5232
|
if (componentsJsonExists) {
|
|
5420
5233
|
logger.warn("components.json already exists, skipping creation");
|
|
@@ -5429,9 +5242,9 @@ var shadcnUiPlugin = {
|
|
|
5429
5242
|
});
|
|
5430
5243
|
logger.info(`Created components.json: ${componentsJsonPath}`);
|
|
5431
5244
|
}
|
|
5432
|
-
const libDir =
|
|
5245
|
+
const libDir = join14(srcDir, "lib");
|
|
5433
5246
|
await ensureDirectory(libDir);
|
|
5434
|
-
const utilsPath =
|
|
5247
|
+
const utilsPath = join14(libDir, `utils.${ctx.typescript ? "ts" : "js"}`);
|
|
5435
5248
|
const utilsExists = await checkPathExists(utilsPath);
|
|
5436
5249
|
if (utilsExists) {
|
|
5437
5250
|
logger.warn(
|
|
@@ -5461,9 +5274,9 @@ var shadcnUiPlugin = {
|
|
|
5461
5274
|
});
|
|
5462
5275
|
logger.info(`Created utils file: ${utilsPath}`);
|
|
5463
5276
|
}
|
|
5464
|
-
const uiDir =
|
|
5277
|
+
const uiDir = join14(srcDir, "components", "ui");
|
|
5465
5278
|
await ensureDirectory(uiDir);
|
|
5466
|
-
const buttonPath =
|
|
5279
|
+
const buttonPath = join14(uiDir, `button.${ctx.typescript ? "tsx" : "jsx"}`);
|
|
5467
5280
|
const buttonExists = await checkPathExists(buttonPath);
|
|
5468
5281
|
if (!buttonExists) {
|
|
5469
5282
|
const buttonContent = ctx.typescript ? getButtonContentTS3() : getButtonContentJS3();
|
|
@@ -5476,7 +5289,7 @@ var shadcnUiPlugin = {
|
|
|
5476
5289
|
});
|
|
5477
5290
|
logger.info(`Created Button component: ${buttonPath}`);
|
|
5478
5291
|
}
|
|
5479
|
-
const cssPath =
|
|
5292
|
+
const cssPath = join14(srcDir, "index.css");
|
|
5480
5293
|
const cssExists = await checkPathExists(cssPath);
|
|
5481
5294
|
if (cssExists) {
|
|
5482
5295
|
const cssContent = await readFileContent(cssPath);
|
|
@@ -5786,7 +5599,7 @@ function getShadcnCSSVariables() {
|
|
|
5786
5599
|
}
|
|
5787
5600
|
|
|
5788
5601
|
// src/plugins/ui/radix-ui.ts
|
|
5789
|
-
import { join as
|
|
5602
|
+
import { join as join15 } from "path";
|
|
5790
5603
|
var radixUiPlugin = {
|
|
5791
5604
|
name: "radix-ui",
|
|
5792
5605
|
displayName: "Radix UI",
|
|
@@ -5863,12 +5676,12 @@ var radixUiPlugin = {
|
|
|
5863
5676
|
const backupManager = new BackupManager();
|
|
5864
5677
|
const writer = new ConfigWriter(backupManager);
|
|
5865
5678
|
const files = [];
|
|
5866
|
-
const srcDir =
|
|
5679
|
+
const srcDir = join15(ctx.projectRoot, ctx.srcDir);
|
|
5867
5680
|
const extension = ctx.typescript ? "tsx" : "jsx";
|
|
5868
5681
|
try {
|
|
5869
|
-
const radixDir =
|
|
5682
|
+
const radixDir = join15(srcDir, "components", "radix");
|
|
5870
5683
|
await ensureDirectory(radixDir);
|
|
5871
|
-
const dialogPath =
|
|
5684
|
+
const dialogPath = join15(radixDir, `Dialog.${extension}`);
|
|
5872
5685
|
const dialogContent = ctx.typescript ? getDialogContentTS() : getDialogContentJS();
|
|
5873
5686
|
await writer.createFile(dialogPath, dialogContent);
|
|
5874
5687
|
files.push({
|
|
@@ -5878,7 +5691,7 @@ var radixUiPlugin = {
|
|
|
5878
5691
|
backup: false
|
|
5879
5692
|
});
|
|
5880
5693
|
logger.info(`Created Dialog component: ${dialogPath}`);
|
|
5881
|
-
const dropdownMenuPath =
|
|
5694
|
+
const dropdownMenuPath = join15(radixDir, `DropdownMenu.${extension}`);
|
|
5882
5695
|
const dropdownMenuContent = ctx.typescript ? getDropdownMenuContentTS() : getDropdownMenuContentJS();
|
|
5883
5696
|
await writer.createFile(dropdownMenuPath, dropdownMenuContent);
|
|
5884
5697
|
files.push({
|
|
@@ -5888,7 +5701,7 @@ var radixUiPlugin = {
|
|
|
5888
5701
|
backup: false
|
|
5889
5702
|
});
|
|
5890
5703
|
logger.info(`Created DropdownMenu component: ${dropdownMenuPath}`);
|
|
5891
|
-
const indexPath =
|
|
5704
|
+
const indexPath = join15(radixDir, `index.${ctx.typescript ? "ts" : "js"}`);
|
|
5892
5705
|
const indexContent = ctx.typescript ? getIndexContentTS5() : getIndexContentJS5();
|
|
5893
5706
|
await writer.createFile(indexPath, indexContent);
|
|
5894
5707
|
files.push({
|
|
@@ -6516,7 +6329,7 @@ export {
|
|
|
6516
6329
|
}
|
|
6517
6330
|
|
|
6518
6331
|
// src/plugins/ui/react-icons.ts
|
|
6519
|
-
import { join as
|
|
6332
|
+
import { join as join16 } from "path";
|
|
6520
6333
|
var reactIconsPlugin = {
|
|
6521
6334
|
name: "react-icons",
|
|
6522
6335
|
displayName: "React Icons",
|
|
@@ -6581,11 +6394,11 @@ var reactIconsPlugin = {
|
|
|
6581
6394
|
const backupManager = new BackupManager();
|
|
6582
6395
|
const writer = new ConfigWriter(backupManager);
|
|
6583
6396
|
const files = [];
|
|
6584
|
-
const srcDir =
|
|
6397
|
+
const srcDir = join16(ctx.projectRoot, ctx.srcDir);
|
|
6585
6398
|
try {
|
|
6586
|
-
const iconsDir =
|
|
6399
|
+
const iconsDir = join16(srcDir, "components", "icons");
|
|
6587
6400
|
await ensureDirectory(iconsDir);
|
|
6588
|
-
const iconExamplePath =
|
|
6401
|
+
const iconExamplePath = join16(
|
|
6589
6402
|
iconsDir,
|
|
6590
6403
|
`IconExample.${ctx.typescript ? "tsx" : "jsx"}`
|
|
6591
6404
|
);
|
|
@@ -6598,7 +6411,7 @@ var reactIconsPlugin = {
|
|
|
6598
6411
|
backup: false
|
|
6599
6412
|
});
|
|
6600
6413
|
logger.info(`Created icon example: ${iconExamplePath}`);
|
|
6601
|
-
const indexPath =
|
|
6414
|
+
const indexPath = join16(iconsDir, `index.${ctx.typescript ? "ts" : "js"}`);
|
|
6602
6415
|
const indexContent = ctx.typescript ? getIndexContentTS6() : getIndexContentJS6();
|
|
6603
6416
|
await writer.createFile(indexPath, indexContent);
|
|
6604
6417
|
files.push({
|
|
@@ -6714,7 +6527,7 @@ export { MdHome, MdSettings, MdSearch } from 'react-icons/md'
|
|
|
6714
6527
|
}
|
|
6715
6528
|
|
|
6716
6529
|
// src/plugins/ui/react-hot-toast.ts
|
|
6717
|
-
import { join as
|
|
6530
|
+
import { join as join17 } from "path";
|
|
6718
6531
|
var reactHotToastPlugin = {
|
|
6719
6532
|
name: "react-hot-toast",
|
|
6720
6533
|
displayName: "React Hot Toast",
|
|
@@ -6778,12 +6591,12 @@ var reactHotToastPlugin = {
|
|
|
6778
6591
|
const backupManager = new BackupManager();
|
|
6779
6592
|
const writer = new ConfigWriter(backupManager);
|
|
6780
6593
|
const files = [];
|
|
6781
|
-
const srcDir =
|
|
6594
|
+
const srcDir = join17(ctx.projectRoot, ctx.srcDir);
|
|
6782
6595
|
const extension = ctx.typescript ? "tsx" : "jsx";
|
|
6783
6596
|
try {
|
|
6784
|
-
const appPath =
|
|
6785
|
-
const mainPath =
|
|
6786
|
-
const indexPath =
|
|
6597
|
+
const appPath = join17(srcDir, `App.${extension}`);
|
|
6598
|
+
const mainPath = join17(srcDir, `main.${extension}`);
|
|
6599
|
+
const indexPath = join17(srcDir, `index.${extension}`);
|
|
6787
6600
|
let targetPath = null;
|
|
6788
6601
|
let targetContent = "";
|
|
6789
6602
|
if (await checkPathExists(appPath)) {
|
|
@@ -6813,7 +6626,7 @@ var reactHotToastPlugin = {
|
|
|
6813
6626
|
logger.warn("Toaster already configured in the app");
|
|
6814
6627
|
}
|
|
6815
6628
|
} else {
|
|
6816
|
-
const newAppPath =
|
|
6629
|
+
const newAppPath = join17(srcDir, `App.${extension}`);
|
|
6817
6630
|
const newAppContent = ctx.typescript ? getAppContentTS6() : getAppContentJS6();
|
|
6818
6631
|
await writer.createFile(newAppPath, newAppContent);
|
|
6819
6632
|
files.push({
|
|
@@ -6910,7 +6723,7 @@ export default App
|
|
|
6910
6723
|
}
|
|
6911
6724
|
|
|
6912
6725
|
// src/plugins/animation/framer-motion.ts
|
|
6913
|
-
import { join as
|
|
6726
|
+
import { join as join18 } from "path";
|
|
6914
6727
|
var framerMotionPlugin = {
|
|
6915
6728
|
name: "framer-motion",
|
|
6916
6729
|
displayName: "Framer Motion",
|
|
@@ -6975,11 +6788,11 @@ var framerMotionPlugin = {
|
|
|
6975
6788
|
const backupManager = new BackupManager();
|
|
6976
6789
|
const writer = new ConfigWriter(backupManager);
|
|
6977
6790
|
const files = [];
|
|
6978
|
-
const srcDir =
|
|
6791
|
+
const srcDir = join18(ctx.projectRoot, ctx.srcDir);
|
|
6979
6792
|
try {
|
|
6980
|
-
const animationDir =
|
|
6793
|
+
const animationDir = join18(srcDir, "components", "animation");
|
|
6981
6794
|
await ensureDirectory(animationDir);
|
|
6982
|
-
const animatedBoxPath =
|
|
6795
|
+
const animatedBoxPath = join18(
|
|
6983
6796
|
animationDir,
|
|
6984
6797
|
`AnimatedBox.${ctx.typescript ? "tsx" : "jsx"}`
|
|
6985
6798
|
);
|
|
@@ -6992,7 +6805,7 @@ var framerMotionPlugin = {
|
|
|
6992
6805
|
backup: false
|
|
6993
6806
|
});
|
|
6994
6807
|
logger.info(`Created animated box example: ${animatedBoxPath}`);
|
|
6995
|
-
const indexPath =
|
|
6808
|
+
const indexPath = join18(
|
|
6996
6809
|
animationDir,
|
|
6997
6810
|
`index.${ctx.typescript ? "ts" : "js"}`
|
|
6998
6811
|
);
|
|
@@ -7141,7 +6954,7 @@ function getIndexContentJS7() {
|
|
|
7141
6954
|
}
|
|
7142
6955
|
|
|
7143
6956
|
// src/plugins/tooling/eslint.ts
|
|
7144
|
-
import { join as
|
|
6957
|
+
import { join as join19 } from "path";
|
|
7145
6958
|
var eslintPlugin = {
|
|
7146
6959
|
name: "eslint",
|
|
7147
6960
|
displayName: "ESLint",
|
|
@@ -7217,7 +7030,7 @@ var eslintPlugin = {
|
|
|
7217
7030
|
const files = [];
|
|
7218
7031
|
const projectRoot = ctx.projectRoot;
|
|
7219
7032
|
try {
|
|
7220
|
-
const eslintConfigPath =
|
|
7033
|
+
const eslintConfigPath = join19(projectRoot, "eslint.config.js");
|
|
7221
7034
|
const eslintConfigExists = await checkPathExists(eslintConfigPath);
|
|
7222
7035
|
if (eslintConfigExists) {
|
|
7223
7036
|
logger.warn("eslint.config.js already exists, skipping creation");
|
|
@@ -7232,7 +7045,7 @@ var eslintPlugin = {
|
|
|
7232
7045
|
});
|
|
7233
7046
|
logger.info(`Created ESLint config: ${eslintConfigPath}`);
|
|
7234
7047
|
}
|
|
7235
|
-
const packageJsonPath =
|
|
7048
|
+
const packageJsonPath = join19(projectRoot, "package.json");
|
|
7236
7049
|
const packageJsonExists = await checkPathExists(packageJsonPath);
|
|
7237
7050
|
if (packageJsonExists) {
|
|
7238
7051
|
const packageJsonContent = await readFileContent(packageJsonPath);
|
|
@@ -7391,7 +7204,7 @@ export default [
|
|
|
7391
7204
|
}
|
|
7392
7205
|
|
|
7393
7206
|
// src/plugins/tooling/prettier.ts
|
|
7394
|
-
import { join as
|
|
7207
|
+
import { join as join20 } from "path";
|
|
7395
7208
|
var prettierPlugin = {
|
|
7396
7209
|
name: "prettier",
|
|
7397
7210
|
displayName: "Prettier",
|
|
@@ -7457,7 +7270,7 @@ var prettierPlugin = {
|
|
|
7457
7270
|
const files = [];
|
|
7458
7271
|
const projectRoot = ctx.projectRoot;
|
|
7459
7272
|
try {
|
|
7460
|
-
const prettierrcPath =
|
|
7273
|
+
const prettierrcPath = join20(projectRoot, ".prettierrc.json");
|
|
7461
7274
|
const prettierrcExists = await checkPathExists(prettierrcPath);
|
|
7462
7275
|
if (prettierrcExists) {
|
|
7463
7276
|
logger.warn(".prettierrc.json already exists, skipping creation");
|
|
@@ -7472,7 +7285,7 @@ var prettierPlugin = {
|
|
|
7472
7285
|
});
|
|
7473
7286
|
logger.info(`Created Prettier config: ${prettierrcPath}`);
|
|
7474
7287
|
}
|
|
7475
|
-
const prettierignorePath =
|
|
7288
|
+
const prettierignorePath = join20(projectRoot, ".prettierignore");
|
|
7476
7289
|
const prettierignoreExists = await checkPathExists(prettierignorePath);
|
|
7477
7290
|
if (prettierignoreExists) {
|
|
7478
7291
|
logger.warn(".prettierignore already exists, skipping creation");
|
|
@@ -7487,7 +7300,7 @@ var prettierPlugin = {
|
|
|
7487
7300
|
});
|
|
7488
7301
|
logger.info(`Created .prettierignore: ${prettierignorePath}`);
|
|
7489
7302
|
}
|
|
7490
|
-
const packageJsonPath =
|
|
7303
|
+
const packageJsonPath = join20(projectRoot, "package.json");
|
|
7491
7304
|
const packageJsonExists = await checkPathExists(packageJsonPath);
|
|
7492
7305
|
if (packageJsonExists) {
|
|
7493
7306
|
const packageJsonContent = await readFileContent(packageJsonPath);
|
|
@@ -7581,8 +7394,8 @@ pnpm-lock.yaml
|
|
|
7581
7394
|
}
|
|
7582
7395
|
|
|
7583
7396
|
// src/plugins/tooling/husky.ts
|
|
7584
|
-
import { join as
|
|
7585
|
-
import { execa
|
|
7397
|
+
import { join as join21 } from "path";
|
|
7398
|
+
import { execa } from "execa";
|
|
7586
7399
|
var huskyPlugin = {
|
|
7587
7400
|
name: "husky",
|
|
7588
7401
|
displayName: "Husky",
|
|
@@ -7649,7 +7462,7 @@ var huskyPlugin = {
|
|
|
7649
7462
|
const files = [];
|
|
7650
7463
|
const projectRoot = ctx.projectRoot;
|
|
7651
7464
|
try {
|
|
7652
|
-
const gitDir =
|
|
7465
|
+
const gitDir = join21(projectRoot, ".git");
|
|
7653
7466
|
const gitExists = await checkPathExists(gitDir);
|
|
7654
7467
|
if (!gitExists) {
|
|
7655
7468
|
logger.warn(
|
|
@@ -7661,9 +7474,9 @@ var huskyPlugin = {
|
|
|
7661
7474
|
message: "Git repository not found. Please initialize Git first."
|
|
7662
7475
|
};
|
|
7663
7476
|
}
|
|
7664
|
-
const huskyDir =
|
|
7477
|
+
const huskyDir = join21(projectRoot, ".husky");
|
|
7665
7478
|
await ensureDirectory(huskyDir);
|
|
7666
|
-
const preCommitPath =
|
|
7479
|
+
const preCommitPath = join21(huskyDir, "pre-commit");
|
|
7667
7480
|
const preCommitExists = await checkPathExists(preCommitPath);
|
|
7668
7481
|
if (!preCommitExists) {
|
|
7669
7482
|
const preCommitContent = getPreCommitContent();
|
|
@@ -7676,7 +7489,7 @@ var huskyPlugin = {
|
|
|
7676
7489
|
});
|
|
7677
7490
|
logger.info(`Created pre-commit hook: ${preCommitPath}`);
|
|
7678
7491
|
}
|
|
7679
|
-
const prePushPath =
|
|
7492
|
+
const prePushPath = join21(huskyDir, "pre-push");
|
|
7680
7493
|
const prePushExists = await checkPathExists(prePushPath);
|
|
7681
7494
|
if (!prePushExists) {
|
|
7682
7495
|
const prePushContent = getPrePushContent();
|
|
@@ -7689,7 +7502,7 @@ var huskyPlugin = {
|
|
|
7689
7502
|
});
|
|
7690
7503
|
logger.info(`Created pre-push hook: ${prePushPath}`);
|
|
7691
7504
|
}
|
|
7692
|
-
const packageJsonPath =
|
|
7505
|
+
const packageJsonPath = join21(projectRoot, "package.json");
|
|
7693
7506
|
const packageJsonExists = await checkPathExists(packageJsonPath);
|
|
7694
7507
|
if (packageJsonExists) {
|
|
7695
7508
|
const packageJsonContent = await readFileContent(packageJsonPath);
|
|
@@ -7713,7 +7526,7 @@ var huskyPlugin = {
|
|
|
7713
7526
|
}
|
|
7714
7527
|
}
|
|
7715
7528
|
try {
|
|
7716
|
-
await
|
|
7529
|
+
await execa("npx", ["husky", "init"], {
|
|
7717
7530
|
cwd: projectRoot,
|
|
7718
7531
|
stdio: "inherit"
|
|
7719
7532
|
});
|
|
@@ -7769,7 +7582,7 @@ npm run test:unit
|
|
|
7769
7582
|
}
|
|
7770
7583
|
|
|
7771
7584
|
// src/plugins/utils/date-fns.ts
|
|
7772
|
-
import { join as
|
|
7585
|
+
import { join as join22 } from "path";
|
|
7773
7586
|
var dateFnsPlugin = {
|
|
7774
7587
|
name: "date-fns",
|
|
7775
7588
|
displayName: "date-fns",
|
|
@@ -7833,11 +7646,11 @@ var dateFnsPlugin = {
|
|
|
7833
7646
|
const backupManager = new BackupManager();
|
|
7834
7647
|
const writer = new ConfigWriter(backupManager);
|
|
7835
7648
|
const files = [];
|
|
7836
|
-
const srcDir =
|
|
7649
|
+
const srcDir = join22(ctx.projectRoot, ctx.srcDir);
|
|
7837
7650
|
try {
|
|
7838
|
-
const utilsDir =
|
|
7651
|
+
const utilsDir = join22(srcDir, "lib", "utils");
|
|
7839
7652
|
await ensureDirectory(utilsDir);
|
|
7840
|
-
const dateUtilsPath =
|
|
7653
|
+
const dateUtilsPath = join22(
|
|
7841
7654
|
utilsDir,
|
|
7842
7655
|
`date.${ctx.typescript ? "ts" : "js"}`
|
|
7843
7656
|
);
|
|
@@ -8053,7 +7866,7 @@ export function getMinutesDifference(date1, date2) {
|
|
|
8053
7866
|
}
|
|
8054
7867
|
|
|
8055
7868
|
// src/plugins/testing/react-testing-library.ts
|
|
8056
|
-
import { join as
|
|
7869
|
+
import { join as join23 } from "path";
|
|
8057
7870
|
var reactTestingLibraryPlugin = {
|
|
8058
7871
|
name: "react-testing-library",
|
|
8059
7872
|
displayName: "React Testing Library",
|
|
@@ -8123,9 +7936,9 @@ var reactTestingLibraryPlugin = {
|
|
|
8123
7936
|
const writer = new ConfigWriter(backupManager);
|
|
8124
7937
|
const files = [];
|
|
8125
7938
|
const projectRoot = ctx.projectRoot;
|
|
8126
|
-
const srcDir =
|
|
7939
|
+
const srcDir = join23(projectRoot, ctx.srcDir);
|
|
8127
7940
|
try {
|
|
8128
|
-
const setupTestsPath =
|
|
7941
|
+
const setupTestsPath = join23(
|
|
8129
7942
|
projectRoot,
|
|
8130
7943
|
`setupTests.${ctx.typescript ? "ts" : "js"}`
|
|
8131
7944
|
);
|
|
@@ -8141,9 +7954,9 @@ var reactTestingLibraryPlugin = {
|
|
|
8141
7954
|
});
|
|
8142
7955
|
logger.info(`Created setupTests file: ${setupTestsPath}`);
|
|
8143
7956
|
}
|
|
8144
|
-
const testDir =
|
|
7957
|
+
const testDir = join23(srcDir, "components", "__tests__");
|
|
8145
7958
|
await ensureDirectory(testDir);
|
|
8146
|
-
const exampleTestPath =
|
|
7959
|
+
const exampleTestPath = join23(
|
|
8147
7960
|
testDir,
|
|
8148
7961
|
`Example.test.${ctx.typescript ? "tsx" : "jsx"}`
|
|
8149
7962
|
);
|
|
@@ -8159,7 +7972,7 @@ var reactTestingLibraryPlugin = {
|
|
|
8159
7972
|
});
|
|
8160
7973
|
logger.info(`Created example test: ${exampleTestPath}`);
|
|
8161
7974
|
}
|
|
8162
|
-
const vitestConfigPath =
|
|
7975
|
+
const vitestConfigPath = join23(projectRoot, "vitest.config.ts");
|
|
8163
7976
|
const vitestConfigExists = await checkPathExists(vitestConfigPath);
|
|
8164
7977
|
if (vitestConfigExists) {
|
|
8165
7978
|
logger.info(
|
|
@@ -8379,12 +8192,6 @@ if (validatedRegistry.length !== pluginRegistry.length) {
|
|
|
8379
8192
|
}
|
|
8380
8193
|
|
|
8381
8194
|
export {
|
|
8382
|
-
logger,
|
|
8383
|
-
readPackageJson,
|
|
8384
|
-
readTsConfig,
|
|
8385
|
-
checkPathExists,
|
|
8386
|
-
detectPackageManager,
|
|
8387
|
-
installPackages,
|
|
8388
8195
|
ConfigWriter,
|
|
8389
8196
|
BackupManager,
|
|
8390
8197
|
pluginRegistry,
|