@cedarjs/codemods 0.0.4
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/LICENSE +21 -0
- package/README.md +297 -0
- package/dist/codemods/list.yargs.js +67 -0
- package/dist/codemods/v2.3.x/tsconfigForRouteHooks/tsconfigForRouteHooks.js +74 -0
- package/dist/codemods/v2.3.x/tsconfigForRouteHooks/tsconfigForRouteHooks.yargs.js +51 -0
- package/dist/codemods/v2.x.x/configureFastify/configureFastify.js +43 -0
- package/dist/codemods/v2.x.x/configureFastify/configureFastify.yargs.js +83 -0
- package/dist/codemods/v2.x.x/updateResolverTypes/updateResolverTypes.js +77 -0
- package/dist/codemods/v2.x.x/updateResolverTypes/updateResolverTypes.yargs.js +62 -0
- package/dist/codemods/v4.2.x/updateClerkGetCurrentUser/updateClerkGetCurrentUser.js +71 -0
- package/dist/codemods/v4.2.x/updateClerkGetCurrentUser/updateClerkGetCurrentUser.yargs.js +58 -0
- package/dist/codemods/v4.x.x/useArmor/useArmor.js +63 -0
- package/dist/codemods/v4.x.x/useArmor/useArmor.yargs.js +62 -0
- package/dist/codemods/v5.x.x/cellQueryResult/cellQueryResult.js +110 -0
- package/dist/codemods/v5.x.x/cellQueryResult/cellQueryResult.yargs.js +58 -0
- package/dist/codemods/v5.x.x/detectEmptyCells/detectEmptyCells.js +88 -0
- package/dist/codemods/v5.x.x/detectEmptyCells/detectEmptyCells.yargs.js +59 -0
- package/dist/codemods/v5.x.x/renameValidateWith/renameValidateWith.js +32 -0
- package/dist/codemods/v5.x.x/renameValidateWith/renameValidateWith.yargs.js +65 -0
- package/dist/codemods/v5.x.x/updateAuth0ToV2/updateAuth0ToV2.js +48 -0
- package/dist/codemods/v5.x.x/updateAuth0ToV2/updateAuth0ToV2.yargs.js +68 -0
- package/dist/codemods/v5.x.x/updateNodeEngineTo18/updateNodeEngineTo18.js +46 -0
- package/dist/codemods/v5.x.x/updateNodeEngineTo18/updateNodeEngineTo18.yargs.js +57 -0
- package/dist/codemods/v5.x.x/upgradeToReact18/upgradeToReact18.js +135 -0
- package/dist/codemods/v5.x.x/upgradeToReact18/upgradeToReact18.yargs.js +56 -0
- package/dist/codemods/v6.x.x/changeGlobalToGlobalThis/changeGlobalToGlobalThis.js +29 -0
- package/dist/codemods/v6.x.x/changeGlobalToGlobalThis/changeGlobalToGlobalThis.yargs.js +60 -0
- package/dist/codemods/v6.x.x/convertJsToJsx/convertJsToJsx.js +45 -0
- package/dist/codemods/v6.x.x/convertJsToJsx/convertJsToJsx.yargs.js +59 -0
- package/dist/codemods/v6.x.x/entryClientNullCheck/entryClientNullCheck.js +51 -0
- package/dist/codemods/v6.x.x/entryClientNullCheck/entryClientNullCheck.yargs.js +60 -0
- package/dist/codemods/v6.x.x/processEnvDotNotation/processEnvDotNotation.js +44 -0
- package/dist/codemods/v6.x.x/processEnvDotNotation/processEnvDotNotation.yargs.js +60 -0
- package/dist/codemods/v6.x.x/replaceComponentSvgs/replaceComponentSvgs.js +154 -0
- package/dist/codemods/v6.x.x/replaceComponentSvgs/replaceComponentSvgs.yargs.js +61 -0
- package/dist/codemods/v6.x.x/updateDevFatalErrorPage/updateDevFatalErrorPage.js +58 -0
- package/dist/codemods/v6.x.x/updateDevFatalErrorPage/updateDevFatalErrorPage.yargs.js +50 -0
- package/dist/codemods/v6.x.x/updateThemeConfig/updateThemeConfig.js +51 -0
- package/dist/codemods/v6.x.x/updateThemeConfig/updateThemeConfig.yargs.js +61 -0
- package/dist/codemods/v7.x.x/updateGraphQLConfig/updateGraphqlConfig.js +51 -0
- package/dist/codemods/v7.x.x/updateGraphQLConfig/updateGraphqlConfig.yargs.js +50 -0
- package/dist/codemods.js +45 -0
- package/dist/lib/cells.js +230 -0
- package/dist/lib/fetchFileFromTemplate.js +29 -0
- package/dist/lib/getFilesWithPattern.js +51 -0
- package/dist/lib/getRootPackageJSON.js +44 -0
- package/dist/lib/isTSProject.js +39 -0
- package/dist/lib/prettify.js +55 -0
- package/dist/lib/runTransform.js +76 -0
- package/dist/lib/ts2js.js +57 -0
- package/package.json +67 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var prettify_exports = {};
|
|
30
|
+
__export(prettify_exports, {
|
|
31
|
+
default: () => prettify_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(prettify_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_prettier = require("prettier");
|
|
36
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
37
|
+
const getPrettierConfig = async () => {
|
|
38
|
+
try {
|
|
39
|
+
const { default: prettierConfig } = await import(`file://${import_path.default.join((0, import_project_config.getPaths)().base, "prettier.config.js")}`);
|
|
40
|
+
return prettierConfig;
|
|
41
|
+
} catch {
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const prettify = async (code, options = {}) => {
|
|
46
|
+
const prettierConfig = await getPrettierConfig();
|
|
47
|
+
return (0, import_prettier.format)(code, {
|
|
48
|
+
singleQuote: true,
|
|
49
|
+
semi: false,
|
|
50
|
+
...prettierConfig,
|
|
51
|
+
parser: "babel",
|
|
52
|
+
...options
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
var prettify_default = prettify;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var runTransform_exports = {};
|
|
30
|
+
__export(runTransform_exports, {
|
|
31
|
+
default: () => runTransform_default,
|
|
32
|
+
runTransform: () => runTransform
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(runTransform_exports);
|
|
35
|
+
var jscodeshift = __toESM(require("jscodeshift/src/Runner"));
|
|
36
|
+
const defaultJscodeshiftOpts = {
|
|
37
|
+
verbose: 0,
|
|
38
|
+
dry: false,
|
|
39
|
+
print: false,
|
|
40
|
+
babel: true,
|
|
41
|
+
ignorePattern: "**/node_modules/**",
|
|
42
|
+
ignoreConfig: [],
|
|
43
|
+
runInBand: false,
|
|
44
|
+
silent: false,
|
|
45
|
+
parser: "babel",
|
|
46
|
+
parserConfig: {},
|
|
47
|
+
failOnError: false,
|
|
48
|
+
stdin: false
|
|
49
|
+
};
|
|
50
|
+
const runTransform = async ({
|
|
51
|
+
transformPath,
|
|
52
|
+
targetPaths,
|
|
53
|
+
parser = "tsx",
|
|
54
|
+
options = {}
|
|
55
|
+
}) => {
|
|
56
|
+
try {
|
|
57
|
+
if (process.env.NODE_ENV === "test" && process.env.RWJS_CWD) {
|
|
58
|
+
process.chdir(process.env.RWJS_CWD);
|
|
59
|
+
}
|
|
60
|
+
await jscodeshift.run(transformPath, targetPaths, {
|
|
61
|
+
...defaultJscodeshiftOpts,
|
|
62
|
+
parser,
|
|
63
|
+
babel: process.env.NODE_ENV === "test",
|
|
64
|
+
...options
|
|
65
|
+
// Putting options here lets them override all the defaults.
|
|
66
|
+
});
|
|
67
|
+
} catch (e) {
|
|
68
|
+
console.error("Transform Error", e.message);
|
|
69
|
+
throw new Error("Failed to invoke transform");
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var runTransform_default = runTransform;
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
runTransform
|
|
76
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var ts2js_exports = {};
|
|
30
|
+
__export(ts2js_exports, {
|
|
31
|
+
default: () => ts2js_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(ts2js_exports);
|
|
34
|
+
var import_core = require("@babel/core");
|
|
35
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
36
|
+
var import_prettify = __toESM(require("./prettify"));
|
|
37
|
+
const ts2js = (file) => {
|
|
38
|
+
const result = (0, import_core.transform)(file, {
|
|
39
|
+
cwd: (0, import_project_config.getPaths)().base,
|
|
40
|
+
configFile: false,
|
|
41
|
+
plugins: [
|
|
42
|
+
[
|
|
43
|
+
"@babel/plugin-transform-typescript",
|
|
44
|
+
{
|
|
45
|
+
isTSX: true,
|
|
46
|
+
allExtensions: true
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
],
|
|
50
|
+
retainLines: true
|
|
51
|
+
});
|
|
52
|
+
if (result?.code) {
|
|
53
|
+
return (0, import_prettify.default)(result.code);
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
};
|
|
57
|
+
var ts2js_default = ts2js;
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cedarjs/codemods",
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"description": "Codemods to ease upgrading a CedarJS Project",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
8
|
+
"directory": "packages/codemods"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"type": "commonjs",
|
|
12
|
+
"bin": "./dist/codemods.js",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsx ./build.mts",
|
|
18
|
+
"build:pack": "yarn pack -o cedar-codemods.tgz",
|
|
19
|
+
"build:watch": "nodemon --watch src --ignore dist --exec \"yarn build\"",
|
|
20
|
+
"check:package": "yarn publint",
|
|
21
|
+
"generate:codemod": "yarn node ./tasks/generateCodemod/generateCodemod.mjs",
|
|
22
|
+
"prepublishOnly": "yarn build",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"test:watch": "vitest watch"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@babel/cli": "7.26.4",
|
|
28
|
+
"@babel/core": "^7.26.10",
|
|
29
|
+
"@babel/parser": "7.26.10",
|
|
30
|
+
"@babel/plugin-transform-typescript": "^7.26.8",
|
|
31
|
+
"@babel/runtime-corejs3": "7.26.10",
|
|
32
|
+
"@babel/traverse": "7.26.10",
|
|
33
|
+
"@cedarjs/project-config": "0.0.4",
|
|
34
|
+
"@svgr/core": "8.1.0",
|
|
35
|
+
"@svgr/plugin-jsx": "8.1.0",
|
|
36
|
+
"@vscode/ripgrep": "1.15.9",
|
|
37
|
+
"@whatwg-node/fetch": "0.9.21",
|
|
38
|
+
"cheerio": "1.0.0",
|
|
39
|
+
"core-js": "3.42.0",
|
|
40
|
+
"deepmerge": "4.3.1",
|
|
41
|
+
"execa": "5.1.1",
|
|
42
|
+
"fast-glob": "3.3.2",
|
|
43
|
+
"graphql": "16.9.0",
|
|
44
|
+
"jscodeshift": "17.0.0",
|
|
45
|
+
"pascalcase": "1.0.0",
|
|
46
|
+
"prettier": "3.5.3",
|
|
47
|
+
"tasuku": "2.0.1",
|
|
48
|
+
"typescript": "5.6.2",
|
|
49
|
+
"yargs": "17.7.2"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@cedarjs/framework-tools": "0.0.4",
|
|
53
|
+
"@types/babel__core": "7.20.5",
|
|
54
|
+
"@types/fs-extra": "11.0.4",
|
|
55
|
+
"@types/jscodeshift": "0.12.0",
|
|
56
|
+
"@types/yargs": "17.0.33",
|
|
57
|
+
"fs-extra": "11.2.0",
|
|
58
|
+
"publint": "0.3.11",
|
|
59
|
+
"tempy": "1.0.1",
|
|
60
|
+
"tsx": "4.19.3",
|
|
61
|
+
"vitest": "2.1.9"
|
|
62
|
+
},
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public"
|
|
65
|
+
},
|
|
66
|
+
"gitHead": "5b4f77f985bd86ee31ee7338312627accf0cb85b"
|
|
67
|
+
}
|