create-catalyst-app 0.1.0-beta.2 → 0.1.0-beta.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.
@@ -4,7 +4,7 @@ const pc = require("picocolors")
4
4
 
5
5
  // Function to create component using given input
6
6
  function createNewComponent({ componentName, containersDir }) {
7
- const componentPath = path.join(containersDir, `${componentName}/${componentName}.js`)
7
+ const componentPath = `${containersDir}${path.sep}${componentName}${path.sep}${componentName}.js`
8
8
 
9
9
  // Component template
10
10
  const componentTemplate = `import React from 'react';
@@ -27,7 +27,7 @@ function createNewComponent({ componentName, containersDir }) {
27
27
 
28
28
  // Function to create rtk reducer file using given input
29
29
  function createRTKReducerFile({ componentName, containersDir, reducerName }) {
30
- const reducerPath = path.join(containersDir, `${componentName}/reducer.js`)
30
+ const reducerPath = `${containersDir}${path.sep}${componentName}${path.sep}reducer.js`
31
31
 
32
32
  // rtk reducer template
33
33
  const reducerTemplate = `import { createSlice } from "@reduxjs/toolkit"
@@ -56,7 +56,7 @@ export const ${reducerName}Reducer = appSlice.reducer
56
56
 
57
57
  // Function to create redux action file using given input
58
58
  function createReduxActionFile({ componentName, containersDir, reducerName }) {
59
- const actionsPath = path.join(containersDir, `${componentName}/actions.js`)
59
+ const actionsPath = `${containersDir}${path.sep}${componentName}${path.sep}actions.js`
60
60
 
61
61
  // redux action template
62
62
  const actionTemplate = `const createActionTypes = (prefix, actionTypeList = []) => {
@@ -84,7 +84,7 @@ export const reduxTest = () => {
84
84
 
85
85
  // Function to create redux reducer file using given input
86
86
  function createReduxReducerFile({ componentName, containersDir, reducerName }) {
87
- const reducerPath = path.join(containersDir, `${componentName}/reducer.js`)
87
+ const reducerPath = `${containersDir}${path.sep}${componentName}${path.sep}reducer.js`
88
88
 
89
89
  // redux reducer template
90
90
  const reducerTemplate = `import { ${reducerName}Actions } from "./actions"
@@ -1,7 +1,9 @@
1
1
  const fs = require("fs")
2
2
  const path = require("path")
3
3
  const pc = require("picocolors")
4
- const { execSync } = require("child_process")
4
+ const { execFileSync } = require("child_process")
5
+
6
+ const executable = (command) => (process.platform === "win32" ? `${command}.cmd` : command)
5
7
 
6
8
  // validates router path
7
9
  function validatePath(path) {
@@ -60,14 +62,40 @@ function createDirectory({ componentName, containersDir }) {
60
62
 
61
63
  // adds route object inside src/js/route/index.js file
62
64
  function createNewRoute({ componentName, routePath, routeTransformerPath }) {
63
- const command = `jscodeshift --silent -t ${routeTransformerPath} --routePath ${routePath} --componentName ${componentName} src/js/routes/index.js`
64
- execSync(command, { stdio: "inherit" })
65
+ execFileSync(
66
+ executable("jscodeshift"),
67
+ [
68
+ "--silent",
69
+ "-t",
70
+ routeTransformerPath,
71
+ "--routePath",
72
+ routePath,
73
+ "--componentName",
74
+ componentName,
75
+ "src/js/routes/index.js",
76
+ ],
77
+ { stdio: "inherit" }
78
+ )
65
79
  }
66
80
 
67
81
  // adds newly created reducer into src/js/store/index.js file
68
82
  function createReducerEntryInStore({ componentName, routePath, reducerTransformerPath, reducerName }) {
69
- const command = `jscodeshift --silent -t ${reducerTransformerPath} --reducerName ${reducerName} --routePath ${routePath} --componentName ${componentName} src/js/store/index.js`
70
- execSync(command, { stdio: "inherit" })
83
+ execFileSync(
84
+ executable("jscodeshift"),
85
+ [
86
+ "--silent",
87
+ "-t",
88
+ reducerTransformerPath,
89
+ "--reducerName",
90
+ reducerName,
91
+ "--routePath",
92
+ routePath,
93
+ "--componentName",
94
+ componentName,
95
+ "src/js/store/index.js",
96
+ ],
97
+ { stdio: "inherit" }
98
+ )
71
99
  }
72
100
 
73
101
  // converts string to camel case
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-catalyst-app",
3
3
  "bin": "scripts/cli.cjs",
4
- "version": "0.1.0-beta.2",
4
+ "version": "0.1.0-beta.3",
5
5
  "description": "cli package to scaffold Catalyst application",
6
6
  "repository": {
7
7
  "type": "git",
@@ -18,7 +18,7 @@
18
18
  "jscodeshift": "^0.16.0",
19
19
  "picocolors": "^0.1.0",
20
20
  "prompts": "^2.4.0",
21
- "tar": "^6.2.1",
21
+ "tar": "^7.5.15",
22
22
  "validate-npm-package-name": "^5.0.0"
23
23
  },
24
24
  "devDependencies": {
package/scripts/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const { execSync } = require("child_process")
2
+ const { execFileSync, execSync } = require("child_process")
3
3
  const Commander = require("commander")
4
4
  const { Option } = require("commander")
5
5
  const prompts = require("prompts")
@@ -10,6 +10,7 @@ const fs = require("fs")
10
10
  var validate = require("validate-npm-package-name")
11
11
  const packageJson = require("../package.json")
12
12
  const packageRoot = path.join(__dirname, "..")
13
+ const executable = (command) => (process.platform === "win32" ? `${command}.cmd` : command)
13
14
 
14
15
  let projectName = null
15
16
  const program = new Commander.Command()
@@ -160,17 +161,25 @@ const program = new Commander.Command()
160
161
  })()
161
162
  function packNpmPackage(packageName, packageVersion, tempDir) {
162
163
  const tarballFileName = `${packageName}-${packageVersion}.tgz`
163
- const tarballFilePath = path.join(tempDir, tarballFileName)
164
+ const tarballFilePath = `${tempDir}${path.sep}${tarballFileName}`
164
165
 
165
166
  try {
166
167
  if (process.env.CREATE_CATALYST_APP_PACK_SOURCE === "local") {
167
- execSync(`npm pack --pack-destination="${tempDir}" --silent`, {
168
- cwd: packageRoot,
169
- })
168
+ execFileSync(
169
+ executable("npm"),
170
+ ["pack", `--pack-destination=${tempDir}`, "--silent"],
171
+ {
172
+ cwd: packageRoot,
173
+ }
174
+ )
170
175
  } else {
171
- execSync(`npm pack ${packageName}@${packageVersion} --silent`, {
172
- cwd: tempDir,
173
- })
176
+ execFileSync(
177
+ executable("npm"),
178
+ ["pack", `${packageName}@${packageVersion}`, "--silent"],
179
+ {
180
+ cwd: tempDir,
181
+ }
182
+ )
174
183
  }
175
184
 
176
185
  return tarballFilePath
@@ -193,22 +202,20 @@ const program = new Commander.Command()
193
202
  tar.extract({
194
203
  file: packageFilePath,
195
204
  sync: true,
196
- filter: (path, entry) => {
197
- return subDirectoriesToExtract.reduce((acc, item) => {
198
- return acc || path.startsWith(item)
199
- }, false)
200
- },
201
205
  cwd: path.join(process.cwd()),
202
- onentry: (entry) => {
206
+ filter: (entryPath, entry) => {
207
+ const shouldExtract = subDirectoriesToExtract.reduce((acc, item) => {
208
+ return acc || entryPath.startsWith(item)
209
+ }, false)
210
+ if (!shouldExtract) return false
203
211
  if (entry.path.startsWith(commonCodeDirectory)) {
204
212
  entry.path = entry.path.replace(commonCodeDirectory, extractionDestination)
205
- }
206
- if (entry.path.startsWith(selectedTemplateCode)) {
213
+ } else if (entry.path.startsWith(selectedTemplateCode)) {
207
214
  entry.path = entry.path.replace(selectedTemplateCode, extractionDestination)
208
- }
209
- if (entry.path.startsWith(tailwindCodeDirectory)) {
215
+ } else if (entry.path.startsWith(tailwindCodeDirectory)) {
210
216
  entry.path = entry.path.replace(tailwindCodeDirectory, extractionDestination)
211
217
  }
218
+ return true
212
219
  },
213
220
  })
214
221
  } catch (e) {
@@ -261,12 +268,12 @@ program
261
268
  program.parse(process.argv)
262
269
 
263
270
  function runMcpSetup(mcpDir, cwd = process.cwd()) {
264
- const pkgPath = path.join(mcpDir, "package.json")
271
+ const pkgPath = `${mcpDir}${path.sep}package.json`
265
272
  const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"))
266
273
  pkg.dependencies["better-sqlite3"] = "^12.8.0"
267
274
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2))
268
275
 
269
- const mcpNodeModules = path.join(mcpDir, "node_modules")
276
+ const mcpNodeModules = `${mcpDir}${path.sep}node_modules`
270
277
  let needsInstall = !fs.existsSync(mcpNodeModules)
271
278
 
272
279
  if (!needsInstall) {
@@ -284,7 +291,7 @@ function runMcpSetup(mcpDir, cwd = process.cwd()) {
284
291
  execSync("npm install", { cwd: mcpDir, stdio: "inherit" })
285
292
  }
286
293
 
287
- execSync(`node ${path.join(mcpDir, "setup.js")}`, { cwd, stdio: "inherit" })
294
+ execFileSync(process.execPath, [`${mcpDir}${path.sep}setup.js`], { cwd, stdio: "inherit" })
288
295
  }
289
296
 
290
297
  async function promptStateManagement() {
@@ -397,7 +404,7 @@ function validateOptions(cmd) {
397
404
  function deleteDirectory(dirPath) {
398
405
  if (dirPath && fs.existsSync(dirPath)) {
399
406
  fs.readdirSync(dirPath).forEach((file) => {
400
- const currentPath = path.join(dirPath, file)
407
+ const currentPath = `${dirPath}${path.sep}${file}`
401
408
  if (fs.lstatSync(currentPath).isDirectory()) {
402
409
  deleteDirectory(currentPath)
403
410
  } else {
@@ -412,7 +419,7 @@ function deleteDirectory(dirPath) {
412
419
  function createGitignore(projectName) {
413
420
  const gitiIgnorePatterns = ["node_modules", "build", "logs"]
414
421
 
415
- const gitignorePath = path.join(process.cwd(), projectName, ".gitignore")
422
+ const gitignorePath = `${process.cwd()}${path.sep}${projectName}${path.sep}.gitignore`
416
423
 
417
424
  if (fs.existsSync(gitignorePath)) {
418
425
  console.log(".gitignore already exists. Please rename or remove it before running the script.")
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "@loadable/component": "^5.16.3",
28
28
  "@tata1mg/router": "0.0.1-beta.7",
29
- "catalyst-core": "0.1.0-beta.2"
29
+ "catalyst-core": "0.1.0-beta.3"
30
30
  },
31
31
  "devDependencies": {
32
32
  "eslint": "^8.26.0",
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@loadable/component": "^5.16.3",
29
29
  "@tata1mg/router": "0.0.1-beta.7",
30
- "catalyst-core": "0.1.0-beta.2"
30
+ "catalyst-core": "0.1.0-beta.3"
31
31
  },
32
32
  "devDependencies": {
33
33
  "eslint": "^8.26.0",
@@ -29,7 +29,7 @@
29
29
  "@tata1mg/router": "0.0.1-beta.7",
30
30
  "@reduxjs/toolkit": "1.9.3",
31
31
  "react-redux": "^8.1.3",
32
- "catalyst-core": "0.1.0-beta.2"
32
+ "catalyst-core": "0.1.0-beta.3"
33
33
  },
34
34
  "devDependencies": {
35
35
  "eslint": "^8.26.0",
@@ -30,7 +30,7 @@
30
30
  "@tata1mg/router": "0.0.1-beta.7",
31
31
  "@reduxjs/toolkit": "1.9.3",
32
32
  "react-redux": "^8.1.3",
33
- "catalyst-core": "0.1.0-beta.2"
33
+ "catalyst-core": "0.1.0-beta.3"
34
34
  },
35
35
  "devDependencies": {
36
36
  "eslint": "^8.26.0",
@@ -29,7 +29,7 @@
29
29
  "@tata1mg/router": "0.0.1-beta.7",
30
30
  "@reduxjs/toolkit": "1.9.3",
31
31
  "react-redux": "^8.1.3",
32
- "catalyst-core": "0.1.0-beta.2"
32
+ "catalyst-core": "0.1.0-beta.3"
33
33
  },
34
34
  "devDependencies": {
35
35
  "eslint": "^8.26.0",
@@ -30,7 +30,7 @@
30
30
  "@tata1mg/router": "0.0.1-beta.7",
31
31
  "@reduxjs/toolkit": "1.9.3",
32
32
  "react-redux": "^8.1.3",
33
- "catalyst-core": "0.1.0-beta.2"
33
+ "catalyst-core": "0.1.0-beta.3"
34
34
  },
35
35
  "devDependencies": {
36
36
  "eslint": "^8.26.0",