create-catalyst-app-internal 0.0.1-beta.14 → 0.0.1-beta.15

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/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.14",
4
+ "version": "0.0.1-beta.15",
5
5
  "description": "cli package to scaffold Catalyst application",
6
6
  "main": "index.js",
7
7
  "scripts": {
@@ -13,9 +13,11 @@
13
13
  "https": "^1.0.0",
14
14
  "picocolors": "^0.1.0",
15
15
  "prompts": "^2.4.0",
16
- "tar": "6.1.15"
16
+ "tar": "^6.2.1",
17
+ "validate-npm-package-name": "^5.0.0"
17
18
  },
18
19
  "devDependencies": {
19
20
  "prettier": "^3.2.5"
20
- }
21
+ },
22
+ "license": "MIT"
21
23
  }
package/scripts/cli.cjs CHANGED
@@ -3,14 +3,13 @@ const { execSync } = require("child_process")
3
3
  const Commander = require("commander")
4
4
  const { Option } = require("commander")
5
5
  const prompts = require("prompts")
6
- const { red, green, cyan } = require("picocolors")
7
-
8
- const packageJson = require("../package.json")
6
+ const { red, green, cyan, bold } = require("picocolors")
9
7
  const tar = require("tar")
10
8
  const path = require("path")
11
9
  const fs = require("fs")
10
+ var validate = require("validate-npm-package-name")
11
+ const packageJson = require("../package.json")
12
12
 
13
- // Hardcoded branch
14
13
  let projectName = null
15
14
  const program = new Commander.Command()
16
15
  .version(packageJson.version)
@@ -31,11 +30,21 @@ const program = new Commander.Command()
31
30
  // Use options provided through commander or prompt the user
32
31
  validateOptions(cmd)
33
32
  const projectName = folderName || (await promptProjectName())
33
+ let isNameValid = validate(projectName)
34
+ if (!isNameValid.validForNewPackages) {
35
+ isNameValid?.warnings?.forEach?.((item) => console.log(red(item)))
36
+ isNameValid?.errors?.forEach?.((item) => console.log(red(item)))
37
+ process.exit(1)
38
+ }
39
+ let projectPath = path.join(process.cwd(), projectName)
40
+ if (fs.existsSync(projectPath)) {
41
+ console.log(red(`${projectName} already exists, try again.`))
42
+ process.exit(1)
43
+ }
34
44
  const language = "js"
35
45
  const projectDescription = await promptDescription()
36
46
  const stateManagement = cmd.stateManagement || (await promptStateManagement())
37
47
 
38
-
39
48
  // Define mapping of options to repository suffixes
40
49
  const repositorySuffixes = {
41
50
  js: "js",
@@ -53,33 +62,41 @@ const program = new Commander.Command()
53
62
  const subDirectoriesToExtract = [commonCodeDirectory, selectedTemplateCode]
54
63
  const extractionDestination = `/${projectName}/`
55
64
  let tempDir
56
- ; (() => {
57
- try {
58
- let projectPath = path.join(process.cwd(), projectName);
59
-
60
- if(fs.existsSync(projectPath)){
61
- console.log(`${projectName} already exists, try again.`)
62
- process.exit(1)
63
- }
64
- tempDir = createTempDir()
65
-
66
- const packageFilePath = packNpmPackage(packageName, packageVersion, tempDir)
67
-
68
- extractSubdirectory(packageFilePath)
69
- createGitignore(projectName)
70
-
71
- execSync(
72
- `cd ${projectName} && npm i && npm pkg set name=${projectName} ${projectDescription ? `description="${projectDescription}"` : ""} && git init --quiet`,
73
- { stdio: "inherit" }
74
- )
75
- deleteDirectory(tempDir)
76
- } catch (error) {
77
- deleteDirectory(tempDir)
78
- console.error(`Error: ${error.message}`)
79
- process.exit(1)
80
- }
81
- })()
65
+ ;(() => {
66
+ try {
67
+ tempDir = createTempDir()
68
+
69
+ const packageFilePath = packNpmPackage(packageName, packageVersion, tempDir)
70
+
71
+ extractSubdirectory(packageFilePath)
72
+ createGitignore(projectName)
82
73
 
74
+ execSync(
75
+ `cd ${projectName} && npm i && npm pkg set name=${projectName} ${projectDescription ? `description="${projectDescription}"` : ""} && git init --quiet && git add . && git commit -m "initial commit from Create Catalyst App"`,
76
+ { stdio: "inherit" }
77
+ )
78
+
79
+ console.log(`\n${green(bold("Success!"))} created ${projectName} at ${projectPath}`)
80
+ console.log("Inside this directory, you can run the following commands.")
81
+
82
+ console.log(cyan(bold(" \n npm run start")))
83
+ console.log(" Starts the development server ")
84
+
85
+ console.log(cyan(bold("\n npm run build")))
86
+ console.log(" Bundles the app for production ")
87
+
88
+ console.log(cyan(bold("\n npm run serves")))
89
+ console.log(" Serves the production build ")
90
+
91
+ console.log("\nWe suggest you to begin, by running")
92
+ console.log(` ${cyan("cd")} ${projectName} && ${cyan("npm start")} \n\n`)
93
+ } catch (error) {
94
+ console.error(`Error: ${error.message}`)
95
+ process.exit(1)
96
+ } finally {
97
+ deleteDirectory(tempDir)
98
+ }
99
+ })()
83
100
  function packNpmPackage(packageName, packageVersion, tempDir) {
84
101
  const tarballFileName = `${packageName}-${packageVersion}.tgz`
85
102
  const tarballFilePath = path.join(tempDir, tarballFileName)
@@ -174,10 +191,10 @@ async function promptProjectName() {
174
191
  if (!res.path || projectName === "") {
175
192
  console.log(
176
193
  "\nPlease specify the project directory:\n" +
177
- ` ${cyan(program.name())} ${green("<project-directory>")}\n` +
178
- "For example:\n" +
179
- ` ${cyan(program.name())} ${green("my-next-app")}\n\n` +
180
- `Run ${cyan(`${program.name()} --help`)} to see all options.`
194
+ ` ${cyan(program.name())} ${green("<project-directory>")}\n` +
195
+ "For example:\n" +
196
+ ` ${cyan(program.name())} ${green("my-next-app")}\n\n` +
197
+ `Run ${cyan(`${program.name()} --help`)} to see all options.`
181
198
  )
182
199
  process.exit(1)
183
200
  }
@@ -223,20 +240,14 @@ function deleteDirectory(dirPath) {
223
240
 
224
241
  // Function to create a .gitignore file with the hardcoded patterns
225
242
  function createGitignore(projectName) {
243
+ const gitiIgnorePatterns = ["node_modules", "build", "logs"]
226
244
 
227
- const gitiIgnorePatterns = [
228
- 'node_modules',
229
- 'build',
230
- 'logs'
231
- ];
232
-
233
- const gitignorePath = path.join(process.cwd(), projectName, '.gitignore');
245
+ const gitignorePath = path.join(process.cwd(), projectName, ".gitignore")
234
246
 
235
247
  if (fs.existsSync(gitignorePath)) {
236
- console.log('.gitignore already exists. Please rename or remove it before running the script.');
237
- return;
248
+ console.log(".gitignore already exists. Please rename or remove it before running the script.")
249
+ return
238
250
  }
239
251
 
240
- fs.writeFileSync(gitignorePath, gitiIgnorePatterns.join('\n'));
252
+ fs.writeFileSync(gitignorePath, gitiIgnorePatterns.join("\n"))
241
253
  }
242
-
@@ -0,0 +1 @@
1
+ **/build/*
@@ -0,0 +1,38 @@
1
+ {
2
+ "parser": "@babel/eslint-parser",
3
+ "rules": {
4
+ "react-hooks/exhaustive-deps": "error" // Checks effect dependencies
5
+ },
6
+ "env": {
7
+ "browser": true,
8
+ "es6": true,
9
+ "node": true
10
+ },
11
+ "extends": [
12
+ "eslint:recommended",
13
+ "plugin:react/recommended"
14
+ ],
15
+ "parserOptions": {
16
+ "sourceType": "module",
17
+ "ecmaFeatures": {
18
+ "experimentalObjectRestSpread": true,
19
+ "jsx": true
20
+ },
21
+ "babelOptions": {
22
+ "configFile": "./.babelrc"
23
+ },
24
+ "ecmaVersion": 6
25
+ },
26
+ "plugins": [
27
+ "babel",
28
+ "react",
29
+ "react-hooks"
30
+ ],
31
+ "settings": {
32
+ "react": {
33
+ "createClass": "createReactClass",
34
+ "pragma": "React",
35
+ "version": "detect"
36
+ }
37
+ }
38
+ }
@@ -6,10 +6,7 @@
6
6
  "BUILD_OUTPUT_PATH": "build",
7
7
  "PUBLIC_STATIC_ASSET_PATH": "/assets/",
8
8
  "PUBLIC_STATIC_ASSET_URL": "http://localhost:3005",
9
- "NODE_ENV": "development",
10
9
  "API_URL": "",
11
10
  "ANALYZE_BUNDLE": false,
12
- "CLIENT_ENV_VARIABLES": [
13
- "API_URL"
14
- ]
11
+ "CLIENT_ENV_VARIABLES": [ "API_URL" ]
15
12
  }
@@ -7,7 +7,7 @@ import clientRouter from "catalyst-core-internal/router/ClientRouter"
7
7
 
8
8
  window.addEventListener("load", () => {
9
9
  loadableReady(() => {
10
- const { __ROUTER_INITIAL_DATA__: routerInitialData, __INITIAL_STATE__ } = window
10
+ const { __ROUTER_INITIAL_DATA__: routerInitialData } = window
11
11
 
12
12
  const router = clientRouter({ routerInitialState: routerInitialData })
13
13
 
@@ -4,7 +4,10 @@
4
4
  "scripts": {
5
5
  "start": "catalyst start",
6
6
  "build": "catalyst build",
7
- "serve": "catalyst serve"
7
+ "serve": "catalyst serve",
8
+ "lint": "eslint .",
9
+ "devBuild": "catalyst devBuild",
10
+ "devServe": "catalyst devServe"
8
11
  },
9
12
  "_moduleAliases": {
10
13
  "@api": "api.js",
@@ -16,7 +19,14 @@
16
19
  },
17
20
  "dependencies": {
18
21
  "@loadable/component": "^5.16.3",
19
- "@tata1mg/router": "^0.0.1-beta.0",
20
- "catalyst-core-internal": "^0.0.1-beta.7"
22
+ "@tata1mg/router": "^0.0.2-alpha.0",
23
+ "catalyst-core-internal": "^0.0.1-beta.8"
24
+ },
25
+ "devDependencies": {
26
+ "eslint": "^8.26.0",
27
+ "eslint-plugin-babel": "^5.3.1",
28
+ "eslint-plugin-react": "^7.34.1",
29
+ "@babel/eslint-parser": "^7.19.1",
30
+ "eslint-plugin-react-hooks": "^4.6.0"
21
31
  }
22
32
  }
@@ -1,28 +1,41 @@
1
- import React from "react"
2
- import { RouterDataProvider, MetaTag } from "@tata1mg/router"
3
- import App from "@containers/App"
4
- import routes from "./index.js"
1
+ import React from "react";
2
+ import { RouterDataProvider, MetaTag } from "@tata1mg/router";
3
+ import App from "@containers/App";
4
+ import routes from "./index.js";
5
5
 
6
6
  export const preparedRoutes = ({ routerInitialState }) => {
7
- return [
8
- {
9
- element: (
10
- <RouterDataProvider config={{}} initialState={routerInitialState}>
11
- <MetaTag />
12
- <App />
13
- </RouterDataProvider>
14
- ),
15
- children: getRoutes()?.map((route, index) => {
16
- const Component = route.component
17
- return {
18
- ...route,
19
- element: <Component key={index} />,
20
- }
21
- }),
22
- },
23
- ]
24
- }
7
+ const getPreparedRoutes = (routes) => {
8
+ return routes.map((route, index) => {
9
+ const Component = route.component;
10
+ const routeToRender = {
11
+ ...route,
12
+ element: (
13
+ <Component key={index} />
14
+ ),
15
+ };
16
+ if (route.children) {
17
+ routeToRender.children = getPreparedRoutes(route.children);
18
+ }
19
+ return routeToRender;
20
+ });
21
+ };
22
+
23
+ return [
24
+ {
25
+ element: (
26
+ <RouterDataProvider
27
+ config={{}}
28
+ initialState={routerInitialState}
29
+ >
30
+ <MetaTag />
31
+ <App />
32
+ </RouterDataProvider>
33
+ ),
34
+ children: getPreparedRoutes(routes),
35
+ },
36
+ ];
37
+ };
25
38
 
26
39
  export const getRoutes = () => {
27
- return routes
28
- }
40
+ return routes;
41
+ };
@@ -4,7 +4,10 @@
4
4
  "scripts": {
5
5
  "start": "catalyst start",
6
6
  "build": "catalyst build",
7
- "serve": "catalyst serve"
7
+ "serve": "catalyst serve",
8
+ "lint": "eslint .",
9
+ "devBuild": "catalyst devBuild",
10
+ "devServe": "catalyst devServe"
8
11
  },
9
12
  "_moduleAliases": {
10
13
  "@api": "api.js",
@@ -17,9 +20,16 @@
17
20
  },
18
21
  "dependencies": {
19
22
  "@loadable/component": "^5.16.3",
20
- "@tata1mg/router": "^0.0.1-beta.0",
21
- "catalyst-core-internal": "^0.0.1-beta.7",
23
+ "@tata1mg/router": "^0.0.2-alpha.0",
24
+ "catalyst-core-internal": "^0.0.1-beta.8",
22
25
  "@reduxjs/toolkit": "1.9.3",
23
26
  "react-redux": "^8.1.3"
27
+ },
28
+ "devDependencies": {
29
+ "eslint": "^8.26.0",
30
+ "eslint-plugin-babel": "^5.3.1",
31
+ "eslint-plugin-react": "^7.34.1",
32
+ "@babel/eslint-parser": "^7.19.1",
33
+ "eslint-plugin-react-hooks": "^4.6.0"
24
34
  }
25
35
  }
@@ -1,28 +1,42 @@
1
- import React from "react"
2
- import { RouterDataProvider, MetaTag } from "@tata1mg/router"
3
- import App from "@containers/App"
4
- import routes from "./index.js"
1
+ import React from "react";
2
+ import { RouterDataProvider, MetaTag } from "@tata1mg/router";
3
+ import App from "@containers/App";
4
+ import routes from "./index.js";
5
5
 
6
6
  export const preparedRoutes = ({ store, routerInitialState }) => {
7
- return [
8
- {
9
- element: (
10
- <RouterDataProvider config={{}} initialState={routerInitialState} fetcherArgs={{ store }}>
11
- <MetaTag />
12
- <App />
13
- </RouterDataProvider>
14
- ),
15
- children: getRoutes()?.map((route, index) => {
16
- const Component = route.component
17
- return {
18
- ...route,
19
- element: <Component key={index} />,
20
- }
21
- }),
22
- },
23
- ]
24
- }
7
+ const getPreparedRoutes = (routes) => {
8
+ return routes.map((route, index) => {
9
+ const Component = route.component;
10
+ const routeToRender = {
11
+ ...route,
12
+ element: (
13
+ <Component key={index} />
14
+ ),
15
+ };
16
+ if (route.children) {
17
+ routeToRender.children = getPreparedRoutes(route.children);
18
+ }
19
+ return routeToRender;
20
+ });
21
+ };
22
+
23
+ return [
24
+ {
25
+ element: (
26
+ <RouterDataProvider
27
+ config={{}}
28
+ initialState={routerInitialState}
29
+ fetcherArgs={{ store }}
30
+ >
31
+ <MetaTag />
32
+ <App />
33
+ </RouterDataProvider>
34
+ ),
35
+ children: getPreparedRoutes(routes),
36
+ },
37
+ ];
38
+ };
25
39
 
26
40
  export const getRoutes = () => {
27
- return routes
28
- }
41
+ return routes;
42
+ };
@@ -4,7 +4,10 @@
4
4
  "scripts": {
5
5
  "start": "catalyst start",
6
6
  "build": "catalyst build",
7
- "serve": "catalyst serve"
7
+ "serve": "catalyst serve",
8
+ "lint": "eslint .",
9
+ "devBuild": "catalyst devBuild",
10
+ "devServe": "catalyst devServe"
8
11
  },
9
12
  "_moduleAliases": {
10
13
  "@api": "api.js",
@@ -17,9 +20,16 @@
17
20
  },
18
21
  "dependencies": {
19
22
  "@loadable/component": "^5.16.3",
20
- "@tata1mg/router": "^0.0.1-beta.0",
21
- "catalyst-core-internal": "^0.0.1-beta.7",
23
+ "@tata1mg/router": "^0.0.2-alpha.0",
24
+ "catalyst-core-internal": "^0.0.1-beta.8",
22
25
  "@reduxjs/toolkit": "1.9.3",
23
26
  "react-redux": "^8.1.3"
27
+ },
28
+ "devDependencies": {
29
+ "eslint": "^8.26.0",
30
+ "eslint-plugin-babel": "^5.3.1",
31
+ "eslint-plugin-react": "^7.34.1",
32
+ "@babel/eslint-parser": "^7.19.1",
33
+ "eslint-plugin-react-hooks": "^4.6.0"
24
34
  }
25
35
  }
@@ -1,28 +1,42 @@
1
- import React from "react"
2
- import { RouterDataProvider, MetaTag } from "@tata1mg/router"
3
- import App from "@containers/App"
4
- import routes from "./index.js"
1
+ import React from "react";
2
+ import { RouterDataProvider, MetaTag } from "@tata1mg/router";
3
+ import App from "@containers/App";
4
+ import routes from "./index.js";
5
5
 
6
6
  export const preparedRoutes = ({ store, routerInitialState }) => {
7
- return [
8
- {
9
- element: (
10
- <RouterDataProvider config={{}} initialState={routerInitialState} fetcherArgs={{ store }}>
11
- <MetaTag />
12
- <App />
13
- </RouterDataProvider>
14
- ),
15
- children: getRoutes()?.map((route, index) => {
16
- const Component = route.component
17
- return {
18
- ...route,
19
- element: <Component key={index} />,
20
- }
21
- }),
22
- },
23
- ]
24
- }
7
+ const getPreparedRoutes = (routes) => {
8
+ return routes.map((route, index) => {
9
+ const Component = route.component;
10
+ const routeToRender = {
11
+ ...route,
12
+ element: (
13
+ <Component key={index} />
14
+ ),
15
+ };
16
+ if (route.children) {
17
+ routeToRender.children = getPreparedRoutes(route.children);
18
+ }
19
+ return routeToRender;
20
+ });
21
+ };
22
+
23
+ return [
24
+ {
25
+ element: (
26
+ <RouterDataProvider
27
+ config={{}}
28
+ initialState={routerInitialState}
29
+ fetcherArgs={{ store }}
30
+ >
31
+ <MetaTag />
32
+ <App />
33
+ </RouterDataProvider>
34
+ ),
35
+ children: getPreparedRoutes(routes),
36
+ },
37
+ ];
38
+ };
25
39
 
26
40
  export const getRoutes = () => {
27
- return routes
28
- }
41
+ return routes;
42
+ };