underpost 2.8.861 → 2.8.867

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.
@@ -51,6 +51,7 @@ const Modal = {
51
51
  RouterInstance: {},
52
52
  disableTools: [],
53
53
  observer: false,
54
+ disableBoxShadow: false,
54
55
  },
55
56
  ) {
56
57
  if (options.heightBottomBar === undefined) options.heightBottomBar = 50;
@@ -89,6 +90,11 @@ const Modal = {
89
90
  onHome: {},
90
91
  homeModals: options.homeModals ? options.homeModals : [],
91
92
  query: options.query ? `${window.location.search}` : undefined,
93
+ getTop: () => window.innerHeight - (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar),
94
+ getHeight: () =>
95
+ window.innerHeight -
96
+ (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
97
+ (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar),
92
98
  };
93
99
 
94
100
  if (idModal !== 'main-body' && options.mode !== 'view') {
@@ -117,12 +123,7 @@ const Modal = {
117
123
 
118
124
  Responsive.Event[`view-${idModal}`] = () => {
119
125
  if (!this.Data[idModal]) return delete Responsive.Event[`view-${idModal}`];
120
- if (this.Data[idModal].slideMenu)
121
- s(`.${idModal}`).style.height = `${
122
- window.innerHeight -
123
- (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
124
- (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
125
- }px`;
126
+ if (this.Data[idModal].slideMenu) s(`.${idModal}`).style.height = `${this.Data[idModal].getHeight()}px`;
126
127
  };
127
128
  Responsive.Event[`view-${idModal}`]();
128
129
 
@@ -207,11 +208,7 @@ const Modal = {
207
208
  const { barConfig } = options;
208
209
  options.style = {
209
210
  position: 'absolute',
210
- height: `${
211
- window.innerHeight -
212
- (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
213
- (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
214
- }px`,
211
+ height: `${Modal.Data[idModal].getHeight()}px`,
215
212
  width: `${slideMenuWidth}px`,
216
213
  // 'overflow-x': 'hidden',
217
214
  // overflow: 'visible', // required for tooltip
@@ -239,11 +236,7 @@ const Modal = {
239
236
  if (this.Data[_idModal].slideMenu && this.Data[_idModal].slideMenu.id === idModal)
240
237
  this.Data[_idModal].slideMenu.callBack();
241
238
  }
242
- s(`.${idModal}`).style.height = `${
243
- window.innerHeight -
244
- (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
245
- (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
246
- }px`;
239
+ s(`.${idModal}`).style.height = `${Modal.Data[idModal].getHeight()}px`;
247
240
  if (s(`.main-body-top`)) {
248
241
  if (Modal.mobileModal()) {
249
242
  if (s(`.btn-menu-${idModal}`).classList.contains('hide') && collapseSlideMenuWidth !== slideMenuWidth)
@@ -753,9 +746,12 @@ const Modal = {
753
746
  s(`.main-btn-${results[currentKeyBoardSearchBoxIndex].routerId}`).click();
754
747
  Modal.removeModal(searchBoxHistoryId);
755
748
  };
756
-
749
+ let boxHistoryDelayRender = 0;
757
750
  const searchBoxHistoryOpen = async () => {
758
- if (!s(`.${id}`)) {
751
+ if (boxHistoryDelayRender) return;
752
+ boxHistoryDelayRender = 1000;
753
+ setTimeout(() => (boxHistoryDelayRender = 0));
754
+ if (!s(`.${searchBoxHistoryId}`)) {
759
755
  const { barConfig } = await Themes[Css.currentTheme]();
760
756
  barConfig.buttons.maximize.disabled = true;
761
757
  barConfig.buttons.minimize.disabled = true;
@@ -763,7 +759,7 @@ const Modal = {
763
759
  barConfig.buttons.menu.disabled = true;
764
760
  barConfig.buttons.close.disabled = false;
765
761
  await Modal.Render({
766
- id,
762
+ id: searchBoxHistoryId,
767
763
  barConfig,
768
764
  title: html`<div class="search-box-recent-title">
769
765
  ${renderViewTitle({
@@ -964,6 +960,7 @@ const Modal = {
964
960
  heightBottomBar: originHeightBottomBar,
965
961
  barMode: options.barMode,
966
962
  observer: true,
963
+ disableBoxShadow: true,
967
964
  });
968
965
  const maxWidthInputSearchBox = 450;
969
966
  const paddingInputSearchBox = 5;
@@ -985,12 +982,7 @@ const Modal = {
985
982
  s(`.top-bar-search-box`).style.top = `${
986
983
  (originHeightTopBar - s(`.top-bar-search-box`).clientHeight) / 2
987
984
  }px`;
988
- if (this.Data[id].slideMenu)
989
- s(`.${id}`).style.height = `${
990
- window.innerHeight -
991
- (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
992
- (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
993
- }px`;
985
+ if (this.Data[id].slideMenu) s(`.${id}`).style.height = `${Modal.Data[id].getHeight()}px`;
994
986
  };
995
987
  Responsive.Event[`view-${id}`]();
996
988
  Keyboard.instanceMultiPressKey({
@@ -1119,9 +1111,7 @@ const Modal = {
1119
1111
  if (!this.Data[id] || !s(`.${id}`)) return delete Responsive.Event[`view-${id}`];
1120
1112
  // <div class="in fll right-offset-menu-bottom-bar" style="height: 100%"></div>
1121
1113
  // s(`.right-offset-menu-bottom-bar`).style.width = `${window.innerWidth - slideMenuWidth}px`;
1122
- s(`.${id}`).style.top = `${
1123
- window.innerHeight - (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
1124
- }px`;
1114
+ s(`.${id}`).style.top = `${Modal.Data[id].getTop()}px`;
1125
1115
  };
1126
1116
  Responsive.Event[`view-${id}`]();
1127
1117
  }
@@ -1293,11 +1283,7 @@ const Modal = {
1293
1283
  s(`.main-body-btn-ui-close`).classList.contains('hide') &&
1294
1284
  s(`.btn-restore-${id}`).style.display !== 'none'
1295
1285
  ? `${window.innerHeight}px`
1296
- : `${
1297
- window.innerHeight -
1298
- (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
1299
- (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
1300
- }px`;
1286
+ : `${Modal.Data[id].getHeight()}px`;
1301
1287
 
1302
1288
  if (
1303
1289
  s(`.main-body-btn-ui-close`).classList.contains('hide') &&
@@ -1405,7 +1391,11 @@ const Modal = {
1405
1391
  }
1406
1392
  </style>
1407
1393
  ${renderStyleTag(`style-${idModal}`, `.${idModal}`, options)}
1408
- <div class="fix ${options && options.class ? options.class : ''} modal box-shadow ${idModal}">
1394
+ <div
1395
+ class="fix ${options && options.class ? options.class : ''} modal ${options.disableBoxShadow
1396
+ ? ''
1397
+ : 'box-shadow'} ${idModal}"
1398
+ >
1409
1399
  <div class="abs modal-handle-${idModal}"></div>
1410
1400
  <div class="in modal-html-${idModal}">
1411
1401
  <div class="stq bar-default-modal bar-default-modal-${idModal}">
@@ -1918,11 +1908,7 @@ const Modal = {
1918
1908
  if (s(`.btn-restore-${idModal}`) && s(`.btn-restore-${idModal}`).style.display !== 'none') {
1919
1909
  s(`.${idModal}`).style.height = s(`.main-body-btn-ui-close`).classList.contains('hide')
1920
1910
  ? `${window.innerHeight}px`
1921
- : `${
1922
- window.innerHeight -
1923
- (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
1924
- (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
1925
- }px`;
1911
+ : `${Modal.Data[idModal].getHeight()}px`;
1926
1912
  }
1927
1913
  s(`.${idModal}`).style.top = s(`.main-body-btn-ui-close`).classList.contains('hide')
1928
1914
  ? `0px`
package/src/index.js CHANGED
@@ -35,7 +35,7 @@ class Underpost {
35
35
  * @type {String}
36
36
  * @memberof Underpost
37
37
  */
38
- static version = 'v2.8.861';
38
+ static version = 'v2.8.867';
39
39
  /**
40
40
  * Repository cli API
41
41
  * @static
@@ -535,13 +535,7 @@ Sitemap: https://${host}${path === '/' ? '' : path}/sitemap.xml`,
535
535
  );
536
536
  }
537
537
 
538
- if (
539
- fullBuildEnabled &&
540
- !enableLiveRebuild &&
541
- !process.argv.includes('l') &&
542
- !process.argv.includes('deploy') &&
543
- docsBuild
544
- ) {
538
+ if (fullBuildEnabled && !enableLiveRebuild && !process.argv.includes('l') && docsBuild) {
545
539
  await buildDocs({
546
540
  host,
547
541
  path,
@@ -27,67 +27,84 @@ dotenv.config();
27
27
 
28
28
  const logger = loggerFactory(import.meta);
29
29
 
30
- // monitoring: https://app.pm2.io/
31
-
32
30
  const Config = {
33
31
  default: DefaultConf,
34
- build: async function (options = { folder: '' }, deployContext, deployList, subConf) {
35
- if (!deployContext) deployContext = process.argv[2];
32
+ build: async function (deployContext = 'dd-default', deployList, subConf) {
33
+ if (typeof process.argv[2] === 'string' && process.argv[2].startsWith('dd-')) deployContext = process.argv[2];
36
34
  if (!fs.existsSync(`./tmp`)) fs.mkdirSync(`./tmp`, { recursive: true });
37
35
  fs.writeFileSync(`./tmp/await-deploy`, '', 'utf8');
38
36
  if (fs.existsSync(`./engine-private/replica/${deployContext}`))
39
37
  return loadConf(deployContext, process.env.NODE_ENV, subConf);
40
38
  else if (deployContext.startsWith('dd-')) return loadConf(deployContext, process.env.NODE_ENV, subConf);
39
+ if (deployContext === 'proxy') Config.buildProxy(deployContext, deployList, subConf);
40
+ },
41
+ deployIdFactory: function (deployId = 'dd-default') {
42
+ if (!deployId.startsWith('dd-')) deployId = `dd-${deployId}`;
41
43
 
42
- if (deployContext === 'deploy') return;
43
-
44
- if (deployContext === 'proxy') {
45
- if (!deployList) deployList = process.argv[3];
46
- if (!subConf) subConf = process.argv[4];
47
- this.default.server = {};
48
- for (const deployId of deployList.split(',')) {
49
- let confPath = `./engine-private/conf/${deployId}/conf.server.json`;
50
- const privateConfDevPath = fs.existsSync(`./engine-private/replica/${deployId}/conf.server.json`)
51
- ? `./engine-private/replica/${deployId}/conf.server.json`
52
- : `./engine-private/conf/${deployId}/conf.server.dev.${subConf}.json`;
53
- const confDevPath = fs.existsSync(privateConfDevPath)
54
- ? privateConfDevPath
55
- : `./engine-private/conf/${deployId}/conf.server.dev.json`;
56
-
57
- if (process.env.NODE_ENV === 'development' && fs.existsSync(confDevPath)) confPath = confDevPath;
58
- const serverConf = JSON.parse(fs.readFileSync(confPath, 'utf8'));
59
-
60
- for (const host of Object.keys(loadReplicas(serverConf, deployContext, subConf))) {
61
- if (serverConf[host]['/'])
62
- this.default.server[host] = {
63
- ...this.default.server[host],
64
- ...serverConf[host],
65
- };
66
- else
67
- this.default.server[host] = {
68
- ...serverConf[host],
69
- ...this.default.server[host],
70
- };
71
- }
44
+ logger.info('Build deployId', deployId);
45
+
46
+ const folder = `./engine-private/conf/${deployId}`;
47
+
48
+ if (!fs.existsSync(folder)) fs.mkdirSync(folder, { recursive: true });
49
+ fs.writeFileSync(
50
+ `${folder}/.env.production`,
51
+ fs.readFileSync('./.env.production', 'utf8').replaceAll('dd-default', deployId),
52
+ 'utf8',
53
+ );
54
+ fs.writeFileSync(
55
+ `${folder}/.env.development`,
56
+ fs.readFileSync('./.env.development', 'utf8').replaceAll('dd-default', deployId),
57
+ 'utf8',
58
+ );
59
+ fs.writeFileSync(
60
+ `${folder}/.env.test`,
61
+ fs.readFileSync('./.env.test', 'utf8').replaceAll('dd-default', deployId),
62
+ 'utf8',
63
+ );
64
+ fs.writeFileSync(`${folder}/package.json`, fs.readFileSync('./package.json', 'utf8'), 'utf8');
65
+
66
+ this.buildTmpConf(folder);
67
+
68
+ return { deployIdFolder: folder, deployId };
69
+ },
70
+ buildTmpConf: function (folder = './conf') {
71
+ for (const confType of Object.keys(this.default))
72
+ fs.writeFileSync(`${folder}/conf.${confType}.json`, JSON.stringify(this.default[confType], null, 4), 'utf8');
73
+ },
74
+ buildProxy: function (deployContext = 'dd-default', deployList, subConf) {
75
+ if (!deployList) deployList = process.argv[3];
76
+ if (!subConf) subConf = process.argv[4];
77
+ this.default.server = {};
78
+ for (const deployId of deployList.split(',')) {
79
+ let confPath = `./engine-private/conf/${deployId}/conf.server.json`;
80
+ const privateConfDevPath = fs.existsSync(`./engine-private/replica/${deployId}/conf.server.json`)
81
+ ? `./engine-private/replica/${deployId}/conf.server.json`
82
+ : `./engine-private/conf/${deployId}/conf.server.dev.${subConf}.json`;
83
+ const confDevPath = fs.existsSync(privateConfDevPath)
84
+ ? privateConfDevPath
85
+ : `./engine-private/conf/${deployId}/conf.server.dev.json`;
86
+
87
+ if (process.env.NODE_ENV === 'development' && fs.existsSync(confDevPath)) confPath = confDevPath;
88
+ const serverConf = JSON.parse(fs.readFileSync(confPath, 'utf8'));
89
+
90
+ for (const host of Object.keys(loadReplicas(serverConf, deployContext, subConf))) {
91
+ if (serverConf[host]['/'])
92
+ this.default.server[host] = {
93
+ ...this.default.server[host],
94
+ ...serverConf[host],
95
+ };
96
+ else
97
+ this.default.server[host] = {
98
+ ...serverConf[host],
99
+ ...this.default.server[host],
100
+ };
72
101
  }
73
102
  }
74
- if (!options || !options.folder)
75
- options = {
76
- ...options,
77
- folder: `./conf`,
78
- };
79
- if (!fs.existsSync(options.folder)) fs.mkdirSync(options.folder, { recursive: true });
80
- for (const confType of Object.keys(this.default)) {
81
- fs.writeFileSync(
82
- `${options.folder}/conf.${confType}.json`,
83
- JSON.stringify(this.default[confType], null, 4),
84
- 'utf8',
85
- );
86
- }
103
+ this.buildTmpConf();
87
104
  },
88
105
  };
89
106
 
90
- const loadConf = (deployId, envInput, subConf) => {
107
+ const loadConf = (deployId = 'dd-default', envInput, subConf) => {
91
108
  if (deployId === 'current') {
92
109
  console.log(process.env.DEPLOY_ID);
93
110
  return;
@@ -103,22 +120,15 @@ const loadConf = (deployId, envInput, subConf) => {
103
120
  shellExec(`git checkout ${path}/package-lock.json`);
104
121
  return;
105
122
  }
106
- if (!deployId.startsWith('dd-')) deployId = 'dd-default';
107
123
  const folder = fs.existsSync(`./engine-private/replica/${deployId}`)
108
124
  ? `./engine-private/replica/${deployId}`
109
125
  : `./engine-private/conf/${deployId}`;
126
+ if (!fs.existsSync(folder)) Config.deployIdFactory(deployId);
110
127
  if (!fs.existsSync(`./conf`)) fs.mkdirSync(`./conf`);
111
- if (!fs.existsSync(`./tmp`)) fs.mkdirSync(`./tmp`, { recursive: true });
112
- const isValidDeployId = fs.existsSync(`${folder}`);
113
- if (!isValidDeployId) {
114
- logger.info(`Save new deploy conf: '${deployId}'`);
115
- shellExec(`node bin/deploy save ${deployId}`);
116
- return loadConf(deployId);
117
- }
128
+ if (!fs.existsSync(`./tmp`)) fs.mkdirSync(`./tmp`);
129
+
118
130
  for (const typeConf of Object.keys(Config.default)) {
119
- let srcConf = isValidDeployId
120
- ? fs.readFileSync(`${folder}/conf.${typeConf}.json`, 'utf8')
121
- : JSON.stringify(Config.default[typeConf]);
131
+ let srcConf = fs.readFileSync(`${folder}/conf.${typeConf}.json`, 'utf8');
122
132
  if (process.env.NODE_ENV === 'development' && typeConf === 'server') {
123
133
  if (!subConf) subConf = process.argv[3];
124
134
  const devConfPath = `${folder}/conf.${typeConf}.dev${subConf ? `.${subConf}` : ''}.json`;
@@ -493,15 +503,6 @@ const buildProxyRouter = () => {
493
503
  }
494
504
  }
495
505
  }
496
- if (process.argv.includes('maintenance'))
497
- (async () => {
498
- globalThis.defaultHtmlSrcMaintenance = (await ssrFactory())({
499
- title: 'Site in maintenance',
500
- ssrPath: '/',
501
- ssrHeadComponents: '',
502
- ssrBodyComponents: (await ssrFactory(`./src/client/ssr/offline/Maintenance.js`))(),
503
- });
504
- })();
505
506
 
506
507
  return proxyRouter;
507
508
  };
@@ -561,16 +562,24 @@ const buildPortProxyRouter = (port, proxyRouter) => {
561
562
  // build router
562
563
  Object.keys(hosts).map((hostKey) => {
563
564
  let { host, path, target, proxy, peer } = hosts[hostKey];
564
- if (process.argv.includes('localhost') && process.env.NODE_ENV === 'development') host = `localhost`;
565
+ if (process.env.NODE_ENV === 'development') host = `localhost`;
566
+
567
+ if (!proxy.includes(port)) {
568
+ logger.warn('Proxy port not set on conf', { port, host, path, proxy, target });
569
+ if (process.env.NODE_ENV === 'production') {
570
+ logger.warn('Omitting host', { host, path, target });
571
+ return;
572
+ }
573
+ }
565
574
 
566
- if (!proxy.includes(port)) return;
567
575
  const absoluteHost = [80, 443].includes(port)
568
576
  ? `${host}${path === '/' ? '' : path}`
569
577
  : `${host}:${port}${path === '/' ? '' : path}`;
570
578
 
571
- if (process.argv.includes('localhost')) {
572
- if (!(absoluteHost in router)) router[absoluteHost] = target;
573
- } else router[absoluteHost] = target;
579
+ if (absoluteHost in router)
580
+ logger.warn('Overwrite: Absolute host already exists on router', { absoluteHost, target });
581
+
582
+ router[absoluteHost] = target;
574
583
  }); // order router
575
584
 
576
585
  if (Object.keys(router).length === 0) return router;
@@ -635,7 +644,6 @@ const getDataDeploy = (
635
644
  deployGroupId: '',
636
645
  deployId: '',
637
646
  disableSyncEnvPort: false,
638
- deployIdConcat: [],
639
647
  },
640
648
  ) => {
641
649
  let dataDeploy =
@@ -648,8 +656,6 @@ const getDataDeploy = (
648
656
  .map((deployId) => deployId.trim())
649
657
  .filter((deployId) => deployId);
650
658
 
651
- if (options.deployIdConcat) dataDeploy = dataDeploy.concat(options.deployIdConcat);
652
-
653
659
  if (options.deployId) dataDeploy = dataDeploy.filter((d) => d === options.deployId);
654
660
 
655
661
  dataDeploy = dataDeploy.map((deployId) => {
@@ -776,12 +782,6 @@ const awaitDeployMonitor = async (init = false, deltaMs = 1000) => {
776
782
  if (fs.existsSync(`./tmp/await-deploy`)) return await awaitDeployMonitor();
777
783
  };
778
784
 
779
- const getDeployId = () => {
780
- const deployIndexArg = process.argv.findIndex((a) => a.match(`deploy-id:`));
781
- if (deployIndexArg > -1) return process.argv[deployIndexArg].split(':')[1].trim();
782
- return 'dd-default';
783
- };
784
-
785
785
  const getCronBackUpFolder = (host = '', path = '') => {
786
786
  return `${host}${path.replace(/\\/g, '/').replace(`/`, '-')}`;
787
787
  };
@@ -998,7 +998,6 @@ export {
998
998
  buildReplicaId,
999
999
  getCronBackUpFolder,
1000
1000
  mergeFile,
1001
- getDeployId,
1002
1001
  getPathsSSR,
1003
1002
  buildKindPorts,
1004
1003
  buildPortProxyRouter,
@@ -55,7 +55,7 @@ const buildProxy = async () => {
55
55
  // '^/target-path': '/',
56
56
  },
57
57
  };
58
- if (!process.argv.includes('maintenance')) options.router = buildPortProxyRouter(port, proxyRouter);
58
+ options.router = buildPortProxyRouter(port, proxyRouter);
59
59
 
60
60
  const filter = false
61
61
  ? (pathname, req) => {
@@ -18,7 +18,6 @@ import { DataBaseProvider } from '../db/DataBaseProvider.js';
18
18
  // import { createProxyMiddleware } from 'http-proxy-middleware';
19
19
  import { createPeerServer } from './peer.js';
20
20
  import { Lampp } from '../runtime/lampp/Lampp.js';
21
- import { getDeployId } from './conf.js';
22
21
  import { JSONweb, ssrFactory } from './client-formatted.js';
23
22
  import Underpost from '../index.js';
24
23
  import { createValkeyConnection } from './valkey.js';
@@ -28,7 +27,7 @@ dotenv.config();
28
27
  const logger = loggerFactory(import.meta);
29
28
 
30
29
  const buildRuntime = async () => {
31
- const deployId = getDeployId();
30
+ const deployId = process.env.DEPLOY_ID;
32
31
 
33
32
  const collectDefaultMetrics = promClient.collectDefaultMetrics;
34
33
  collectDefaultMetrics();
@@ -107,12 +107,12 @@ class UnderpostStartUp {
107
107
  for (const replica of replicas) {
108
108
  if (!replica.match(deployId)) continue;
109
109
  shellExec(`node bin/deploy conf ${replica} ${env}`);
110
- shellExec(`npm ${runCmd} deploy deploy-id:${replica}`, { async: true });
110
+ shellExec(`npm ${runCmd} ${replica}`, { async: true });
111
111
  await awaitDeployMonitor(true);
112
112
  }
113
113
  }
114
114
  shellExec(`node bin/deploy conf ${deployId} ${env}`);
115
- shellExec(`npm ${runCmd} deploy deploy-id:${deployId}`, { async: true });
115
+ shellExec(`npm ${runCmd} ${deployId}`, { async: true });
116
116
  await awaitDeployMonitor(true);
117
117
  UnderpostRootEnv.API.set('container-status', `${deployId}-${env}-running-deployment`);
118
118
  },
package/test/api.test.js CHANGED
@@ -21,12 +21,13 @@ const BASE_URL =
21
21
 
22
22
  describe(`GET 'Test' API Request `, async () => {
23
23
  {
24
- const url = `${BASE_URL}/test/youtube-id/?url=https://www.youtube.com/watch?v=o4f42SbyDMk`;
24
+ const youtubeId = '2aib-pmgUdQ';
25
+ const url = `${BASE_URL}/test/youtube-id/?url=https://www.youtube.com/watch?v=${youtubeId}`;
25
26
  it(`youtube id from raw youtube url`, async () => {
26
27
  logger.info('request info', { url });
27
28
  const res = await axios.get(url);
28
29
  logger.info('response', res.data);
29
- return expect(res.data.data).equal('o4f42SbyDMk');
30
+ return expect(res.data.data).equal(youtubeId);
30
31
  });
31
32
  }
32
33
  {
package/bin/cyberia0.js DELETED
@@ -1,78 +0,0 @@
1
- #! /usr/bin/env node
2
-
3
- import dotenv from 'dotenv';
4
- import { Command } from 'commander';
5
- import fs from 'fs-extra';
6
- import { pbcopy, shellExec } from '../src/server/process.js';
7
- import Jimp from 'jimp';
8
- import Underpost from '../src/index.js';
9
- import { loggerFactory } from '../src/server/logger.js';
10
- import { DataBaseProvider } from '../src/db/DataBaseProvider.js';
11
-
12
- dotenv.config();
13
-
14
- const logger = loggerFactory(import.meta);
15
-
16
- const deployId = process.env.DEFAULT_DEPLOY_ID;
17
- const host = process.env.DEFAULT_DEPLOY_HOST;
18
- const path = process.env.DEFAULT_DEPLOY_PATH;
19
-
20
- const confServerPath = `./engine-private/conf/${deployId}/conf.server.json`;
21
- const confServer = JSON.parse(fs.readFileSync(confServerPath, 'utf8'));
22
- const { db } = confServer[host][path];
23
-
24
- logger.info('env', {
25
- deployId,
26
- host,
27
- path,
28
- db,
29
- });
30
-
31
- await DataBaseProvider.load({
32
- apis: ['object-layer'],
33
- host,
34
- path,
35
- db,
36
- });
37
-
38
- const ObjectLayer = DataBaseProvider.instance[`${host}${path}`].mongoose.models.ObjectLayer;
39
-
40
- const program = new Command();
41
-
42
- program.name('cyberia').description(`content generator cli ${Underpost.version}`).version(Underpost.version);
43
-
44
- const pngDirectoryIteratorByObjectLayerType = async (
45
- objectLayerType = 'skin',
46
- callback = ({ path, objectLayerType, objectLayerId, direction, frame }) => {},
47
- ) => {
48
- for (const objectLayerId of await fs.readdir(`./src/client/public/cyberia/assets/${objectLayerType}`)) {
49
- for (const direction of await fs.readdir(
50
- `./src/client/public/cyberia/assets/${objectLayerType}/${objectLayerId}`,
51
- )) {
52
- const dirFolder = `./src/client/public/cyberia/assets/${objectLayerType}/${objectLayerId}/${direction}`;
53
- if (!fs.statSync(dirFolder).isDirectory()) continue;
54
- for (const frame of await fs.readdir(dirFolder)) {
55
- const imageFilePath = `./src/client/public/cyberia/assets/${objectLayerType}/${objectLayerId}/${direction}/${frame}`;
56
- await callback({ path: imageFilePath, objectLayerType, objectLayerId, direction, frame });
57
- }
58
- }
59
- }
60
- };
61
-
62
- program
63
- .command('ol')
64
- .option('--import [object-layer-type]', 'Import object layer from type storage png image')
65
- .action(async (options = { import: false }) => {
66
- if (options.import) {
67
- await pngDirectoryIteratorByObjectLayerType(
68
- options.import,
69
- async ({ path, objectLayerType, objectLayerId, direction, frame }) => {
70
- console.log(path, { objectLayerType, objectLayerId, direction, frame });
71
- },
72
- );
73
- }
74
- await DataBaseProvider.instance[`${host}${path}`].mongoose.close();
75
- })
76
- .description('Object layer management');
77
-
78
- program.parse();