@common-stack/generate-plugin 6.0.2-alpha.1 → 6.0.2-alpha.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/CHANGELOG.md +36 -0
- package/lib/generators/add-backend/files/config.json +0 -1
- package/lib/generators/add-backend/files/package.json +79 -114
- package/lib/generators/add-backend/files/src/api/root-schema.graphqls +9 -0
- package/lib/generators/add-backend/files/src/config/env-config.ts.template +2 -24
- package/lib/generators/add-backend/files/src/service.ts.template +4 -5
- package/lib/generators/add-browser-package/files/package.json +47 -47
- package/lib/generators/add-client-package/files/package.json +28 -28
- package/lib/generators/add-core-package/files/package.json +28 -28
- package/lib/generators/add-frontend/frameworks/chakraui/entry.client.tsx.template +30 -24
- package/lib/generators/add-frontend/frameworks/chakraui/entry.server.tsx.template +5 -8
- package/lib/generators/add-frontend/frameworks/chakraui/root.tsx.template +3 -3
- package/lib/generators/add-frontend/templates/Dockerfile +1 -1
- package/lib/generators/add-frontend/templates/package.json +4 -22
- package/lib/generators/add-frontend/templates/src/config/public-config.ts.template +6 -0
- package/lib/generators/add-fullstack/files/Jenkinsfile +4 -7
- package/lib/generators/add-fullstack/files/package.json +346 -358
- package/lib/generators/add-fullstack/files/tools/deploy-cli/updateYamlSettings.js +14 -15
- package/lib/generators/add-fullstack/files/tools/sortPackageJson.mjs +8 -1
- package/lib/generators/add-fullstack/generator.cjs +22 -25
- package/lib/generators/add-fullstack/generator.cjs.map +1 -1
- package/lib/generators/add-fullstack/generator.mjs +20 -23
- package/lib/generators/add-fullstack/generator.mjs.map +1 -1
- package/lib/generators/add-fullstack/schema.json +5 -0
- package/lib/generators/add-fullstack/updates/index.d.ts +2 -0
- package/lib/generators/add-fullstack/updates/jenkinsfileUpdate.cjs +36 -0
- package/lib/generators/add-fullstack/updates/jenkinsfileUpdate.cjs.map +1 -0
- package/lib/generators/add-fullstack/updates/jenkinsfileUpdate.d.ts +1 -0
- package/lib/generators/add-fullstack/updates/jenkinsfileUpdate.mjs +36 -0
- package/lib/generators/add-fullstack/updates/jenkinsfileUpdate.mjs.map +1 -0
- package/lib/generators/add-fullstack/updates/packageJsonUpdate.cjs +8 -0
- package/lib/generators/add-fullstack/updates/packageJsonUpdate.cjs.map +1 -0
- package/lib/generators/add-fullstack/updates/packageJsonUpdate.d.ts +2 -0
- package/lib/generators/add-fullstack/updates/packageJsonUpdate.mjs +8 -0
- package/lib/generators/add-fullstack/updates/packageJsonUpdate.mjs.map +1 -0
- package/lib/generators/add-moleculer/files/Dockerfile +1 -1
- package/lib/generators/add-moleculer/files/package.json +6 -25
- package/lib/generators/add-server-package/files/package.json +3 -3
- package/package.json +3 -3
- package/src/generators/add-frontend/frameworks/chakraui/entry.client.tsx.template +30 -24
- package/src/generators/add-frontend/frameworks/chakraui/entry.server.tsx.template +5 -8
- package/src/generators/add-frontend/frameworks/chakraui/root.tsx.template +3 -3
- package/src/generators/add-fullstack/files/Jenkinsfile +4 -7
- package/src/generators/add-fullstack/files/package.json +6 -18
- package/src/generators/add-fullstack/files/tools/deploy-cli/updateYamlSettings.js +14 -15
- package/src/generators/add-fullstack/files/tools/sortPackageJson.mjs +8 -1
- package/src/generators/add-fullstack/generator.ts +41 -35
- package/src/generators/add-fullstack/schema.d.ts +2 -1
- package/src/generators/add-fullstack/schema.json +5 -0
- package/src/generators/add-fullstack/updates/index.ts +2 -0
- package/src/generators/add-fullstack/updates/jenkinsfileUpdate.ts +47 -0
- package/src/generators/add-fullstack/updates/packageJsonUpdate.ts +11 -0
- package/src/generators/add-moleculer/files/Dockerfile +1 -1
- package/src/generators/add-moleculer/files/package.json +6 -25
- package/lib/generators/add-backend/files/generated-schema.graphql +0 -235
- package/lib/generators/add-frontend/templates/public/css/dashboard.css +0 -491
- package/lib/generators/add-fullstack/files/jest.config copy.js +0 -27
- package/lib/generators/add-fullstack/files/tools/html-plugin-template.ejs +0 -28
- package/src/generators/add-fullstack/files/jest.config copy.js +0 -27
- package/src/generators/add-fullstack/files/tools/html-plugin-template.ejs +0 -28
|
@@ -36,8 +36,10 @@ import config from '@app/cde-webconfig.json';
|
|
|
36
36
|
|
|
37
37
|
import { Head } from './root';
|
|
38
38
|
import type { IAppLoadContext } from '@common-stack/client-core';
|
|
39
|
-
import { ServerStyleContext } from '@app/frontend-stack-react/entries/chakraui/context.js';
|
|
39
|
+
// import { ServerStyleContext } from '@app/frontend-stack-react/entries/chakraui/context.js';
|
|
40
|
+
import { ServerStyleContext } from './context';
|
|
40
41
|
import { i18nextInstance as i18next } from '@app/frontend-stack-react/i18n-localization/i18next.server.js';
|
|
42
|
+
|
|
41
43
|
const { extractCriticalToChunks } = createEmotionServer(defaultCache);
|
|
42
44
|
|
|
43
45
|
const ABORT_DELAY = 5000;
|
|
@@ -124,12 +126,7 @@ async function handleBrowserRequest(
|
|
|
124
126
|
// And here we detect what namespaces the routes about to render want to use
|
|
125
127
|
const ns = i18next.getRouteNamespaces(remixContext);
|
|
126
128
|
const slotFillContext = { fills: {} };
|
|
127
|
-
const {
|
|
128
|
-
modules: clientModules,
|
|
129
|
-
container,
|
|
130
|
-
apolloClient: client,
|
|
131
|
-
store,
|
|
132
|
-
}: IAppLoadContext = loadContext;
|
|
129
|
+
const { modules: clientModules, container, apolloClient: client, store }: IAppLoadContext = loadContext;
|
|
133
130
|
|
|
134
131
|
// First, we create a new instance of i18next so every request will have a
|
|
135
132
|
// completely unique instance and not share any state.
|
|
@@ -145,7 +142,7 @@ async function handleBrowserRequest(
|
|
|
145
142
|
lng, // The locale we detected above
|
|
146
143
|
ns, // The namespaces the routes about to render want to use
|
|
147
144
|
backend: {
|
|
148
|
-
loadPath:
|
|
145
|
+
loadPath: config.i18n.backend.loadServerPath,
|
|
149
146
|
},
|
|
150
147
|
});
|
|
151
148
|
}
|
|
@@ -79,8 +79,8 @@ export function shouldRevalidate(params: any) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export default function App() {
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
// const { locale } = useLoaderData();
|
|
83
|
+
const locale = 'en';
|
|
84
84
|
useChangeLanguage(locale);
|
|
85
85
|
|
|
86
86
|
React.useEffect(() => {
|
|
@@ -94,4 +94,4 @@ export default function App() {
|
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
export { ErrorBoundary };
|
|
97
|
+
export { ErrorBoundary };
|
|
@@ -30,7 +30,7 @@ pipeline {
|
|
|
30
30
|
choice choices: ['auto', 'force'], description: 'Choose merge strategy', name: 'NPM_PUBLISH_STRATEGY'
|
|
31
31
|
choice choices: ['yarn', 'npm'], description: 'Choose build strategy', name: 'BUILD_STRATEGY'
|
|
32
32
|
choice choices: ['0.7.9','0.7.7', '0.6.0'], description: 'Choose Idestack chart version', name: 'IDESTACK_CHART_VERSION'
|
|
33
|
-
choice choices: ['
|
|
33
|
+
choice choices: ['nodejs20', 'nodejs18', 'nodejs22'], description: 'Choose NodeJS version', name: 'NODEJS_TOOL_VERSION'
|
|
34
34
|
choice choices: ['buildOnly', 'buildAndTest', 'buildAndPublish', 'mobileBuild', 'mobilePreview', 'mobilePreviewLocal', 'mobilePreviewSubmit', 'mobileProd', 'mobileProdSubmit', 'devDeployOnly', 'stageDeploy', 'stageDeployOnly', 'prodDeploy', 'prodDeployOnly', 'allenv'], description: 'Where to deploy micro services?', name: 'ENV_CHOICE'
|
|
35
35
|
choice choices: ['all', 'ios', 'android' ], description: 'Mobile type if it is mobile build?', name: 'MOBILE_CHOICE'
|
|
36
36
|
booleanParam (defaultValue: false, description: 'Skip production release approval', name: 'SKIP_RELEASE_APPROVAL')
|
|
@@ -38,7 +38,7 @@ pipeline {
|
|
|
38
38
|
string(name: 'BUILD_TIME_OUT', defaultValue: '120', description: 'Build timeout in minutes', trim: true)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
// Setup common + secret key variables for pipeline.
|
|
42
42
|
environment {
|
|
43
43
|
BUILD_COMMAND = getBuildCommand()
|
|
44
44
|
NAMESPACE = "${params.BASE_NAMESPACE}-${params.VERSION}"
|
|
@@ -86,7 +86,6 @@ pipeline {
|
|
|
86
86
|
sh """
|
|
87
87
|
echo "what is docker git version $GIT_BRANCH_NAME -- ${params.ENV_CHOICE}"
|
|
88
88
|
${params.BUILD_STRATEGY} install
|
|
89
|
-
${params.BUILD_STRATEGY} run lerna
|
|
90
89
|
"""
|
|
91
90
|
}
|
|
92
91
|
}
|
|
@@ -99,7 +98,7 @@ pipeline {
|
|
|
99
98
|
sshagent(credentials: [params.GIT_CREDENTIAL_ID]) {
|
|
100
99
|
sh """
|
|
101
100
|
rm .npmrc
|
|
102
|
-
lerna exec --scope=*mobile-device ${params.BUILD_STRATEGY} ${env.BUILD_COMMAND}
|
|
101
|
+
npx lerna exec --scope=*mobile-device ${params.BUILD_STRATEGY} ${env.BUILD_COMMAND}
|
|
103
102
|
git checkout -- .npmrc
|
|
104
103
|
yarn gitcommit
|
|
105
104
|
git pull origin ${params.REPOSITORY_BRANCH}
|
|
@@ -145,7 +144,6 @@ pipeline {
|
|
|
145
144
|
git merge ${env.GIT_PR_BRANCH_NAME} -m 'auto merging ${params.GIT_PR_BRANCH_NAME} \r\n[skip ci]'
|
|
146
145
|
git push origin ${params.DEVELOP_BRANCH}
|
|
147
146
|
${params.BUILD_STRATEGY} install
|
|
148
|
-
${params.BUILD_STRATEGY} run lerna
|
|
149
147
|
${params.BUILD_STRATEGY} run build
|
|
150
148
|
"""
|
|
151
149
|
script {
|
|
@@ -278,7 +276,6 @@ pipeline {
|
|
|
278
276
|
git checkout ${params.REPOSITORY_BRANCH}
|
|
279
277
|
git merge origin/${params.DEVELOP_BRANCH} -m 'auto merging ${params.DEVELOP_BRANCH} \r\n[skip ci]'
|
|
280
278
|
${params.BUILD_STRATEGY} install
|
|
281
|
-
${params.BUILD_STRATEGY} run lerna
|
|
282
279
|
"""
|
|
283
280
|
script {
|
|
284
281
|
GIT_BRANCH_NAME = params.REPOSITORY_BRANCH
|
|
@@ -648,7 +645,7 @@ def buildAndPushDockerImage(server, name, version) {
|
|
|
648
645
|
echo "Docker image ${REPOSITORY_SERVER}/${name}:${version} already exists. Skipping build."
|
|
649
646
|
} else {
|
|
650
647
|
sh """
|
|
651
|
-
lerna exec --scope=*${server} ${params.BUILD_STRATEGY} run docker:${env.BUILD_COMMAND};
|
|
648
|
+
npx lerna exec --scope=*${server} ${params.BUILD_STRATEGY} run docker:${env.BUILD_COMMAND};
|
|
652
649
|
docker tag ${name}:${version} ${REPOSITORY_SERVER}/${name}:${version}
|
|
653
650
|
docker push ${REPOSITORY_SERVER}/${name}:${version}
|
|
654
651
|
docker rmi ${REPOSITORY_SERVER}/${name}:${version}
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"publish:forceManual": "yarn lernapublish --force-publish=*",
|
|
77
77
|
"publish:push": "yarn prelernapublish && git push origin publish && yarn postlernapublish",
|
|
78
78
|
"setBranchEnv": "cross-env REPOSITORY_BRANCH=${1:-$REPOSITORY_BRANCH} PUBLISH_BRANCH=${2:-$PUBLISH_BRANCH}",
|
|
79
|
-
"sort-packages": "node tools/sortPackageJson.mjs",
|
|
79
|
+
"sort-packages": "node tools/sortPackageJson.mjs && prettier --write package.json **/**/*/package.json **/*/package.json",
|
|
80
80
|
"start": "cross-env NODE_ENV=development ENV_FILE=../../config/development/dev.env yarn startWeb",
|
|
81
81
|
"start:SSR": "concurrently --names \"BACKEND,FRONTEND\" -c \"bgBlue.bold,bgMagenta.bold\" \"lerna run --scope='*backend-server' start\" \"lerna run --scope='*frontend-server' start:SSR\"",
|
|
82
82
|
"start:devSSR": "concurrently --names \"BACKEND,FRONTEND\" -c \"bgBlue.bold,bgMagenta.bold\" \"lerna run --scope='*backend-server' watch\" \"lerna run --scope='*frontend-server' start:devSSR\"",
|
|
@@ -102,27 +102,15 @@
|
|
|
102
102
|
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
103
103
|
}
|
|
104
104
|
},
|
|
105
|
-
"lint-staged": {
|
|
106
|
-
"*.md": [
|
|
107
|
-
"yarn format:md",
|
|
108
|
-
"git add"
|
|
109
|
-
],
|
|
110
|
-
"*.{js,jsx,ts,tsx}": [
|
|
111
|
-
"eslint --fix",
|
|
112
|
-
"git add"
|
|
113
|
-
],
|
|
114
|
-
"package.json": "sort-package-json --check package.json */**/package.json "
|
|
115
|
-
},
|
|
116
105
|
"resolutions": {
|
|
117
106
|
"@apollo/client": "^3.9.0",
|
|
118
107
|
"@types/react": "^18.0.25",
|
|
119
108
|
"@types/react-dom": "^18.0.8",
|
|
120
|
-
"chokidar": "^3.5.3",
|
|
121
109
|
"html-to-text": "^8.0.0",
|
|
122
|
-
"react": "18.
|
|
123
|
-
"react-dom": "18.
|
|
124
|
-
"react-native": "0.
|
|
125
|
-
"react-native-gesture-handler": "~2.
|
|
110
|
+
"react": "18.3.0-canary-c3048aab4-20240326",
|
|
111
|
+
"react-dom": "18.3.0-canary-c3048aab4-20240326",
|
|
112
|
+
"react-native": "0.72.10",
|
|
113
|
+
"react-native-gesture-handler": "~2.12.0"
|
|
126
114
|
},
|
|
127
115
|
"dependencies": {
|
|
128
116
|
"dataloader": "^2.1.0",
|
|
@@ -159,7 +147,7 @@
|
|
|
159
147
|
"@babel/preset-typescript": "^7.18.6",
|
|
160
148
|
"@babel/register": "^7.18.9",
|
|
161
149
|
"@babel/runtime": "^7.20.1",
|
|
162
|
-
"@common-stack/env-list-loader": "6.0.
|
|
150
|
+
"@common-stack/env-list-loader": "6.0.2-alpha.2",
|
|
163
151
|
"@emotion/babel-plugin": "^11.11.0",
|
|
164
152
|
"@graphql-codegen/add": "^5.0.2",
|
|
165
153
|
"@graphql-codegen/cli": "^5.0.2",
|
|
@@ -3,6 +3,9 @@ const fs = require('fs');
|
|
|
3
3
|
|
|
4
4
|
// Function to update the configuration file
|
|
5
5
|
function updateConfiguration(filePath, newVersion) {
|
|
6
|
+
// Convert the version from vMajor.Minor to vMajor-Minor for URL
|
|
7
|
+
const versionForUrl = newVersion.replace('.', '-');
|
|
8
|
+
|
|
6
9
|
// Read the configuration file
|
|
7
10
|
fs.readFile(filePath, 'utf8', (err, data) => {
|
|
8
11
|
if (err) {
|
|
@@ -10,24 +13,20 @@ function updateConfiguration(filePath, newVersion) {
|
|
|
10
13
|
return;
|
|
11
14
|
}
|
|
12
15
|
|
|
13
|
-
// Replace VERSION and CONNECTION_ID
|
|
16
|
+
// Replace only the specific VERSION and CONNECTION_ID fields, preserving leading whitespace
|
|
14
17
|
let updatedData = data
|
|
15
|
-
.replace(
|
|
16
|
-
.replace(
|
|
18
|
+
.replace(/^(\s*)VERSION:\s*v\d+(\.\d+)?/gm, `$1VERSION: ${newVersion}`)
|
|
19
|
+
.replace(/^(\s*)CONNECTION_ID:\s*v\d+(\.\d+)?/gm, `$1CONNECTION_ID: ${newVersion}`);
|
|
17
20
|
|
|
18
|
-
// Update CLIENT_URL
|
|
21
|
+
// Update CLIENT_URL, preserving leading whitespace, and replacing the version with the hyphenated version
|
|
19
22
|
updatedData = updatedData.replace(
|
|
20
|
-
|
|
21
|
-
(match) => {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const domain = domainParts[0];
|
|
25
|
-
const newDomain = domain.replace(/-v\d+(\.\d+)?/, `-${newVersion}`);
|
|
26
|
-
return match.replace(domain, newDomain);
|
|
27
|
-
}
|
|
28
|
-
return match;
|
|
23
|
+
/^(\s*)CLIENT_URL:\s*"https:\/\/([\w-]+)-v\d+(-\d+)?(\.[\w-]+(\.\w+)?)\/?"/gm,
|
|
24
|
+
(match, p1, p2, p3, p4) => {
|
|
25
|
+
const newDomain = `${p2}-${versionForUrl}${p4}`;
|
|
26
|
+
return `${p1}CLIENT_URL: "https://${newDomain}"`;
|
|
29
27
|
},
|
|
30
28
|
);
|
|
29
|
+
|
|
31
30
|
// Write the updated configuration back to the file
|
|
32
31
|
fs.writeFile(filePath, updatedData, 'utf8', (err) => {
|
|
33
32
|
if (err) {
|
|
@@ -35,7 +34,7 @@ function updateConfiguration(filePath, newVersion) {
|
|
|
35
34
|
return;
|
|
36
35
|
}
|
|
37
36
|
console.log(`Configuration file updated successfully.`);
|
|
38
|
-
console.log(`Manually update CLIENT_URL in values-dev.yaml and values-prod.yaml`)
|
|
37
|
+
console.log(`Manually update CLIENT_URL in values-dev.yaml and values-prod.yaml`);
|
|
39
38
|
});
|
|
40
39
|
});
|
|
41
40
|
}
|
|
@@ -45,7 +44,7 @@ const filePath = process.argv[2];
|
|
|
45
44
|
const versionArg = process.argv[3];
|
|
46
45
|
|
|
47
46
|
if (!filePath || !versionArg || !versionArg.match(/^v\d+(\.\d+)?$/)) {
|
|
48
|
-
console.error('Usage: node updateConfiguration.js v[Major].[Minor]');
|
|
47
|
+
console.error('Usage: node updateConfiguration.js <path-to-config> v[Major].[Minor]');
|
|
49
48
|
process.exit(1);
|
|
50
49
|
}
|
|
51
50
|
|
|
@@ -11,23 +11,28 @@ const sortPackageJson = await import('sort-package-json').then(module => module.
|
|
|
11
11
|
|
|
12
12
|
// Directories to process
|
|
13
13
|
const directories = [
|
|
14
|
+
path.join(__dirname, '../'),
|
|
15
|
+
path.join(__dirname, '../packages-modules'),
|
|
14
16
|
path.join(__dirname, '../packages'),
|
|
15
17
|
path.join(__dirname, '../servers'),
|
|
16
18
|
path.join(__dirname, '../portable-devices')
|
|
17
19
|
];
|
|
18
20
|
|
|
21
|
+
// Function to sort a single package.json file
|
|
19
22
|
async function sortPackageJsonFile(filePath) {
|
|
20
23
|
const packageJson = JSON.parse(await fsPromises.readFile(filePath, 'utf8'));
|
|
21
24
|
const sortedPackageJson = sortPackageJson(packageJson);
|
|
22
25
|
await fsPromises.writeFile(filePath, JSON.stringify(sortedPackageJson, null, 2) + '\n');
|
|
23
26
|
}
|
|
24
27
|
|
|
28
|
+
// Recursive function to sort all package.json files in a directory, skipping node_modules
|
|
25
29
|
async function sortAllPackageJsonFiles(dir) {
|
|
26
30
|
const files = await fsPromises.readdir(dir);
|
|
27
31
|
for (const file of files) {
|
|
28
32
|
const fullPath = path.join(dir, file);
|
|
29
33
|
const stat = await fsPromises.lstat(fullPath);
|
|
30
|
-
|
|
34
|
+
|
|
35
|
+
if (stat.isDirectory() && file !== 'node_modules') {
|
|
31
36
|
await sortAllPackageJsonFiles(fullPath);
|
|
32
37
|
} else if (file === 'package.json') {
|
|
33
38
|
await sortPackageJsonFile(fullPath);
|
|
@@ -36,10 +41,12 @@ async function sortAllPackageJsonFiles(dir) {
|
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
|
|
44
|
+
// Function to process all directories
|
|
39
45
|
async function processDirectories(dirs) {
|
|
40
46
|
for (const dir of dirs) {
|
|
41
47
|
await sortAllPackageJsonFiles(dir);
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
|
|
51
|
+
// Execute the sorting process
|
|
45
52
|
await processDirectories(directories);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/* eslint-disable import/no-cycle */
|
|
3
|
+
import { addProjectConfiguration, formatFiles, generateFiles, Tree } from '@nx/devkit';
|
|
2
4
|
import * as path from 'path';
|
|
3
|
-
import fs from 'fs';
|
|
5
|
+
import * as fs from 'fs';
|
|
4
6
|
import { AddFullstackGeneratorSchema } from './schema';
|
|
5
7
|
import { getValid, isValid } from '../../utils';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
import { updateJenkinsFile, updatePackageJson } from './updates';
|
|
9
|
+
import {
|
|
10
|
+
generateBackend,
|
|
11
|
+
generateFrontend,
|
|
9
12
|
generateMoleculer,
|
|
10
13
|
generateBrowserPackage,
|
|
11
14
|
generateClientPackage,
|
|
@@ -14,22 +17,24 @@ import {
|
|
|
14
17
|
} from '../../index';
|
|
15
18
|
|
|
16
19
|
export async function addFullstackGenerator(tree: Tree, options: AddFullstackGeneratorSchema) {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// targets: {},
|
|
23
|
-
// });
|
|
20
|
+
const basePath = options.path || '';
|
|
21
|
+
const projectRoot = path.join(basePath, getValid(options.name) ?? 'fullstack-pro');
|
|
22
|
+
|
|
23
|
+
console.log(`basePath: ${basePath}`);
|
|
24
|
+
|
|
24
25
|
generateFiles(tree, path.join(__dirname, 'files'), projectRoot, options);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
|
|
27
|
+
// Update Jenkinsfile with dynamic values
|
|
28
|
+
const jenkinsFilePath = path.join(projectRoot, 'Jenkinsfile');
|
|
29
|
+
updateJenkinsFile(jenkinsFilePath, options.name);
|
|
30
|
+
|
|
31
|
+
// Update package.json with the project name
|
|
32
|
+
updatePackageJson(tree, projectRoot, getValid(options.name));
|
|
33
|
+
|
|
29
34
|
await formatFiles(tree);
|
|
30
35
|
|
|
31
36
|
if (isValid(options.config)) {
|
|
32
|
-
const configPath = getValid(options.config);
|
|
37
|
+
const configPath = path.resolve(basePath, getValid(options.config));
|
|
33
38
|
if (fs.existsSync(configPath)) {
|
|
34
39
|
try {
|
|
35
40
|
const content = String(fs.readFileSync(configPath));
|
|
@@ -37,30 +42,21 @@ export async function addFullstackGenerator(tree: Tree, options: AddFullstackGen
|
|
|
37
42
|
configs.parent = projectRoot;
|
|
38
43
|
|
|
39
44
|
await processConfigs(tree, configs);
|
|
40
|
-
} catch(error) {
|
|
45
|
+
} catch (error) {
|
|
41
46
|
console.error('Error while reading config.', error);
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
|
|
47
|
-
const processConfigs = async (tree: Tree, configs: any) => {
|
|
48
|
-
if (configs.servers) {
|
|
49
|
-
await generateServers(tree, configs.parent, configs.servers);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (configs.packages && configs.packages.modules) {
|
|
53
|
-
await generatePackages(tree, configs.parent, configs.packages.modules);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
52
|
|
|
57
53
|
const generateServers = async (tree: Tree, parent: string, servers: any) => {
|
|
58
54
|
for (const [serverName, serverConfig] of Object.entries(servers)) {
|
|
59
55
|
const configs: any = serverConfig;
|
|
60
56
|
configs.name = serverName;
|
|
61
|
-
configs.directory =
|
|
62
|
-
|
|
63
|
-
switch(configs?.type) {
|
|
57
|
+
configs.directory = path.join(parent, 'servers');
|
|
58
|
+
|
|
59
|
+
switch (configs?.type) {
|
|
64
60
|
case 'frontend':
|
|
65
61
|
await generateFrontend(tree, configs);
|
|
66
62
|
break;
|
|
@@ -74,15 +70,15 @@ const generateServers = async (tree: Tree, parent: string, servers: any) => {
|
|
|
74
70
|
break;
|
|
75
71
|
}
|
|
76
72
|
}
|
|
77
|
-
}
|
|
73
|
+
};
|
|
78
74
|
|
|
79
75
|
const generatePackages = async (tree: Tree, parent: string, packages: any) => {
|
|
80
76
|
for (const [packageName, packageConfig] of Object.entries(packages)) {
|
|
81
77
|
const configs: any = packageConfig;
|
|
82
78
|
configs.name = packageName;
|
|
83
|
-
configs.directory =
|
|
84
|
-
|
|
85
|
-
switch((packageConfig as any)?.type) {
|
|
79
|
+
configs.directory = path.join(parent, 'packages');
|
|
80
|
+
|
|
81
|
+
switch ((packageConfig as any)?.type) {
|
|
86
82
|
case 'packages-core':
|
|
87
83
|
await generateCorePackage(tree, configs);
|
|
88
84
|
break;
|
|
@@ -99,6 +95,16 @@ const generatePackages = async (tree: Tree, parent: string, packages: any) => {
|
|
|
99
95
|
break;
|
|
100
96
|
}
|
|
101
97
|
}
|
|
102
|
-
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const processConfigs = async (tree: Tree, configs: any) => {
|
|
101
|
+
if (configs.servers) {
|
|
102
|
+
await generateServers(tree, configs.parent, configs.servers);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (configs.packages && configs.packages.modules) {
|
|
106
|
+
await generatePackages(tree, configs.parent, configs.packages.modules);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
103
109
|
|
|
104
110
|
export default addFullstackGenerator;
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
"config": {
|
|
13
13
|
"type": "string",
|
|
14
14
|
"description": "The absolute path of config file"
|
|
15
|
+
},
|
|
16
|
+
"path": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "The base path where the project will be created or updated",
|
|
19
|
+
"x-prompt": "Where do you want to create or update the project? (Leave empty for the current directory)"
|
|
15
20
|
}
|
|
16
21
|
},
|
|
17
22
|
"required": ["name"]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
|
|
4
|
+
export function updateJenkinsFile(filePath: string, name: string) {
|
|
5
|
+
const paramsToUpdate = {
|
|
6
|
+
BASE_NAMESPACE: name,
|
|
7
|
+
CONNECTION_ID: name,
|
|
8
|
+
WORKSPACE_ID: name,
|
|
9
|
+
UNIQUE_NAME: name,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
let jenkinsFileContent = '';
|
|
13
|
+
if (fs.existsSync(filePath)) {
|
|
14
|
+
jenkinsFileContent = fs.readFileSync(filePath, 'utf-8');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let labelExists = false;
|
|
18
|
+
|
|
19
|
+
const updatedContent = jenkinsFileContent.split('\n').map(line => {
|
|
20
|
+
// Check if the label is already defined and skip modifying it
|
|
21
|
+
if (line.includes('label') && line.includes('kubernetes')) {
|
|
22
|
+
labelExists = true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Update only the specified parameters
|
|
26
|
+
for (const param in paramsToUpdate) {
|
|
27
|
+
if (line.includes(`string(name: '${param}'`)) {
|
|
28
|
+
return line.replace(/defaultValue: '.*'/, `defaultValue: '${paramsToUpdate[param]}'`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return line;
|
|
32
|
+
}).join('\n');
|
|
33
|
+
|
|
34
|
+
// Add missing parameters if they don't exist
|
|
35
|
+
Object.keys(paramsToUpdate).forEach(param => {
|
|
36
|
+
if (!updatedContent.includes(`string(name: '${param}'`)) {
|
|
37
|
+
updatedContent.concat(
|
|
38
|
+
`string(name: '${param}', defaultValue: '${paramsToUpdate[param]}', description: '${param.replace(/_/g, ' ').toLowerCase()}')\n`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Only write back to the file if we have made changes
|
|
44
|
+
if (!labelExists || Object.keys(paramsToUpdate).some(param => !updatedContent.includes(`string(name: '${param}'`))) {
|
|
45
|
+
fs.writeFileSync(filePath, updatedContent, 'utf-8');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Tree, updateJson } from '@nx/devkit';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
|
|
4
|
+
export function updatePackageJson(tree: Tree, projectRoot: string, name: string) {
|
|
5
|
+
const packageJsonPath = path.join(projectRoot, 'package.json');
|
|
6
|
+
updateJson(tree, packageJsonPath, (packageJson) => {
|
|
7
|
+
packageJson['name'] = name;
|
|
8
|
+
// You can add more custom logic here if needed
|
|
9
|
+
return packageJson;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -25,33 +25,14 @@
|
|
|
25
25
|
"watch": "npm run start:dev"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@common-stack/
|
|
32
|
-
"@common-stack/
|
|
33
|
-
"@common-stack/server-core": "6.0.1-alpha.0",
|
|
34
|
-
"@common-stack/server-stack": "6.0.1-alpha.0",
|
|
35
|
-
"@common-stack/store-mongo": "6.0.1-alpha.0",
|
|
28
|
+
"@common-stack/client-core": "6.0.2-alpha.2",
|
|
29
|
+
"@common-stack/core": "6.0.2-alpha.2",
|
|
30
|
+
"@common-stack/server-core": "6.0.2-alpha.2",
|
|
31
|
+
"@common-stack/server-stack": "6.0.2-alpha.2",
|
|
32
|
+
"@common-stack/store-mongo": "6.0.2-alpha.2",
|
|
36
33
|
"@container-stack/mailing-api": "5.2.1-alpha.1",
|
|
37
|
-
"app-root-path": "^3.0.0",
|
|
38
|
-
"body-parser": "^1.19.0",
|
|
39
|
-
"cors": "^2.8.5",
|
|
40
|
-
"dataloader": "^2.0.0",
|
|
41
|
-
"dotenv": "^7.0.0",
|
|
42
|
-
"envalid": "~7.2.2",
|
|
43
|
-
"esm": "^3.2.25",
|
|
44
|
-
"graphql-tools": "^9.0.0",
|
|
45
34
|
"helmet": "^3.21.2",
|
|
46
|
-
"
|
|
47
|
-
"ioredis": "^4.14.1",
|
|
48
|
-
"lodash": "^4.17.15",
|
|
49
|
-
"moleculer": "^0.14.2",
|
|
50
|
-
"mongoose": "^6.3.3",
|
|
51
|
-
"mongoose-execution-time": "^1.1.0",
|
|
52
|
-
"react": "18.0.0",
|
|
53
|
-
"redux": "^4.0.1",
|
|
54
|
-
"reflect-metadata": "^0.1.13",
|
|
35
|
+
"react": "18.2.0",
|
|
55
36
|
"rxjs": "^6.5.3",
|
|
56
37
|
"rxjs-compat": "^6.5.3"
|
|
57
38
|
},
|