@nocobase/cli-v1 2.1.0-beta.35 → 2.1.0-beta.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli-v1",
3
- "version": "2.1.0-beta.35",
3
+ "version": "2.1.0-beta.36",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./src/index.js",
@@ -8,9 +8,9 @@
8
8
  "nocobase-v1": "./bin/index.js"
9
9
  },
10
10
  "dependencies": {
11
- "@nocobase/cli": "2.1.0-beta.35",
11
+ "@nocobase/cli": "2.1.0-beta.36",
12
12
  "@nocobase/license-kit": "^0.3.8",
13
- "@nocobase/utils": "2.1.0-beta.35",
13
+ "@nocobase/utils": "2.1.0-beta.36",
14
14
  "chalk": "^4.1.1",
15
15
  "commander": "^9.2.0",
16
16
  "deepmerge": "^4.3.1",
@@ -25,7 +25,7 @@
25
25
  "tree-kill": "^1.2.2"
26
26
  },
27
27
  "devDependencies": {
28
- "@nocobase/devtools": "2.1.0-beta.35",
28
+ "@nocobase/devtools": "2.1.0-beta.36",
29
29
  "@types/fs-extra": "^11.0.1"
30
30
  },
31
31
  "repository": {
@@ -33,5 +33,5 @@
33
33
  "url": "git+https://github.com/nocobase/nocobase.git",
34
34
  "directory": "packages/core/cli"
35
35
  },
36
- "gitHead": "74310d8b9e9581fcde14b5a93d12b41ddb5bb325"
36
+ "gitHead": "397d45c744f6eb48b3a0cd785c87cbf1257c3513"
37
37
  }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ /* eslint-env jest */
11
+
12
+ const path = require('path');
13
+ const { PluginGenerator } = require('../plugin-generator');
14
+
15
+ describe('cli-v1 plugin generator', () => {
16
+ test('uses cwd as baseDir when baseDir is not provided', () => {
17
+ const cwd = path.resolve('/tmp/nocobase-plugin-generator');
18
+ const generator = new PluginGenerator({
19
+ cwd,
20
+ args: {},
21
+ context: {
22
+ name: '@nocobase/plugin-demo',
23
+ },
24
+ });
25
+
26
+ expect(generator.baseDir).toBe(cwd);
27
+ });
28
+
29
+ test('prefers explicit baseDir over cwd', () => {
30
+ const baseDir = path.resolve('/tmp/nocobase-plugin-generator-base');
31
+ const cwd = path.resolve('/tmp/nocobase-plugin-generator-cwd');
32
+ const generator = new PluginGenerator({
33
+ baseDir,
34
+ cwd,
35
+ args: {},
36
+ context: {
37
+ name: '@nocobase/plugin-demo',
38
+ },
39
+ });
40
+
41
+ expect(generator.baseDir).toBe(baseDir);
42
+ });
43
+ });
@@ -38,8 +38,11 @@ async function getProjectVersion() {
38
38
 
39
39
  class PluginGenerator extends Generator {
40
40
  constructor(options) {
41
- const { log, context = {}, ...opts } = options;
42
- super(opts);
41
+ const { log, context = {}, cwd, baseDir, ...opts } = options;
42
+ super({
43
+ ...opts,
44
+ baseDir: baseDir || cwd || process.cwd(),
45
+ });
43
46
  this.context = context;
44
47
  this.log = log || console.log;
45
48
  }
package/src/util.js CHANGED
@@ -521,6 +521,7 @@ exports.initEnv = function initEnv() {
521
521
  // PM2_HOME: generatePm2Home(),
522
522
  // SOCKET_PATH: generateGatewayPath(),
523
523
  NODE_MODULES_PATH: resolve(process.cwd(), 'node_modules'),
524
+ NODE_PATH: resolve(process.cwd(), 'node_modules'),
524
525
  PLUGIN_PACKAGE_PREFIX: '@nocobase/plugin-,@nocobase/plugin-sample-,@nocobase/preset-',
525
526
  SERVER_TSCONFIG_PATH: './tsconfig.server.json',
526
527
  CACHE_DEFAULT_STORE: 'memory',