aircitytype 1.1.5 → 1.1.7
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/aircity/index.d.ts +3 -2
- package/main.js +18 -25
- package/package.json +6 -3
package/aircity/index.d.ts
CHANGED
@@ -739,7 +739,7 @@ interface EditHelper {
|
|
739
739
|
start(fn?: () => void): void;
|
740
740
|
}
|
741
741
|
|
742
|
-
declare class
|
742
|
+
declare class FDAPITYPE {
|
743
743
|
tag: any;
|
744
744
|
coord: any;
|
745
745
|
constructor(a: any, b: any, c: any);
|
@@ -861,7 +861,8 @@ type EchartTool = {
|
|
861
861
|
|
862
862
|
declare var HostConfig: HOSTINFO;
|
863
863
|
declare var offline: boolean;
|
864
|
-
declare var __g:
|
864
|
+
declare var __g: FDAPITYPE;
|
865
|
+
declare var fdapi: FDAPITYPE;
|
865
866
|
declare var __player: { resize: () => void };
|
866
867
|
declare var tools: EchartTool;
|
867
868
|
declare var projectROOT: string;
|
package/main.js
CHANGED
@@ -3,7 +3,8 @@ console.log("start install!");
|
|
3
3
|
|
4
4
|
const fs = require("fs");
|
5
5
|
const fse = require("fs-extra");
|
6
|
-
const path = require(
|
6
|
+
const path = require("path");
|
7
|
+
const { parse } = require("jsonc-parser");
|
7
8
|
|
8
9
|
const source = "./node_modules/aircitytype/aircity";
|
9
10
|
const target = "./node_modules/@types/aircity";
|
@@ -31,21 +32,20 @@ fs.access(source, fs.constants.F_OK, (err) => {
|
|
31
32
|
}
|
32
33
|
});
|
33
34
|
|
34
|
-
|
35
35
|
// 定义JSON文件路径
|
36
|
-
const tsconfigPath = path.join(process.cwd(),
|
37
|
-
const jsconfigPath = path.join(process.cwd(),
|
36
|
+
const tsconfigPath = path.join(process.cwd(), "tsconfig.json");
|
37
|
+
const jsconfigPath = path.join(process.cwd(), "jsconfig.json");
|
38
38
|
|
39
39
|
// 函数用于检查文件是否存在并解析存在的那个文件
|
40
40
|
function checkAndParseConfigFiles(callback) {
|
41
41
|
const filesToCheck = [
|
42
|
-
{ path: tsconfigPath, name:
|
43
|
-
{ path: jsconfigPath, name:
|
42
|
+
{ path: tsconfigPath, name: "tsconfig.json" },
|
43
|
+
{ path: jsconfigPath, name: "jsconfig.json" },
|
44
44
|
];
|
45
45
|
|
46
46
|
function checkNextFile(index) {
|
47
47
|
if (index >= filesToCheck.length) {
|
48
|
-
console.log(
|
48
|
+
console.log("没有找到 tsconfig.json 或 jsconfig.json 文件");
|
49
49
|
return;
|
50
50
|
}
|
51
51
|
|
@@ -67,44 +67,40 @@ function checkAndParseConfigFiles(callback) {
|
|
67
67
|
|
68
68
|
// 解析并处理 JSON 文件
|
69
69
|
function parseJsonFile(filePath, callback) {
|
70
|
-
fs.readFile(filePath,
|
70
|
+
fs.readFile(filePath, "utf8", (err, data) => {
|
71
71
|
if (err) {
|
72
72
|
console.error(`读取 ${filePath} 文件时出错:`, err);
|
73
73
|
return;
|
74
74
|
}
|
75
75
|
|
76
|
-
console.log(data)
|
77
|
-
|
78
76
|
let jsonData;
|
79
77
|
try {
|
80
|
-
jsonData =
|
78
|
+
jsonData = parse(data);
|
81
79
|
} catch (parseErr) {
|
82
80
|
console.error(`解析 ${filePath} 文件时出错:`, parseErr);
|
83
81
|
return;
|
84
82
|
}
|
85
83
|
|
86
|
-
|
84
|
+
// 检查和修改配置
|
85
|
+
modifyCompilerOptions(jsonData);
|
87
86
|
|
88
|
-
|
89
|
-
modifyCompilerOptions(jsonData);
|
90
|
-
|
91
|
-
// 将修改后的 JSON 对象转换为字符串并写回文件
|
87
|
+
// 将修改后的 JSON 对象转换为字符串并写回文件
|
92
88
|
const updatedJsonString = JSON.stringify(jsonData, null, 2);
|
93
|
-
fs.writeFile(filePath, updatedJsonString,
|
89
|
+
fs.writeFile(filePath, updatedJsonString, "utf8", (writeErr) => {
|
94
90
|
if (writeErr) {
|
95
91
|
console.error(`写入 ${filePath} 文件时出错:`, writeErr);
|
96
92
|
return;
|
97
93
|
}
|
98
94
|
console.log(`${filePath} 文件已成功更新`);
|
99
|
-
|
95
|
+
|
100
96
|
// 执行回调函数(如果有)
|
101
|
-
if (callback && typeof callback ===
|
97
|
+
if (callback && typeof callback === "function") {
|
102
98
|
callback(jsonData, filePath);
|
103
99
|
}
|
104
100
|
});
|
105
101
|
|
106
102
|
// 执行回调函数(如果有)
|
107
|
-
if (callback && typeof callback ===
|
103
|
+
if (callback && typeof callback === "function") {
|
108
104
|
callback(jsonData, filePath);
|
109
105
|
}
|
110
106
|
});
|
@@ -116,7 +112,6 @@ checkAndParseConfigFiles((jsonData, filePath) => {
|
|
116
112
|
console.log(`完成解析 ${filePath}`);
|
117
113
|
});
|
118
114
|
|
119
|
-
|
120
115
|
// 修改 compilerOptions 中的 types 数组
|
121
116
|
function modifyCompilerOptions(jsonData) {
|
122
117
|
if (!jsonData.compilerOptions) {
|
@@ -130,12 +125,10 @@ function modifyCompilerOptions(jsonData) {
|
|
130
125
|
const typesArray = jsonData.compilerOptions.types;
|
131
126
|
|
132
127
|
// 如果 types 数组中没有 'aircity',则添加
|
133
|
-
if (!typesArray.includes(
|
134
|
-
typesArray.push(
|
128
|
+
if (!typesArray.includes("aircity")) {
|
129
|
+
typesArray.push("aircity");
|
135
130
|
console.log('已添加 "aircity" 到 types 数组');
|
136
131
|
} else {
|
137
132
|
console.log('"aircity" 已存在于 types 数组中');
|
138
133
|
}
|
139
134
|
}
|
140
|
-
|
141
|
-
|
package/package.json
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "aircitytype",
|
3
|
-
"description": "增加了
|
3
|
+
"description": "增加了fdapi",
|
4
4
|
"scripts": {
|
5
5
|
"test": "echo \"Error: no test specified\" && exit 1"
|
6
6
|
},
|
7
7
|
"keywords": [],
|
8
|
-
"author": "strex@qq.com",
|
8
|
+
"author": "strex@qq.com",
|
9
9
|
"license": "ISC",
|
10
10
|
"repository": {
|
11
11
|
"type": "git",
|
@@ -14,5 +14,8 @@
|
|
14
14
|
"bin": {
|
15
15
|
"installdts": "./main.js"
|
16
16
|
},
|
17
|
-
"
|
17
|
+
"dependencies": {
|
18
|
+
"jsonc-parser": "^3.3.1"
|
19
|
+
},
|
20
|
+
"version": "1.1.7"
|
18
21
|
}
|