underpost 2.8.86 → 2.8.87

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.
Files changed (42) hide show
  1. package/.env.development +6 -1
  2. package/.env.production +6 -1
  3. package/.env.test +6 -1
  4. package/README.md +22 -2
  5. package/bin/build.js +1 -0
  6. package/bin/deploy.js +32 -20
  7. package/bin/file.js +5 -2
  8. package/bin/util.js +1 -56
  9. package/cli.md +10 -5
  10. package/conf.js +3 -3
  11. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  12. package/manifests/deployment/mongo-express/deployment.yaml +12 -12
  13. package/manifests/maas/nvim.sh +91 -0
  14. package/package.json +3 -11
  15. package/src/api/file/file.service.js +28 -8
  16. package/src/api/user/user.router.js +31 -5
  17. package/src/api/user/user.service.js +3 -4
  18. package/src/cli/cluster.js +4 -23
  19. package/src/cli/db.js +0 -19
  20. package/src/cli/deploy.js +21 -29
  21. package/src/cli/fs.js +1 -0
  22. package/src/cli/index.js +4 -1
  23. package/src/cli/repository.js +4 -2
  24. package/src/cli/run.js +17 -2
  25. package/src/client/components/core/CssCore.js +12 -0
  26. package/src/client/components/core/FullScreen.js +19 -28
  27. package/src/client/components/core/Input.js +1 -0
  28. package/src/client/components/core/Modal.js +25 -39
  29. package/src/client/components/core/ObjectLayerEngine.js +229 -4
  30. package/src/client/components/core/ObjectLayerEngineModal.js +441 -0
  31. package/src/client/components/core/ToggleSwitch.js +15 -1
  32. package/src/client/public/default/assets/mailer/api-user-default-avatar.png +0 -0
  33. package/src/index.js +1 -1
  34. package/src/server/client-build-docs.js +1 -1
  35. package/src/server/client-build.js +4 -12
  36. package/src/server/client-icons.js +6 -78
  37. package/src/server/conf.js +83 -138
  38. package/src/server/proxy.js +1 -1
  39. package/src/server/runtime.js +1 -2
  40. package/src/server/start.js +2 -2
  41. package/test/api.test.js +3 -2
  42. package/bin/cyberia0.js +0 -78
package/.env.development CHANGED
@@ -1,7 +1,12 @@
1
1
  DEPLOY_ID=dd-default
2
+ DEFAULT_DEPLOY_ID=dd-default
2
3
  NODE_ENV=development
3
4
  PORT=4000
4
5
  JWT_SECRET=test
5
6
  EXPIRE=168
6
7
  NODE_OPTIONS=--max-old-space-size=8192
7
- BASE_API=api
8
+ BASE_API=api
9
+ DEFAULT_DEPLOY_HOST=default.net
10
+ DEFAULT_DEPLOY_PATH=/
11
+ DEFAULT_ADMIN_EMAIL=admin@default.net
12
+ DEFAULT_ADMIN_PASSWORD=changethis
package/.env.production CHANGED
@@ -1,7 +1,12 @@
1
1
  DEPLOY_ID=dd-default
2
+ DEFAULT_DEPLOY_ID=dd-default
2
3
  NODE_ENV=production
3
4
  PORT=3000
4
5
  JWT_SECRET=test
5
6
  EXPIRE=168
6
7
  NODE_OPTIONS=--max-old-space-size=8192
7
- BASE_API=api
8
+ BASE_API=api
9
+ DEFAULT_DEPLOY_HOST=default.net
10
+ DEFAULT_DEPLOY_PATH=/
11
+ DEFAULT_ADMIN_EMAIL=admin@default.net
12
+ DEFAULT_ADMIN_PASSWORD=changethis
package/.env.test CHANGED
@@ -1,7 +1,12 @@
1
1
  DEPLOY_ID=dd-default
2
+ DEFAULT_DEPLOY_ID=dd-default
2
3
  NODE_ENV=test
3
4
  PORT=5000
4
5
  JWT_SECRET=test
5
6
  EXPIRE=168
6
7
  NODE_OPTIONS=--max-old-space-size=8192
7
- BASE_API=api
8
+ BASE_API=api
9
+ DEFAULT_DEPLOY_HOST=default.net
10
+ DEFAULT_DEPLOY_PATH=/
11
+ DEFAULT_ADMIN_EMAIL=admin@default.net
12
+ DEFAULT_ADMIN_PASSWORD=changethis
package/README.md CHANGED
@@ -25,11 +25,21 @@
25
25
 
26
26
 
27
27
 
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
28
38
 
29
39
  <!-- badges -->
30
40
 
31
41
 
32
- [![Node.js CI](https://github.com/underpostnet/engine/actions/workflows/docker-image.ci.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [![Test](https://github.com/underpostnet/engine/actions/workflows/coverall.ci.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [![Downloads](https://img.shields.io/npm/dm/underpost.svg)](https://www.npmjs.com/package/underpost) [![Socket Badge](https://socket.dev/api/badge/npm/package/underpost/2.8.86)](https://socket.dev/npm/package/underpost/overview/2.8.86) [![Coverage Status](https://coveralls.io/repos/github/underpostnet/engine/badge.svg?branch=master)](https://coveralls.io/github/underpostnet/engine?branch=master) [![Version](https://img.shields.io/npm/v/underpost.svg)](https://www.npmjs.org/package/underpost) [![License](https://img.shields.io/npm/l/underpost.svg)](https://www.npmjs.com/package/underpost)
42
+ [![Node.js CI](https://github.com/underpostnet/engine/actions/workflows/docker-image.ci.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [![Test](https://github.com/underpostnet/engine/actions/workflows/coverall.ci.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [![Downloads](https://img.shields.io/npm/dm/underpost.svg)](https://www.npmjs.com/package/underpost) [![Socket Badge](https://socket.dev/api/badge/npm/package/underpost/2.8.87)](https://socket.dev/npm/package/underpost/overview/2.8.87) [![Coverage Status](https://coveralls.io/repos/github/underpostnet/engine/badge.svg?branch=master)](https://coveralls.io/github/underpostnet/engine?branch=master) [![Version](https://img.shields.io/npm/v/underpost.svg)](https://www.npmjs.org/package/underpost) [![License](https://img.shields.io/npm/l/underpost.svg)](https://www.npmjs.com/package/underpost)
33
43
 
34
44
 
35
45
  <!-- end-badges -->
@@ -43,6 +53,16 @@
43
53
 
44
54
 
45
55
 
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
46
66
 
47
67
  </div>
48
68
 
@@ -88,7 +108,7 @@ Run dev client server
88
108
  npm run dev
89
109
  ```
90
110
  <!-- -->
91
- ## underpost ci/cd cli v2.8.86
111
+ ## underpost ci/cd cli v2.8.87
92
112
 
93
113
  ### Usage: `underpost [options] [command]`
94
114
  ```
package/bin/build.js CHANGED
@@ -156,6 +156,7 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
156
156
  switch (confName) {
157
157
  case 'dd-cyberia':
158
158
  fs.copyFileSync(`./bin/cyberia.js`, `${basePath}/bin/cyberia.js`);
159
+ fs.copyFileSync(`./bin/cyberia.js`, `${basePath}/bin/cyberia0.js`);
159
160
  break;
160
161
 
161
162
  default:
package/bin/deploy.js CHANGED
@@ -28,6 +28,7 @@ import { DefaultConf } from '../conf.js';
28
28
  import colors from 'colors';
29
29
  import { program } from '../src/cli/index.js';
30
30
  import { getLocalIPv4Address, ip } from '../src/server/dns.js';
31
+ import { timer } from '../src/client/components/core/CommonJs.js';
31
32
 
32
33
  colors.enable();
33
34
 
@@ -39,19 +40,6 @@ const [exe, dir, operator] = process.argv;
39
40
 
40
41
  try {
41
42
  switch (operator) {
42
- case 'save':
43
- {
44
- let deployId = process.argv[3] ?? 'dd-default';
45
- if (!deployId.startsWith('dd-')) deployId = 'dd-default';
46
- const folder = `./engine-private/conf/${deployId}`;
47
- if (fs.existsSync(folder)) fs.removeSync(folder);
48
- await Config.build({ folder });
49
- fs.writeFileSync(`${folder}/.env.production`, fs.readFileSync('./.env.production', 'utf8'), 'utf8');
50
- fs.writeFileSync(`${folder}/.env.development`, fs.readFileSync('./.env.development', 'utf8'), 'utf8');
51
- fs.writeFileSync(`${folder}/.env.test`, fs.readFileSync('./.env.test', 'utf8'), 'utf8');
52
- fs.writeFileSync(`${folder}/package.json`, fs.readFileSync('./package.json', 'utf8'), 'utf8');
53
- }
54
- break;
55
43
  case 'add-nodejs-app-client-conf':
56
44
  {
57
45
  const toOptions = {
@@ -271,23 +259,20 @@ try {
271
259
  for (const deployIdObj of dataDeploy) {
272
260
  const { deployId, replicaHost } = deployIdObj;
273
261
  if (replicaHost && !singleReplicaHosts.includes(replicaHost)) singleReplicaHosts.push(replicaHost);
274
- const proxyInstance = deployId.match('proxy') || deployId.match('cron');
275
262
  const baseConfPath = fs.existsSync(`./engine-private/replica/${deployId}`)
276
263
  ? `./engine-private/replica`
277
264
  : `./engine-private/conf`;
278
265
  for (const envInstanceObj of dataEnv) {
279
266
  const envPath = `${baseConfPath}/${deployId}/.env.${envInstanceObj.env}`;
280
267
  const envObj = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
281
- envObj.PORT = proxyInstance
282
- ? envInstanceObj.port
283
- : envInstanceObj.port + port - singleReplicaHosts.length - (replicaHost ? 1 : 0);
268
+ envObj.PORT = envInstanceObj.port + port - singleReplicaHosts.length - (replicaHost ? 1 : 0);
284
269
 
285
270
  writeEnv(envPath, envObj);
286
271
  }
287
272
  const serverConf = loadReplicas(
288
273
  JSON.parse(fs.readFileSync(`${baseConfPath}/${deployId}/conf.server.json`, 'utf8')),
289
274
  );
290
- if (!proxyInstance) for (const host of Object.keys(serverConf)) port += Object.keys(serverConf[host]).length;
275
+ for (const host of Object.keys(serverConf)) port += Object.keys(serverConf[host]).length;
291
276
  }
292
277
  break;
293
278
 
@@ -383,10 +368,22 @@ try {
383
368
  }
384
369
 
385
370
  case 'version-build': {
371
+ shellExec(`node bin run kill 4001`);
372
+ shellExec(`node bin run kill 4002`);
373
+ shellExec(`node bin run kill 4003`);
374
+ shellExec(`npm run update-template`);
375
+ shellExec(`cd ../pwa-microservices-template && npm run build && timeout 5s npm run dev`, {
376
+ async: true,
377
+ });
378
+ await timer(5500);
379
+ const templateRunnerResult = fs.readFileSync(`../pwa-microservices-template/logs/start.js/all.log`, 'utf8');
380
+ logger.info('Test template runner result');
381
+ console.log(templateRunnerResult);
386
382
  shellExec(`node bin/deploy clean-core-repo`);
387
383
  shellCd(`/home/dd/engine`);
388
384
  const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
389
385
  const newVersion = process.argv[3] ?? originPackageJson.version;
386
+ const node = process.argv[4] ?? 'kind-control-plane';
390
387
  const { version } = originPackageJson;
391
388
  originPackageJson.version = newVersion;
392
389
  fs.writeFileSync(`package.json`, JSON.stringify(originPackageJson, null, 4), 'utf8');
@@ -444,8 +441,23 @@ try {
444
441
  shellExec(`node bin/deploy update-dependencies`);
445
442
  shellExec(`auto-changelog`);
446
443
  shellExec(`node bin/build dd`);
447
- shellExec(`node bin deploy --kubeadm --build-manifest --sync --info-router --replicas 1 dd`);
448
- shellExec(`node bin deploy --kubeadm --build-manifest --sync --info-router --replicas 1 dd production`);
444
+ shellExec(
445
+ `node bin deploy --kubeadm --build-manifest --sync --info-router --replicas 1 --node ${node} dd production`,
446
+ );
447
+ for (const deployId of fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8').split(`,`)) {
448
+ fs.copySync(
449
+ `./engine-private/conf/${deployId}/build/development/deployment.yaml`,
450
+ `./manifests/deployment/${deployId}-development/deployment.yaml`,
451
+ );
452
+ fs.copySync(
453
+ `./engine-private/conf/${deployId}/build/development/proxy.yaml`,
454
+ `./manifests/deployment/${deployId}-development/proxy.yaml`,
455
+ );
456
+ }
457
+ shellExec(`sudo rm -rf ./engine-private/conf/dd-default`);
458
+ shellExec(`node bin new --deploy-id dd-default`);
459
+ console.log(fs.existsSync(`./engine-private/conf/dd-default`));
460
+ shellExec(`sudo rm -rf ./engine-private/conf/dd-default`);
449
461
  break;
450
462
  }
451
463
 
package/bin/file.js CHANGED
@@ -60,6 +60,8 @@ try {
60
60
  else {
61
61
  shellExec(`cd ${toPath} && git reset && git checkout . && git clean -f -d`);
62
62
  shellExec(`underpost pull ${toPath} underpostnet/pwa-microservices-template`);
63
+ shellExec(`sudo rm -rf ${toPath}/engine-private`);
64
+ shellExec(`sudo rm -rf ${toPath}/logs`);
63
65
  }
64
66
  } else {
65
67
  fs.removeSync(toPath);
@@ -94,6 +96,7 @@ try {
94
96
  './manifests/deployment/dd-template-development',
95
97
  'bin/web3.js',
96
98
  'bin/cyberia.js',
99
+ 'bin/cyberia0.js',
97
100
  ]) {
98
101
  if (fs.existsSync(deletePath)) fs.removeSync('../pwa-microservices-template/' + deletePath);
99
102
  }
@@ -125,8 +128,8 @@ try {
125
128
  templatePackageJson.scripts = originPackageJson.scripts;
126
129
  templatePackageJson.name = name;
127
130
  templatePackageJson.description = description;
128
- templatePackageJson.scripts.dev = dev;
129
- templatePackageJson.scripts.build = build;
131
+ // templatePackageJson.scripts.dev = dev;
132
+ // templatePackageJson.scripts.build = build;
130
133
  templatePackageJson.keywords = uniqueArray(
131
134
  ['pwa', 'microservices', 'template', 'builder'].concat(templatePackageJson.keywords),
132
135
  );
package/bin/util.js CHANGED
@@ -1,14 +1,10 @@
1
1
  import fs from 'fs-extra';
2
2
  import si from 'systeminformation';
3
3
  import * as dir from 'path';
4
- import { svg } from 'font-awesome-assets';
5
4
 
6
5
  import { loggerFactory } from '../src/server/logger.js';
7
- import { pbcopy, shellExec } from '../src/server/process.js';
6
+ import { pbcopy } from '../src/server/process.js';
8
7
  import { buildKindPorts } from '../src/server/conf.js';
9
- import { FileFactory } from '../src/api/file/file.service.js';
10
- import { faBase64Png, getBufferPngText } from '../src/server/client-icons.js';
11
- import keyword_extractor from 'keyword-extractor';
12
8
 
13
9
  const logger = loggerFactory(import.meta);
14
10
 
@@ -73,57 +69,6 @@ try {
73
69
  cleanEmptyFoldersRecursively('./');
74
70
  break;
75
71
 
76
- case 'text-to-image': {
77
- const buffer = await getBufferPngText({
78
- text: process.argv[3],
79
- textColor: process.argv[4],
80
- bgColor: process.argv[5],
81
- size: process.argv[6],
82
- debugFilename: process.argv[7],
83
- });
84
- fs.writeFileSync(`./text-to-image.png`, buffer);
85
- break;
86
- }
87
- case 'fa-image':
88
- const faId = process.argv[3] ? process.argv[3] : 'user';
89
- const color = process.argv[4] ? process.argv[4] : '#5f5f5f';
90
- const path = process.argv[5] ? process.argv[5] : './';
91
-
92
- {
93
- fs.writeFileSync(`./tmp/${faId}.svg`, svg(faId, color), 'utf8');
94
- const data = fs.readFileSync(`./tmp/${faId}.svg`);
95
- console.log(FileFactory.svg(data, `${faId}.svg`));
96
- fs.removeSync(`${path}${faId}.svg`);
97
- }
98
- {
99
- fs.writeFileSync(`${path}${faId}.png`, Buffer.from(faBase64Png(faId, 100, 100, color), 'base64'));
100
- }
101
-
102
- break;
103
-
104
- case 'b64-image':
105
- fs.writeFileSync('b64-image', `data:image/jpg;base64,${fs.readFileSync(process.argv[3]).toString('base64')}`);
106
- break;
107
-
108
- case 'get-keys': {
109
- const sentence = fs.existsSync('./_')
110
- ? fs.readFileSync('./_', 'utf8')
111
- : process.argv[3]
112
- ? process.argv[3]
113
- : 'President Obama woke up Monday facing a Congressional defeat that many in both parties believed could hobble his presidency.';
114
-
115
- // Extract the keywords
116
- const extraction_result = keyword_extractor.extract(sentence, {
117
- language: 'english',
118
- remove_digits: true,
119
- // return_changed_case: true,
120
- // remove_duplicates: false,
121
- });
122
-
123
- console.log(extraction_result.join(', '));
124
- break;
125
- }
126
-
127
72
  case 'build-ports': {
128
73
  pbcopy(buildKindPorts(process.argv[3], process.argv[4]));
129
74
  }
package/cli.md CHANGED
@@ -1,4 +1,4 @@
1
- ## underpost ci/cd cli v2.8.86
1
+ ## underpost ci/cd cli v2.8.87
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -47,11 +47,12 @@ Commands:
47
47
  Initializes a new Underpost project with a predefined structure.
48
48
 
49
49
  Arguments:
50
- app-name The name of the application to create.
50
+ app-name The name or deploy-id of the application to create.
51
51
 
52
52
  Options:
53
- --dev Sets the development cli context
54
- -h, --help display help for command
53
+ --deploy-id Crete deploy ID conf env files
54
+ --dev Sets the development cli context
55
+ -h, --help display help for command
55
56
 
56
57
  ```
57
58
 
@@ -290,6 +291,8 @@ Options:
290
291
  management commands.
291
292
  --cert Resets TLS/SSL certificate secrets for
292
293
  deployments.
294
+ --node <node> Sets optional node for deployment
295
+ operations.
293
296
  --build-manifest Builds Kubernetes YAML manifests, including
294
297
  deployments, services, proxies, and
295
298
  secrets.
@@ -304,6 +307,8 @@ Options:
304
307
  current resource deployments.
305
308
  --kubeadm Enables the kubeadm context for deployment
306
309
  operations.
310
+ --etc-hosts Enables the etc-hosts context for
311
+ deployment operations.
307
312
  --restore-hosts Restores default `/etc/hosts` entries.
308
313
  -h, --help display help for command
309
314
 
@@ -594,7 +599,7 @@ Options:
594
599
  Runs a script from the specified path.
595
600
 
596
601
  Arguments:
597
- runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, underpost-config, gpu-env, tf-gpu-test, dev-cluster, ssh-cluster-info, cyberia-ide, engine-ide, template-deploy, clean, pull, release-deploy, ssh-deploy, ide, dev-client, dev-api, monitor, db-client, promote, metrics, cluster, deploy, tf-vae-test, deploy-job.
602
+ runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, underpost-config, gpu-env, tf-gpu-test, dev-cluster, ssh-cluster-info, cyberia-ide, engine-ide, template-deploy, clean, pull, release-deploy, ssh-deploy, ide, dev-client, dev-api, router-sync, monitor, db-client, promote, metrics, cluster, deploy, tf-vae-test, deploy-job.
598
603
  path The absolute or relative directory path where the script is located.
599
604
 
600
605
  Options:
package/conf.js CHANGED
@@ -130,7 +130,7 @@ const DefaultConf = /**/ {
130
130
  ssr: {
131
131
  Default: {
132
132
  head: ['Seo', 'Pwa', 'Css', 'DefaultScripts', 'Production'],
133
- body: ['CacheControl', 'DefaultSplashScreen', '404', '500'],
133
+ body: ['CacheControl', 'DefaultSplashScreen'],
134
134
  mailer: { userVerifyEmail: 'DefaultVerifyEmail', userRecoverEmail: 'DefaultRecoverEmail' },
135
135
  offline: [
136
136
  { path: '/offline', title: 'No Network Connection', client: 'NoNetworkConnection', head: [], body: [] },
@@ -147,8 +147,8 @@ const DefaultConf = /**/ {
147
147
  apis: ['default', 'core', 'user', 'test', 'file'],
148
148
  origins: [],
149
149
  minifyBuild: false,
150
- iconsBuild: true,
151
- liteBuild: false,
150
+ iconsBuild: false,
151
+ liteBuild: true,
152
152
  docsBuild: false,
153
153
  offlineBuild: false,
154
154
  ws: 'core',
@@ -17,7 +17,7 @@ spec:
17
17
  spec:
18
18
  containers:
19
19
  - name: dd-default-development-blue
20
- image: localhost/rockylinux9-underpost:v2.8.86
20
+ image: localhost/rockylinux9-underpost:v2.8.87
21
21
  # resources:
22
22
  # requests:
23
23
  # memory: "124Ki"
@@ -100,7 +100,7 @@ spec:
100
100
  spec:
101
101
  containers:
102
102
  - name: dd-default-development-green
103
- image: localhost/rockylinux9-underpost:v2.8.86
103
+ image: localhost/rockylinux9-underpost:v2.8.87
104
104
  # resources:
105
105
  # requests:
106
106
  # memory: "124Ki"
@@ -20,16 +20,16 @@ spec:
20
20
  ports:
21
21
  - containerPort: 8081
22
22
  env:
23
- - name: ME_CONFIG_MONGODB_ADMINUSERNAME
24
- valueFrom:
25
- secretKeyRef:
26
- name: mongodb-secret
27
- key: username
28
- - name: ME_CONFIG_MONGODB_ADMINPASSWORD
29
- valueFrom:
30
- secretKeyRef:
31
- name: mongodb-secret
32
- key: password
23
+ # - name: ME_CONFIG_MONGODB_ADMINUSERNAME
24
+ # valueFrom:
25
+ # secretKeyRef:
26
+ # name: mongodb-secret
27
+ # key: username
28
+ # - name: ME_CONFIG_MONGODB_ADMINPASSWORD
29
+ # valueFrom:
30
+ # secretKeyRef:
31
+ # name: mongodb-secret
32
+ # key: password
33
33
  - name: ME_CONFIG_BASICAUTH_USERNAME
34
34
  valueFrom:
35
35
  secretKeyRef:
@@ -42,8 +42,8 @@ spec:
42
42
  key: password
43
43
  - name: ME_CONFIG_MONGODB_SERVER
44
44
  value: 'mongodb-0.mongodb-service'
45
- - name: ME_CONFIG_MONGODB_ENABLE_ADMIN
46
- value: 'true'
45
+ # - name: ME_CONFIG_MONGODB_ENABLE_ADMIN
46
+ # value: 'true'
47
47
  - name: ME_CONFIG_MONGODB_PORT
48
48
  value: '27017'
49
49
  ---
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ sudo dnf install -y neovim
5
+
6
+
7
+ sudo rm -rf ~/.config/nvim
8
+ sudo rm -rf ~/.local/share/nvim
9
+
10
+ mkdir -p ~/.config/nvim
11
+ mkdir -p ~/.local/share/nvim/site/autoload
12
+
13
+ # Install vim-plug for Neovim
14
+ curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
15
+ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
16
+
17
+ # Create an init.vim with nvim-tree.lua + web-devicons + gruvbox (theme)
18
+ cat > ~/.config/nvim/init.vim <<'EOF'
19
+ " Minimal init.vim to use nvim-tree.lua + gruvbox theme via vim-plug
20
+
21
+ " --- vim-plug manager
22
+ call plug#begin('~/.local/share/nvim/plugged')
23
+
24
+ " file explorer (nvim-tree)
25
+ Plug 'nvim-tree/nvim-tree.lua'
26
+ Plug 'nvim-tree/nvim-web-devicons' " optional: file icons
27
+
28
+ " colorscheme
29
+ Plug 'morhetz/gruvbox'
30
+
31
+ " sensible defaults, optional
32
+ Plug 'tpope/vim-sensible'
33
+
34
+ call plug#end()
35
+
36
+ " --- UI settings
37
+ syntax on
38
+ filetype plugin indent on
39
+ set number
40
+ set relativenumber
41
+ if has('termguicolors')
42
+ set termguicolors
43
+ endif
44
+ set background=dark
45
+
46
+ " gruvbox options (optional)
47
+ let g:gruvbox_contrast_dark = 'soft'
48
+ colorscheme gruvbox
49
+
50
+ " --- nvim-tree configuration (Lua block)
51
+ lua << 'LUA'
52
+ -- safe require
53
+ local ok, tree = pcall(require, "nvim-tree")
54
+ if not ok then
55
+ return
56
+ end
57
+ tree.setup{
58
+ view = {
59
+ width = 30,
60
+ side = "left",
61
+ preserve_window_proportions = true,
62
+ },
63
+ renderer = {
64
+ indent_markers = { enable = true },
65
+ },
66
+ actions = {
67
+ open_file = {
68
+ quit_on_open = false,
69
+ }
70
+ }
71
+ }
72
+ LUA
73
+
74
+ " --- mappings: Ctrl-n toggles nvim-tree
75
+ nnoremap <C-n> :NvimTreeToggle<CR>
76
+
77
+ " Open nvim-tree on startup when opening nvim with no file args
78
+ autocmd StdinReadPre * let s:std_in=1
79
+ autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NvimTreeToggle | wincmd p | endif
80
+ EOF
81
+
82
+ # Fix permissions in case something was left owned by root (happens if you used sudo on these paths before)
83
+ sudo chown -R "$USER":"$USER" ~/.config/nvim ~/.local/share/nvim 2>/dev/null || true
84
+
85
+ # Install plugins automatically (non-interactive)
86
+ nvim +PlugInstall +qall
87
+
88
+ echo
89
+ echo "Done. Plugins installed."
90
+ echo "Run 'nvim' and press Ctrl-n to toggle the file tree."
91
+ echo "If colorscheme is not correct, ensure your terminal supports truecolor and TERM is xterm-256color."
package/package.json CHANGED
@@ -2,14 +2,14 @@
2
2
  "type": "module",
3
3
  "main": "src/index.js",
4
4
  "name": "underpost",
5
- "version": "2.8.86",
5
+ "version": "2.8.87",
6
6
  "description": "pwa api rest template",
7
7
  "scripts": {
8
8
  "start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
9
9
  "build": "node bin/deploy build-full-client",
10
10
  "test": "env-cmd -f .env.test c8 mocha",
11
- "pm2": "env-cmd -f .env.production pm2 start src/server.js --node-args=\"--max-old-space-size=8192\" --name engine",
12
- "dev": "env-cmd -f .env.development node src/client.dev default",
11
+ "pm2": "env-cmd -f .env.production pm2 start src/server.js --node-args=\"--max-old-space-size=8192\" --name engine -- dd-default",
12
+ "dev": "env-cmd -f .env.development nodemon src/server",
13
13
  "dev-img": "env-cmd -f .env.development node src/server",
14
14
  "prod-img": "env-cmd -f .env.production node src/server",
15
15
  "monitor": "pm2 start src/monitor.js --name monitor -- dd production",
@@ -58,11 +58,8 @@
58
58
  "axios": "^1.5.1",
59
59
  "chai": "^5.1.0",
60
60
  "clean-jsdoc-theme": "^4.3.0",
61
- "cli-progress": "^3.12.0",
62
- "cli-spinners": "^3.0.0",
63
61
  "clipboardy": "^4.0.0",
64
62
  "cloudinary": "^2.5.1",
65
- "color": "^4.2.3",
66
63
  "colors": "^1.4.0",
67
64
  "commander": "^12.1.0",
68
65
  "compression": "^1.7.4",
@@ -74,7 +71,6 @@
74
71
  "express": "^4.18.2",
75
72
  "express-fileupload": "^1.4.3",
76
73
  "favicons": "^7.2.0",
77
- "font-awesome-assets": "^0.0.9",
78
74
  "fs-extra": "^11.1.1",
79
75
  "fullcalendar": "^6.1.15",
80
76
  "html-minifier-terser": "^7.2.0",
@@ -82,11 +78,9 @@
82
78
  "ignore-walk": "^6.0.4",
83
79
  "iovalkey": "^0.2.1",
84
80
  "jimp": "^0.22.12",
85
- "joystick-controller": "^1.0.15",
86
81
  "json-colorizer": "^2.2.2",
87
82
  "jsonwebtoken": "^9.0.2",
88
83
  "keyword-extractor": "^0.0.28",
89
- "log-update": "^6.0.0",
90
84
  "mariadb": "^3.2.2",
91
85
  "marked": "^12.0.2",
92
86
  "mocha": "^10.8.2",
@@ -97,7 +91,6 @@
97
91
  "pathfinding": "^0.4.18",
98
92
  "peer": "^1.0.2",
99
93
  "peerjs": "^1.5.2",
100
- "pixi.js": "7.4.2",
101
94
  "prom-client": "^15.1.2",
102
95
  "public-ip": "^6.0.1",
103
96
  "read": "^2.1.0",
@@ -116,7 +109,6 @@
116
109
  "vanilla-jsoneditor": "^2.3.2",
117
110
  "winston": "^3.11.0"
118
111
  },
119
- "devDependencies": {},
120
112
  "publishConfig": {
121
113
  "provenance": true,
122
114
  "access": "public",
@@ -5,14 +5,18 @@ import crypto from 'crypto';
5
5
  const logger = loggerFactory(import.meta);
6
6
 
7
7
  const FileFactory = {
8
- upload: async function (req, File) {
9
- const results = [];
10
- if (!req.files) throw { message: 'not file found' };
11
- if (Array.isArray(req.files.file)) for (const file of req.files.file) results.push(await new File(file).save());
8
+ filesExtract: (req) => {
9
+ const files = [];
10
+ if (Array.isArray(req.files.file)) for (const file of req.files.file) files.push(file);
12
11
  else if (Object.keys(req.files).length > 0)
13
- for (const keyFile of Object.keys(req.files)) results.push(await new File(req.files[keyFile]).save());
12
+ for (const keyFile of Object.keys(req.files)) files.push(req.files[keyFile]);
13
+ return files;
14
+ },
15
+ upload: async function (req, File) {
16
+ const results = FileFactory.filesExtract(req);
14
17
  let index = -1;
15
- for (const file of results) {
18
+ for (let file of results) {
19
+ file = await new File(file).save();
16
20
  index++;
17
21
  const [result] = await File.find({
18
22
  _id: file._id,
@@ -25,7 +29,23 @@ const FileFactory = {
25
29
  return Buffer.from(raw, 'utf8').toString('hex');
26
30
  // reverse hexValue.toString()
27
31
  },
28
- svg: (data = new Buffer(), name = '') => {
32
+ getMymeTypeFromPath: (path) => {
33
+ switch (path.split('.').pop()) {
34
+ case 'png':
35
+ return 'image/png';
36
+ case 'jpg':
37
+ return 'image/jpeg';
38
+ case 'jpeg':
39
+ return 'image/jpeg';
40
+ case 'gif':
41
+ return 'image/gif';
42
+ case 'svg':
43
+ return 'image/svg+xml';
44
+ default:
45
+ return 'application/octet-stream';
46
+ }
47
+ },
48
+ create: (data = Buffer.from([]), name = '') => {
29
49
  return {
30
50
  name: name,
31
51
  data: data,
@@ -33,7 +53,7 @@ const FileFactory = {
33
53
  encoding: '7bit',
34
54
  tempFilePath: '',
35
55
  truncated: false,
36
- mimetype: 'image/svg+xml',
56
+ mimetype: FileFactory.getMymeTypeFromPath(name),
37
57
  md5: crypto.createHash('md5').update(data).digest('hex'),
38
58
  cid: undefined,
39
59
  };