@ray-js/cli 1.3.0-beta.2-beta-2 → 1.3.0-beta.3

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/lib/API.js CHANGED
@@ -59,13 +59,20 @@ class API {
59
59
  }
60
60
  loadPlugin() {
61
61
  this.config.plugins
62
- .concat(['@ray-js/build-plugin-router', '@ray-js/build-plugin-ray'])
62
+ .concat([
63
+ '@ray-js/build-plugin-router',
64
+ '@ray-js/build-plugin-ray',
65
+ '@ray-js/ray/plugins/i18n-plugin',
66
+ ])
63
67
  .forEach((p) => {
64
68
  this.addPlugin(p);
65
69
  });
66
70
  }
67
71
  addPlugin(plugin) {
68
72
  if (typeof plugin === 'string') {
73
+ if (plugin.startsWith('ray')) {
74
+ plugin = `@ray-js/${plugin}`;
75
+ }
69
76
  plugin = requirePlugin(plugin);
70
77
  }
71
78
  const _p = typeof plugin === 'function' ? plugin(this) : plugin;
@@ -8,17 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
13
  };
@@ -26,32 +15,66 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
15
  exports.runBuilder = void 0;
27
16
  const builder_mp_1 = require("@ray-js/builder-mp");
28
17
  const builder_web_1 = require("@ray-js/builder-web");
18
+ const shared_1 = require("@ray-js/shared");
19
+ const colors_1 = __importDefault(require("colors"));
29
20
  const API_1 = __importDefault(require("./API"));
21
+ colors_1.default.enable();
22
+ const defaultCompileOptions = {
23
+ cwd: process.cwd(),
24
+ source: 'src',
25
+ mode: 'development',
26
+ watch: false,
27
+ target: 'wechat',
28
+ mini: false,
29
+ analyze: false,
30
+ devtools: false,
31
+ debug: false,
32
+ output: 'dist',
33
+ };
30
34
  function runBuilder(options) {
31
35
  return __awaiter(this, void 0, void 0, function* () {
32
36
  const api = new API_1.default(options);
33
- const { type = 'app' } = options, opts = __rest(options
34
- // 加载ray.config.ts 或 ray.config.js
35
- , ["type"]);
36
37
  // 加载ray.config.ts 或 ray.config.js
37
38
  api.loadConfig();
39
+ const finalOpts = Object.assign({}, defaultCompileOptions, api.config, options);
40
+ // 从配置文件中注入运行时参数
41
+ if (finalOpts.debug) {
42
+ process.env.REMAX_DEBUG = JSON.stringify(true);
43
+ }
44
+ else {
45
+ delete process.env.REMAX_DEBUG;
46
+ }
47
+ const { cwd, target, output, onTargetDir } = finalOpts;
48
+ /**
49
+ * 又是历史原因
50
+ * 因老项目生成的产物目录是tuya,所以就干脆是tuya,不然会出现既 tuya 又 thing 的目录
51
+ * 将开发整懵逼
52
+ */
53
+ const dist = target === 'thing' ? 'tuya' : target;
54
+ // 默认产物会编译到目录${output}/${target}下
55
+ // 某些情况下需要直接编译到 ${output}/下
56
+ // onTargetDir 提供一个修改 output 的方法
57
+ const outputPath = (0, shared_1.resolvePath)(typeof onTargetDir === 'function' ? [onTargetDir(output, dist)] : [output, dist], { cwd });
58
+ finalOpts.output = outputPath;
59
+ api.options = finalOpts;
60
+ shared_1.log.verbose('ray-builder', `final options:`, finalOpts);
38
61
  // 加载插件,插件可以是插件的模块路径
39
62
  api.loadPlugin();
40
63
  // 初始化插件,即执行插件plugin.setup()方法
41
64
  api.callPluginMethod('setup');
42
65
  const ctx = { api };
43
- switch (opts.target) {
66
+ switch (finalOpts.target) {
44
67
  // @ts-ignore
45
68
  case 'tuya':
46
69
  case 'wechat':
47
70
  case 'thing':
48
- yield (0, builder_mp_1.build)(opts, ctx);
71
+ yield (0, builder_mp_1.build)(finalOpts, ctx);
49
72
  break;
50
73
  case 'web':
51
- yield (0, builder_web_1.build)(opts, ctx);
74
+ yield (0, builder_web_1.build)(finalOpts, ctx);
52
75
  break;
53
76
  default:
54
- throw new Error(`Target '${opts.target}' is not supported.'`);
77
+ throw new Error(`Target '${finalOpts.target}' is not supported.'`);
55
78
  }
56
79
  });
57
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/cli",
3
- "version": "1.3.0-beta.2-beta-2",
3
+ "version": "1.3.0-beta.3",
4
4
  "description": "Ray cli",
5
5
  "bin": {
6
6
  "ray": "./bin/ray"
@@ -24,13 +24,13 @@
24
24
  "watch": "tsc -p ./tsconfig.build.json --watch"
25
25
  },
26
26
  "dependencies": {
27
- "@ray-js/build-plugin-ray": "^1.3.0-beta.2-beta-2",
28
- "@ray-js/build-plugin-router": "^1.3.0-beta.2-beta-2",
29
- "@ray-js/builder-component": "^1.3.0-beta.2-beta-2",
30
- "@ray-js/builder-mp": "^1.3.0-beta.2-beta-2",
31
- "@ray-js/builder-web": "^1.3.0-beta.2-beta-2",
32
- "@ray-js/shared": "^1.3.0-beta.2-beta-2",
33
- "@ray-js/types": "^1.3.0-beta.2-beta-2",
27
+ "@ray-js/build-plugin-ray": "^1.3.0-beta.3",
28
+ "@ray-js/build-plugin-router": "^1.3.0-beta.3",
29
+ "@ray-js/builder-component": "^1.3.0-beta.3",
30
+ "@ray-js/builder-mp": "^1.3.0-beta.3",
31
+ "@ray-js/builder-web": "^1.3.0-beta.3",
32
+ "@ray-js/shared": "^1.3.0-beta.3",
33
+ "@ray-js/types": "^1.3.0-beta.3",
34
34
  "colors": "1.4.0",
35
35
  "commander": "^8.2.0",
36
36
  "webpack-chain": "^6.5.1"
@@ -41,6 +41,6 @@
41
41
  "email": "tuyafe@tuya.com"
42
42
  }
43
43
  ],
44
- "gitHead": "067ce2e382196cd995ebc4774fc5e977ac21115c",
44
+ "gitHead": "be72a5dad6214ebf9c6653df02956374c735c98e",
45
45
  "repository": {}
46
46
  }