@vite-hub/codemods 0.5.0 → 0.6.0

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/cli.js CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as runCli } from "./cli-main-aLhc0Eyq.js";
3
- //#region src/cli.ts
2
+ import { t as runCli } from "./cli-main-ICe6yfP7.js";
3
+ // src/cli.ts
4
4
  process.exitCode = await runCli(process.argv.slice(2));
5
- //#endregion
6
5
  export {};
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
- export declare const codemods: readonly Codemod[];
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 {
@@ -115,6 +112,8 @@ interface MigrationStep {
115
112
  result?: CodemodResult;
116
113
  /** Why the codemod could not migrate. Its edits are not applied. */
117
114
  error?: string;
115
+ /** How to fix the problem before retrying the codemod. */
116
+ fix?: string;
118
117
  }
119
118
  interface Migration {
120
119
  cwd: string;
@@ -122,8 +121,8 @@ interface Migration {
122
121
  steps: MigrationStep[];
123
122
  /** The combined edits of every step that succeeded, against the files as they were before the migration. */
124
123
  edits: FileEdit[];
125
- /** Problems with the project that no codemod owns, such as a Nuxt version that ViteHub does not support. */
126
- warnings: string[];
124
+ /** Facts about the migration that no codemod owns, such as the `nitro` package that it added on Nuxt 4.7. */
125
+ notes: string[];
127
126
  /** Names of the codemods that the migration checked. */
128
127
  supported: string[];
129
128
  }
@@ -135,7 +134,9 @@ export declare function detectCodemods(cwd: string, candidates?: readonly Codemo
135
134
  /**
136
135
  * Detects every supported module in the project and runs its codemod. The codemods run one after another on a
137
136
  * 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.
137
+ * nothing; the others still run. Writes the combined edits unless `dryRun` is set. When a successful plan adds
138
+ * `vite-hub/nuxt`, it adds `nitro` to package.json on Nuxt 4.7, and throws `CODEMODS_NUXT_UNSUPPORTED` before it
139
+ * changes project files on a Nuxt version before 4.7, unless `nuxtNightly` is set.
139
140
  */
140
141
  export declare function runMigration(options?: RunMigrationOptions): Promise<Migration>;
141
142
  /**
@@ -143,12 +144,9 @@ export declare function runMigration(options?: RunMigrationOptions): Promise<Mig
143
144
  * `nextSteps` adds steps of the caller after those of the codemods, when the migration changed files.
144
145
  */
145
146
  export declare function formatMigrationReport(migration: Migration, nextSteps?: readonly string[]): string;
146
- //#endregion
147
- //#region src/error-diagnostics.d.ts
148
147
  /** Whether a codemod refused to migrate the project, so the caller reports the message and the fix. */
149
148
  export declare function isCodemodError(error: unknown): error is Error & {
150
149
  code: string;
151
150
  fix?: string;
152
151
  };
153
- //#endregion
154
- export type { Codemod, CodemodContext, CodemodResult, CodemodRun, Detection, FileEdit, FollowUp, Migration, MigrationStep, RunCodemodOptions, RunMigrationOptions };
152
+ 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
- import { a as findCodemod, c as runCodemod, d as isCodemodError, i as runMigration, l as codemods, n as detectCodemods, o as formatDiff, r as formatMigrationReport, s as formatReport, t as runCli, u as upgradeCodemods } from "./cli-main-aLhc0Eyq.js";
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-ICe6yfP7.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-hub/codemods",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
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": "^7.29.9",
40
+ "@babel/parser": "^8.1.3",
41
41
  "@valibot/to-json-schema": "^1.8.0",
42
- "@vue/compiler-sfc": "^3.5.44",
42
+ "@vue/compiler-sfc": "^3.5.46",
43
43
  "diff": "^9.0.0",
44
44
  "jiti": "^2.7.0",
45
- "magic-string": "^0.30.21",
45
+ "magic-string": "^1.4.5",
46
46
  "nostics": "1.4.0",
47
47
  "scule": "^1.3.0",
48
- "semver": "^7.8.5",
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": "^7.29.8",
55
- "@types/node": "^24.19.1",
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.0",
57
+ "@vite-hub/env": "0.6.0",
58
58
  "@vite-hub/internal": "0.0.1",
59
59
  "publint": "^0.3.25",
60
60
  "typescript": "^6.0.3",
61
- "vite": "^8.2.2",
62
- "vite-plus": "^0.3.3",
63
- "vitest": "^4.1.11",
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": ">=24.15.0"
67
+ "node": ">=22.12.0"
68
68
  },
69
69
  "scripts": {
70
70
  "build": "vp pack",