create-catalyst-app-internal 0.0.1-beta.1 → 0.0.1-beta.11

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
- "bin": "scripts/cli.mjs",
4
- "version": "0.0.1-beta.1",
3
+ "bin": "scripts/cli.cjs",
4
+ "version": "0.0.1-beta.11",
5
5
  "description": "cli package to scaffold Catalyst application",
6
6
  "main": "index.js",
7
7
  "scripts": {
package/scripts/cli.cjs CHANGED
@@ -35,9 +35,6 @@ const program = new Commander.Command()
35
35
  const projectDescription = await promptDescription()
36
36
  const stateManagement = cmd.stateManagement || (await promptStateManagement())
37
37
 
38
- const resolvedProjectPath = path.resolve(projectName.trim())
39
- const projectPath = path.basename(resolvedProjectPath)
40
- const root = path.resolve(projectPath)
41
38
 
42
39
  // Define mapping of options to repository suffixes
43
40
  const repositorySuffixes = {
@@ -56,30 +53,32 @@ const program = new Commander.Command()
56
53
  const subDirectoriesToExtract = [commonCodeDirectory, selectedTemplateCode]
57
54
  const extractionDestination = `/${projectName}/`
58
55
  let tempDir
59
- ;(() => {
60
- try {
61
- tempDir = createTempDir()
62
-
63
- const packageFilePath = packNpmPackage(packageName, packageVersion, tempDir)
64
-
65
- extractSubdirectory(packageFilePath)
66
-
67
- execSync(
68
- `cd ${projectName} && npm i && npm pkg set name=${projectName} ${
69
- projectDescription ? `description=${projectDescription}` : ""
70
- } && git init --quiet`,
71
- { stdio: "inherit" }
72
- )
73
-
74
- console.log(cyan(`Installing Packages`))
75
-
76
- deleteDirectory(tempDir)
77
- } catch (error) {
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
+ )
78
75
  deleteDirectory(tempDir)
79
- console.error(`Error: ${error.message}`)
80
- process.exit(1)
81
- }
82
- })()
76
+ } catch (error) {
77
+ deleteDirectory(tempDir)
78
+ console.error(`Error: ${error.message}`)
79
+ process.exit(1)
80
+ }
81
+ })()
83
82
 
84
83
  function packNpmPackage(packageName, packageVersion, tempDir) {
85
84
  const tarballFileName = `${packageName}-${packageVersion}.tgz`
@@ -175,10 +174,10 @@ async function promptProjectName() {
175
174
  if (!res.path || projectName === "") {
176
175
  console.log(
177
176
  "\nPlease specify the project directory:\n" +
178
- ` ${cyan(program.name())} ${green("<project-directory>")}\n` +
179
- "For example:\n" +
180
- ` ${cyan(program.name())} ${green("my-next-app")}\n\n` +
181
- `Run ${cyan(`${program.name()} --help`)} to see all options.`
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.`
182
181
  )
183
182
  process.exit(1)
184
183
  }
@@ -221,3 +220,23 @@ function deleteDirectory(dirPath) {
221
220
  fs.rmdirSync(dirPath)
222
221
  }
223
222
  }
223
+
224
+ // Function to create a .gitignore file with the hardcoded patterns
225
+ function createGitignore(projectName) {
226
+
227
+ const gitiIgnorePatterns = [
228
+ 'node_modules',
229
+ 'build',
230
+ 'logs'
231
+ ];
232
+
233
+ const gitignorePath = path.join(process.cwd(), projectName, '.gitignore');
234
+
235
+ if (fs.existsSync(gitignorePath)) {
236
+ console.log('.gitignore already exists. Please rename or remove it before running the script.');
237
+ return;
238
+ }
239
+
240
+ fs.writeFileSync(gitignorePath, gitiIgnorePatterns.join('\n'));
241
+ }
242
+
@@ -24,4 +24,4 @@ const apiInstance = () => {
24
24
  put: fetchFunction,
25
25
  }
26
26
  }
27
- export default { apiInstance }
27
+ export default apiInstance
@@ -5,13 +5,28 @@
5
5
  "WEBPACK_DEV_SERVER_PORT": 3006,
6
6
  "BUILD_OUTPUT_PATH": "build",
7
7
  "PUBLIC_STATIC_ASSET_PATH": "/assets/",
8
- "PUBLIC_STATIC_ASSET_URL": "http://localhost:3006",
9
- "NODE_ENV": "production",
10
- "BUILD_ENV": "localBuild",
8
+ "PUBLIC_STATIC_ASSET_URL": "http://localhost:3005",
9
+ "NODE_ENV": "development",
11
10
  "API_URL": "",
12
- "CLIENT_EXPOSED_KEYS": [],
13
11
  "ANALYZE_BUNDLE": false,
14
- "ENABLE_DEBUG_LOGS": true,
15
- "ENABLE_FILE_LOGGING": true,
16
- "ENABLE_CONSOLE_LOGGING": true
12
+ "CLIENT_ENV_VARIABLES": [
13
+ "NODE_SERVER_HOSTNAME",
14
+ "NODE_SERVER_PORT",
15
+ "WEBPACK_DEV_SERVER_HOSTNAME",
16
+ "WEBPACK_DEV_SERVER_PORT",
17
+ "BUILD_OUTPUT_PATH",
18
+ "PUBLIC_STATIC_ASSET_PATH",
19
+ "PUBLIC_STATIC_ASSET_URL",
20
+ "NODE_ENV",
21
+ "BUILD_ENV",
22
+ "API_URL",
23
+ "ANALYZE_BUNDLE",
24
+ "ENABLE_DEBUG_LOGS",
25
+ "ENABLE_FILE_LOGGING",
26
+ "ENABLE_CONSOLE_LOGGING",
27
+ "ANALYZE_BUNDLE",
28
+ "ENABLE_DEBUG_LOGS",
29
+ "ENABLE_FILE_LOGGING",
30
+ "ENABLE_CONSOLE_LOGGING"
31
+ ]
17
32
  }
Binary file
@@ -3,9 +3,8 @@ import { Head, Body } from "catalyst-core-internal"
3
3
 
4
4
  function Document(props) {
5
5
  return (
6
- <html lang={props.lang}>
6
+ <html lang="en">
7
7
  <Head {...props}>
8
- <meta charset="final-order" />
9
8
  </Head>
10
9
  <Body {...props} />
11
10
  </html>
@@ -1 +1,8 @@
1
- export function addMiddlewares(app) {}
1
+ const express = require('express');
2
+ const path = require('path');
3
+
4
+ export function addMiddlewares(app) {
5
+
6
+ app.use('/favicon.ico', express.static(path.join(__dirname, '../favicon.ico')));
7
+
8
+ }
@@ -1,7 +1,7 @@
1
1
  import React from "react"
2
2
  import css from "./Home.scss"
3
3
 
4
- function Landing() {
4
+ function Home() {
5
5
  return (
6
6
  <div className={css.app}>
7
7
  <header className={css.appHeader}>
@@ -20,4 +20,4 @@ function Landing() {
20
20
  )
21
21
  }
22
22
 
23
- export default Landing
23
+ export default Home
@@ -14,7 +14,6 @@ export const preparedRoutes = ({ store, routerInitialState }) => {
14
14
  ),
15
15
  children: getRoutes()?.map((route, index) => {
16
16
  const Component = route.component
17
- // const pageType = route.staticPageType ? route.staticPageType : null
18
17
  return {
19
18
  ...route,
20
19
  element: <Component key={index} />,
@@ -12,11 +12,9 @@ window.addEventListener("load", () => {
12
12
  const router = clientRouter({ routerInitialState: routerInitialData })
13
13
 
14
14
  const Application = (
15
- <Provider serverState={__INITIAL_STATE__}>
16
- <React.StrictMode>
17
- <RouterProvider router={router} />
18
- </React.StrictMode>
19
- </Provider>
15
+ <React.StrictMode>
16
+ <RouterProvider router={router} />
17
+ </React.StrictMode>
20
18
  )
21
19
 
22
20
  const container = document.getElementById("app")
@@ -12,12 +12,11 @@
12
12
  "@server": "server",
13
13
  "@config": "config",
14
14
  "@css": "src/static/css",
15
- "@routes": "src/js/routes/",
16
- "@store": "src/js/store/index.js"
15
+ "@routes": "src/js/routes/"
17
16
  },
18
17
  "dependencies": {
19
18
  "@loadable/component": "^5.16.3",
20
- "@tata1mg/router": "^0.0.1-alpha.13",
21
- "catalyst-core-internal": "0.0.1-beta.0"
19
+ "@tata1mg/router": "^0.0.1-beta.0",
20
+ "catalyst-core-internal": "^0.0.1-beta.4"
22
21
  }
23
22
  }
@@ -1,13 +1,15 @@
1
- import React, { useState } from "react"
2
- import { useOutlet } from "@tata1mg/router"
3
- const App = () => {
4
- const o = useOutlet()
5
- const [outlet] = useState(o)
1
+ import React from "react"
2
+ import { Outlet } from "@tata1mg/router"
6
3
 
7
- return <>{outlet}</>
4
+ const App = () => {
5
+ return (
6
+ <>
7
+ <Outlet />
8
+ </>
9
+ )
8
10
  }
9
11
 
10
- App.serverSideFunction = ({}) => {
12
+ App.serverSideFunction = () => {
11
13
  return new Promise((resolve) => resolve())
12
14
  }
13
15
 
@@ -17,8 +17,8 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@loadable/component": "^5.16.3",
20
- "@tata1mg/router": "^0.0.1-alpha.13",
21
- "catalyst-core-internal": "0.0.1-beta.0",
20
+ "@tata1mg/router": "^0.0.1-beta.0",
21
+ "catalyst-core-internal": "^0.0.1-beta.4",
22
22
  "@reduxjs/toolkit": "1.9.3",
23
23
  "react-redux": "^8.1.3"
24
24
  }
@@ -1,10 +1,12 @@
1
- import React, { useState } from "react"
2
- import { useOutlet } from "@tata1mg/router"
3
- const App = () => {
4
- const o = useOutlet()
5
- const [outlet] = useState(o)
1
+ import React from "react"
2
+ import { Outlet } from "@tata1mg/router"
6
3
 
7
- return <>{outlet}</>
4
+ const App = () => {
5
+ return (
6
+ <>
7
+ <Outlet />
8
+ </>
9
+ )
8
10
  }
9
11
 
10
12
  App.serverSideFunction = () => {
@@ -4,7 +4,7 @@ export const defaultState = {
4
4
  testActionDispatched: false,
5
5
  }
6
6
 
7
- const shellReducer = (state = defaultState, action) => {
7
+ export const shellReducer = (state = defaultState, action) => {
8
8
  switch (action.type) {
9
9
  case ShellActions.REDUX_TEST: {
10
10
  return {
@@ -18,4 +18,3 @@ const shellReducer = (state = defaultState, action) => {
18
18
  }
19
19
  }
20
20
 
21
- export default shellReducer
@@ -6,11 +6,11 @@ import fetchInstance from "@api"
6
6
  /**
7
7
  * Function that initializes the store with the initialstate and adds middlewares that can be used during action dispatch
8
8
  * @param {object} initialState Default state
9
- * @param {object} request Request object that we recieve on server, this is only recieved when store is initialised on the server.
9
+ * @param {object} request Request object that we recieve on server, this is only recieved when store is initialized on the server.
10
10
  * @return {object} The store itself
11
11
  */
12
12
 
13
- const configureStore = (initialState, request) => {
13
+ const configureStore = (initialState) => {
14
14
  const api = fetchInstance
15
15
  const store = createStore({
16
16
  reducer: combineReducers({ shellReducer }),
@@ -17,8 +17,8 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@loadable/component": "^5.16.3",
20
- "@tata1mg/router": "^0.0.1-alpha.13",
21
- "catalyst-core-internal": "0.0.1-beta.0",
20
+ "@tata1mg/router": "^0.0.1-beta.0",
21
+ "catalyst-core-internal": "^0.0.1-beta.4",
22
22
  "@reduxjs/toolkit": "1.9.3",
23
23
  "react-redux": "^8.1.3"
24
24
  }
@@ -1,10 +1,12 @@
1
- import React, { useState } from "react"
2
- import { useOutlet } from "@tata1mg/router"
3
- const App = () => {
4
- const o = useOutlet()
5
- const [outlet] = useState(o)
1
+ import React from "react"
2
+ import { Outlet } from "@tata1mg/router"
6
3
 
7
- return <>{outlet}</>
4
+ const App = () => {
5
+ return (
6
+ <>
7
+ <Outlet />
8
+ </>
9
+ )
8
10
  }
9
11
 
10
12
  App.serverSideFunction = () => {
@@ -8,7 +8,7 @@ export const appSlice = createSlice({
8
8
  name: "shellReducer",
9
9
  initialState: initialState,
10
10
  reducers: {
11
- reduxTest: (state, action) => {
11
+ reduxTest: (state) => {
12
12
  state.testActionDispatched = true
13
13
  },
14
14
  },
@@ -6,11 +6,11 @@ import fetchInstance from "@api"
6
6
  /**
7
7
  * Function that initializes the store with the initialstate and adds middlewares that can be used during action dispatch
8
8
  * @param {object} initialState Default state
9
- * @param {object} request Request object that we recieve on server, this is only recieved when store is initialised on the server.
9
+ * @param {object} request Request object that we recieve on server, this is only recieved when store is initialized on the server.
10
10
  * @return {object} The store itself
11
11
  */
12
12
 
13
- const configureStore = (initialState, request) => {
13
+ const configureStore = (initialState) => {
14
14
  const api = fetchInstance
15
15
  const store = createStore({
16
16
  reducer: combineReducers({ shellReducer }),
@@ -1,53 +0,0 @@
1
- {
2
- "parser": "@babel/eslint-parser",
3
- "rules": {
4
- "prettier/prettier": "error",
5
- "no-console": "warn",
6
- "react/prop-types": 1,
7
- "react/display-name": [0, { "ignoreTranspilerName": true }],
8
- "react-hooks/exhaustive-deps": "warn", // Checks effect dependencies
9
- "no-prototype-builtins": "off",
10
- "jam3/no-sanitizer-with-danger": 2,
11
- "react/jsx-no-target-blank": [0, {
12
- "enforceDynamicLinks": "never"
13
- }]
14
- },
15
- "env": {
16
- "browser": true,
17
- "es6": true,
18
- "jest": true,
19
- "node": true
20
- },
21
- "globals": {
22
- "expect": true,
23
- "__non_webpack_require__": true,
24
- "logger": "readonly",
25
- "AppCallbacks": "readonly"
26
- },
27
- "extends": ["eslint:recommended", "plugin:react/recommended"],
28
- "parserOptions": {
29
- "sourceType": "module",
30
- "ecmaFeatures": {
31
- "experimentalObjectRestSpread": true,
32
- "jsx": true
33
- },
34
- "babelOptions": {
35
- "configFile": "./babel.config.js"
36
- },
37
- "ecmaVersion": 6
38
- },
39
- "plugins": ["babel", "react", "react-hooks", "prettier", "jam3"],
40
- "settings": {
41
- "react": {
42
- "createClass": "createReactClass",
43
- "pragma": "React",
44
- "version": "detect"
45
- },
46
- "propWrapperFunctions": [
47
- "forbidExtraProps",
48
- { "property": "freeze", "object": "Object" },
49
- { "property": "myFavoriteWrapper" }
50
- ],
51
- "linkComponents": ["Hyperlink", { "name": "Link", "linkAttribute": "to" }]
52
- }
53
- }
@@ -1,7 +0,0 @@
1
- {
2
- "trailingComma": "es5",
3
- "tabWidth": 4,
4
- "semi": false,
5
- "arrowParens": "always",
6
- "printWidth": 110
7
- }