underpost 2.89.45 → 2.90.1
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.production +2 -0
- package/README.md +3 -2
- package/bin/build.js +4 -0
- package/cli.md +73 -42
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +8 -24
- package/manifests/lxd/underpost-setup.sh +1 -1
- package/package.json +1 -1
- package/scripts/nvim.sh +1 -1
- package/src/cli/cluster.js +7 -21
- package/src/cli/db.js +34 -10
- package/src/cli/deploy.js +280 -116
- package/src/cli/index.js +27 -2
- package/src/cli/monitor.js +1 -1
- package/src/cli/run.js +216 -12
- package/src/cli/static.js +84 -0
- package/src/client/components/core/CalendarCore.js +1 -7
- package/src/client/components/core/Modal.js +2 -2
- package/src/client/components/core/Panel.js +1 -1
- package/src/client/components/core/PanelForm.js +1 -5
- package/src/client/components/default/MenuDefault.js +5 -30
- package/src/index.js +10 -1
- package/src/server/client-build.js +9 -33
- package/src/server/json-schema.js +0 -77
package/src/cli/run.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { daemonProcess, getTerminalPid, openTerminal, pbcopy, shellCd, shellExec } from '../server/process.js';
|
|
8
8
|
import {
|
|
9
9
|
awaitDeployMonitor,
|
|
10
|
+
buildKindPorts,
|
|
10
11
|
Config,
|
|
11
12
|
getNpmRootPath,
|
|
12
13
|
getUnderpostRootPath,
|
|
@@ -68,6 +69,13 @@ class UnderpostRun {
|
|
|
68
69
|
* @property {boolean} terminal - Whether to open a terminal.
|
|
69
70
|
* @property {number} devProxyPortOffset - The port offset for the development proxy.
|
|
70
71
|
* @property {boolean} hostNetwork - Whether to use host networking.
|
|
72
|
+
* @property {string} requestsMemory - The memory request for the container.
|
|
73
|
+
* @property {string} requestsCpu - The CPU request for the container.
|
|
74
|
+
* @property {string} limitsMemory - The memory limit for the container.
|
|
75
|
+
* @property {string} limitsCpu - The CPU limit for the container.
|
|
76
|
+
* @property {string} resourceTemplateId - The resource template ID.
|
|
77
|
+
* @property {boolean} expose - Whether to expose the service.
|
|
78
|
+
* @property {boolean} etcHosts - Whether to modify /etc/hosts.
|
|
71
79
|
* @property {string} confServerPath - The configuration server path.
|
|
72
80
|
* @property {string} underpostRoot - The root path of the Underpost installation.
|
|
73
81
|
* @memberof UnderpostRun
|
|
@@ -100,6 +108,13 @@ class UnderpostRun {
|
|
|
100
108
|
terminal: false,
|
|
101
109
|
devProxyPortOffset: 0,
|
|
102
110
|
hostNetwork: false,
|
|
111
|
+
requestsMemory: '',
|
|
112
|
+
requestsCpu: '',
|
|
113
|
+
limitsMemory: '',
|
|
114
|
+
limitsCpu: '',
|
|
115
|
+
resourceTemplateId: '',
|
|
116
|
+
expose: false,
|
|
117
|
+
etcHosts: false,
|
|
103
118
|
confServerPath: '',
|
|
104
119
|
underpostRoot: '',
|
|
105
120
|
};
|
|
@@ -186,8 +201,8 @@ class UnderpostRun {
|
|
|
186
201
|
* @param {Object} options - The default underpost runner options for customizing workflow
|
|
187
202
|
* @memberof UnderpostRun
|
|
188
203
|
*/
|
|
189
|
-
'underpost-config': (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
190
|
-
UnderpostDeploy.API.configMap(path
|
|
204
|
+
'underpost-config': (path = '', options = UnderpostRun.DEFAULT_OPTION) => {
|
|
205
|
+
UnderpostDeploy.API.configMap(path ? path : 'production', options.namespace);
|
|
191
206
|
},
|
|
192
207
|
/**
|
|
193
208
|
* @method gpu-env
|
|
@@ -224,7 +239,7 @@ class UnderpostRun {
|
|
|
224
239
|
'dev-cluster': (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
225
240
|
const baseCommand = options.dev ? 'node bin' : 'underpost';
|
|
226
241
|
const mongoHosts = ['mongodb-0.mongodb-service'];
|
|
227
|
-
if (
|
|
242
|
+
if (!options.expose) {
|
|
228
243
|
shellExec(`${baseCommand} cluster${options.dev ? ' --dev' : ''} --reset`);
|
|
229
244
|
shellExec(`${baseCommand} cluster${options.dev ? ' --dev' : ''}`);
|
|
230
245
|
|
|
@@ -253,7 +268,7 @@ class UnderpostRun {
|
|
|
253
268
|
metadata: async (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
254
269
|
const ports = '6379,27017';
|
|
255
270
|
shellExec(`node bin run kill '${ports}'`);
|
|
256
|
-
shellExec(`node bin run dev-cluster --dev expose`, { async: true });
|
|
271
|
+
shellExec(`node bin run dev-cluster --dev --expose`, { async: true });
|
|
257
272
|
console.log('Loading fordward services...');
|
|
258
273
|
await timer(5000);
|
|
259
274
|
shellExec(`node bin metadata --generate ${path}`);
|
|
@@ -502,7 +517,7 @@ class UnderpostRun {
|
|
|
502
517
|
}
|
|
503
518
|
|
|
504
519
|
const currentTraffic = isDeployRunnerContext(path, options)
|
|
505
|
-
? UnderpostDeploy.API.getCurrentTraffic(deployId)
|
|
520
|
+
? UnderpostDeploy.API.getCurrentTraffic(deployId, { namespace: options.namespace })
|
|
506
521
|
: '';
|
|
507
522
|
let targetTraffic = currentTraffic ? (currentTraffic === 'blue' ? 'green' : 'blue') : '';
|
|
508
523
|
if (targetTraffic) versions = targetTraffic;
|
|
@@ -517,10 +532,15 @@ class UnderpostRun {
|
|
|
517
532
|
shellExec(
|
|
518
533
|
`${baseCommand} deploy --kubeadm --disable-update-proxy ${deployId} ${env} --versions ${versions}${options.namespace ? ` --namespace ${options.namespace}` : ''}`,
|
|
519
534
|
);
|
|
520
|
-
if (!targetTraffic)
|
|
535
|
+
if (!targetTraffic)
|
|
536
|
+
targetTraffic = UnderpostDeploy.API.getCurrentTraffic(deployId, { namespace: options.namespace });
|
|
521
537
|
await UnderpostDeploy.API.monitorReadyRunner(deployId, env, targetTraffic);
|
|
522
538
|
UnderpostDeploy.API.switchTraffic(deployId, env, targetTraffic);
|
|
523
|
-
} else
|
|
539
|
+
} else
|
|
540
|
+
logger.info(
|
|
541
|
+
'current traffic',
|
|
542
|
+
UnderpostDeploy.API.getCurrentTraffic(deployId, { namespace: options.namespace }),
|
|
543
|
+
);
|
|
524
544
|
},
|
|
525
545
|
|
|
526
546
|
/**
|
|
@@ -555,6 +575,190 @@ class UnderpostRun {
|
|
|
555
575
|
shellExec(`node bin env clean`);
|
|
556
576
|
},
|
|
557
577
|
|
|
578
|
+
/**
|
|
579
|
+
* @method get-proxy
|
|
580
|
+
* @description Retrieves and logs the HTTPProxy resources in the specified namespace using `kubectl get HTTPProxy`.
|
|
581
|
+
* @param {string} path - The input value, identifier, or path for the operation (used as an optional filter for the HTTPProxy resources).
|
|
582
|
+
* @param {Object} options - The default underpost runner options for customizing workflow
|
|
583
|
+
* @memberof UnderpostRun
|
|
584
|
+
*/
|
|
585
|
+
'get-proxy': async (path = '', options = UnderpostRun.DEFAULT_OPTION) => {
|
|
586
|
+
console.log(
|
|
587
|
+
shellExec(`kubectl get HTTPProxy -n ${options.namespace} ${path} -o yaml`, {
|
|
588
|
+
silent: true,
|
|
589
|
+
stdout: true,
|
|
590
|
+
})
|
|
591
|
+
.replaceAll(`blue`, `blue`.bgBlue.bold.black)
|
|
592
|
+
.replaceAll('green', 'green'.bgGreen.bold.black)
|
|
593
|
+
.replaceAll('Error', 'Error'.bold.red)
|
|
594
|
+
.replaceAll('error', 'error'.bold.red)
|
|
595
|
+
.replaceAll('ERROR', 'ERROR'.bold.red)
|
|
596
|
+
.replaceAll('Invalid', 'Invalid'.bold.red)
|
|
597
|
+
.replaceAll('invalid', 'invalid'.bold.red)
|
|
598
|
+
.replaceAll('INVALID', 'INVALID'.bold.red),
|
|
599
|
+
);
|
|
600
|
+
},
|
|
601
|
+
|
|
602
|
+
'instance-promote': async (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
603
|
+
const env = options.dev ? 'development' : 'production';
|
|
604
|
+
const baseCommand = options.dev ? 'node bin' : 'underpost';
|
|
605
|
+
const baseClusterCommand = options.dev ? ' --dev' : '';
|
|
606
|
+
let [deployId, id] = path.split(',');
|
|
607
|
+
const confInstances = JSON.parse(
|
|
608
|
+
fs.readFileSync(`./engine-private/conf/${deployId}/conf.instances.json`, 'utf8'),
|
|
609
|
+
);
|
|
610
|
+
for (const instance of confInstances) {
|
|
611
|
+
let {
|
|
612
|
+
id: _id,
|
|
613
|
+
host: _host,
|
|
614
|
+
path: _path,
|
|
615
|
+
image: _image,
|
|
616
|
+
fromPort: _fromPort,
|
|
617
|
+
toPort: _toPort,
|
|
618
|
+
cmd: _cmd,
|
|
619
|
+
volumes: _volumes,
|
|
620
|
+
metadata: _metadata,
|
|
621
|
+
} = instance;
|
|
622
|
+
if (id !== _id) continue;
|
|
623
|
+
const _deployId = `${deployId}-${_id}`;
|
|
624
|
+
const currentTraffic = UnderpostDeploy.API.getCurrentTraffic(_deployId, {
|
|
625
|
+
hostTest: _host,
|
|
626
|
+
});
|
|
627
|
+
const targetTraffic = currentTraffic ? (currentTraffic === 'blue' ? 'green' : 'blue') : 'blue';
|
|
628
|
+
let proxyYaml =
|
|
629
|
+
UnderpostDeploy.API.baseProxyYamlFactory({ host: _host, env: options.tls ? 'production' : env, options }) +
|
|
630
|
+
UnderpostDeploy.API.deploymentYamlServiceFactory({
|
|
631
|
+
path: _path,
|
|
632
|
+
port: _fromPort,
|
|
633
|
+
// serviceId: deployId,
|
|
634
|
+
deployId: _deployId,
|
|
635
|
+
env,
|
|
636
|
+
deploymentVersions: [targetTraffic],
|
|
637
|
+
// pathRewritePolicy,
|
|
638
|
+
});
|
|
639
|
+
if (options.tls) {
|
|
640
|
+
shellExec(`sudo kubectl delete Certificate ${_host} -n ${options.namespace} --ignore-not-found`);
|
|
641
|
+
proxyYaml += UnderpostDeploy.API.buildCertManagerCertificate({ ...options, host: _host });
|
|
642
|
+
}
|
|
643
|
+
// console.log(proxyYaml);
|
|
644
|
+
shellExec(`kubectl delete HTTPProxy ${_host} --namespace ${options.namespace} --ignore-not-found`);
|
|
645
|
+
shellExec(
|
|
646
|
+
`kubectl apply -f - -n ${options.namespace} <<EOF
|
|
647
|
+
${proxyYaml}
|
|
648
|
+
EOF
|
|
649
|
+
`,
|
|
650
|
+
{ disableLog: true },
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
},
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* @method instance
|
|
657
|
+
* @param {string} path - The input value, identifier, or path for the operation (used as a comma-separated string containing workflow parameters).
|
|
658
|
+
* @param {Object} options - The default underpost runner options for customizing workflow
|
|
659
|
+
* @memberof UnderpostRun
|
|
660
|
+
*/
|
|
661
|
+
instance: async (path = '', options = UnderpostRun.DEFAULT_OPTION) => {
|
|
662
|
+
const env = options.dev ? 'development' : 'production';
|
|
663
|
+
const baseCommand = options.dev ? 'node bin' : 'underpost';
|
|
664
|
+
const baseClusterCommand = options.dev ? ' --dev' : '';
|
|
665
|
+
let [deployId, id, replicas = 1] = path.split(',');
|
|
666
|
+
const confInstances = JSON.parse(
|
|
667
|
+
fs.readFileSync(`./engine-private/conf/${deployId}/conf.instances.json`, 'utf8'),
|
|
668
|
+
);
|
|
669
|
+
const etcHosts = [];
|
|
670
|
+
for (const instance of confInstances) {
|
|
671
|
+
let {
|
|
672
|
+
id: _id,
|
|
673
|
+
host: _host,
|
|
674
|
+
path: _path,
|
|
675
|
+
image: _image,
|
|
676
|
+
fromPort: _fromPort,
|
|
677
|
+
toPort: _toPort,
|
|
678
|
+
cmd: _cmd,
|
|
679
|
+
volumes: _volumes,
|
|
680
|
+
metadata: _metadata,
|
|
681
|
+
} = instance;
|
|
682
|
+
if (id !== _id) continue;
|
|
683
|
+
const _deployId = `${deployId}-${_id}`;
|
|
684
|
+
etcHosts.push(_host);
|
|
685
|
+
if (options.expose) continue;
|
|
686
|
+
// Examples images:
|
|
687
|
+
// `underpost/underpost-engine:${Underpost.version}`
|
|
688
|
+
// `localhost/rockylinux9-underpost:${Underpost.version}`
|
|
689
|
+
if (!_image) _image = `underpost/underpost-engine:${Underpost.version}`;
|
|
690
|
+
|
|
691
|
+
if (options.nodeName) {
|
|
692
|
+
shellExec(`sudo crictl pull ${_image}`);
|
|
693
|
+
} else {
|
|
694
|
+
shellExec(`docker pull ${_image}`);
|
|
695
|
+
shellExec(`sudo kind load docker-image ${_image}`);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
const currentTraffic = UnderpostDeploy.API.getCurrentTraffic(_deployId, {
|
|
699
|
+
hostTest: _host,
|
|
700
|
+
});
|
|
701
|
+
|
|
702
|
+
const targetTraffic = currentTraffic ? (currentTraffic === 'blue' ? 'green' : 'blue') : 'blue';
|
|
703
|
+
const podId = `${_deployId}-${env}-${targetTraffic}`;
|
|
704
|
+
const ignorePods = UnderpostDeploy.API.get(podId).map((p) => p.NAME);
|
|
705
|
+
UnderpostDeploy.API.configMap(env, options.namespace);
|
|
706
|
+
shellExec(`kubectl delete service ${podId}-service --namespace ${options.namespace} --ignore-not-found`);
|
|
707
|
+
shellExec(`kubectl delete deployment ${podId} --namespace ${options.namespace} --ignore-not-found`);
|
|
708
|
+
for (const _volume of _volumes)
|
|
709
|
+
if (_volume.claimName)
|
|
710
|
+
UnderpostDeploy.API.deployVolume(_volume, {
|
|
711
|
+
namespace: options.namespace,
|
|
712
|
+
deployId: _deployId,
|
|
713
|
+
env,
|
|
714
|
+
version: targetTraffic,
|
|
715
|
+
nodeName: options.nodeName,
|
|
716
|
+
});
|
|
717
|
+
let deploymentYaml = `---
|
|
718
|
+
${UnderpostDeploy.API.deploymentYamlPartsFactory({
|
|
719
|
+
deployId: _deployId,
|
|
720
|
+
env,
|
|
721
|
+
suffix: targetTraffic,
|
|
722
|
+
resources: UnderpostDeploy.API.resourcesFactory(options),
|
|
723
|
+
replicas,
|
|
724
|
+
image: _image,
|
|
725
|
+
namespace: options.namespace,
|
|
726
|
+
volumes: _volumes,
|
|
727
|
+
cmd: _cmd[env],
|
|
728
|
+
}).replace('{{ports}}', buildKindPorts(_fromPort, _toPort))}
|
|
729
|
+
`;
|
|
730
|
+
// console.log(deploymentYaml);
|
|
731
|
+
shellExec(
|
|
732
|
+
`kubectl apply -f - -n ${options.namespace} <<EOF
|
|
733
|
+
${deploymentYaml}
|
|
734
|
+
EOF
|
|
735
|
+
`,
|
|
736
|
+
{ disableLog: true },
|
|
737
|
+
);
|
|
738
|
+
const { ready, readyPods } = await UnderpostDeploy.API.monitorReadyRunner(
|
|
739
|
+
_deployId,
|
|
740
|
+
env,
|
|
741
|
+
targetTraffic,
|
|
742
|
+
ignorePods,
|
|
743
|
+
);
|
|
744
|
+
|
|
745
|
+
if (!ready) {
|
|
746
|
+
logger.error(`Deployment ${deployId} did not become ready in time.`);
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
shellExec(
|
|
750
|
+
`${baseCommand} run${baseClusterCommand} --namespace ${options.namespace}` +
|
|
751
|
+
`${options.nodeName ? ` --node-name ${options.nodeName}` : ''}` +
|
|
752
|
+
`${options.tls ? ` --tls` : ''}` +
|
|
753
|
+
` instance-promote '${path}'`,
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
if (options.etcHosts) {
|
|
757
|
+
const hostListenResult = UnderpostDeploy.API.etcHostFactory(etcHosts);
|
|
758
|
+
logger.info(hostListenResult.renderHosts);
|
|
759
|
+
}
|
|
760
|
+
},
|
|
761
|
+
|
|
558
762
|
/**
|
|
559
763
|
* @method ls-deployments
|
|
560
764
|
* @description Retrieves and logs a table of Kubernetes deployments using `UnderpostDeploy.API.get`.
|
|
@@ -827,12 +1031,12 @@ class UnderpostRun {
|
|
|
827
1031
|
if (!inputReplicas) inputReplicas = 1;
|
|
828
1032
|
if (inputDeployId === 'dd') {
|
|
829
1033
|
for (const deployId of fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8').split(',')) {
|
|
830
|
-
const currentTraffic = UnderpostDeploy.API.getCurrentTraffic(deployId);
|
|
1034
|
+
const currentTraffic = UnderpostDeploy.API.getCurrentTraffic(deployId, { namespace: options.namespace });
|
|
831
1035
|
const targetTraffic = currentTraffic === 'blue' ? 'green' : 'blue';
|
|
832
1036
|
UnderpostDeploy.API.switchTraffic(deployId, inputEnv, targetTraffic, inputReplicas);
|
|
833
1037
|
}
|
|
834
1038
|
} else {
|
|
835
|
-
const currentTraffic = UnderpostDeploy.API.getCurrentTraffic(inputDeployId);
|
|
1039
|
+
const currentTraffic = UnderpostDeploy.API.getCurrentTraffic(inputDeployId, { namespace: options.namespace });
|
|
836
1040
|
const targetTraffic = currentTraffic === 'blue' ? 'green' : 'blue';
|
|
837
1041
|
UnderpostDeploy.API.switchTraffic(inputDeployId, inputEnv, targetTraffic, inputReplicas);
|
|
838
1042
|
}
|
|
@@ -919,7 +1123,7 @@ class UnderpostRun {
|
|
|
919
1123
|
const deployId = path;
|
|
920
1124
|
const { validVersion } = UnderpostRepository.API.privateConfUpdate(deployId);
|
|
921
1125
|
if (!validVersion) throw new Error('Version mismatch');
|
|
922
|
-
const currentTraffic = UnderpostDeploy.API.getCurrentTraffic(deployId);
|
|
1126
|
+
const currentTraffic = UnderpostDeploy.API.getCurrentTraffic(deployId, { namespace: options.namespace });
|
|
923
1127
|
const targetTraffic = currentTraffic === 'blue' ? 'green' : 'blue';
|
|
924
1128
|
const env = 'production';
|
|
925
1129
|
const ignorePods = UnderpostDeploy.API.get(`${deployId}-${env}-${targetTraffic}`).map((p) => p.NAME);
|
|
@@ -970,7 +1174,7 @@ class UnderpostRun {
|
|
|
970
1174
|
envObj.DEV_PROXY_PORT_OFFSET = options.devProxyPortOffset;
|
|
971
1175
|
writeEnv(envPath, envObj);
|
|
972
1176
|
}
|
|
973
|
-
shellExec(`node bin run dev-cluster expose`, { async: true });
|
|
1177
|
+
shellExec(`node bin run dev-cluster --expose`, { async: true });
|
|
974
1178
|
{
|
|
975
1179
|
const cmd = `npm run dev-api ${deployId} ${subConf} ${host} ${_path} ${clientHostPort}${options.tls ? ' tls' : ''}`;
|
|
976
1180
|
options.terminal ? openTerminal(cmd) : shellExec(cmd, { async: true });
|
|
@@ -1061,7 +1265,7 @@ class UnderpostRun {
|
|
|
1061
1265
|
}
|
|
1062
1266
|
const success = await UnderpostTest.API.statusMonitor(podToMonitor);
|
|
1063
1267
|
if (success) {
|
|
1064
|
-
const versions = UnderpostDeploy.API.getCurrentTraffic(deployId) || 'blue';
|
|
1268
|
+
const versions = UnderpostDeploy.API.getCurrentTraffic(deployId, { namespace: options.namespace }) || 'blue';
|
|
1065
1269
|
if (!node) node = os.hostname();
|
|
1066
1270
|
shellExec(
|
|
1067
1271
|
`${baseCommand} deploy${options.dev ? '' : ' --kubeadm'}${options.devProxyPortOffset ? ' --disable-deployment-proxy' : ''} --build-manifest --sync --info-router --replicas ${
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static site generation module
|
|
3
|
+
* @module src/cli/static.js
|
|
4
|
+
* @namespace UnderpostStatic
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import fs from 'fs-extra';
|
|
8
|
+
import { ssrFactory } from '../server/ssr.js';
|
|
9
|
+
import { shellExec } from '../server/process.js';
|
|
10
|
+
import Underpost from '../index.js';
|
|
11
|
+
import { JSONweb } from '../server/client-formatted.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @class UnderpostStatic
|
|
15
|
+
* @description Static site generation class
|
|
16
|
+
* @memberof UnderpostStatic
|
|
17
|
+
*/
|
|
18
|
+
class UnderpostStatic {
|
|
19
|
+
static API = {
|
|
20
|
+
/**
|
|
21
|
+
* Generate static HTML file
|
|
22
|
+
* @param {Object} options - Options for static generation
|
|
23
|
+
* @param {string} options.page - Page identifier
|
|
24
|
+
* @param {string} options.title - Page title
|
|
25
|
+
* @param {string} options.outputPath - Output file path
|
|
26
|
+
* @param {string} options.deployId - Deployment identifier
|
|
27
|
+
* @param {string} options.buildHost - Build host
|
|
28
|
+
* @param {string} options.buildPath - Build path
|
|
29
|
+
* @param {string} options.env - Environment (development/production)
|
|
30
|
+
* @param {boolean} options.build - Whether to trigger build
|
|
31
|
+
* @param {boolean} options.dev - Development mode flag
|
|
32
|
+
* @memberof UnderpostStatic
|
|
33
|
+
* @returns {Promise<void>}
|
|
34
|
+
*/
|
|
35
|
+
async callback(
|
|
36
|
+
options = {
|
|
37
|
+
page: '',
|
|
38
|
+
title: '',
|
|
39
|
+
outputPath: '',
|
|
40
|
+
deployId: '',
|
|
41
|
+
buildHost: '',
|
|
42
|
+
buildPath: '',
|
|
43
|
+
env: '',
|
|
44
|
+
build: false,
|
|
45
|
+
dev: false,
|
|
46
|
+
},
|
|
47
|
+
) {
|
|
48
|
+
if (!options.outputPath) options.outputPath = '.';
|
|
49
|
+
if (!options.buildPath) options.buildPath = '/';
|
|
50
|
+
if (!options.env) options.env = 'production';
|
|
51
|
+
|
|
52
|
+
if (options.page) {
|
|
53
|
+
const Render = await ssrFactory();
|
|
54
|
+
const SsrComponent = await ssrFactory(options.page);
|
|
55
|
+
const htmlSrc = Render({
|
|
56
|
+
title: options.title || 'Home',
|
|
57
|
+
ssrPath: '/',
|
|
58
|
+
ssrHeadComponents: '',
|
|
59
|
+
ssrBodyComponents: SsrComponent(),
|
|
60
|
+
// buildId: options.deployId || 'local',
|
|
61
|
+
renderPayload: {
|
|
62
|
+
// apiBaseProxyPath,
|
|
63
|
+
// apiBaseHost,
|
|
64
|
+
// apiBasePath: process.env.BASE_API,
|
|
65
|
+
version: Underpost.version,
|
|
66
|
+
...(options.env === 'development' ? { dev: true } : undefined),
|
|
67
|
+
},
|
|
68
|
+
renderApi: {
|
|
69
|
+
JSONweb,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
fs.writeFileSync(options.outputPath, htmlSrc, 'utf8');
|
|
73
|
+
}
|
|
74
|
+
if (options.deployId && options.build) {
|
|
75
|
+
shellExec(`underpost env ${options.deployId} ${options.env}`);
|
|
76
|
+
shellExec(
|
|
77
|
+
`npm run build ${options.deployId}${options.buildHost ? ` ${options.buildHost} ${options.buildPath}` : ``}`,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default UnderpostStatic;
|
|
@@ -25,9 +25,7 @@ const eventDateFactory = (event) =>
|
|
|
25
25
|
const CalendarCore = {
|
|
26
26
|
RenderStyle: async function () {},
|
|
27
27
|
Data: {},
|
|
28
|
-
Render: async function (
|
|
29
|
-
options = { idModal: '', Elements: {}, heightTopBar: 50, heightBottomBar: 50, hiddenDates: [] },
|
|
30
|
-
) {
|
|
28
|
+
Render: async function (options = { idModal: '', Elements: {}, hiddenDates: [] }) {
|
|
31
29
|
this.Data[options.idModal] = {
|
|
32
30
|
data: [],
|
|
33
31
|
originData: [],
|
|
@@ -36,8 +34,6 @@ const CalendarCore = {
|
|
|
36
34
|
hiddenDates: options.hiddenDates ? options.hiddenDates : [],
|
|
37
35
|
};
|
|
38
36
|
|
|
39
|
-
const { heightTopBar, heightBottomBar } = options;
|
|
40
|
-
|
|
41
37
|
const titleIcon = html`<i class="fas fa-calendar-alt"></i>`;
|
|
42
38
|
|
|
43
39
|
const getPanelData = async () => {
|
|
@@ -234,8 +230,6 @@ const CalendarCore = {
|
|
|
234
230
|
idPanel,
|
|
235
231
|
parentIdModal: options.idModal,
|
|
236
232
|
formData,
|
|
237
|
-
heightTopBar,
|
|
238
|
-
heightBottomBar,
|
|
239
233
|
data: this.Data[options.idModal].data,
|
|
240
234
|
formContainerClass: '',
|
|
241
235
|
scrollClassContainer: `main-body-calendar-${options.idModal}`,
|
|
@@ -54,8 +54,8 @@ const Modal = {
|
|
|
54
54
|
disableBoxShadow: false,
|
|
55
55
|
},
|
|
56
56
|
) {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
options.heightBottomBar = 50;
|
|
58
|
+
options.heightTopBar = 50;
|
|
59
59
|
let originHeightBottomBar = options.heightBottomBar ? newInstance(options.heightBottomBar) : 0;
|
|
60
60
|
let originHeightTopBar = options.heightTopBar ? newInstance(options.heightTopBar) : 0;
|
|
61
61
|
let width = 300;
|
|
@@ -38,7 +38,7 @@ const Panel = {
|
|
|
38
38
|
formObj.id = `${idPanel}-${formObj.id}`;
|
|
39
39
|
return formObj;
|
|
40
40
|
});
|
|
41
|
-
const { scrollClassContainer, formData, data
|
|
41
|
+
const { scrollClassContainer, formData, data } = options;
|
|
42
42
|
|
|
43
43
|
const titleObj = formData.find((f) => f.panel && f.panel.type === 'title');
|
|
44
44
|
const titleKey = titleObj ? titleObj.model : '';
|
|
@@ -21,8 +21,6 @@ const PanelForm = {
|
|
|
21
21
|
instance: async function (
|
|
22
22
|
options = {
|
|
23
23
|
idPanel: '',
|
|
24
|
-
heightTopBar: 50,
|
|
25
|
-
heightBottomBar: 50,
|
|
26
24
|
defaultUrlImage: '',
|
|
27
25
|
Elements: {},
|
|
28
26
|
parentIdModal: undefined,
|
|
@@ -31,7 +29,7 @@ const PanelForm = {
|
|
|
31
29
|
firsUpdateEvent: async () => {},
|
|
32
30
|
},
|
|
33
31
|
) {
|
|
34
|
-
const { idPanel,
|
|
32
|
+
const { idPanel, defaultUrlImage, Elements } = options;
|
|
35
33
|
|
|
36
34
|
let prefixTags = [idPanel, 'public'];
|
|
37
35
|
this.Data[idPanel] = {
|
|
@@ -101,8 +99,6 @@ const PanelForm = {
|
|
|
101
99
|
await Panel.Render({
|
|
102
100
|
idPanel,
|
|
103
101
|
formData,
|
|
104
|
-
heightTopBar,
|
|
105
|
-
heightBottomBar,
|
|
106
102
|
data,
|
|
107
103
|
htmlFormHeader: options.htmlFormHeader,
|
|
108
104
|
parentIdModal: options.parentIdModal,
|
|
@@ -40,8 +40,7 @@ const MenuDefault = {
|
|
|
40
40
|
const RouterInstance = RouterDefault();
|
|
41
41
|
|
|
42
42
|
const { barConfig } = await Themes[Css.currentTheme]();
|
|
43
|
-
|
|
44
|
-
const heightBottomBar = 50;
|
|
43
|
+
|
|
45
44
|
const badgeNotificationMenuStyle = { top: '-33px', left: '24px' };
|
|
46
45
|
const barMode = undefined; // 'top-bottom-bar';
|
|
47
46
|
await Modal.Render({
|
|
@@ -221,8 +220,6 @@ const MenuDefault = {
|
|
|
221
220
|
},
|
|
222
221
|
mode: 'slide-menu',
|
|
223
222
|
RouterInstance,
|
|
224
|
-
heightTopBar,
|
|
225
|
-
heightBottomBar,
|
|
226
223
|
htmlMainBody: options.htmlMainBody,
|
|
227
224
|
});
|
|
228
225
|
|
|
@@ -252,7 +249,7 @@ const MenuDefault = {
|
|
|
252
249
|
`.style-lading-render`,
|
|
253
250
|
html` <style>
|
|
254
251
|
.landing-container {
|
|
255
|
-
min-height: calc(100vh -
|
|
252
|
+
min-height: calc(100vh - 100px);
|
|
256
253
|
display: flex;
|
|
257
254
|
/* align-items: center; */
|
|
258
255
|
justify-content: center;
|
|
@@ -306,7 +303,9 @@ const MenuDefault = {
|
|
|
306
303
|
padding: 2rem;
|
|
307
304
|
border-radius: 12px;
|
|
308
305
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
|
|
309
|
-
transition:
|
|
306
|
+
transition:
|
|
307
|
+
transform 0.3s ease,
|
|
308
|
+
box-shadow 0.3s ease;
|
|
310
309
|
opacity: 0;
|
|
311
310
|
animation: fadeInUp 0.6s ease-out forwards;
|
|
312
311
|
}
|
|
@@ -494,8 +493,6 @@ const MenuDefault = {
|
|
|
494
493
|
mode: 'view',
|
|
495
494
|
slideMenu: 'modal-menu',
|
|
496
495
|
RouterInstance,
|
|
497
|
-
heightTopBar,
|
|
498
|
-
heightBottomBar,
|
|
499
496
|
});
|
|
500
497
|
});
|
|
501
498
|
|
|
@@ -515,8 +512,6 @@ const MenuDefault = {
|
|
|
515
512
|
mode: 'view',
|
|
516
513
|
slideMenu: 'modal-menu',
|
|
517
514
|
RouterInstance,
|
|
518
|
-
heightTopBar,
|
|
519
|
-
heightBottomBar,
|
|
520
515
|
});
|
|
521
516
|
});
|
|
522
517
|
|
|
@@ -536,8 +531,6 @@ const MenuDefault = {
|
|
|
536
531
|
mode: 'view',
|
|
537
532
|
slideMenu: 'modal-menu',
|
|
538
533
|
RouterInstance,
|
|
539
|
-
heightTopBar,
|
|
540
|
-
heightBottomBar,
|
|
541
534
|
});
|
|
542
535
|
});
|
|
543
536
|
|
|
@@ -562,8 +555,6 @@ const MenuDefault = {
|
|
|
562
555
|
mode: 'view',
|
|
563
556
|
slideMenu: 'modal-menu',
|
|
564
557
|
RouterInstance,
|
|
565
|
-
heightTopBar,
|
|
566
|
-
heightBottomBar,
|
|
567
558
|
});
|
|
568
559
|
});
|
|
569
560
|
|
|
@@ -583,8 +574,6 @@ const MenuDefault = {
|
|
|
583
574
|
mode: 'view',
|
|
584
575
|
slideMenu: 'modal-menu',
|
|
585
576
|
RouterInstance,
|
|
586
|
-
heightTopBar,
|
|
587
|
-
heightBottomBar,
|
|
588
577
|
});
|
|
589
578
|
});
|
|
590
579
|
|
|
@@ -605,8 +594,6 @@ const MenuDefault = {
|
|
|
605
594
|
mode: 'view',
|
|
606
595
|
slideMenu: 'modal-menu',
|
|
607
596
|
RouterInstance,
|
|
608
|
-
heightTopBar,
|
|
609
|
-
heightBottomBar,
|
|
610
597
|
});
|
|
611
598
|
});
|
|
612
599
|
|
|
@@ -626,8 +613,6 @@ const MenuDefault = {
|
|
|
626
613
|
mode: 'view',
|
|
627
614
|
slideMenu: 'modal-menu',
|
|
628
615
|
RouterInstance,
|
|
629
|
-
heightTopBar,
|
|
630
|
-
heightBottomBar,
|
|
631
616
|
observer: true,
|
|
632
617
|
});
|
|
633
618
|
});
|
|
@@ -648,8 +633,6 @@ const MenuDefault = {
|
|
|
648
633
|
mode: 'view',
|
|
649
634
|
slideMenu: 'modal-menu',
|
|
650
635
|
RouterInstance,
|
|
651
|
-
heightTopBar,
|
|
652
|
-
heightBottomBar,
|
|
653
636
|
observer: true,
|
|
654
637
|
});
|
|
655
638
|
});
|
|
@@ -670,8 +653,6 @@ const MenuDefault = {
|
|
|
670
653
|
mode: 'view',
|
|
671
654
|
slideMenu: 'modal-menu',
|
|
672
655
|
RouterInstance,
|
|
673
|
-
heightTopBar,
|
|
674
|
-
heightBottomBar,
|
|
675
656
|
observer: true,
|
|
676
657
|
});
|
|
677
658
|
});
|
|
@@ -694,8 +675,6 @@ const MenuDefault = {
|
|
|
694
675
|
setTimeout(async () => {
|
|
695
676
|
await PanelForm.instance({
|
|
696
677
|
idPanel: 'default-blog',
|
|
697
|
-
heightTopBar,
|
|
698
|
-
heightBottomBar,
|
|
699
678
|
defaultUrlImage: `${getProxyPath()}android-chrome-96x96.png`,
|
|
700
679
|
Elements: ElementsDefault,
|
|
701
680
|
parentIdModal: idModal,
|
|
@@ -709,8 +688,6 @@ const MenuDefault = {
|
|
|
709
688
|
mode: 'view',
|
|
710
689
|
slideMenu: 'modal-menu',
|
|
711
690
|
RouterInstance,
|
|
712
|
-
heightTopBar,
|
|
713
|
-
heightBottomBar,
|
|
714
691
|
barMode,
|
|
715
692
|
});
|
|
716
693
|
});
|
|
@@ -732,8 +709,6 @@ const MenuDefault = {
|
|
|
732
709
|
mode: 'view',
|
|
733
710
|
slideMenu: 'modal-menu',
|
|
734
711
|
RouterInstance,
|
|
735
|
-
heightTopBar,
|
|
736
|
-
heightBottomBar,
|
|
737
712
|
barMode,
|
|
738
713
|
});
|
|
739
714
|
});
|
package/src/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import UnderpostRun from './cli/run.js';
|
|
|
20
20
|
import UnderpostScript from './cli/script.js';
|
|
21
21
|
import UnderpostSecret from './cli/secrets.js';
|
|
22
22
|
import UnderpostSSH from './cli/ssh.js';
|
|
23
|
+
import UnderpostStatic from './cli/static.js';
|
|
23
24
|
import UnderpostTest from './cli/test.js';
|
|
24
25
|
import UnderpostStartUp from './server/start.js';
|
|
25
26
|
|
|
@@ -35,7 +36,7 @@ class Underpost {
|
|
|
35
36
|
* @type {String}
|
|
36
37
|
* @memberof Underpost
|
|
37
38
|
*/
|
|
38
|
-
static version = 'v2.
|
|
39
|
+
static version = 'v2.90.1';
|
|
39
40
|
/**
|
|
40
41
|
* Repository cli API
|
|
41
42
|
* @static
|
|
@@ -64,6 +65,14 @@ class Underpost {
|
|
|
64
65
|
* @memberof Underpost
|
|
65
66
|
*/
|
|
66
67
|
static start = UnderpostStartUp.API;
|
|
68
|
+
/**
|
|
69
|
+
* Static cli API
|
|
70
|
+
* @static
|
|
71
|
+
* @type {UnderpostStatic.API}
|
|
72
|
+
* @memberof Underpost
|
|
73
|
+
*/
|
|
74
|
+
static static = UnderpostStatic.API;
|
|
75
|
+
|
|
67
76
|
/**
|
|
68
77
|
* Cluster cli API
|
|
69
78
|
* @static
|