glyphix 1.1.0 → 1.2.0

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 (2) hide show
  1. package/bin/glyphix.js +57 -18
  2. package/package.json +1 -1
package/bin/glyphix.js CHANGED
@@ -118,7 +118,43 @@ var import_node_path3 = require("path");
118
118
  var import_node_fs = require("fs");
119
119
  var import_dotenv = __toESM(require("dotenv"));
120
120
  var import_node_child_process = require("child_process");
121
- var import_deepmerge = __toESM(require("deepmerge"));
121
+ function mergeEsbuildConfigs(...configs) {
122
+ const result = {};
123
+ for (const config of configs) {
124
+ for (const key in config) {
125
+ const value = config[key];
126
+ switch (key) {
127
+ case "entryPoints":
128
+ result.entryPoints = [
129
+ ...result.entryPoints || [],
130
+ ...Array.isArray(value) ? value : [value]
131
+ ];
132
+ break;
133
+ case "plugins":
134
+ result.plugins = [
135
+ ...result.plugins || [],
136
+ ...value || []
137
+ ];
138
+ break;
139
+ case "define":
140
+ case "loader":
141
+ case "alias":
142
+ case "banner":
143
+ case "footer":
144
+ case "inject":
145
+ result[key] = {
146
+ ...result[key] || {},
147
+ ...value
148
+ };
149
+ break;
150
+ default:
151
+ result[key] = value;
152
+ break;
153
+ }
154
+ }
155
+ }
156
+ return result;
157
+ }
122
158
  var GxGenerate = class {
123
159
  constructor() {
124
160
  // 执行 gx 命令的目录路径
@@ -199,7 +235,6 @@ var GxGenerate = class {
199
235
  target: "node14",
200
236
  // 目标平台设置为最新 ECMAScript
201
237
  define: {
202
- "process.env.GLYPHIX_APP_VERSION": `"${this.getGitVersion()}"`,
203
238
  ...this.loadEnv()
204
239
  },
205
240
  nodePaths: [(0, import_node_path3.resolve)(this.sourceRoot, "..", "node_modules")],
@@ -244,20 +279,31 @@ var GxGenerate = class {
244
279
  }
245
280
  ]
246
281
  };
247
- const customConfigPath = (0, import_node_path3.resolve)(
282
+ let customConfigPath = (0, import_node_path3.resolve)(
248
283
  this.sourceRoot,
249
284
  "..",
250
- "glyphix.config.js"
285
+ "glyphix.config.ts"
251
286
  );
252
- if (!(0, import_node_fs.existsSync)(customConfigPath)) return internalConfig;
287
+ if (!(0, import_node_fs.existsSync)(customConfigPath))
288
+ customConfigPath = (0, import_node_path3.resolve)(
289
+ this.sourceRoot,
290
+ "..",
291
+ "glyphix.config.js"
292
+ );
293
+ if (!(0, import_node_fs.existsSync)(customConfigPath))
294
+ return internalConfig;
253
295
  try {
296
+ if (customConfigPath.endsWith(".ts")) {
297
+ require("ts-node").register({
298
+ transpileOnly: true,
299
+ compilerOptions: {
300
+ module: "commonjs"
301
+ }
302
+ });
303
+ }
254
304
  const useConfig = require(customConfigPath);
255
- const a = (0, import_deepmerge.default)(internalConfig, useConfig, {
256
- arrayMerge: (targetArray, sourceArray) => [
257
- ...targetArray,
258
- ...sourceArray
259
- ]
260
- });
305
+ const a = mergeEsbuildConfigs(internalConfig, useConfig);
306
+ console.log(a.plugins);
261
307
  return a;
262
308
  } catch (error) {
263
309
  console.error(error);
@@ -302,13 +348,6 @@ var GxGenerate = class {
302
348
  });
303
349
  });
304
350
  }
305
- getGitVersion() {
306
- try {
307
- return (0, import_node_child_process.execSync)("git rev-parse HEAD").toString().trim();
308
- } catch (err) {
309
- return "not git version";
310
- }
311
- }
312
351
  build() {
313
352
  const curDir = process.cwd();
314
353
  this.installDependencies().then(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glyphix",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "types/index.d.ts",
6
6
  "files": [