ts-codemod-lib 2.2.5 → 3.0.1
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/dist/functions/ast-transformers/convert-to-readonly.mjs +4 -1
- package/dist/functions/ast-transformers/convert-to-readonly.mjs.map +1 -1
- package/package.json +66 -115
- package/src/functions/ast-transformers/convert-to-readonly.mts +7 -1
- package/src/functions/ast-transformers/convert-to-readonly.test.mts +44 -0
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-codemod-lib",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
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,144 +31,46 @@
|
|
|
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.3.0",
|
|
43
|
+
"ts-type-forge": "^9.2.1"
|
|
111
44
|
},
|
|
112
45
|
"devDependencies": {
|
|
113
|
-
"@rollup/plugin-replace": "6.0.3",
|
|
114
|
-
"@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
46
|
"@types/node": "26.2.0",
|
|
123
47
|
"@vitest/browser-playwright": "4.1.10",
|
|
124
48
|
"@vitest/coverage-v8": "4.1.10",
|
|
125
49
|
"@vitest/ui": "4.1.10",
|
|
126
|
-
"cmd-ts": "0.15.0",
|
|
127
|
-
"conventional-changelog-conventionalcommits": "10.2.1",
|
|
128
50
|
"cspell": "10.0.1",
|
|
129
51
|
"dedent": "1.7.2",
|
|
130
52
|
"esbuild": "0.28.1",
|
|
131
|
-
"eslint": "10.8.
|
|
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",
|
|
53
|
+
"eslint": "10.8.1",
|
|
137
54
|
"jiti": "2.7.0",
|
|
138
|
-
"markdownlint": "0.41.1",
|
|
139
|
-
"markdownlint-cli2": "0.23.2",
|
|
140
55
|
"npm-run-all2": "9.0.3",
|
|
141
56
|
"playwright": "1.62.1",
|
|
142
57
|
"prettier": "3.9.6",
|
|
143
58
|
"prettier-plugin-organize-imports": "4.3.0",
|
|
144
59
|
"prettier-plugin-packagejson": "3.0.2",
|
|
145
60
|
"rollup": "4.62.4",
|
|
146
|
-
"
|
|
147
|
-
"semantic-release": "25.0.8",
|
|
148
|
-
"ts-repo-utils": "10.1.7",
|
|
149
|
-
"tsx": "4.23.4",
|
|
61
|
+
"tsx": "4.23.11",
|
|
150
62
|
"typedoc": "0.28.20",
|
|
151
63
|
"typedoc-github-theme": "0.4.0",
|
|
152
64
|
"typescript": "6.0.3",
|
|
153
65
|
"typescript-native": "npm:typescript@7.0.2",
|
|
154
|
-
"vite": "8.2.
|
|
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
|
-
}
|
|
66
|
+
"vite": "8.2.1",
|
|
67
|
+
"vitest": "4.1.10",
|
|
68
|
+
"eslint-config-typed": "5.9.2",
|
|
69
|
+
"eslint-plugin-ts-data-forge": "0.4.7",
|
|
70
|
+
"eslint-plugin-ts-fortress": "1.0.3",
|
|
71
|
+
"eslint-plugin-ts-type-forge": "0.6.5",
|
|
72
|
+
"ts-repo-utils": "10.2.0"
|
|
172
73
|
},
|
|
173
|
-
"packageManager": "pnpm@11.20.0",
|
|
174
74
|
"engines": {
|
|
175
75
|
"node": ">=22.22.2",
|
|
176
76
|
"pnpm": ">=9.0.0"
|
|
@@ -181,5 +81,56 @@
|
|
|
181
81
|
"publishConfig": {
|
|
182
82
|
"access": "public",
|
|
183
83
|
"provenance": true
|
|
84
|
+
},
|
|
85
|
+
"scripts": {
|
|
86
|
+
"build": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/build.mts",
|
|
87
|
+
"build:min": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/build.mts --skip-check",
|
|
88
|
+
"check-all": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/check-all.mts",
|
|
89
|
+
"check:ext": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/check-ext.mts",
|
|
90
|
+
"clean": "pnpm run /clean:.*/",
|
|
91
|
+
"clean:logs": "npx rimraf ./*.log",
|
|
92
|
+
"codemod": "run-s codemod:uncommitted:* fmt",
|
|
93
|
+
"codemod:diff": "run-s codemod:diff:* fmt",
|
|
94
|
+
"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}'",
|
|
95
|
+
"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}'",
|
|
96
|
+
"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}'",
|
|
97
|
+
"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}'",
|
|
98
|
+
"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}'",
|
|
99
|
+
"codemod:full": "run-s codemod:full:* fmt",
|
|
100
|
+
"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}'",
|
|
101
|
+
"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}'",
|
|
102
|
+
"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}'",
|
|
103
|
+
"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}'",
|
|
104
|
+
"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}'",
|
|
105
|
+
"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}'",
|
|
106
|
+
"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}'",
|
|
107
|
+
"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}'",
|
|
108
|
+
"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}'",
|
|
109
|
+
"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}'",
|
|
110
|
+
"cspell": "cspell \"**\" --gitignore --gitignore-root ../../ --no-progress",
|
|
111
|
+
"doc": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/gen-docs.mts",
|
|
112
|
+
"doc:embed": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/cmd/embed-examples.mts",
|
|
113
|
+
"doc:preview": "vite preview --config ./configs/vite.doc.config.mts",
|
|
114
|
+
"doc:watch": "typedoc --options ./configs/typedoc.config.mjs --watch",
|
|
115
|
+
"fmt": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../../libs/ts-repo-utils/src/cmd/format-uncommitted.mts --cwd .",
|
|
116
|
+
"fmt:diff": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ../../libs/ts-repo-utils/src/cmd/format-diff-from.mts origin/main --cwd .",
|
|
117
|
+
"fmt:full": "prettier --write .",
|
|
118
|
+
"gi": "run-s gi:src fmt",
|
|
119
|
+
"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",
|
|
120
|
+
"lint": "eslint .",
|
|
121
|
+
"lint:fix": "eslint . --fix",
|
|
122
|
+
"prepare-release": "run-s fmt build doc",
|
|
123
|
+
"run:test": "tsx --tsconfig ../../tools/configs/tsconfig.tsx.json ./scripts/test-code/transform-test-code.mts",
|
|
124
|
+
"test": "pnpm run z:vitest:node run",
|
|
125
|
+
"test:browser": "pnpm run z:vitest --project='Browser' run",
|
|
126
|
+
"test:cov": "pnpm run z:vitest:node run --coverage",
|
|
127
|
+
"test:cov:ui": "vite preview --outDir ./coverage",
|
|
128
|
+
"test:ui": "pnpm run z:vitest:node --ui",
|
|
129
|
+
"testw": "pnpm run z:vitest:node watch",
|
|
130
|
+
"tsc": "node ../../node_modules/typescript-native/bin/tsc --noEmit",
|
|
131
|
+
"tscw": "node ../../node_modules/typescript-native/bin/tsc --noEmit --watch -p ./tsconfig.json",
|
|
132
|
+
"type-check": "node ../../node_modules/typescript-native/bin/tsc --noEmit",
|
|
133
|
+
"z:vitest": "vitest --config ./configs/vitest.config.mts",
|
|
134
|
+
"z:vitest:node": "pnpm run z:vitest --project='Node.js'"
|
|
184
135
|
}
|
|
185
|
-
}
|
|
136
|
+
}
|
|
@@ -957,9 +957,15 @@ const transformMappedTypeNode = (
|
|
|
957
957
|
t === '?' ? '?' : t === '-' ? '-?' : t === '+' ? '+?' : undefined,
|
|
958
958
|
).value ?? '';
|
|
959
959
|
|
|
960
|
+
// Key remapping (`as` clause). It is part of the key set the mapped type
|
|
961
|
+
// produces, so dropping it would silently change the type.
|
|
962
|
+
const nameTypeText = pipe(node.getNameTypeNode()?.getFullText()).mapNullable(
|
|
963
|
+
(t) => ` as ${t.trim()}`,
|
|
964
|
+
).value;
|
|
965
|
+
|
|
960
966
|
const result: string = pipe(
|
|
961
967
|
// remove readonlyToken
|
|
962
|
-
`{ [${node.getTypeParameter().getFullText()}]${questionTokenText}: ${node.getTypeNode()?.getFullText()} }`,
|
|
968
|
+
`{ [${node.getTypeParameter().getFullText()}${nameTypeText ?? ''}]${questionTokenText}: ${node.getTypeNode()?.getFullText()} }`,
|
|
963
969
|
).map((mpt) =>
|
|
964
970
|
match(readonlyContext.type, {
|
|
965
971
|
// Don't wrap with Readonly if already readonly or unnecessary
|
|
@@ -2203,6 +2203,50 @@ describe(convertToReadonlyTransformer, () => {
|
|
|
2203
2203
|
])('$name', testFn);
|
|
2204
2204
|
});
|
|
2205
2205
|
|
|
2206
|
+
describe('Mapped type key remapping', () => {
|
|
2207
|
+
test.each([
|
|
2208
|
+
{
|
|
2209
|
+
name: 'Keeps the `as` clause when wrapping with Readonly',
|
|
2210
|
+
source: dedent`
|
|
2211
|
+
type DropSymbolKeys<R, V> = {
|
|
2212
|
+
[K in keyof R as K extends symbol ? never : K]: V;
|
|
2213
|
+
};
|
|
2214
|
+
`,
|
|
2215
|
+
expected: dedent`
|
|
2216
|
+
type DropSymbolKeys<R, V> = Readonly<{
|
|
2217
|
+
[K in keyof R as K extends symbol ? never : K]: V;
|
|
2218
|
+
}>;
|
|
2219
|
+
`,
|
|
2220
|
+
},
|
|
2221
|
+
{
|
|
2222
|
+
name: 'Keeps the `as` clause when the readonly modifier is removed',
|
|
2223
|
+
source: dedent`
|
|
2224
|
+
type Renamed<R> = {
|
|
2225
|
+
readonly [K in keyof R as \`get\${Capitalize<K & string>}\`]: R[K];
|
|
2226
|
+
};
|
|
2227
|
+
`,
|
|
2228
|
+
expected: dedent`
|
|
2229
|
+
type Renamed<R> = Readonly<{
|
|
2230
|
+
[K in keyof R as \`get\${Capitalize<K & string>}\`]: R[K];
|
|
2231
|
+
}>;
|
|
2232
|
+
`,
|
|
2233
|
+
},
|
|
2234
|
+
{
|
|
2235
|
+
name: 'Keeps the `as` clause alongside an optional modifier',
|
|
2236
|
+
source: dedent`
|
|
2237
|
+
type PartialRenamed<R> = {
|
|
2238
|
+
[K in keyof R as K extends symbol ? never : K]?: R[K];
|
|
2239
|
+
};
|
|
2240
|
+
`,
|
|
2241
|
+
expected: dedent`
|
|
2242
|
+
type PartialRenamed<R> = Readonly<{
|
|
2243
|
+
[K in keyof R as K extends symbol ? never : K]?: R[K];
|
|
2244
|
+
}>;
|
|
2245
|
+
`,
|
|
2246
|
+
},
|
|
2247
|
+
])('$name', testFn);
|
|
2248
|
+
});
|
|
2249
|
+
|
|
2206
2250
|
describe('Primitive and keyword types', () => {
|
|
2207
2251
|
test.each([
|
|
2208
2252
|
{
|
|
@@ -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":""}
|
|
@@ -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 '../functions/ast-transformers/readonly-transformer-helpers/constants.mjs';
|
|
7
|
-
import { replaceAnyWithUnknownTransformer } from '../functions/ast-transformers/replace-any-with-unknown.mjs';
|
|
8
|
-
import { runTransformerCLI } from './run-transformer-cli.mjs';
|
|
9
|
-
|
|
10
|
-
const transformer = replaceAnyWithUnknownTransformer();
|
|
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=replace-any-with-unknown.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replace-any-with-unknown.mjs","sources":["../../src/cmd/replace-any-with-unknown.mts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as cmd from 'cmd-ts';\nimport { Arr, Result } from 'ts-data-forge';\nimport { replaceAnyWithUnknownTransformer } from '../functions/index.mjs';\nimport { runTransformerCLI } from './run-transformer-cli.mjs';\n\nconst transformer = replaceAnyWithUnknownTransformer();\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,gCAAA,EAAiC;AAErD,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"}
|