openapi-typesafe-migrate 1.0.0-rc.6 → 1.0.0-rc.8
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 +110 -0
- package/README.md +61 -25
- package/dist/cli/main.mjs +1160 -286
- package/dist/cli/main.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,115 @@
|
|
|
1
1
|
# openapi-typesafe-migrate
|
|
2
2
|
|
|
3
|
+
## 1.0.0-rc.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#107](https://github.com/openapi-typesafe/openapi-typesafe/pull/107) [`173c82c`](https://github.com/openapi-typesafe/openapi-typesafe/commit/173c82c24fb8d59a5e3d4894596391dd48f2608f) Thanks [@fedorello](https://github.com/fedorello)! - When a bug of the tool would corrupt one file, only that file is left as it was: the report lists
|
|
8
|
+
it under "Skipped" with the reason and asks you to migrate it by hand, the other files are still
|
|
9
|
+
migrated (and written with `--write`), and the command exits with `1`. Before, such a bug stopped
|
|
10
|
+
the whole run and nothing was migrated.
|
|
11
|
+
|
|
12
|
+
- [#107](https://github.com/openapi-typesafe/openapi-typesafe/pull/107) [`173c82c`](https://github.com/openapi-typesafe/openapi-typesafe/commit/173c82c24fb8d59a5e3d4894596391dd48f2608f) Thanks [@fedorello](https://github.com/fedorello)! - A CircleCI job now takes the `shell` of the executor it names (`executor: py` with
|
|
13
|
+
`executors.py.shell: /usr/bin/python3`), so the Python code of its steps is no longer rewritten as
|
|
14
|
+
a command line; a step that names an old package is listed as a manual step. The job's own `shell`
|
|
15
|
+
still wins.
|
|
16
|
+
|
|
17
|
+
- [#107](https://github.com/openapi-typesafe/openapi-typesafe/pull/107) [`173c82c`](https://github.com/openapi-typesafe/openapi-typesafe/commit/173c82c24fb8d59a5e3d4894596391dd48f2608f) Thanks [@fedorello](https://github.com/fedorello)! - A Dockerfile `ARG` or `ENV` whose value has a shell default, such as
|
|
18
|
+
`ENV GEN=${GEN:-npx openapi-typescript}`, no longer stops the whole migration with "Edits overlap"
|
|
19
|
+
and exit code 1: the default is renamed once, like any other `ARG` or `ENV` value.
|
|
20
|
+
|
|
21
|
+
- [#107](https://github.com/openapi-typesafe/openapi-typesafe/pull/107) [`173c82c`](https://github.com/openapi-typesafe/openapi-typesafe/commit/173c82c24fb8d59a5e3d4894596391dd48f2608f) Thanks [@fedorello](https://github.com/fedorello)! - A GitLab CI job named `openapi`, `swagger`, `asyncapi`, `overlay` or `arazzo` no longer makes the
|
|
22
|
+
whole `.gitlab-ci.yml` count as an API description, so its commands are migrated again. A YAML file
|
|
23
|
+
counts as an API description only when such a top-level key holds a version (`openapi: 3.1.0`), and
|
|
24
|
+
a CI config (`.gitlab-ci.yml`, a GitHub workflow, a CircleCI config, …) never does.
|
|
25
|
+
|
|
26
|
+
- [#107](https://github.com/openapi-typesafe/openapi-typesafe/pull/107) [`173c82c`](https://github.com/openapi-typesafe/openapi-typesafe/commit/173c82c24fb8d59a5e3d4894596391dd48f2608f) Thanks [@fedorello](https://github.com/fedorello)! - Old flags in a justfile recipe parameter default (`b *flags='-it':` with `{{gen}} f.yaml
|
|
27
|
+
{{flags}}`) are now reported, like the flags of a `flags := '-it'` variable. Before, the run failed
|
|
28
|
+
later with `CLI_FLAG_REMOVED`.
|
|
29
|
+
|
|
30
|
+
- [#107](https://github.com/openapi-typesafe/openapi-typesafe/pull/107) [`173c82c`](https://github.com/openapi-typesafe/openapi-typesafe/commit/173c82c24fb8d59a5e3d4894596391dd48f2608f) Thanks [@fedorello](https://github.com/fedorello)! - A Makefile command that make computes, such as `$(or $(GEN),npx openapi-typescript) b.yaml -it`,
|
|
31
|
+
is now reported with the text you wrote. Before, the report showed a row of underscores instead.
|
|
32
|
+
|
|
33
|
+
- [#107](https://github.com/openapi-typesafe/openapi-typesafe/pull/107) [`173c82c`](https://github.com/openapi-typesafe/openapi-typesafe/commit/173c82c24fb8d59a5e3d4894596391dd48f2608f) Thanks [@fedorello](https://github.com/fedorello)! - A path that names the `node_modules` folder of an old package itself (`"paths": { "a":
|
|
34
|
+
["./node_modules/openapi-fetch"] }` in a tsconfig, or an import of `../node_modules/openapi-fetch`)
|
|
35
|
+
is now reported, like a path to a file inside it.
|
|
36
|
+
|
|
37
|
+
- [#107](https://github.com/openapi-typesafe/openapi-typesafe/pull/107) [`173c82c`](https://github.com/openapi-typesafe/openapi-typesafe/commit/173c82c24fb8d59a5e3d4894596391dd48f2608f) Thanks [@fedorello](https://github.com/fedorello)! - Options passed to `openapiTS()` that take keys from another object (`{ ...base }`) are now checked
|
|
38
|
+
for legacy callbacks. When the file writes that object (`...{ transform }` or `const base = { … }`),
|
|
39
|
+
its `transform`, `postTransform` and `transformProperty` are listed as manual steps; a spread of an
|
|
40
|
+
object the tool cannot read (an import, a call) is listed too, so you can check it. Before, such
|
|
41
|
+
options were not reported at all.
|
|
42
|
+
|
|
43
|
+
- [#107](https://github.com/openapi-typesafe/openapi-typesafe/pull/107) [`173c82c`](https://github.com/openapi-typesafe/openapi-typesafe/commit/173c82c24fb8d59a5e3d4894596391dd48f2608f) Thanks [@fedorello](https://github.com/fedorello)! - A justfile recipe whose first line is a shebang for another program (`#!/usr/bin/env python3`), and
|
|
44
|
+
code given on the command line (`python3 -c '…'`, `node -e "…"`, `ruby -e '…'`), are no longer
|
|
45
|
+
read as shell commands. When such code names an old package, it is listed as a manual step
|
|
46
|
+
("the script runs with python3, …"); before, it was neither changed nor reported, or a command
|
|
47
|
+
line inside it was rewritten.
|
|
48
|
+
|
|
49
|
+
- [#107](https://github.com/openapi-typesafe/openapi-typesafe/pull/107) [`173c82c`](https://github.com/openapi-typesafe/openapi-typesafe/commit/173c82c24fb8d59a5e3d4894596391dd48f2608f) Thanks [@fedorello](https://github.com/fedorello)! - A rewritten `transform` whose type is declared outside the function now compiles: a TypeScript
|
|
50
|
+
node type in the type of its `const` (`const transform: (s: SchemaObject) => ts.TypeNode`), in a
|
|
51
|
+
JSDoc `@type` or in a JSDoc `@returns` becomes `string`, like the returns. Before, that type stayed
|
|
52
|
+
and the file no longer compiled. A declared type the tool cannot map, such as a local alias, keeps
|
|
53
|
+
the `transform`, which is listed as a manual step.
|
|
54
|
+
|
|
55
|
+
- [#107](https://github.com/openapi-typesafe/openapi-typesafe/pull/107) [`173c82c`](https://github.com/openapi-typesafe/openapi-typesafe/commit/173c82c24fb8d59a5e3d4894596391dd48f2608f) Thanks [@fedorello](https://github.com/fedorello)! - A launcher or install command written with its Windows file suffix (`npx.cmd openapi-typescript`,
|
|
56
|
+
`pnpm.exe exec …`, `npm.ps1 i openapi-fetch`) is now migrated like `npx`, `pnpm` and `npm`.
|
|
57
|
+
Before, the old name after it was only reported.
|
|
58
|
+
|
|
59
|
+
- [#107](https://github.com/openapi-typesafe/openapi-typesafe/pull/107) [`173c82c`](https://github.com/openapi-typesafe/openapi-typesafe/commit/173c82c24fb8d59a5e3d4894596391dd48f2608f) Thanks [@fedorello](https://github.com/fedorello)! - The migration renames the old generator in GitHub Actions expressions again, such as
|
|
60
|
+
`run: ${{ inputs.generator || 'npx openapi-typescript' }} api.yaml` and
|
|
61
|
+
`npx ${{ inputs.pkg || 'openapi-typescript' }}`, and in input defaults of an `action.yml` or a
|
|
62
|
+
reusable workflow (`default: npx openapi-typescript`). The value of an expression comes from the
|
|
63
|
+
run, so old flags after it are listed as a manual step. Before, these places were neither changed
|
|
64
|
+
nor reported, and npx ran the old package after the migration.
|
|
65
|
+
|
|
66
|
+
## 1.0.0-rc.7
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- [#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
|
|
71
|
+
the workflow's `defaults.run.shell` in GitHub Actions, or the job's `shell` in CircleCI. A Python
|
|
72
|
+
or Node script under such a default is left and reported instead of rewritten as shell, and
|
|
73
|
+
`shell: /usr/bin/env bash -e {0}`, `shell: msys2 {0}` and `shell: wsl-bash {0}` are read as bash
|
|
74
|
+
again, so their commands are migrated.
|
|
75
|
+
|
|
76
|
+
- [#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 }`)
|
|
77
|
+
now gets `irCallbacks: true as const` (in JavaScript, `/** @type {const} */ (true)`): a plain
|
|
78
|
+
`true` became `boolean` there, and the `openapiTS` call stopped compiling (TS2769). The option is
|
|
79
|
+
also written before the JSDoc of `transform`, which stays with `transform`.
|
|
80
|
+
|
|
81
|
+
- [#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
|
|
82
|
+
no longer removed with the rewritten `transform` returns. In a checked JavaScript file the type
|
|
83
|
+
stopped resolving (TS2503).
|
|
84
|
+
|
|
85
|
+
- [#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
|
|
86
|
+
openapi-typescript")`, an `if … { … } else { … }`), a recipe parameter default
|
|
87
|
+
(`types gen="npx openapi-typescript":`) and a string in an interpolation get the new generator
|
|
88
|
+
name again; they kept the old one without a word, and `npx` then downloaded the old generator.
|
|
89
|
+
Such a value can also be another program, so the old flags after `{{gen}}` are reported.
|
|
90
|
+
|
|
91
|
+
- [#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
|
|
92
|
+
longer keeps the imports of a workspace package that declares the npm package itself. The
|
|
93
|
+
nearest manifest that declares the name decides, as Node resolves it: that package's dependency
|
|
94
|
+
and its imports now both get the new name.
|
|
95
|
+
|
|
96
|
+
- [#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
|
|
97
|
+
`${GEN:-npx openapi-typescript}`, `: "${GEN:=npx openapi-typescript}"` or
|
|
98
|
+
`npx ${PKG:-openapi-typescript}`. Before, these commands kept the old name and npx quietly ran the
|
|
99
|
+
old package. The variable can still be set to another program outside the file, so the flags after
|
|
100
|
+
such a default are listed as a manual step instead of being changed.
|
|
101
|
+
|
|
102
|
+
- [#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
|
|
103
|
+
`openapi.yaml` or `openapi.json`) and OpenAPI Overlay and Arazzo documents are data now, like the
|
|
104
|
+
API description itself: their example `command` and `script` values are no longer rewritten, so
|
|
105
|
+
the change no longer reaches the generated comments.
|
|
106
|
+
|
|
107
|
+
- [#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
|
|
108
|
+
where the variable is set: in another GitLab `script` item, through `$GITHUB_ENV` in an earlier
|
|
109
|
+
step, as `$$GEN` in a Makefile recipe, as a bash array run with `"${GEN[@]}"`, or outside the
|
|
110
|
+
file. Before, flags like `-it` after such a variable were kept without a word, and the new
|
|
111
|
+
generator then stopped with an unknown flag. The items of a bash array are now renamed too.
|
|
112
|
+
|
|
3
113
|
## 1.0.0-rc.6
|
|
4
114
|
|
|
5
115
|
### 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, and a node type declared for `transform` (its return type, the type of its `const`, a JSDoc `@type` or `@returns`) becomes `string`; a declared type the tool cannot map keeps the `transform`, which is reported. |
|
|
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,46 @@ 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 same holds for the string literals
|
|
61
|
+
of a GitHub Actions expression (`${{ inputs.gen || 'npx openapi-typescript' }}`), which the runner
|
|
62
|
+
puts into the script before the shell runs, and for the default of an input
|
|
63
|
+
(`inputs.command.default` of an `action.yml`, `workflow_call` and `workflow_dispatch` inputs):
|
|
64
|
+
the old name in them is renamed, and the flags after an expression are reported, because its value
|
|
65
|
+
comes from the run. A Makefile program that make computes (`$(or $(GEN),npx
|
|
66
|
+
openapi-typescript)`, `$(shell …)`) may run the generator too, so the flags after it are
|
|
67
|
+
reported. The flags change only when every definition of the variable
|
|
54
68
|
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.
|
|
56
|
-
|
|
69
|
+
later Makefile line or shell assignment sets to another program is reported with its old flags. So is a
|
|
70
|
+
variable that runs a command but that no definition the tool reads sets: one set by another
|
|
71
|
+
`script` item or step (`echo "GEN=…" >> "$GITHUB_ENV"`), a Makefile recipe's `$$GEN`, a bash
|
|
72
|
+
array (`GEN=(npx openapi-typescript)`, whose items are renamed, run as `"${GEN[@]}"`), or one
|
|
73
|
+
set outside the file. A variable of old
|
|
74
|
+
flags that the generator gets (`$(FLAGS)` with `FLAGS := -it`, or a justfile `{{flags}}` with
|
|
75
|
+
`flags := '-it'` or a recipe parameter `*flags='-it'`) may serve other commands too, so it
|
|
57
76
|
is reported, not changed. YAML files are changed only in command
|
|
58
|
-
keys (`run`, `script`, `command`, `entrypoint`, …)
|
|
59
|
-
style, never in other values. A CI step whose `shell` is another program (`shell: python`) runs
|
|
77
|
+
keys (`run`, `script`, `command`, `entrypoint`, …), in the values of `env` and in input
|
|
78
|
+
defaults, in block and flow style, never in other values. A CI step whose `shell` is another program (`shell: python`) runs
|
|
60
79
|
code of that language, so its script is not changed, and it is reported when it names an old
|
|
61
|
-
package.
|
|
62
|
-
`
|
|
80
|
+
package. The nearest `shell` counts: the step's own, then the job's and the workflow's
|
|
81
|
+
`defaults.run.shell` (GitHub Actions), or the job's `shell` and then the `shell` of the
|
|
82
|
+
executor the job names (`executor: py`, CircleCI). `env` (`/usr/bin/env bash
|
|
83
|
+
-e {0}`) runs the program after it, and `msys2 {0}` and `wsl-bash {0}` run bash. The same holds for a
|
|
84
|
+
justfile recipe whose first line is a shebang for another program (`#!/usr/bin/env python3`), and
|
|
85
|
+
for code given on the command line (`python3 -c '…'`, `node -e "…"`, `ruby -e '…'`). An API description (a YAML document with a top-level `openapi`,
|
|
86
|
+
`swagger`, `asyncapi`, `overlay` or `arazzo` key whose value is a version, such as `openapi: 3.1.0`;
|
|
87
|
+
a CI config such as `.gitlab-ci.yml` or a workflow never is one, so a GitLab job named `openapi`
|
|
88
|
+
is migrated) is data, so it is never changed, not even an
|
|
89
|
+
example `command`, and neither is a YAML file that such a document (YAML or JSON) reaches by
|
|
90
|
+
`$ref`, directly or through other such files (a split layout's `components/schemas/Job.yaml`); a
|
|
63
91
|
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
92
|
line and column, not changed. `Makefile`, `justfile` and `Dockerfile` are read only under the names
|
|
65
93
|
make, just and docker look for (also `makefile`, `GNUmakefile`, `Justfile`, `.justfile`,
|
|
@@ -105,8 +133,9 @@ or written; the report lists it under "Skipped". A file is written as a new file
|
|
|
105
133
|
old one (same mode), so a hard link to a file elsewhere keeps its old text; the log notes it.
|
|
106
134
|
A file whose bytes are not UTF-8 (a Latin-1 source, for example) is not changed, because its
|
|
107
135
|
text cannot be written back without changing other characters; neither is a file that cannot be
|
|
108
|
-
read. The report lists both under "Skipped".
|
|
109
|
-
|
|
136
|
+
read. The report lists both under "Skipped". So does a file that a bug of the tool would corrupt
|
|
137
|
+
(two of its edits overlap): it is left as it was, the other files are still migrated, and the
|
|
138
|
+
command exits with `1`. Every file is read and migrated before the first one is written. If a write fails, the writing stops, the command exits with `1`, and the report names
|
|
110
139
|
the files written before it and the ones that were not.
|
|
111
140
|
The report and the log show a spec with credentials (`git+https://<token>@…`) as
|
|
112
141
|
`git+https://***@…`; the file keeps it as written.
|
|
@@ -130,8 +159,9 @@ The report lists each of these with the file and line:
|
|
|
130
159
|
code, so check whether the fix is still needed;
|
|
131
160
|
- a word in a command that names an old package where the tool cannot tell what runs it (an
|
|
132
161
|
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`)
|
|
134
|
-
|
|
162
|
+
- a CI step whose `shell` is another program (`shell: python`), a justfile recipe with a shebang
|
|
163
|
+
for one, or inline code (`python3 -c '…'`) that names an old package: the tool does not read
|
|
164
|
+
code of other languages, so migrate it by hand;
|
|
135
165
|
- an import map that a Deno config names by a URL or a path outside the folder;
|
|
136
166
|
- a renamed peer dependency: users of your package must switch too;
|
|
137
167
|
- a pnpm `package.json5` that names an old package: the tool does not read JSON5, so rename the
|
|
@@ -165,9 +195,14 @@ The report lists each of these with the file and line:
|
|
|
165
195
|
`overrides` or `resolutions` (see
|
|
166
196
|
[Libraries built on openapi-fetch](https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/fetch/index.md#libraries-built-on-openapi-fetch));
|
|
167
197
|
- `transform` callbacks it cannot rewrite (also when their options use a type built from
|
|
168
|
-
`OpenAPITSOptions`, such as `Partial<OpenAPITSOptions
|
|
198
|
+
`OpenAPITSOptions`, such as `Partial<OpenAPITSOptions>`, or when the type declared for them
|
|
199
|
+
names another type, such as a local alias), and `postTransform` /
|
|
169
200
|
`transformProperty`, also in options that other code shares, and `openapiTS()` calls whose options it cannot see (a
|
|
170
|
-
parameter, a function call)
|
|
201
|
+
parameter, a function call). Options that take keys from another object (`{ ...base }`) are read
|
|
202
|
+
through it when the file writes it (`...{ … }` or a `const` with an object), so its callbacks are
|
|
203
|
+
reported and a `transform` in it is kept; a spread of anything else (an import, a call, a `let`)
|
|
204
|
+
is reported, since it may bring callbacks the tool cannot see. They keep working with a
|
|
205
|
+
deprecation warning; see
|
|
171
206
|
[IR callbacks](https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/node.md#ir-callbacks).
|
|
172
207
|
|
|
173
208
|
Then install, regenerate your types and commit them once (the file header names openapi-typesafe
|
|
@@ -187,7 +222,8 @@ The default log folder is new for each run and only you can open it (mode 0700).
|
|
|
187
222
|
that exists gets the new lines appended, and missing parent folders are created.
|
|
188
223
|
|
|
189
224
|
Exit codes: `0` done, `1` the migration failed (the message and the log say why), a file could not
|
|
190
|
-
be written (the report names what was written), the
|
|
225
|
+
be written (the report names what was written), a bug of the tool left a file as it was (the report
|
|
226
|
+
lists it under "Skipped"), the project folder does not exist or is a file,
|
|
191
227
|
or the log could not be created (nothing is changed then), `2` unknown option or argument.
|
|
192
228
|
|
|
193
229
|
## Versioning
|