underpost 2.8.44 → 2.8.46

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.
Files changed (45) hide show
  1. package/.github/workflows/ghpkg.yml +13 -46
  2. package/.github/workflows/npmpkg.yml +67 -0
  3. package/.github/workflows/publish.yml +5 -5
  4. package/.github/workflows/pwa-microservices-template.page.yml +3 -2
  5. package/.github/workflows/pwa-microservices-template.test.yml +2 -2
  6. package/.vscode/settings.json +2 -0
  7. package/CHANGELOG.md +16 -0
  8. package/Dockerfile +3 -24
  9. package/bin/build.js +37 -0
  10. package/bin/deploy.js +1 -14
  11. package/bin/file.js +19 -13
  12. package/bin/index.js +117 -39
  13. package/docker-compose.yml +1 -1
  14. package/manifests/mongodb/backup-access.yaml +16 -0
  15. package/manifests/mongodb/backup-cronjob.yaml +40 -0
  16. package/manifests/mongodb/backup-pv-pvc.yaml +22 -0
  17. package/manifests/mongodb/configmap.yaml +26 -0
  18. package/manifests/mongodb/headless-service.yaml +10 -0
  19. package/manifests/mongodb/kustomization.yaml +11 -0
  20. package/manifests/mongodb/pv-pvc.yaml +23 -0
  21. package/manifests/mongodb/statefulset.yaml +125 -0
  22. package/manifests/valkey/kustomization.yaml +2 -2
  23. package/manifests/valkey/service.yaml +17 -0
  24. package/manifests/valkey/statefulset.yaml +39 -0
  25. package/package.json +25 -5
  26. package/src/cli/cluster.js +154 -0
  27. package/src/cli/db.js +98 -0
  28. package/src/cli/env.js +52 -0
  29. package/src/cli/image.js +118 -0
  30. package/src/cli/repository.js +108 -0
  31. package/src/cli/script.js +29 -0
  32. package/src/cli/secrets.js +37 -0
  33. package/src/cli/test.js +32 -0
  34. package/src/client/components/core/Auth.js +22 -4
  35. package/src/client/components/core/CommonJs.js +73 -1
  36. package/src/client/components/core/Input.js +1 -1
  37. package/src/client/components/core/Scroll.js +1 -0
  38. package/src/client/components/core/Translate.js +4 -0
  39. package/src/index.js +61 -24
  40. package/src/server/conf.js +6 -208
  41. package/src/server/logger.js +3 -3
  42. package/src/server/network.js +2 -2
  43. package/startup.cjs +0 -12
  44. /package/manifests/deployment/{mongo-express.yaml → mongo-express/deployment.yaml} +0 -0
  45. /package/manifests/deployment/{phpmyadmin.yaml → phpmyadmin/deployment.yaml} +0 -0
@@ -13,8 +13,8 @@ import cliProgress from 'cli-progress';
13
13
  import cliSpinners from 'cli-spinners';
14
14
  import logUpdate from 'log-update';
15
15
  import colors from 'colors';
16
- import { actionInitLog, loggerFactory } from './logger.js';
17
- import { pbcopy, shellExec } from './process.js';
16
+ import { loggerFactory } from './logger.js';
17
+ import { shellExec } from './process.js';
18
18
  import { DefaultConf } from '../../conf.js';
19
19
  import read from 'read';
20
20
  import splitFile from 'split-file';
@@ -525,9 +525,11 @@ const buildPortProxyRouter = (port, proxyRouter) => {
525
525
 
526
526
  if (Object.keys(router).length === 0) return router;
527
527
 
528
+ const reOrderRouter = {};
528
529
  for (const absoluteHostKey of orderArrayFromAttrInt(Object.keys(router), 'length'))
529
- router[absoluteHostKey] = router[absoluteHostKey];
530
- return router;
530
+ reOrderRouter[absoluteHostKey] = router[absoluteHostKey];
531
+
532
+ return reOrderRouter;
531
533
  };
532
534
 
533
535
  const cliBar = async (time = 5000) => {
@@ -1039,132 +1041,6 @@ const setUpProxyMaintenanceServer = ({ deployGroupId }) => {
1039
1041
  shellExec(`node bin/deploy run ${proxyDeployId} maintenance`);
1040
1042
  };
1041
1043
 
1042
- const repoClone = (gitUri = 'underpostnet/pwa-microservices-template') => {
1043
- const repoName = gitUri.split('/').pop();
1044
- if (fs.existsSync(`./${repoName}`)) fs.removeSync(`./${repoName}`);
1045
- shellExec(
1046
- `git clone https://${process.env.GITHUB_TOKEN ? `${process.env.GITHUB_TOKEN}@` : ''}github.com/${gitUri}.git`,
1047
- );
1048
- if (process.env.GITHUB_TOKEN) {
1049
- shellExec(
1050
- `git clone https://${
1051
- process.env.GITHUB_TOKEN ? `${process.env.GITHUB_TOKEN}@` : ''
1052
- }github.com/${gitUri}-private.git`,
1053
- );
1054
- fs.moveSync(`./${repoName}-private`, `./${repoName}/engine-private`, {
1055
- overwrite: true,
1056
- });
1057
- }
1058
- };
1059
-
1060
- const repoPull = (repoPath = './', gitUri = 'underpostnet/pwa-microservices-template') => {
1061
- shellExec(`cd ${repoPath} && git pull https://${process.env.GITHUB_TOKEN}@github.com/${gitUri}.git`, {
1062
- disableLog: true,
1063
- });
1064
- };
1065
-
1066
- const commitData = {
1067
- feat: {
1068
- description: 'A new feature',
1069
- title: 'Features',
1070
- emoji: '✨',
1071
- },
1072
- fix: {
1073
- description: 'A bug fix',
1074
- title: 'Bug Fixes',
1075
- emoji: '🐛',
1076
- },
1077
- docs: {
1078
- description: 'Documentation only changes',
1079
- title: 'Documentation',
1080
- emoji: '📚',
1081
- },
1082
- style: {
1083
- description:
1084
- 'Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)',
1085
- title: 'Styles',
1086
- emoji: '💎',
1087
- },
1088
- refactor: {
1089
- description: 'A code change that neither fixes a bug nor adds a feature',
1090
- title: 'Code Refactoring',
1091
- emoji: '📦',
1092
- },
1093
- perf: {
1094
- description: 'A code change that improves performance',
1095
- title: 'Performance Improvements',
1096
- emoji: '⚡️',
1097
- },
1098
- cd: {
1099
- description:
1100
- 'Changes to our Continuous Delivery configuration files and scripts (example scopes: Jenkins, Spinnaker, ArgoCD)',
1101
- title: 'Continuous Delivery',
1102
- emoji: '🚀',
1103
- },
1104
- test: {
1105
- description: 'Adding missing tests or correcting existing tests',
1106
- title: 'Tests',
1107
- emoji: '🚨',
1108
- },
1109
- build: {
1110
- description: 'Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)',
1111
- title: 'Builds',
1112
- emoji: '🛠',
1113
- },
1114
- ci: {
1115
- description:
1116
- 'Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)',
1117
- title: 'Continuous Integrations',
1118
- emoji: '⚙️',
1119
- },
1120
- chore: {
1121
- description: "Other changes that don't modify src or test files",
1122
- title: 'Chores',
1123
- emoji: '♻️',
1124
- },
1125
- revert: {
1126
- description: 'Reverts a previous commit',
1127
- title: 'Reverts',
1128
- emoji: '🗑',
1129
- },
1130
- backup: {
1131
- description: 'Changes related to backups, including creation, restoration, and maintenance.',
1132
- title: 'Backups',
1133
- emoji: '💾',
1134
- },
1135
- };
1136
-
1137
- const repoCommit = (
1138
- repoPath = './',
1139
- commitType = 'feat',
1140
- subModule = '',
1141
- message = '',
1142
- options = {
1143
- copy: false,
1144
- info: false,
1145
- empty: false,
1146
- },
1147
- ) => {
1148
- if (options.info) return logger.info('', commitData);
1149
- const _message = `${commitType}${subModule ? `(${subModule})` : ''}${process.argv.includes('!') ? '!' : ''}: ${
1150
- commitData[commitType].emoji
1151
- } ${message ? message : commitData[commitType].description}`;
1152
- if (options.copy) return pbcopy(_message);
1153
- shellExec(`cd ${repoPath} && git commit ${options?.empty ? `--allow-empty ` : ''}-m "${_message}"`);
1154
- };
1155
-
1156
- const repoPush = (repoPath = './', gitUri = 'underpostnet/pwa-microservices-template') => {
1157
- shellExec(`cd ${repoPath} && git push https://${process.env.GITHUB_TOKEN}@github.com/${gitUri}.git`, {
1158
- disableLog: true,
1159
- });
1160
- logger.info(
1161
- 'commit url',
1162
- `http://github.com/${gitUri}/commit/${shellExec(`cd ${repoPath} && git rev-parse --verify HEAD`, {
1163
- stdout: true,
1164
- }).trim()}`,
1165
- );
1166
- };
1167
-
1168
1044
  const getNpmRootPath = () =>
1169
1045
  shellExec(`npm root -g`, {
1170
1046
  stdout: true,
@@ -1172,37 +1048,6 @@ const getNpmRootPath = () =>
1172
1048
  silent: true,
1173
1049
  }).trim();
1174
1050
 
1175
- const newProject = (repositoryName, version) => {
1176
- return new Promise(async (resolve, reject) => {
1177
- try {
1178
- const exeRootPath = `${getNpmRootPath()}/underpost`;
1179
- // const exeRootPath = '/home/dd/pwa-microservices-template';
1180
- actionInitLog(version);
1181
- await logger.setUpInfo();
1182
- const destFolder = `${process.cwd()}/${repositoryName}`;
1183
- logger.info('Note: This process may take several minutes to complete');
1184
- logger.info('build app', { destFolder });
1185
- fs.mkdirSync(destFolder, { recursive: true });
1186
- fs.copySync(exeRootPath, destFolder);
1187
- if (fs.existsSync(`${destFolder}/node_modules`)) fs.removeSync(`${destFolder}/node_modules`);
1188
- fs.writeFileSync(`${destFolder}/.gitignore`, fs.readFileSync(`${exeRootPath}/.dockerignore`, 'utf8'), 'utf8');
1189
- shellExec(`cd ${destFolder} && git init && git add . && git commit -m "Base template implementation"`);
1190
- shellExec(`cd ${destFolder} && npm install`);
1191
- shellExec(`cd ${destFolder} && npm run build`);
1192
- shellExec(`cd ${destFolder} && npm run dev`);
1193
- return resolve();
1194
- } catch (error) {
1195
- logger.error(error, error.stack);
1196
- return reject(error.message);
1197
- }
1198
- });
1199
- };
1200
-
1201
- const runTest = (version) => {
1202
- actionInitLog(version);
1203
- shellExec(`cd ${getNpmRootPath()}/underpost && npm run test`);
1204
- };
1205
-
1206
1051
  const writeEnv = (envPath, envObj) =>
1207
1052
  fs.writeFileSync(
1208
1053
  envPath,
@@ -1212,46 +1057,6 @@ const writeEnv = (envPath, envObj) =>
1212
1057
  'utf8',
1213
1058
  );
1214
1059
 
1215
- const UnderpostRootEnv = {
1216
- set: (key, value) => {
1217
- const exeRootPath = `${getNpmRootPath()}/underpost`;
1218
- const envPath = `${exeRootPath}/.env`;
1219
- let env = {};
1220
- if (fs.existsSync(envPath)) env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
1221
- env[key] = value;
1222
- writeEnv(envPath, env);
1223
- },
1224
- delete: (key, value) => {
1225
- const exeRootPath = `${getNpmRootPath()}/underpost`;
1226
- const envPath = `${exeRootPath}/.env`;
1227
- let env = {};
1228
- if (fs.existsSync(envPath)) env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
1229
- delete env[key];
1230
- writeEnv(envPath, env);
1231
- },
1232
- get: (key) => {
1233
- const exeRootPath = `${getNpmRootPath()}/underpost`;
1234
- const envPath = `${exeRootPath}/.env`;
1235
- if (!fs.existsSync(envPath)) return logger.error(`Unable to find underpost root environment`);
1236
- const env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
1237
- logger.info('underpost root', { [key]: env[key] });
1238
- return env[key];
1239
- },
1240
- list: () => {
1241
- const exeRootPath = `${getNpmRootPath()}/underpost`;
1242
- const envPath = `${exeRootPath}/.env`;
1243
- if (!fs.existsSync(envPath)) return logger.error(`Unable to find underpost root environment`);
1244
- const env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
1245
- logger.info('underpost root', env);
1246
- return env;
1247
- },
1248
- clean: () => {
1249
- const exeRootPath = `${getNpmRootPath()}/underpost`;
1250
- const envPath = `${exeRootPath}/.env`;
1251
- fs.removeSync(envPath);
1252
- },
1253
- };
1254
-
1255
1060
  export {
1256
1061
  Cmd,
1257
1062
  Config,
@@ -1287,13 +1092,6 @@ export {
1287
1092
  buildKindPorts,
1288
1093
  buildPortProxyRouter,
1289
1094
  splitFileFactory,
1290
- repoClone,
1291
- repoPull,
1292
- repoCommit,
1293
- repoPush,
1294
- newProject,
1295
- runTest,
1296
1095
  getNpmRootPath,
1297
1096
  writeEnv,
1298
- UnderpostRootEnv,
1299
1097
  };
@@ -84,8 +84,8 @@ const format = (meta) =>
84
84
  * @memberof Logger
85
85
  */
86
86
  const setUpInfo = async (logger = new winston.Logger()) => {
87
- logger.info('npm_package_version', process.env.npm_package_version);
88
87
  logger.info('argv', process.argv);
88
+ logger.info('cwd', process.cwd());
89
89
  logger.info('platform', process.platform);
90
90
  logger.info('env', process.env.NODE_ENV);
91
91
  logger.info('--max-old-space-size', {
@@ -186,11 +186,11 @@ const underpostASCI = () => `
186
186
  ░╚═════╝░╚═╝░░╚══╝╚═════╝░╚══════╝╚═╝░░╚═╝╚═╝░░░░░░╚════╝░╚═════╝░░░░╚═╝░░░
187
187
  `;
188
188
 
189
- const actionInitLog = (version = '0.0.0') =>
189
+ const actionInitLog = () =>
190
190
  console.log(
191
191
  underpostASCI() +
192
192
  `
193
- ${version} https://www.nexodev.org/docs
193
+ https://www.nexodev.org/docs
194
194
  `,
195
195
  );
196
196
 
@@ -39,8 +39,8 @@ const saveRuntimeRouter = async () => {
39
39
  const host = process.env.DEFAULT_DEPLOY_HOST;
40
40
  const path = process.env.DEFAULT_DEPLOY_PATH;
41
41
  const confServerPath = `./engine-private/conf/${deployId}/conf.server.json`;
42
- if (!deployId || !host || !path) {
43
- logger.warn('default deploy instance not found');
42
+ if (!deployId || !host || !path || !fs.existsSync(confServerPath)) {
43
+ // logger.warn('default deploy instance not found');
44
44
  return;
45
45
  }
46
46
  const confServer = JSON.parse(fs.readFileSync(confServerPath, 'utf8'));
package/startup.cjs DELETED
@@ -1,12 +0,0 @@
1
- const shell = require('shelljs');
2
-
3
- // /usr/bin/supervisord -n
4
- // /usr/sbin/sshd -D
5
-
6
- shell.exec(`/usr/bin/supervisord -n`, { async: true });
7
-
8
- // shell.exec(`sudo /opt/lampp/lampp start`, { async: true });
9
-
10
- // shell.exec(`/usr/bin/mongod -f /etc/mongod.conf`, { async: true });
11
-
12
- shell.exec(`underpost new app`);