ts-codemod-lib 2.2.5 → 3.0.0
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/README.md +15 -54
- package/package.json +63 -109
- package/dist/cmd/append-as-const.d.mts +0 -3
- package/dist/cmd/append-as-const.d.mts.map +0 -1
- package/dist/cmd/append-as-const.mjs +0 -63
- package/dist/cmd/append-as-const.mjs.map +0 -1
- package/dist/cmd/convert-interface-to-type.d.mts +0 -3
- package/dist/cmd/convert-interface-to-type.d.mts.map +0 -1
- package/dist/cmd/convert-interface-to-type.mjs +0 -63
- package/dist/cmd/convert-interface-to-type.mjs.map +0 -1
- package/dist/cmd/convert-to-readonly.d.mts +0 -3
- package/dist/cmd/convert-to-readonly.d.mts.map +0 -1
- package/dist/cmd/convert-to-readonly.mjs +0 -63
- package/dist/cmd/convert-to-readonly.mjs.map +0 -1
- package/dist/cmd/replace-any-with-unknown.d.mts +0 -3
- package/dist/cmd/replace-any-with-unknown.d.mts.map +0 -1
- package/dist/cmd/replace-any-with-unknown.mjs +0 -63
- package/dist/cmd/replace-any-with-unknown.mjs.map +0 -1
- package/dist/cmd/replace-record-with-unknown-record.d.mts +0 -3
- package/dist/cmd/replace-record-with-unknown-record.d.mts.map +0 -1
- package/dist/cmd/replace-record-with-unknown-record.mjs +0 -63
- package/dist/cmd/replace-record-with-unknown-record.mjs.map +0 -1
- package/dist/cmd/run-transformer-cli.d.mts +0 -13
- package/dist/cmd/run-transformer-cli.d.mts.map +0 -1
- package/dist/cmd/run-transformer-cli.mjs +0 -176
- package/dist/cmd/run-transformer-cli.mjs.map +0 -1
- package/src/cmd/append-as-const.mts +0 -67
- package/src/cmd/convert-interface-to-type.mts +0 -67
- package/src/cmd/convert-to-readonly.mts +0 -67
- package/src/cmd/replace-any-with-unknown.mts +0 -67
- package/src/cmd/replace-record-with-unknown-record.mts +0 -67
- package/src/cmd/run-transformer-cli.mts +0 -307
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/ts-codemod-lib)
|
|
4
4
|
[](https://www.npmjs.com/package/ts-codemod-lib)
|
|
5
|
-
[](
|
|
6
|
-
[](https://github.com/noshiro-pf/mono/blob/main/libs/ts-codemod-lib/LICENSE)
|
|
6
|
+
[](https://codecov.io/gh/noshiro-pf/mono)
|
|
7
7
|
|
|
8
8
|
A TypeScript library for code transformations using AST (Abstract Syntax Tree) transformers, powered by the [ts-morph](https://github.com/dsherret/ts-morph).
|
|
9
9
|
|
|
@@ -15,7 +15,6 @@ A TypeScript library for code transformations using AST (Abstract Syntax Tree) t
|
|
|
15
15
|
|
|
16
16
|
- **AST-based Transformations**: Leverage TypeScript Compiler API for reliable type-aware code transformations
|
|
17
17
|
- **Ready-to-use Transformers**: Append `as const`, convert to readonly types, replace `any` with `unknown`, and more
|
|
18
|
-
- **Ready-to-use CLI Tools**: Convert interfaces to types, add readonly modifiers, and more
|
|
19
18
|
- **Extensible API**: Build custom transformers using the provided utilities
|
|
20
19
|
- **Type-safe**: Written in TypeScript with strict type checking
|
|
21
20
|
- **Selective Transformation**: Support for ignoring specific lines or entire files via comments
|
|
@@ -33,10 +32,10 @@ pnpm add ts-codemod-lib
|
|
|
33
32
|
yarn add ts-codemod-lib
|
|
34
33
|
```
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
The command line tools live in a separate package:
|
|
37
36
|
|
|
38
37
|
```bash
|
|
39
|
-
npm add -D ts-codemod-
|
|
38
|
+
npm add -D ts-codemod-cli
|
|
40
39
|
```
|
|
41
40
|
|
|
42
41
|
## Available Transformers
|
|
@@ -99,7 +98,7 @@ type User2 = Readonly<{
|
|
|
99
98
|
}>;
|
|
100
99
|
```
|
|
101
100
|
|
|
102
|
-
For more detailed transformation examples, see the [test file](
|
|
101
|
+
For more detailed transformation examples, see the [test file](https://github.com/noshiro-pf/mono/blob/main/libs/ts-codemod-lib/src/functions/ast-transformers/convert-to-readonly.test.mts) which covers various scenarios including complex types, nested structures, and DeepReadonly transformations.
|
|
103
102
|
|
|
104
103
|
### 3. `convertInterfaceToTypeTransformer`
|
|
105
104
|
|
|
@@ -141,7 +140,7 @@ const sortValues2 = (...args: readonly unknown[]): unknown =>
|
|
|
141
140
|
(args as any).toSorted((a: any, b: any) => a - b);
|
|
142
141
|
```
|
|
143
142
|
|
|
144
|
-
For more detailed transformation examples, see the [test file](
|
|
143
|
+
For more detailed transformation examples, see the [test file](https://github.com/noshiro-pf/mono/blob/main/libs/ts-codemod-lib/src/functions/ast-transformers/replace-any-with-unknown.test.mts) which covers various scenarios including function parameters, return types, and variable declarations.
|
|
145
144
|
|
|
146
145
|
### 5. `replaceRecordWithUnknownRecordTransformer`
|
|
147
146
|
|
|
@@ -209,57 +208,19 @@ type Data2 = { value: any };
|
|
|
209
208
|
const items2 = [1, 2, 3];
|
|
210
209
|
```
|
|
211
210
|
|
|
212
|
-
##
|
|
211
|
+
## Command Line Tools
|
|
213
212
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
### append-as-const
|
|
217
|
-
|
|
218
|
-
Appends `as const` to array literals and object literals to make them readonly constants.
|
|
219
|
-
|
|
220
|
-
```bash
|
|
221
|
-
npx append-as-const <baseDir> [--exclude <pattern>] [--uncommitted] [--diff-from <base>] [--silent]
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### convert-interface-to-type
|
|
225
|
-
|
|
226
|
-
Converts TypeScript interface declarations to type aliases.
|
|
227
|
-
|
|
228
|
-
```bash
|
|
229
|
-
npx convert-interface-to-type <baseDir> [--exclude <pattern>] [--uncommitted] [--diff-from <base>] [--silent]
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### convert-to-readonly
|
|
233
|
-
|
|
234
|
-
Adds `readonly` modifiers to type definitions throughout your codebase.
|
|
213
|
+
The transformers are also available as commands, published separately as
|
|
214
|
+
[`ts-codemod-cli`](https://www.npmjs.com/package/ts-codemod-cli):
|
|
235
215
|
|
|
236
216
|
```bash
|
|
237
|
-
|
|
217
|
+
npm add -D ts-codemod-cli
|
|
218
|
+
npx convert-to-readonly 'src/**/*.mts'
|
|
238
219
|
```
|
|
239
220
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
```bash
|
|
245
|
-
npx replace-any-with-unknown <baseDir> [--exclude <pattern>] [--uncommitted] [--diff-from <base>] [--silent]
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
### replace-record-with-unknown-record
|
|
249
|
-
|
|
250
|
-
Replaces `Record<string, unknown>` with `UnknownRecord` for better type safety.
|
|
251
|
-
|
|
252
|
-
```bash
|
|
253
|
-
npx replace-record-with-unknown-record <baseDir> [--exclude <pattern>] [--uncommitted] [--diff-from <base>] [--silent]
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
**Common Options:**
|
|
257
|
-
|
|
258
|
-
- `baseDir`: Base directory to scan for TypeScript files
|
|
259
|
-
- `--exclude`: Glob patterns to exclude (e.g., `"src/generated/**/*.mts"`)
|
|
260
|
-
- `--uncommitted`: Transform only uncommitted files (untracked, modified, and staged), intersected with `baseDir`
|
|
261
|
-
- `--diff-from <base>`: Transform only files that differ from the given base branch or commit hash (e.g., `origin/main`), intersected with `baseDir`
|
|
262
|
-
- `--silent`: Suppress output messages
|
|
221
|
+
They are in their own package because they need `cmd-ts`, `dedent` and
|
|
222
|
+
`ts-repo-utils` — dependencies this library does not otherwise carry. See that
|
|
223
|
+
package's README for the full command list and options.
|
|
263
224
|
|
|
264
225
|
## Programmatic Usage
|
|
265
226
|
|
|
@@ -447,7 +408,7 @@ node codemod.mjs
|
|
|
447
408
|
### Local Setup
|
|
448
409
|
|
|
449
410
|
```sh
|
|
450
|
-
git clone https://github.com/noshiro-pf/
|
|
411
|
+
git clone https://github.com/noshiro-pf/mono.git
|
|
451
412
|
pnpm i
|
|
452
413
|
```
|
|
453
414
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-codemod-lib",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -11,13 +11,11 @@
|
|
|
11
11
|
],
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/noshiro-pf/
|
|
14
|
+
"url": "git+https://github.com/noshiro-pf/mono.git",
|
|
15
|
+
"directory": "libs/ts-codemod-lib"
|
|
15
16
|
},
|
|
16
17
|
"license": "Apache-2.0",
|
|
17
18
|
"author": "noshiro-pf <noshiro.pf@gmail.com>",
|
|
18
|
-
"sideEffects": [
|
|
19
|
-
"./dist/cmd/*.mjs"
|
|
20
|
-
],
|
|
21
19
|
"type": "module",
|
|
22
20
|
"exports": {
|
|
23
21
|
".": {
|
|
@@ -33,110 +31,29 @@
|
|
|
33
31
|
},
|
|
34
32
|
"module": "./dist/entry-point.mjs",
|
|
35
33
|
"types": "./dist/types.d.mts",
|
|
36
|
-
"bin": {
|
|
37
|
-
"append-as-const": "./dist/cmd/append-as-const.mjs",
|
|
38
|
-
"convert-interface-to-type": "./dist/cmd/convert-interface-to-type.mjs",
|
|
39
|
-
"convert-to-readonly": "./dist/cmd/convert-to-readonly.mjs",
|
|
40
|
-
"replace-any-with-unknown": "./dist/cmd/replace-any-with-unknown.mjs",
|
|
41
|
-
"replace-record-with-unknown-record": "./dist/cmd/replace-record-with-unknown-record.mjs"
|
|
42
|
-
},
|
|
43
34
|
"files": [
|
|
44
35
|
"src",
|
|
45
36
|
"dist",
|
|
46
37
|
"README.md",
|
|
47
38
|
"LICENSE"
|
|
48
39
|
],
|
|
49
|
-
"scripts": {
|
|
50
|
-
"agents:gen": "tsx ./scripts/cmd/gen-agents-md.mts",
|
|
51
|
-
"agents:sync": "tsx ./scripts/cmd/sync-agent-config.mts",
|
|
52
|
-
"build": "tsx ./scripts/cmd/build.mts",
|
|
53
|
-
"build:min": "tsx ./scripts/cmd/build.mts --skip-check",
|
|
54
|
-
"check-all": "tsx ./scripts/cmd/check-all.mts",
|
|
55
|
-
"check:ext": "tsx ./scripts/cmd/check-ext.mts",
|
|
56
|
-
"clean": "pnpm run /clean:.*/",
|
|
57
|
-
"clean:logs": "npx rimraf ./*.log",
|
|
58
|
-
"codemod": "run-s codemod:uncommitted:* fmt",
|
|
59
|
-
"codemod:diff": "run-s codemod:diff:* fmt",
|
|
60
|
-
"codemod:diff:any-to-unknown": "tsx ./src/cmd/replace-any-with-unknown.mts --diff-from origin/main '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
61
|
-
"codemod:diff:as-const": "tsx ./src/cmd/append-as-const.mts --diff-from origin/main '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
62
|
-
"codemod:diff:interface-to-type": "tsx ./src/cmd/convert-interface-to-type.mts --diff-from origin/main '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
63
|
-
"codemod:diff:readonly": "tsx ./src/cmd/convert-to-readonly.mts --diff-from origin/main '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
64
|
-
"codemod:diff:unknown-record": "tsx ./src/cmd/replace-record-with-unknown-record.mts --diff-from origin/main '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
65
|
-
"codemod:full": "run-s codemod:full:* fmt",
|
|
66
|
-
"codemod:full:any-to-unknown": "tsx ./src/cmd/replace-any-with-unknown.mts '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
67
|
-
"codemod:full:as-const": "tsx ./src/cmd/append-as-const.mts '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
68
|
-
"codemod:full:interface-to-type": "tsx ./src/cmd/convert-interface-to-type.mts '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
69
|
-
"codemod:full:readonly": "tsx ./src/cmd/convert-to-readonly.mts '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
70
|
-
"codemod:full:unknown-record": "tsx ./src/cmd/replace-record-with-unknown-record.mts '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
71
|
-
"codemod:uncommitted:any-to-unknown": "tsx ./src/cmd/replace-any-with-unknown.mts --uncommitted '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
72
|
-
"codemod:uncommitted:as-const": "tsx ./src/cmd/append-as-const.mts --uncommitted '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
73
|
-
"codemod:uncommitted:interface-to-type": "tsx ./src/cmd/convert-interface-to-type.mts --uncommitted '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
74
|
-
"codemod:uncommitted:readonly": "tsx ./src/cmd/convert-to-readonly.mts --uncommitted '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
75
|
-
"codemod:uncommitted:unknown-record": "tsx ./src/cmd/replace-record-with-unknown-record.mts --uncommitted '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
76
|
-
"cspell": "cspell \"{**,.changeset/**/*,.github/**/*}\" --gitignore --gitignore-root ./ --no-progress",
|
|
77
|
-
"doc": "tsx ./scripts/cmd/gen-docs.mts",
|
|
78
|
-
"doc:embed": "tsx ./scripts/cmd/embed-examples.mts",
|
|
79
|
-
"doc:preview": "vite preview --config ./configs/vite.doc.config.mts",
|
|
80
|
-
"doc:watch": "typedoc --options ./configs/typedoc.config.mjs --watch",
|
|
81
|
-
"fmt": "format-uncommitted",
|
|
82
|
-
"fmt:diff": "format-diff-from origin/main",
|
|
83
|
-
"fmt:full": "prettier --write .",
|
|
84
|
-
"gi": "run-s gi:src fmt",
|
|
85
|
-
"gi:src": "gen-index-ts ./src --index-ext .mts --export-ext .mjs --target-ext .mts --target-ext .tsx --exclude entry-point.mts --exclude cmd",
|
|
86
|
-
"lint": "eslint .",
|
|
87
|
-
"lint:fix": "eslint . --fix",
|
|
88
|
-
"md": "markdownlint-cli2",
|
|
89
|
-
"prepare-release": "run-s sync-cli-versions fmt build doc",
|
|
90
|
-
"repo-settings:apply": "repo-settings apply",
|
|
91
|
-
"repo-settings:backup": "repo-settings backup",
|
|
92
|
-
"run:cmd": "tsx ./src/cmd/convert-to-readonly.mts ./test/sample1.mts",
|
|
93
|
-
"run:test": "tsx ./scripts/test-code/transform-test-code.mts",
|
|
94
|
-
"sync-cli-versions": "tsx scripts/cmd/sync-cli-versions.mts",
|
|
95
|
-
"test": "pnpm run z:vitest:node run",
|
|
96
|
-
"test:browser": "pnpm run z:vitest --project='Browser' run",
|
|
97
|
-
"test:cov": "pnpm run z:vitest:node run --coverage",
|
|
98
|
-
"test:cov:ui": "vite preview --outDir ./coverage",
|
|
99
|
-
"test:ui": "pnpm run z:vitest:node --ui",
|
|
100
|
-
"testw": "pnpm run z:vitest:node watch",
|
|
101
|
-
"tsc": "node ./node_modules/typescript-native/bin/tsc --noEmit",
|
|
102
|
-
"tscw": "node ./node_modules/typescript-native/bin/tsc --noEmit --watch -p ./tsconfig.json",
|
|
103
|
-
"type-check": "node ./node_modules/typescript-native/bin/tsc --noEmit",
|
|
104
|
-
"z:vitest": "vitest --config ./configs/vitest.config.mts",
|
|
105
|
-
"z:vitest:node": "pnpm run z:vitest --project='Node.js'"
|
|
106
|
-
},
|
|
107
40
|
"dependencies": {
|
|
108
|
-
"ts-data-forge": "^14.1.0",
|
|
109
41
|
"ts-morph": "^28.0.0",
|
|
110
|
-
"ts-
|
|
42
|
+
"ts-data-forge": "^14.2.1",
|
|
43
|
+
"ts-type-forge": "^9.2.1"
|
|
111
44
|
},
|
|
112
45
|
"devDependencies": {
|
|
113
46
|
"@rollup/plugin-replace": "6.0.3",
|
|
114
47
|
"@rollup/plugin-strip": "3.0.4",
|
|
115
|
-
"@semantic-release/changelog": "7.0.0",
|
|
116
|
-
"@semantic-release/commit-analyzer": "13.0.1",
|
|
117
|
-
"@semantic-release/exec": "7.1.0",
|
|
118
|
-
"@semantic-release/git": "11.0.1",
|
|
119
|
-
"@semantic-release/github": "12.0.9",
|
|
120
|
-
"@semantic-release/npm": "13.1.5",
|
|
121
|
-
"@semantic-release/release-notes-generator": "14.1.1",
|
|
122
48
|
"@types/node": "26.2.0",
|
|
123
49
|
"@vitest/browser-playwright": "4.1.10",
|
|
124
50
|
"@vitest/coverage-v8": "4.1.10",
|
|
125
51
|
"@vitest/ui": "4.1.10",
|
|
126
|
-
"cmd-ts": "0.15.0",
|
|
127
|
-
"conventional-changelog-conventionalcommits": "10.2.1",
|
|
128
52
|
"cspell": "10.0.1",
|
|
129
53
|
"dedent": "1.7.2",
|
|
130
54
|
"esbuild": "0.28.1",
|
|
131
55
|
"eslint": "10.8.0",
|
|
132
|
-
"eslint-config-typed": "5.8.4",
|
|
133
|
-
"eslint-plugin-ts-data-forge": "0.4.2",
|
|
134
|
-
"eslint-plugin-ts-fortress": "1.0.0",
|
|
135
|
-
"eslint-plugin-ts-type-forge": "0.6.1",
|
|
136
|
-
"github-settings-as-code": "2.1.0",
|
|
137
56
|
"jiti": "2.7.0",
|
|
138
|
-
"markdownlint": "0.41.1",
|
|
139
|
-
"markdownlint-cli2": "0.23.2",
|
|
140
57
|
"npm-run-all2": "9.0.3",
|
|
141
58
|
"playwright": "1.62.1",
|
|
142
59
|
"prettier": "3.9.6",
|
|
@@ -144,33 +61,19 @@
|
|
|
144
61
|
"prettier-plugin-packagejson": "3.0.2",
|
|
145
62
|
"rollup": "4.62.4",
|
|
146
63
|
"rollup-plugin-esbuild": "6.2.1",
|
|
147
|
-
"semantic-release": "25.0.8",
|
|
148
|
-
"ts-repo-utils": "10.1.7",
|
|
149
64
|
"tsx": "4.23.4",
|
|
150
65
|
"typedoc": "0.28.20",
|
|
151
66
|
"typedoc-github-theme": "0.4.0",
|
|
152
67
|
"typescript": "6.0.3",
|
|
153
68
|
"typescript-native": "npm:typescript@7.0.2",
|
|
154
69
|
"vite": "8.2.0",
|
|
155
|
-
"vitest": "4.1.10"
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
"
|
|
159
|
-
"
|
|
160
|
-
"ts-repo-utils": "
|
|
161
|
-
},
|
|
162
|
-
"peerDependenciesMeta": {
|
|
163
|
-
"cmd-ts": {
|
|
164
|
-
"optional": true
|
|
165
|
-
},
|
|
166
|
-
"dedent": {
|
|
167
|
-
"optional": true
|
|
168
|
-
},
|
|
169
|
-
"ts-repo-utils": {
|
|
170
|
-
"optional": true
|
|
171
|
-
}
|
|
70
|
+
"vitest": "4.1.10",
|
|
71
|
+
"eslint-config-typed": "5.8.5",
|
|
72
|
+
"eslint-plugin-ts-data-forge": "0.4.4",
|
|
73
|
+
"eslint-plugin-ts-fortress": "1.0.1",
|
|
74
|
+
"eslint-plugin-ts-type-forge": "0.6.3",
|
|
75
|
+
"ts-repo-utils": "10.2.0"
|
|
172
76
|
},
|
|
173
|
-
"packageManager": "pnpm@11.20.0",
|
|
174
77
|
"engines": {
|
|
175
78
|
"node": ">=22.22.2",
|
|
176
79
|
"pnpm": ">=9.0.0"
|
|
@@ -181,5 +84,56 @@
|
|
|
181
84
|
"publishConfig": {
|
|
182
85
|
"access": "public",
|
|
183
86
|
"provenance": true
|
|
87
|
+
},
|
|
88
|
+
"scripts": {
|
|
89
|
+
"build": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/build.mts",
|
|
90
|
+
"build:min": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/build.mts --skip-check",
|
|
91
|
+
"check-all": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/check-all.mts",
|
|
92
|
+
"check:ext": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/check-ext.mts",
|
|
93
|
+
"clean": "pnpm run /clean:.*/",
|
|
94
|
+
"clean:logs": "npx rimraf ./*.log",
|
|
95
|
+
"codemod": "run-s codemod:uncommitted:* fmt",
|
|
96
|
+
"codemod:diff": "run-s codemod:diff:* fmt",
|
|
97
|
+
"codemod:diff:any-to-unknown": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/replace-any-with-unknown.mts --diff-from origin/main '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
98
|
+
"codemod:diff:as-const": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/append-as-const.mts --diff-from origin/main '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
99
|
+
"codemod:diff:interface-to-type": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/convert-interface-to-type.mts --diff-from origin/main '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
100
|
+
"codemod:diff:readonly": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/convert-to-readonly.mts --diff-from origin/main '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
101
|
+
"codemod:diff:unknown-record": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/replace-record-with-unknown-record.mts --diff-from origin/main '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
102
|
+
"codemod:full": "run-s codemod:full:* fmt",
|
|
103
|
+
"codemod:full:any-to-unknown": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/replace-any-with-unknown.mts '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
104
|
+
"codemod:full:as-const": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/append-as-const.mts '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
105
|
+
"codemod:full:interface-to-type": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/convert-interface-to-type.mts '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
106
|
+
"codemod:full:readonly": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/convert-to-readonly.mts '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
107
|
+
"codemod:full:unknown-record": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/replace-record-with-unknown-record.mts '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
108
|
+
"codemod:uncommitted:any-to-unknown": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/replace-any-with-unknown.mts --uncommitted '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
109
|
+
"codemod:uncommitted:as-const": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/append-as-const.mts --uncommitted '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
110
|
+
"codemod:uncommitted:interface-to-type": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/convert-interface-to-type.mts --uncommitted '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
111
|
+
"codemod:uncommitted:readonly": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/convert-to-readonly.mts --uncommitted '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
112
|
+
"codemod:uncommitted:unknown-record": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../ts-codemod-cli/src/cmd/replace-record-with-unknown-record.mts --uncommitted '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
113
|
+
"cspell": "cspell \"**\" --gitignore --gitignore-root ../../ --no-progress",
|
|
114
|
+
"doc": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/gen-docs.mts",
|
|
115
|
+
"doc:embed": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/embed-examples.mts",
|
|
116
|
+
"doc:preview": "vite preview --config ./configs/vite.doc.config.mts",
|
|
117
|
+
"doc:watch": "typedoc --options ./configs/typedoc.config.mjs --watch",
|
|
118
|
+
"fmt": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../../libs/ts-repo-utils/src/cmd/format-uncommitted.mts --cwd .",
|
|
119
|
+
"fmt:diff": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../../libs/ts-repo-utils/src/cmd/format-diff-from.mts origin/main --cwd .",
|
|
120
|
+
"fmt:full": "prettier --write .",
|
|
121
|
+
"gi": "run-s gi:src fmt",
|
|
122
|
+
"gi:src": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../../libs/ts-repo-utils/src/cmd/gen-index-ts.mts ./src --index-ext .mts --export-ext .mjs --target-ext .mts --target-ext .tsx --exclude entry-point.mts",
|
|
123
|
+
"lint": "eslint .",
|
|
124
|
+
"lint:fix": "eslint . --fix",
|
|
125
|
+
"prepare-release": "run-s fmt build doc",
|
|
126
|
+
"run:test": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/test-code/transform-test-code.mts",
|
|
127
|
+
"test": "pnpm run z:vitest:node run",
|
|
128
|
+
"test:browser": "pnpm run z:vitest --project='Browser' run",
|
|
129
|
+
"test:cov": "pnpm run z:vitest:node run --coverage",
|
|
130
|
+
"test:cov:ui": "vite preview --outDir ./coverage",
|
|
131
|
+
"test:ui": "pnpm run z:vitest:node --ui",
|
|
132
|
+
"testw": "pnpm run z:vitest:node watch",
|
|
133
|
+
"tsc": "node ../../node_modules/typescript-native/bin/tsc --noEmit",
|
|
134
|
+
"tscw": "node ../../node_modules/typescript-native/bin/tsc --noEmit --watch -p ./tsconfig.json",
|
|
135
|
+
"type-check": "node ../../node_modules/typescript-native/bin/tsc --noEmit",
|
|
136
|
+
"z:vitest": "vitest --config ./configs/vitest.config.mts",
|
|
137
|
+
"z:vitest:node": "pnpm run z:vitest --project='Node.js'"
|
|
184
138
|
}
|
|
185
|
-
}
|
|
139
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"append-as-const.d.mts","sourceRoot":"","sources":["../../src/cmd/append-as-const.mts"],"names":[],"mappings":""}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import * as cmd from 'cmd-ts';
|
|
3
|
-
import { Result, Arr } from 'ts-data-forge';
|
|
4
|
-
import { appendAsConstTransformer } from '../functions/ast-transformers/append-as-const.mjs';
|
|
5
|
-
import 'ts-morph';
|
|
6
|
-
import '../functions/functions/is-atomic-type-node.mjs';
|
|
7
|
-
import '../functions/ast-transformers/readonly-transformer-helpers/constants.mjs';
|
|
8
|
-
import { runTransformerCLI } from './run-transformer-cli.mjs';
|
|
9
|
-
|
|
10
|
-
const transformer = appendAsConstTransformer();
|
|
11
|
-
const cmdDef = cmd.command({
|
|
12
|
-
name: transformer.name,
|
|
13
|
-
version: "2.2.5",
|
|
14
|
-
args: {
|
|
15
|
-
baseDir: cmd.positional({
|
|
16
|
-
type: cmd.string,
|
|
17
|
-
displayName: "baseDir",
|
|
18
|
-
description: "The base directory in which to perform the conversion"
|
|
19
|
-
}),
|
|
20
|
-
exclude: cmd.multioption({
|
|
21
|
-
long: "exclude",
|
|
22
|
-
type: cmd.optional(cmd.array(cmd.string)),
|
|
23
|
-
description: 'Glob patterns of files to exclude from the base directory (e.g., "src/generated/**/*.mts")'
|
|
24
|
-
}),
|
|
25
|
-
uncommitted: cmd.flag({
|
|
26
|
-
long: "uncommitted",
|
|
27
|
-
type: cmd.optional(cmd.boolean),
|
|
28
|
-
description: "If true, transforms only uncommitted files (untracked, modified, and staged files)"
|
|
29
|
-
}),
|
|
30
|
-
diffFrom: cmd.option({
|
|
31
|
-
long: "diff-from",
|
|
32
|
-
type: cmd.optional(cmd.string),
|
|
33
|
-
description: "If provided, transforms only files that differ from the given base branch or commit hash"
|
|
34
|
-
}),
|
|
35
|
-
silent: cmd.flag({
|
|
36
|
-
long: "silent",
|
|
37
|
-
type: cmd.optional(cmd.boolean),
|
|
38
|
-
description: "If true, suppresses output messages (default: false)"
|
|
39
|
-
})
|
|
40
|
-
},
|
|
41
|
-
handler: (args) => {
|
|
42
|
-
(async () => {
|
|
43
|
-
const result = await runTransformerCLI(
|
|
44
|
-
{
|
|
45
|
-
baseDir: args.baseDir,
|
|
46
|
-
exclude: args.exclude ?? [],
|
|
47
|
-
uncommitted: args.uncommitted ?? false,
|
|
48
|
-
diffFrom: args.diffFrom,
|
|
49
|
-
silent: args.silent ?? false
|
|
50
|
-
},
|
|
51
|
-
[transformer]
|
|
52
|
-
);
|
|
53
|
-
if (Result.isErr(result)) {
|
|
54
|
-
process.exit(1);
|
|
55
|
-
}
|
|
56
|
-
})().catch((error) => {
|
|
57
|
-
console.error("An error occurred:", error);
|
|
58
|
-
process.exit(1);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
await cmd.run(cmdDef, Arr.skip(process.argv, 2));
|
|
63
|
-
//# sourceMappingURL=append-as-const.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"append-as-const.mjs","sources":["../../src/cmd/append-as-const.mts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as cmd from 'cmd-ts';\nimport { Arr, Result } from 'ts-data-forge';\nimport { appendAsConstTransformer } from '../functions/index.mjs';\nimport { runTransformerCLI } from './run-transformer-cli.mjs';\n\nconst transformer = appendAsConstTransformer();\n\nconst cmdDef = cmd.command({\n name: transformer.name,\n version: '2.2.5',\n args: {\n baseDir: cmd.positional({\n type: cmd.string,\n displayName: 'baseDir',\n description: 'The base directory in which to perform the conversion',\n }),\n exclude: cmd.multioption({\n long: 'exclude',\n type: cmd.optional(cmd.array(cmd.string)),\n description:\n 'Glob patterns of files to exclude from the base directory (e.g., \"src/generated/**/*.mts\")',\n }),\n uncommitted: cmd.flag({\n long: 'uncommitted',\n type: cmd.optional(cmd.boolean),\n description:\n 'If true, transforms only uncommitted files (untracked, modified, and staged files)',\n }),\n diffFrom: cmd.option({\n long: 'diff-from',\n type: cmd.optional(cmd.string),\n description:\n 'If provided, transforms only files that differ from the given base branch or commit hash',\n }),\n silent: cmd.flag({\n long: 'silent',\n type: cmd.optional(cmd.boolean),\n description: 'If true, suppresses output messages (default: false)',\n }),\n },\n handler: (args) => {\n (async (): Promise<void> => {\n const result = await runTransformerCLI(\n {\n baseDir: args.baseDir,\n exclude: args.exclude ?? [],\n uncommitted: args.uncommitted ?? false,\n diffFrom: args.diffFrom,\n silent: args.silent ?? false,\n },\n [transformer],\n );\n\n if (Result.isErr(result)) {\n process.exit(1);\n }\n })().catch((error: unknown) => {\n console.error('An error occurred:', error);\n\n process.exit(1);\n });\n },\n});\n\nawait cmd.run(cmdDef, Arr.skip(process.argv, 2));\n"],"names":[],"mappings":";;;;;;;;;AAOA,MAAM,cAAc,wBAAA,EAAyB;AAE7C,MAAM,MAAA,GAAS,IAAI,OAAA,CAAQ;AAAA,EACzB,MAAM,WAAA,CAAY,IAAA;AAAA,EAClB,OAAA,EAAS,OAAA;AAAA,EACT,IAAA,EAAM;AAAA,IACJ,OAAA,EAAS,IAAI,UAAA,CAAW;AAAA,MACtB,MAAM,GAAA,CAAI,MAAA;AAAA,MACV,WAAA,EAAa,SAAA;AAAA,MACb,WAAA,EAAa;AAAA,KACd,CAAA;AAAA,IACD,OAAA,EAAS,IAAI,WAAA,CAAY;AAAA,MACvB,IAAA,EAAM,SAAA;AAAA,MACN,MAAM,GAAA,CAAI,QAAA,CAAS,IAAI,KAAA,CAAM,GAAA,CAAI,MAAM,CAAC,CAAA;AAAA,MACxC,WAAA,EACE;AAAA,KACH,CAAA;AAAA,IACD,WAAA,EAAa,IAAI,IAAA,CAAK;AAAA,MACpB,IAAA,EAAM,aAAA;AAAA,MACN,IAAA,EAAM,GAAA,CAAI,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAAA,MAC9B,WAAA,EACE;AAAA,KACH,CAAA;AAAA,IACD,QAAA,EAAU,IAAI,MAAA,CAAO;AAAA,MACnB,IAAA,EAAM,WAAA;AAAA,MACN,IAAA,EAAM,GAAA,CAAI,QAAA,CAAS,GAAA,CAAI,MAAM,CAAA;AAAA,MAC7B,WAAA,EACE;AAAA,KACH,CAAA;AAAA,IACD,MAAA,EAAQ,IAAI,IAAA,CAAK;AAAA,MACf,IAAA,EAAM,QAAA;AAAA,MACN,IAAA,EAAM,GAAA,CAAI,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAAA,MAC9B,WAAA,EAAa;AAAA,KACd;AAAA,GACH;AAAA,EACA,OAAA,EAAS,CAAC,IAAA,KAAS;AACjB,IAAA,CAAC,YAA2B;AAC1B,MAAA,MAAM,SAAS,MAAM,iBAAA;AAAA,QACnB;AAAA,UACE,SAAS,IAAA,CAAK,OAAA;AAAA,UACd,OAAA,EAAS,IAAA,CAAK,OAAA,IAAW,EAAC;AAAA,UAC1B,WAAA,EAAa,KAAK,WAAA,IAAe,KAAA;AAAA,UACjC,UAAU,IAAA,CAAK,QAAA;AAAA,UACf,MAAA,EAAQ,KAAK,MAAA,IAAU;AAAA,SACzB;AAAA,QACA,CAAC,WAAW;AAAA,OACd;AAEA,MAAA,IAAI,MAAA,CAAO,KAAA,CAAM,MAAM,CAAA,EAAG;AACxB,QAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,MAChB;AAAA,IACF,CAAA,GAAG,CAAE,KAAA,CAAM,CAAC,KAAA,KAAmB;AAC7B,MAAA,OAAA,CAAQ,KAAA,CAAM,sBAAsB,KAAK,CAAA;AAEzC,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB,CAAC,CAAA;AAAA,EACH;AACF,CAAC,CAAA;AAED,MAAM,GAAA,CAAI,IAAI,MAAA,EAAQ,GAAA,CAAI,KAAK,OAAA,CAAQ,IAAA,EAAM,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-interface-to-type.d.mts","sourceRoot":"","sources":["../../src/cmd/convert-interface-to-type.mts"],"names":[],"mappings":""}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import * as cmd from 'cmd-ts';
|
|
3
|
-
import { Result, Arr } from 'ts-data-forge';
|
|
4
|
-
import 'ts-morph';
|
|
5
|
-
import '../functions/functions/is-atomic-type-node.mjs';
|
|
6
|
-
import { convertInterfaceToTypeTransformer } from '../functions/ast-transformers/convert-interface-to-type.mjs';
|
|
7
|
-
import '../functions/ast-transformers/readonly-transformer-helpers/constants.mjs';
|
|
8
|
-
import { runTransformerCLI } from './run-transformer-cli.mjs';
|
|
9
|
-
|
|
10
|
-
const transformer = convertInterfaceToTypeTransformer();
|
|
11
|
-
const cmdDef = cmd.command({
|
|
12
|
-
name: transformer.name,
|
|
13
|
-
version: "2.2.5",
|
|
14
|
-
args: {
|
|
15
|
-
baseDir: cmd.positional({
|
|
16
|
-
type: cmd.string,
|
|
17
|
-
displayName: "baseDir",
|
|
18
|
-
description: "The base directory in which to perform the conversion"
|
|
19
|
-
}),
|
|
20
|
-
exclude: cmd.multioption({
|
|
21
|
-
long: "exclude",
|
|
22
|
-
type: cmd.optional(cmd.array(cmd.string)),
|
|
23
|
-
description: 'Glob patterns of files to exclude from the base directory (e.g., "src/generated/**/*.mts")'
|
|
24
|
-
}),
|
|
25
|
-
uncommitted: cmd.flag({
|
|
26
|
-
long: "uncommitted",
|
|
27
|
-
type: cmd.optional(cmd.boolean),
|
|
28
|
-
description: "If true, transforms only uncommitted files (untracked, modified, and staged files)"
|
|
29
|
-
}),
|
|
30
|
-
diffFrom: cmd.option({
|
|
31
|
-
long: "diff-from",
|
|
32
|
-
type: cmd.optional(cmd.string),
|
|
33
|
-
description: "If provided, transforms only files that differ from the given base branch or commit hash"
|
|
34
|
-
}),
|
|
35
|
-
silent: cmd.flag({
|
|
36
|
-
long: "silent",
|
|
37
|
-
type: cmd.optional(cmd.boolean),
|
|
38
|
-
description: "If true, suppresses output messages (default: false)"
|
|
39
|
-
})
|
|
40
|
-
},
|
|
41
|
-
handler: (args) => {
|
|
42
|
-
(async () => {
|
|
43
|
-
const result = await runTransformerCLI(
|
|
44
|
-
{
|
|
45
|
-
baseDir: args.baseDir,
|
|
46
|
-
exclude: args.exclude ?? [],
|
|
47
|
-
uncommitted: args.uncommitted ?? false,
|
|
48
|
-
diffFrom: args.diffFrom,
|
|
49
|
-
silent: args.silent ?? false
|
|
50
|
-
},
|
|
51
|
-
[transformer]
|
|
52
|
-
);
|
|
53
|
-
if (Result.isErr(result)) {
|
|
54
|
-
process.exit(1);
|
|
55
|
-
}
|
|
56
|
-
})().catch((error) => {
|
|
57
|
-
console.error("An error occurred:", error);
|
|
58
|
-
process.exit(1);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
await cmd.run(cmdDef, Arr.skip(process.argv, 2));
|
|
63
|
-
//# sourceMappingURL=convert-interface-to-type.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-interface-to-type.mjs","sources":["../../src/cmd/convert-interface-to-type.mts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as cmd from 'cmd-ts';\nimport { Arr, Result } from 'ts-data-forge';\nimport { convertInterfaceToTypeTransformer } from '../functions/index.mjs';\nimport { runTransformerCLI } from './run-transformer-cli.mjs';\n\nconst transformer = convertInterfaceToTypeTransformer();\n\nconst cmdDef = cmd.command({\n name: transformer.name,\n version: '2.2.5',\n args: {\n baseDir: cmd.positional({\n type: cmd.string,\n displayName: 'baseDir',\n description: 'The base directory in which to perform the conversion',\n }),\n exclude: cmd.multioption({\n long: 'exclude',\n type: cmd.optional(cmd.array(cmd.string)),\n description:\n 'Glob patterns of files to exclude from the base directory (e.g., \"src/generated/**/*.mts\")',\n }),\n uncommitted: cmd.flag({\n long: 'uncommitted',\n type: cmd.optional(cmd.boolean),\n description:\n 'If true, transforms only uncommitted files (untracked, modified, and staged files)',\n }),\n diffFrom: cmd.option({\n long: 'diff-from',\n type: cmd.optional(cmd.string),\n description:\n 'If provided, transforms only files that differ from the given base branch or commit hash',\n }),\n silent: cmd.flag({\n long: 'silent',\n type: cmd.optional(cmd.boolean),\n description: 'If true, suppresses output messages (default: false)',\n }),\n },\n handler: (args) => {\n (async (): Promise<void> => {\n const result = await runTransformerCLI(\n {\n baseDir: args.baseDir,\n exclude: args.exclude ?? [],\n uncommitted: args.uncommitted ?? false,\n diffFrom: args.diffFrom,\n silent: args.silent ?? false,\n },\n [transformer],\n );\n\n if (Result.isErr(result)) {\n process.exit(1);\n }\n })().catch((error: unknown) => {\n console.error('An error occurred:', error);\n\n process.exit(1);\n });\n },\n});\n\nawait cmd.run(cmdDef, Arr.skip(process.argv, 2));\n"],"names":[],"mappings":";;;;;;;;;AAOA,MAAM,cAAc,iCAAA,EAAkC;AAEtD,MAAM,MAAA,GAAS,IAAI,OAAA,CAAQ;AAAA,EACzB,MAAM,WAAA,CAAY,IAAA;AAAA,EAClB,OAAA,EAAS,OAAA;AAAA,EACT,IAAA,EAAM;AAAA,IACJ,OAAA,EAAS,IAAI,UAAA,CAAW;AAAA,MACtB,MAAM,GAAA,CAAI,MAAA;AAAA,MACV,WAAA,EAAa,SAAA;AAAA,MACb,WAAA,EAAa;AAAA,KACd,CAAA;AAAA,IACD,OAAA,EAAS,IAAI,WAAA,CAAY;AAAA,MACvB,IAAA,EAAM,SAAA;AAAA,MACN,MAAM,GAAA,CAAI,QAAA,CAAS,IAAI,KAAA,CAAM,GAAA,CAAI,MAAM,CAAC,CAAA;AAAA,MACxC,WAAA,EACE;AAAA,KACH,CAAA;AAAA,IACD,WAAA,EAAa,IAAI,IAAA,CAAK;AAAA,MACpB,IAAA,EAAM,aAAA;AAAA,MACN,IAAA,EAAM,GAAA,CAAI,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAAA,MAC9B,WAAA,EACE;AAAA,KACH,CAAA;AAAA,IACD,QAAA,EAAU,IAAI,MAAA,CAAO;AAAA,MACnB,IAAA,EAAM,WAAA;AAAA,MACN,IAAA,EAAM,GAAA,CAAI,QAAA,CAAS,GAAA,CAAI,MAAM,CAAA;AAAA,MAC7B,WAAA,EACE;AAAA,KACH,CAAA;AAAA,IACD,MAAA,EAAQ,IAAI,IAAA,CAAK;AAAA,MACf,IAAA,EAAM,QAAA;AAAA,MACN,IAAA,EAAM,GAAA,CAAI,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAAA,MAC9B,WAAA,EAAa;AAAA,KACd;AAAA,GACH;AAAA,EACA,OAAA,EAAS,CAAC,IAAA,KAAS;AACjB,IAAA,CAAC,YAA2B;AAC1B,MAAA,MAAM,SAAS,MAAM,iBAAA;AAAA,QACnB;AAAA,UACE,SAAS,IAAA,CAAK,OAAA;AAAA,UACd,OAAA,EAAS,IAAA,CAAK,OAAA,IAAW,EAAC;AAAA,UAC1B,WAAA,EAAa,KAAK,WAAA,IAAe,KAAA;AAAA,UACjC,UAAU,IAAA,CAAK,QAAA;AAAA,UACf,MAAA,EAAQ,KAAK,MAAA,IAAU;AAAA,SACzB;AAAA,QACA,CAAC,WAAW;AAAA,OACd;AAEA,MAAA,IAAI,MAAA,CAAO,KAAA,CAAM,MAAM,CAAA,EAAG;AACxB,QAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,MAChB;AAAA,IACF,CAAA,GAAG,CAAE,KAAA,CAAM,CAAC,KAAA,KAAmB;AAC7B,MAAA,OAAA,CAAQ,KAAA,CAAM,sBAAsB,KAAK,CAAA;AAEzC,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB,CAAC,CAAA;AAAA,EACH;AACF,CAAC,CAAA;AAED,MAAM,GAAA,CAAI,IAAI,MAAA,EAAQ,GAAA,CAAI,KAAK,OAAA,CAAQ,IAAA,EAAM,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-to-readonly.d.mts","sourceRoot":"","sources":["../../src/cmd/convert-to-readonly.mts"],"names":[],"mappings":""}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import * as cmd from 'cmd-ts';
|
|
3
|
-
import { Result, Arr } from 'ts-data-forge';
|
|
4
|
-
import 'ts-morph';
|
|
5
|
-
import '../functions/functions/is-atomic-type-node.mjs';
|
|
6
|
-
import { convertToReadonlyTransformer } from '../functions/ast-transformers/convert-to-readonly.mjs';
|
|
7
|
-
import '../functions/ast-transformers/readonly-transformer-helpers/constants.mjs';
|
|
8
|
-
import { runTransformerCLI } from './run-transformer-cli.mjs';
|
|
9
|
-
|
|
10
|
-
const transformer = convertToReadonlyTransformer();
|
|
11
|
-
const cmdDef = cmd.command({
|
|
12
|
-
name: transformer.name,
|
|
13
|
-
version: "2.2.5",
|
|
14
|
-
args: {
|
|
15
|
-
baseDir: cmd.positional({
|
|
16
|
-
type: cmd.string,
|
|
17
|
-
displayName: "baseDir",
|
|
18
|
-
description: "The base directory in which to perform the conversion"
|
|
19
|
-
}),
|
|
20
|
-
exclude: cmd.multioption({
|
|
21
|
-
long: "exclude",
|
|
22
|
-
type: cmd.optional(cmd.array(cmd.string)),
|
|
23
|
-
description: 'Glob patterns of files to exclude from the base directory (e.g., "src/generated/**/*.mts")'
|
|
24
|
-
}),
|
|
25
|
-
uncommitted: cmd.flag({
|
|
26
|
-
long: "uncommitted",
|
|
27
|
-
type: cmd.optional(cmd.boolean),
|
|
28
|
-
description: "If true, transforms only uncommitted files (untracked, modified, and staged files)"
|
|
29
|
-
}),
|
|
30
|
-
diffFrom: cmd.option({
|
|
31
|
-
long: "diff-from",
|
|
32
|
-
type: cmd.optional(cmd.string),
|
|
33
|
-
description: "If provided, transforms only files that differ from the given base branch or commit hash"
|
|
34
|
-
}),
|
|
35
|
-
silent: cmd.flag({
|
|
36
|
-
long: "silent",
|
|
37
|
-
type: cmd.optional(cmd.boolean),
|
|
38
|
-
description: "If true, suppresses output messages (default: false)"
|
|
39
|
-
})
|
|
40
|
-
},
|
|
41
|
-
handler: (args) => {
|
|
42
|
-
(async () => {
|
|
43
|
-
const result = await runTransformerCLI(
|
|
44
|
-
{
|
|
45
|
-
baseDir: args.baseDir,
|
|
46
|
-
exclude: args.exclude ?? [],
|
|
47
|
-
uncommitted: args.uncommitted ?? false,
|
|
48
|
-
diffFrom: args.diffFrom,
|
|
49
|
-
silent: args.silent ?? false
|
|
50
|
-
},
|
|
51
|
-
[transformer]
|
|
52
|
-
);
|
|
53
|
-
if (Result.isErr(result)) {
|
|
54
|
-
process.exit(1);
|
|
55
|
-
}
|
|
56
|
-
})().catch((error) => {
|
|
57
|
-
console.error("An error occurred:", error);
|
|
58
|
-
process.exit(1);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
await cmd.run(cmdDef, Arr.skip(process.argv, 2));
|
|
63
|
-
//# sourceMappingURL=convert-to-readonly.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-to-readonly.mjs","sources":["../../src/cmd/convert-to-readonly.mts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as cmd from 'cmd-ts';\nimport { Arr, Result } from 'ts-data-forge';\nimport { convertToReadonlyTransformer } from '../functions/index.mjs';\nimport { runTransformerCLI } from './run-transformer-cli.mjs';\n\nconst transformer = convertToReadonlyTransformer();\n\nconst cmdDef = cmd.command({\n name: transformer.name,\n version: '2.2.5',\n args: {\n baseDir: cmd.positional({\n type: cmd.string,\n displayName: 'baseDir',\n description: 'The base directory in which to perform the conversion',\n }),\n exclude: cmd.multioption({\n long: 'exclude',\n type: cmd.optional(cmd.array(cmd.string)),\n description:\n 'Glob patterns of files to exclude from the base directory (e.g., \"src/generated/**/*.mts\")',\n }),\n uncommitted: cmd.flag({\n long: 'uncommitted',\n type: cmd.optional(cmd.boolean),\n description:\n 'If true, transforms only uncommitted files (untracked, modified, and staged files)',\n }),\n diffFrom: cmd.option({\n long: 'diff-from',\n type: cmd.optional(cmd.string),\n description:\n 'If provided, transforms only files that differ from the given base branch or commit hash',\n }),\n silent: cmd.flag({\n long: 'silent',\n type: cmd.optional(cmd.boolean),\n description: 'If true, suppresses output messages (default: false)',\n }),\n },\n handler: (args) => {\n (async (): Promise<void> => {\n const result = await runTransformerCLI(\n {\n baseDir: args.baseDir,\n exclude: args.exclude ?? [],\n uncommitted: args.uncommitted ?? false,\n diffFrom: args.diffFrom,\n silent: args.silent ?? false,\n },\n [transformer],\n );\n\n if (Result.isErr(result)) {\n process.exit(1);\n }\n })().catch((error: unknown) => {\n console.error('An error occurred:', error);\n\n process.exit(1);\n });\n },\n});\n\nawait cmd.run(cmdDef, Arr.skip(process.argv, 2));\n"],"names":[],"mappings":";;;;;;;;;AAOA,MAAM,cAAc,4BAAA,EAA6B;AAEjD,MAAM,MAAA,GAAS,IAAI,OAAA,CAAQ;AAAA,EACzB,MAAM,WAAA,CAAY,IAAA;AAAA,EAClB,OAAA,EAAS,OAAA;AAAA,EACT,IAAA,EAAM;AAAA,IACJ,OAAA,EAAS,IAAI,UAAA,CAAW;AAAA,MACtB,MAAM,GAAA,CAAI,MAAA;AAAA,MACV,WAAA,EAAa,SAAA;AAAA,MACb,WAAA,EAAa;AAAA,KACd,CAAA;AAAA,IACD,OAAA,EAAS,IAAI,WAAA,CAAY;AAAA,MACvB,IAAA,EAAM,SAAA;AAAA,MACN,MAAM,GAAA,CAAI,QAAA,CAAS,IAAI,KAAA,CAAM,GAAA,CAAI,MAAM,CAAC,CAAA;AAAA,MACxC,WAAA,EACE;AAAA,KACH,CAAA;AAAA,IACD,WAAA,EAAa,IAAI,IAAA,CAAK;AAAA,MACpB,IAAA,EAAM,aAAA;AAAA,MACN,IAAA,EAAM,GAAA,CAAI,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAAA,MAC9B,WAAA,EACE;AAAA,KACH,CAAA;AAAA,IACD,QAAA,EAAU,IAAI,MAAA,CAAO;AAAA,MACnB,IAAA,EAAM,WAAA;AAAA,MACN,IAAA,EAAM,GAAA,CAAI,QAAA,CAAS,GAAA,CAAI,MAAM,CAAA;AAAA,MAC7B,WAAA,EACE;AAAA,KACH,CAAA;AAAA,IACD,MAAA,EAAQ,IAAI,IAAA,CAAK;AAAA,MACf,IAAA,EAAM,QAAA;AAAA,MACN,IAAA,EAAM,GAAA,CAAI,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAAA,MAC9B,WAAA,EAAa;AAAA,KACd;AAAA,GACH;AAAA,EACA,OAAA,EAAS,CAAC,IAAA,KAAS;AACjB,IAAA,CAAC,YAA2B;AAC1B,MAAA,MAAM,SAAS,MAAM,iBAAA;AAAA,QACnB;AAAA,UACE,SAAS,IAAA,CAAK,OAAA;AAAA,UACd,OAAA,EAAS,IAAA,CAAK,OAAA,IAAW,EAAC;AAAA,UAC1B,WAAA,EAAa,KAAK,WAAA,IAAe,KAAA;AAAA,UACjC,UAAU,IAAA,CAAK,QAAA;AAAA,UACf,MAAA,EAAQ,KAAK,MAAA,IAAU;AAAA,SACzB;AAAA,QACA,CAAC,WAAW;AAAA,OACd;AAEA,MAAA,IAAI,MAAA,CAAO,KAAA,CAAM,MAAM,CAAA,EAAG;AACxB,QAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,MAChB;AAAA,IACF,CAAA,GAAG,CAAE,KAAA,CAAM,CAAC,KAAA,KAAmB;AAC7B,MAAA,OAAA,CAAQ,KAAA,CAAM,sBAAsB,KAAK,CAAA;AAEzC,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB,CAAC,CAAA;AAAA,EACH;AACF,CAAC,CAAA;AAED,MAAM,GAAA,CAAI,IAAI,MAAA,EAAQ,GAAA,CAAI,KAAK,OAAA,CAAQ,IAAA,EAAM,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replace-any-with-unknown.d.mts","sourceRoot":"","sources":["../../src/cmd/replace-any-with-unknown.mts"],"names":[],"mappings":""}
|