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

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,53 @@
1
1
  # openapi-typesafe-migrate
2
2
 
3
+ ## 1.0.0-rc.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#93](https://github.com/openapi-typesafe/openapi-typesafe/pull/93) [`25f631d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/25f631d8dabed24e18a859b08e8395496e145118) Thanks [@fedorello](https://github.com/fedorello)! - An OpenAPI, Swagger or AsyncAPI document in YAML is no longer changed: an example value under a
8
+ `command` or `script` key that mentions the generator stays as written.
9
+
10
+ - [#93](https://github.com/openapi-typesafe/openapi-typesafe/pull/93) [`25f631d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/25f631d8dabed24e18a859b08e8395496e145118) Thanks [@fedorello](https://github.com/fedorello)! - `openapi-typesafe-migrate | head` (or any reader that closes the pipe early) no longer crashes with
11
+ an `EPIPE` stack trace and exit code 1: the rest of the report is dropped and the run ends as it
12
+ would have.
13
+
14
+ - [#93](https://github.com/openapi-typesafe/openapi-typesafe/pull/93) [`25f631d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/25f631d8dabed24e18a859b08e8395496e145118) Thanks [@fedorello](https://github.com/fedorello)! - A constant or an import that an `export { … }` list names is no longer removed with the old
15
+ `transform` returns, so the file still compiles.
16
+
17
+ - [#93](https://github.com/openapi-typesafe/openapi-typesafe/pull/93) [`25f631d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/25f631d8dabed24e18a859b08e8395496e145118) Thanks [@fedorello](https://github.com/fedorello)! - An exported function that `transform` names is no longer rewritten: other modules may call it
18
+ and expect TypeScript nodes. It is kept and reported as a manual step, like options that other
19
+ code uses.
20
+
21
+ - [#93](https://github.com/openapi-typesafe/openapi-typesafe/pull/93) [`25f631d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/25f631d8dabed24e18a859b08e8395496e145118) Thanks [@fedorello](https://github.com/fedorello)! - A justfile variable that holds the generator (`gen := "npx openapi-typescript"`) now has its old
22
+ flags renamed where it runs: `{{gen}} api.yaml -it` kept `-it`. A variable of old flags that the
23
+ generator gets (`{{flags}}`) is reported.
24
+
25
+ - [#93](https://github.com/openapi-typesafe/openapi-typesafe/pull/93) [`25f631d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/25f631d8dabed24e18a859b08e8395496e145118) Thanks [@fedorello](https://github.com/fedorello)! - A dependency under an old name on a local package (`workspace:*`, `link:`, `file:`, `portal:`),
26
+ such as a fork named `openapi-fetch` in the workspace, is no longer renamed: the new name pointed
27
+ at a package the workspace does not have, and the install failed. The dependency and the imports
28
+ of it keep their name, and the report lists it as a manual step.
29
+
30
+ - [#93](https://github.com/openapi-typesafe/openapi-typesafe/pull/93) [`25f631d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/25f631d8dabed24e18a859b08e8395496e145118) Thanks [@fedorello](https://github.com/fedorello)! - A CI step whose `shell` is another program (`shell: python` in GitHub Actions, or a CircleCI
31
+ `shell` next to `command`) runs code of that language, not commands. Its script is now left as it
32
+ is and reported when it names an old package; it was skipped without a word.
33
+
34
+ - [#93](https://github.com/openapi-typesafe/openapi-typesafe/pull/93) [`25f631d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/25f631d8dabed24e18a859b08e8395496e145118) Thanks [@fedorello](https://github.com/fedorello)! - A shell variable that holds the generator is migrated now. A script, a CI `run` block or a
35
+ `package.json` script that sets `GEN="npx openapi-typescript"` (also after `export`, `local` or
36
+ `readonly`) and then runs `$GEN api.yaml -it` was left as it was, and nothing was reported, so
37
+ the build went on downloading the old generator. The value is renamed where it is set and the
38
+ flags after `$GEN` where it runs, and a variable of old flags that the generator gets is reported.
39
+
40
+ - [#93](https://github.com/openapi-typesafe/openapi-typesafe/pull/93) [`25f631d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/25f631d8dabed24e18a859b08e8395496e145118) Thanks [@fedorello](https://github.com/fedorello)! - Once `openapi-fetch` is aliased to `openapi-typesafe-fetch` in the overrides (as the docs ask for
41
+ swr-openapi), the report no longer says to update that override or to add the alias again, so a
42
+ second run is clean. The alias counts in the `package.json` itself and in a workspace above it.
43
+
44
+ - [#93](https://github.com/openapi-typesafe/openapi-typesafe/pull/93) [`25f631d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/25f631d8dabed24e18a859b08e8395496e145118) Thanks [@fedorello](https://github.com/fedorello)! - A path in the `typesVersions` of `package.json` into the installed files of an old package
45
+ (`node_modules/openapi-fetch/dist/index.d.ts`) is reported, as such paths in a tsconfig are: the
46
+ new package has its own files there.
47
+
48
+ - [#93](https://github.com/openapi-typesafe/openapi-typesafe/pull/93) [`25f631d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/25f631d8dabed24e18a859b08e8395496e145118) Thanks [@fedorello](https://github.com/fedorello)! - The `command` of a wireit script in `package.json` is migrated like the other scripts. It was
49
+ neither changed nor reported.
50
+
3
51
  ## 1.0.0-rc.5
4
52
 
5
53
  ### Patch Changes
package/README.md CHANGED
@@ -18,23 +18,23 @@ 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`. 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. |
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:` stays; a dependency on a local package (`workspace:`, `link:`, `file:`) keeps its name and is reported. 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; options or a named `transform` function that other code can reach (another use, or an export) are kept and reported. Module constants and imports that only the old returns used are removed; exported ones stay. 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. |
31
31
 
32
32
  Commands are read in `package.json` scripts, shell scripts (`.sh`, `.bash`, `.zsh`), husky hooks,
33
33
  `Makefile`, `justfile`, `Dockerfile`, CI and other YAML files, Nx `project.json` targets and
34
34
  `nx.json` target defaults (also their `configurations`), `deno.json` tasks, pnpm `package.yaml`
35
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
36
+ pre-commit hooks (`entry` with its `args`), and the `simple-git-hooks`, `lint-staged`,
37
+ `nx.targets` and wireit `command` commands of a manifest, also in `.lintstagedrc*` and `.simple-git-hooks.json`. The
38
38
  generator is found behind the usual wrappers too (`npx`, `pnpm exec`, `yarn workspace <name>`,
39
39
  `dotenvx run`, `nx exec`, `tsx`, `timeout`, `xargs`, …). A here-document is data, except the one a
40
40
  shell runs (`bash <<EOF`, `cat <<EOF | sh`). They are read word by word, the way the shell splits
@@ -47,14 +47,20 @@ Dockerfile's exec form (`RUN ["npx",
47
47
  openapi-typescript`, also for some targets only, and `GEN := $(OAT)`) is renamed where it is set,
48
48
  and the flags after `$(OAT)` (or `$G` for a one-letter name) where it runs; so is an `env` variable
49
49
  of a workflow and the flags after `$GEN` or `${{ env.GEN }}`, and a Dockerfile `ARG` or `ENV`
50
- variable and the flags after `$GEN`. The flags change only when every definition of the variable
50
+ variable and the flags after `$GEN`, and a justfile variable (`gen := "npx openapi-typescript"`)
51
+ and the flags after `{{gen}}`. A shell variable that a script, a `run` block or a package.json
52
+ script sets itself (`GEN="npx openapi-typescript"`, also after `export`, `local` or `readonly`)
53
+ is renamed where it is set, and the flags after `$GEN` where it runs. The flags change only when every definition of the variable
51
54
  in the file sets it to the generator: a variable that another Dockerfile stage, a step `env` or a
52
- later Makefile line sets to another program is reported with its old flags. A variable of old
55
+ later Makefile line or shell assignment sets to another program is reported with its old flags. A variable of old
53
56
  flags that the generator gets (`$(FLAGS)` with `FLAGS := -it`) may serve other commands too, so it
54
57
  is reported, not changed. YAML files are changed only in command
55
58
  keys (`run`, `script`, `command`, `entrypoint`, …) and in the values of `env`, in block and flow
56
- style, never in other values such as an OpenAPI `description`; a YAML file that names no old package
57
- is not even parsed. A config that cannot be parsed and names an old package is reported with the
59
+ style, never in other values. A CI step whose `shell` is another program (`shell: python`) runs
60
+ code of that language, so its script is not changed, and it is reported when it names an old
61
+ package. An API description (a YAML document with a top-level `openapi`,
62
+ `swagger` or `asyncapi` key) is data, so it is never changed, not even an example `command`; a
63
+ YAML file that names no old package is not even parsed. A config that cannot be parsed and names an old package is reported with the
58
64
  line and column, not changed. `Makefile`, `justfile` and `Dockerfile` are read only under the names
59
65
  make, just and docker look for (also `makefile`, `GNUmakefile`, `Justfile`, `.justfile`,
60
66
  `Containerfile` and `*.mk`), so `Dockerfile.dev` is not changed.
@@ -112,7 +118,11 @@ The report lists each of these with the file and line:
112
118
  - a version spec it cannot replace (`latest`, a URL, a file, an npm alias), and `overrides` /
113
119
  `resolutions` and every other package manager setting (`packageExtensions`,
114
120
  `allowedDeprecatedVersions`, …, in `package.json`, `pnpm-workspace.yaml` or `.yarnrc.yml`,
115
- patches included) that names an old package;
121
+ patches included) that names an old package, except an override that aliases it to its
122
+ successor (`"openapi-fetch": "npm:openapi-typesafe-fetch@^1.0.0"`), which is the migration done;
123
+ - a dependency under an old name on a local package (`workspace:*`, `link:`, `file:`, `portal:`),
124
+ such as a fork in the workspace: it and the imports of it keep the old name, because the new
125
+ name would point at a package the project does not have;
116
126
  - a `catalog:` dependency whose catalog entry is outside the folder it migrates (`--root` of one
117
127
  package of a workspace), or missing from the workspace: it keeps its old name, because the
118
128
  entry is not edited;
@@ -120,6 +130,8 @@ The report lists each of these with the file and line:
120
130
  code, so check whether the fix is still needed;
121
131
  - a word in a command that names an old package where the tool cannot tell what runs it (an
122
132
  argument of a program it does not know, a script name): migrate it by hand;
133
+ - a CI step whose `shell` is another program (`shell: python`) and whose script names an old
134
+ package: the tool does not read code of other languages, so migrate it by hand;
123
135
  - an import map that a Deno config names by a URL or a path outside the folder;
124
136
  - a renamed peer dependency: users of your package must switch too;
125
137
  - a pnpm `package.json5` that names an old package: the tool does not read JSON5, so rename the
@@ -134,8 +146,8 @@ The report lists each of these with the file and line:
134
146
  - deep imports such as `openapi-fetch/dist/...` (also subpath import targets and `browser` keys):
135
147
  check that the file exists in the new package;
136
148
  - 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;
149
+ and such paths in a tsconfig or in `typesVersions`: import from the new package instead, or
150
+ point the path at its files;
139
151
  - Jest patterns that name an old package (`moduleNameMapper`, `transformIgnorePatterns`): make
140
152
  them match the new name where they mean the package;
141
153
  - a module name built at run time right after an old package name
@@ -148,9 +160,9 @@ The report lists each of these with the file and line:
148
160
  - strings that equal an old package name outside a module specifier (an object key, a label, a
149
161
  bundler option such as `external: ["openapi-fetch"]`): they are kept, because only you know
150
162
  whether they mean the package. Comments are not changed or reported;
151
- - `swr-openapi` in your dependencies: it takes its client type from `openapi-fetch` (a peer
152
- dependency), so alias `openapi-fetch` to `openapi-typesafe-fetch` with `overrides` or
153
- `resolutions` (see
163
+ - `swr-openapi` in your dependencies, until the alias is in place: it takes its client type from
164
+ `openapi-fetch` (a peer dependency), so alias `openapi-fetch` to `openapi-typesafe-fetch` with
165
+ `overrides` or `resolutions` (see
154
166
  [Libraries built on openapi-fetch](https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/fetch/index.md#libraries-built-on-openapi-fetch));
155
167
  - `transform` callbacks it cannot rewrite (also when their options use a type built from
156
168
  `OpenAPITSOptions`, such as `Partial<OpenAPITSOptions>`), and `postTransform` /