underpost 2.8.1 → 2.8.6
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/.dockerignore +1 -0
- package/.github/workflows/ghpkg.yml +19 -49
- package/.github/workflows/npmpkg.yml +67 -0
- package/.github/workflows/publish.yml +5 -5
- package/.github/workflows/pwa-microservices-template.page.yml +12 -4
- package/.github/workflows/pwa-microservices-template.test.yml +2 -2
- package/.vscode/extensions.json +17 -71
- package/.vscode/settings.json +18 -3
- package/AUTHORS.md +16 -5
- package/CHANGELOG.md +103 -3
- package/Dockerfile +24 -66
- package/README.md +1 -28
- package/bin/build.js +186 -0
- package/bin/db.js +2 -24
- package/bin/deploy.js +169 -144
- package/bin/file.js +59 -16
- package/bin/hwt.js +0 -10
- package/bin/index.js +201 -60
- package/bin/ssl.js +19 -11
- package/bin/util.js +9 -104
- package/bin/vs.js +26 -2
- package/conf.js +29 -138
- package/docker-compose.yml +1 -1
- package/manifests/deployment/mongo-express/deployment.yaml +60 -0
- package/manifests/deployment/phpmyadmin/deployment.yaml +54 -0
- package/manifests/kind-config-dev.yaml +12 -0
- package/manifests/kind-config.yaml +12 -0
- package/manifests/letsencrypt-prod.yaml +15 -0
- package/manifests/mariadb/config.yaml +10 -0
- package/manifests/mariadb/kustomization.yaml +9 -0
- package/manifests/mariadb/pv.yaml +12 -0
- package/manifests/mariadb/pvc.yaml +10 -0
- package/manifests/mariadb/secret.yaml +8 -0
- package/manifests/mariadb/service.yaml +10 -0
- package/manifests/mariadb/statefulset.yaml +55 -0
- package/manifests/mongodb/backup-access.yaml +16 -0
- package/manifests/mongodb/backup-cronjob.yaml +42 -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/mongodb-4.4/kustomization.yaml +7 -0
- package/manifests/mongodb-4.4/pv-pvc.yaml +23 -0
- package/manifests/mongodb-4.4/service-deployment.yaml +63 -0
- package/manifests/valkey/kustomization.yaml +7 -0
- package/manifests/valkey/service.yaml +17 -0
- package/manifests/valkey/statefulset.yaml +39 -0
- package/package.json +133 -136
- package/src/api/core/core.service.js +1 -1
- package/src/api/user/user.model.js +16 -3
- package/src/api/user/user.service.js +1 -1
- package/src/cli/cluster.js +202 -0
- package/src/cli/cron.js +90 -0
- package/src/cli/db.js +212 -0
- package/src/cli/deploy.js +318 -0
- package/src/cli/env.js +52 -0
- package/src/cli/fs.js +149 -0
- package/src/cli/image.js +148 -0
- package/src/cli/repository.js +125 -0
- package/src/cli/script.js +53 -0
- package/src/cli/secrets.js +37 -0
- package/src/cli/test.js +118 -0
- package/src/client/components/core/Auth.js +22 -4
- package/src/client/components/core/CalendarCore.js +127 -50
- package/src/client/components/core/CommonJs.js +282 -19
- package/src/client/components/core/Css.js +1 -0
- package/src/client/components/core/CssCore.js +8 -4
- package/src/client/components/core/Docs.js +1 -2
- package/src/client/components/core/DropDown.js +5 -1
- package/src/client/components/core/Input.js +22 -6
- package/src/client/components/core/LoadingAnimation.js +8 -1
- package/src/client/components/core/Modal.js +40 -12
- package/src/client/components/core/Panel.js +92 -31
- package/src/client/components/core/PanelForm.js +25 -23
- package/src/client/components/core/Scroll.js +1 -0
- package/src/client/components/core/Translate.js +47 -9
- package/src/client/components/core/Validator.js +9 -1
- package/src/client/components/core/VanillaJs.js +0 -9
- package/src/client/components/core/Worker.js +34 -31
- package/src/client/services/core/core.service.js +15 -10
- package/src/client/services/default/default.management.js +4 -2
- package/src/client/ssr/Render.js +4 -1
- package/src/client/ssr/body/CacheControl.js +2 -3
- package/src/client/sw/default.sw.js +3 -3
- package/src/db/mongo/MongooseDB.js +29 -1
- package/src/index.js +85 -19
- package/src/runtime/lampp/Lampp.js +1 -13
- package/src/runtime/xampp/Xampp.js +0 -13
- package/src/server/auth.js +3 -3
- package/src/server/backup.js +49 -93
- package/src/server/client-build.js +36 -46
- package/src/server/client-formatted.js +6 -3
- package/src/server/conf.js +204 -54
- package/src/server/dns.js +30 -55
- package/src/server/downloader.js +0 -8
- package/src/server/logger.js +15 -10
- package/src/server/network.js +17 -43
- package/src/server/process.js +25 -2
- package/src/server/proxy.js +4 -26
- package/src/server/runtime.js +30 -30
- package/src/server/ssl.js +1 -1
- package/src/server/valkey.js +2 -0
- package/test/api.test.js +0 -8
- package/src/dns.js +0 -22
- package/src/server/prompt-optimizer.js +0 -28
- package/startup.js +0 -11
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
import { listenPortController, listenServerFactory } from '../server/network.js';
|
|
8
|
+
|
|
9
|
+
dotenv.config();
|
|
10
|
+
|
|
11
|
+
const logger = loggerFactory(import.meta);
|
|
12
|
+
|
|
13
|
+
class UnderpostRepository {
|
|
14
|
+
static API = {
|
|
15
|
+
clone(gitUri = 'underpostnet/pwa-microservices-template', options = { bare: false }) {
|
|
16
|
+
const repoName = gitUri.split('/').pop();
|
|
17
|
+
if (fs.existsSync(`./${repoName}`)) fs.removeSync(`./${repoName}`);
|
|
18
|
+
shellExec(
|
|
19
|
+
`git clone ${options?.bare === true ? ` --bare ` : ''}https://${
|
|
20
|
+
process.env.GITHUB_TOKEN ? `${process.env.GITHUB_TOKEN}@` : ''
|
|
21
|
+
}github.com/${gitUri}.git`,
|
|
22
|
+
{
|
|
23
|
+
disableLog: true,
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
},
|
|
27
|
+
pull(repoPath = './', gitUri = 'underpostnet/pwa-microservices-template') {
|
|
28
|
+
shellExec(
|
|
29
|
+
`cd ${repoPath} && git pull https://${
|
|
30
|
+
process.env.GITHUB_TOKEN ? `${process.env.GITHUB_TOKEN}@` : ''
|
|
31
|
+
}github.com/${gitUri}.git`,
|
|
32
|
+
{
|
|
33
|
+
disableLog: true,
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
},
|
|
37
|
+
commit(
|
|
38
|
+
repoPath = './',
|
|
39
|
+
commitType = 'feat',
|
|
40
|
+
subModule = '',
|
|
41
|
+
message = '',
|
|
42
|
+
options = {
|
|
43
|
+
copy: false,
|
|
44
|
+
info: false,
|
|
45
|
+
empty: false,
|
|
46
|
+
},
|
|
47
|
+
) {
|
|
48
|
+
if (commitType === 'reset') {
|
|
49
|
+
shellExec(`cd ${repoPath} && git reset --soft HEAD~${isNaN(parseInt(subModule)) ? 1 : parseInt(subModule)}`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (options.info) return logger.info('', commitData);
|
|
53
|
+
const _message = `${commitType}${subModule ? `(${subModule})` : ''}${process.argv.includes('!') ? '!' : ''}: ${
|
|
54
|
+
commitData[commitType].emoji
|
|
55
|
+
} ${message ? message : commitData[commitType].description}`;
|
|
56
|
+
if (options.copy) return pbcopy(_message);
|
|
57
|
+
shellExec(`cd ${repoPath} && git commit ${options?.empty ? `--allow-empty ` : ''}-m "${_message}"`);
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
push(repoPath = './', gitUri = 'underpostnet/pwa-microservices-template', options = { f: false }) {
|
|
61
|
+
shellExec(
|
|
62
|
+
`cd ${repoPath} && git push https://${process.env.GITHUB_TOKEN}@github.com/${gitUri}.git${
|
|
63
|
+
options?.f === true ? ' --force' : ''
|
|
64
|
+
}`,
|
|
65
|
+
{
|
|
66
|
+
disableLog: true,
|
|
67
|
+
},
|
|
68
|
+
);
|
|
69
|
+
logger.info(
|
|
70
|
+
'commit url',
|
|
71
|
+
`http://github.com/${gitUri}/commit/${shellExec(`cd ${repoPath} && git rev-parse --verify HEAD`, {
|
|
72
|
+
stdout: true,
|
|
73
|
+
}).trim()}`,
|
|
74
|
+
);
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
new(repositoryName) {
|
|
78
|
+
return new Promise(async (resolve, reject) => {
|
|
79
|
+
try {
|
|
80
|
+
await logger.setUpInfo();
|
|
81
|
+
if (repositoryName === 'service') return resolve(await listenPortController(listenServerFactory(), ':'));
|
|
82
|
+
else actionInitLog();
|
|
83
|
+
const exeRootPath = `${getNpmRootPath()}/underpost`;
|
|
84
|
+
const destFolder = `./${repositoryName}`;
|
|
85
|
+
logger.info('Note: This process may take several minutes to complete');
|
|
86
|
+
logger.info('build app', { destFolder });
|
|
87
|
+
if (fs.existsSync(destFolder)) fs.removeSync(destFolder);
|
|
88
|
+
fs.mkdirSync(destFolder, { recursive: true });
|
|
89
|
+
fs.copySync(exeRootPath, destFolder);
|
|
90
|
+
fs.writeFileSync(`${destFolder}/.gitignore`, fs.readFileSync(`${exeRootPath}/.dockerignore`, 'utf8'), 'utf8');
|
|
91
|
+
shellExec(`cd ${destFolder} && git init && git add . && git commit -m "Base template implementation"`);
|
|
92
|
+
shellExec(`cd ${destFolder} && npm run build`);
|
|
93
|
+
shellExec(`cd ${destFolder} && npm run dev`);
|
|
94
|
+
return resolve();
|
|
95
|
+
} catch (error) {
|
|
96
|
+
logger.error(error, error.stack);
|
|
97
|
+
return reject(error.message);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
getDeleteFiles(path = '.') {
|
|
103
|
+
const commandUntrack = `cd ${path} && git ls-files --deleted`;
|
|
104
|
+
const diffUntrackOutput = shellExec(commandUntrack, { stdout: true, silent: true });
|
|
105
|
+
return diffUntrackOutput.toString().split('\n').filter(Boolean);
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
getChangedFiles(path = '.', extension = '', head = false) {
|
|
109
|
+
const extensionFilter = extension ? `-- '***.${extension}'` : '';
|
|
110
|
+
const command = `cd ${path} && git diff ${head ? 'HEAD^ HEAD ' : ''}--name-only ${extensionFilter}`;
|
|
111
|
+
const commandUntrack = `cd ${path} && git ls-files --others --exclude-standard`;
|
|
112
|
+
const diffOutput = shellExec(command, { stdout: true, silent: true });
|
|
113
|
+
const diffUntrackOutput = shellExec(commandUntrack, { stdout: true, silent: true });
|
|
114
|
+
const deleteFiles = UnderpostRepository.API.getDeleteFiles(path);
|
|
115
|
+
return diffOutput
|
|
116
|
+
.toString()
|
|
117
|
+
.split('\n')
|
|
118
|
+
.filter(Boolean)
|
|
119
|
+
.concat(diffUntrackOutput.toString().split('\n').filter(Boolean))
|
|
120
|
+
.filter((f) => !deleteFiles.includes(f));
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default UnderpostRepository;
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
import UnderpostDeploy from './deploy.js';
|
|
6
|
+
|
|
7
|
+
const logger = loggerFactory(import.meta);
|
|
8
|
+
|
|
9
|
+
class UnderpostScript {
|
|
10
|
+
static API = {
|
|
11
|
+
set(key, value) {
|
|
12
|
+
const npmRoot = `${getNpmRootPath()}/underpost`;
|
|
13
|
+
const packageJson = JSON.parse(fs.readFileSync(`${npmRoot}/package.json`, 'utf8'));
|
|
14
|
+
packageJson.scripts[key] = value;
|
|
15
|
+
fs.writeFileSync(`${npmRoot}/package.json`, JSON.stringify(packageJson, null, 4));
|
|
16
|
+
},
|
|
17
|
+
run(key, value, options) {
|
|
18
|
+
const npmRoot = `${getNpmRootPath()}/underpost`;
|
|
19
|
+
const packageJson = JSON.parse(fs.readFileSync(`${npmRoot}/package.json`, 'utf8'));
|
|
20
|
+
if (options.itc === true) {
|
|
21
|
+
value = packageJson.scripts[key];
|
|
22
|
+
const podScriptPath = `${options.itcPath && typeof options.itcPath === 'string' ? options.itcPath : '/'}${value
|
|
23
|
+
.split('/')
|
|
24
|
+
.pop()}`;
|
|
25
|
+
const nameSpace = options.ns && typeof options.ns === 'string' ? options.ns : 'default';
|
|
26
|
+
const podMatch = options.podName && typeof options.podName === 'string' ? options.podName : key;
|
|
27
|
+
|
|
28
|
+
if (fs.existsSync(`${value}`)) {
|
|
29
|
+
for (const pod of UnderpostDeploy.API.get(podMatch)) {
|
|
30
|
+
shellExec(`sudo kubectl cp ${value} ${nameSpace}/${pod.NAME}:${podScriptPath}`);
|
|
31
|
+
const cmd = `node ${podScriptPath}`;
|
|
32
|
+
shellExec(`sudo kubectl exec -i ${pod.NAME} -- sh -c "${cmd}"`);
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
for (const pod of UnderpostDeploy.API.get(podMatch)) {
|
|
36
|
+
shellExec(`sudo kubectl exec -i ${pod.NAME} -- sh -c "${value}"`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
shellExec(`cd ${npmRoot} && npm run ${key}`);
|
|
43
|
+
},
|
|
44
|
+
get(key) {
|
|
45
|
+
const npmRoot = `${getNpmRootPath()}/underpost`;
|
|
46
|
+
const packageJson = JSON.parse(fs.readFileSync(`${npmRoot}/package.json`, 'utf8'));
|
|
47
|
+
logger.info('[get] ' + key, packageJson.scripts[key]);
|
|
48
|
+
return packageJson.scripts[key];
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
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,118 @@
|
|
|
1
|
+
import { timer } from '../client/components/core/CommonJs.js';
|
|
2
|
+
import { MariaDB } from '../db/mariadb/MariaDB.js';
|
|
3
|
+
import { getNpmRootPath } from '../server/conf.js';
|
|
4
|
+
import { actionInitLog, loggerFactory, setUpInfo } from '../server/logger.js';
|
|
5
|
+
import { pbcopy, shellExec } from '../server/process.js';
|
|
6
|
+
import UnderpostDeploy from './deploy.js';
|
|
7
|
+
|
|
8
|
+
const logger = loggerFactory(import.meta);
|
|
9
|
+
|
|
10
|
+
class UnderpostTest {
|
|
11
|
+
static API = {
|
|
12
|
+
/**
|
|
13
|
+
* Logs information about the current process environment to the console.
|
|
14
|
+
*
|
|
15
|
+
* This function is used to log details about
|
|
16
|
+
* the execution context, such as command-line arguments,
|
|
17
|
+
* environment variables, the process's administrative privileges,
|
|
18
|
+
* and the maximum available heap space size.
|
|
19
|
+
*
|
|
20
|
+
* @static
|
|
21
|
+
* @method setUpInfo
|
|
22
|
+
* @returns {Promise<void>}
|
|
23
|
+
* @memberof Underpost
|
|
24
|
+
*/
|
|
25
|
+
async setUpInfo() {
|
|
26
|
+
return await setUpInfo(logger);
|
|
27
|
+
},
|
|
28
|
+
run() {
|
|
29
|
+
actionInitLog();
|
|
30
|
+
shellExec(`cd ${getNpmRootPath()}/underpost && npm run test`);
|
|
31
|
+
},
|
|
32
|
+
async callback(deployList = '', options = { itc: false, sh: false, logs: false }) {
|
|
33
|
+
if (
|
|
34
|
+
options.podName &&
|
|
35
|
+
typeof options.podName === 'string' &&
|
|
36
|
+
options.podStatus &&
|
|
37
|
+
typeof options.podStatus === 'string'
|
|
38
|
+
)
|
|
39
|
+
return await UnderpostTest.API.statusMonitor(options.podName, options.podStatus, options.kindType);
|
|
40
|
+
|
|
41
|
+
if (options.sh === true || options.logs === true) {
|
|
42
|
+
const [pod] = UnderpostDeploy.API.get(deployList);
|
|
43
|
+
if (pod) {
|
|
44
|
+
if (options.sh) return pbcopy(`sudo kubectl exec -it ${pod.NAME} -- sh`);
|
|
45
|
+
if (options.logs) return shellExec(`sudo kubectl logs -f ${pod.NAME}`);
|
|
46
|
+
}
|
|
47
|
+
return logger.warn(`Couldn't find pods in deployment`, deployList);
|
|
48
|
+
}
|
|
49
|
+
if (deployList) {
|
|
50
|
+
for (const _deployId of deployList.split(',')) {
|
|
51
|
+
const deployId = _deployId.trim();
|
|
52
|
+
if (!deployId) continue;
|
|
53
|
+
if (options.itc === true)
|
|
54
|
+
switch (deployId) {
|
|
55
|
+
case 'dd-lampp':
|
|
56
|
+
{
|
|
57
|
+
const { MARIADB_HOST, MARIADB_USER, MARIADB_PASSWORD, DD_LAMPP_TEST_DB_0 } = process.env;
|
|
58
|
+
|
|
59
|
+
await MariaDB.query({
|
|
60
|
+
host: MARIADB_HOST,
|
|
61
|
+
user: MARIADB_USER,
|
|
62
|
+
password: MARIADB_PASSWORD,
|
|
63
|
+
query: `SHOW TABLES FROM ${DD_LAMPP_TEST_DB_0}`,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
|
|
68
|
+
default:
|
|
69
|
+
{
|
|
70
|
+
shellExec('npm run test');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const pods = UnderpostDeploy.API.get(deployId);
|
|
77
|
+
if (pods.length > 0)
|
|
78
|
+
for (const deployData of pods) {
|
|
79
|
+
const { NAME } = deployData;
|
|
80
|
+
shellExec(
|
|
81
|
+
`sudo kubectl exec -i ${NAME} -- sh -c "cd /home/dd/engine && underpost test ${deployId} --inside-container"`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
else logger.warn(`Couldn't find pods in deployment`, { deployId });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
} else return UnderpostTest.API.run();
|
|
88
|
+
},
|
|
89
|
+
statusMonitor(podName, status = 'Running', kindType = '', deltaMs = 1000, maxAttempts = 60 * 5) {
|
|
90
|
+
if (!(kindType && typeof kindType === 'string')) kindType = 'pods';
|
|
91
|
+
return new Promise(async (resolve) => {
|
|
92
|
+
let index = 0;
|
|
93
|
+
logger.info(`Loading instance`, { podName, status, kindType, deltaMs, maxAttempts });
|
|
94
|
+
const _monitor = async () => {
|
|
95
|
+
await timer(deltaMs);
|
|
96
|
+
const pods = UnderpostDeploy.API.get(podName, kindType);
|
|
97
|
+
const result = pods.find((p) => p.STATUS === status);
|
|
98
|
+
logger.info(
|
|
99
|
+
`Testing pod ${podName}... ${result ? 1 : 0}/1 - elapsed time ${deltaMs * (index + 1)}s - attempt ${
|
|
100
|
+
index + 1
|
|
101
|
+
}/${maxAttempts}`,
|
|
102
|
+
pods[0] ? pods[0].STATUS : 'Not found kind object',
|
|
103
|
+
);
|
|
104
|
+
if (result) return resolve(true);
|
|
105
|
+
index++;
|
|
106
|
+
if (index === maxAttempts) {
|
|
107
|
+
logger.error(`Failed to test pod ${podName} within ${maxAttempts} attempts`);
|
|
108
|
+
return resolve(false);
|
|
109
|
+
}
|
|
110
|
+
return _monitor();
|
|
111
|
+
};
|
|
112
|
+
await _monitor();
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
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
|
|