openapi-typesafe-migrate 1.0.0-rc.6 → 1.0.0-rc.7
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 +47 -0
- package/README.md +30 -15
- package/dist/cli/main.mjs +718 -220
- package/dist/cli/main.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# openapi-typesafe-migrate
|
|
2
2
|
|
|
3
|
+
## 1.0.0-rc.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#101](https://github.com/openapi-typesafe/openapi-typesafe/pull/101) [`7b4ba3f`](https://github.com/openapi-typesafe/openapi-typesafe/commit/7b4ba3f783c16e506d4c9afbfe6392b1e820b1e4) Thanks [@fedorello](https://github.com/fedorello)! - A CI script now runs with the shell that CI gives it: the step's own `shell`, then the job's and
|
|
8
|
+
the workflow's `defaults.run.shell` in GitHub Actions, or the job's `shell` in CircleCI. A Python
|
|
9
|
+
or Node script under such a default is left and reported instead of rewritten as shell, and
|
|
10
|
+
`shell: /usr/bin/env bash -e {0}`, `shell: msys2 {0}` and `shell: wsl-bash {0}` are read as bash
|
|
11
|
+
again, so their commands are migrated.
|
|
12
|
+
|
|
13
|
+
- [#101](https://github.com/openapi-typesafe/openapi-typesafe/pull/101) [`7b4ba3f`](https://github.com/openapi-typesafe/openapi-typesafe/commit/7b4ba3f783c16e506d4c9afbfe6392b1e820b1e4) Thanks [@fedorello](https://github.com/fedorello)! - A rewritten `transform` in options of a `const` without a type (`const options = { transform }`)
|
|
14
|
+
now gets `irCallbacks: true as const` (in JavaScript, `/** @type {const} */ (true)`): a plain
|
|
15
|
+
`true` became `boolean` there, and the `openapiTS` call stopped compiling (TS2769). The option is
|
|
16
|
+
also written before the JSDoc of `transform`, which stays with `transform`.
|
|
17
|
+
|
|
18
|
+
- [#101](https://github.com/openapi-typesafe/openapi-typesafe/pull/101) [`7b4ba3f`](https://github.com/openapi-typesafe/openapi-typesafe/commit/7b4ba3f783c16e506d4c9afbfe6392b1e820b1e4) Thanks [@fedorello](https://github.com/fedorello)! - An import that a JSDoc comment still names (`@param {ts.TypeNode} node`, `{@link ts.factory}`) is
|
|
19
|
+
no longer removed with the rewritten `transform` returns. In a checked JavaScript file the type
|
|
20
|
+
stopped resolving (TS2503).
|
|
21
|
+
|
|
22
|
+
- [#101](https://github.com/openapi-typesafe/openapi-typesafe/pull/101) [`7b4ba3f`](https://github.com/openapi-typesafe/openapi-typesafe/commit/7b4ba3f783c16e506d4c9afbfe6392b1e820b1e4) Thanks [@fedorello](https://github.com/fedorello)! - A justfile variable set by an expression (`gen := env_var_or_default("GEN", "npx
|
|
23
|
+
openapi-typescript")`, an `if … { … } else { … }`), a recipe parameter default
|
|
24
|
+
(`types gen="npx openapi-typescript":`) and a string in an interpolation get the new generator
|
|
25
|
+
name again; they kept the old one without a word, and `npx` then downloaded the old generator.
|
|
26
|
+
Such a value can also be another program, so the old flags after `{{gen}}` are reported.
|
|
27
|
+
|
|
28
|
+
- [#101](https://github.com/openapi-typesafe/openapi-typesafe/pull/101) [`7b4ba3f`](https://github.com/openapi-typesafe/openapi-typesafe/commit/7b4ba3f783c16e506d4c9afbfe6392b1e820b1e4) Thanks [@fedorello](https://github.com/fedorello)! - A local package under an old name in a workspace root (`"openapi-fetch": "file:./vendor/…"`) no
|
|
29
|
+
longer keeps the imports of a workspace package that declares the npm package itself. The
|
|
30
|
+
nearest manifest that declares the name decides, as Node resolves it: that package's dependency
|
|
31
|
+
and its imports now both get the new name.
|
|
32
|
+
|
|
33
|
+
- [#101](https://github.com/openapi-typesafe/openapi-typesafe/pull/101) [`7b4ba3f`](https://github.com/openapi-typesafe/openapi-typesafe/commit/7b4ba3f783c16e506d4c9afbfe6392b1e820b1e4) Thanks [@fedorello](https://github.com/fedorello)! - The migration now renames the old generator inside a shell default value, such as
|
|
34
|
+
`${GEN:-npx openapi-typescript}`, `: "${GEN:=npx openapi-typescript}"` or
|
|
35
|
+
`npx ${PKG:-openapi-typescript}`. Before, these commands kept the old name and npx quietly ran the
|
|
36
|
+
old package. The variable can still be set to another program outside the file, so the flags after
|
|
37
|
+
such a default are listed as a manual step instead of being changed.
|
|
38
|
+
|
|
39
|
+
- [#101](https://github.com/openapi-typesafe/openapi-typesafe/pull/101) [`7b4ba3f`](https://github.com/openapi-typesafe/openapi-typesafe/commit/7b4ba3f783c16e506d4c9afbfe6392b1e820b1e4) Thanks [@fedorello](https://github.com/fedorello)! - The files of a split API description (`components/schemas/Job.yaml`, reached by `$ref` from
|
|
40
|
+
`openapi.yaml` or `openapi.json`) and OpenAPI Overlay and Arazzo documents are data now, like the
|
|
41
|
+
API description itself: their example `command` and `script` values are no longer rewritten, so
|
|
42
|
+
the change no longer reaches the generated comments.
|
|
43
|
+
|
|
44
|
+
- [#101](https://github.com/openapi-typesafe/openapi-typesafe/pull/101) [`7b4ba3f`](https://github.com/openapi-typesafe/openapi-typesafe/commit/7b4ba3f783c16e506d4c9afbfe6392b1e820b1e4) Thanks [@fedorello](https://github.com/fedorello)! - The migration now lists the old flags after a variable that runs a command when it cannot see
|
|
45
|
+
where the variable is set: in another GitLab `script` item, through `$GITHUB_ENV` in an earlier
|
|
46
|
+
step, as `$$GEN` in a Makefile recipe, as a bash array run with `"${GEN[@]}"`, or outside the
|
|
47
|
+
file. Before, flags like `-it` after such a variable were kept without a word, and the new
|
|
48
|
+
generator then stopped with an unknown flag. The items of a bash array are now renamed too.
|
|
49
|
+
|
|
3
50
|
## 1.0.0-rc.6
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -18,16 +18,16 @@ 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:` 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.
|
|
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, and so do the imports of it in the files for which that manifest is the nearest one that declares the name, as Node resolves it. 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 (without a type, the option is `irCallbacks: true as const`, which keeps the type `true` that the call needs); 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
|
|
@@ -48,18 +48,33 @@ openapi-typescript`, also for some targets only, and `GEN := $(OAT)`) is renamed
|
|
|
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
50
|
variable and the flags after `$GEN`, and a justfile variable (`gen := "npx openapi-typescript"`)
|
|
51
|
-
and the flags after `{{gen}}`.
|
|
51
|
+
and the flags after `{{gen}}`. In a justfile every string and backtick of an expression is read
|
|
52
|
+
as a command line where it is written: in a value that just computes
|
|
53
|
+
(`env_var_or_default("GEN", "npx openapi-typescript")`, an `if`), in a recipe parameter default
|
|
54
|
+
(`types gen="npx openapi-typescript":`) and in an interpolation; such a value and a parameter (the
|
|
55
|
+
command line can set it) may run another program, so the flags after them are reported. A shell variable that a script, a `run` block or a package.json
|
|
52
56
|
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
|
|
57
|
+
is renamed where it is set, and the flags after `$GEN` where it runs. The word of a default
|
|
58
|
+
(`${GEN:-npx openapi-typescript}`, `${GEN:=…}`, `${GEN:+…}`) is read as a command line where it
|
|
59
|
+
is written, so the old name in it is renamed; the variable may hold another program set outside
|
|
60
|
+
the file, so the flags after such a default are reported. The flags change only when every definition of the variable
|
|
54
61
|
in the file sets it to the generator: a variable that another Dockerfile stage, a step `env` or a
|
|
55
|
-
later Makefile line or shell assignment sets to another program is reported with its old flags.
|
|
62
|
+
later Makefile line or shell assignment sets to another program is reported with its old flags. So is a
|
|
63
|
+
variable that runs a command but that no definition the tool reads sets: one set by another
|
|
64
|
+
`script` item or step (`echo "GEN=…" >> "$GITHUB_ENV"`), a Makefile recipe's `$$GEN`, a bash
|
|
65
|
+
array (`GEN=(npx openapi-typescript)`, whose items are renamed, run as `"${GEN[@]}"`), or one
|
|
66
|
+
set outside the file. A variable of old
|
|
56
67
|
flags that the generator gets (`$(FLAGS)` with `FLAGS := -it`) may serve other commands too, so it
|
|
57
68
|
is reported, not changed. YAML files are changed only in command
|
|
58
69
|
keys (`run`, `script`, `command`, `entrypoint`, …) and in the values of `env`, in block and flow
|
|
59
70
|
style, never in other values. A CI step whose `shell` is another program (`shell: python`) runs
|
|
60
71
|
code of that language, so its script is not changed, and it is reported when it names an old
|
|
61
|
-
package.
|
|
62
|
-
`
|
|
72
|
+
package. The nearest `shell` counts: the step's own, then the job's and the workflow's
|
|
73
|
+
`defaults.run.shell` (GitHub Actions), or the job's `shell` (CircleCI). `env` (`/usr/bin/env bash
|
|
74
|
+
-e {0}`) runs the program after it, and `msys2 {0}` and `wsl-bash {0}` run bash. An API description (a YAML document with a top-level `openapi`,
|
|
75
|
+
`swagger`, `asyncapi`, `overlay` or `arazzo` key) is data, so it is never changed, not even an
|
|
76
|
+
example `command`, and neither is a YAML file that such a document (YAML or JSON) reaches by
|
|
77
|
+
`$ref`, directly or through other such files (a split layout's `components/schemas/Job.yaml`); a
|
|
63
78
|
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
|
|
64
79
|
line and column, not changed. `Makefile`, `justfile` and `Dockerfile` are read only under the names
|
|
65
80
|
make, just and docker look for (also `makefile`, `GNUmakefile`, `Justfile`, `.justfile`,
|