@reliverse/dler 1.7.152 → 1.7.153

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.
Files changed (33) hide show
  1. package/bin/impl/auth/impl/init.d.ts +2 -2
  2. package/bin/impl/build/impl.d.ts +7 -1
  3. package/bin/impl/build/impl.js +161 -1
  4. package/bin/impl/config/constants.d.ts +1 -1
  5. package/bin/impl/config/constants.js +1 -1
  6. package/bin/impl/providers/better-t-stack/types.d.ts +7 -7
  7. package/bin/impl/pub/impl.d.ts +6 -1
  8. package/bin/impl/pub/impl.js +176 -2
  9. package/bin/impl/schema/mod.d.ts +140 -0
  10. package/bin/impl/schema/mod.js +22 -0
  11. package/bin/impl/utils/workspace-prompt.d.ts +9 -0
  12. package/bin/impl/utils/workspace-prompt.js +46 -0
  13. package/bin/impl/utils/workspace-utils.d.ts +28 -0
  14. package/bin/impl/utils/workspace-utils.js +127 -0
  15. package/bin/mod.d.ts +2 -9
  16. package/bin/mod.js +9 -23
  17. package/package.json +2 -1
  18. package/bin/impl/migrate/codemods/anything-bun.d.ts +0 -5
  19. package/bin/impl/migrate/codemods/anything-bun.js +0 -577
  20. package/bin/impl/migrate/codemods/commander-rempts.d.ts +0 -4
  21. package/bin/impl/migrate/codemods/commander-rempts.js +0 -250
  22. package/bin/impl/migrate/codemods/console-relinka.d.ts +0 -3
  23. package/bin/impl/migrate/codemods/console-relinka.js +0 -142
  24. package/bin/impl/migrate/codemods/fs-relifso.d.ts +0 -8
  25. package/bin/impl/migrate/codemods/fs-relifso.js +0 -156
  26. package/bin/impl/migrate/codemods/monorepo-catalog.d.ts +0 -96
  27. package/bin/impl/migrate/codemods/monorepo-catalog.js +0 -517
  28. package/bin/impl/migrate/codemods/nodenext-bundler.d.ts +0 -10
  29. package/bin/impl/migrate/codemods/nodenext-bundler.js +0 -222
  30. package/bin/impl/migrate/codemods/path-pathkit.d.ts +0 -8
  31. package/bin/impl/migrate/codemods/path-pathkit.js +0 -143
  32. package/bin/impl/migrate/codemods/readdir-glob.d.ts +0 -8
  33. package/bin/impl/migrate/codemods/readdir-glob.js +0 -133
@@ -1,222 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { readdir, readFile, stat, writeFile } from "node:fs/promises";
3
- import { extname, getFileImportsExports, join } from "@reliverse/pathkit";
4
- async function getAllTsFiles(dir) {
5
- const files = [];
6
- try {
7
- const entries = await readdir(dir);
8
- for (const entry of entries) {
9
- const fullPath = join(dir, entry);
10
- const stats = await stat(fullPath);
11
- if (stats.isDirectory() && !entry.startsWith(".") && entry !== "node_modules") {
12
- const subFiles = await getAllTsFiles(fullPath);
13
- files.push(...subFiles);
14
- } else if (stats.isFile()) {
15
- const ext = extname(entry);
16
- if ([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts"].includes(ext)) {
17
- files.push(fullPath);
18
- }
19
- }
20
- }
21
- } catch {
22
- }
23
- return files;
24
- }
25
- async function updateTsConfig(targetResolution, dryRun = false) {
26
- const results = [];
27
- const tsConfigPath = "./tsconfig.json";
28
- if (!existsSync(tsConfigPath)) {
29
- results.push({
30
- file: tsConfigPath,
31
- success: false,
32
- message: "tsconfig.json not found"
33
- });
34
- return results;
35
- }
36
- try {
37
- const content = await readFile(tsConfigPath, "utf8");
38
- const tsConfig = JSON.parse(content);
39
- const changes = [];
40
- if (!tsConfig.compilerOptions) {
41
- tsConfig.compilerOptions = {};
42
- }
43
- if (tsConfig.compilerOptions.moduleResolution !== targetResolution) {
44
- tsConfig.compilerOptions.moduleResolution = targetResolution;
45
- changes.push(`Set moduleResolution to ${targetResolution}`);
46
- }
47
- if (targetResolution === "nodenext") {
48
- if (tsConfig.compilerOptions.module !== "nodenext") {
49
- tsConfig.compilerOptions.module = "nodenext";
50
- changes.push("Set module to nodenext");
51
- }
52
- } else if (targetResolution === "bundler") {
53
- if (tsConfig.compilerOptions.module !== "preserve") {
54
- tsConfig.compilerOptions.module = "preserve";
55
- changes.push("Set module to preserve");
56
- }
57
- if (!tsConfig.compilerOptions.noEmit) {
58
- tsConfig.compilerOptions.noEmit = true;
59
- changes.push("Enabled noEmit");
60
- }
61
- }
62
- if (!tsConfig.compilerOptions.target) {
63
- tsConfig.compilerOptions.target = "ES2022";
64
- changes.push("Set target to ES2022");
65
- }
66
- if (changes.length > 0) {
67
- if (!dryRun) {
68
- await writeFile(tsConfigPath, JSON.stringify(tsConfig, null, 2) + "\n", "utf8");
69
- }
70
- results.push({
71
- file: tsConfigPath,
72
- success: true,
73
- message: `${changes.length} change(s) made`,
74
- changes
75
- });
76
- } else {
77
- results.push({
78
- file: tsConfigPath,
79
- success: true,
80
- message: "Already configured correctly"
81
- });
82
- }
83
- } catch (error) {
84
- results.push({
85
- file: tsConfigPath,
86
- success: false,
87
- message: `Failed to update: ${error instanceof Error ? error.message : String(error)}`
88
- });
89
- }
90
- return results;
91
- }
92
- async function updatePackageJson(dryRun = false) {
93
- const results = [];
94
- const packageJsonPath = "./package.json";
95
- if (!existsSync(packageJsonPath)) {
96
- results.push({
97
- file: packageJsonPath,
98
- success: false,
99
- message: "package.json not found"
100
- });
101
- return results;
102
- }
103
- try {
104
- const content = await readFile(packageJsonPath, "utf8");
105
- const packageJson = JSON.parse(content);
106
- const changes = [];
107
- if (packageJson.type !== "module") {
108
- packageJson.type = "module";
109
- changes.push('Set type to "module"');
110
- }
111
- if (changes.length > 0) {
112
- if (!dryRun) {
113
- await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf8");
114
- }
115
- results.push({
116
- file: packageJsonPath,
117
- success: true,
118
- message: `${changes.length} change(s) made`,
119
- changes
120
- });
121
- } else {
122
- results.push({
123
- file: packageJsonPath,
124
- success: true,
125
- message: "Already configured correctly"
126
- });
127
- }
128
- } catch (error) {
129
- results.push({
130
- file: packageJsonPath,
131
- success: false,
132
- message: `Failed to update: ${error instanceof Error ? error.message : String(error)}`
133
- });
134
- }
135
- return results;
136
- }
137
- async function updateImportExtensions(targetResolution, dryRun = false) {
138
- const results = [];
139
- const files = await getAllTsFiles(".");
140
- for (const file of files) {
141
- try {
142
- const content = await readFile(file, "utf8");
143
- const analysis = getFileImportsExports(content, {
144
- kind: "import",
145
- pathTypes: ["relative", "absolute", "alias"]
146
- });
147
- if (analysis.length === 0) continue;
148
- let modified = content;
149
- const changes = [];
150
- let hasChanges = false;
151
- for (const imp of analysis) {
152
- if (!imp.source) continue;
153
- const isRelativeOrAbsolute = imp.pathType === "relative" || imp.pathType === "absolute" || imp.pathType === "alias";
154
- if (!isRelativeOrAbsolute) continue;
155
- if (targetResolution === "nodenext") {
156
- if (imp.source.endsWith(".ts") || imp.source.endsWith(".tsx")) {
157
- const newSource = imp.source.replace(/\.tsx?$/, ".js");
158
- modified = modified.replace(`"${imp.source}"`, `"${newSource}"`).replace(`'${imp.source}'`, `'${newSource}'`);
159
- changes.push(`${imp.source} \u2192 ${newSource}`);
160
- hasChanges = true;
161
- } else if (!imp.source.includes(".") && !imp.source.endsWith("/")) {
162
- const newSource = `${imp.source}.js`;
163
- modified = modified.replace(`"${imp.source}"`, `"${newSource}"`).replace(`'${imp.source}'`, `'${newSource}'`);
164
- changes.push(`${imp.source} \u2192 ${newSource}`);
165
- hasChanges = true;
166
- }
167
- } else if (targetResolution === "bundler") {
168
- if (imp.source.match(/\.(js|jsx|ts|tsx)$/)) {
169
- const newSource = imp.source.replace(/\.(js|jsx|ts|tsx)$/, "");
170
- modified = modified.replace(`"${imp.source}"`, `"${newSource}"`).replace(`'${imp.source}'`, `'${newSource}'`);
171
- changes.push(`${imp.source} \u2192 ${newSource}`);
172
- hasChanges = true;
173
- }
174
- }
175
- }
176
- if (hasChanges) {
177
- if (!dryRun) {
178
- await writeFile(file, modified, "utf8");
179
- }
180
- results.push({
181
- file,
182
- success: true,
183
- message: `${changes.length} import(s) updated`,
184
- changes
185
- });
186
- }
187
- } catch (error) {
188
- results.push({
189
- file,
190
- success: false,
191
- message: `Failed to process: ${error instanceof Error ? error.message : String(error)}`
192
- });
193
- }
194
- }
195
- return results;
196
- }
197
- export async function migrateToNodeNext(dryRun = false) {
198
- const results = [];
199
- const tsConfigResults = await updateTsConfig("nodenext", dryRun);
200
- results.push(...tsConfigResults);
201
- const packageResults = await updatePackageJson(dryRun);
202
- results.push(...packageResults);
203
- const importResults = await updateImportExtensions("nodenext", dryRun);
204
- results.push(...importResults);
205
- return results;
206
- }
207
- export async function migrateToBundler(dryRun = false) {
208
- const results = [];
209
- const tsConfigResults = await updateTsConfig("bundler", dryRun);
210
- results.push(...tsConfigResults);
211
- const packageResults = await updatePackageJson(dryRun);
212
- results.push(...packageResults);
213
- const importResults = await updateImportExtensions("bundler", dryRun);
214
- results.push(...importResults);
215
- return results;
216
- }
217
- export async function migrateModuleResolution(target, dryRun = false) {
218
- if (target === "nodenext") {
219
- return migrateToNodeNext(dryRun);
220
- }
221
- return migrateToBundler(dryRun);
222
- }
@@ -1,8 +0,0 @@
1
- interface MigrationResult {
2
- file: string;
3
- success: boolean;
4
- message: string;
5
- changes?: string[];
6
- }
7
- export declare function migratePathToPathkit(dryRun?: boolean): Promise<MigrationResult[]>;
8
- export {};
@@ -1,143 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { readdir, readFile, stat, writeFile } from "node:fs/promises";
3
- import { extname, join } from "@reliverse/pathkit";
4
- async function getAllTsFiles(dir) {
5
- const files = [];
6
- try {
7
- const entries = await readdir(dir);
8
- for (const entry of entries) {
9
- const fullPath = join(dir, entry);
10
- const stats = await stat(fullPath);
11
- if (stats.isDirectory() && !entry.startsWith(".") && entry !== "node_modules") {
12
- const subFiles = await getAllTsFiles(fullPath);
13
- files.push(...subFiles);
14
- } else if (stats.isFile()) {
15
- const ext = extname(entry);
16
- if ([".ts", ".tsx", ".js", ".jsx", ".vue", ".svelte"].includes(ext)) {
17
- files.push(fullPath);
18
- }
19
- }
20
- }
21
- } catch {
22
- }
23
- return files;
24
- }
25
- export async function migratePathToPathkit(dryRun = false) {
26
- const results = [];
27
- const files = await getAllTsFiles(".");
28
- for (const file of files) {
29
- try {
30
- const content = await readFile(file, "utf8");
31
- let modified = content;
32
- const changes = [];
33
- const patheImportRegex = /from\s+["']pathe["']/g;
34
- if (patheImportRegex.test(content)) {
35
- modified = modified.replace(patheImportRegex, 'from "@reliverse/pathkit"');
36
- changes.push("Updated pathe imports to @reliverse/pathkit");
37
- }
38
- const patheUtilsRegex = /from\s+["']pathe\/utils["']/g;
39
- if (patheUtilsRegex.test(content)) {
40
- modified = modified.replace(patheUtilsRegex, 'from "@reliverse/pathkit"');
41
- changes.push("Updated pathe/utils imports to @reliverse/pathkit");
42
- }
43
- const nodePathImportRegex = /import\s+(?:(\{[^}]*\})|(\w+))\s+from\s+["']node:path["']/g;
44
- if (nodePathImportRegex.test(content)) {
45
- modified = modified.replace(nodePathImportRegex, (_match, namedExports, defaultExport) => {
46
- if (namedExports) {
47
- return `import ${namedExports} from "@reliverse/pathkit"`;
48
- }
49
- return `import ${defaultExport} from "@reliverse/pathkit"`;
50
- });
51
- changes.push("Updated node:path imports to @reliverse/pathkit");
52
- }
53
- const patheRequireRegex = /require\s*\(\s*["']pathe["']\s*\)/g;
54
- if (patheRequireRegex.test(content)) {
55
- modified = modified.replace(patheRequireRegex, 'require("@reliverse/pathkit")');
56
- changes.push("Updated pathe require to @reliverse/pathkit");
57
- }
58
- const patheUtilsRequireRegex = /require\s*\(\s*["']pathe\/utils["']\s*\)/g;
59
- if (patheUtilsRequireRegex.test(content)) {
60
- modified = modified.replace(patheUtilsRequireRegex, 'require("@reliverse/pathkit")');
61
- changes.push("Updated pathe/utils require to @reliverse/pathkit");
62
- }
63
- const nodePathRequireRegex = /require\s*\(\s*["']node:path["']\s*\)/g;
64
- if (nodePathRequireRegex.test(content)) {
65
- modified = modified.replace(nodePathRequireRegex, 'require("@reliverse/pathkit")');
66
- changes.push("Updated node:path require to @reliverse/pathkit");
67
- }
68
- if (changes.length > 0) {
69
- if (!dryRun) {
70
- await writeFile(file, modified, "utf8");
71
- }
72
- results.push({
73
- file,
74
- success: true,
75
- message: `${changes.length} change(s) made`,
76
- changes
77
- });
78
- }
79
- } catch (error) {
80
- results.push({
81
- file,
82
- success: false,
83
- message: `Failed to process: ${error instanceof Error ? error.message : String(error)}`
84
- });
85
- }
86
- }
87
- await updatePackageJson(results, dryRun, {
88
- remove: ["pathe"],
89
- add: { "@reliverse/pathkit": "^latest" }
90
- });
91
- return results;
92
- }
93
- async function updatePackageJson(results, dryRun, config) {
94
- try {
95
- const packageJsonPath = "./package.json";
96
- if (existsSync(packageJsonPath)) {
97
- const packageContent = await readFile(packageJsonPath, "utf8");
98
- const packageJson = JSON.parse(packageContent);
99
- let packageChanged = false;
100
- const packageChanges = [];
101
- for (const pkg of config.remove) {
102
- if (packageJson.dependencies?.[pkg]) {
103
- packageJson.dependencies = Object.fromEntries(
104
- Object.entries(packageJson.dependencies).filter(([key]) => key !== pkg)
105
- );
106
- packageChanged = true;
107
- packageChanges.push(`Removed ${pkg} from dependencies`);
108
- }
109
- if (packageJson.devDependencies?.[pkg]) {
110
- packageJson.devDependencies = Object.fromEntries(
111
- Object.entries(packageJson.devDependencies).filter(([key]) => key !== pkg)
112
- );
113
- packageChanged = true;
114
- packageChanges.push(`Removed ${pkg} from devDependencies`);
115
- }
116
- }
117
- for (const [pkg, version] of Object.entries(config.add)) {
118
- if (packageChanged && !packageJson.dependencies?.[pkg]) {
119
- if (!packageJson.dependencies) packageJson.dependencies = {};
120
- packageJson.dependencies[pkg] = version;
121
- packageChanges.push(`Added ${pkg} to dependencies`);
122
- }
123
- }
124
- if (packageChanged) {
125
- if (!dryRun) {
126
- await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf8");
127
- }
128
- results.push({
129
- file: packageJsonPath,
130
- success: true,
131
- message: `${packageChanges.length} change(s) made`,
132
- changes: packageChanges
133
- });
134
- }
135
- }
136
- } catch (error) {
137
- results.push({
138
- file: "./package.json",
139
- success: false,
140
- message: `Failed to update package.json: ${error instanceof Error ? error.message : String(error)}`
141
- });
142
- }
143
- }
@@ -1,8 +0,0 @@
1
- interface MigrationResult {
2
- file: string;
3
- success: boolean;
4
- message: string;
5
- changes?: string[];
6
- }
7
- export declare function migrateReaddirToGlob(dryRun?: boolean): Promise<MigrationResult[]>;
8
- export {};
@@ -1,133 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { readdir, readFile, stat, writeFile } from "node:fs/promises";
3
- import { extname, join } from "@reliverse/pathkit";
4
- async function getAllTsFiles(dir) {
5
- const files = [];
6
- try {
7
- const entries = await readdir(dir);
8
- for (const entry of entries) {
9
- const fullPath = join(dir, entry);
10
- const stats = await stat(fullPath);
11
- if (stats.isDirectory() && !entry.startsWith(".") && entry !== "node_modules") {
12
- const subFiles = await getAllTsFiles(fullPath);
13
- files.push(...subFiles);
14
- } else if (stats.isFile()) {
15
- const ext = extname(entry);
16
- if ([".ts", ".tsx", ".js", ".jsx", ".vue", ".svelte"].includes(ext)) {
17
- files.push(fullPath);
18
- }
19
- }
20
- }
21
- } catch {
22
- }
23
- return files;
24
- }
25
- export async function migrateReaddirToGlob(dryRun = false) {
26
- const results = [];
27
- const files = await getAllTsFiles(".");
28
- for (const file of files) {
29
- try {
30
- const content = await readFile(file, "utf8");
31
- let modified = content;
32
- const changes = [];
33
- if (!content.includes("import") || !content.includes("globby")) {
34
- const importStatement = 'import globby from "globby";\n';
35
- modified = importStatement + modified;
36
- changes.push("Added globby import");
37
- }
38
- const readdirRegex = /(?:await\s+)?(?:fs\.)?readdir(?:Sync)?\s*\(\s*([^)]+)\s*\)/g;
39
- if (readdirRegex.test(content)) {
40
- modified = modified.replace(readdirRegex, (_match, targetDir) => {
41
- const cleanTargetDir = targetDir.replace(/["']/g, "").trim();
42
- return `await globby("*", { cwd: ${cleanTargetDir}, onlyFiles: false })`;
43
- });
44
- changes.push("Converted fs.readdir to globby");
45
- }
46
- const promisesReaddirRegex = /(?:await\s+)?fs\.promises\.readdir\s*\(\s*([^)]+)\s*\)/g;
47
- if (promisesReaddirRegex.test(content)) {
48
- modified = modified.replace(promisesReaddirRegex, (_match, targetDir) => {
49
- const cleanTargetDir = targetDir.replace(/["']/g, "").trim();
50
- return `await globby("*", { cwd: ${cleanTargetDir}, onlyFiles: false })`;
51
- });
52
- changes.push("Converted fs.promises.readdir to globby");
53
- }
54
- if (changes.length > 0) {
55
- if (!dryRun) {
56
- await writeFile(file, modified, "utf8");
57
- }
58
- results.push({
59
- file,
60
- success: true,
61
- message: `${changes.length} change(s) made`,
62
- changes
63
- });
64
- }
65
- } catch (error) {
66
- results.push({
67
- file,
68
- success: false,
69
- message: `Failed to process: ${error instanceof Error ? error.message : String(error)}`
70
- });
71
- }
72
- }
73
- await updatePackageJson(results, dryRun, {
74
- add: { globby: "^13.2.2" }
75
- });
76
- return results;
77
- }
78
- async function updatePackageJson(results, dryRun, config) {
79
- try {
80
- const packageJsonPath = "./package.json";
81
- if (existsSync(packageJsonPath)) {
82
- const packageContent = await readFile(packageJsonPath, "utf8");
83
- const packageJson = JSON.parse(packageContent);
84
- let packageChanged = false;
85
- const packageChanges = [];
86
- if (config.remove) {
87
- for (const pkg of config.remove) {
88
- if (packageJson.dependencies?.[pkg]) {
89
- packageJson.dependencies = Object.fromEntries(
90
- Object.entries(packageJson.dependencies).filter(([key]) => key !== pkg)
91
- );
92
- packageChanged = true;
93
- packageChanges.push(`Removed ${pkg} from dependencies`);
94
- }
95
- if (packageJson.devDependencies?.[pkg]) {
96
- packageJson.devDependencies = Object.fromEntries(
97
- Object.entries(packageJson.devDependencies).filter(([key]) => key !== pkg)
98
- );
99
- packageChanged = true;
100
- packageChanges.push(`Removed ${pkg} from devDependencies`);
101
- }
102
- }
103
- }
104
- for (const [pkg, version] of Object.entries(config.add)) {
105
- if (!packageJson.dependencies?.[pkg]) {
106
- packageJson.dependencies = {
107
- ...packageJson.dependencies,
108
- [pkg]: version
109
- };
110
- packageChanged = true;
111
- packageChanges.push(`Added ${pkg} to dependencies`);
112
- }
113
- }
114
- if (packageChanged && !dryRun) {
115
- await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
116
- }
117
- if (packageChanges.length > 0) {
118
- results.push({
119
- file: packageJsonPath,
120
- success: true,
121
- message: `${packageChanges.length} change(s) made`,
122
- changes: packageChanges
123
- });
124
- }
125
- }
126
- } catch (error) {
127
- results.push({
128
- file: "./package.json",
129
- success: false,
130
- message: `Failed to update package.json: ${error instanceof Error ? error.message : String(error)}`
131
- });
132
- }
133
- }