glyphix 1.0.9 → 1.0.10
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/glyphix.js +81 -20
- package/package.json +2 -1
package/glyphix.js
CHANGED
|
@@ -108,6 +108,7 @@ function findGlyphixTools() {
|
|
|
108
108
|
}
|
|
109
109
|
function buildGlyphix(args) {
|
|
110
110
|
var _a, _b;
|
|
111
|
+
console.log(findGlyphixTools(), reconstructArgs(args));
|
|
111
112
|
const childProcess = (0, import_child_process2.execFile)(findGlyphixTools(), reconstructArgs(args), {
|
|
112
113
|
cwd: process.cwd()
|
|
113
114
|
});
|
|
@@ -117,6 +118,9 @@ function buildGlyphix(args) {
|
|
|
117
118
|
(_b = childProcess.stderr) == null ? void 0 : _b.on("data", (data) => {
|
|
118
119
|
console.error(data);
|
|
119
120
|
});
|
|
121
|
+
childProcess.on("error", (err) => {
|
|
122
|
+
console.error(err);
|
|
123
|
+
});
|
|
120
124
|
childProcess.on("exit", () => {
|
|
121
125
|
console.log("exit");
|
|
122
126
|
});
|
|
@@ -134,6 +138,32 @@ var import_eslint = require("eslint");
|
|
|
134
138
|
var import_glob = require("glob");
|
|
135
139
|
var import_chalk2 = __toESM(require("chalk"));
|
|
136
140
|
var import_node_process = require("process");
|
|
141
|
+
var import_dotenv = __toESM(require("dotenv"));
|
|
142
|
+
function loadEnv() {
|
|
143
|
+
const dotenvTags = [
|
|
144
|
+
// 本地环境
|
|
145
|
+
"development",
|
|
146
|
+
// 测试环境
|
|
147
|
+
// 比如:单元测试
|
|
148
|
+
"test",
|
|
149
|
+
// 部署环境
|
|
150
|
+
// 比如:日常、预发、线上
|
|
151
|
+
"production"
|
|
152
|
+
];
|
|
153
|
+
if (!dotenvTags.includes(process.env.GLYPHIX_ENV ?? "")) {
|
|
154
|
+
process.env.GLYPHIX_ENV = dotenvTags[0];
|
|
155
|
+
}
|
|
156
|
+
const dotenvPath = (0, import_node_path3.resolve)(".env");
|
|
157
|
+
const dotenvFiles = [
|
|
158
|
+
dotenvPath,
|
|
159
|
+
`${dotenvPath}.local`,
|
|
160
|
+
`${dotenvPath}.${process.env.GLYPHIX_ENV}`,
|
|
161
|
+
`${dotenvPath}.${process.env.GLYPHIX_ENV}.local`
|
|
162
|
+
].filter(import_node_fs.existsSync);
|
|
163
|
+
dotenvFiles.reverse().forEach((dotenvFile) => {
|
|
164
|
+
import_dotenv.default.config({ path: dotenvFile });
|
|
165
|
+
});
|
|
166
|
+
}
|
|
137
167
|
function getOriginFilePath(filePath, rootPath) {
|
|
138
168
|
const relativePath = (0, import_node_path3.relative)(rootPath, filePath);
|
|
139
169
|
const projectRoot = process.cwd();
|
|
@@ -195,15 +225,6 @@ function dealResource() {
|
|
|
195
225
|
const entries = entryFileContent.entry;
|
|
196
226
|
(0, import_fs_extra2.removeSync)((0, import_node_path3.resolve)(rootPath, ".vite-dist"));
|
|
197
227
|
let entriedFullPath = entries.map((item) => (0, import_node_path3.resolve)(rootPath, item));
|
|
198
|
-
entriedFullPath = entriedFullPath.map((item) => {
|
|
199
|
-
if ((0, import_node_fs.existsSync)(item)) {
|
|
200
|
-
const dest = item.replace(".js", ".ts");
|
|
201
|
-
if ((0, import_node_fs.existsSync)(dest)) (0, import_fs_extra2.removeSync)(dest);
|
|
202
|
-
(0, import_fs_extra2.moveSync)(item, dest);
|
|
203
|
-
return dest;
|
|
204
|
-
}
|
|
205
|
-
return item;
|
|
206
|
-
});
|
|
207
228
|
return {
|
|
208
229
|
root: rootPath,
|
|
209
230
|
entry: entriedFullPath
|
|
@@ -211,6 +232,11 @@ function dealResource() {
|
|
|
211
232
|
}
|
|
212
233
|
function build(rootPath, entriedFullPath) {
|
|
213
234
|
const resolveExtensions = [".ts", ".js"];
|
|
235
|
+
let envDefine = {};
|
|
236
|
+
Array.from(Object.keys(process.env)).forEach((key) => {
|
|
237
|
+
if (key.startsWith("GLYPHIX"))
|
|
238
|
+
envDefine[`process.env.${key}`] = JSON.stringify(process.env[key]);
|
|
239
|
+
});
|
|
214
240
|
import_esbuild.default.build({
|
|
215
241
|
entryPoints: entriedFullPath,
|
|
216
242
|
// 入口文件
|
|
@@ -228,6 +254,7 @@ function build(rootPath, entriedFullPath) {
|
|
|
228
254
|
platform: "node",
|
|
229
255
|
target: "node14",
|
|
230
256
|
// 目标平台设置为最新 ECMAScript
|
|
257
|
+
define: envDefine,
|
|
231
258
|
minify: process.env.GLYPHIX_ENV === "development" ? false : true,
|
|
232
259
|
plugins: [
|
|
233
260
|
{
|
|
@@ -265,6 +292,7 @@ function build(rootPath, entriedFullPath) {
|
|
|
265
292
|
}
|
|
266
293
|
function generateGlyphix() {
|
|
267
294
|
const config = dealResource();
|
|
295
|
+
loadEnv();
|
|
268
296
|
lintFile(config.root).then((res) => {
|
|
269
297
|
if (res.length) {
|
|
270
298
|
(0, import_node_process.exit)(1);
|
|
@@ -274,25 +302,58 @@ function generateGlyphix() {
|
|
|
274
302
|
}
|
|
275
303
|
|
|
276
304
|
// src/index.ts
|
|
277
|
-
import_yargs.default.
|
|
305
|
+
import_yargs.default.command("create", "create a glyphix project", {}, (args) => {
|
|
278
306
|
console.debug("create project", __dirname);
|
|
279
307
|
if (args._.length < 2) {
|
|
280
308
|
console.error("miss project name");
|
|
281
309
|
return;
|
|
282
310
|
}
|
|
283
311
|
createProject(process.cwd(), args._[1] + "");
|
|
284
|
-
}).command("generate", "compiler glyphix project", {}, generateGlyphix).command(
|
|
285
|
-
"
|
|
286
|
-
"
|
|
312
|
+
}).command("generate", "compiler glyphix project", {}, generateGlyphix).command(
|
|
313
|
+
"build",
|
|
314
|
+
"build glyphix project",
|
|
287
315
|
(yargs2) => {
|
|
288
|
-
return yargs2.
|
|
289
|
-
describe: "
|
|
290
|
-
type: "string"
|
|
291
|
-
|
|
292
|
-
|
|
316
|
+
return yargs2.options("device", {
|
|
317
|
+
describe: "The name of the device to use when building.\nThereafter, emulation and packaging will use this\nconfiguration.",
|
|
318
|
+
type: "string",
|
|
319
|
+
alias: "d"
|
|
320
|
+
}).options("emulator", {
|
|
321
|
+
describe: "Build packages for the emulator, not the target device",
|
|
322
|
+
type: "boolean",
|
|
323
|
+
alias: "e"
|
|
324
|
+
}).options("image-rules", {
|
|
325
|
+
describe: "Use the specified image rules description file\n(default is config/image-rules.json).",
|
|
326
|
+
type: "string",
|
|
327
|
+
alias: "r"
|
|
328
|
+
}).options("full", {
|
|
329
|
+
describe: "Rebuild all the files for the project.",
|
|
293
330
|
type: "string",
|
|
294
|
-
|
|
331
|
+
alias: "f"
|
|
332
|
+
}).options("dump", {
|
|
333
|
+
describe: "Dump details of the build process to aid debugging.",
|
|
334
|
+
type: "boolean"
|
|
295
335
|
}).help().argv;
|
|
296
336
|
},
|
|
297
337
|
buildGlyphix
|
|
298
|
-
).
|
|
338
|
+
).command("emu", "run emulator", (yargs2) => {
|
|
339
|
+
return yargs2.options("device", {
|
|
340
|
+
describe: "The name of the device to use when building,\nemulation and packaging.",
|
|
341
|
+
type: "string",
|
|
342
|
+
alias: "d",
|
|
343
|
+
demandOption: false
|
|
344
|
+
}).options("emulator-exe", {
|
|
345
|
+
describe: "Path to the glyphix-emu executable",
|
|
346
|
+
type: "string",
|
|
347
|
+
alias: "e",
|
|
348
|
+
normalize: true,
|
|
349
|
+
demandOption: false
|
|
350
|
+
}).options("language", {
|
|
351
|
+
describe: "Set the system language name. The default value is zh-CN.",
|
|
352
|
+
type: "string",
|
|
353
|
+
alias: "l"
|
|
354
|
+
}).options("inspector", {
|
|
355
|
+
describe: "Scale the window size to real device screen.",
|
|
356
|
+
type: "string",
|
|
357
|
+
alias: "l"
|
|
358
|
+
}).help().argv;
|
|
359
|
+
}).help().alias("help", "h").argv;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glyphix",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"adm-zip": "^0.5.16",
|
|
20
20
|
"chalk": "^4.1.2",
|
|
21
|
+
"dotenv": "^16.4.7",
|
|
21
22
|
"esbuild": "^0.24.2",
|
|
22
23
|
"eslint": "^9.18.0",
|
|
23
24
|
"fs-extra": "^11.2.0",
|