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.
@@ -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
- .find(jscodeshift.ArrayExpression)
31
- .forEach(p => p.get('elements').push(newObject))
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-catalyst-app-internal",
3
3
  "bin": "scripts/cli.cjs",
4
- "version": "0.0.1-beta.31",
4
+ "version": "0.0.1-beta.33",
5
5
  "description": "cli package to scaffold Catalyst application",
6
6
  "dependencies": {
7
7
  "commander": "^8.2.0",
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
- console.log("finalPath", __dirname)
32
- execSync(`node ../codemod/createNewRoute.js`, { stdio: "inherit" })
31
+ const createRoutePath = path.join(__dirname, "../codemod/createNewRoute.js")
32
+ execSync(`node ${createRoutePath}`, { stdio: "inherit" })
33
33
  return
34
34
  }
35
35