@nocobase/cli 1.6.0-alpha.9 → 1.6.0-beta.2

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/nocobase.conf.tpl CHANGED
@@ -65,6 +65,8 @@ server {
65
65
  }
66
66
  }
67
67
 
68
+ {{otherLocation}}
69
+
68
70
  location ^~ {{publicPath}}api/ {
69
71
  proxy_pass http://127.0.0.1:{{apiPort}};
70
72
  proxy_http_version 1.1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "1.6.0-alpha.9",
3
+ "version": "1.6.0-beta.2",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "./src/index.js",
@@ -8,7 +8,7 @@
8
8
  "nocobase": "./bin/index.js"
9
9
  },
10
10
  "dependencies": {
11
- "@nocobase/app": "1.6.0-alpha.9",
11
+ "@nocobase/app": "1.6.0-beta.2",
12
12
  "@types/fs-extra": "^11.0.1",
13
13
  "@umijs/utils": "3.5.20",
14
14
  "chalk": "^4.1.1",
@@ -25,12 +25,12 @@
25
25
  "tsx": "^4.19.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@nocobase/devtools": "1.6.0-alpha.9"
28
+ "@nocobase/devtools": "1.6.0-beta.2"
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",
32
32
  "url": "git+https://github.com/nocobase/nocobase.git",
33
33
  "directory": "packages/core/cli"
34
34
  },
35
- "gitHead": "c6136fc6c9a2daab33fb1a20716cd9768e9a147f"
35
+ "gitHead": "476ab2f424d86f585c8fba1459568c8aec49a5c6"
36
36
  }
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- const { resolve } = require('path');
10
+ const { resolve, posix } = require('path');
11
11
  const { Command } = require('commander');
12
12
  const { readFileSync, writeFileSync } = require('fs');
13
13
 
@@ -19,11 +19,18 @@ module.exports = (cli) => {
19
19
  cli.command('create-nginx-conf').action(async (name, options) => {
20
20
  const file = resolve(__dirname, '../../nocobase.conf.tpl');
21
21
  const data = readFileSync(file, 'utf-8');
22
+ let otherLocation = '';
23
+ if (process.env.APP_PUBLIC_PATH !== '/') {
24
+ otherLocation = `location / {
25
+ alias ${posix.resolve(process.cwd())}/node_modules/@nocobase/app/dist/client/;
26
+ try_files $uri $uri/ /index.html;
27
+ }`;
28
+ }
22
29
  const replaced = data
23
- .replace(/\{\{cwd\}\}/g, '/app/nocobase')
30
+ .replace(/\{\{cwd\}\}/g, posix.resolve(process.cwd()))
24
31
  .replace(/\{\{publicPath\}\}/g, process.env.APP_PUBLIC_PATH)
25
- .replace(/\{\{apiPort\}\}/g, process.env.APP_PORT);
26
-
32
+ .replace(/\{\{apiPort\}\}/g, process.env.APP_PORT)
33
+ .replace(/\{\{otherLocation\}\}/g, otherLocation);
27
34
  const targetFile = resolve(process.cwd(), 'storage', 'nocobase.conf');
28
35
  writeFileSync(targetFile, replaced);
29
36
  });
@@ -8,19 +8,30 @@
8
8
  */
9
9
  const _ = require('lodash');
10
10
  const { Command } = require('commander');
11
- const { isDev, run, postCheck, downloadPro, promptForTs } = require('../util');
11
+ const { run, postCheck, downloadPro, promptForTs } = require('../util');
12
12
  const { existsSync, rmSync } = require('fs');
13
- const { resolve } = require('path');
13
+ const { resolve, isAbsolute } = require('path');
14
14
  const chalk = require('chalk');
15
15
  const chokidar = require('chokidar');
16
16
 
17
+ function getSocketPath() {
18
+ const { SOCKET_PATH } = process.env;
19
+
20
+ if (isAbsolute(SOCKET_PATH)) {
21
+ return SOCKET_PATH;
22
+ }
23
+
24
+ return resolve(process.cwd(), SOCKET_PATH);
25
+ }
26
+
17
27
  function deleteSockFiles() {
18
- const { SOCKET_PATH, PM2_HOME } = process.env;
28
+ const { PM2_HOME } = process.env;
19
29
  if (existsSync(PM2_HOME)) {
20
30
  rmSync(PM2_HOME, { recursive: true });
21
31
  }
22
- if (existsSync(SOCKET_PATH)) {
23
- rmSync(SOCKET_PATH);
32
+ const socketPath = getSocketPath();
33
+ if (existsSync(socketPath)) {
34
+ rmSync(socketPath);
24
35
  }
25
36
  }
26
37
 
package/src/util.js CHANGED
@@ -11,11 +11,12 @@ const net = require('net');
11
11
  const chalk = require('chalk');
12
12
  const execa = require('execa');
13
13
  const fg = require('fast-glob');
14
- const { dirname, join, resolve, sep } = require('path');
14
+ const { dirname, join, resolve, sep, isAbsolute } = require('path');
15
15
  const { readFile, writeFile } = require('fs').promises;
16
16
  const { existsSync, mkdirSync, cpSync, writeFileSync } = require('fs');
17
17
  const dotenv = require('dotenv');
18
- const fs = require('fs');
18
+ const fs = require('fs-extra');
19
+ const os = require('os');
19
20
  const moment = require('moment-timezone');
20
21
 
21
22
  exports.isPackageValid = (pkg) => {
@@ -325,6 +326,32 @@ function areTimeZonesEqual(timeZone1, timeZone2) {
325
326
  return moment.tz(timeZone1).format('Z') === moment.tz(timeZone2).format('Z');
326
327
  }
327
328
 
329
+ function generateGatewayPath() {
330
+ if (process.env.SOCKET_PATH) {
331
+ if (isAbsolute(process.env.SOCKET_PATH)) {
332
+ return process.env.SOCKET_PATH;
333
+ }
334
+ return resolve(process.cwd(), process.env.SOCKET_PATH);
335
+ }
336
+ if (process.env.NOCOBASE_RUNNING_IN_DOCKER === 'true') {
337
+ return resolve(os.homedir(), '.nocobase', 'gateway.sock');
338
+ }
339
+ return resolve(process.cwd(), 'storage/gateway.sock');
340
+ }
341
+
342
+ function generatePm2Home() {
343
+ if (process.env.PM2_HOME) {
344
+ if (isAbsolute(process.env.PM2_HOME)) {
345
+ return process.env.PM2_HOME;
346
+ }
347
+ return resolve(process.cwd(), process.env.PM2_HOME);
348
+ }
349
+ if (process.env.NOCOBASE_RUNNING_IN_DOCKER === 'true') {
350
+ return resolve(os.homedir(), '.nocobase', 'pm2');
351
+ }
352
+ return resolve(process.cwd(), './storage/.pm2');
353
+ }
354
+
328
355
  exports.initEnv = function initEnv() {
329
356
  const env = {
330
357
  APP_ENV: 'development',
@@ -343,9 +370,9 @@ exports.initEnv = function initEnv() {
343
370
  MFSU_AD: 'none',
344
371
  MAKO_AD: 'none',
345
372
  WS_PATH: '/ws',
346
- SOCKET_PATH: 'storage/gateway.sock',
373
+ // PM2_HOME: generatePm2Home(),
374
+ // SOCKET_PATH: generateGatewayPath(),
347
375
  NODE_MODULES_PATH: resolve(process.cwd(), 'node_modules'),
348
- PM2_HOME: resolve(process.cwd(), './storage/.pm2'),
349
376
  PLUGIN_PACKAGE_PREFIX: '@nocobase/plugin-,@nocobase/plugin-sample-,@nocobase/preset-',
350
377
  SERVER_TSCONFIG_PATH: './tsconfig.server.json',
351
378
  PLAYWRIGHT_AUTH_FILE: resolve(process.cwd(), 'storage/playwright/.auth/admin.json'),
@@ -428,6 +455,11 @@ exports.initEnv = function initEnv() {
428
455
  `process.env.DB_TIMEZONE="${process.env.DB_TIMEZONE}" and process.env.TZ="${process.env.TZ}" are different`,
429
456
  );
430
457
  }
458
+
459
+ process.env.PM2_HOME = generatePm2Home();
460
+ process.env.SOCKET_PATH = generateGatewayPath();
461
+ fs.mkdirpSync(dirname(process.env.SOCKET_PATH), { force: true, recursive: true });
462
+ fs.mkdirpSync(process.env.PM2_HOME, { force: true, recursive: true });
431
463
  };
432
464
 
433
465
  exports.generatePlugins = function () {