openapi-typesafe-migrate 0.0.0 → 1.0.0-rc.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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Drew Powers
4
+ Copyright (c) 2026 Fedor Chishchin and openapi-typesafe contributors
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,59 @@
1
1
  # openapi-typesafe-migrate
2
2
 
3
- This name is reserved for openapi-typesafe. This version contains no code.
3
+ Move a project from `openapi-typescript`, `openapi-fetch`, `openapi-react-query` and
4
+ `openapi-typescript-helpers` to the openapi-typesafe packages.
5
+
6
+ ```sh
7
+ npx openapi-typesafe-migrate # report what would change
8
+ npx openapi-typesafe-migrate --write # change the files
9
+ ```
10
+
11
+ Run it in the project root, with a clean git tree, so you can review the diff.
12
+
13
+ Run it with `npx` (or `pnpm dlx`, `yarn dlx`, `bunx`), not as a dependency: it uses TypeScript 6
14
+ (`@typescript/typescript6`), and an npm install of it links the project's `tsc` to TypeScript 6.
15
+
16
+ ## What it changes
17
+
18
+ | Where | Change |
19
+ | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
20
+ | Every `package.json` | `dependencies`, `devDependencies`, `peerDependencies` and `optionalDependencies` get the new names, with the version of this tool; `^`, `~` and exact ranges keep their style. `catalog:` and `workspace:` stay. |
21
+ | `pnpm-workspace.yaml` | Entries of `catalog:` and `catalogs:`. Comments and formatting stay. |
22
+ | `package.json` scripts, shell scripts, YAML (CI), `Makefile`, `justfile`, `Dockerfile` | The `openapi-typescript` command, and the flags it renamed: `--immutable-types` / `-it` → `--immutable`, `--support-array-length` → `--array-length`, `--redoc` → `--redocly`, `-ap` → `--additional-properties`. |
23
+ | Sources (`.ts`, `.tsx`, `.js`, `.mjs`, `.cjs`, `.vue`, `.svelte`, `.astro`, …) | Quoted module specifiers: imports, `require()`, `import()`, `vi.mock()`, `declare module`, tool configs. |
24
+ | `openapiTS(source, { transform })` calls | When `transform` is the only callback and returns plain `ts.factory` types (or the helper constants), the returns become type text and `irCallbacks: true` is added. |
25
+
26
+ `node_modules`, `.git`, `dist` and the output folders `.next`, `.nuxt`, `.output`, `.svelte-kit`,
27
+ `.turbo` and `coverage` are skipped; links are not followed.
28
+
29
+ ## What it leaves to you
30
+
31
+ The report lists each of these with the file and line:
32
+
33
+ - a version spec it cannot replace (`latest`, a URL, a file, an npm alias), and `overrides` /
34
+ `resolutions` / `pnpm` settings (in `package.json` or `pnpm-workspace.yaml`, patches included)
35
+ that name an old package;
36
+ - a renamed peer dependency: users of your package must switch too;
37
+ - `npx openapi-typescript@<version>`: the old package is pinned, change it by hand;
38
+ - deep imports such as `openapi-fetch/dist/...`: check that the file exists in the new package;
39
+ - `transform` callbacks it cannot rewrite, and `postTransform` / `transformProperty`: they keep
40
+ working with a deprecation warning; see
41
+ [IR callbacks](https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/node.md#ir-callbacks).
42
+
43
+ Then install, regenerate your types and commit them once (the file header names openapi-typesafe
44
+ now, so `--check` fails until you do), and run your type check and tests.
45
+
46
+ ## Options
47
+
48
+ | Option | Default |
49
+ | -------------- | ---------------------------------------------------------------------------- |
50
+ | `--write` | Dry run: nothing is written |
51
+ | `--root <dir>` | The current directory |
52
+ | `--log <file>` | A new JSON Lines file in the system temporary directory; its path is printed |
53
+
54
+ Exit codes: `0` done, `1` the migration failed (the message and the log say why), `2` unknown
55
+ option.
56
+
57
+ ## License
58
+
59
+ [MIT](./LICENSE)
package/bin/migrate.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ // The command is built from src/cli/main.ts.
4
+ import "../dist/cli/main.mjs";