underpost 2.8.62 → 2.8.64

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 (39) hide show
  1. package/Dockerfile +9 -10
  2. package/bin/build.js +2 -2
  3. package/bin/deploy.js +1 -1
  4. package/bin/index.js +21 -7
  5. package/docker-compose.yml +1 -1
  6. package/package.json +1 -1
  7. package/src/api/default/default.service.js +1 -1
  8. package/src/api/user/user.service.js +1 -1
  9. package/src/cli/cron.js +39 -8
  10. package/src/cli/deploy.js +83 -42
  11. package/src/cli/fs.js +7 -6
  12. package/src/cli/image.js +81 -75
  13. package/src/cli/monitor.js +92 -0
  14. package/src/client/components/core/Account.js +25 -21
  15. package/src/client/components/core/Blockchain.js +1 -1
  16. package/src/client/components/core/CalendarCore.js +14 -83
  17. package/src/client/components/core/CommonJs.js +2 -1
  18. package/src/client/components/core/CssCore.js +8 -2
  19. package/src/client/components/core/Docs.js +1 -1
  20. package/src/client/components/core/EventsUI.js +2 -2
  21. package/src/client/components/core/FileExplorer.js +86 -78
  22. package/src/client/components/core/LoadingAnimation.js +1 -17
  23. package/src/client/components/core/LogIn.js +3 -3
  24. package/src/client/components/core/LogOut.js +1 -1
  25. package/src/client/components/core/Modal.js +12 -7
  26. package/src/client/components/core/Panel.js +19 -61
  27. package/src/client/components/core/PanelForm.js +13 -22
  28. package/src/client/components/core/Recover.js +3 -3
  29. package/src/client/components/core/Router.js +3 -1
  30. package/src/client/components/core/SignUp.js +2 -2
  31. package/src/client/components/default/RoutesDefault.js +3 -2
  32. package/src/client/services/default/default.management.js +45 -38
  33. package/src/client/ssr/Render.js +2 -0
  34. package/src/index.js +17 -2
  35. package/src/runtime/lampp/Dockerfile +65 -0
  36. package/src/server/conf.js +45 -1
  37. package/src/server/dns.js +9 -1
  38. package/src/server/network.js +7 -122
  39. package/src/server/runtime.js +1 -3
package/Dockerfile CHANGED
@@ -1,11 +1,11 @@
1
1
  ARG BASE_DEBIAN=buster
2
2
 
3
+ # USER root
4
+
3
5
  FROM debian:${BASE_DEBIAN}
4
6
 
5
7
  ENV DEBIAN_FRONTEND=noninteractive
6
8
 
7
- WORKDIR /home/dd
8
-
9
9
  # Set root password to root, format is 'user:password'.
10
10
  RUN echo 'root:root' | chpasswd
11
11
 
@@ -25,9 +25,6 @@ RUN mkdir -p /var/run/sshd
25
25
  # Allow root login via password
26
26
  RUN sed -ri 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
27
27
 
28
- # copy supervisor config file to start openssh-server
29
- COPY supervisord-openssh-server.conf /etc/supervisor/conf.d/supervisord-openssh-server.conf
30
-
31
28
  # install open ssl git and others tools
32
29
  RUN apt-get install -yq --no-install-recommends libssl-dev curl wget git gnupg
33
30
 
@@ -37,12 +34,14 @@ RUN apt-get install -y nodejs build-essential
37
34
  RUN node --version
38
35
  RUN npm --version
39
36
 
40
- RUN npm install -g underpost
41
-
42
- VOLUME [ "/home/dd/engine/logs" ]
37
+ WORKDIR /home/dd
43
38
 
44
39
  EXPOSE 22
45
40
 
46
- EXPOSE 4000-4004
41
+ EXPOSE 80
42
+
43
+ EXPOSE 443
44
+
45
+ EXPOSE 3000-3100
47
46
 
48
- CMD [ "underpost", "new", "service" ]
47
+ EXPOSE 4000-4100
package/bin/build.js CHANGED
@@ -47,7 +47,7 @@ if (process.argv.includes('conf')) {
47
47
  if (!fs.existsSync(`../${privateRepoName}`)) {
48
48
  shellExec(`cd .. && underpost clone ${privateGitUri}`, { silent: true });
49
49
  } else {
50
- shellExec(`cd ../${privateRepoName} && underpost pull . ${privateGitUri}`);
50
+ shellExec(`cd ../${privateRepoName} && git checkout . && git clean -f -d && underpost pull . ${privateGitUri}`);
51
51
  }
52
52
  const toPath = `../${privateRepoName}/conf/${_confName}`;
53
53
  fs.removeSync(toPath);
@@ -176,7 +176,7 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
176
176
  if (!fs.existsSync(`${basePath}/images`)) fs.mkdirSync(`${basePath}/images`);
177
177
 
178
178
  const env = process.argv.includes('development') ? 'development' : 'production';
179
- const deploymentsFiles = ['Dockerfile', 'proxy.yaml', 'deployment.yaml', 'secret.yaml'];
179
+ const deploymentsFiles = ['proxy.yaml', 'deployment.yaml', 'secret.yaml'];
180
180
  // remove engine-private of .dockerignore for local testing
181
181
  for (const file of deploymentsFiles) {
182
182
  if (fs.existsSync(`./manifests/deployment/${confName}-${env}/${file}`)) {
package/bin/deploy.js CHANGED
@@ -673,8 +673,8 @@ try {
673
673
  }
674
674
 
675
675
  case 'version-build': {
676
- const newVersion = process.argv[3];
677
676
  const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
677
+ const newVersion = process.argv[3] ?? originPackageJson.version;
678
678
  const { version } = originPackageJson;
679
679
  originPackageJson.version = newVersion;
680
680
  fs.writeFileSync(`package.json`, JSON.stringify(originPackageJson, null, 4), 'utf8');
package/bin/index.js CHANGED
@@ -105,6 +105,7 @@ program
105
105
  .option('--info-util', 'Display kubectl util management commands')
106
106
  .option('--cert', 'Reset tls/ssl certificate secrets')
107
107
  .option('--build-manifest', 'Build kind yaml manifests: deployments, services, proxy and secrets')
108
+ .option('--dashboard-update', 'Update dashboard instance data with current router config')
108
109
  .option('--version', 'Set custom version')
109
110
  .description('Manage deployment, for default deploy development pods')
110
111
  .action(Underpost.deploy.callback);
@@ -135,13 +136,15 @@ program
135
136
 
136
137
  program
137
138
  .command('dockerfile-image-build')
138
- .argument('<deploy-id>', 'Deploy configuration id')
139
- .argument('[env]', 'Optional environment, for default is development')
140
- .argument('[path]', 'Absolute or relative directory, for default is current')
141
- .option('--image-archive', 'Only load tar image from ./images')
142
- .option('--podman-save', 'Save image from podman to ./images')
143
- .option('--image-name <image-name>', 'Set custom image name')
144
- .option('--image-version <image-version>', 'Set custom image version')
139
+ .option('--path [path]', 'Dockerfile path')
140
+ .option('--image-name [image-name]', 'Set image name')
141
+ .option('--image-path [image-path]', 'Set tar image path')
142
+ .option('--dockerfile-name [dockerfile-name]', 'set Dockerfile name')
143
+ .option('--podman-save', 'Export tar file from podman')
144
+ .option('--kind-load', 'Import tar image to Kind cluster')
145
+ .option('--secrets', 'Dockerfile env secrets')
146
+ .option('--secrets-path [secrets-path]', 'Dockerfile custom path env secrets')
147
+ .option('--no-cache', 'Build without using cache')
145
148
  .description('Build image from Dockerfile')
146
149
  .action(Underpost.image.dockerfile.build);
147
150
 
@@ -193,6 +196,7 @@ program
193
196
  .option('--itc', 'Inside container execution context')
194
197
  .option('--init', 'Init cron jobs for cron job default deploy id')
195
198
  .option('--git', 'Upload to github')
199
+ .option('--dashboard-update', 'Update dashboard cron data with current jobs config')
196
200
  .description('Cron jobs management')
197
201
  .action(Underpost.cron.callback);
198
202
 
@@ -220,4 +224,14 @@ program
220
224
  .option('--kind-type <kind-type>')
221
225
  .action(Underpost.test.callback);
222
226
 
227
+ program
228
+ .command('monitor')
229
+ .argument('<deploy-id>', 'Deploy configuration id')
230
+ .argument('[env]', 'Optional environment, for default is development')
231
+ .option('--ms-interval <ms-interval>', 'Custom ms interval delta time')
232
+ .option('--now', 'Exec immediately monitor script')
233
+ .option('--single', 'Disable recurrence')
234
+ .description('Monitor health server management')
235
+ .action(Underpost.monitor.callback);
236
+
223
237
  program.parse();
@@ -58,7 +58,7 @@ services:
58
58
  cpus: '0.25'
59
59
  memory: 20M
60
60
  labels: # labels in Compose file instead of Dockerfile
61
- engine.version: '2.8.62'
61
+ engine.version: '2.8.64'
62
62
  networks:
63
63
  - load-balancer
64
64
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "main": "src/index.js",
4
4
  "name": "underpost",
5
- "version": "2.8.62",
5
+ "version": "2.8.64",
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",
@@ -24,7 +24,7 @@ const DefaultService = {
24
24
  /** @type {import('./default.model.js').DefaultModel} */
25
25
  const Default = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Default;
26
26
  if (req.params.id) return await Default.findByIdAndDelete(req.params.id);
27
- else return await await Default.deleteMany();
27
+ else return await Default.deleteMany();
28
28
  },
29
29
  };
30
30
 
@@ -378,7 +378,7 @@ const UserService = {
378
378
  switch (user.role) {
379
379
  case 'admin': {
380
380
  if (req.params.id) return await User.findByIdAndDelete(req.params.id);
381
- else return await await User.deleteMany();
381
+ else return await User.deleteMany();
382
382
  }
383
383
  default:
384
384
  if (req.auth.user._id !== req.params.id) throw new Error(`Invalid token user id`);
package/src/cli/cron.js CHANGED
@@ -4,20 +4,24 @@
4
4
  * @namespace UnderpostCron
5
5
  */
6
6
 
7
- import Underpost from '../index.js';
7
+ import { DataBaseProvider } from '../db/DataBaseProvider.js';
8
8
  import BackUp from '../server/backup.js';
9
9
  import { Cmd } from '../server/conf.js';
10
10
  import Dns from '../server/dns.js';
11
- import { netWorkCron, saveRuntimeCron } from '../server/network.js';
11
+ import { loggerFactory } from '../server/logger.js';
12
+
12
13
  import { shellExec } from '../server/process.js';
13
14
  import fs from 'fs-extra';
14
15
 
16
+ const logger = loggerFactory(import.meta);
17
+
15
18
  /**
16
19
  * UnderpostCron main module methods
17
20
  * @class
18
21
  * @memberof UnderpostCron
19
22
  */
20
23
  class UnderpostCron {
24
+ static NETWORK = [];
21
25
  static JOB = {
22
26
  /**
23
27
  * DNS cli API
@@ -46,10 +50,10 @@ class UnderpostCron {
46
50
  callback: async function (
47
51
  deployList = 'default',
48
52
  jobList = Object.keys(UnderpostCron.JOB),
49
- options = { itc: false, init: false, git: false },
53
+ options = { itc: false, init: false, git: false, dashboardUpdate: false },
50
54
  ) {
51
55
  if (options.init === true) {
52
- await Underpost.test.setUpInfo();
56
+ UnderpostCron.NETWORK = [];
53
57
  const jobDeployId = fs.readFileSync('./engine-private/deploy/dd.cron', 'utf8').trim();
54
58
  deployList = fs.readFileSync('./engine-private/deploy/dd.router', 'utf8').trim();
55
59
  const confCronConfig = JSON.parse(fs.readFileSync(`./engine-private/conf/${jobDeployId}/conf.cron.json`));
@@ -57,7 +61,7 @@ class UnderpostCron {
57
61
  for (const job of Object.keys(confCronConfig.jobs)) {
58
62
  const name = `${jobDeployId}-${job}`;
59
63
  let deployId;
60
- shellExec(Cmd.delete(name));
64
+ if (!options.dashboardUpdate) shellExec(Cmd.delete(name));
61
65
  switch (job) {
62
66
  case 'dns':
63
67
  deployId = jobDeployId;
@@ -67,15 +71,16 @@ class UnderpostCron {
67
71
  deployId = deployList;
68
72
  break;
69
73
  }
70
- shellExec(Cmd.cron(deployId, job, name, confCronConfig.jobs[job].expression, options));
71
- netWorkCron.push({
74
+ if (!options.dashboardUpdate)
75
+ shellExec(Cmd.cron(deployId, job, name, confCronConfig.jobs[job].expression, options));
76
+ UnderpostCron.NETWORK.push({
72
77
  deployId,
73
78
  jobId: job,
74
79
  expression: confCronConfig.jobs[job].expression,
75
80
  });
76
81
  }
77
82
  }
78
- await saveRuntimeCron();
83
+ if (options.dashboardUpdate === true) await UnderpostCron.API.updateDashboardData();
79
84
  if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
80
85
  return;
81
86
  }
@@ -84,6 +89,32 @@ class UnderpostCron {
84
89
  if (UnderpostCron.JOB[jobId]) await UnderpostCron.JOB[jobId].callback(deployList, options);
85
90
  }
86
91
  },
92
+ async updateDashboardData() {
93
+ try {
94
+ const deployId = process.env.DEFAULT_DEPLOY_ID;
95
+ const host = process.env.DEFAULT_DEPLOY_HOST;
96
+ const path = process.env.DEFAULT_DEPLOY_PATH;
97
+ const confServerPath = `./engine-private/conf/${deployId}/conf.server.json`;
98
+ const confServer = JSON.parse(fs.readFileSync(confServerPath, 'utf8'));
99
+ const { db } = confServer[host][path];
100
+
101
+ await DataBaseProvider.load({ apis: ['cron'], host, path, db });
102
+
103
+ /** @type {import('../api/cron/cron.model.js').CronModel} */
104
+ const Cron = DataBaseProvider.instance[`${host}${path}`].mongoose.models.Cron;
105
+
106
+ await Cron.deleteMany();
107
+
108
+ for (const cronInstance of UnderpostCron.NETWORK) {
109
+ logger.info('save', cronInstance);
110
+ await new Cron(cronInstance).save();
111
+ }
112
+
113
+ await DataBaseProvider.instance[`${host}${path}`].mongoose.close();
114
+ } catch (error) {
115
+ logger.error(error, error.stack);
116
+ }
117
+ },
87
118
  };
88
119
  }
89
120
 
package/src/cli/deploy.js CHANGED
@@ -3,18 +3,21 @@ import {
3
3
  buildPortProxyRouter,
4
4
  buildProxyRouter,
5
5
  Config,
6
+ deployRangePortFactory,
6
7
  getDataDeploy,
7
8
  loadReplicas,
9
+ pathPortAssignmentFactory,
8
10
  } from '../server/conf.js';
9
11
  import { loggerFactory } from '../server/logger.js';
10
12
  import { shellExec } from '../server/process.js';
11
13
  import fs from 'fs-extra';
12
14
  import dotenv from 'dotenv';
13
- import Underpost from '../index.js';
15
+ import { DataBaseProvider } from '../db/DataBaseProvider.js';
14
16
 
15
17
  const logger = loggerFactory(import.meta);
16
18
 
17
19
  class UnderpostDeploy {
20
+ static NETWORK = {};
18
21
  static API = {
19
22
  sync(deployList) {
20
23
  const deployGroupId = 'dd.tmp';
@@ -36,21 +39,29 @@ class UnderpostDeploy {
36
39
  for (const _deployId of deployList.split(',')) {
37
40
  const deployId = _deployId.trim();
38
41
  if (!deployId) continue;
39
-
40
- const router = await UnderpostDeploy.API.routerFactory(deployId, env);
41
- const ports = Object.values(router).map((p) => parseInt(p.split(':')[2]));
42
- const fromPort = Math.min(...ports);
43
- const toPort = Math.max(...ports);
44
42
  const confServer = loadReplicas(
45
43
  JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8')),
46
44
  'proxy',
47
45
  );
46
+ const router = await UnderpostDeploy.API.routerFactory(deployId, env);
47
+ const pathPortAssignmentData = pathPortAssignmentFactory(router, confServer);
48
+ const { fromPort, toPort } = deployRangePortFactory(router);
48
49
 
49
50
  fs.mkdirSync(`./engine-private/conf/${deployId}/build/${env}`, { recursive: true });
50
51
  if (env === 'development') fs.mkdirSync(`./manifests/deployment/${deployId}-${env}`, { recursive: true });
51
52
 
52
53
  logger.info('port range', { deployId, fromPort, toPort });
53
- // const customImg = `underpost-engine:${version && typeof version === 'string' ? version : Underpost.version}`;
54
+ // const customImg = `underpost-engine:${version && typeof version === 'string' ? version : '0.0.0'}`;
55
+ // lifecycle:
56
+ // postStart:
57
+ // exec:
58
+ // command:
59
+ // - /bin/sh
60
+ // - -c
61
+ // - >
62
+ // sleep 20 &&
63
+ // npm install -g underpost &&
64
+ // underpost secret underpost --create-from-file /etc/config/.env.${env}
54
65
  const deploymentYamlParts = `apiVersion: apps/v1
55
66
  kind: Deployment
56
67
  metadata:
@@ -74,17 +85,10 @@ spec:
74
85
  - /bin/sh
75
86
  - -c
76
87
  - >
88
+ npm install -g npm@11.2.0 &&
89
+ npm install -g underpost &&
90
+ underpost secret underpost --create-from-file /etc/config/.env.${env} &&
77
91
  underpost dockerfile-node-script --build --run ${deployId} ${env}
78
- lifecycle:
79
- postStart:
80
- exec:
81
- command:
82
- - /bin/sh
83
- - -c
84
- - >
85
- sleep 20 &&
86
- npm install -g underpost
87
- underpost secret underpost --create-from-file /etc/config/.env.${env}
88
92
  volumeMounts:
89
93
  - name: config-volume
90
94
  mountPath: /etc/config
@@ -92,7 +96,7 @@ spec:
92
96
  - name: config-volume
93
97
  configMap:
94
98
  name: underpost-config
95
- # image: localhost/${deployId}-${env}:${version && typeof version === 'string' ? version : Underpost.version}
99
+ # image: localhost/${deployId}-${env}:${version && typeof version === 'string' ? version : '0.0.0'}
96
100
  ---
97
101
  apiVersion: v1
98
102
  kind: Service
@@ -134,27 +138,8 @@ spec:
134
138
  kind: ClusterIssuer
135
139
  secretName: ${host}`;
136
140
 
137
- const pathPortConditions = [];
138
- for (const path of Object.keys(confServer[host])) {
139
- const { peer } = confServer[host][path];
140
- if (!router[`${host}${path === '/' ? '' : path}`]) continue;
141
- const port = parseInt(router[`${host}${path === '/' ? '' : path}`].split(':')[2]);
142
- // logger.info('', { host, port, path });
143
- pathPortConditions.push({
144
- port,
145
- path,
146
- });
147
-
148
- if (peer) {
149
- // logger.info('', { host, port: port + 1, path: '/peer' });
150
- pathPortConditions.push({
151
- port: port + 1,
152
- path: '/peer',
153
- });
154
- }
155
- }
156
-
157
- // logger.info('', { host, pathPortConditions });
141
+ const pathPortAssignment = pathPortAssignmentData[host];
142
+ // logger.info('', { host, pathPortAssignment });
158
143
  proxyYaml += `
159
144
  ---
160
145
  apiVersion: projectcontour.io/v1
@@ -171,7 +156,7 @@ spec:
171
156
  secretName: ${host}`
172
157
  }
173
158
  routes:`;
174
- for (const conditionObj of pathPortConditions) {
159
+ for (const conditionObj of pathPortAssignment) {
175
160
  const { path, port } = conditionObj;
176
161
  proxyYaml += `
177
162
  - conditions:
@@ -212,6 +197,7 @@ spec:
212
197
  expose: false,
213
198
  cert: false,
214
199
  version: '',
200
+ dashboardUpdate: false,
215
201
  },
216
202
  ) {
217
203
  if (options.infoUtil === true)
@@ -224,8 +210,9 @@ kubectl scale statefulsets <stateful-set-name> --replicas=<new-replicas>
224
210
  deployList = fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8');
225
211
  if (options.sync) UnderpostDeploy.API.sync(deployList);
226
212
  if (options.buildManifest === true) await UnderpostDeploy.API.buildManifest(deployList, env, options.version);
227
- if (options.infoRouter === true)
228
- return logger.info('router', await UnderpostDeploy.API.routerFactory(deployList, env));
213
+ if (options.infoRouter === true) logger.info('router', await UnderpostDeploy.API.routerFactory(deployList, env));
214
+ if (options.dashboardUpdate === true) await UnderpostDeploy.API.updateDashboardData(deployList, env, options);
215
+ if (options.infoRouter === true) return;
229
216
  shellExec(`kubectl delete configmap underpost-config`);
230
217
  shellExec(
231
218
  `kubectl create configmap underpost-config --from-file=/home/dd/engine/engine-private/conf/dd-cron/.env.${env}`,
@@ -328,6 +315,60 @@ kubectl scale statefulsets <stateful-set-name> --replicas=<new-replicas>
328
315
 
329
316
  return result;
330
317
  },
318
+ async updateDashboardData(deployList, env, options) {
319
+ try {
320
+ const deployId = process.env.DEFAULT_DEPLOY_ID;
321
+ const host = process.env.DEFAULT_DEPLOY_HOST;
322
+ const path = process.env.DEFAULT_DEPLOY_PATH;
323
+ const { db } = JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8'))[host][
324
+ path
325
+ ];
326
+
327
+ await DataBaseProvider.load({ apis: ['instance'], host, path, db });
328
+
329
+ /** @type {import('../api/instance/instance.model.js').InstanceModel} */
330
+ const Instance = DataBaseProvider.instance[`${host}${path}`].mongoose.models.Instance;
331
+
332
+ await Instance.deleteMany();
333
+
334
+ for (const _deployId of deployList.split(',')) {
335
+ const deployId = _deployId.trim();
336
+ if (!deployId) continue;
337
+ const confServer = loadReplicas(
338
+ JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8')),
339
+ 'proxy',
340
+ );
341
+ const router = await UnderpostDeploy.API.routerFactory(deployId, env);
342
+ const pathPortAssignmentData = pathPortAssignmentFactory(router, confServer);
343
+
344
+ for (const host of Object.keys(confServer)) {
345
+ for (const { path, port } of pathPortAssignmentData[host]) {
346
+ if (!confServer[host][path]) continue;
347
+
348
+ const { client, runtime, apis } = confServer[host][path];
349
+
350
+ const body = {
351
+ deployId,
352
+ host,
353
+ path,
354
+ port,
355
+ client,
356
+ runtime,
357
+ apis,
358
+ };
359
+
360
+ logger.info('save', body);
361
+
362
+ await new Instance(body).save();
363
+ }
364
+ }
365
+ }
366
+
367
+ await DataBaseProvider.instance[`${host}${path}`].mongoose.close();
368
+ } catch (error) {
369
+ logger.error(error, error.stack);
370
+ }
371
+ },
331
372
  };
332
373
  }
333
374
 
package/src/cli/fs.js CHANGED
@@ -38,7 +38,7 @@ class UnderpostFileStorage {
38
38
  options = { rm: false, recursive: false, deployId: '', force: false, pull: false, git: false },
39
39
  ) {
40
40
  const { storage, storageConf } = UnderpostFileStorage.API.getStorageConf(options);
41
- const deleteFiles = UnderpostRepository.API.getDeleteFiles(path);
41
+ const deleteFiles = options.pull === true ? [] : UnderpostRepository.API.getDeleteFiles(path);
42
42
  for (const relativePath of deleteFiles) {
43
43
  const _path = path + '/' + relativePath;
44
44
  if (_path in storage) {
@@ -46,10 +46,6 @@ class UnderpostFileStorage {
46
46
  delete storage[_path];
47
47
  }
48
48
  }
49
- const files =
50
- options.git === true
51
- ? UnderpostRepository.API.getChangedFiles(path)
52
- : await fs.readdir(path, { recursive: true });
53
49
  if (options.pull === true) {
54
50
  for (const _path of Object.keys(storage)) {
55
51
  if (!fs.existsSync(_path) || options.force === true) {
@@ -57,7 +53,11 @@ class UnderpostFileStorage {
57
53
  await UnderpostFileStorage.API.pull(_path, options);
58
54
  } else logger.warn(`Pull path already exists`, _path);
59
55
  }
60
- } else
56
+ } else {
57
+ const files =
58
+ options.git === true
59
+ ? UnderpostRepository.API.getChangedFiles(path)
60
+ : await fs.readdir(path, { recursive: true });
61
61
  for (const relativePath of files) {
62
62
  const _path = path + '/' + relativePath;
63
63
  if (fs.statSync(_path).isDirectory()) {
@@ -68,6 +68,7 @@ class UnderpostFileStorage {
68
68
  if (storage) storage[_path] = {};
69
69
  } else logger.warn('File already exists', _path);
70
70
  }
71
+ }
71
72
  UnderpostFileStorage.API.writeStorageConf(storage, storageConf);
72
73
  if (options.git === true) {
73
74
  shellExec(`cd ${path} && git add .`);