openapi-typesafe-migrate 1.0.0-rc.4 → 1.0.0-rc.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,98 @@
1
1
  # openapi-typesafe-migrate
2
2
 
3
+ ## 1.0.0-rc.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#69](https://github.com/openapi-typesafe/openapi-typesafe/pull/69) [`1296bd7`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1296bd79e83c39598a471b9bfabf34ffcd71a83e) Thanks [@fedorello](https://github.com/fedorello)! - A module specifier with a bundler query (`"openapi-fetch?url"`, `"openapi-fetch/x.js?raw"`) gets the
8
+ new package name and keeps its query. Before, a query right after the package name hid the package,
9
+ and the specifier was left as it was.
10
+
11
+ - [#69](https://github.com/openapi-typesafe/openapi-typesafe/pull/69) [`1296bd7`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1296bd79e83c39598a471b9bfabf34ffcd71a83e) Thanks [@fedorello](https://github.com/fedorello)! - A `catalog:` dependency whose catalog entry is not in the project (`--root packages/api` of a pnpm
12
+ workspace) keeps its name and is reported as a manual step: the entry above the root cannot be
13
+ renamed, and renaming only the dependency failed the install with
14
+ `ERR_PNPM_CATALOG_ENTRY_NOT_FOUND_FOR_SPEC`. At a workspace root, where no catalog is above, such a
15
+ dependency is reported as one whose entry is missing. `catalog: ` with a space is the default
16
+ catalog, as pnpm reads it.
17
+
18
+ - [#69](https://github.com/openapi-typesafe/openapi-typesafe/pull/69) [`1296bd7`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1296bd79e83c39598a471b9bfabf34ffcd71a83e) Thanks [@fedorello](https://github.com/fedorello)! - The generator is renamed after more programs that run it: `nice`, `timeout`, `xargs`, `command`,
19
+ `exec -a`, `dotenvx run --`, `doppler run --`, `nx exec --`, `yarn workspace <name>`, a bare `bun`,
20
+ `corepack`, and `tsx` or `ts-node` before the path of its binary; `yarn global add` renames its
21
+ packages. Any other word of a command that names an old package or a path to its binary (a
22
+ script name after `npm run`, an argument of an unknown program, `$(npm bin)/openapi-typescript`)
23
+ is reported as a manual step. Such commands were left without a word, and
24
+ `dotenvx run -- npx openapi-typescript` kept downloading the old generator.
25
+
26
+ - [#69](https://github.com/openapi-typesafe/openapi-typesafe/pull/69) [`1296bd7`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1296bd79e83c39598a471b9bfabf34ffcd71a83e) Thanks [@fedorello](https://github.com/fedorello)! - The body of a here-document (`<<NOTE`, `<<'NOTE'`, `<<-NOTE`) is read as data in scripts, `run: |`
27
+ blocks and Dockerfiles: an apostrophe in it (`Don't edit`) opened a quote to the end of the file,
28
+ and no command after it was migrated. A here-document that a shell runs (`bash <<EOF`,
29
+ Dockerfile `RUN <<EOF` and `RUN <<EOT bash`, `cat <<EOF | sh`) is read as the script it is, so its
30
+ commands are migrated. A shift in an arithmetic expansion (`$((1 << 2))`) is not a here-document.
31
+
32
+ - [#69](https://github.com/openapi-typesafe/openapi-typesafe/pull/69) [`1296bd7`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1296bd79e83c39598a471b9bfabf34ffcd71a83e) Thanks [@fedorello](https://github.com/fedorello)! - When `transform` is rewritten to type text with `irCallbacks: true`, the options declared with
33
+ `OpenAPITSOptions` (`const options: OpenAPITSOptions`, `satisfies` or `as OpenAPITSOptions`, a
34
+ `transform` const typed `OpenAPITSOptions["transform"]`) name `OpenAPITSIrOptions` instead, with its
35
+ import; the rewritten file did not compile. Options typed with a type built from `OpenAPITSOptions`
36
+ (`Partial<OpenAPITSOptions>`) keep their `transform`, reported as a manual step. The type is found
37
+ in the other forms it is written in too: `import("openapi-typescript").OpenAPITSOptions`, a local
38
+ alias or an interface that extends it, and the JSDoc `@type` and `@satisfies` of a JavaScript file.
39
+ Options that take keys from another object (`{ ...base, transform }`) keep their `transform`,
40
+ reported as a manual step: the tool cannot see the callbacks and type of `base`. A `transform`
41
+ written as a shorthand property (`{ transform }`) is rewritten too.
42
+
43
+ - [#69](https://github.com/openapi-typesafe/openapi-typesafe/pull/69) [`1296bd7`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1296bd79e83c39598a471b9bfabf34ffcd71a83e) Thanks [@fedorello](https://github.com/fedorello)! - The Jest patterns that name an old package (`moduleNameMapper: { "^openapi-fetch$": … }`,
44
+ `transformIgnorePatterns`) are reported as manual steps, in `jest.config.*` files and in the `jest`
45
+ field of `package.json`. A pattern is not a module specifier, so the tool does not change it. A
46
+ value of a JSON config that is just a package name (`"^@api$": "openapi-fetch"`) is reported too;
47
+ a string of a config script that names a package (`"openapi-fetch/$1"`) is reported once.
48
+
49
+ - [#69](https://github.com/openapi-typesafe/openapi-typesafe/pull/69) [`1296bd7`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1296bd79e83c39598a471b9bfabf34ffcd71a83e) Thanks [@fedorello](https://github.com/fedorello)! - The `import` and `export` blocks of `.mdx` files are migrated like those of a source file. Prose and
50
+ code fences of the page stay as written.
51
+
52
+ - [#69](https://github.com/openapi-typesafe/openapi-typesafe/pull/69) [`1296bd7`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1296bd79e83c39598a471b9bfabf34ffcd71a83e) Thanks [@fedorello](https://github.com/fedorello)! - More files that run the generator are migrated:
53
+ - Task's `Taskfile.yml` (`cmds`, `cmd`, `sh`, `status`, `defer`, `preconditions`);
54
+ - pre-commit's `.pre-commit-config.yaml`: the `entry` and `args` of a hook as one command, and the
55
+ old packages in `additional_dependencies`;
56
+ - the `simple-git-hooks`, `lint-staged` and `nx.targets` commands of `package.json` and
57
+ `package.yaml`;
58
+ - `.lintstagedrc` (JSON or YAML), `.lintstagedrc.json`, `.lintstagedrc.yaml`, `.simple-git-hooks.json`;
59
+ - the `targetDefaults` commands of `nx.json`, and the commands of Nx `configurations`.
60
+
61
+ A YAML command written with escapes (`"openapi-typescript \"$SPEC\""`) is migrated by its value,
62
+ and the whole string is written again with its escapes.
63
+
64
+ - [#69](https://github.com/openapi-typesafe/openapi-typesafe/pull/69) [`1296bd7`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1296bd79e83c39598a471b9bfabf34ffcd71a83e) Thanks [@fedorello](https://github.com/fedorello)! - The import map file that a Deno config names (`"importMap": "./deps.json"`) is migrated like
65
+ `import_map.json`, and its imports count as declared for the files under that config. An import map
66
+ named by a URL or by a path outside the project is reported as a manual step.
67
+
68
+ - [#69](https://github.com/openapi-typesafe/openapi-typesafe/pull/69) [`1296bd7`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1296bd79e83c39598a471b9bfabf34ffcd71a83e) Thanks [@fedorello](https://github.com/fedorello)! - An import of a path into the installed files of an old package
69
+ (`"../node_modules/openapi-fetch/dist/index.js"`) is reported as a manual step: the old package is no
70
+ longer installed after the migration, so the path stops resolving.
71
+
72
+ - [#69](https://github.com/openapi-typesafe/openapi-typesafe/pull/69) [`1296bd7`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1296bd79e83c39598a471b9bfabf34ffcd71a83e) Thanks [@fedorello](https://github.com/fedorello)! - A patch file of an old package (patch-package `patches/openapi-fetch+0.13.0.patch`, pnpm
73
+ `openapi-fetch@0.13.0.patch`, Yarn `openapi-fetch-npm-0.13.0-<hash>.patch`) is reported as a manual
74
+ step: the new package has other code, so the patch cannot be carried over.
75
+
76
+ - [#69](https://github.com/openapi-typesafe/openapi-typesafe/pull/69) [`1296bd7`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1296bd79e83c39598a471b9bfabf34ffcd71a83e) Thanks [@fedorello](https://github.com/fedorello)! - Every package manager setting that names an old package is reported as a manual step, not only
77
+ `overrides` and `patchedDependencies`: `packageExtensions`, `allowedDeprecatedVersions`,
78
+ `onlyBuiltDependencies` and the rest, in `pnpm-workspace.yaml`, in the `pnpm` field of
79
+ `package.json` and in `.yarnrc.yml`. Values count too (`"x": "npm:openapi-fetch@0.13.0"` in
80
+ `overrides`). A setting under the `pnpm` field is reported by its own key (`pnpm.overrides`).
81
+
82
+ - [#66](https://github.com/openapi-typesafe/openapi-typesafe/pull/66) [`15344bf`](https://github.com/openapi-typesafe/openapi-typesafe/commit/15344bfb803ff9872a6d3f79b8279fbbbbfd14ea) Thanks [@fedorello](https://github.com/fedorello)! - The report shows control characters of file names and project text as escapes (`\n`, `\u001b`),
83
+ so a file name cannot forge CI commands or erase the lines before it.
84
+
85
+ - [#69](https://github.com/openapi-typesafe/openapi-typesafe/pull/69) [`1296bd7`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1296bd79e83c39598a471b9bfabf34ffcd71a83e) Thanks [@fedorello](https://github.com/fedorello)! - The targets of Node subpath imports in `package.json` (`"imports": { "#client": "openapi-fetch" }`,
86
+ also under conditions and fallback lists) get the new package names, so they still resolve once the
87
+ dependencies are renamed. So do the keys and values of the `browser` field
88
+ (`"browser": { "openapi-fetch": false }`). A target or `browser` key that reaches into a file of
89
+ the package is reported as a manual step.
90
+
91
+ - [#77](https://github.com/openapi-typesafe/openapi-typesafe/pull/77) [`decc2e2`](https://github.com/openapi-typesafe/openapi-typesafe/commit/decc2e2ae056f8a9b191d7f838056487760df530) Thanks [@fedorello](https://github.com/fedorello)! - `tsconfig.json`, `tsconfig.*.json` and `jsconfig.json` are migrated: the `compilerOptions.paths`
92
+ keys of an old package (`"openapi-fetch"`, `"openapi-fetch/*"`) and its name in
93
+ `compilerOptions.types` get the new names, so the paths still match the renamed imports. A path into
94
+ `node_modules` of an old package is reported as a manual step.
95
+
3
96
  ## 1.0.0-rc.4
4
97
 
5
98
  No changes in this release.
package/README.md CHANGED
@@ -18,22 +18,30 @@ Run it with `npx` (or `pnpm dlx`, `yarn dlx`, `bunx`), not as a dependency: it u
18
18
 
19
19
  ## What it changes
20
20
 
21
- | Where | Change |
22
- | ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
23
- | Every `package.json` and pnpm's `package.yaml` | `dependencies`, `devDependencies`, `peerDependencies` and `optionalDependencies` get the new names, with the version of this tool, in the style of the old range (see below). `catalog:` and `workspace:` stay. An `npm:` alias of an original package (`"my-fetch": "npm:openapi-fetch@^0.13"`) points at the new package. The keys of `peerDependenciesMeta` and `dependenciesMeta` and the names in `bundleDependencies` get the new names too, and so do bun's `catalog` and `catalogs`. |
24
- | `pnpm-workspace.yaml`, `.yarnrc.yml` | Entries of `catalog:` and `catalogs:` (pnpm, Yarn 4.10 and newer), ranges with spaces included. |
25
- | `deno.json`, `deno.jsonc`, `import_map.json` | Keys of `imports` and `scopes` that name an original package (`openapi-fetch`, `openapi-fetch/`), and their `npm:` values. |
26
- | Commands (the files are listed below the table) | The `openapi-typescript` command (also as `npx`, `pnpm exec`, `node_modules/.bin/…` or `npm:openapi-typescript`), and the flags it renamed, in that command only: `--immutable-types` / `-it` → `--immutable`, `--support-array-length` → `--array-length`, `--redoc` → `--redocly`, `-ap` → `--additional-properties`. The old package names in install commands (`npm i`, `pnpm add`, `npx -p`, …). |
27
- | `.github/dependabot.yml` | Every old package name in `dependency-name` and `patterns`. |
28
- | Sources (`.ts`, `.tsx`, `.js`, `.mjs`, `.cjs`, `.vue`, `.svelte`, `.astro`, …) | Module specifiers only: `import` / `export … from`, `import()`, `require()`, `require.resolve()`, `import("…")` types and `@import` tags in JSDoc (every block), `declare module`, `/// <reference types>`, and module mocks: `vi.mock()` and the other `vi` / `jest` module methods (`jest.setMock()`, `jest.requireActual()`, …), bun's `mock.module()`. Components: their `<script>` blocks and Astro's frontmatter. |
29
- | `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. The options may also be a `const` of the same file that only this call uses. Module constants and imports that only the old returns used are removed. Names are resolved by scope, so a local constant is never taken for a module one. |
21
+ | Where | Change |
22
+ | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
23
+ | Every `package.json` and pnpm's `package.yaml` | `dependencies`, `devDependencies`, `peerDependencies` and `optionalDependencies` get the new names, with the version of this tool, in the style of the old range (see below). `catalog:` and `workspace:` stay. An `npm:` alias of an original package (`"my-fetch": "npm:openapi-fetch@^0.13"`) points at the new package. The keys of `peerDependenciesMeta` and `dependenciesMeta` and the names in `bundleDependencies` get the new names too, and so do bun's `catalog` and `catalogs`. The targets of subpath `imports` (`"#client": "openapi-fetch"`, under any conditions) get the new names; the `#` keys stay. So do the keys and values of the `browser` field (`"openapi-fetch": false`). |
24
+ | `pnpm-workspace.yaml`, `.yarnrc.yml` | Entries of `catalog:` and `catalogs:` (pnpm, Yarn 4.10 and newer), ranges with spaces included. |
25
+ | `deno.json`, `deno.jsonc`, `import_map.json` | Keys of `imports` and `scopes` that name an original package (`openapi-fetch`, `openapi-fetch/`), and their `npm:` values, also in the file a config names as its `importMap` (`"importMap": "./deps.json"`). |
26
+ | `tsconfig.json`, `tsconfig.*.json`, `jsconfig.json` | The `compilerOptions.paths` keys of an original package (`"openapi-fetch/*"`) and its name in `compilerOptions.types`. |
27
+ | Commands (the files are listed below the table) | The `openapi-typescript` command (also as `npx`, `pnpm exec`, `node_modules/.bin/…` or `npm:openapi-typescript`), and the flags it renamed, in that command only: `--immutable-types` / `-it` → `--immutable`, `--support-array-length` → `--array-length`, `--redoc` → `--redocly`, `-ap` → `--additional-properties`. The old package names in install commands (`npm i`, `pnpm add`, `npx -p`, …). |
28
+ | `.github/dependabot.yml` | Every old package name in `dependency-name` and `patterns`. |
29
+ | Sources (`.ts`, `.tsx`, `.js`, `.mjs`, `.cjs`, `.vue`, `.svelte`, `.astro`, `.mdx`, …) | Module specifiers only: `import` / `export … from`, `import()`, `require()`, `require.resolve()`, `import("…")` types and `@import` tags in JSDoc (every block), `declare module`, `/// <reference types>`, and module mocks: `vi.mock()` and the other `vi` / `jest` module methods (`jest.setMock()`, `jest.requireActual()`, …), bun's `mock.module()`. Components: their `<script>` blocks and Astro's frontmatter; MDX: its `import` / `export` blocks. A bundler query stays (`openapi-fetch?url`). |
30
+ | `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. The options may also be a `const` of the same file that only this call uses. Module constants and imports that only the old returns used are removed. Names are resolved by scope, so a local constant is never taken for a module one. Options declared as `OpenAPITSOptions` are declared as `OpenAPITSIrOptions` then. |
30
31
 
31
32
  Commands are read in `package.json` scripts, shell scripts (`.sh`, `.bash`, `.zsh`), husky hooks,
32
- `Makefile`, `justfile`, `Dockerfile`, CI and other YAML files, Nx `project.json` targets,
33
- `deno.json` tasks and pnpm `package.yaml` scripts. They are read word by word, the way the shell
34
- splits them (quotes, `\` line continuations, comments, `&&`, `|`, `sh -c "…"`, and the commands
35
- inside `if`, `while`, `for` and `{ … }`), so only the generator's own flags are renamed, and a
36
- script name (`npm run openapi-typescript`) is never changed. A Dockerfile's exec form (`RUN ["npx",
33
+ `Makefile`, `justfile`, `Dockerfile`, CI and other YAML files, Nx `project.json` targets and
34
+ `nx.json` target defaults (also their `configurations`), `deno.json` tasks, pnpm `package.yaml`
35
+ scripts, Task's `Taskfile.yml` (`cmds`, `cmd`, `sh`, `status`, `defer`, `preconditions`),
36
+ pre-commit hooks (`entry` with its `args`), and the `simple-git-hooks`, `lint-staged` and
37
+ `nx.targets` commands of a manifest, also in `.lintstagedrc*` and `.simple-git-hooks.json`. The
38
+ generator is found behind the usual wrappers too (`npx`, `pnpm exec`, `yarn workspace <name>`,
39
+ `dotenvx run`, `nx exec`, `tsx`, `timeout`, `xargs`, …). A here-document is data, except the one a
40
+ shell runs (`bash <<EOF`, `cat <<EOF | sh`). They are read word by word, the way the shell splits
41
+ them (quotes, `\` line continuations, comments, `&&`, `|`,
42
+ `sh -c "…"`, and the commands inside `if`, `while`, `for` and `{ … }`), so only the generator's
43
+ own flags are renamed, and a script name (`npm run openapi-typescript`) is never changed. A
44
+ Dockerfile's exec form (`RUN ["npx",
37
45
  "openapi-typescript", …]`, also after `RUN --mount=…`) is read word by word, and the command line of
38
46
  `["sh", "-c", "…"]` as shell text. A Makefile variable that holds the generator (`OAT :=
39
47
  openapi-typescript`, also for some targets only, and `GEN := $(OAT)`) is renamed where it is set,
@@ -102,8 +110,17 @@ The report and the log show a spec with credentials (`git+https://<token>@…`)
102
110
  The report lists each of these with the file and line:
103
111
 
104
112
  - a version spec it cannot replace (`latest`, a URL, a file, an npm alias), and `overrides` /
105
- `resolutions` / `pnpm` settings (in `package.json` or `pnpm-workspace.yaml`, patches included)
106
- that name an old package;
113
+ `resolutions` and every other package manager setting (`packageExtensions`,
114
+ `allowedDeprecatedVersions`, …, in `package.json`, `pnpm-workspace.yaml` or `.yarnrc.yml`,
115
+ patches included) that names an old package;
116
+ - a `catalog:` dependency whose catalog entry is outside the folder it migrates (`--root` of one
117
+ package of a workspace), or missing from the workspace: it keeps its old name, because the
118
+ entry is not edited;
119
+ - a patch file of an old package (`patches/openapi-fetch+0.13.0.patch`): the new package has other
120
+ code, so check whether the fix is still needed;
121
+ - a word in a command that names an old package where the tool cannot tell what runs it (an
122
+ argument of a program it does not know, a script name): migrate it by hand;
123
+ - an import map that a Deno config names by a URL or a path outside the folder;
107
124
  - a renamed peer dependency: users of your package must switch too;
108
125
  - a pnpm `package.json5` that names an old package: the tool does not read JSON5, so rename the
109
126
  packages and the command there by hand, or write it as `package.json` and run the tool again;
@@ -114,7 +131,13 @@ The report lists each of these with the file and line:
114
131
  - strings in sources that run `openapi-typescript` (`execSync("npx openapi-typescript …")`, also
115
132
  a template such as `` `npx openapi-typescript ${spec}` ``),
116
133
  with the command they should become;
117
- - deep imports such as `openapi-fetch/dist/...`: check that the file exists in the new package;
134
+ - deep imports such as `openapi-fetch/dist/...` (also subpath import targets and `browser` keys):
135
+ check that the file exists in the new package;
136
+ - imports from the `node_modules` folder of an old package (`../node_modules/openapi-fetch/x.js`),
137
+ and such paths in a tsconfig: import from the new package instead, or point the path at its
138
+ files;
139
+ - Jest patterns that name an old package (`moduleNameMapper`, `transformIgnorePatterns`): make
140
+ them match the new name where they mean the package;
118
141
  - a module name built at run time right after an old package name
119
142
  (``import(`openapi-fetch${suffix}`)``): the rest may go on with the name, so only you know what
120
143
  to write;
@@ -129,8 +152,9 @@ The report lists each of these with the file and line:
129
152
  dependency), so alias `openapi-fetch` to `openapi-typesafe-fetch` with `overrides` or
130
153
  `resolutions` (see
131
154
  [Libraries built on openapi-fetch](https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/fetch/index.md#libraries-built-on-openapi-fetch));
132
- - `transform` callbacks it cannot rewrite, and `postTransform` / `transformProperty`, also in
133
- options that other code shares, and `openapiTS()` calls whose options it cannot see (a
155
+ - `transform` callbacks it cannot rewrite (also when their options use a type built from
156
+ `OpenAPITSOptions`, such as `Partial<OpenAPITSOptions>`), and `postTransform` /
157
+ `transformProperty`, also in options that other code shares, and `openapiTS()` calls whose options it cannot see (a
134
158
  parameter, a function call): they keep working with a deprecation warning; see
135
159
  [IR callbacks](https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/node.md#ir-callbacks).
136
160