@vite-hub/codemods 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -8
- package/dist/{cli-main-aLhc0Eyq.js → cli-main-BPr3LL6y.js} +1153 -361
- package/dist/cli.js +2 -3
- package/dist/index.d.ts +14 -18
- package/dist/index.js +1 -2
- package/package.json +12 -12
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "nostics";
|
|
2
|
-
//#region src/types.d.ts
|
|
3
2
|
/** A manual step that the codemod could not do safely. */
|
|
4
3
|
interface FollowUp {
|
|
5
4
|
/** Path relative to the project directory. */
|
|
@@ -19,6 +18,7 @@ interface CodemodResult {
|
|
|
19
18
|
/** One line that tells what the codemod did. */
|
|
20
19
|
summary: string;
|
|
21
20
|
edits: FileEdit[];
|
|
21
|
+
requiresNitro3?: boolean;
|
|
22
22
|
followUps: FollowUp[];
|
|
23
23
|
/** Facts about the migration that need no action in a specific file. */
|
|
24
24
|
notes: string[];
|
|
@@ -48,13 +48,11 @@ interface Codemod {
|
|
|
48
48
|
/** Plans the edits. It must not write files; the runner writes them. */
|
|
49
49
|
run: (context: CodemodContext) => Promise<CodemodResult>;
|
|
50
50
|
}
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region src/registry.d.ts
|
|
53
51
|
/**
|
|
54
52
|
* Every available codemod. Add a new codemod here to make the CLI list and run it. NuxtHub runs first: it renames
|
|
55
53
|
* hub to vitehub in place and picks the host from the Wrangler config, and the others add to that vitehub key.
|
|
56
54
|
*/
|
|
57
|
-
|
|
55
|
+
declare const codemods$1: readonly Codemod[];
|
|
58
56
|
/**
|
|
59
57
|
* Codemods that move an app between ViteHub releases. `vitehub migrate` runs each one that applies, in this order, and
|
|
60
58
|
* each one sees the edits of the ones before it. Config codemods run first: `vitehub-options` moves top-level feature
|
|
@@ -66,13 +64,13 @@ export declare const codemods: readonly Codemod[];
|
|
|
66
64
|
* app from another module, such as NuxtHub, are not upgrades, so only `npx @vite-hub/codemods` runs them.
|
|
67
65
|
*/
|
|
68
66
|
export declare const upgradeCodemods: readonly Codemod[];
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/runner.d.ts
|
|
71
67
|
interface RunCodemodOptions {
|
|
72
68
|
/** Project directory. Defaults to `process.cwd()`. */
|
|
73
69
|
cwd?: string;
|
|
74
70
|
/** Plan the edits and write nothing. */
|
|
75
71
|
dryRun?: boolean;
|
|
72
|
+
/** On a Nuxt version before 4.7, set `nuxt` to `npm:nuxt-nightly@5x` in package.json instead of stopping. */
|
|
73
|
+
nuxtNightly?: boolean;
|
|
76
74
|
}
|
|
77
75
|
interface CodemodRun {
|
|
78
76
|
codemod: Codemod;
|
|
@@ -83,23 +81,20 @@ interface CodemodRun {
|
|
|
83
81
|
export declare function findCodemod(name: string): Codemod | undefined;
|
|
84
82
|
/**
|
|
85
83
|
* Runs one codemod. Writes its edits unless `dryRun` is set. Throws `CODEMODS_BLOCKED` when it cannot migrate, also when an
|
|
86
|
-
* edit is a symbolic link or is inside one
|
|
84
|
+
* edit is a symbolic link or is inside one, and `CODEMODS_NUXT_UNSUPPORTED` when it adds `vite-hub/nuxt` to an app on a
|
|
85
|
+
* Nuxt version before 4.7 without `nuxtNightly`. On Nuxt 4.7 without `nitro`, it adds `nitro` to package.json.
|
|
87
86
|
*/
|
|
88
87
|
export declare function runCodemod(name: string, options?: RunCodemodOptions): Promise<CodemodRun>;
|
|
89
88
|
/** Formats the planned edits as unified diffs. */
|
|
90
89
|
export declare function formatDiff(result: Pick<CodemodResult, "edits">): string;
|
|
91
90
|
/** Formats the report that ends every codemod run. */
|
|
92
91
|
export declare function formatReport(run: CodemodRun): string;
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/cli-main.d.ts
|
|
95
92
|
interface CliOutput {
|
|
96
93
|
stdout: (text: string) => void;
|
|
97
94
|
stderr: (text: string) => void;
|
|
98
95
|
}
|
|
99
96
|
/** Runs the CLI with arguments after the binary name. Returns the exit code. */
|
|
100
97
|
export declare function runCli(argv: readonly string[], output?: CliOutput): Promise<number>;
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/migrate.d.ts
|
|
103
98
|
interface RunMigrationOptions {
|
|
104
99
|
/** Project directory. Defaults to `process.cwd()`. */
|
|
105
100
|
cwd?: string;
|
|
@@ -107,6 +102,8 @@ interface RunMigrationOptions {
|
|
|
107
102
|
dryRun?: boolean;
|
|
108
103
|
/** The codemods to detect and run, in order. Defaults to every codemod. `vitehub migrate` passes `upgradeCodemods`. */
|
|
109
104
|
codemods?: readonly Codemod[];
|
|
105
|
+
/** On a Nuxt version before 4.7, set `nuxt` to `npm:nuxt-nightly@5x` in package.json instead of stopping. */
|
|
106
|
+
nuxtNightly?: boolean;
|
|
110
107
|
}
|
|
111
108
|
/** One codemod that the migration ran. It has a `result` or an `error`. */
|
|
112
109
|
interface MigrationStep {
|
|
@@ -122,8 +119,8 @@ interface Migration {
|
|
|
122
119
|
steps: MigrationStep[];
|
|
123
120
|
/** The combined edits of every step that succeeded, against the files as they were before the migration. */
|
|
124
121
|
edits: FileEdit[];
|
|
125
|
-
/**
|
|
126
|
-
|
|
122
|
+
/** Facts about the migration that no codemod owns, such as the `nitro` package that it added on Nuxt 4.7. */
|
|
123
|
+
notes: string[];
|
|
127
124
|
/** Names of the codemods that the migration checked. */
|
|
128
125
|
supported: string[];
|
|
129
126
|
}
|
|
@@ -135,7 +132,9 @@ export declare function detectCodemods(cwd: string, candidates?: readonly Codemo
|
|
|
135
132
|
/**
|
|
136
133
|
* Detects every supported module in the project and runs its codemod. The codemods run one after another on a
|
|
137
134
|
* scratch copy, so each one sees the edits of the ones before it. A codemod that fails adds an error and changes
|
|
138
|
-
* nothing; the others still run. Writes the combined edits unless `dryRun` is set.
|
|
135
|
+
* nothing; the others still run. Writes the combined edits unless `dryRun` is set. When a successful plan adds
|
|
136
|
+
* `vite-hub/nuxt`, it adds `nitro` to package.json on Nuxt 4.7, and throws `CODEMODS_NUXT_UNSUPPORTED` before it
|
|
137
|
+
* changes project files on a Nuxt version before 4.7, unless `nuxtNightly` is set.
|
|
139
138
|
*/
|
|
140
139
|
export declare function runMigration(options?: RunMigrationOptions): Promise<Migration>;
|
|
141
140
|
/**
|
|
@@ -143,12 +142,9 @@ export declare function runMigration(options?: RunMigrationOptions): Promise<Mig
|
|
|
143
142
|
* `nextSteps` adds steps of the caller after those of the codemods, when the migration changed files.
|
|
144
143
|
*/
|
|
145
144
|
export declare function formatMigrationReport(migration: Migration, nextSteps?: readonly string[]): string;
|
|
146
|
-
//#endregion
|
|
147
|
-
//#region src/error-diagnostics.d.ts
|
|
148
145
|
/** Whether a codemod refused to migrate the project, so the caller reports the message and the fix. */
|
|
149
146
|
export declare function isCodemodError(error: unknown): error is Error & {
|
|
150
147
|
code: string;
|
|
151
148
|
fix?: string;
|
|
152
149
|
};
|
|
153
|
-
|
|
154
|
-
export type { Codemod, CodemodContext, CodemodResult, CodemodRun, Detection, FileEdit, FollowUp, Migration, MigrationStep, RunCodemodOptions, RunMigrationOptions };
|
|
150
|
+
export { type Codemod, type CodemodContext, type CodemodResult, type CodemodRun, type Detection, type FileEdit, type FollowUp, type Migration, type MigrationStep, type RunCodemodOptions, type RunMigrationOptions, codemods$1 as codemods };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { codemods, detectCodemods, findCodemod, formatDiff, formatMigrationReport, formatReport, isCodemodError, runCli, runCodemod, runMigration, upgradeCodemods };
|
|
1
|
+
export { l as codemods, n as detectCodemods, a as findCodemod, o as formatDiff, r as formatMigrationReport, s as formatReport, d as isCodemodError, t as runCli, c as runCodemod, i as runMigration, u as upgradeCodemods } from "./cli-main-BPr3LL6y.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/codemods",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Codemods that move applications to ViteHub.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -37,34 +37,34 @@
|
|
|
37
37
|
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@babel/parser": "^
|
|
40
|
+
"@babel/parser": "^8.1.3",
|
|
41
41
|
"@valibot/to-json-schema": "^1.8.0",
|
|
42
|
-
"@vue/compiler-sfc": "^3.5.
|
|
42
|
+
"@vue/compiler-sfc": "^3.5.46",
|
|
43
43
|
"diff": "^9.0.0",
|
|
44
44
|
"jiti": "^2.7.0",
|
|
45
|
-
"magic-string": "^
|
|
45
|
+
"magic-string": "^1.4.5",
|
|
46
46
|
"nostics": "1.4.0",
|
|
47
47
|
"scule": "^1.3.0",
|
|
48
|
-
"semver": "^7.8.
|
|
48
|
+
"semver": "^7.8.6",
|
|
49
49
|
"tinyglobby": "^0.2.17",
|
|
50
50
|
"valibot": "^1.5.0",
|
|
51
51
|
"yaml": "^2.9.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@babel/types": "^
|
|
55
|
-
"@types/node": "^24.19.
|
|
54
|
+
"@babel/types": "^8.1.3",
|
|
55
|
+
"@types/node": "^24.19.2",
|
|
56
56
|
"@types/semver": "^7.8.0",
|
|
57
|
-
"@vite-hub/env": "0.5.
|
|
57
|
+
"@vite-hub/env": "0.5.1",
|
|
58
58
|
"@vite-hub/internal": "0.0.1",
|
|
59
59
|
"publint": "^0.3.25",
|
|
60
60
|
"typescript": "^6.0.3",
|
|
61
|
-
"vite": "^8.
|
|
62
|
-
"vite-plus": "^
|
|
63
|
-
"vitest": "
|
|
61
|
+
"vite": "^8.3.8",
|
|
62
|
+
"vite-plus": "^1.7.0",
|
|
63
|
+
"vitest": "5.1.0",
|
|
64
64
|
"zod": "^4.6.7"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
|
-
"node": ">=
|
|
67
|
+
"node": ">=22.12.0"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "vp pack",
|