underpost 2.85.1 → 2.85.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.
- package/.env.development +2 -1
- package/.env.production +2 -1
- package/.env.test +2 -1
- package/.github/workflows/release.cd.yml +3 -3
- package/.vscode/zed.keymap.json +22 -0
- package/README.md +3 -3
- package/bin/deploy.js +4 -2
- package/bin/file.js +4 -0
- package/bin/vs.js +4 -4
- package/cli.md +15 -11
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +2 -2
- package/package.json +2 -2
- package/src/cli/baremetal.js +3 -3
- package/src/cli/deploy.js +26 -4
- package/src/cli/index.js +7 -3
- package/src/cli/repository.js +34 -44
- package/src/cli/run.js +121 -13
- package/src/client/components/core/CommonJs.js +1 -0
- package/src/client/components/core/SocketIo.js +5 -1
- package/src/client/sw/default.sw.js +193 -97
- package/src/client.dev.js +1 -1
- package/src/index.js +1 -1
- package/src/proxy.js +1 -1
- package/src/runtime/express/Express.js +4 -1
- package/src/server/auth.js +2 -1
- package/src/server/conf.js +132 -15
- package/src/server/proxy.js +53 -26
- package/src/server/start.js +13 -3
- package/src/server/tls.js +1 -1
package/.env.development
CHANGED
package/.env.production
CHANGED
package/.env.test
CHANGED
|
@@ -29,8 +29,8 @@ jobs:
|
|
|
29
29
|
set -e
|
|
30
30
|
echo "Starting remote release deploy"
|
|
31
31
|
underpost run pull
|
|
32
|
-
underpost run git-conf
|
|
33
32
|
underpost run secret
|
|
34
33
|
cd /home/dd/engine
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
node bin run --dev git-conf admin@underpost.net,underpostnet
|
|
35
|
+
node bin run --dev template-deploy-image
|
|
36
|
+
node bin run --dev ssh-deploy sync-engine-test
|
package/.vscode/zed.keymap.json
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"context": "Editor",
|
|
4
|
+
"bindings": {
|
|
5
|
+
"ctrl-c": "editor::Copy",
|
|
6
|
+
"ctrl-x": "editor::Cut",
|
|
7
|
+
"ctrl-v": "editor::Paste",
|
|
8
|
+
"ctrl-shift-c": "editor::CopyAndTrim",
|
|
9
|
+
"ctrl-shift-v": "editor::Paste",
|
|
10
|
+
"cmd-c": "editor::Copy",
|
|
11
|
+
"cmd-x": "editor::Cut",
|
|
12
|
+
"cmd-v": "editor::Paste"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"context": "Terminal",
|
|
17
|
+
"bindings": {
|
|
18
|
+
"ctrl-shift-c": "terminal::Copy",
|
|
19
|
+
"ctrl-shift-v": "terminal::Paste",
|
|
20
|
+
"cmd-shift-c": "terminal::Copy",
|
|
21
|
+
"cmd-shift-v": "terminal::Paste"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
2
24
|
{
|
|
3
25
|
"context": "Editor && edit_prediction",
|
|
4
26
|
"bindings": {
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
<!-- badges -->
|
|
20
20
|
|
|
21
|
-
[](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [](https://www.npmjs.com/package/underpost) [](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [](https://www.npmjs.com/package/underpost) [](https://socket.dev/npm/package/underpost/overview/2.85.7) [](https://coveralls.io/github/underpostnet/engine?branch=master) [](https://www.npmjs.org/package/underpost) [](https://www.npmjs.com/package/underpost)
|
|
22
22
|
|
|
23
23
|
<!-- end-badges -->
|
|
24
24
|
|
|
@@ -66,7 +66,7 @@ Run dev client server
|
|
|
66
66
|
npm run dev
|
|
67
67
|
```
|
|
68
68
|
<!-- -->
|
|
69
|
-
## underpost ci/cd cli v2.85.
|
|
69
|
+
## underpost ci/cd cli v2.85.7
|
|
70
70
|
|
|
71
71
|
### Usage: `underpost [options] [command]`
|
|
72
72
|
```
|
|
@@ -75,7 +75,7 @@ npm run dev
|
|
|
75
75
|
-h, --help display help for command
|
|
76
76
|
|
|
77
77
|
Commands:
|
|
78
|
-
new [options]
|
|
78
|
+
new [options] [app-name] Initializes a new Underpost project, service, or configuration.
|
|
79
79
|
start [options] <deploy-id> [env] Initiates application servers, build pipelines, or other defined services based on the deployment ID.
|
|
80
80
|
clone [options] <uri> Clones a specified GitHub repository into the current directory.
|
|
81
81
|
pull [options] <path> <uri> Pulls the latest changes from a specified GitHub repository.
|
package/bin/deploy.js
CHANGED
|
@@ -380,6 +380,7 @@ try {
|
|
|
380
380
|
}
|
|
381
381
|
|
|
382
382
|
case 'version-build': {
|
|
383
|
+
dotenv.config({ path: `./engine-private/conf/dd-cron/.env.production`, override: true });
|
|
383
384
|
shellCd(`/home/dd/engine`);
|
|
384
385
|
shellExec(`node bin/deploy clean-core-repo`);
|
|
385
386
|
shellExec(`node bin pull . ${process.env.GITHUB_USERNAME}/engine`);
|
|
@@ -493,6 +494,7 @@ try {
|
|
|
493
494
|
}
|
|
494
495
|
|
|
495
496
|
case 'version-deploy': {
|
|
497
|
+
dotenv.config({ path: `./engine-private/conf/dd-cron/.env.production`, override: true });
|
|
496
498
|
shellExec(
|
|
497
499
|
`underpost secret underpost --create-from-file /home/dd/engine/engine-private/conf/dd-cron/.env.production`,
|
|
498
500
|
);
|
|
@@ -1302,8 +1304,8 @@ nvidia/gpu-operator \
|
|
|
1302
1304
|
|
|
1303
1305
|
case 'tls': {
|
|
1304
1306
|
fs.mkdirSync(`./engine-private/ssl/localhost`, { recursive: true });
|
|
1305
|
-
const targetDir = `./engine-private/ssl
|
|
1306
|
-
const domains = ['localhost', '127.0.0.1', '::1'];
|
|
1307
|
+
const targetDir = `./engine-private/ssl/${process.argv[3] ? process.argv[3] : 'localhost'}`;
|
|
1308
|
+
const domains = ['localhost', '127.0.0.1', '::1'].concat(process.argv[3] ? process.argv[3] : []);
|
|
1307
1309
|
shellExec(`chmod +x ./scripts/ssl.sh`);
|
|
1308
1310
|
shellExec(`./scripts/ssl.sh ${targetDir} "${domains.join(' ')}"`);
|
|
1309
1311
|
break;
|
package/bin/file.js
CHANGED
|
@@ -11,9 +11,12 @@ import {
|
|
|
11
11
|
import { shellCd, shellExec } from '../src/server/process.js';
|
|
12
12
|
import walk from 'ignore-walk';
|
|
13
13
|
import { validateTemplatePath } from '../src/server/conf.js';
|
|
14
|
+
import dotenv from 'dotenv';
|
|
14
15
|
|
|
15
16
|
const logger = loggerFactory(import.meta);
|
|
16
17
|
|
|
18
|
+
dotenv.config({ path: `./engine-private/conf/dd-cron/.env.production`, override: true });
|
|
19
|
+
|
|
17
20
|
logger.info('argv', process.argv);
|
|
18
21
|
|
|
19
22
|
let [exe, dir, type] = process.argv;
|
|
@@ -69,6 +72,7 @@ try {
|
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
for (const copyPath of result) {
|
|
75
|
+
if (copyPath === 'NaN') continue;
|
|
72
76
|
const folder = getDirname(`${toPath}/${copyPath}`);
|
|
73
77
|
const absolutePath = `${rawPath}/${copyPath}`;
|
|
74
78
|
|
package/bin/vs.js
CHANGED
|
@@ -4,11 +4,11 @@ import { loggerFactory } from '../src/server/logger.js';
|
|
|
4
4
|
|
|
5
5
|
const logger = loggerFactory(import.meta);
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const vsCodeRootPath = '/root/.vscode-root';
|
|
8
|
+
const vsProgram = 'code';
|
|
9
9
|
|
|
10
|
-
const vsCodeRootPath = '/root/.windsurf';
|
|
11
|
-
const vsProgram = 'windsurf';
|
|
10
|
+
// const vsCodeRootPath = '/root/.windsurf';
|
|
11
|
+
// const vsProgram = 'windsurf';
|
|
12
12
|
|
|
13
13
|
switch (process.argv[2]) {
|
|
14
14
|
case 'info': {
|
package/cli.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
## underpost ci/cd cli v2.85.
|
|
1
|
+
## underpost ci/cd cli v2.85.7
|
|
2
2
|
|
|
3
3
|
### Usage: `underpost [options] [command]`
|
|
4
4
|
```
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
-h, --help display help for command
|
|
8
8
|
|
|
9
9
|
Commands:
|
|
10
|
-
new [options]
|
|
10
|
+
new [options] [app-name] Initializes a new Underpost project, service, or configuration.
|
|
11
11
|
start [options] <deploy-id> [env] Initiates application servers, build pipelines, or other defined services based on the deployment ID.
|
|
12
12
|
clone [options] <uri> Clones a specified GitHub repository into the current directory.
|
|
13
13
|
pull [options] <path> <uri> Pulls the latest changes from a specified GitHub repository.
|
|
@@ -42,20 +42,20 @@ Commands:
|
|
|
42
42
|
|
|
43
43
|
### `new` :
|
|
44
44
|
```
|
|
45
|
-
Usage: underpost new [options]
|
|
45
|
+
Usage: underpost new [options] [app-name]
|
|
46
46
|
|
|
47
47
|
Initializes a new Underpost project, service, or configuration.
|
|
48
48
|
|
|
49
49
|
Arguments:
|
|
50
|
-
app-name
|
|
50
|
+
app-name The name of the new project.
|
|
51
51
|
|
|
52
52
|
Options:
|
|
53
|
-
--deploy-id
|
|
54
|
-
--
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
--
|
|
58
|
-
-h, --help
|
|
53
|
+
--deploy-id <deploy-id> Crete deploy ID conf env files
|
|
54
|
+
--sub-conf <sub-conf> Create sub conf env files
|
|
55
|
+
--cluster Create deploy ID cluster files and sync to current
|
|
56
|
+
cluster
|
|
57
|
+
--dev Sets the development cli context
|
|
58
|
+
-h, --help display help for command
|
|
59
59
|
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -623,7 +623,7 @@ Options:
|
|
|
623
623
|
Runs a script from the specified path.
|
|
624
624
|
|
|
625
625
|
Arguments:
|
|
626
|
-
runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, underpost-config, gpu-env, tf-gpu-test, dev-cluster, ssh-cluster-info, dev-hosts-expose, dev-hosts-restore, cyberia-ide, engine-ide, cluster-build, template-deploy, template-deploy-image, clean, pull, release-deploy, ssh-deploy, ide, sync, ls-deployments, host-update, dev-container, monitor, db-client, git-conf, promote, metrics, cluster, deploy, service, sync-replica, tf-vae-test, deploy-job.
|
|
626
|
+
runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, underpost-config, gpu-env, tf-gpu-test, dev-cluster, ssh-cluster-info, dev-hosts-expose, dev-hosts-restore, cyberia-ide, engine-ide, cluster-build, template-deploy, template-deploy-image, clean, pull, release-deploy, ssh-deploy, ide, sync, ls-deployments, ls-images, host-update, dev-container, monitor, db-client, git-conf, promote, metrics, cluster, deploy, dev, service, release-cmt, sync-replica, tf-vae-test, deploy-job.
|
|
627
627
|
path The absolute or relative directory path where the script is located.
|
|
628
628
|
|
|
629
629
|
Options:
|
|
@@ -642,6 +642,10 @@ Options:
|
|
|
642
642
|
--kubeadm Flag to indicate Kubeadm cluster type context
|
|
643
643
|
--k3s Flag to indicate K3s cluster type context
|
|
644
644
|
--force Forces operation, overriding any warnings or conflicts.
|
|
645
|
+
--tls Enables TLS for the runner execution.
|
|
646
|
+
--reset Resets the runner state before execution.
|
|
647
|
+
--terminal Enables terminal mode for interactive script execution.
|
|
648
|
+
--dev-proxy-port-offset <port-offset> Sets a custom port offset for development proxy.
|
|
645
649
|
-h, --help display help for command
|
|
646
650
|
|
|
647
651
|
```
|
|
@@ -17,7 +17,7 @@ spec:
|
|
|
17
17
|
spec:
|
|
18
18
|
containers:
|
|
19
19
|
- name: dd-default-development-blue
|
|
20
|
-
image: localhost/rockylinux9-underpost:v2.85.
|
|
20
|
+
image: localhost/rockylinux9-underpost:v2.85.7
|
|
21
21
|
# resources:
|
|
22
22
|
# requests:
|
|
23
23
|
# memory: "124Ki"
|
|
@@ -100,7 +100,7 @@ spec:
|
|
|
100
100
|
spec:
|
|
101
101
|
containers:
|
|
102
102
|
- name: dd-default-development-green
|
|
103
|
-
image: localhost/rockylinux9-underpost:v2.85.
|
|
103
|
+
image: localhost/rockylinux9-underpost:v2.85.7
|
|
104
104
|
# resources:
|
|
105
105
|
# requests:
|
|
106
106
|
# memory: "124Ki"
|
|
@@ -17,7 +17,7 @@ spec:
|
|
|
17
17
|
spec:
|
|
18
18
|
containers:
|
|
19
19
|
- name: dd-test-development-blue
|
|
20
|
-
image: localhost/rockylinux9-underpost:v2.85.
|
|
20
|
+
image: localhost/rockylinux9-underpost:v2.85.7
|
|
21
21
|
# resources:
|
|
22
22
|
# requests:
|
|
23
23
|
# memory: "96294Ki"
|
|
@@ -104,7 +104,7 @@ spec:
|
|
|
104
104
|
spec:
|
|
105
105
|
containers:
|
|
106
106
|
- name: dd-test-development-green
|
|
107
|
-
image: localhost/rockylinux9-underpost:v2.85.
|
|
107
|
+
image: localhost/rockylinux9-underpost:v2.85.7
|
|
108
108
|
# resources:
|
|
109
109
|
# requests:
|
|
110
110
|
# memory: "96294Ki"
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"main": "src/index.js",
|
|
4
4
|
"name": "underpost",
|
|
5
|
-
"version": "2.85.
|
|
5
|
+
"version": "2.85.7",
|
|
6
6
|
"description": "pwa api rest template",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"monitor": "pm2 start src/monitor.js --name monitor -- dd production",
|
|
16
16
|
"dev-api": "env-cmd -f .env.development nodemon --watch src --ignore src/client src/api",
|
|
17
17
|
"dev-client": "env-cmd -f .env.development node src/client.dev",
|
|
18
|
-
"proxy": "node src/proxy proxy",
|
|
18
|
+
"dev-proxy": "env-cmd -f .env.development node src/proxy proxy",
|
|
19
19
|
"docs": "jsdoc -c jsdoc.json",
|
|
20
20
|
"install-global": "npm install -g pm2 && npm install -g jsdoc && npm install -g prettier && npm install -g env-cmd",
|
|
21
21
|
"install-test": "npm install -g mocha && npm install -g c8 && npm install -g coveralls",
|
package/src/cli/baremetal.js
CHANGED
|
@@ -76,9 +76,9 @@ class UnderpostBaremetal {
|
|
|
76
76
|
const underpostRoot = options?.dev === true ? '.' : `${npmRoot}/underpost`;
|
|
77
77
|
|
|
78
78
|
// Set default values if not provided.
|
|
79
|
-
workflowId = workflowId
|
|
80
|
-
hostname = hostname
|
|
81
|
-
ipAddress = ipAddress
|
|
79
|
+
workflowId = workflowId ? workflowId : 'rpi4mb';
|
|
80
|
+
hostname = hostname ? hostname : workflowId;
|
|
81
|
+
ipAddress = ipAddress ? ipAddress : '192.168.1.192';
|
|
82
82
|
|
|
83
83
|
// Set default MAC address
|
|
84
84
|
let macAddress = '00:00:00:00:00:00';
|
package/src/cli/deploy.js
CHANGED
|
@@ -80,7 +80,7 @@ class UnderpostDeploy {
|
|
|
80
80
|
process.env.PORT = initEnvObj.PORT;
|
|
81
81
|
process.env.NODE_ENV = env;
|
|
82
82
|
await Config.build('proxy', deployList);
|
|
83
|
-
return buildPortProxyRouter(env === 'development' ? 80 : 443, buildProxyRouter());
|
|
83
|
+
return buildPortProxyRouter({ port: env === 'development' ? 80 : 443, proxyRouter: buildProxyRouter() });
|
|
84
84
|
},
|
|
85
85
|
/**
|
|
86
86
|
* Creates a YAML service configuration for a deployment.
|
|
@@ -689,15 +689,37 @@ EOF`);
|
|
|
689
689
|
/**
|
|
690
690
|
* Creates a hosts file for a deployment.
|
|
691
691
|
* @param {Array<string>} hosts - List of hosts to be added to the hosts file.
|
|
692
|
+
* @param {object} options - Options for the hosts file creation.
|
|
693
|
+
* @param {boolean} options.append - Whether to append to the existing hosts file.
|
|
694
|
+
* @returns {object} - Object containing the rendered hosts file.
|
|
692
695
|
* @memberof UnderpostDeploy
|
|
693
696
|
*/
|
|
694
|
-
etcHostFactory(hosts = []) {
|
|
697
|
+
etcHostFactory(hosts = [], options = { append: false }) {
|
|
698
|
+
hosts = hosts.map((host) => {
|
|
699
|
+
try {
|
|
700
|
+
if (!host.startsWith('http')) host = `http://${host}`;
|
|
701
|
+
const hostname = new URL(host).hostname;
|
|
702
|
+
logger.info('Hostname extract valid', { host, hostname });
|
|
703
|
+
return hostname;
|
|
704
|
+
} catch (e) {
|
|
705
|
+
logger.warn('No hostname extract valid', host);
|
|
706
|
+
return host;
|
|
707
|
+
}
|
|
708
|
+
});
|
|
695
709
|
const renderHosts = `127.0.0.1 ${hosts.join(
|
|
696
710
|
' ',
|
|
697
711
|
)} localhost localhost.localdomain localhost4 localhost4.localdomain4
|
|
698
712
|
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6`;
|
|
699
713
|
|
|
700
|
-
fs.
|
|
714
|
+
if (options && options.append && fs.existsSync(`/etc/hosts`)) {
|
|
715
|
+
fs.writeFileSync(
|
|
716
|
+
`/etc/hosts`,
|
|
717
|
+
fs.readFileSync(`/etc/hosts`, 'utf8') +
|
|
718
|
+
`
|
|
719
|
+
${renderHosts}`,
|
|
720
|
+
'utf8',
|
|
721
|
+
);
|
|
722
|
+
} else fs.writeFileSync(`/etc/hosts`, renderHosts, 'utf8');
|
|
701
723
|
return { renderHosts };
|
|
702
724
|
},
|
|
703
725
|
/**
|
|
@@ -768,7 +790,7 @@ EOF`);
|
|
|
768
790
|
.filter((o) => o.image);
|
|
769
791
|
}
|
|
770
792
|
if (node === 'kind-worker') {
|
|
771
|
-
const raw = shellExec(`docker exec -i
|
|
793
|
+
const raw = shellExec(`docker exec -i ${node} crictl images`, {
|
|
772
794
|
stdout: true,
|
|
773
795
|
silent: true,
|
|
774
796
|
});
|
package/src/cli/index.js
CHANGED
|
@@ -22,11 +22,11 @@ program.name('underpost').description(`underpost ci/cd cli ${Underpost.version}`
|
|
|
22
22
|
// 'new' command: Create a new project
|
|
23
23
|
program
|
|
24
24
|
.command('new')
|
|
25
|
-
.argument('
|
|
26
|
-
.option('--deploy-id', 'Crete deploy ID conf env files')
|
|
25
|
+
.argument('[app-name]', 'The name of the new project.')
|
|
26
|
+
.option('--deploy-id <deploy-id>', 'Crete deploy ID conf env files')
|
|
27
|
+
.option('--sub-conf <sub-conf>', 'Create sub conf env files')
|
|
27
28
|
.option('--cluster', 'Create deploy ID cluster files and sync to current cluster')
|
|
28
29
|
.option('--dev', 'Sets the development cli context')
|
|
29
|
-
.option('--sub-conf <sub-conf>', 'Create sub conf env files')
|
|
30
30
|
.description('Initializes a new Underpost project, service, or configuration.')
|
|
31
31
|
.action(Underpost.repo.new);
|
|
32
32
|
|
|
@@ -389,6 +389,10 @@ program
|
|
|
389
389
|
.option('--kubeadm', 'Flag to indicate Kubeadm cluster type context')
|
|
390
390
|
.option('--k3s', 'Flag to indicate K3s cluster type context')
|
|
391
391
|
.option('--force', 'Forces operation, overriding any warnings or conflicts.')
|
|
392
|
+
.option('--tls', 'Enables TLS for the runner execution.')
|
|
393
|
+
.option('--reset', 'Resets the runner state before execution.')
|
|
394
|
+
.option('--terminal', 'Enables terminal mode for interactive script execution.')
|
|
395
|
+
.option('--dev-proxy-port-offset <port-offset>', 'Sets a custom port offset for development proxy.')
|
|
392
396
|
.description('Runs a script from the specified path.')
|
|
393
397
|
.action(UnderpostRun.API.callback);
|
|
394
398
|
|
package/src/cli/repository.js
CHANGED
|
@@ -213,60 +213,50 @@ class UnderpostRepository {
|
|
|
213
213
|
},
|
|
214
214
|
|
|
215
215
|
/**
|
|
216
|
-
*
|
|
217
|
-
* @param {string}
|
|
218
|
-
* @param {object} [options={
|
|
219
|
-
* @param {
|
|
220
|
-
* @param {
|
|
221
|
-
* @param {boolean} [options.cluster=false] - If true,
|
|
222
|
-
* @param {
|
|
223
|
-
* @returns {Promise<
|
|
216
|
+
* Initializes a new Underpost repository, optionally setting up a deploy ID or sub-configuration.
|
|
217
|
+
* @param {string} [projectName=''] - The name of the project to create.
|
|
218
|
+
* @param {object} [options={ deployId: '', subConf: '', cluster: false, dev: false }] - Initialization options.
|
|
219
|
+
* @param {string} [options.deployId=''] - The deployment ID to set up.
|
|
220
|
+
* @param {string} [options.subConf=''] - The sub-configuration to create.
|
|
221
|
+
* @param {boolean} [options.cluster=false] - If true, sets up a clustered configuration.
|
|
222
|
+
* @param {boolean} [options.dev=false] - If true, uses development settings.
|
|
223
|
+
* @returns {Promise<boolean>} A promise that resolves when the initialization is complete.
|
|
224
224
|
* @memberof UnderpostRepository
|
|
225
225
|
*/
|
|
226
|
-
new(
|
|
226
|
+
new(projectName, options = { deployId: '', subConf: '', cluster: false, dev: false }) {
|
|
227
227
|
return new Promise(async (resolve, reject) => {
|
|
228
228
|
try {
|
|
229
229
|
await logger.setUpInfo();
|
|
230
230
|
actionInitLog();
|
|
231
|
-
if (options.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
deployId,
|
|
235
|
-
subConf: options.subConf,
|
|
236
|
-
});
|
|
237
|
-
fs.copySync(
|
|
238
|
-
`./engine-private/conf/${deployId}/conf.server.json`,
|
|
239
|
-
`./engine-private/conf/${deployId}/conf.server.dev.${options.subConf}.json`,
|
|
240
|
-
);
|
|
241
|
-
return resolve();
|
|
231
|
+
if (options.deployId) {
|
|
232
|
+
Config.deployIdFactory(options.deployId, options);
|
|
233
|
+
return resolve(true);
|
|
242
234
|
}
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
);
|
|
262
|
-
shellExec(`cd ${destFolder} && git init && git add . && git commit -m "Base template implementation"`);
|
|
235
|
+
if (projectName) {
|
|
236
|
+
const npmRoot = getNpmRootPath();
|
|
237
|
+
const underpostRoot = options?.dev === true ? '.' : `${npmRoot}/underpost`;
|
|
238
|
+
const destFolder = `./${projectName}`;
|
|
239
|
+
logger.info('Note: This process may take several minutes to complete');
|
|
240
|
+
logger.info('build app', { destFolder });
|
|
241
|
+
if (fs.existsSync(destFolder)) fs.removeSync(destFolder);
|
|
242
|
+
fs.mkdirSync(destFolder, { recursive: true });
|
|
243
|
+
if (!options.dev) {
|
|
244
|
+
fs.copySync(underpostRoot, destFolder);
|
|
245
|
+
fs.writeFileSync(
|
|
246
|
+
`${destFolder}/.gitignore`,
|
|
247
|
+
fs.readFileSync(`${underpostRoot}/.dockerignore`, 'utf8'),
|
|
248
|
+
'utf8',
|
|
249
|
+
);
|
|
250
|
+
shellExec(`cd ${destFolder} && git init && git add . && git commit -m "Base template implementation"`);
|
|
251
|
+
}
|
|
252
|
+
shellExec(`cd ${destFolder} && npm run build`);
|
|
253
|
+
shellExec(`cd ${destFolder} && npm run dev`);
|
|
263
254
|
}
|
|
264
|
-
|
|
265
|
-
shellExec(`cd ${destFolder} && npm run dev`);
|
|
266
|
-
return resolve();
|
|
255
|
+
return resolve(true);
|
|
267
256
|
} catch (error) {
|
|
257
|
+
console.log(error);
|
|
268
258
|
logger.error(error, error.stack);
|
|
269
|
-
return reject(
|
|
259
|
+
return reject(false);
|
|
270
260
|
}
|
|
271
261
|
});
|
|
272
262
|
},
|