@availity/mui-codemod 1.0.87 → 2.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/CHANGELOG.md +34 -0
- package/dist/codemod.js +14 -31
- package/package.json +13 -5
- package/project.json +5 -4
- package/dist/codemod.d.mts +0 -193
- package/dist/codemod.mjs +0 -168
- package/jest.config.js +0 -7
- package/tsconfig.spec.json +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [2.0.0](https://github.com/Availity/element/compare/@availity/mui-codemod@1.0.88...@availity/mui-codemod@2.0.0) (2026-06-16)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `element` updated to version `1.0.88`
|
|
10
|
+
* `mui-layout` updated to version `1.0.88`
|
|
11
|
+
* `mui-typography` updated to version `1.0.88`
|
|
12
|
+
|
|
13
|
+
### ⚠ BREAKING CHANGES
|
|
14
|
+
|
|
15
|
+
* CJS builds removed, packages are ESM-only.
|
|
16
|
+
|
|
17
|
+
- Convert all packages to ESM (type: module)
|
|
18
|
+
- Replace Jest with Vitest for all test targets
|
|
19
|
+
- Migrate ESLint to v9 flat config (eslint.config.js)
|
|
20
|
+
- Build output ESM-only (removed CJS dist/index.js require path)
|
|
21
|
+
- Upgrade @tanstack/react-query from v4 to v5
|
|
22
|
+
- Upgrade @availity/api-axios to v13
|
|
23
|
+
- Drop Node 20 support (engines: ^22.0.0 || ^24.0.0)
|
|
24
|
+
- Bump React to 19.2.7, MUI to 7.3.11, TypeScript to 5.9.3
|
|
25
|
+
- Simplify CI caching with built-in yarn cache action + Nx cache
|
|
26
|
+
- Modernize nx.json configuration
|
|
27
|
+
- Update husky hooks to use yarn directly
|
|
28
|
+
- Replace lint-staged nx affected with direct eslint
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
* migrate to ESM, Vitest, and ESLint 9 flat config ([cc22bb4](https://github.com/Availity/element/commit/cc22bb4a230bc1f3b190f187c4e61249d015b25b))
|
|
33
|
+
|
|
34
|
+
## [1.0.88](https://github.com/Availity/element/compare/@availity/mui-codemod@1.0.87...@availity/mui-codemod@1.0.88) (2026-06-03)
|
|
35
|
+
|
|
36
|
+
### Dependency Updates
|
|
37
|
+
|
|
38
|
+
* `element` updated to version `1.0.87`
|
|
5
39
|
## [1.0.87](https://github.com/Availity/element/compare/@availity/mui-codemod@1.0.86...@availity/mui-codemod@1.0.87) (2026-06-03)
|
|
6
40
|
|
|
7
41
|
### Dependency Updates
|
package/dist/codemod.js
CHANGED
|
@@ -1,38 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
-
mod
|
|
24
|
-
));
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
25
8
|
|
|
26
9
|
// src/codemod.js
|
|
27
|
-
var childProcess =
|
|
28
|
-
var { promises: fs } =
|
|
29
|
-
var path =
|
|
30
|
-
var yargs =
|
|
31
|
-
var jscodeshiftPackage =
|
|
32
|
-
var postcssCliPackage =
|
|
33
|
-
var jscodeshiftDirectory = path.dirname(
|
|
10
|
+
var childProcess = __require("child_process");
|
|
11
|
+
var { promises: fs } = __require("fs");
|
|
12
|
+
var path = __require("path");
|
|
13
|
+
var yargs = __require("yargs");
|
|
14
|
+
var jscodeshiftPackage = __require("jscodeshift/package.json");
|
|
15
|
+
var postcssCliPackage = __require("postcss-cli/package.json");
|
|
16
|
+
var jscodeshiftDirectory = path.dirname(__require.resolve("jscodeshift"));
|
|
34
17
|
var jscodeshiftExecutable = path.join(jscodeshiftDirectory, jscodeshiftPackage.bin.jscodeshift);
|
|
35
|
-
var postcssCliDirectory = path.dirname(
|
|
18
|
+
var postcssCliDirectory = path.dirname(__require.resolve("postcss-cli"));
|
|
36
19
|
var postcssExecutable = path.join(postcssCliDirectory, postcssCliPackage.bin.postcss);
|
|
37
20
|
async function runJscodeshiftTransform(transform, files, flags, codemodFlags) {
|
|
38
21
|
const paths = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-codemod",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Availity MUI v1 Codemods - part of the @availity/element design system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"node": ">=18.0.0"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "tsup src/codemod.js --format esm
|
|
28
|
-
"dev": "tsup src/codemod.js --format esm
|
|
27
|
+
"build": "tsup src/codemod.js --format esm --dts",
|
|
28
|
+
"dev": "tsup src/codemod.js --format esm --watch --dts",
|
|
29
29
|
"clean": "rm -rf dist",
|
|
30
30
|
"clean:nm": "rm -rf node_modules",
|
|
31
31
|
"publish": "yarn npm publish --tolerate-republish --access public",
|
|
32
32
|
"publish:canary": "yarn npm publish --access public --tag canary"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"tsup": "^8.
|
|
36
|
-
"typescript": "^5.
|
|
35
|
+
"tsup": "^8.5.1",
|
|
36
|
+
"typescript": "^5.9.3"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
@@ -43,5 +43,13 @@
|
|
|
43
43
|
"jscodeshift": "^17.3.0",
|
|
44
44
|
"postcss-cli": "^11.0.1",
|
|
45
45
|
"yargs": "^17.7.2"
|
|
46
|
+
},
|
|
47
|
+
"type": "module",
|
|
48
|
+
"exports": {
|
|
49
|
+
".": {
|
|
50
|
+
"types": "./dist/index.d.ts",
|
|
51
|
+
"import": "./dist/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./package.json": "./package.json"
|
|
46
54
|
}
|
|
47
55
|
}
|
package/project.json
CHANGED
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
"tags": [],
|
|
7
7
|
"targets": {
|
|
8
8
|
"test": {
|
|
9
|
-
"executor": "
|
|
10
|
-
"outputs": ["{workspaceRoot}/coverage/codemod"],
|
|
9
|
+
"executor": "nx:run-commands",
|
|
11
10
|
"options": {
|
|
12
|
-
"
|
|
11
|
+
"command": "vitest run packages/codemod"
|
|
13
12
|
}
|
|
14
13
|
},
|
|
15
14
|
"version": {
|
|
@@ -19,7 +18,9 @@
|
|
|
19
18
|
"commitMessageFormat": "chore({projectName}): release version ${version} [skip ci]",
|
|
20
19
|
"tagPrefix": "@availity/{projectName}@",
|
|
21
20
|
"trackDeps": true,
|
|
22
|
-
"skipCommitTypes": [
|
|
21
|
+
"skipCommitTypes": [
|
|
22
|
+
"docs"
|
|
23
|
+
]
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
}
|
package/dist/codemod.d.mts
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const childProcess = require('child_process');
|
|
3
|
-
const { promises: fs } = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const yargs = require('yargs');
|
|
6
|
-
const jscodeshiftPackage = require('jscodeshift/package.json');
|
|
7
|
-
const postcssCliPackage = require('postcss-cli/package.json');
|
|
8
|
-
|
|
9
|
-
const jscodeshiftDirectory = path.dirname(require.resolve('jscodeshift'));
|
|
10
|
-
const jscodeshiftExecutable = path.join(jscodeshiftDirectory, jscodeshiftPackage.bin.jscodeshift);
|
|
11
|
-
|
|
12
|
-
const postcssCliDirectory = path.dirname(require.resolve('postcss-cli'));
|
|
13
|
-
const postcssExecutable = path.join(postcssCliDirectory, postcssCliPackage.bin.postcss);
|
|
14
|
-
|
|
15
|
-
async function runJscodeshiftTransform(transform, files, flags, codemodFlags) {
|
|
16
|
-
const paths = [
|
|
17
|
-
path.resolve(__dirname, './lib', `${transform}/index.js`),
|
|
18
|
-
path.resolve(__dirname, './lib', `${transform}.js`),
|
|
19
|
-
path.resolve(__dirname, './node', `${transform}/index.js`),
|
|
20
|
-
path.resolve(__dirname, './node', `${transform}.js`),
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
let transformerPath;
|
|
24
|
-
let error;
|
|
25
|
-
for (const item of paths) {
|
|
26
|
-
try {
|
|
27
|
-
await fs.stat(item);
|
|
28
|
-
error = undefined;
|
|
29
|
-
transformerPath = item;
|
|
30
|
-
break;
|
|
31
|
-
} catch (srcPathError) {
|
|
32
|
-
error = srcPathError;
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (error) {
|
|
38
|
-
if (error?.code === 'ENOENT') {
|
|
39
|
-
throw new Error(
|
|
40
|
-
`Transform '${transform}' not found. Check out ${path.resolve(__dirname, './README.md for a list of available codemods.')}`,
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const args = [
|
|
47
|
-
jscodeshiftExecutable,
|
|
48
|
-
'--transform',
|
|
49
|
-
transformerPath,
|
|
50
|
-
...codemodFlags,
|
|
51
|
-
'--extensions',
|
|
52
|
-
'js,ts,jsx,tsx,json',
|
|
53
|
-
'--parser',
|
|
54
|
-
flags.parser || 'tsx',
|
|
55
|
-
'--ignore-pattern',
|
|
56
|
-
'**/node_modules/**',
|
|
57
|
-
'--ignore-pattern',
|
|
58
|
-
'**/*.css'
|
|
59
|
-
];
|
|
60
|
-
|
|
61
|
-
if (flags.dry) {
|
|
62
|
-
args.push('--dry');
|
|
63
|
-
}
|
|
64
|
-
if (flags.print) {
|
|
65
|
-
args.push('--print');
|
|
66
|
-
}
|
|
67
|
-
if (flags.jscodeshift) {
|
|
68
|
-
args.push(flags.jscodeshift);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
args.push(...files);
|
|
72
|
-
|
|
73
|
-
console.log(`Executing command: jscodeshift ${args.join(' ')}`);
|
|
74
|
-
const jscodeshiftProcess = childProcess.spawnSync('node', args, { stdio: 'inherit' });
|
|
75
|
-
|
|
76
|
-
if (jscodeshiftProcess.error) {
|
|
77
|
-
throw jscodeshiftProcess.error;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const parseCssFilePaths = async (files) => {
|
|
82
|
-
const cssFiles = await Promise.all(files.map(async (filePath) => {
|
|
83
|
-
const stat = await fs.stat(filePath);
|
|
84
|
-
if (stat.isDirectory()) {
|
|
85
|
-
return `${filePath}/**/*.css`;
|
|
86
|
-
}
|
|
87
|
-
if (filePath.endsWith('.css')) {
|
|
88
|
-
return filePath;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return null;
|
|
92
|
-
}),);
|
|
93
|
-
|
|
94
|
-
return cssFiles.filter(Boolean);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
async function runPostcssTransform(transform, files) {
|
|
98
|
-
const paths = [
|
|
99
|
-
path.resolve(__dirname, './lib', `${transform}/postcss.config.js`),
|
|
100
|
-
path.resolve(__dirname, './node', `${transform}/postcss.config.js`),
|
|
101
|
-
];
|
|
102
|
-
|
|
103
|
-
let configPath;
|
|
104
|
-
let error;
|
|
105
|
-
for (const item of paths) {
|
|
106
|
-
try {
|
|
107
|
-
await fs.stat(item);
|
|
108
|
-
error = undefined;
|
|
109
|
-
configPath = item;
|
|
110
|
-
break;
|
|
111
|
-
} catch (srcPathError) {
|
|
112
|
-
error = srcPathError;
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (error) {
|
|
118
|
-
if (error?.code !== 'ENOENT') {
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
} else {
|
|
122
|
-
const cssPaths = await parseCssFilePaths(files);
|
|
123
|
-
|
|
124
|
-
if (cssPaths.length > 0) {
|
|
125
|
-
const args = [
|
|
126
|
-
postcssExecutable,
|
|
127
|
-
...cssPaths,
|
|
128
|
-
'--config',
|
|
129
|
-
configPath,
|
|
130
|
-
'--replace',
|
|
131
|
-
'--verbose',
|
|
132
|
-
];
|
|
133
|
-
|
|
134
|
-
console.log(`Executing command: postcss ${args.join(' ')}`);
|
|
135
|
-
const postCssProcess = childProcess.spawnSync('node', args, { stdio: 'inherit' });
|
|
136
|
-
|
|
137
|
-
if (postCssProcess.error) {
|
|
138
|
-
throw postCssProcess.error;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function run(argv) {
|
|
145
|
-
const { codemod, paths, ...flags } = argv;
|
|
146
|
-
const files = paths.map((filePath) => path.resolve(filePath));
|
|
147
|
-
|
|
148
|
-
runJscodeshiftTransform(codemod, files, flags, argv._);
|
|
149
|
-
runPostcssTransform(codemod, files);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
yargs.command({
|
|
153
|
-
command: '$0 <codemod> <paths...>',
|
|
154
|
-
describe: 'Applies a `@mui/codemod` to the specified paths',
|
|
155
|
-
builder: (command) => {
|
|
156
|
-
return command
|
|
157
|
-
.positional('codemod', {
|
|
158
|
-
description: 'The name of the codemod',
|
|
159
|
-
type: 'string'
|
|
160
|
-
})
|
|
161
|
-
.positional('paths', {
|
|
162
|
-
array: true,
|
|
163
|
-
description: 'Paths forwarded to `jscodeshift`',
|
|
164
|
-
type: 'string',
|
|
165
|
-
})
|
|
166
|
-
.option('dry', {
|
|
167
|
-
description: 'dry run (no changes are made to files)',
|
|
168
|
-
default: false,
|
|
169
|
-
type: 'boolean'
|
|
170
|
-
})
|
|
171
|
-
.option('parser', {
|
|
172
|
-
description: 'which parser for jscodeshift to use',
|
|
173
|
-
default: 'tsx',
|
|
174
|
-
type: 'string'
|
|
175
|
-
})
|
|
176
|
-
.option('print', {
|
|
177
|
-
description: 'print transformed files to stdout, useful for development',
|
|
178
|
-
default: false,
|
|
179
|
-
type: 'boolean'
|
|
180
|
-
})
|
|
181
|
-
.option('jscodeshift', {
|
|
182
|
-
description: '(Advanced) Pass options directly to jscodeshift',
|
|
183
|
-
default: false,
|
|
184
|
-
type: 'string'
|
|
185
|
-
});
|
|
186
|
-
},
|
|
187
|
-
handler: run,
|
|
188
|
-
})
|
|
189
|
-
.scriptName('npx @availity/mui-codemod')
|
|
190
|
-
.example('$0 v4.0.0/theme-spacing-api src')
|
|
191
|
-
.example('$0 v5.0.0/component-rename-prop src -- --component=Grid --from=prop --to=newProp')
|
|
192
|
-
.help()
|
|
193
|
-
.parse();
|
package/dist/codemod.mjs
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
-
}) : x)(function(x) {
|
|
5
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
// src/codemod.js
|
|
10
|
-
var childProcess = __require("child_process");
|
|
11
|
-
var { promises: fs } = __require("fs");
|
|
12
|
-
var path = __require("path");
|
|
13
|
-
var yargs = __require("yargs");
|
|
14
|
-
var jscodeshiftPackage = __require("jscodeshift/package.json");
|
|
15
|
-
var postcssCliPackage = __require("postcss-cli/package.json");
|
|
16
|
-
var jscodeshiftDirectory = path.dirname(__require.resolve("jscodeshift"));
|
|
17
|
-
var jscodeshiftExecutable = path.join(jscodeshiftDirectory, jscodeshiftPackage.bin.jscodeshift);
|
|
18
|
-
var postcssCliDirectory = path.dirname(__require.resolve("postcss-cli"));
|
|
19
|
-
var postcssExecutable = path.join(postcssCliDirectory, postcssCliPackage.bin.postcss);
|
|
20
|
-
async function runJscodeshiftTransform(transform, files, flags, codemodFlags) {
|
|
21
|
-
const paths = [
|
|
22
|
-
path.resolve(__dirname, "./lib", `${transform}/index.js`),
|
|
23
|
-
path.resolve(__dirname, "./lib", `${transform}.js`),
|
|
24
|
-
path.resolve(__dirname, "./node", `${transform}/index.js`),
|
|
25
|
-
path.resolve(__dirname, "./node", `${transform}.js`)
|
|
26
|
-
];
|
|
27
|
-
let transformerPath;
|
|
28
|
-
let error;
|
|
29
|
-
for (const item of paths) {
|
|
30
|
-
try {
|
|
31
|
-
await fs.stat(item);
|
|
32
|
-
error = void 0;
|
|
33
|
-
transformerPath = item;
|
|
34
|
-
break;
|
|
35
|
-
} catch (srcPathError) {
|
|
36
|
-
error = srcPathError;
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (error) {
|
|
41
|
-
if ((error == null ? void 0 : error.code) === "ENOENT") {
|
|
42
|
-
throw new Error(
|
|
43
|
-
`Transform '${transform}' not found. Check out ${path.resolve(__dirname, "./README.md for a list of available codemods.")}`
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
throw error;
|
|
47
|
-
}
|
|
48
|
-
const args = [
|
|
49
|
-
jscodeshiftExecutable,
|
|
50
|
-
"--transform",
|
|
51
|
-
transformerPath,
|
|
52
|
-
...codemodFlags,
|
|
53
|
-
"--extensions",
|
|
54
|
-
"js,ts,jsx,tsx,json",
|
|
55
|
-
"--parser",
|
|
56
|
-
flags.parser || "tsx",
|
|
57
|
-
"--ignore-pattern",
|
|
58
|
-
"**/node_modules/**",
|
|
59
|
-
"--ignore-pattern",
|
|
60
|
-
"**/*.css"
|
|
61
|
-
];
|
|
62
|
-
if (flags.dry) {
|
|
63
|
-
args.push("--dry");
|
|
64
|
-
}
|
|
65
|
-
if (flags.print) {
|
|
66
|
-
args.push("--print");
|
|
67
|
-
}
|
|
68
|
-
if (flags.jscodeshift) {
|
|
69
|
-
args.push(flags.jscodeshift);
|
|
70
|
-
}
|
|
71
|
-
args.push(...files);
|
|
72
|
-
console.log(`Executing command: jscodeshift ${args.join(" ")}`);
|
|
73
|
-
const jscodeshiftProcess = childProcess.spawnSync("node", args, { stdio: "inherit" });
|
|
74
|
-
if (jscodeshiftProcess.error) {
|
|
75
|
-
throw jscodeshiftProcess.error;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
var parseCssFilePaths = async (files) => {
|
|
79
|
-
const cssFiles = await Promise.all(files.map(async (filePath) => {
|
|
80
|
-
const stat = await fs.stat(filePath);
|
|
81
|
-
if (stat.isDirectory()) {
|
|
82
|
-
return `${filePath}/**/*.css`;
|
|
83
|
-
}
|
|
84
|
-
if (filePath.endsWith(".css")) {
|
|
85
|
-
return filePath;
|
|
86
|
-
}
|
|
87
|
-
return null;
|
|
88
|
-
}));
|
|
89
|
-
return cssFiles.filter(Boolean);
|
|
90
|
-
};
|
|
91
|
-
async function runPostcssTransform(transform, files) {
|
|
92
|
-
const paths = [
|
|
93
|
-
path.resolve(__dirname, "./lib", `${transform}/postcss.config.js`),
|
|
94
|
-
path.resolve(__dirname, "./node", `${transform}/postcss.config.js`)
|
|
95
|
-
];
|
|
96
|
-
let configPath;
|
|
97
|
-
let error;
|
|
98
|
-
for (const item of paths) {
|
|
99
|
-
try {
|
|
100
|
-
await fs.stat(item);
|
|
101
|
-
error = void 0;
|
|
102
|
-
configPath = item;
|
|
103
|
-
break;
|
|
104
|
-
} catch (srcPathError) {
|
|
105
|
-
error = srcPathError;
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (error) {
|
|
110
|
-
if ((error == null ? void 0 : error.code) !== "ENOENT") {
|
|
111
|
-
throw error;
|
|
112
|
-
}
|
|
113
|
-
} else {
|
|
114
|
-
const cssPaths = await parseCssFilePaths(files);
|
|
115
|
-
if (cssPaths.length > 0) {
|
|
116
|
-
const args = [
|
|
117
|
-
postcssExecutable,
|
|
118
|
-
...cssPaths,
|
|
119
|
-
"--config",
|
|
120
|
-
configPath,
|
|
121
|
-
"--replace",
|
|
122
|
-
"--verbose"
|
|
123
|
-
];
|
|
124
|
-
console.log(`Executing command: postcss ${args.join(" ")}`);
|
|
125
|
-
const postCssProcess = childProcess.spawnSync("node", args, { stdio: "inherit" });
|
|
126
|
-
if (postCssProcess.error) {
|
|
127
|
-
throw postCssProcess.error;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
function run(argv) {
|
|
133
|
-
const { codemod, paths, ...flags } = argv;
|
|
134
|
-
const files = paths.map((filePath) => path.resolve(filePath));
|
|
135
|
-
runJscodeshiftTransform(codemod, files, flags, argv._);
|
|
136
|
-
runPostcssTransform(codemod, files);
|
|
137
|
-
}
|
|
138
|
-
yargs.command({
|
|
139
|
-
command: "$0 <codemod> <paths...>",
|
|
140
|
-
describe: "Applies a `@mui/codemod` to the specified paths",
|
|
141
|
-
builder: (command) => {
|
|
142
|
-
return command.positional("codemod", {
|
|
143
|
-
description: "The name of the codemod",
|
|
144
|
-
type: "string"
|
|
145
|
-
}).positional("paths", {
|
|
146
|
-
array: true,
|
|
147
|
-
description: "Paths forwarded to `jscodeshift`",
|
|
148
|
-
type: "string"
|
|
149
|
-
}).option("dry", {
|
|
150
|
-
description: "dry run (no changes are made to files)",
|
|
151
|
-
default: false,
|
|
152
|
-
type: "boolean"
|
|
153
|
-
}).option("parser", {
|
|
154
|
-
description: "which parser for jscodeshift to use",
|
|
155
|
-
default: "tsx",
|
|
156
|
-
type: "string"
|
|
157
|
-
}).option("print", {
|
|
158
|
-
description: "print transformed files to stdout, useful for development",
|
|
159
|
-
default: false,
|
|
160
|
-
type: "boolean"
|
|
161
|
-
}).option("jscodeshift", {
|
|
162
|
-
description: "(Advanced) Pass options directly to jscodeshift",
|
|
163
|
-
default: false,
|
|
164
|
-
type: "string"
|
|
165
|
-
});
|
|
166
|
-
},
|
|
167
|
-
handler: run
|
|
168
|
-
}).scriptName("npx @availity/mui-codemod").example("$0 v4.0.0/theme-spacing-api src").example("$0 v5.0.0/component-rename-prop src -- --component=Grid --from=prop --to=newProp").help().parse();
|
package/jest.config.js
DELETED
package/tsconfig.spec.json
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./jsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"types": ["jest", "node", "@testing-library/jest-dom"],
|
|
7
|
-
"allowJs": true
|
|
8
|
-
},
|
|
9
|
-
"include": ["**/*.test.js", "**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"]
|
|
10
|
-
}
|