underpost 2.8.6 → 2.8.7

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 (79) hide show
  1. package/.vscode/extensions.json +3 -2
  2. package/.vscode/settings.json +2 -0
  3. package/CHANGELOG.md +24 -4
  4. package/Dockerfile +9 -10
  5. package/README.md +39 -2
  6. package/bin/build.js +2 -2
  7. package/bin/deploy.js +1337 -131
  8. package/bin/file.js +8 -0
  9. package/bin/index.js +1 -218
  10. package/cli.md +451 -0
  11. package/docker-compose.yml +1 -1
  12. package/jsdoc.json +1 -1
  13. package/manifests/calico-custom-resources.yaml +25 -0
  14. package/manifests/deployment/adminer/deployment.yaml +32 -0
  15. package/manifests/deployment/adminer/kustomization.yaml +7 -0
  16. package/manifests/deployment/adminer/service.yaml +13 -0
  17. package/manifests/deployment/fastapi/backend-deployment.yml +120 -0
  18. package/manifests/deployment/fastapi/backend-service.yml +19 -0
  19. package/manifests/deployment/fastapi/frontend-deployment.yml +54 -0
  20. package/manifests/deployment/fastapi/frontend-service.yml +15 -0
  21. package/manifests/deployment/kafka/deployment.yaml +69 -0
  22. package/manifests/kubeadm-calico-config.yaml +119 -0
  23. package/manifests/mongodb-4.4/service-deployment.yaml +1 -1
  24. package/manifests/postgresql/configmap.yaml +9 -0
  25. package/manifests/postgresql/kustomization.yaml +10 -0
  26. package/manifests/postgresql/pv.yaml +15 -0
  27. package/manifests/postgresql/pvc.yaml +13 -0
  28. package/manifests/postgresql/service.yaml +10 -0
  29. package/manifests/postgresql/statefulset.yaml +37 -0
  30. package/manifests/valkey/statefulset.yaml +6 -4
  31. package/package.json +3 -9
  32. package/src/api/default/default.service.js +1 -1
  33. package/src/api/user/user.service.js +14 -11
  34. package/src/cli/cluster.js +207 -20
  35. package/src/cli/cron.js +39 -8
  36. package/src/cli/db.js +20 -10
  37. package/src/cli/deploy.js +254 -85
  38. package/src/cli/env.js +9 -3
  39. package/src/cli/fs.js +21 -9
  40. package/src/cli/image.js +42 -124
  41. package/src/cli/index.js +312 -0
  42. package/src/cli/monitor.js +236 -0
  43. package/src/cli/repository.js +5 -2
  44. package/src/client/components/core/Account.js +28 -24
  45. package/src/client/components/core/Blockchain.js +1 -1
  46. package/src/client/components/core/CalendarCore.js +14 -84
  47. package/src/client/components/core/CommonJs.js +2 -1
  48. package/src/client/components/core/Css.js +0 -1
  49. package/src/client/components/core/CssCore.js +10 -2
  50. package/src/client/components/core/Docs.js +1 -1
  51. package/src/client/components/core/EventsUI.js +3 -3
  52. package/src/client/components/core/FileExplorer.js +86 -78
  53. package/src/client/components/core/JoyStick.js +2 -2
  54. package/src/client/components/core/LoadingAnimation.js +1 -17
  55. package/src/client/components/core/LogIn.js +3 -3
  56. package/src/client/components/core/LogOut.js +1 -1
  57. package/src/client/components/core/Modal.js +14 -8
  58. package/src/client/components/core/Panel.js +19 -61
  59. package/src/client/components/core/PanelForm.js +13 -22
  60. package/src/client/components/core/Recover.js +3 -3
  61. package/src/client/components/core/RichText.js +1 -11
  62. package/src/client/components/core/Router.js +3 -1
  63. package/src/client/components/core/SignUp.js +2 -2
  64. package/src/client/components/default/RoutesDefault.js +3 -2
  65. package/src/client/services/default/default.management.js +45 -38
  66. package/src/client/ssr/Render.js +2 -0
  67. package/src/index.js +18 -2
  68. package/src/mailer/MailerProvider.js +3 -0
  69. package/src/runtime/lampp/Dockerfile +65 -0
  70. package/src/server/client-build.js +13 -0
  71. package/src/server/conf.js +93 -1
  72. package/src/server/dns.js +56 -18
  73. package/src/server/json-schema.js +77 -0
  74. package/src/server/network.js +7 -122
  75. package/src/server/peer.js +2 -2
  76. package/src/server/proxy.js +4 -4
  77. package/src/server/runtime.js +24 -11
  78. package/src/server/start.js +122 -0
  79. package/src/server/valkey.js +25 -11
package/src/cli/image.js CHANGED
@@ -1,13 +1,14 @@
1
1
  import fs from 'fs-extra';
2
- import Underpost from '../index.js';
3
2
  import { shellCd, shellExec } from '../server/process.js';
4
3
  import dotenv from 'dotenv';
5
- import { getNpmRootPath } from '../server/conf.js';
6
- import { timer } from '../client/components/core/CommonJs.js';
7
- import UnderpostRootEnv from './env.js';
4
+ import { awaitDeployMonitor, getNpmRootPath } from '../server/conf.js';
5
+ import { loggerFactory } from '../server/logger.js';
6
+ import UnderpostMonitor from './monitor.js';
8
7
 
9
8
  dotenv.config();
10
9
 
10
+ const logger = loggerFactory(import.meta);
11
+
11
12
  class UnderpostImage {
12
13
  static API = {
13
14
  dockerfile: {
@@ -15,132 +16,49 @@ class UnderpostImage {
15
16
  shellExec(`sudo podman pull docker.io/library/debian:buster`);
16
17
  },
17
18
  build(
18
- deployId = 'default',
19
- env = 'development',
20
- path = '.',
21
- options = { imageArchive: false, podmanSave: false, imageName: '', imageVersion: '' },
19
+ options = {
20
+ path: '',
21
+ imageName: '',
22
+ imagePath: '',
23
+ dockerfileName: '',
24
+ podmanSave: false,
25
+ kindLoad: false,
26
+ secrets: false,
27
+ secretsPath: '',
28
+ noCache: false,
29
+ },
22
30
  ) {
23
- const imgName = `${
24
- options.imageName && typeof options.imageName === 'string' ? options.imageName : `${deployId}-${env}`
25
- }:${
26
- options.imageVersion && typeof options.imageVersions === 'string' ? options.imageVersion : Underpost.version
27
- }`;
28
- const podManImg = `localhost/${imgName}`;
29
- const imagesStoragePath = `/images`;
30
- if (!fs.existsSync(`${path}${imagesStoragePath}`))
31
- fs.mkdirSync(`${path}${imagesStoragePath}`, { recursive: true });
32
- const tarFile = `.${imagesStoragePath}/${imgName.replace(':', '_')}.tar`;
33
-
34
- let secrets = ' ';
31
+ const { path, imageName, imagePath, dockerfileName, podmanSave, secrets, secretsPath, kindLoad, noCache } =
32
+ options;
33
+ const podManImg = `localhost/${imageName}`;
34
+ if (imagePath && typeof imagePath === 'string' && !fs.existsSync(imagePath))
35
+ fs.mkdirSync(imagePath, { recursive: true });
36
+ const tarFile = `${imagePath}/${imageName.replace(':', '_')}.tar`;
37
+ let secretsInput = ' ';
35
38
  let secretDockerInput = '';
36
-
37
- const envObj = dotenv.parse(fs.readFileSync(`${getNpmRootPath()}/underpost/.env`, 'utf8'));
38
-
39
- for (const key of Object.keys(envObj)) {
40
- continue;
41
- secrets += ` && export ${key}="${envObj[key]}" `; // $(cat gitlab-token.txt)
42
- secretDockerInput += ` --secret id=${key},env=${key} \ `;
43
- }
44
- // --rm --no-cache
45
- if (options.imageArchive !== true) {
46
- fs.copyFile(`${getNpmRootPath()}/underpost/.env`, `${path}/.env.underpost`);
47
- shellExec(
48
- `cd ${path}${secrets}&& sudo podman build -f ./Dockerfile -t ${imgName} --pull=never --cap-add=CAP_AUDIT_WRITE${secretDockerInput}`,
39
+ let cache = '';
40
+ if (secrets === true) {
41
+ const envObj = dotenv.parse(
42
+ fs.readFileSync(
43
+ secretsPath && typeof secretsPath === 'string' ? secretsPath : `${getNpmRootPath()}/underpost/.env`,
44
+ 'utf8',
45
+ ),
49
46
  );
50
- fs.removeSync(`${path}/.env.underpost`);
51
- }
52
- if (options.imageArchive !== true || options.podmanSave === true)
53
- shellExec(`cd ${path} && podman save -o ${tarFile} ${podManImg}`);
54
- shellExec(`cd ${path} && sudo kind load image-archive ${tarFile}`);
55
- },
56
- async script(deployId = 'default', env = 'development', options = { run: false, build: false }) {
57
- if (deployId === 'deploy') {
58
- const _deployId = UnderpostRootEnv.API.get('deploy-id');
59
- const _env = UnderpostRootEnv.API.get('deploy-env');
60
- const _path = UnderpostRootEnv.API.get('deploy-path');
61
- if (_deployId) {
62
- deployId = _deployId;
63
- if (_env) env = _env;
64
- if (_path) path = _path;
65
- } else {
66
- await timer(30 * 1000);
67
- return await UnderpostImage.API.script(deployId, env, path, options);
47
+ for (const key of Object.keys(envObj)) {
48
+ secretsInput += ` && export ${key}="${envObj[key]}" `; // $(cat gitlab-token.txt)
49
+ secretDockerInput += ` --secret id=${key},env=${key} \ `;
68
50
  }
69
51
  }
70
- if (options.build === true) {
71
- const buildBasePath = `/home/dd`;
72
- const repoName = `engine-${deployId.split('-')[1]}`;
73
- fs.mkdirSync(buildBasePath, { recursive: true });
74
- shellExec(`cd ${buildBasePath} && underpost clone underpostnet/${repoName}`);
75
- shellExec(`cd ${buildBasePath} && sudo mv ./${repoName} ./engine`);
76
- shellExec(`cd ${buildBasePath}/engine && underpost clone underpostnet/${repoName}-private`);
77
- shellExec(`cd ${buildBasePath}/engine && sudo mv ./${repoName}-private ./engine-private`);
78
- shellCd(`${buildBasePath}/engine`);
79
- shellExec(`npm install`);
80
- const itcScripts = fs.readdir('./engine-private/itc-scripts');
81
- for (const itcScript of itcScripts)
82
- if (itcScript.match(deployId)) shellExec(`node ./engine-private/itc-scripts/${itcScript}`);
83
- }
84
- switch (deployId) {
85
- case 'dd-lampp':
86
- {
87
- const lamppPublicPath = '/xampp/htdocs/online';
88
- shellExec(`sudo mkdir -p ${lamppPublicPath}`);
89
- }
90
- break;
91
-
92
- default:
93
- {
94
- {
95
- const originPath = `./src/db/mongo/MongooseDB.js`;
96
- fs.writeFileSync(
97
- originPath,
98
- fs.readFileSync(originPath, 'utf8').replaceAll(
99
- `connect: async (host, name) => {`,
100
- `connect: async (host, name) => {
101
- host = 'mongodb://mongodb-0.mongodb-service:27017';
102
- `,
103
- ),
104
- 'utf8',
105
- );
106
- }
52
+ if (noCache === true) cache += ' --rm --no-cache';
53
+ if (path && typeof path === 'string')
54
+ shellExec(
55
+ `cd ${path}${secretsInput}&& sudo podman build -f ./${
56
+ dockerfileName && typeof dockerfileName === 'string' ? dockerfileName : 'Dockerfile'
57
+ } -t ${imageName} --pull=never --cap-add=CAP_AUDIT_WRITE${cache}${secretDockerInput} --network host`,
58
+ );
107
59
 
108
- {
109
- const originPath = `./src/server/valkey.js`;
110
- fs.writeFileSync(
111
- originPath,
112
- fs.readFileSync(originPath, 'utf8').replaceAll(
113
- ` // port: 6379,
114
- // host: 'service-valkey.default.svc.cluster.local',`,
115
- ` port: 6379,
116
- host: 'service-valkey.default.svc.cluster.local',`,
117
- ),
118
- 'utf8',
119
- );
120
- }
121
- }
122
- break;
123
- }
124
- shellExec(`node bin/deploy conf ${deployId} ${env}`);
125
- shellExec(`node bin/deploy build-full-client ${deployId}`);
126
- if (options.run === true) {
127
- const runCmd = env === 'production' ? 'run prod-img' : 'run dev-img';
128
- if (fs.existsSync(`./engine-private/replica`)) {
129
- const replicas = await fs.readdir(`./engine-private/replica`);
130
- for (const replica of replicas) {
131
- shellExec(`node bin/deploy conf ${replica} ${env}`);
132
- shellExec(`npm ${runCmd} ${replica} deploy`, { async: true });
133
- fs.writeFileSync(`./tmp/await-deploy`, '', 'utf8');
134
- const monitor = async () => {
135
- await timer(1000);
136
- if (fs.existsSync(`./tmp/await-deploy`)) return await monitor();
137
- };
138
- await monitor();
139
- }
140
- shellExec(`node bin/deploy conf ${deployId} ${env}`);
141
- }
142
- shellExec(`npm ${runCmd} ${deployId} deploy`);
143
- }
60
+ if (podmanSave === true) shellExec(`podman save -o ${tarFile} ${podManImg}`);
61
+ if (kindLoad === true) shellExec(`sudo kind load image-archive ${tarFile}`);
144
62
  },
145
63
  },
146
64
  };
@@ -0,0 +1,312 @@
1
+ import dotenv from 'dotenv';
2
+ import { Command } from 'commander';
3
+ import Underpost from '../index.js';
4
+ import { getUnderpostRootPath, loadConf } from '../server/conf.js';
5
+ import fs from 'fs-extra';
6
+ import { commitData } from '../client/components/core/CommonJs.js';
7
+ import { shellExec } from '../server/process.js';
8
+
9
+ const underpostRootPath = getUnderpostRootPath();
10
+ fs.existsSync(`${underpostRootPath}/.env`)
11
+ ? dotenv.config({ path: `${underpostRootPath}/.env`, override: true })
12
+ : dotenv.config();
13
+
14
+ const program = new Command();
15
+
16
+ program.name('underpost').description(`underpost ci/cd cli ${Underpost.version}`).version(Underpost.version);
17
+
18
+ program
19
+ .command('new')
20
+ .argument('<app-name>', 'Application name')
21
+ .description('Create a new project')
22
+ .action(Underpost.repo.new);
23
+
24
+ program
25
+ .command('start')
26
+ .argument('<deploy-id>', 'Deploy configuration id')
27
+ .argument('[env]', 'Optional environment, for default is development')
28
+ .option('--run', 'Run app servers and monitor health server')
29
+ .option('--build', 'Build app client')
30
+ .action(Underpost.start.callback)
31
+ .description('Start up server, build pipelines, or services');
32
+
33
+ program
34
+ .command('clone')
35
+ .argument(`<uri>`, 'e.g. username/repository')
36
+ .option('--bare', 'Clone only .git files')
37
+ .description('Clone github repository')
38
+ .action(Underpost.repo.clone);
39
+
40
+ program
41
+ .command('pull')
42
+ .argument('<path>', 'Absolute or relative directory')
43
+ .argument(`<uri>`, 'e.g. username/repository')
44
+ .description('Pull github repository')
45
+ .action(Underpost.repo.pull);
46
+
47
+ program
48
+ .command('cmt')
49
+ .argument('<path>', 'Absolute or relative directory')
50
+ .argument(`<commit-type>`, `Options: ${Object.keys(commitData)}`)
51
+ .argument(`[module-tag]`, 'Optional set module tag')
52
+ .argument(`[message]`, 'Optional set additional message')
53
+ .option('--empty', 'Allow empty files')
54
+ .option('--copy', 'Copy to clipboard message')
55
+ .option('--info', 'Info commit types')
56
+ .description('Commit github repository')
57
+ .action(Underpost.repo.commit);
58
+
59
+ program
60
+ .command('push')
61
+ .argument('<path>', 'Absolute or relative directory')
62
+ .argument(`<uri>`, 'e.g. username/repository')
63
+ .option('-f', 'Force push overwriting repository')
64
+ .description('Push github repository')
65
+ .action(Underpost.repo.push);
66
+
67
+ program
68
+ .command('env')
69
+ .argument('<deploy-id>', `deploy configuration id, if 'clean' restore default`)
70
+ .argument('[env]', 'Optional environment, for default is production')
71
+ .description('Set environment variables files and conf related to <deploy-id>')
72
+ .action(loadConf);
73
+
74
+ program
75
+ .command('config')
76
+ .argument('operator', `Options: ${Object.keys(Underpost.env)}`)
77
+ .argument('[key]', 'Config key')
78
+ .argument('[value]', 'Config value')
79
+ .description(`Manage configuration, operators`)
80
+ .action((...args) => Underpost.env[args[0]](args[1], args[2]));
81
+
82
+ program
83
+ .command('root')
84
+ .description('Get npm root path')
85
+ .action(() => console.log(getNpmRootPath()));
86
+
87
+ program
88
+ .command('cluster')
89
+ .argument('[pod-name]', 'Optional pod name filter')
90
+ .option('--reset', `Delete all clusters and prune all data and caches`)
91
+ .option('--mariadb', 'Init with mariadb statefulset')
92
+ .option('--mongodb', 'Init with mongodb statefulset')
93
+ .option('--postgresql', 'Init with postgresql statefulset')
94
+ .option('--mongodb4', 'Init with mongodb 4.4 service')
95
+ .option('--istio', 'Init base istio cluster')
96
+ .option('--valkey', 'Init with valkey service')
97
+ .option('--contour', 'Init with project contour base HTTPProxy and envoy')
98
+ .option('--cert-manager', 'Init with letsencrypt-prod ClusterIssuer')
99
+ .option('--info', 'Get all kinds objects deployed')
100
+ .option('--full', 'Init with all statefulsets and services available')
101
+ .option('--ns-use <ns-name>', 'Switches current context to namespace')
102
+ .option('--dev', 'init with dev cluster')
103
+ .option('--list-pods', 'Display list pods information')
104
+ .option('--info-capacity', 'display current total machine capacity info')
105
+ .option('--info-capacity-pod', 'display current machine capacity pod info')
106
+ .option('--pull-image', 'Set optional pull associated image')
107
+ .action(Underpost.cluster.init)
108
+ .description('Manage cluster, for default initialization base kind cluster');
109
+
110
+ program
111
+ .command('deploy')
112
+ .argument('<deploy-list>', 'Deploy id list, e.g. default-a,default-b')
113
+ .argument('[env]', 'Optional environment, for default is development')
114
+ .option('--remove', 'Delete deployments and services')
115
+ .option('--sync', 'Sync deployments env, ports, and replicas')
116
+ .option('--info-router', 'Display router structure')
117
+ .option('--expose', 'Expose service match deploy-list')
118
+ .option('--info-util', 'Display kubectl util management commands')
119
+ .option('--cert', 'Reset tls/ssl certificate secrets')
120
+ .option('--build-manifest', 'Build kind yaml manifests: deployments, services, proxy and secrets')
121
+ .option('--dashboard-update', 'Update dashboard instance data with current router config')
122
+ .option('--replicas <replicas>', 'Set custom number of replicas')
123
+ .option('--versions <deployment-versions>', 'Comma separated custom deployment versions')
124
+ .option('--traffic <traffic-versions>', 'Comma separated custom deployment traffic')
125
+ .option('--disable-update-deployment', 'Disable update deployments')
126
+ .option('--info-traffic', 'get traffic conf form current resources deployments')
127
+ .option(
128
+ '--rebuild-clients-bundle',
129
+ 'Inside container, rebuild clients bundle, only static public or storage client files',
130
+ )
131
+ .description('Manage deployment, for default deploy development pods')
132
+ .action(Underpost.deploy.callback);
133
+
134
+ program
135
+ .command('secret')
136
+ .argument('<platform>', `Options: ${Object.keys(Underpost.secret)}`)
137
+ .option('--init', 'Init secrets platform environment')
138
+ .option('--create-from-file <path-env-file>', 'Create secret from env file')
139
+ .option('--list', 'Lists secrets')
140
+ // .option('--delete [secret-key]', 'Delete key secret, if not set, are default delete all')
141
+ // .option('--create [secret-key] [secret-value]', 'Create secret key, with secret value')
142
+ .description(`Manage secrets`)
143
+ .action((...args) => {
144
+ if (args[1].createFromFile) return Underpost.secret[args[0]].createFromEnvFile(args[1].createFromFile);
145
+ if (args[1].list) return Underpost.secret[args[0]].list();
146
+ if (args[1].init) return Underpost.secret[args[0]].init();
147
+ });
148
+
149
+ program
150
+ .command('dockerfile-image-build')
151
+ .option('--path [path]', 'Dockerfile path')
152
+ .option('--image-name [image-name]', 'Set image name')
153
+ .option('--image-path [image-path]', 'Set tar image path')
154
+ .option('--dockerfile-name [dockerfile-name]', 'set Dockerfile name')
155
+ .option('--podman-save', 'Export tar file from podman')
156
+ .option('--kind-load', 'Import tar image to Kind cluster')
157
+ .option('--secrets', 'Dockerfile env secrets')
158
+ .option('--secrets-path [secrets-path]', 'Dockerfile custom path env secrets')
159
+ .option('--no-cache', 'Build without using cache')
160
+ .description('Build image from Dockerfile')
161
+ .action(Underpost.image.dockerfile.build);
162
+
163
+ program
164
+ .command('dockerfile-pull-base-images')
165
+ .description('Pull underpost dockerfile images requirements')
166
+ .action(Underpost.image.dockerfile.pullBaseImages);
167
+
168
+ program
169
+ .command('install')
170
+ .description('Fast import underpost npm dependencies')
171
+ .action(() => {
172
+ fs.copySync(`${underpostRootPath}/node_modules`, './node_modules');
173
+ });
174
+
175
+ program
176
+ .command('db')
177
+ .argument('<deploy-list>', 'Deploy id list, e.g. default-a,default-b')
178
+ .option('--import', 'Import container backups from repositories')
179
+ .option('--export', 'Export container backups to repositories')
180
+ .option('--pod-name <pod-name>', 'Optional pod context')
181
+ .option('--collections <collections>', 'Comma separated collections')
182
+ .option('--out-path <out-path>', 'Custom out path backup')
183
+ .option('--drop', 'Drop databases')
184
+ .option('--preserveUUID', 'Preserve Ids')
185
+ .option('--git', 'Upload to github')
186
+ .option('--hosts <hosts>', 'Comma separated hosts')
187
+ .option('--paths <paths>', 'Comma separated paths')
188
+ .option('--ns <ns-name>', 'Optional name space context')
189
+ .description('Manage databases')
190
+ .action(Underpost.db.callback);
191
+
192
+ program
193
+ .command('script')
194
+ .argument('operator', `Options: ${Object.keys(Underpost.script)}`)
195
+ .argument('<script-name>', 'Script name')
196
+ .argument('[script-value]', 'Literal command, or path')
197
+ .option('--itc', 'Inside container execution context')
198
+ .option('--itc-path', 'Inside container path options')
199
+ .option('--ns <ns-name>', 'Options name space context')
200
+ .option('--pod-name <pod-name>')
201
+ .description(
202
+ 'Supports a number of built-in underpost global scripts and their preset life cycle events as well as arbitrary scripts',
203
+ )
204
+ .action((...args) => Underpost.script[args[0]](args[1], args[2], args[3]));
205
+
206
+ program
207
+ .command('cron')
208
+ .argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
209
+ .argument('[job-list]', `Deploy id list, e.g. ${Object.keys(Underpost.cron)}, for default all available jobs`)
210
+ .option('--itc', 'Inside container execution context')
211
+ .option('--init', 'Init cron jobs for cron job default deploy id')
212
+ .option('--git', 'Upload to github')
213
+ .option('--dashboard-update', 'Update dashboard cron data with current jobs config')
214
+ .description('Cron jobs management')
215
+ .action(Underpost.cron.callback);
216
+
217
+ program
218
+ .command('fs')
219
+ .argument('[path]', 'Absolute or relative directory')
220
+ .option('--rm', 'Remove file')
221
+ .option('--git', 'Current git changes')
222
+ .option('--recursive', 'Upload files recursively')
223
+ .option('--deploy-id <deploy-id>', 'Deploy configuration id')
224
+ .option('--pull', 'Download file')
225
+ .option('--force', 'Force action')
226
+ .option('--storage-file-path <storage-file-path>', 'custom file storage path')
227
+ .description('File storage management, for default upload file')
228
+ .action(Underpost.fs.callback);
229
+
230
+ program
231
+ .command('test')
232
+ .argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
233
+ .description('Manage Test, for default run current underpost default test')
234
+ .option('--itc', 'Inside container execution context')
235
+ .option('--sh', 'Copy to clipboard, container entrypoint shell command')
236
+ .option('--logs', 'Display container logs')
237
+ .option('--pod-name <pod-name>')
238
+ .option('--pod-status <pod-status>')
239
+ .option('--kind-type <kind-type>')
240
+ .action(Underpost.test.callback);
241
+
242
+ program
243
+ .command('monitor')
244
+ .argument('<deploy-id>', 'Deploy configuration id')
245
+ .argument('[env]', 'Optional environment, for default is development')
246
+ .option('--ms-interval <ms-interval>', 'Custom ms interval delta time')
247
+ .option('--now', 'Exec immediately monitor script')
248
+ .option('--single', 'Disable recurrence')
249
+ .option('--replicas <replicas>', 'Set custom number of replicas')
250
+ .option('--type <type>', 'Set custom monitor type')
251
+ .option('--sync', 'Sync with current proxy deployments proxy traffic')
252
+ .description('Monitor health server management')
253
+ .action(Underpost.monitor.callback);
254
+
255
+ const buildCliDoc = () => {
256
+ let md = shellExec(`node bin help`, { silent: true, stdout: true }).split('Options:');
257
+ const baseOptions =
258
+ `## ${md[0].split(`\n`)[2]}
259
+
260
+ ### Usage: ` +
261
+ '`' +
262
+ md[0].split(`\n`)[0].split('Usage: ')[1] +
263
+ '`' +
264
+ `
265
+ ` +
266
+ '```\n Options:' +
267
+ md[1] +
268
+ ' \n```';
269
+ md =
270
+ baseOptions +
271
+ `
272
+
273
+ ## Commands:
274
+ `;
275
+ program.commands.map((o) => {
276
+ md +=
277
+ `
278
+
279
+ ` +
280
+ '### `' +
281
+ o._name +
282
+ '` :' +
283
+ `
284
+ ` +
285
+ '```\n ' +
286
+ shellExec(`node bin help ${o._name}`, { silent: true, stdout: true }) +
287
+ ' \n```' +
288
+ `
289
+ `;
290
+ });
291
+ fs.writeFileSync(`./src/client/public/nexodev/docs/references/Command Line Interface.md`, md, 'utf8');
292
+ fs.writeFileSync(`./cli.md`, md, 'utf8');
293
+ const readmeSplit = `pwa-microservices-template</a>`;
294
+ const readme = fs.readFileSync(`./README.md`, 'utf8').split(readmeSplit);
295
+ fs.writeFileSync(
296
+ './README.md',
297
+ readme[0] +
298
+ readmeSplit +
299
+ `
300
+
301
+ ` +
302
+ baseOptions +
303
+ `
304
+
305
+ <a target="_top" href="https://github.com/underpostnet/pwa-microservices-template/blob/master/cli.md">See complete CLI Docs here.</a>
306
+
307
+ `,
308
+ 'utf8',
309
+ );
310
+ };
311
+
312
+ export { program, buildCliDoc };