underpost 2.7.2 → 2.7.3
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/.github/workflows/test.yml +80 -0
- package/bin/deploy.js +25 -0
- package/bin/file.js +6 -5
- package/bin/index.js +27 -4
- package/bin/ssl.js +2 -12
- package/docker-compose.yml +1 -1
- package/package.json +1 -1
- package/src/client/components/core/Docs.js +1 -1
- package/src/client/ssr/body-components/CacheControl.js +1 -1
- package/src/db/mongo/MongooseDB.js +92 -1
- package/src/runtime/lampp/Lampp.js +47 -1
- package/src/server/client-build.js +0 -6
- package/src/server/logger.js +11 -1
- package/src/server/process.js +3 -3
- package/src/server/ssl.js +12 -1
- package/bin/dns.js +0 -1
- package/bin/install.js +0 -398
- package/bin/shortcut.js +0 -44
- /package/src/client/components/core/{BlockChain.js → Blockchain.js} +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: ['master']
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: ['master']
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
name: Node ${{ matrix.node }} on ${{ matrix.os }}
|
|
10
|
+
runs-on: ${{ matrix.os }}
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
node-version: [21.x]
|
|
14
|
+
os: [ubuntu-latest]
|
|
15
|
+
# os: [ubuntu-latest, windows-latest]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Clone repository
|
|
19
|
+
uses: actions/checkout@v3
|
|
20
|
+
|
|
21
|
+
- name: Set Node.js version
|
|
22
|
+
uses: actions/setup-node@v3
|
|
23
|
+
with:
|
|
24
|
+
node-version: ${{ matrix.node }}
|
|
25
|
+
|
|
26
|
+
- name: Get npm root
|
|
27
|
+
run: sudo npm root -g
|
|
28
|
+
|
|
29
|
+
- name: Install underpost cli
|
|
30
|
+
run: sudo npm install -g underpost
|
|
31
|
+
|
|
32
|
+
- name: Run test
|
|
33
|
+
run: sudo underpost test
|
|
34
|
+
|
|
35
|
+
# for travis
|
|
36
|
+
# - name: Run coveralls
|
|
37
|
+
# run: npm run coveralls # nyc npm run test --reporter=text-lcov | coveralls -v
|
|
38
|
+
|
|
39
|
+
# - name: Test token
|
|
40
|
+
# run: echo "${{ secrets.COVERALLS_REPO_TOKEN }}"
|
|
41
|
+
|
|
42
|
+
# - name: Coveralls
|
|
43
|
+
# uses: coverallsapp/github-action@master
|
|
44
|
+
# with:
|
|
45
|
+
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
46
|
+
# flag-name: ${{matrix.os}}-node-${{ matrix.node }}
|
|
47
|
+
# parallel: true
|
|
48
|
+
|
|
49
|
+
# - name: Coveralls
|
|
50
|
+
# uses: coverallsapp/github-action@master
|
|
51
|
+
# with:
|
|
52
|
+
# github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
53
|
+
# path-to-lcov: '/usr/local/lib/node_modules/underpost/coverage/lcov.info'
|
|
54
|
+
# env:
|
|
55
|
+
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
|
|
56
|
+
# COVERALLS_GIT_BRANCH: "${{ github.ref }}"
|
|
57
|
+
|
|
58
|
+
# - name: Coveralls
|
|
59
|
+
# run: node ./node_modules/coveralls-next/bin/coveralls.js # cat ./coverage/lcov.info |
|
|
60
|
+
# env:
|
|
61
|
+
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
|
|
62
|
+
# COVERALLS_SERVICE_NAME: CI-pipeline
|
|
63
|
+
# COVERALLS_SERVICE_JOB_ID: ${{github.run_id}}
|
|
64
|
+
# COVERALLS_SERVICE_JOB_NUMBER: ${{github.run_number}}
|
|
65
|
+
# COVERALLS_FLAG_NAME: ${{matrix.os}}-node-${{ matrix.node }}
|
|
66
|
+
# COVERALLS_PARALLEL: true
|
|
67
|
+
# NODE_COVERALLS_DEBUG: 1
|
|
68
|
+
# finish:
|
|
69
|
+
# needs: test
|
|
70
|
+
# runs-on: ubuntu-latest
|
|
71
|
+
# steps:
|
|
72
|
+
# - name: Clone repository
|
|
73
|
+
# uses: actions/checkout@v2
|
|
74
|
+
|
|
75
|
+
# - name: Coveralls Finished
|
|
76
|
+
# run: |
|
|
77
|
+
# curl -kv -d 'payload[build_num]=${{github.run_id}}&payload[status]=done' https://coveralls.io/webhook?repo_token=${COVERALLS_REPO_TOKEN}
|
|
78
|
+
# env:
|
|
79
|
+
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
|
|
80
|
+
# COVERALLS_GIT_BRANCH: '${{ github.ref }}'
|
package/bin/deploy.js
CHANGED
|
@@ -30,6 +30,8 @@ import { buildClient } from '../src/server/client-build.js';
|
|
|
30
30
|
import { range, setPad, timer, uniqueArray } from '../src/client/components/core/CommonJs.js';
|
|
31
31
|
import toJsonSchema from 'to-json-schema';
|
|
32
32
|
import simpleGit from 'simple-git';
|
|
33
|
+
import { MongooseDB } from '../src/db/mongo/MongooseDB.js';
|
|
34
|
+
import { Lampp } from '../src/runtime/lampp/Lampp.js';
|
|
33
35
|
|
|
34
36
|
const logger = loggerFactory(import.meta);
|
|
35
37
|
|
|
@@ -251,6 +253,19 @@ try {
|
|
|
251
253
|
|
|
252
254
|
shellExec(Cmd.replica(deployId, host, path));
|
|
253
255
|
}
|
|
256
|
+
if (serverConf[host][path].db) {
|
|
257
|
+
switch (serverConf[host][path].db.provider) {
|
|
258
|
+
case 'mariadb':
|
|
259
|
+
{
|
|
260
|
+
shellExec(`node bin/db ${host}${path} create ${deployId}`);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
break;
|
|
264
|
+
|
|
265
|
+
default:
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
254
269
|
}
|
|
255
270
|
}
|
|
256
271
|
}
|
|
@@ -574,6 +589,16 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
|
|
|
574
589
|
}
|
|
575
590
|
|
|
576
591
|
break;
|
|
592
|
+
|
|
593
|
+
case 'mongo': {
|
|
594
|
+
await MongooseDB.server();
|
|
595
|
+
break;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
case 'lampp': {
|
|
599
|
+
await Lampp.install();
|
|
600
|
+
}
|
|
601
|
+
|
|
577
602
|
default:
|
|
578
603
|
break;
|
|
579
604
|
}
|
package/bin/file.js
CHANGED
|
@@ -10,11 +10,6 @@ const logger = loggerFactory(import.meta);
|
|
|
10
10
|
|
|
11
11
|
logger.info('argv', process.argv);
|
|
12
12
|
|
|
13
|
-
// usage:
|
|
14
|
-
// node bin/file create './wena que-onda.py'
|
|
15
|
-
// node bin/file create js-module './wena que-onda.js'
|
|
16
|
-
// node bin/file copy-src 'c:/dd/excel-api' 'c:/dd/engine/engine-private/deploy/excel-api'
|
|
17
|
-
|
|
18
13
|
let [exe, dir, type] = process.argv;
|
|
19
14
|
let rawPath = process.argv[3].replaceAll(`'`, '');
|
|
20
15
|
let toPath = process.argv[4].replaceAll(`'`, '');
|
|
@@ -77,6 +72,12 @@ try {
|
|
|
77
72
|
fs.copyFileSync(absolutePath, `${toPath}/${copyPath}`);
|
|
78
73
|
}
|
|
79
74
|
|
|
75
|
+
if (type === 'update-template') {
|
|
76
|
+
fs.copySync(`./.vscode`, `../pwa-microservices-template/.vscode`);
|
|
77
|
+
fs.copySync(`./.github`, `../pwa-microservices-template/.github`);
|
|
78
|
+
fs.copySync(`./src/client/public/default`, `../pwa-microservices-template/src/client/public/default`);
|
|
79
|
+
}
|
|
80
|
+
|
|
80
81
|
break;
|
|
81
82
|
case 'create':
|
|
82
83
|
const buildPath = `${path}/${name}${ext ? `.${ext}` : ''}`;
|
package/bin/index.js
CHANGED
|
@@ -4,9 +4,13 @@ import dotenv from 'dotenv';
|
|
|
4
4
|
import { shellCd, shellExec } from '../src/server/process.js';
|
|
5
5
|
import fs from 'fs-extra';
|
|
6
6
|
import { Command } from 'commander';
|
|
7
|
+
import { MongooseDB } from '../src/db/mongo/MongooseDB.js';
|
|
8
|
+
import { loggerFactory, underpostASCI } from '../src/server/logger.js';
|
|
7
9
|
|
|
8
10
|
dotenv.config();
|
|
9
11
|
|
|
12
|
+
const logger = loggerFactory(import.meta);
|
|
13
|
+
|
|
10
14
|
const globalBinFolder = `${shellExec(`npm root -g`, {
|
|
11
15
|
stdout: true,
|
|
12
16
|
silent: true,
|
|
@@ -15,23 +19,42 @@ const globalBinFolder = `${shellExec(`npm root -g`, {
|
|
|
15
19
|
|
|
16
20
|
const program = new Command();
|
|
17
21
|
|
|
18
|
-
const version = '2.7.
|
|
22
|
+
const version = '2.7.3';
|
|
19
23
|
|
|
20
24
|
program.name('underpost').description(`underpost.net ci/cd cli ${version}`).version(version);
|
|
21
25
|
|
|
22
26
|
program
|
|
23
27
|
.command('new <app-name>')
|
|
24
28
|
.description('Create a new project')
|
|
25
|
-
.action((appName) => {
|
|
29
|
+
.action(async (appName) => {
|
|
30
|
+
console.log(
|
|
31
|
+
underpostASCI() +
|
|
32
|
+
`
|
|
33
|
+
v${version} https://www.nexodev.org/docs
|
|
34
|
+
`,
|
|
35
|
+
);
|
|
36
|
+
await logger.setUpInfo();
|
|
26
37
|
const destFolder = `${process.cwd()}/${appName}`;
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
logger.info('Note: This process may take several minutes to complete');
|
|
39
|
+
logger.info('build app', { destFolder });
|
|
29
40
|
fs.mkdirSync(destFolder, { recursive: true });
|
|
30
41
|
fs.copySync(globalBinFolder, destFolder);
|
|
31
42
|
fs.writeFileSync(`${destFolder}/.gitignore`, fs.readFileSync(`${globalBinFolder}/.dockerignore`, 'utf8'), 'utf8');
|
|
32
43
|
shellCd(`${destFolder}`);
|
|
33
44
|
shellExec(`git init && git add . && git commit -m "Base template implementation"`);
|
|
34
45
|
shellExec(`npm run install-template`);
|
|
46
|
+
switch (process.platform) {
|
|
47
|
+
case 'linux':
|
|
48
|
+
try {
|
|
49
|
+
await MongooseDB.server();
|
|
50
|
+
} catch (error) {
|
|
51
|
+
logger.error(error, 'failed to start mongodb server');
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
|
|
55
|
+
default:
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
35
58
|
shellExec(`npm run dev`);
|
|
36
59
|
});
|
|
37
60
|
|
package/bin/ssl.js
CHANGED
|
@@ -14,10 +14,7 @@ const logger = loggerFactory(import.meta);
|
|
|
14
14
|
|
|
15
15
|
await logger.setUpInfo();
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
// node bin/ssl windows <deploy-id> www.example.com
|
|
19
|
-
|
|
20
|
-
const [exe, dir, os, deployId, hosts] = process.argv;
|
|
17
|
+
const [exe, dir, deployId, hosts] = process.argv;
|
|
21
18
|
|
|
22
19
|
try {
|
|
23
20
|
let cmd;
|
|
@@ -44,14 +41,7 @@ try {
|
|
|
44
41
|
await ncp.copy(cmd);
|
|
45
42
|
await read({ prompt: 'Command copy to clipboard, press enter to continue.\n' });
|
|
46
43
|
// Certificate
|
|
47
|
-
|
|
48
|
-
case 'windows':
|
|
49
|
-
await buildSSL(host);
|
|
50
|
-
break;
|
|
51
|
-
|
|
52
|
-
default:
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
44
|
+
await buildSSL(host);
|
|
55
45
|
logger.info('Certificate saved', host);
|
|
56
46
|
} else throw new Error(`host not found: ${host}`);
|
|
57
47
|
}
|
package/docker-compose.yml
CHANGED
package/package.json
CHANGED
|
@@ -109,6 +109,6 @@ SrrComponent = ({ ttiLoadTimeLimit }) => {
|
|
|
109
109
|
const CacheControl = ${CacheControl};
|
|
110
110
|
CacheControl({ ttiLoadTimeLimit: ${ttiLoadTimeLimit ? ttiLoadTimeLimit : 1000 * 70 * 1} });
|
|
111
111
|
</script>
|
|
112
|
-
<div class="clean-cache-container">v2.7.
|
|
112
|
+
<div class="clean-cache-container">v2.7.3</div>
|
|
113
113
|
`;
|
|
114
114
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
|
-
|
|
2
|
+
import cron from 'node-cron';
|
|
3
3
|
import { loggerFactory } from '../../server/logger.js';
|
|
4
4
|
import { getCapVariableName } from '../../client/components/core/CommonJs.js';
|
|
5
|
+
import { shellCd, shellExec } from '../../server/process.js';
|
|
5
6
|
|
|
6
7
|
const logger = loggerFactory(import.meta);
|
|
7
8
|
|
|
@@ -41,6 +42,96 @@ const MongooseDB = {
|
|
|
41
42
|
|
|
42
43
|
return models;
|
|
43
44
|
},
|
|
45
|
+
server: async function () {
|
|
46
|
+
logger.info('platform', process.platform);
|
|
47
|
+
switch (process.platform) {
|
|
48
|
+
case 'win32':
|
|
49
|
+
{
|
|
50
|
+
// https://www.mongodb.com/docs/v7.0/tutorial/install-mongodb-on-windows-unattended/
|
|
51
|
+
|
|
52
|
+
// C:\Program Files\MongoDB\Tools\100\bin
|
|
53
|
+
|
|
54
|
+
const urlDownload = `https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-7.0.14-signed.msi`;
|
|
55
|
+
const folderPath = `./engine-private/setup`;
|
|
56
|
+
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
57
|
+
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
58
|
+
logger.info('destination', fullPath);
|
|
59
|
+
shellCd(folderPath);
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
case 'linux':
|
|
63
|
+
{
|
|
64
|
+
if (!process.argv.includes('server')) {
|
|
65
|
+
logger.info('remove');
|
|
66
|
+
shellExec(`sudo apt-get purge mongodb-org*`);
|
|
67
|
+
shellExec(`sudo rm -r /var/log/mongodb`);
|
|
68
|
+
shellExec(`sudo rm -r /var/lib/mongodb`);
|
|
69
|
+
// restore lib
|
|
70
|
+
// shellExec(`sudo chown -R mongodb:mongodb /var/lib/mongodb/*`);
|
|
71
|
+
|
|
72
|
+
if (process.argv.includes('legacy')) {
|
|
73
|
+
logger.info('install legacy 4.4');
|
|
74
|
+
shellExec(`wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -`);
|
|
75
|
+
|
|
76
|
+
shellExec(
|
|
77
|
+
`echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list`,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
shellExec(`sudo apt-get update`);
|
|
81
|
+
|
|
82
|
+
shellExec(
|
|
83
|
+
`sudo apt-get install mongodb-org=4.4.8 mongodb-org-server=4.4.8 mongodb-org-shell=4.4.8 mongodb-org-mongos=4.4.8 mongodb-org-tools=4.4.8`,
|
|
84
|
+
);
|
|
85
|
+
} else {
|
|
86
|
+
logger.info('install 7.0');
|
|
87
|
+
shellExec(`curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
|
|
88
|
+
sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
|
|
89
|
+
--dearmor`);
|
|
90
|
+
shellExec(
|
|
91
|
+
`echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list`,
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
shellExec(`sudo apt-get update`);
|
|
95
|
+
|
|
96
|
+
shellExec(`sudo apt-get install -y mongodb-org`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
logger.info('clean server environment');
|
|
100
|
+
shellExec(`sudo service mongod stop`);
|
|
101
|
+
shellExec(`sudo systemctl unmask mongod`);
|
|
102
|
+
shellExec(`sudo pkill -f mongod`);
|
|
103
|
+
shellExec(`sudo systemctl enable mongod.service`);
|
|
104
|
+
shellExec(`sudo chown -R mongodb:mongodb /var/lib/mongodb`);
|
|
105
|
+
shellExec(`sudo chown mongodb:mongodb /tmp/mongodb-27017.sock`);
|
|
106
|
+
|
|
107
|
+
logger.info('run server');
|
|
108
|
+
shellExec(`sudo service mongod restart`);
|
|
109
|
+
|
|
110
|
+
const checkStatus = () => {
|
|
111
|
+
logger.info('check status');
|
|
112
|
+
shellExec(`sudo systemctl status mongod`);
|
|
113
|
+
shellExec(`sudo systemctl --type=service | grep mongod`);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
checkStatus();
|
|
117
|
+
break;
|
|
118
|
+
// every 30 minute
|
|
119
|
+
cron.schedule(
|
|
120
|
+
'0 */30 * * * *',
|
|
121
|
+
async () => {
|
|
122
|
+
checkStatus();
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
scheduled: true,
|
|
126
|
+
timezone: process.env.TIME_ZONE || 'America/New_York',
|
|
127
|
+
},
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
default:
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
},
|
|
44
135
|
};
|
|
45
136
|
|
|
46
137
|
export { MongooseDB };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import { network } from '../../server/network.js';
|
|
3
|
-
import { shellExec } from '../../server/process.js';
|
|
3
|
+
import { shellCd, shellExec } from '../../server/process.js';
|
|
4
4
|
import { timer } from '../../client/components/core/CommonJs.js';
|
|
5
|
+
import { loggerFactory } from '../../server/logger.js';
|
|
6
|
+
|
|
7
|
+
const logger = loggerFactory(import.meta);
|
|
5
8
|
|
|
6
9
|
const Lampp = {
|
|
7
10
|
ports: [],
|
|
@@ -64,6 +67,49 @@ const Lampp = {
|
|
|
64
67
|
this.router = undefined;
|
|
65
68
|
if (fs.existsSync(`./tmp/lampp-router.conf`)) fs.rmSync(`./tmp/lampp-router.conf`);
|
|
66
69
|
},
|
|
70
|
+
install: async function () {
|
|
71
|
+
switch (process.platform) {
|
|
72
|
+
case 'linux':
|
|
73
|
+
{
|
|
74
|
+
if (!fs.existsSync(`./engine-private/setup`)) fs.mkdirSync(`./engine-private/setup`, { recursive: true });
|
|
75
|
+
|
|
76
|
+
shellCd(`./engine-private/setup`);
|
|
77
|
+
|
|
78
|
+
if (!process.argv.includes(`server`)) {
|
|
79
|
+
shellExec(
|
|
80
|
+
`curl -Lo xampp-linux-installer.run https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/7.4.30/xampp-linux-x64-7.4.30-1-installer.run?from_af=true`,
|
|
81
|
+
);
|
|
82
|
+
shellExec(`sudo chmod +x xampp-linux-installer.run`);
|
|
83
|
+
shellExec(
|
|
84
|
+
`sudo ./xampp-linux-installer.run --mode unattended && \\` +
|
|
85
|
+
`ln -sf /opt/lampp/lampp /usr/bin/lampp && \\` +
|
|
86
|
+
`sed -i.bak s'/Require local/Require all granted/g' /opt/lampp/etc/extra/httpd-xampp.conf && \\` +
|
|
87
|
+
`sed -i.bak s'/display_errors=Off/display_errors=On/g' /opt/lampp/etc/php.ini && \\` +
|
|
88
|
+
`mkdir /opt/lampp/apache2/conf.d && \\` +
|
|
89
|
+
`echo "IncludeOptional /opt/lampp/apache2/conf.d/*.conf" >> /opt/lampp/etc/httpd.conf && \\` +
|
|
90
|
+
`mkdir /www && \\` +
|
|
91
|
+
`ln -s /www /opt/lampp/htdocs`,
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
if (fs.existsSync(`/opt/lampp/logs/access_log`))
|
|
95
|
+
fs.copySync(`/opt/lampp/logs/access_log`, `/opt/lampp/logs/access.log`);
|
|
96
|
+
if (fs.existsSync(`/opt/lampp/logs/error_log`))
|
|
97
|
+
fs.copySync(`/opt/lampp/logs/error_log`, `/opt/lampp/logs/error.log`);
|
|
98
|
+
if (fs.existsSync(`/opt/lampp/logs/php_error_log`))
|
|
99
|
+
fs.copySync(`/opt/lampp/logs/php_error_log`, `/opt/lampp/logs/php_error.log`);
|
|
100
|
+
if (fs.existsSync(`/opt/lampp/logs/ssl_request_log`))
|
|
101
|
+
fs.copySync(`/opt/lampp/logs/ssl_request_log`, `/opt/lampp/logs/ssl_request.log`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
await Lampp.initService({ daemon: true });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
break;
|
|
108
|
+
|
|
109
|
+
default:
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
67
113
|
};
|
|
68
114
|
|
|
69
115
|
export { Lampp };
|
|
@@ -164,12 +164,6 @@ const buildClient = async (options = { liveClientBuildPaths: [], instances: [] }
|
|
|
164
164
|
|
|
165
165
|
if (redirect || disabledRebuild) continue;
|
|
166
166
|
|
|
167
|
-
if (!enableLiveRebuild && runtime === 'lampp' && client === 'wordpress') {
|
|
168
|
-
shellExec(`node bin/install linux wordpress ${host}${path}`);
|
|
169
|
-
shellExec(`node bin/db ${host}${path} create`);
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
167
|
if (fullBuildEnabled) {
|
|
174
168
|
// !(confServer[host]['/'] && confServer[host]['/'].liteBuild)
|
|
175
169
|
await fullBuild({
|
package/src/server/logger.js
CHANGED
|
@@ -87,6 +87,7 @@ const format = (meta) =>
|
|
|
87
87
|
*/
|
|
88
88
|
const setUpInfo = async (logger = new winston.Logger()) => {
|
|
89
89
|
logger.info('argv', process.argv);
|
|
90
|
+
logger.info('platform', process.platform);
|
|
90
91
|
logger.info('env', process.env.NODE_ENV);
|
|
91
92
|
logger.info('admin', await isAdmin());
|
|
92
93
|
logger.info('--max-old-space-size', {
|
|
@@ -177,4 +178,13 @@ const loggerMiddleware = (meta = { url: '' }) => {
|
|
|
177
178
|
);
|
|
178
179
|
};
|
|
179
180
|
|
|
180
|
-
|
|
181
|
+
const underpostASCI = () => `
|
|
182
|
+
▗▖ ▗▖▗▖ ▗▖▗▄▄▄ ▗▄▄▄▖▗▄▄▖ ▄▄▄▄ ▄▄▄ ▄▄▄ ■
|
|
183
|
+
▐▌ ▐▌▐▛▚▖▐▌▐▌ █ ▐▌ ▐▌ ▐▌█ █ █ █ ▀▄▄▗▄▟▙▄▖
|
|
184
|
+
▐▌ ▐▌▐▌ ▝▜▌▐▌ █ ▐▛▀▀▘▐▛▀▚▖█▄▄▄▀ ▀▄▄▄▀ ▄▄▄▀ ▐▌
|
|
185
|
+
▝▚▄▞▘▐▌ ▐▌▐▙▄▄▀ ▐▙▄▄▖▐▌ ▐▌█ ▐▌
|
|
186
|
+
▀ ▐▌
|
|
187
|
+
|
|
188
|
+
`;
|
|
189
|
+
|
|
190
|
+
export { loggerFactory, loggerMiddleware, setUpInfo, underpostASCI };
|
package/src/server/process.js
CHANGED
|
@@ -53,13 +53,13 @@ const ProcessController = {
|
|
|
53
53
|
},
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
const shellExec = (cmd, options = { silent: false, async: false, stdout: false, disableLog:
|
|
56
|
+
const shellExec = (cmd, options = { silent: false, async: false, stdout: false, disableLog: false }) => {
|
|
57
57
|
if (!options.disableLog) logger.info(`cmd`, cmd);
|
|
58
58
|
return options.stdout ? shell.exec(cmd, options).stdout : shell.exec(cmd, options);
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
const shellCd = (cd, options = { disableLog:
|
|
62
|
-
if (options.disableLog) logger.info(`cd`, cd);
|
|
61
|
+
const shellCd = (cd, options = { disableLog: false }) => {
|
|
62
|
+
if (!options.disableLog) logger.info(`cd`, cd);
|
|
63
63
|
return shell.cd(cd);
|
|
64
64
|
};
|
|
65
65
|
|
package/src/server/ssl.js
CHANGED
|
@@ -106,4 +106,15 @@ const sslRedirectMiddleware = (req, res, port, proxyRouter) => {
|
|
|
106
106
|
return res.status(302).redirect(sslRedirectUrl);
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
const installCertbot = () => {
|
|
110
|
+
switch (process.platform) {
|
|
111
|
+
case 'win32':
|
|
112
|
+
break;
|
|
113
|
+
case 'linux':
|
|
114
|
+
break;
|
|
115
|
+
default:
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export { buildSSL, buildSecureContext, validateSecureContext, createSslServer, sslRedirectMiddleware, installCertbot };
|
package/bin/dns.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// update single/group/all dns record: A | ANAME
|
package/bin/install.js
DELETED
|
@@ -1,398 +0,0 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import AdmZip from 'adm-zip';
|
|
3
|
-
import axios from 'axios';
|
|
4
|
-
import { Downloader } from '../src/server/downloader.js';
|
|
5
|
-
import { getRootDirectory, shellCd, shellExec } from '../src/server/process.js';
|
|
6
|
-
import { loggerFactory } from '../src/server/logger.js';
|
|
7
|
-
import { s4 } from '../src/client/components/core/CommonJs.js';
|
|
8
|
-
|
|
9
|
-
const logger = loggerFactory(import.meta);
|
|
10
|
-
|
|
11
|
-
logger.info('argv', process.argv);
|
|
12
|
-
|
|
13
|
-
const [exe, dir, os, program, hostPath = '', deployId] = process.argv;
|
|
14
|
-
const [host, path = ''] = hostPath.split('/');
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
let cmd;
|
|
18
|
-
switch (program) {
|
|
19
|
-
case 'lab':
|
|
20
|
-
switch (os) {
|
|
21
|
-
case 'windows':
|
|
22
|
-
{
|
|
23
|
-
const urlDownload = 'https://github.com/underpostnet/lab.git';
|
|
24
|
-
// const folderPath = `./lab`;
|
|
25
|
-
// if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
26
|
-
shellExec(`git clone ${urlDownload}`);
|
|
27
|
-
const dependencies = [
|
|
28
|
-
'transformers',
|
|
29
|
-
'tensorflow',
|
|
30
|
-
'torch',
|
|
31
|
-
'torchaudio',
|
|
32
|
-
'torchvision',
|
|
33
|
-
'diffusers',
|
|
34
|
-
'nvidia-cuda-runtime-cu11',
|
|
35
|
-
'torchrec-nightly',
|
|
36
|
-
'matplotlib',
|
|
37
|
-
'scikit-learn',
|
|
38
|
-
'numpy',
|
|
39
|
-
'pandas',
|
|
40
|
-
];
|
|
41
|
-
for (const dependencie of dependencies) {
|
|
42
|
-
shellExec(`pip install ${dependencie}`);
|
|
43
|
-
shellExec(`conda install ${dependencie}`);
|
|
44
|
-
}
|
|
45
|
-
shellExec(`conda install -c anaconda cudatoolkit`);
|
|
46
|
-
shellExec(`conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia`);
|
|
47
|
-
|
|
48
|
-
shellExec(`conda create --name cuda_env`);
|
|
49
|
-
shellExec(`conda activate cuda_env`);
|
|
50
|
-
|
|
51
|
-
shellExec(`conda config --append channels conda-forge`);
|
|
52
|
-
shellExec(`conda config --append channels nvidia`);
|
|
53
|
-
}
|
|
54
|
-
break;
|
|
55
|
-
|
|
56
|
-
default:
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
break;
|
|
60
|
-
case 'certbot':
|
|
61
|
-
switch (os) {
|
|
62
|
-
case 'windows':
|
|
63
|
-
await (async () => {
|
|
64
|
-
const urlDownload =
|
|
65
|
-
'https://github.com/certbot/certbot/releases/latest/download/certbot-beta-installer-win_amd64_signed.exe';
|
|
66
|
-
const folderPath = `./engine-private/setup`;
|
|
67
|
-
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
68
|
-
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
69
|
-
logger.info('destination', fullPath);
|
|
70
|
-
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
71
|
-
cmd = `PowerShell Start-Process -FilePath "${fullPath}" -ArgumentList "/S" -Wait`;
|
|
72
|
-
shellExec(cmd);
|
|
73
|
-
})();
|
|
74
|
-
break;
|
|
75
|
-
default:
|
|
76
|
-
throw new Error(`Os not found: ${os} for program ${program}`);
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
case 'xampp':
|
|
80
|
-
switch (os) {
|
|
81
|
-
case 'windows':
|
|
82
|
-
await (async () => {
|
|
83
|
-
const versions = {
|
|
84
|
-
'7.4.13-0':
|
|
85
|
-
'https://ufpr.dl.sourceforge.net/project/xampp/XAMPP%20Windows/7.4.13/xampp-windows-x64-7.4.13-0-VC15-installer.exe',
|
|
86
|
-
'7.4.13-1':
|
|
87
|
-
'https://ufpr.dl.sourceforge.net/project/xampp/XAMPP%20Windows/7.4.13/xampp-portable-windows-x64-7.4.13-1-VC15-installer.exe',
|
|
88
|
-
'8.0.28':
|
|
89
|
-
'https://sitsa.dl.sourceforge.net/project/xampp/XAMPP%20Windows/8.0.28/xampp-windows-x64-8.0.28-0-VS16-installer.exe',
|
|
90
|
-
};
|
|
91
|
-
const urlDownload = versions['7.4.13-1'];
|
|
92
|
-
const folderPath = `./engine-private/setup`;
|
|
93
|
-
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
94
|
-
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
95
|
-
logger.info('destination', fullPath);
|
|
96
|
-
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
97
|
-
cmd = `${getRootDirectory()}${fullPath.slice(1)} --mode unattended`;
|
|
98
|
-
if (!fs.existsSync(`C:/xampp/apache`)) shellExec(cmd);
|
|
99
|
-
fs.writeFileSync(
|
|
100
|
-
`C:/xampp/apache/conf/httpd.template.conf`,
|
|
101
|
-
fs.readFileSync(`C:/xampp/apache/conf/httpd.conf`, 'utf8'),
|
|
102
|
-
'utf8',
|
|
103
|
-
);
|
|
104
|
-
fs.writeFileSync(
|
|
105
|
-
`C:/xampp/apache/conf/extra/httpd-ssl.template.conf`,
|
|
106
|
-
fs.readFileSync(`C:/xampp/apache/conf/extra/httpd-ssl.conf`, 'utf8'),
|
|
107
|
-
'utf8',
|
|
108
|
-
);
|
|
109
|
-
fs.writeFileSync(`C:/xampp/.gitignore`, `/htdocs`, 'utf8');
|
|
110
|
-
shellCd(`c:/xampp`);
|
|
111
|
-
shellExec(`git init && git add . && git commit -m "update"`);
|
|
112
|
-
shellCd(getRootDirectory());
|
|
113
|
-
})();
|
|
114
|
-
break;
|
|
115
|
-
default:
|
|
116
|
-
throw new Error(`Os not found: ${os} for program ${program}`);
|
|
117
|
-
}
|
|
118
|
-
break;
|
|
119
|
-
case 'docker':
|
|
120
|
-
switch (os) {
|
|
121
|
-
case 'windows':
|
|
122
|
-
await (async () => {
|
|
123
|
-
const urlDownload = `https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe`;
|
|
124
|
-
const folderPath = `./engine-private/setup`;
|
|
125
|
-
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
126
|
-
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
127
|
-
logger.info('destination', fullPath);
|
|
128
|
-
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
129
|
-
logger.warn('You must have WSL, install with the following command', `wsl --install`);
|
|
130
|
-
cmd = `${getRootDirectory()}${fullPath.slice(1)} install --quiet --accept-license`;
|
|
131
|
-
if (!fs.existsSync(`C:/Program Files/Docker/Docker`)) shellExec(cmd);
|
|
132
|
-
})();
|
|
133
|
-
break;
|
|
134
|
-
|
|
135
|
-
default:
|
|
136
|
-
throw new Error(`Os not found: ${os} for program ${program}`);
|
|
137
|
-
}
|
|
138
|
-
break;
|
|
139
|
-
case 'wordpress':
|
|
140
|
-
await (async () => {
|
|
141
|
-
const urlDownload = `https://wordpress.org/latest.zip`;
|
|
142
|
-
const folderPath = `./engine-private/setup`;
|
|
143
|
-
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
144
|
-
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
145
|
-
logger.info('destination', fullPath);
|
|
146
|
-
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
147
|
-
const confServer = JSON.parse(
|
|
148
|
-
fs.readFileSync(
|
|
149
|
-
deployId ? `./engine-private/conf/${deployId}/conf.server.json` : `./conf/conf.server.json`,
|
|
150
|
-
'utf8',
|
|
151
|
-
),
|
|
152
|
-
);
|
|
153
|
-
const { directory, db } = confServer[host][`/${path}`];
|
|
154
|
-
logger.info('client found', confServer[host][`/${path}`]);
|
|
155
|
-
const zipTargetPath = directory ? directory : `./public/${path ? `${host}/${path}` : host}`;
|
|
156
|
-
if (!fs.existsSync(zipTargetPath)) fs.mkdirSync(zipTargetPath, { recursive: true });
|
|
157
|
-
const tmpFolderExtract = s4() + s4();
|
|
158
|
-
fs.mkdirSync(`./public/${tmpFolderExtract}`, { recursive: true });
|
|
159
|
-
logger.info(`Please wait, zip extract to`, zipTargetPath);
|
|
160
|
-
new AdmZip(fullPath).extractAllTo(/*target path*/ `./public/${tmpFolderExtract}`, /*overwrite*/ true);
|
|
161
|
-
fs.moveSync(`./public/${tmpFolderExtract}/wordpress`, zipTargetPath, { overwrite: true });
|
|
162
|
-
// https://wordpress.org/documentation/article/htaccess/
|
|
163
|
-
// https://github.com/chimurai/http-proxy-middleware/issues/785
|
|
164
|
-
let htaccess = ``;
|
|
165
|
-
if (host.split('.')[2]) {
|
|
166
|
-
// sub domain
|
|
167
|
-
htaccess += `# BEGIN WordPress Multisite
|
|
168
|
-
# Using subdomain network type: https://wordpress.org/documentation/article/htaccess/#multisite
|
|
169
|
-
|
|
170
|
-
RewriteEngine On
|
|
171
|
-
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
|
172
|
-
RewriteBase /
|
|
173
|
-
RewriteRule ^index\.php$ - [L]
|
|
174
|
-
|
|
175
|
-
# add a trailing slash to /wp-admin
|
|
176
|
-
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
|
|
177
|
-
|
|
178
|
-
RewriteCond %{REQUEST_FILENAME} -f [OR]
|
|
179
|
-
RewriteCond %{REQUEST_FILENAME} -d
|
|
180
|
-
RewriteRule ^ - [L]
|
|
181
|
-
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
|
|
182
|
-
RewriteRule ^(.*\.php)$ $1 [L]
|
|
183
|
-
RewriteRule . index.php [L]
|
|
184
|
-
|
|
185
|
-
# END WordPress Multisite
|
|
186
|
-
`;
|
|
187
|
-
} else if (path) {
|
|
188
|
-
// sub folder
|
|
189
|
-
htaccess += `# BEGIN WordPress Multisite
|
|
190
|
-
# Using subfolder network type: https://wordpress.org/documentation/article/htaccess/#multisite
|
|
191
|
-
|
|
192
|
-
RewriteEngine On
|
|
193
|
-
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
|
194
|
-
RewriteBase /
|
|
195
|
-
RewriteRule ^index\.php$ - [L]
|
|
196
|
-
|
|
197
|
-
# add a trailing slash to /wp-admin
|
|
198
|
-
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
|
|
199
|
-
|
|
200
|
-
RewriteCond %{REQUEST_FILENAME} -f [OR]
|
|
201
|
-
RewriteCond %{REQUEST_FILENAME} -d
|
|
202
|
-
RewriteRule ^ - [L]
|
|
203
|
-
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
|
|
204
|
-
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
|
|
205
|
-
RewriteRule . index.php [L]
|
|
206
|
-
|
|
207
|
-
# END WordPress Multisite
|
|
208
|
-
`;
|
|
209
|
-
} else {
|
|
210
|
-
// main domain
|
|
211
|
-
htaccess += `
|
|
212
|
-
# BEGIN WordPress
|
|
213
|
-
|
|
214
|
-
RewriteEngine On
|
|
215
|
-
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
|
216
|
-
RewriteBase /
|
|
217
|
-
RewriteRule ^index\.php$ - [L]
|
|
218
|
-
RewriteCond %{REQUEST_FILENAME} !-f
|
|
219
|
-
RewriteCond %{REQUEST_FILENAME} !-d
|
|
220
|
-
RewriteRule . /index.php [L]
|
|
221
|
-
|
|
222
|
-
# END WordPress
|
|
223
|
-
`;
|
|
224
|
-
}
|
|
225
|
-
// fs.writeFileSync(`${zipTargetPath}/.htaccess`, htaccess, 'utf8');
|
|
226
|
-
const secretKeyResult = await axios.get(`https://api.wordpress.org/secret-key/1.1/salt/`);
|
|
227
|
-
logger.info('wordpress secret Key Result', secretKeyResult.data);
|
|
228
|
-
fs.writeFileSync(
|
|
229
|
-
`${zipTargetPath}/wp-config.php`,
|
|
230
|
-
fs
|
|
231
|
-
.readFileSync(`${zipTargetPath}/wp-config-sample.php`, 'utf8')
|
|
232
|
-
.replaceAll(`define( 'AUTH_KEY', 'put your unique phrase here' );`, '')
|
|
233
|
-
.replaceAll(`define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );`, '')
|
|
234
|
-
.replaceAll(`define( 'LOGGED_IN_KEY', 'put your unique phrase here' );`, '')
|
|
235
|
-
.replaceAll(`define( 'NONCE_KEY', 'put your unique phrase here' );`, '')
|
|
236
|
-
.replaceAll(`define( 'AUTH_SALT', 'put your unique phrase here' );`, '')
|
|
237
|
-
.replaceAll(`define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );`, '')
|
|
238
|
-
.replaceAll(`define( 'LOGGED_IN_SALT', 'put your unique phrase here' );`, '')
|
|
239
|
-
.replaceAll(`define( 'NONCE_SALT', 'put your unique phrase here' );`, '')
|
|
240
|
-
.replaceAll(
|
|
241
|
-
`/**#@-*/`,
|
|
242
|
-
`${secretKeyResult.data}
|
|
243
|
-
|
|
244
|
-
/**#@-*/`,
|
|
245
|
-
)
|
|
246
|
-
.replaceAll('database_name_here', db.name)
|
|
247
|
-
.replaceAll('username_here', db.user)
|
|
248
|
-
.replaceAll('password_here', db.password)
|
|
249
|
-
.replaceAll(`$table_prefix = 'wp_';`, `$table_prefix = 'wp_${db.name}_';`),
|
|
250
|
-
'utf8',
|
|
251
|
-
);
|
|
252
|
-
const rootDirectory = getRootDirectory();
|
|
253
|
-
shellCd(zipTargetPath);
|
|
254
|
-
shellExec(`git init && git add . && git commit -m "update"`);
|
|
255
|
-
shellCd(rootDirectory);
|
|
256
|
-
fs.rmSync(`./public/${tmpFolderExtract}`, { recursive: true, force: true });
|
|
257
|
-
const wpHtaccess = `
|
|
258
|
-
# BEGIN WordPress
|
|
259
|
-
<IfModule mod_rewrite.c>
|
|
260
|
-
RewriteEngine On
|
|
261
|
-
RewriteRule ^index\.php$ - [L]
|
|
262
|
-
RewriteCond $1 ^(index\.php)?$ [OR]
|
|
263
|
-
# RewriteCond $1 \.(gif|jpg|png|ico|css|js|php)$ [NC,OR]
|
|
264
|
-
RewriteCond $1 \.(.*) [NC,OR]
|
|
265
|
-
RewriteCond %{REQUEST_FILENAME} -f [OR]
|
|
266
|
-
RewriteCond %{REQUEST_FILENAME} -d
|
|
267
|
-
RewriteRule ^(.*)$ - [S=1]
|
|
268
|
-
RewriteRule . /index.php [L]
|
|
269
|
-
</IfModule>
|
|
270
|
-
# END wordpress
|
|
271
|
-
`;
|
|
272
|
-
})();
|
|
273
|
-
break;
|
|
274
|
-
case 'nginx':
|
|
275
|
-
// https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mariadb-php-lemp-stack-on-debian-10
|
|
276
|
-
// https://github.com/pothi/wordpress-nginx/
|
|
277
|
-
// https://github.com/digitalocean/nginxconfig.io
|
|
278
|
-
break;
|
|
279
|
-
case 'mongodb':
|
|
280
|
-
switch (os) {
|
|
281
|
-
case 'windows':
|
|
282
|
-
await (async () => {
|
|
283
|
-
const versions = {
|
|
284
|
-
'6.0': 'https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-6.0.11-signed.msi',
|
|
285
|
-
'7.0': `https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-7.0.3-signed.msi`,
|
|
286
|
-
};
|
|
287
|
-
const version = '6.0';
|
|
288
|
-
const urlDownload = versions[version];
|
|
289
|
-
const folderPath = `./engine-private/setup`;
|
|
290
|
-
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
291
|
-
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
292
|
-
logger.info('destination', fullPath);
|
|
293
|
-
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
294
|
-
// https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-windows-unattended/
|
|
295
|
-
// msiexec.exe /i <path_to_package> [/quiet][/passive][/q{n|b|r|f}]
|
|
296
|
-
// /quiet - quiet mode (there is no user interaction)
|
|
297
|
-
// /passive - unattended mode (the installation shows only a progress bar)
|
|
298
|
-
// /q - set the UI level:
|
|
299
|
-
// n - no UI
|
|
300
|
-
// n+ - no UI except for a modal dialog box displayed at the end.
|
|
301
|
-
// b - basic UI
|
|
302
|
-
// b+ - basic UI with a modal dialog box displayed at the end. The modal box is not displayed if the user cancels the installation. Use qb+! or qb!+ to hide the [ Cancel ] button.
|
|
303
|
-
// b- - basic UI with no modal dialog boxes. Please note that /qb+- is not a supported UI level. Use qb-! or qb!- to hide the [ Cancel ] button.
|
|
304
|
-
// r - reduced UI
|
|
305
|
-
// f - full UI
|
|
306
|
-
// cmd = `msiexec.exe /i ${getRootDirectory()}${fullPath.slice(1)} /qn`;
|
|
307
|
-
shellCd(`${getRootDirectory()}${folderPath.slice(1)}`);
|
|
308
|
-
cmd = `msiexec.exe /i ${urlDownload.split('/').pop()} ^ SHOULD_INSTALL_COMPASS="1" /qn`;
|
|
309
|
-
if (!fs.existsSync(`C:/Program Files/MongoDB/Server`)) shellExec(cmd);
|
|
310
|
-
const dbPath = `c:/mongodb/data`;
|
|
311
|
-
if (!fs.existsSync(dbPath)) fs.mkdirSync(dbPath, { recursive: true });
|
|
312
|
-
// https://www.mongodb.com/docs/v6.0/tutorial/install-mongodb-on-windows/
|
|
313
|
-
// https://medium.com/stackfame/run-mongodb-as-a-service-in-windows-b0acd3a4b712
|
|
314
|
-
// shellCd(`C:/Program Files/MongoDB/Server/${version}/bin/`);
|
|
315
|
-
// shellExec(`mongos.exe --dbpath="${dbPath}"`);
|
|
316
|
-
// shellExec(`"C:/Program Files/MongoDB/Server/${version}/bin/mongos.exe" --dbpath "${dbPath}"`);
|
|
317
|
-
})();
|
|
318
|
-
break;
|
|
319
|
-
|
|
320
|
-
default:
|
|
321
|
-
throw new Error(`Os not found: ${os} for program ${program}`);
|
|
322
|
-
}
|
|
323
|
-
break;
|
|
324
|
-
case 'mongodb-op-cli':
|
|
325
|
-
switch (os) {
|
|
326
|
-
case 'windows':
|
|
327
|
-
await (async () => {
|
|
328
|
-
// https://www.mongodb.com/try/download/mongocli
|
|
329
|
-
const urlDownload = `https://fastdl.mongodb.org/mongocli/mongocli_1.31.0_windows_x86_64.msi`;
|
|
330
|
-
const folderPath = `./engine-private/setup`;
|
|
331
|
-
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
332
|
-
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
333
|
-
logger.info('destination', fullPath);
|
|
334
|
-
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
335
|
-
shellCd(`${getRootDirectory()}${folderPath.slice(1)}`);
|
|
336
|
-
cmd = `msiexec.exe /i ${urlDownload.split('/').pop()} /qn`;
|
|
337
|
-
shellExec(cmd);
|
|
338
|
-
})();
|
|
339
|
-
break;
|
|
340
|
-
|
|
341
|
-
default:
|
|
342
|
-
throw new Error(`Os not found: ${os} for program ${program}`);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
break;
|
|
346
|
-
case 'mongodb-op-tools':
|
|
347
|
-
switch (os) {
|
|
348
|
-
case 'windows':
|
|
349
|
-
await (async () => {
|
|
350
|
-
// env export import
|
|
351
|
-
// https://www.mongodb.com/try/download/database-tools
|
|
352
|
-
const urlDownload = `https://fastdl.mongodb.org/tools/db/mongodb-database-tools-windows-x86_64-100.9.3.msi`;
|
|
353
|
-
const folderPath = `./engine-private/setup`;
|
|
354
|
-
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
355
|
-
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
356
|
-
logger.info('destination', fullPath);
|
|
357
|
-
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
358
|
-
shellCd(`${getRootDirectory()}${folderPath.slice(1)}`);
|
|
359
|
-
cmd = `msiexec.exe /i ${urlDownload.split('/').pop()} /qn`;
|
|
360
|
-
shellExec(cmd);
|
|
361
|
-
})();
|
|
362
|
-
break;
|
|
363
|
-
|
|
364
|
-
default:
|
|
365
|
-
throw new Error(`Os not found: ${os} for program ${program}`);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
break;
|
|
369
|
-
case 'mongodb-shell':
|
|
370
|
-
switch (os) {
|
|
371
|
-
case 'windows':
|
|
372
|
-
await (async () => {
|
|
373
|
-
// https://www.mongodb.com/try/download/shell
|
|
374
|
-
const urlDownload = `https://downloads.mongodb.com/compass/mongosh-2.1.0-x64.msi`;
|
|
375
|
-
const folderPath = `./engine-private/setup`;
|
|
376
|
-
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
377
|
-
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
378
|
-
logger.info('destination', fullPath);
|
|
379
|
-
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
380
|
-
shellCd(`${getRootDirectory()}${folderPath.slice(1)}`);
|
|
381
|
-
cmd = `msiexec.exe /i ${urlDownload.split('/').pop()} /qn`;
|
|
382
|
-
shellExec(cmd);
|
|
383
|
-
})();
|
|
384
|
-
break;
|
|
385
|
-
|
|
386
|
-
default:
|
|
387
|
-
throw new Error(`Os not found: ${os} for program ${program}`);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
break;
|
|
391
|
-
|
|
392
|
-
default:
|
|
393
|
-
throw new Error(`Program not found: ${program}`);
|
|
394
|
-
}
|
|
395
|
-
logger.info(`end install ${program} on ${os}`);
|
|
396
|
-
} catch (error) {
|
|
397
|
-
logger.error(error, error.stack);
|
|
398
|
-
}
|
package/bin/shortcut.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import { getRootDirectory, shellExec } from '../src/server/process.js';
|
|
3
|
-
import os from 'os';
|
|
4
|
-
|
|
5
|
-
const [exe, dir, oS, env] = process.argv;
|
|
6
|
-
|
|
7
|
-
switch (oS) {
|
|
8
|
-
case 'windows':
|
|
9
|
-
switch (env) {
|
|
10
|
-
case 'development':
|
|
11
|
-
(() => {
|
|
12
|
-
const desktopDir = `${os.homedir()}/desktop`.replaceAll('\\', '/');
|
|
13
|
-
fs.writeFileSync(
|
|
14
|
-
`./bin/shortcut.ps1`,
|
|
15
|
-
`
|
|
16
|
-
$DesktopPath = [Environment]::GetFolderPath("Desktop") + "/${env}-engine.lnk"
|
|
17
|
-
|
|
18
|
-
$WshShell = New-Object -comObject WScript.Shell
|
|
19
|
-
|
|
20
|
-
$Shortcut = $WshShell.CreateShortcut($DesktopPath)
|
|
21
|
-
|
|
22
|
-
$Shortcut.TargetPath = "cmd.exe"
|
|
23
|
-
|
|
24
|
-
$Shortcut.Arguments = "PowerShell Start-Process cmd -Verb RunAs -ArgumentList '/k cd ${getRootDirectory()} && npm run dev"
|
|
25
|
-
|
|
26
|
-
$Shortcut.IconLocation = "${getRootDirectory()}/src/client/public/doc/favicon.ico"
|
|
27
|
-
|
|
28
|
-
$Shortcut.Save()
|
|
29
|
-
`,
|
|
30
|
-
);
|
|
31
|
-
shellExec(`PowerShell bin/shortcut.ps1`);
|
|
32
|
-
fs.unlinkSync(`./bin/shortcut.ps1`);
|
|
33
|
-
})();
|
|
34
|
-
break;
|
|
35
|
-
|
|
36
|
-
default:
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
break;
|
|
41
|
-
|
|
42
|
-
default:
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
File without changes
|