underpost 2.8.44 → 2.8.451

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 (36) hide show
  1. package/.vscode/settings.json +2 -0
  2. package/CHANGELOG.md +16 -0
  3. package/Dockerfile +3 -24
  4. package/bin/build.js +31 -0
  5. package/bin/file.js +15 -13
  6. package/bin/index.js +100 -40
  7. package/docker-compose.yml +1 -1
  8. package/manifests/mongodb/backup-access.yaml +16 -0
  9. package/manifests/mongodb/backup-cronjob.yaml +40 -0
  10. package/manifests/mongodb/backup-pv-pvc.yaml +22 -0
  11. package/manifests/mongodb/configmap.yaml +26 -0
  12. package/manifests/mongodb/headless-service.yaml +10 -0
  13. package/manifests/mongodb/kustomization.yaml +11 -0
  14. package/manifests/mongodb/pv-pvc.yaml +23 -0
  15. package/manifests/mongodb/statefulset.yaml +125 -0
  16. package/manifests/valkey/kustomization.yaml +2 -2
  17. package/manifests/valkey/service.yaml +17 -0
  18. package/manifests/valkey/statefulset.yaml +39 -0
  19. package/package.json +9 -3
  20. package/src/cli/cluster.js +154 -0
  21. package/src/cli/env.js +52 -0
  22. package/src/cli/image.js +118 -0
  23. package/src/cli/repository.js +108 -0
  24. package/src/cli/script.js +29 -0
  25. package/src/cli/secrets.js +37 -0
  26. package/src/cli/test.js +32 -0
  27. package/src/client/components/core/CommonJs.js +73 -1
  28. package/src/client/components/core/Input.js +1 -1
  29. package/src/client/components/core/Scroll.js +1 -0
  30. package/src/index.js +53 -24
  31. package/src/server/conf.js +6 -208
  32. package/src/server/logger.js +2 -3
  33. package/src/server/network.js +1 -1
  34. package/startup.cjs +0 -12
  35. /package/manifests/deployment/{mongo-express.yaml → mongo-express/deployment.yaml} +0 -0
  36. /package/manifests/deployment/{phpmyadmin.yaml → phpmyadmin/deployment.yaml} +0 -0
@@ -811,6 +811,77 @@ const generateRandomPasswordSelection = (length) => {
811
811
  // 0b = Binary
812
812
  // 0o = Octal
813
813
 
814
+ const commitData = {
815
+ feat: {
816
+ description: 'A new feature',
817
+ title: 'Features',
818
+ emoji: '✨',
819
+ },
820
+ fix: {
821
+ description: 'A bug fix',
822
+ title: 'Bug Fixes',
823
+ emoji: '🐛',
824
+ },
825
+ docs: {
826
+ description: 'Documentation only changes',
827
+ title: 'Documentation',
828
+ emoji: '📚',
829
+ },
830
+ style: {
831
+ description:
832
+ 'Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)',
833
+ title: 'Styles',
834
+ emoji: '💎',
835
+ },
836
+ refactor: {
837
+ description: 'A code change that neither fixes a bug nor adds a feature',
838
+ title: 'Code Refactoring',
839
+ emoji: '📦',
840
+ },
841
+ perf: {
842
+ description: 'A code change that improves performance',
843
+ title: 'Performance Improvements',
844
+ emoji: '⚡️',
845
+ },
846
+ cd: {
847
+ description:
848
+ 'Changes to our Continuous Delivery configuration files and scripts (example scopes: Jenkins, Spinnaker, ArgoCD)',
849
+ title: 'Continuous Delivery',
850
+ emoji: '🚀',
851
+ },
852
+ test: {
853
+ description: 'Adding missing tests or correcting existing tests',
854
+ title: 'Tests',
855
+ emoji: '🚨',
856
+ },
857
+ build: {
858
+ description: 'Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)',
859
+ title: 'Builds',
860
+ emoji: '🛠',
861
+ },
862
+ ci: {
863
+ description:
864
+ 'Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)',
865
+ title: 'Continuous Integrations',
866
+ emoji: '⚙️',
867
+ },
868
+ chore: {
869
+ description: "Other changes that don't modify src or test files",
870
+ title: 'Chores',
871
+ emoji: '♻️',
872
+ },
873
+ revert: {
874
+ description: 'Reverts a previous commit',
875
+ title: 'Reverts',
876
+ emoji: '🗑',
877
+ },
878
+ backup: {
879
+ description: 'Changes related to backups, including creation, restoration, and maintenance.',
880
+ title: 'Backups',
881
+ emoji: '💾',
882
+ },
883
+ };
884
+
814
885
  const userRoleEnum = ['admin', 'moderator', 'user', 'guest'];
815
886
 
816
887
  const commonAdminGuard = (role) => userRoleEnum.indexOf(role) === userRoleEnum.indexOf('admin');
@@ -869,8 +940,9 @@ export {
869
940
  hexToNumber,
870
941
  numberToHex,
871
942
  generateRandomPasswordSelection,
872
- userRoleEnum,
873
943
  commonAdminGuard,
874
944
  commonModeratorGuard,
875
945
  isChileanIdentityDocument,
946
+ userRoleEnum,
947
+ commitData,
876
948
  };
@@ -100,7 +100,7 @@ const Input = {
100
100
  </div>
101
101
  </div>`;
102
102
  },
103
- parseJsonEval: (selector) => {
103
+ parseJson: (selector) => {
104
104
  try {
105
105
  return JSON.parse(s(selector).value);
106
106
  } catch (error) {
@@ -39,6 +39,7 @@ const Scroll = {
39
39
  delete this.topRefreshEvents[id];
40
40
  },
41
41
  pullTopRefresh: function () {
42
+ return;
42
43
  append(
43
44
  'body',
44
45
  html` <style>
package/src/index.js CHANGED
@@ -4,10 +4,13 @@
4
4
  * @namespace Underpost
5
5
  */
6
6
 
7
- import { runTest } from './server/conf.js';
8
- import { loggerFactory, setUpInfo } from './server/logger.js';
9
-
10
- const logger = loggerFactory(import.meta);
7
+ import UnderpostCluster from './cli/cluster.js';
8
+ import UnderpostRootEnv from './cli/env.js';
9
+ import UnderpostImage from './cli/image.js';
10
+ import UnderpostRepository from './cli/repository.js';
11
+ import UnderpostScript from './cli/script.js';
12
+ import UnderpostSecret from './cli/secrets.js';
13
+ import UnderpostTest from './cli/test.js';
11
14
 
12
15
  /**
13
16
  * Underpost main module methods
@@ -21,30 +24,56 @@ class Underpost {
21
24
  * @type {String}
22
25
  * @memberof Underpost
23
26
  */
24
- static version = 'v2.8.44';
25
-
26
- constructor() {}
27
-
27
+ static version = 'v2.8.451';
28
28
  /**
29
- * Logs information about the current process environment to the console.
30
- *
31
- * This function is used to log details about
32
- * the execution context, such as command-line arguments,
33
- * environment variables, the process's administrative privileges,
34
- * and the maximum available heap space size.
35
- *
29
+ * Repository cli API
36
30
  * @static
37
- * @method setUpInfo
38
- * @returns {Promise<void>}
31
+ * @type {UnderpostRepository.API}
39
32
  * @memberof Underpost
40
33
  */
41
- static async setUpInfo() {
42
- return await setUpInfo(logger);
43
- }
44
-
45
- static runTest() {
46
- return runTest(Underpost.version);
47
- }
34
+ static repo = UnderpostRepository.API;
35
+ /**
36
+ * Root Env cli API
37
+ * @static
38
+ * @type {UnderpostRootEnv.API}
39
+ * @memberof Underpost
40
+ */
41
+ static env = UnderpostRootEnv.API;
42
+ /**
43
+ * Test cli API
44
+ * @static
45
+ * @type {UnderpostTest.API}
46
+ * @memberof Underpost
47
+ */
48
+ static test = UnderpostTest.API;
49
+ /**
50
+ * Cluster cli API
51
+ * @static
52
+ * @type {UnderpostCluster.API}
53
+ * @memberof Underpost
54
+ */
55
+ static cluster = UnderpostCluster.API;
56
+ /**
57
+ * Image cli API
58
+ * @static
59
+ * @type {UnderpostImage.API}
60
+ * @memberof Underpost
61
+ */
62
+ static image = UnderpostImage.API;
63
+ /**
64
+ * Secrets cli API
65
+ * @static
66
+ * @type {UnderpostSecret.API}
67
+ * @memberof Underpost
68
+ */
69
+ static secret = UnderpostSecret.API;
70
+ /**
71
+ * Scripts cli API
72
+ * @static
73
+ * @type {UnderpostScript.API}
74
+ * @memberof Underpost
75
+ */
76
+ static script = UnderpostScript.API;
48
77
  }
49
78
 
50
79
  const up = Underpost;
@@ -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,7 +84,6 @@ 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);
89
88
  logger.info('platform', process.platform);
90
89
  logger.info('env', process.env.NODE_ENV);
@@ -186,11 +185,11 @@ const underpostASCI = () => `
186
185
  ░╚═════╝░╚═╝░░╚══╝╚═════╝░╚══════╝╚═╝░░╚═╝╚═╝░░░░░░╚════╝░╚═════╝░░░░╚═╝░░░
187
186
  `;
188
187
 
189
- const actionInitLog = (version = '0.0.0') =>
188
+ const actionInitLog = () =>
190
189
  console.log(
191
190
  underpostASCI() +
192
191
  `
193
- ${version} https://www.nexodev.org/docs
192
+ https://www.nexodev.org/docs
194
193
  `,
195
194
  );
196
195
 
@@ -40,7 +40,7 @@ const saveRuntimeRouter = async () => {
40
40
  const path = process.env.DEFAULT_DEPLOY_PATH;
41
41
  const confServerPath = `./engine-private/conf/${deployId}/conf.server.json`;
42
42
  if (!deployId || !host || !path) {
43
- logger.warn('default deploy instance not found');
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`);