@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,45 @@
|
|
|
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 convertJsToJsx_exports = {};
|
|
30
|
+
__export(convertJsToJsx_exports, {
|
|
31
|
+
default: () => transform
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(convertJsToJsx_exports);
|
|
34
|
+
var import_fs = __toESM(require("fs"));
|
|
35
|
+
function transform(file, api) {
|
|
36
|
+
const j = api.jscodeshift;
|
|
37
|
+
const ast = j(file.source);
|
|
38
|
+
const containsJSX = ast.find(j.JSXElement).length !== 0 || ast.find(j.JSXFragment).length !== 0 || ast.find(j.JSXText).length !== 0;
|
|
39
|
+
if (containsJSX) {
|
|
40
|
+
import_fs.default.renameSync(
|
|
41
|
+
file.path,
|
|
42
|
+
file.path.substring(0, file.path.lastIndexOf(".")) + ".jsx"
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 convertJsToJsx_yargs_exports = {};
|
|
30
|
+
__export(convertJsToJsx_yargs_exports, {
|
|
31
|
+
command: () => command,
|
|
32
|
+
description: () => description,
|
|
33
|
+
handler: () => handler
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(convertJsToJsx_yargs_exports);
|
|
36
|
+
var import_path = __toESM(require("path"));
|
|
37
|
+
var import_fast_glob = __toESM(require("fast-glob"));
|
|
38
|
+
var import_tasuku = __toESM(require("tasuku"));
|
|
39
|
+
var import_runTransform = __toESM(require("../../../lib/runTransform"));
|
|
40
|
+
const command = "convert-js-to-jsx";
|
|
41
|
+
const description = "(v5.x.x->v6.x.x) Converts web components from .js to .jsx";
|
|
42
|
+
const handler = () => {
|
|
43
|
+
(0, import_tasuku.default)("Convert Js To Jsx", async ({ setOutput }) => {
|
|
44
|
+
await (0, import_runTransform.default)({
|
|
45
|
+
transformPath: import_path.default.join(__dirname, "convertJsToJsx.js"),
|
|
46
|
+
// All files in web/src that are .js
|
|
47
|
+
targetPaths: import_fast_glob.default.sync("web/src/**/*.js")
|
|
48
|
+
});
|
|
49
|
+
setOutput(
|
|
50
|
+
"All done! Your file contents have not been changed just the extension."
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
command,
|
|
57
|
+
description,
|
|
58
|
+
handler
|
|
59
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var entryClientNullCheck_exports = {};
|
|
20
|
+
__export(entryClientNullCheck_exports, {
|
|
21
|
+
default: () => transform
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(entryClientNullCheck_exports);
|
|
24
|
+
function transform(file, api) {
|
|
25
|
+
const j = api.jscodeshift;
|
|
26
|
+
const ast = j(file.source);
|
|
27
|
+
const node = ast.find(j.VariableDeclaration, {
|
|
28
|
+
declarations: [{ id: { name: "redwoodAppElement" } }]
|
|
29
|
+
});
|
|
30
|
+
if (node.length === 0) {
|
|
31
|
+
console.warn(
|
|
32
|
+
"\nCould not find 'redwoodAppElement' variable declaration. Please make the necessary changes to your 'web/src/index.js' file manually.\n"
|
|
33
|
+
);
|
|
34
|
+
return file.source;
|
|
35
|
+
}
|
|
36
|
+
node.insertAfter(
|
|
37
|
+
j.ifStatement(
|
|
38
|
+
j.unaryExpression("!", j.identifier("redwoodAppElement")),
|
|
39
|
+
j.blockStatement([
|
|
40
|
+
j.throwStatement(
|
|
41
|
+
j.newExpression(j.identifier("Error"), [
|
|
42
|
+
j.literal(
|
|
43
|
+
"Could not find an element with ID 'redwood-app'. Please ensure it exists in your 'web/src/index.html' file."
|
|
44
|
+
)
|
|
45
|
+
])
|
|
46
|
+
)
|
|
47
|
+
])
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
return ast.toSource();
|
|
51
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 entryClientNullCheck_yargs_exports = {};
|
|
30
|
+
__export(entryClientNullCheck_yargs_exports, {
|
|
31
|
+
command: () => command,
|
|
32
|
+
description: () => description,
|
|
33
|
+
handler: () => handler
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(entryClientNullCheck_yargs_exports);
|
|
36
|
+
var import_path = __toESM(require("path"));
|
|
37
|
+
var import_fast_glob = __toESM(require("fast-glob"));
|
|
38
|
+
var import_tasuku = __toESM(require("tasuku"));
|
|
39
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
40
|
+
var import_runTransform = __toESM(require("../../../lib/runTransform"));
|
|
41
|
+
const command = "entry-client-null-check";
|
|
42
|
+
const description = "(v6.x.x->v6.x.x) Converts world to bazinga";
|
|
43
|
+
const handler = () => {
|
|
44
|
+
(0, import_tasuku.default)("Entry Client Null Check", async ({ setOutput }) => {
|
|
45
|
+
await (0, import_runTransform.default)({
|
|
46
|
+
transformPath: import_path.default.join(__dirname, "entryClientNullCheck.js"),
|
|
47
|
+
targetPaths: import_fast_glob.default.sync("entry.client.{jsx,tsx}", {
|
|
48
|
+
cwd: (0, import_project_config.getPaths)().web.src,
|
|
49
|
+
absolute: true
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
setOutput("All done! Run `yarn rw lint --fix` to prettify your code");
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
command,
|
|
58
|
+
description,
|
|
59
|
+
handler
|
|
60
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var processEnvDotNotation_exports = {};
|
|
20
|
+
__export(processEnvDotNotation_exports, {
|
|
21
|
+
default: () => transform
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(processEnvDotNotation_exports);
|
|
24
|
+
function transform(file, api) {
|
|
25
|
+
const j = api.jscodeshift;
|
|
26
|
+
const root = j(file.source);
|
|
27
|
+
root.find(j.MemberExpression, {
|
|
28
|
+
object: {
|
|
29
|
+
type: "MemberExpression",
|
|
30
|
+
object: { name: "process" },
|
|
31
|
+
property: { name: "env" }
|
|
32
|
+
}
|
|
33
|
+
}).forEach((path) => {
|
|
34
|
+
const envVarName = path.value.property;
|
|
35
|
+
if (j.StringLiteral.check(envVarName)) {
|
|
36
|
+
const dotNotation = j.memberExpression(
|
|
37
|
+
j.memberExpression(j.identifier("process"), j.identifier("env")),
|
|
38
|
+
j.identifier(envVarName.value)
|
|
39
|
+
);
|
|
40
|
+
j(path).replaceWith(dotNotation);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return root.toSource();
|
|
44
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 processEnvDotNotation_yargs_exports = {};
|
|
30
|
+
__export(processEnvDotNotation_yargs_exports, {
|
|
31
|
+
command: () => command,
|
|
32
|
+
description: () => description,
|
|
33
|
+
handler: () => handler
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(processEnvDotNotation_yargs_exports);
|
|
36
|
+
var import_path = __toESM(require("path"));
|
|
37
|
+
var import_fast_glob = __toESM(require("fast-glob"));
|
|
38
|
+
var import_tasuku = __toESM(require("tasuku"));
|
|
39
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
40
|
+
var import_runTransform = __toESM(require("../../../lib/runTransform"));
|
|
41
|
+
const command = "process-env-dot-notation";
|
|
42
|
+
const description = "(v6.x.x->v6.x.x) Converts world to bazinga";
|
|
43
|
+
const handler = () => {
|
|
44
|
+
(0, import_tasuku.default)("Process Env Dot Notation", async ({ setOutput }) => {
|
|
45
|
+
await (0, import_runTransform.default)({
|
|
46
|
+
transformPath: import_path.default.join(__dirname, "processEnvDotNotation.js"),
|
|
47
|
+
targetPaths: import_fast_glob.default.sync("**/*.{js,jsx,tsx}", {
|
|
48
|
+
cwd: (0, import_project_config.getPaths)().web.src,
|
|
49
|
+
absolute: true
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
setOutput("All done! Run `yarn rw lint --fix` to prettify your code");
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
command,
|
|
58
|
+
description,
|
|
59
|
+
handler
|
|
60
|
+
});
|
|
@@ -0,0 +1,154 @@
|
|
|
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 replaceComponentSvgs_exports = {};
|
|
30
|
+
__export(replaceComponentSvgs_exports, {
|
|
31
|
+
default: () => transform
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(replaceComponentSvgs_exports);
|
|
34
|
+
var import_promises = __toESM(require("fs/promises"));
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_core = require("@svgr/core");
|
|
37
|
+
var import_pascalcase = __toESM(require("pascalcase"));
|
|
38
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
39
|
+
async function convertSvgToReactComponent(svgFilePath, outputPath, componentName, typescript) {
|
|
40
|
+
const svgContents = await import_promises.default.readFile(svgFilePath, "utf-8");
|
|
41
|
+
const jsCode = await (0, import_core.transform)(
|
|
42
|
+
svgContents,
|
|
43
|
+
{
|
|
44
|
+
jsxRuntime: "automatic",
|
|
45
|
+
plugins: ["@svgr/plugin-jsx"],
|
|
46
|
+
typescript
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
componentName
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
await import_promises.default.writeFile(outputPath, jsCode);
|
|
53
|
+
console.log();
|
|
54
|
+
console.log(`SVG converted to React component: ${outputPath}`);
|
|
55
|
+
}
|
|
56
|
+
async function transform(file, api) {
|
|
57
|
+
const j = api.jscodeshift;
|
|
58
|
+
const root = j(file.source);
|
|
59
|
+
const isTS = file.path.endsWith(".tsx");
|
|
60
|
+
const svgImports = root.find(j.ImportDeclaration).filter((path2) => {
|
|
61
|
+
const importPath = path2.node.source.value;
|
|
62
|
+
return importPath.endsWith(".svg");
|
|
63
|
+
});
|
|
64
|
+
const svgNamedExports = root.find(j.ExportNamedDeclaration).filter((path2) => {
|
|
65
|
+
const source = path2.value.source;
|
|
66
|
+
return Boolean(
|
|
67
|
+
source && typeof source.value === "string" && source.value.endsWith(".svg")
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
const svgsToConvert = [];
|
|
71
|
+
const importOrExportStatementsWithSvg = [
|
|
72
|
+
...svgImports.paths(),
|
|
73
|
+
...svgNamedExports.paths()
|
|
74
|
+
];
|
|
75
|
+
importOrExportStatementsWithSvg.forEach((declaration) => {
|
|
76
|
+
const specifiers = declaration.node.specifiers;
|
|
77
|
+
specifiers?.forEach((specifier) => {
|
|
78
|
+
let svgName = "";
|
|
79
|
+
if (specifier.type === "ExportSpecifier") {
|
|
80
|
+
svgName = specifier.exported.name;
|
|
81
|
+
} else if (specifier.type === "ImportDefaultSpecifier") {
|
|
82
|
+
if (!specifier.local) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
svgName = specifier.local.name;
|
|
86
|
+
}
|
|
87
|
+
const sourcePath = declaration.node.source?.value;
|
|
88
|
+
if (!sourcePath) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const currentFolder = import_path.default.dirname(file.path);
|
|
92
|
+
let pathToSvgFile = import_path.default.resolve(currentFolder, sourcePath);
|
|
93
|
+
if (sourcePath.startsWith("src/")) {
|
|
94
|
+
pathToSvgFile = sourcePath.replace("src/", (0, import_project_config.getPaths)().web.src + "/");
|
|
95
|
+
}
|
|
96
|
+
const svgsUsedAsComponent = root.findJSXElements(svgName);
|
|
97
|
+
const svgsUsedAsRenderProp = root.find(j.JSXExpressionContainer, {
|
|
98
|
+
expression: {
|
|
99
|
+
type: "Identifier",
|
|
100
|
+
name: svgName
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const svgsReexported = root.find(j.ExportSpecifier).filter((path2) => {
|
|
104
|
+
return path2.value.local?.name === svgName || path2.value.exported.name === svgName;
|
|
105
|
+
});
|
|
106
|
+
const selectedSvgs = [
|
|
107
|
+
...svgsUsedAsComponent.paths(),
|
|
108
|
+
...svgsUsedAsRenderProp.paths(),
|
|
109
|
+
...svgsReexported.paths()
|
|
110
|
+
];
|
|
111
|
+
selectedSvgs.forEach(() => {
|
|
112
|
+
svgsToConvert.push({
|
|
113
|
+
filePath: pathToSvgFile,
|
|
114
|
+
importSourcePath: declaration.node.source
|
|
115
|
+
// imports are all strings in this case
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
if (svgsToConvert.length > 0) {
|
|
121
|
+
await Promise.all(
|
|
122
|
+
svgsToConvert.map(async (svg) => {
|
|
123
|
+
const svgFileNameWithoutExtension = import_path.default.basename(
|
|
124
|
+
svg.filePath,
|
|
125
|
+
import_path.default.extname(svg.filePath)
|
|
126
|
+
);
|
|
127
|
+
const componentName = (0, import_pascalcase.default)(svgFileNameWithoutExtension);
|
|
128
|
+
const newFileName = `${componentName}SVG`;
|
|
129
|
+
const outputPath = import_path.default.join(
|
|
130
|
+
import_path.default.dirname(svg.filePath),
|
|
131
|
+
`${newFileName}.${isTS ? "tsx" : "jsx"}`
|
|
132
|
+
);
|
|
133
|
+
try {
|
|
134
|
+
await convertSvgToReactComponent(
|
|
135
|
+
svg.filePath,
|
|
136
|
+
outputPath,
|
|
137
|
+
componentName,
|
|
138
|
+
isTS
|
|
139
|
+
);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error(
|
|
142
|
+
`Error converting ${svg.filePath} to React component: ${error.message}`
|
|
143
|
+
);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
svg.importSourcePath.value = svg.importSourcePath.value.replace(
|
|
147
|
+
`${svgFileNameWithoutExtension}${import_path.default.extname(svg.filePath)}`,
|
|
148
|
+
newFileName
|
|
149
|
+
);
|
|
150
|
+
})
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return root.toSource();
|
|
154
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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 replaceComponentSvgs_yargs_exports = {};
|
|
30
|
+
__export(replaceComponentSvgs_yargs_exports, {
|
|
31
|
+
command: () => command,
|
|
32
|
+
description: () => description,
|
|
33
|
+
handler: () => handler
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(replaceComponentSvgs_yargs_exports);
|
|
36
|
+
var import_path = __toESM(require("path"));
|
|
37
|
+
var import_fast_glob = __toESM(require("fast-glob"));
|
|
38
|
+
var import_tasuku = __toESM(require("tasuku"));
|
|
39
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
40
|
+
var import_runTransform = __toESM(require("../../../lib/runTransform"));
|
|
41
|
+
const command = "replace-component-svgs";
|
|
42
|
+
const description = "(v5.x.x->v6.x.x) Converts imported SVGs used as components to React components";
|
|
43
|
+
const handler = () => {
|
|
44
|
+
(0, import_tasuku.default)("Replace Component Svgs", async ({ setOutput }) => {
|
|
45
|
+
const targetPaths = import_fast_glob.default.sync("**/*.{js,jsx,tsx}", {
|
|
46
|
+
cwd: (0, import_project_config.getPaths)().web.src,
|
|
47
|
+
absolute: true
|
|
48
|
+
});
|
|
49
|
+
await (0, import_runTransform.default)({
|
|
50
|
+
transformPath: import_path.default.join(__dirname, "replaceComponentSvgs.js"),
|
|
51
|
+
targetPaths
|
|
52
|
+
});
|
|
53
|
+
setOutput("All done! Run `yarn rw lint --fix` to prettify your code");
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
command,
|
|
59
|
+
description,
|
|
60
|
+
handler
|
|
61
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
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 updateDevFatalErrorPage_exports = {};
|
|
30
|
+
__export(updateDevFatalErrorPage_exports, {
|
|
31
|
+
updateDevFatalErrorPage: () => updateDevFatalErrorPage
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(updateDevFatalErrorPage_exports);
|
|
34
|
+
var import_fs = __toESM(require("fs"));
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_fetch = require("@whatwg-node/fetch");
|
|
37
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
+
const updateDevFatalErrorPage = async () => {
|
|
39
|
+
const rwPaths = (0, import_project_config.getPaths)();
|
|
40
|
+
const webFatalErrorPagesDir = import_path.default.join(rwPaths.web.pages, "FatalErrorPage");
|
|
41
|
+
const filename = import_path.default.join(webFatalErrorPagesDir, "FatalErrorPage");
|
|
42
|
+
const url = "https://raw.githubusercontent.com/cedarjs/cedar/0acd00946f9ad235320ea9b0b9a380d366e8936f/packages/create-cedar-app/templates/ts/web/src/pages/FatalErrorPage/FatalErrorPage.tsx";
|
|
43
|
+
const isTsxPage = import_fs.default.existsSync(
|
|
44
|
+
import_path.default.join(webFatalErrorPagesDir, "FatalErrorPage.tsx")
|
|
45
|
+
);
|
|
46
|
+
const isJsxPage = import_fs.default.existsSync(
|
|
47
|
+
import_path.default.join(webFatalErrorPagesDir, "FatalErrorPage.jsx")
|
|
48
|
+
);
|
|
49
|
+
const ext = isTsxPage ? "tsx" : isJsxPage ? "jsx" : "js";
|
|
50
|
+
const res = await (0, import_fetch.fetch)(url);
|
|
51
|
+
const text = await res.text();
|
|
52
|
+
const newFatalErrorPage = `${filename}.${ext}`;
|
|
53
|
+
import_fs.default.writeFileSync(newFatalErrorPage, text);
|
|
54
|
+
};
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
updateDevFatalErrorPage
|
|
58
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
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 updateDevFatalErrorPage_yargs_exports = {};
|
|
30
|
+
__export(updateDevFatalErrorPage_yargs_exports, {
|
|
31
|
+
command: () => command,
|
|
32
|
+
description: () => description,
|
|
33
|
+
handler: () => handler
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(updateDevFatalErrorPage_yargs_exports);
|
|
36
|
+
var import_tasuku = __toESM(require("tasuku"));
|
|
37
|
+
var import_updateDevFatalErrorPage = require("./updateDevFatalErrorPage");
|
|
38
|
+
const command = "update-dev-fatal-error-page";
|
|
39
|
+
const description = "(v5.x.x->v6.x.x) Update Fatal Error Page with development version from the create-cedar-app template";
|
|
40
|
+
const handler = () => {
|
|
41
|
+
(0, import_tasuku.default)("Update Fatal Error Page with regular import", async () => {
|
|
42
|
+
await (0, import_updateDevFatalErrorPage.updateDevFatalErrorPage)();
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
command,
|
|
48
|
+
description,
|
|
49
|
+
handler
|
|
50
|
+
});
|