@vite-hub/codemods 0.4.1 → 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 +112 -12
- package/dist/{cli-main-DfzMGFup.js → cli-main-BPr3LL6y.js} +3607 -1154
- package/dist/cli.js +2 -3
- package/dist/index.d.ts +16 -19
- 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,30 +48,29 @@ 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
|
|
61
59
|
* keys into `vitehub()`, where `agent-surface` then renames the Agent driver keys. `define-forms` moves the Database
|
|
62
60
|
* files before the import codemods rewrite them. `root-accessors` moves `#vitehub/env/server` to `vite-hub/env` before
|
|
63
61
|
* `one-entry-imports` joins the `vite-hub/env/*` imports with it. `queue-durations` and `result-tuples` run after
|
|
64
|
-
* `queue-workflow-verbs`, so they also read the calls that `queue-workflow-verbs` renamed.
|
|
62
|
+
* `queue-workflow-verbs`, so they also read the calls that `queue-workflow-verbs` renamed. `nuxt-server-imports` runs
|
|
63
|
+
* last and detects again after the others, so it imports the helpers under their new names. The codemods that move an
|
|
65
64
|
* app from another module, such as NuxtHub, are not upgrades, so only `npx @vite-hub/codemods` runs them.
|
|
66
65
|
*/
|
|
67
66
|
export declare const upgradeCodemods: readonly Codemod[];
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/runner.d.ts
|
|
70
67
|
interface RunCodemodOptions {
|
|
71
68
|
/** Project directory. Defaults to `process.cwd()`. */
|
|
72
69
|
cwd?: string;
|
|
73
70
|
/** Plan the edits and write nothing. */
|
|
74
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;
|
|
75
74
|
}
|
|
76
75
|
interface CodemodRun {
|
|
77
76
|
codemod: Codemod;
|
|
@@ -82,23 +81,20 @@ interface CodemodRun {
|
|
|
82
81
|
export declare function findCodemod(name: string): Codemod | undefined;
|
|
83
82
|
/**
|
|
84
83
|
* Runs one codemod. Writes its edits unless `dryRun` is set. Throws `CODEMODS_BLOCKED` when it cannot migrate, also when an
|
|
85
|
-
* 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.
|
|
86
86
|
*/
|
|
87
87
|
export declare function runCodemod(name: string, options?: RunCodemodOptions): Promise<CodemodRun>;
|
|
88
88
|
/** Formats the planned edits as unified diffs. */
|
|
89
89
|
export declare function formatDiff(result: Pick<CodemodResult, "edits">): string;
|
|
90
90
|
/** Formats the report that ends every codemod run. */
|
|
91
91
|
export declare function formatReport(run: CodemodRun): string;
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/cli-main.d.ts
|
|
94
92
|
interface CliOutput {
|
|
95
93
|
stdout: (text: string) => void;
|
|
96
94
|
stderr: (text: string) => void;
|
|
97
95
|
}
|
|
98
96
|
/** Runs the CLI with arguments after the binary name. Returns the exit code. */
|
|
99
97
|
export declare function runCli(argv: readonly string[], output?: CliOutput): Promise<number>;
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region src/migrate.d.ts
|
|
102
98
|
interface RunMigrationOptions {
|
|
103
99
|
/** Project directory. Defaults to `process.cwd()`. */
|
|
104
100
|
cwd?: string;
|
|
@@ -106,6 +102,8 @@ interface RunMigrationOptions {
|
|
|
106
102
|
dryRun?: boolean;
|
|
107
103
|
/** The codemods to detect and run, in order. Defaults to every codemod. `vitehub migrate` passes `upgradeCodemods`. */
|
|
108
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;
|
|
109
107
|
}
|
|
110
108
|
/** One codemod that the migration ran. It has a `result` or an `error`. */
|
|
111
109
|
interface MigrationStep {
|
|
@@ -121,8 +119,8 @@ interface Migration {
|
|
|
121
119
|
steps: MigrationStep[];
|
|
122
120
|
/** The combined edits of every step that succeeded, against the files as they were before the migration. */
|
|
123
121
|
edits: FileEdit[];
|
|
124
|
-
/**
|
|
125
|
-
|
|
122
|
+
/** Facts about the migration that no codemod owns, such as the `nitro` package that it added on Nuxt 4.7. */
|
|
123
|
+
notes: string[];
|
|
126
124
|
/** Names of the codemods that the migration checked. */
|
|
127
125
|
supported: string[];
|
|
128
126
|
}
|
|
@@ -134,7 +132,9 @@ export declare function detectCodemods(cwd: string, candidates?: readonly Codemo
|
|
|
134
132
|
/**
|
|
135
133
|
* Detects every supported module in the project and runs its codemod. The codemods run one after another on a
|
|
136
134
|
* scratch copy, so each one sees the edits of the ones before it. A codemod that fails adds an error and changes
|
|
137
|
-
* 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.
|
|
138
138
|
*/
|
|
139
139
|
export declare function runMigration(options?: RunMigrationOptions): Promise<Migration>;
|
|
140
140
|
/**
|
|
@@ -142,12 +142,9 @@ export declare function runMigration(options?: RunMigrationOptions): Promise<Mig
|
|
|
142
142
|
* `nextSteps` adds steps of the caller after those of the codemods, when the migration changed files.
|
|
143
143
|
*/
|
|
144
144
|
export declare function formatMigrationReport(migration: Migration, nextSteps?: readonly string[]): string;
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/error-diagnostics.d.ts
|
|
147
145
|
/** Whether a codemod refused to migrate the project, so the caller reports the message and the fix. */
|
|
148
146
|
export declare function isCodemodError(error: unknown): error is Error & {
|
|
149
147
|
code: string;
|
|
150
148
|
fix?: string;
|
|
151
149
|
};
|
|
152
|
-
|
|
153
|
-
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.
|
|
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.
|
|
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",
|