create-catalyst-app-internal 0.0.1-beta.31 → 0.0.1-beta.33
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/codemod/createRoute.js +6 -2
- package/package.json +1 -1
- package/scripts/cli.cjs +2 -2
package/codemod/createRoute.js
CHANGED
|
@@ -27,8 +27,12 @@ module.exports = function (fileInfo, api, options) {
|
|
|
27
27
|
root.find(jscodeshift.Program).get('body', 0).insertBefore(`import ${componentName} from '@containers/${componentName}/${componentName}'`);
|
|
28
28
|
|
|
29
29
|
root.find(jscodeshift.VariableDeclarator, { id: { name: 'routes' } })
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
.forEach(path => {
|
|
31
|
+
// Ensure we are modifying the top-level array expression
|
|
32
|
+
if (path.value.init.type === 'ArrayExpression') {
|
|
33
|
+
path.value.init.elements.push(newObject);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
32
36
|
|
|
33
37
|
|
|
34
38
|
console.log(pc.green('\nNew route added successfully.'));
|
package/package.json
CHANGED
package/scripts/cli.cjs
CHANGED
|
@@ -28,8 +28,8 @@ const program = new Commander.Command()
|
|
|
28
28
|
.action(async (folderName = null, cmd) => {
|
|
29
29
|
try {
|
|
30
30
|
if (process.argv.includes("new-route")) {
|
|
31
|
-
|
|
32
|
-
execSync(`node
|
|
31
|
+
const createRoutePath = path.join(__dirname, "../codemod/createNewRoute.js")
|
|
32
|
+
execSync(`node ${createRoutePath}`, { stdio: "inherit" })
|
|
33
33
|
return
|
|
34
34
|
}
|
|
35
35
|
|