underpost 2.8.44 → 2.8.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ghpkg.yml +13 -46
- package/.github/workflows/npmpkg.yml +67 -0
- package/.github/workflows/publish.yml +5 -5
- package/.github/workflows/pwa-microservices-template.page.yml +3 -2
- package/.github/workflows/pwa-microservices-template.test.yml +2 -2
- package/.vscode/settings.json +2 -0
- package/CHANGELOG.md +16 -0
- package/Dockerfile +3 -24
- package/bin/build.js +37 -0
- package/bin/deploy.js +1 -14
- package/bin/file.js +19 -13
- package/bin/index.js +117 -39
- package/docker-compose.yml +1 -1
- package/manifests/mongodb/backup-access.yaml +16 -0
- package/manifests/mongodb/backup-cronjob.yaml +40 -0
- package/manifests/mongodb/backup-pv-pvc.yaml +22 -0
- package/manifests/mongodb/configmap.yaml +26 -0
- package/manifests/mongodb/headless-service.yaml +10 -0
- package/manifests/mongodb/kustomization.yaml +11 -0
- package/manifests/mongodb/pv-pvc.yaml +23 -0
- package/manifests/mongodb/statefulset.yaml +125 -0
- package/manifests/valkey/kustomization.yaml +2 -2
- package/manifests/valkey/service.yaml +17 -0
- package/manifests/valkey/statefulset.yaml +39 -0
- package/package.json +25 -5
- package/src/cli/cluster.js +154 -0
- package/src/cli/db.js +98 -0
- package/src/cli/env.js +52 -0
- package/src/cli/image.js +118 -0
- package/src/cli/repository.js +108 -0
- package/src/cli/script.js +29 -0
- package/src/cli/secrets.js +37 -0
- package/src/cli/test.js +32 -0
- package/src/client/components/core/Auth.js +22 -4
- package/src/client/components/core/CommonJs.js +73 -1
- package/src/client/components/core/Input.js +1 -1
- package/src/client/components/core/Scroll.js +1 -0
- package/src/client/components/core/Translate.js +4 -0
- package/src/index.js +61 -24
- package/src/server/conf.js +6 -208
- package/src/server/logger.js +3 -3
- package/src/server/network.js +2 -2
- package/startup.cjs +0 -12
- /package/manifests/deployment/{mongo-express.yaml → mongo-express/deployment.yaml} +0 -0
- /package/manifests/deployment/{phpmyadmin.yaml → phpmyadmin/deployment.yaml} +0 -0
package/src/cli/env.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { getNpmRootPath, writeEnv } from '../server/conf.js';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import { loggerFactory } from '../server/logger.js';
|
|
4
|
+
import dotenv from 'dotenv';
|
|
5
|
+
|
|
6
|
+
dotenv.config();
|
|
7
|
+
|
|
8
|
+
const logger = loggerFactory(import.meta);
|
|
9
|
+
|
|
10
|
+
class UnderpostRootEnv {
|
|
11
|
+
static API = {
|
|
12
|
+
set(key, value) {
|
|
13
|
+
const exeRootPath = `${getNpmRootPath()}/underpost`;
|
|
14
|
+
const envPath = `${exeRootPath}/.env`;
|
|
15
|
+
let env = {};
|
|
16
|
+
if (fs.existsSync(envPath)) env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
|
|
17
|
+
env[key] = value;
|
|
18
|
+
writeEnv(envPath, env);
|
|
19
|
+
},
|
|
20
|
+
delete(key) {
|
|
21
|
+
const exeRootPath = `${getNpmRootPath()}/underpost`;
|
|
22
|
+
const envPath = `${exeRootPath}/.env`;
|
|
23
|
+
let env = {};
|
|
24
|
+
if (fs.existsSync(envPath)) env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
|
|
25
|
+
delete env[key];
|
|
26
|
+
writeEnv(envPath, env);
|
|
27
|
+
},
|
|
28
|
+
get(key) {
|
|
29
|
+
const exeRootPath = `${getNpmRootPath()}/underpost`;
|
|
30
|
+
const envPath = `${exeRootPath}/.env`;
|
|
31
|
+
if (!fs.existsSync(envPath)) return logger.error(`Unable to find underpost root environment`);
|
|
32
|
+
const env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
|
|
33
|
+
logger.info('underpost root', { [key]: env[key] });
|
|
34
|
+
return env[key];
|
|
35
|
+
},
|
|
36
|
+
list() {
|
|
37
|
+
const exeRootPath = `${getNpmRootPath()}/underpost`;
|
|
38
|
+
const envPath = `${exeRootPath}/.env`;
|
|
39
|
+
if (!fs.existsSync(envPath)) return logger.error(`Unable to find underpost root environment`);
|
|
40
|
+
const env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
|
|
41
|
+
logger.info('underpost root', env);
|
|
42
|
+
return env;
|
|
43
|
+
},
|
|
44
|
+
clean() {
|
|
45
|
+
const exeRootPath = `${getNpmRootPath()}/underpost`;
|
|
46
|
+
const envPath = `${exeRootPath}/.env`;
|
|
47
|
+
fs.removeSync(envPath);
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default UnderpostRootEnv;
|
package/src/cli/image.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import Underpost from '../index.js';
|
|
3
|
+
import { shellExec } from '../server/process.js';
|
|
4
|
+
import { MariaDB } from '../db/mariadb/MariaDB.js';
|
|
5
|
+
import dotenv from 'dotenv';
|
|
6
|
+
import { getNpmRootPath } from '../server/conf.js';
|
|
7
|
+
|
|
8
|
+
dotenv.config();
|
|
9
|
+
|
|
10
|
+
class UnderpostImage {
|
|
11
|
+
static API = {
|
|
12
|
+
dockerfile: {
|
|
13
|
+
pullBaseImages() {
|
|
14
|
+
shellExec(`sudo podman pull docker.io/library/debian:buster`);
|
|
15
|
+
},
|
|
16
|
+
build(deployId = 'default', env = 'development', path = '.', imageArchive = false) {
|
|
17
|
+
const imgName = `${deployId}-${env}:${Underpost.version}`;
|
|
18
|
+
const podManImg = `localhost/${imgName}`;
|
|
19
|
+
const imagesStoragePath = `./images`;
|
|
20
|
+
const tarFile = `${imagesStoragePath}/${imgName.replace(':', '_')}.tar`;
|
|
21
|
+
|
|
22
|
+
let secrets = ' ';
|
|
23
|
+
let secretDockerInput = '';
|
|
24
|
+
|
|
25
|
+
const envObj = dotenv.parse(fs.readFileSync(`${getNpmRootPath()}/underpost/.env`, 'utf8'));
|
|
26
|
+
|
|
27
|
+
for (const key of Object.keys(envObj)) {
|
|
28
|
+
continue;
|
|
29
|
+
secrets += ` && export ${key}="${envObj[key]}" `; // $(cat gitlab-token.txt)
|
|
30
|
+
secretDockerInput += ` --secret id=${key},env=${key} \ `;
|
|
31
|
+
}
|
|
32
|
+
// --rm --no-cache
|
|
33
|
+
if (imageArchive !== true) {
|
|
34
|
+
fs.copyFile(`${getNpmRootPath()}/underpost/.env`, `${path}/.env.underpost`);
|
|
35
|
+
shellExec(
|
|
36
|
+
`cd ${path}${secrets}&& sudo podman build -f ./Dockerfile -t ${imgName} --pull=never --cap-add=CAP_AUDIT_WRITE${secretDockerInput}`,
|
|
37
|
+
);
|
|
38
|
+
fs.removeSync(`${path}/.env.underpost`);
|
|
39
|
+
shellExec(`cd ${path} && podman save -o ${tarFile} ${podManImg}`);
|
|
40
|
+
}
|
|
41
|
+
shellExec(`cd ${path} && sudo kind load image-archive ${tarFile}`);
|
|
42
|
+
},
|
|
43
|
+
async script(deployId = 'default', env = 'development') {
|
|
44
|
+
switch (deployId) {
|
|
45
|
+
case 'dd-lampp':
|
|
46
|
+
{
|
|
47
|
+
const lamppPublicPath = '/xampp/htdocs/online';
|
|
48
|
+
if (process.argv.includes('test')) {
|
|
49
|
+
const { MARIADB_HOST, MARIADB_USER, MARIADB_PASSWORD, DD_LAMPP_TEST_DB_0 } = process.env;
|
|
50
|
+
|
|
51
|
+
await MariaDB.query({
|
|
52
|
+
host: MARIADB_HOST,
|
|
53
|
+
user: MARIADB_USER,
|
|
54
|
+
password: MARIADB_PASSWORD,
|
|
55
|
+
query: `SHOW TABLES FROM ${DD_LAMPP_TEST_DB_0}`,
|
|
56
|
+
});
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
shellExec(`sudo mkdir -p ${lamppPublicPath}`);
|
|
60
|
+
|
|
61
|
+
{
|
|
62
|
+
shellExec(
|
|
63
|
+
`cd ${lamppPublicPath} && git clone https://${process.env.GITHUB_TOKEN}@github.com/${process.env.DD_LAMPP_REPO_0}`,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
shellExec(`cd ${lamppPublicPath} && sudo ${process.env.DD_LAMPP_SCRIPT_0}`);
|
|
67
|
+
|
|
68
|
+
shellExec(
|
|
69
|
+
`sudo sed -i -e "s@define( 'DB_HOST', 'localhost' );@define( 'DB_HOST', '${process.env.MARIADB_HOST}' );@g" ${lamppPublicPath}/${process.env.DD_LAMPP_REPO_0_FOLDER}/wp-config.php`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
{
|
|
73
|
+
shellExec(
|
|
74
|
+
`cd ${lamppPublicPath} && git clone https://${process.env.GITHUB_TOKEN}@github.com/${process.env.DD_LAMPP_REPO_1}`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
|
|
80
|
+
default:
|
|
81
|
+
{
|
|
82
|
+
{
|
|
83
|
+
const originPath = `./src/db/mongo/MongooseDB.js`;
|
|
84
|
+
fs.writeFileSync(
|
|
85
|
+
originPath,
|
|
86
|
+
fs.readFileSync(originPath, 'utf8').replaceAll(
|
|
87
|
+
`connect: async (host, name) => {`,
|
|
88
|
+
`connect: async (host, name) => {
|
|
89
|
+
host = 'mongodb://mongodb-0.mongodb-service:27017';
|
|
90
|
+
`,
|
|
91
|
+
),
|
|
92
|
+
'utf8',
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
{
|
|
97
|
+
const originPath = `./src/server/valkey.js`;
|
|
98
|
+
fs.writeFileSync(
|
|
99
|
+
originPath,
|
|
100
|
+
fs.readFileSync(originPath, 'utf8').replaceAll(
|
|
101
|
+
` // port: 6379,
|
|
102
|
+
// host: 'service-valkey.default.svc.cluster.local',`,
|
|
103
|
+
` port: 6379,
|
|
104
|
+
host: 'service-valkey.default.svc.cluster.local',`,
|
|
105
|
+
),
|
|
106
|
+
'utf8',
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
shellExec(`node bin/deploy conf ${deployId} ${env}`);
|
|
113
|
+
shellExec(`node bin/deploy build-full-client ${deployId}`);
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export default UnderpostImage;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { commitData } from '../client/components/core/CommonJs.js';
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
import { pbcopy, shellExec } from '../server/process.js';
|
|
4
|
+
import { actionInitLog, loggerFactory } from '../server/logger.js';
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
import { getNpmRootPath } from '../server/conf.js';
|
|
7
|
+
|
|
8
|
+
dotenv.config();
|
|
9
|
+
|
|
10
|
+
const logger = loggerFactory(import.meta);
|
|
11
|
+
|
|
12
|
+
class UnderpostRepository {
|
|
13
|
+
static API = {
|
|
14
|
+
clone(gitUri = 'underpostnet/pwa-microservices-template', options = { bare: false }) {
|
|
15
|
+
const repoName = gitUri.split('/').pop();
|
|
16
|
+
if (fs.existsSync(`./${repoName}`)) fs.removeSync(`./${repoName}`);
|
|
17
|
+
return shellExec(
|
|
18
|
+
`git clone ${options?.bare === true ? ` --bare ` : ''}https://${
|
|
19
|
+
process.env.GITHUB_TOKEN ? `${process.env.GITHUB_TOKEN}@` : ''
|
|
20
|
+
}github.com/${gitUri}.git`,
|
|
21
|
+
{
|
|
22
|
+
disableLog: true,
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
if (process.env.GITHUB_TOKEN) {
|
|
26
|
+
shellExec(
|
|
27
|
+
`git clone https://${
|
|
28
|
+
process.env.GITHUB_TOKEN ? `${process.env.GITHUB_TOKEN}@` : ''
|
|
29
|
+
}github.com/${gitUri}-private.git`,
|
|
30
|
+
);
|
|
31
|
+
fs.moveSync(`./${repoName}-private`, `./${repoName}/engine-private`, {
|
|
32
|
+
overwrite: true,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
pull(repoPath = './', gitUri = 'underpostnet/pwa-microservices-template') {
|
|
37
|
+
shellExec(
|
|
38
|
+
`cd ${repoPath} && git pull https://${
|
|
39
|
+
process.env.GITHUB_TOKEN ? `${process.env.GITHUB_TOKEN}@` : ''
|
|
40
|
+
}github.com/${gitUri}.git`,
|
|
41
|
+
{
|
|
42
|
+
disableLog: true,
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
commit(
|
|
47
|
+
repoPath = './',
|
|
48
|
+
commitType = 'feat',
|
|
49
|
+
subModule = '',
|
|
50
|
+
message = '',
|
|
51
|
+
options = {
|
|
52
|
+
copy: false,
|
|
53
|
+
info: false,
|
|
54
|
+
empty: false,
|
|
55
|
+
},
|
|
56
|
+
) {
|
|
57
|
+
if (options.info) return logger.info('', commitData);
|
|
58
|
+
const _message = `${commitType}${subModule ? `(${subModule})` : ''}${process.argv.includes('!') ? '!' : ''}: ${
|
|
59
|
+
commitData[commitType].emoji
|
|
60
|
+
} ${message ? message : commitData[commitType].description}`;
|
|
61
|
+
if (options.copy) return pbcopy(_message);
|
|
62
|
+
shellExec(`cd ${repoPath} && git commit ${options?.empty ? `--allow-empty ` : ''}-m "${_message}"`);
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
push(repoPath = './', gitUri = 'underpostnet/pwa-microservices-template', options = { f: false }) {
|
|
66
|
+
shellExec(
|
|
67
|
+
`cd ${repoPath} && git push https://${process.env.GITHUB_TOKEN}@github.com/${gitUri}.git${
|
|
68
|
+
options?.f === true ? ' --force' : ''
|
|
69
|
+
}`,
|
|
70
|
+
{
|
|
71
|
+
disableLog: true,
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
logger.info(
|
|
75
|
+
'commit url',
|
|
76
|
+
`http://github.com/${gitUri}/commit/${shellExec(`cd ${repoPath} && git rev-parse --verify HEAD`, {
|
|
77
|
+
stdout: true,
|
|
78
|
+
}).trim()}`,
|
|
79
|
+
);
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
new(repositoryName) {
|
|
83
|
+
return new Promise(async (resolve, reject) => {
|
|
84
|
+
try {
|
|
85
|
+
const exeRootPath = `${getNpmRootPath()}/underpost`;
|
|
86
|
+
actionInitLog();
|
|
87
|
+
await logger.setUpInfo();
|
|
88
|
+
const destFolder = `./${repositoryName}`;
|
|
89
|
+
logger.info('Note: This process may take several minutes to complete');
|
|
90
|
+
logger.info('build app', { destFolder });
|
|
91
|
+
if (fs.existsSync(destFolder)) fs.removeSync(destFolder);
|
|
92
|
+
fs.mkdirSync(destFolder, { recursive: true });
|
|
93
|
+
fs.copySync(exeRootPath, destFolder);
|
|
94
|
+
fs.writeFileSync(`${destFolder}/.gitignore`, fs.readFileSync(`${exeRootPath}/.dockerignore`, 'utf8'), 'utf8');
|
|
95
|
+
shellExec(`cd ${destFolder} && git init && git add . && git commit -m "Base template implementation"`);
|
|
96
|
+
shellExec(`cd ${destFolder} && npm run build`);
|
|
97
|
+
shellExec(`cd ${destFolder} && npm run dev`);
|
|
98
|
+
return resolve();
|
|
99
|
+
} catch (error) {
|
|
100
|
+
logger.error(error, error.stack);
|
|
101
|
+
return reject(error.message);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default UnderpostRepository;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getNpmRootPath } from '../server/conf.js';
|
|
2
|
+
import { loggerFactory } from '../server/logger.js';
|
|
3
|
+
import { shellExec } from '../server/process.js';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
|
|
6
|
+
const logger = loggerFactory(import.meta);
|
|
7
|
+
|
|
8
|
+
class UnderpostScript {
|
|
9
|
+
static API = {
|
|
10
|
+
set(key, value) {
|
|
11
|
+
const npmRoot = `${getNpmRootPath()}/underpost`;
|
|
12
|
+
const packageJson = JSON.parse(fs.readFileSync(`${npmRoot}/package.json`, 'utf8'));
|
|
13
|
+
packageJson.scripts[key] = value;
|
|
14
|
+
fs.writeFileSync(`${npmRoot}/package.json`, JSON.stringify(packageJson, null, 4));
|
|
15
|
+
},
|
|
16
|
+
run(key) {
|
|
17
|
+
const npmRoot = `${getNpmRootPath()}/underpost`;
|
|
18
|
+
shellExec(`cd ${npmRoot} && npm run ${key}`);
|
|
19
|
+
},
|
|
20
|
+
get(key) {
|
|
21
|
+
const npmRoot = `${getNpmRootPath()}/underpost`;
|
|
22
|
+
const packageJson = JSON.parse(fs.readFileSync(`${npmRoot}/package.json`, 'utf8'));
|
|
23
|
+
logger.info('[get] ' + key, packageJson.scripts[key]);
|
|
24
|
+
return packageJson.scripts[key];
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default UnderpostScript;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
import { shellExec } from '../server/process.js';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import UnderpostRootEnv from './env.js';
|
|
5
|
+
|
|
6
|
+
class UnderpostSecret {
|
|
7
|
+
static API = {
|
|
8
|
+
docker: {
|
|
9
|
+
init() {
|
|
10
|
+
shellExec(`docker swarm init`);
|
|
11
|
+
},
|
|
12
|
+
createFromEnvFile(envPath) {
|
|
13
|
+
const envObj = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
|
|
14
|
+
for (const key of Object.keys(envObj)) {
|
|
15
|
+
UnderpostSecret.API.docker.set(key, envObj[key]);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
set(key, value) {
|
|
19
|
+
shellExec(`docker secret rm ${key}`);
|
|
20
|
+
shellExec(`echo "${value}" | docker secret create ${key} -`);
|
|
21
|
+
},
|
|
22
|
+
list() {
|
|
23
|
+
shellExec(`docker secret ls`);
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
underpost: {
|
|
27
|
+
createFromEnvFile(envPath) {
|
|
28
|
+
const envObj = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
|
|
29
|
+
for (const key of Object.keys(envObj)) {
|
|
30
|
+
UnderpostRootEnv.API.set(key, envObj[key]);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default UnderpostSecret;
|
package/src/cli/test.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getNpmRootPath } from '../server/conf.js';
|
|
2
|
+
import { actionInitLog, loggerFactory } from '../server/logger.js';
|
|
3
|
+
import { shellExec } from '../server/process.js';
|
|
4
|
+
|
|
5
|
+
const logger = loggerFactory(import.meta);
|
|
6
|
+
|
|
7
|
+
class UnderpostTest {
|
|
8
|
+
static API = {
|
|
9
|
+
/**
|
|
10
|
+
* Logs information about the current process environment to the console.
|
|
11
|
+
*
|
|
12
|
+
* This function is used to log details about
|
|
13
|
+
* the execution context, such as command-line arguments,
|
|
14
|
+
* environment variables, the process's administrative privileges,
|
|
15
|
+
* and the maximum available heap space size.
|
|
16
|
+
*
|
|
17
|
+
* @static
|
|
18
|
+
* @method setUpInfo
|
|
19
|
+
* @returns {Promise<void>}
|
|
20
|
+
* @memberof Underpost
|
|
21
|
+
*/
|
|
22
|
+
async setUpInfo() {
|
|
23
|
+
return await setUpInfo(logger);
|
|
24
|
+
},
|
|
25
|
+
run() {
|
|
26
|
+
actionInitLog();
|
|
27
|
+
shellExec(`cd ${getNpmRootPath()}/underpost && npm run test`);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default UnderpostTest;
|
|
@@ -3,7 +3,10 @@ import { Account } from './Account.js';
|
|
|
3
3
|
import { loggerFactory } from './Logger.js';
|
|
4
4
|
import { LogIn } from './LogIn.js';
|
|
5
5
|
import { LogOut } from './LogOut.js';
|
|
6
|
+
import { NotificationManager } from './NotificationManager.js';
|
|
6
7
|
import { SignUp } from './SignUp.js';
|
|
8
|
+
import { Translate } from './Translate.js';
|
|
9
|
+
import { s } from './VanillaJs.js';
|
|
7
10
|
|
|
8
11
|
const logger = loggerFactory(import.meta);
|
|
9
12
|
|
|
@@ -65,6 +68,7 @@ const Auth = {
|
|
|
65
68
|
const _result = await UserService.get({ id: 'auth' });
|
|
66
69
|
return {
|
|
67
70
|
status: _result.status,
|
|
71
|
+
message: _result.message,
|
|
68
72
|
data: {
|
|
69
73
|
user: _result.data,
|
|
70
74
|
},
|
|
@@ -77,6 +81,15 @@ const Auth = {
|
|
|
77
81
|
await Account.updateForm(data.user);
|
|
78
82
|
return { user: data.user };
|
|
79
83
|
}
|
|
84
|
+
if (message && message.match('expired'))
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
s(`.main-btn-log-in`).click();
|
|
87
|
+
NotificationManager.Push({
|
|
88
|
+
html: Translate.Render(`expired-session`),
|
|
89
|
+
status: 'warning',
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
return await Auth.sessionOut();
|
|
80
93
|
}
|
|
81
94
|
|
|
82
95
|
// anon guest session
|
|
@@ -92,20 +105,25 @@ const Auth = {
|
|
|
92
105
|
|
|
93
106
|
this.setGuestToken(guestToken);
|
|
94
107
|
let { data, status, message } = await UserService.get({ id: 'auth' });
|
|
95
|
-
if (status === 'error')
|
|
108
|
+
if (status === 'error') {
|
|
109
|
+
if (message && message.match('expired')) {
|
|
110
|
+
localStorage.removeItem('jwt.g');
|
|
111
|
+
return await Auth.sessionOut();
|
|
112
|
+
} else throw new Error(message);
|
|
113
|
+
}
|
|
96
114
|
await Account.updateForm(data);
|
|
97
115
|
return { user: data };
|
|
98
116
|
} catch (error) {
|
|
99
117
|
logger.error(error);
|
|
100
|
-
localStorage.removeItem('jwt');
|
|
101
|
-
localStorage.removeItem('jwt.g');
|
|
102
118
|
return { user: UserMock.default };
|
|
103
119
|
}
|
|
104
120
|
},
|
|
105
121
|
sessionOut: async function () {
|
|
106
122
|
this.deleteToken();
|
|
107
123
|
localStorage.removeItem('jwt');
|
|
108
|
-
|
|
124
|
+
const result = await this.sessionIn();
|
|
125
|
+
await LogOut.Trigger(result);
|
|
126
|
+
return result;
|
|
109
127
|
},
|
|
110
128
|
};
|
|
111
129
|
|
|
@@ -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
|
};
|
|
@@ -508,6 +508,10 @@ const TranslateCore = {
|
|
|
508
508
|
en: 'Invalid identity document',
|
|
509
509
|
es: 'Documento de identidad inválido',
|
|
510
510
|
};
|
|
511
|
+
Translate.Data['expired-session'] = {
|
|
512
|
+
en: 'Your session has expired. Please log in again.',
|
|
513
|
+
es: 'Su sesión ha expirado. Por favor, inicie sesión de nuevo.',
|
|
514
|
+
};
|
|
511
515
|
},
|
|
512
516
|
};
|
|
513
517
|
|
package/src/index.js
CHANGED
|
@@ -4,10 +4,14 @@
|
|
|
4
4
|
* @namespace Underpost
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import UnderpostCluster from './cli/cluster.js';
|
|
8
|
+
import UnderpostDB from './cli/db.js';
|
|
9
|
+
import UnderpostRootEnv from './cli/env.js';
|
|
10
|
+
import UnderpostImage from './cli/image.js';
|
|
11
|
+
import UnderpostRepository from './cli/repository.js';
|
|
12
|
+
import UnderpostScript from './cli/script.js';
|
|
13
|
+
import UnderpostSecret from './cli/secrets.js';
|
|
14
|
+
import UnderpostTest from './cli/test.js';
|
|
11
15
|
|
|
12
16
|
/**
|
|
13
17
|
* Underpost main module methods
|
|
@@ -21,30 +25,63 @@ class Underpost {
|
|
|
21
25
|
* @type {String}
|
|
22
26
|
* @memberof Underpost
|
|
23
27
|
*/
|
|
24
|
-
static version = 'v2.8.
|
|
25
|
-
|
|
26
|
-
constructor() {}
|
|
27
|
-
|
|
28
|
+
static version = 'v2.8.46';
|
|
28
29
|
/**
|
|
29
|
-
*
|
|
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
|
-
*
|
|
30
|
+
* Repository cli API
|
|
36
31
|
* @static
|
|
37
|
-
* @
|
|
38
|
-
* @returns {Promise<void>}
|
|
32
|
+
* @type {UnderpostRepository.API}
|
|
39
33
|
* @memberof Underpost
|
|
40
34
|
*/
|
|
41
|
-
static
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
static repo = UnderpostRepository.API;
|
|
36
|
+
/**
|
|
37
|
+
* Root Env cli API
|
|
38
|
+
* @static
|
|
39
|
+
* @type {UnderpostRootEnv.API}
|
|
40
|
+
* @memberof Underpost
|
|
41
|
+
*/
|
|
42
|
+
static env = UnderpostRootEnv.API;
|
|
43
|
+
/**
|
|
44
|
+
* Test cli API
|
|
45
|
+
* @static
|
|
46
|
+
* @type {UnderpostTest.API}
|
|
47
|
+
* @memberof Underpost
|
|
48
|
+
*/
|
|
49
|
+
static test = UnderpostTest.API;
|
|
50
|
+
/**
|
|
51
|
+
* Cluster cli API
|
|
52
|
+
* @static
|
|
53
|
+
* @type {UnderpostCluster.API}
|
|
54
|
+
* @memberof Underpost
|
|
55
|
+
*/
|
|
56
|
+
static cluster = UnderpostCluster.API;
|
|
57
|
+
/**
|
|
58
|
+
* Image cli API
|
|
59
|
+
* @static
|
|
60
|
+
* @type {UnderpostImage.API}
|
|
61
|
+
* @memberof Underpost
|
|
62
|
+
*/
|
|
63
|
+
static image = UnderpostImage.API;
|
|
64
|
+
/**
|
|
65
|
+
* Secrets cli API
|
|
66
|
+
* @static
|
|
67
|
+
* @type {UnderpostSecret.API}
|
|
68
|
+
* @memberof Underpost
|
|
69
|
+
*/
|
|
70
|
+
static secret = UnderpostSecret.API;
|
|
71
|
+
/**
|
|
72
|
+
* Scripts cli API
|
|
73
|
+
* @static
|
|
74
|
+
* @type {UnderpostScript.API}
|
|
75
|
+
* @memberof Underpost
|
|
76
|
+
*/
|
|
77
|
+
static script = UnderpostScript.API;
|
|
78
|
+
/**
|
|
79
|
+
* Database cli API
|
|
80
|
+
* @static
|
|
81
|
+
* @type {UnderpostDB.API}
|
|
82
|
+
* @memberof Underpost
|
|
83
|
+
*/
|
|
84
|
+
static db = UnderpostDB.API;
|
|
48
85
|
}
|
|
49
86
|
|
|
50
87
|
const up = Underpost;
|