@commercetools-frontend/codemod 23.2.1 → 23.2.3
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/build/package.json +1 -1
- package/build/src/cli.js +16 -23
- package/build/src/index.js +2 -8
- package/build/src/transforms/react-default-props-migration.js +4 -9
- package/build/src/transforms/redesign-cleanup.js +4 -9
- package/build/src/transforms/remove-deprecated-modal-level-props.js +1 -3
- package/build/src/transforms/rename-js-to-jsx.js +3 -8
- package/build/src/transforms/rename-mod-css-to-module-css.js +4 -9
- package/build/src/types.js +1 -2
- package/package.json +2 -2
package/build/package.json
CHANGED
package/build/src/cli.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.run = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const commander_1 = require("commander");
|
|
9
|
-
const glob_1 = __importDefault(require("glob"));
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { program } from 'commander';
|
|
3
|
+
import glob from 'glob';
|
|
10
4
|
// @ts-ignore internal module
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
import Runner from 'jscodeshift/src/Runner';
|
|
6
|
+
import pkgJson from '../package.json';
|
|
7
|
+
program
|
|
14
8
|
.name('mc-codemod')
|
|
15
9
|
.description('Codemods for updating Merchant Center customizations.')
|
|
16
|
-
.version(
|
|
10
|
+
.version(pkgJson.version)
|
|
17
11
|
.option('--dry-run', `(optional) Executes the command but does not send any mutation request.`, false);
|
|
18
12
|
const transforms = [
|
|
19
13
|
{
|
|
@@ -38,8 +32,8 @@ const transforms = [
|
|
|
38
32
|
},
|
|
39
33
|
];
|
|
40
34
|
const executeCodemod = async (transform, globPattern, globalOptions) => {
|
|
41
|
-
const absoluteGlobPattern =
|
|
42
|
-
const files =
|
|
35
|
+
const absoluteGlobPattern = path.resolve(globPattern);
|
|
36
|
+
const files = glob.sync(path.join(absoluteGlobPattern, '**/*.{ts,tsx,js,jsx}'), {
|
|
43
37
|
ignore: [
|
|
44
38
|
'**/node_modules/**',
|
|
45
39
|
'**/public/**',
|
|
@@ -48,7 +42,7 @@ const executeCodemod = async (transform, globPattern, globalOptions) => {
|
|
|
48
42
|
],
|
|
49
43
|
});
|
|
50
44
|
const runJscodeshift = async (transformPath, filePaths, options) => {
|
|
51
|
-
await
|
|
45
|
+
await Runner.run(transformPath, filePaths, options);
|
|
52
46
|
};
|
|
53
47
|
switch (transform) {
|
|
54
48
|
case 'redesign-cleanup':
|
|
@@ -56,7 +50,7 @@ const executeCodemod = async (transform, globPattern, globalOptions) => {
|
|
|
56
50
|
case 'remove-deprecated-modal-level-props':
|
|
57
51
|
case 'rename-js-to-jsx':
|
|
58
52
|
case 'rename-mod-css-to-module-css': {
|
|
59
|
-
const transformPath =
|
|
53
|
+
const transformPath = path.join(__dirname, `transforms/${transform}.js`);
|
|
60
54
|
await runJscodeshift(transformPath, files, {
|
|
61
55
|
extensions: 'tsx,ts,jsx,js',
|
|
62
56
|
parser: 'tsx',
|
|
@@ -69,19 +63,18 @@ const executeCodemod = async (transform, globPattern, globalOptions) => {
|
|
|
69
63
|
throw new Error(`Unknown transform ${transform}.`);
|
|
70
64
|
}
|
|
71
65
|
};
|
|
72
|
-
const run = () => {
|
|
66
|
+
export const run = () => {
|
|
73
67
|
// Transform commands
|
|
74
68
|
transforms.forEach((transform) => {
|
|
75
|
-
|
|
69
|
+
program
|
|
76
70
|
.command(transform.name)
|
|
77
71
|
.argument('<glob-pattern>')
|
|
78
72
|
.description(transform.description)
|
|
79
73
|
.action((globPattern) => {
|
|
80
|
-
const globalOptions =
|
|
74
|
+
const globalOptions = program.opts();
|
|
81
75
|
executeCodemod(transform.name, globPattern, globalOptions);
|
|
82
76
|
});
|
|
83
77
|
});
|
|
84
|
-
|
|
78
|
+
program.parse();
|
|
85
79
|
};
|
|
86
|
-
|
|
87
|
-
exports.default = exports.run;
|
|
80
|
+
export default run;
|
package/build/src/index.js
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.cli = void 0;
|
|
7
|
-
const cli_1 = __importDefault(require("./cli"));
|
|
8
|
-
exports.cli = cli_1.default;
|
|
1
|
+
import cli from './cli';
|
|
2
|
+
export { cli };
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const prettier_1 = __importDefault(require("prettier"));
|
|
1
|
+
import prettier from 'prettier';
|
|
7
2
|
// When adjusting the component body where the previous props object was used
|
|
8
3
|
// we don't need to adjust the function calls that are listed here
|
|
9
4
|
const IGNORED_FUNCTIONS_ON_BODY_ADJUSTMENTS = [
|
|
@@ -395,11 +390,11 @@ async function reactDefaultPropsMigration(file, api, options) {
|
|
|
395
390
|
}
|
|
396
391
|
if (!options.dry) {
|
|
397
392
|
// Format output code with prettier
|
|
398
|
-
const prettierConfig = await
|
|
399
|
-
return
|
|
393
|
+
const prettierConfig = await prettier.resolveConfig(file.path);
|
|
394
|
+
return prettier.format(root.toSource(), prettierConfig);
|
|
400
395
|
}
|
|
401
396
|
else {
|
|
402
397
|
return null;
|
|
403
398
|
}
|
|
404
399
|
}
|
|
405
|
-
|
|
400
|
+
export default reactDefaultPropsMigration;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const prettier_1 = __importDefault(require("prettier"));
|
|
1
|
+
import prettier from 'prettier';
|
|
7
2
|
function getArgumentValue(argument, j) {
|
|
8
3
|
let computedArgumentValue;
|
|
9
4
|
switch (argument.type) {
|
|
@@ -379,11 +374,11 @@ async function themeMigrationCleanup(file, api, options) {
|
|
|
379
374
|
}
|
|
380
375
|
if (!options.dry) {
|
|
381
376
|
// Format output code with prettier
|
|
382
|
-
const prettierConfig = await
|
|
383
|
-
return
|
|
377
|
+
const prettierConfig = await prettier.resolveConfig(file.path);
|
|
378
|
+
return prettier.format(root.toSource(), prettierConfig);
|
|
384
379
|
}
|
|
385
380
|
else {
|
|
386
381
|
return null;
|
|
387
382
|
}
|
|
388
383
|
}
|
|
389
|
-
|
|
384
|
+
export default themeMigrationCleanup;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
const componentNamesWithDeprecatedZIndexProps = [
|
|
4
2
|
'InfoModalPage',
|
|
5
3
|
'FormModalPage',
|
|
@@ -37,4 +35,4 @@ function removeDeprecatedModalLevelProps(file, api, options) {
|
|
|
37
35
|
? root.toSource({ ...options, quote: 'single' })
|
|
38
36
|
: null;
|
|
39
37
|
}
|
|
40
|
-
|
|
38
|
+
export default removeDeprecatedModalLevelProps;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
1
|
+
import fs from 'fs';
|
|
7
2
|
function renameJsToJsx(file, api, options) {
|
|
8
3
|
const j = api.jscodeshift;
|
|
9
4
|
const root = j(file.source);
|
|
@@ -15,11 +10,11 @@ function renameJsToJsx(file, api, options) {
|
|
|
15
10
|
}
|
|
16
11
|
else {
|
|
17
12
|
const renamedFilePath = file.path.replace('.js', '.jsx');
|
|
18
|
-
|
|
13
|
+
fs.renameSync(file.path, renamedFilePath);
|
|
19
14
|
api.report(`renamed to ${renamedFilePath}`);
|
|
20
15
|
}
|
|
21
16
|
}
|
|
22
17
|
}
|
|
23
18
|
return null;
|
|
24
19
|
}
|
|
25
|
-
|
|
20
|
+
export default renameJsToJsx;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
8
3
|
function renameModCssToModuleCss(file, api, options) {
|
|
9
4
|
const j = api.jscodeshift;
|
|
10
5
|
let hasModifications = false;
|
|
@@ -21,7 +16,7 @@ function renameModCssToModuleCss(file, api, options) {
|
|
|
21
16
|
node.source.value = nextCssModulesFilePath;
|
|
22
17
|
hasModifications = true;
|
|
23
18
|
// Side effect for renaming the actual CSS module file.
|
|
24
|
-
|
|
19
|
+
fs.renameSync(path.join(path.dirname(file.path), previousCssModulesFilePath), path.join(path.dirname(file.path), nextCssModulesFilePath));
|
|
25
20
|
}
|
|
26
21
|
}
|
|
27
22
|
}
|
|
@@ -31,4 +26,4 @@ function renameModCssToModuleCss(file, api, options) {
|
|
|
31
26
|
? root.toSource({ ...options, quote: 'single' })
|
|
32
27
|
: null;
|
|
33
28
|
}
|
|
34
|
-
|
|
29
|
+
export default renameModCssToModuleCss;
|
package/build/src/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/codemod",
|
|
3
|
-
"version": "23.2.
|
|
3
|
+
"version": "23.2.3",
|
|
4
4
|
"description": "Codemod transformations for Custom Applications",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@types/prettier": "2.7.3",
|
|
47
47
|
"rimraf": "5.0.7",
|
|
48
48
|
"typescript": "5.0.4",
|
|
49
|
-
"@commercetools-frontend/application-components": "23.2.
|
|
49
|
+
"@commercetools-frontend/application-components": "23.2.3"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": "18.x || 20.x || >=22.0.0"
|