create-catalyst-app-internal 0.0.1-beta.0 → 0.0.1-beta.10
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 +2 -2
- package/scripts/cli.cjs +49 -30
- package/templates/common/config/config.json +21 -5
- package/templates/common/server/document.js +1 -2
- package/templates/common/server/server.js +1 -1
- package/templates/common/src/js/containers/Home/Home.js +2 -2
- package/templates/common/src/js/routes/utils.js +0 -1
- package/templates/none-js/client/index.js +3 -5
- package/templates/none-js/package.json +3 -4
- package/templates/none-js/src/js/containers/App/index.js +9 -7
- package/templates/redux-js/package.json +2 -2
- package/templates/redux-js/src/js/containers/App/index.js +8 -6
- package/templates/redux-js/src/js/containers/App/reducer.js +1 -2
- package/templates/redux-js/src/js/store/index.js +2 -2
- package/templates/rtk-js/package.json +2 -2
- package/templates/rtk-js/src/js/containers/App/index.js +8 -6
- package/templates/rtk-js/src/js/containers/App/reducer.js +1 -1
- package/templates/rtk-js/src/js/store/index.js +2 -2
- package/templates/common/.eslintrc +0 -53
- package/templates/common/.prettierrc.json +0 -7
package/package.json
CHANGED
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
80
|
-
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
+
|
|
@@ -6,12 +6,28 @@
|
|
|
6
6
|
"BUILD_OUTPUT_PATH": "build",
|
|
7
7
|
"PUBLIC_STATIC_ASSET_PATH": "/assets/",
|
|
8
8
|
"PUBLIC_STATIC_ASSET_URL": "http://localhost:3006",
|
|
9
|
-
"NODE_ENV": "
|
|
9
|
+
"NODE_ENV": "development",
|
|
10
10
|
"BUILD_ENV": "localBuild",
|
|
11
11
|
"API_URL": "",
|
|
12
|
-
"CLIENT_EXPOSED_KEYS": [],
|
|
13
12
|
"ANALYZE_BUNDLE": false,
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
"CLIENT_ENV_VARIABLES": [
|
|
14
|
+
"NODE_SERVER_HOSTNAME",
|
|
15
|
+
"NODE_SERVER_PORT",
|
|
16
|
+
"WEBPACK_DEV_SERVER_HOSTNAME",
|
|
17
|
+
"WEBPACK_DEV_SERVER_PORT",
|
|
18
|
+
"BUILD_OUTPUT_PATH",
|
|
19
|
+
"PUBLIC_STATIC_ASSET_PATH",
|
|
20
|
+
"PUBLIC_STATIC_ASSET_URL",
|
|
21
|
+
"NODE_ENV",
|
|
22
|
+
"BUILD_ENV",
|
|
23
|
+
"API_URL",
|
|
24
|
+
"ANALYZE_BUNDLE",
|
|
25
|
+
"ENABLE_DEBUG_LOGS",
|
|
26
|
+
"ENABLE_FILE_LOGGING",
|
|
27
|
+
"ENABLE_CONSOLE_LOGGING",
|
|
28
|
+
"ANALYZE_BUNDLE",
|
|
29
|
+
"ENABLE_DEBUG_LOGS",
|
|
30
|
+
"ENABLE_FILE_LOGGING",
|
|
31
|
+
"ENABLE_CONSOLE_LOGGING"
|
|
32
|
+
]
|
|
17
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function addMiddlewares(
|
|
1
|
+
export function addMiddlewares() {}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import css from "./Home.scss"
|
|
3
3
|
|
|
4
|
-
function
|
|
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
|
|
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
|
-
<
|
|
16
|
-
<
|
|
17
|
-
|
|
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-
|
|
21
|
-
"catalyst-core-internal": "0.0.1-beta.
|
|
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
|
|
2
|
-
import {
|
|
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
|
-
|
|
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-
|
|
21
|
-
"catalyst-core-internal": "0.0.1-beta.
|
|
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
|
|
2
|
-
import {
|
|
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
|
-
|
|
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
|
|
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
|
|
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-
|
|
21
|
-
"catalyst-core-internal": "0.0.1-beta.
|
|
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
|
|
2
|
-
import {
|
|
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
|
-
|
|
4
|
+
const App = () => {
|
|
5
|
+
return (
|
|
6
|
+
<>
|
|
7
|
+
<Outlet />
|
|
8
|
+
</>
|
|
9
|
+
)
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
App.serverSideFunction = () => {
|
|
@@ -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
|
|
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
|
|
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
|
-
}
|