deeke-script-app 1.9.1 → 1.9.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/@deekeScript/@type/interface/System.d.ts +10 -0
- package/jsconfig.json +18 -4
- package/package.json +1 -1
- package/update-types.js +82 -63
|
@@ -127,6 +127,16 @@ interface System {
|
|
|
127
127
|
* @param keepOn 是否保持屏幕常亮
|
|
128
128
|
*/
|
|
129
129
|
public setKeepScreenOn(keepOn: boolean): void;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 获取当前系统区域与语言信息(配置中的首个 Locale)
|
|
133
|
+
* @returns language 为语言码;country 为国家/地区码;tag 为 BCP 47 标签(如 zh-CN)
|
|
134
|
+
*/
|
|
135
|
+
public getLocaleInfo(): {
|
|
136
|
+
language: string;
|
|
137
|
+
country: string;
|
|
138
|
+
tag: string;
|
|
139
|
+
};
|
|
130
140
|
}
|
|
131
141
|
|
|
132
142
|
export { };
|
package/jsconfig.json
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES6",
|
|
4
|
-
"lib": [
|
|
5
|
-
|
|
4
|
+
"lib": [
|
|
5
|
+
"es2016",
|
|
6
|
+
],
|
|
7
|
+
"checkJs": true,
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
"module": "commonjs",
|
|
10
|
+
"moduleResolution": "node10",
|
|
11
|
+
"types": [
|
|
12
|
+
"node"
|
|
13
|
+
],
|
|
14
|
+
"ignoreDeprecations": "6.0",
|
|
15
|
+
"baseUrl": ".",
|
|
16
|
+
"paths": {
|
|
17
|
+
"app/*": [
|
|
18
|
+
"app/*"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
6
21
|
},
|
|
7
22
|
"include": [
|
|
8
|
-
"
|
|
9
|
-
"test/**/*",
|
|
23
|
+
"**/*",
|
|
10
24
|
"@deekeScript/**/*"
|
|
11
25
|
]
|
|
12
26
|
}
|
package/package.json
CHANGED
package/update-types.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const os = require('os');
|
|
3
4
|
const { execSync } = require('child_process');
|
|
4
5
|
|
|
5
6
|
const PROJECT_ROOT = __dirname;
|
|
6
7
|
const TYPES_FOLDER = path.join(PROJECT_ROOT, '@deekeScript');
|
|
7
|
-
|
|
8
|
+
/** 旧版脚本使用的临时目录,仅用于清理遗留 */
|
|
9
|
+
const LEGACY_TEMP_DIR = path.join(PROJECT_ROOT, '.temp-update');
|
|
8
10
|
const PACKAGE_NAME = 'deeke-script-app';
|
|
9
11
|
|
|
12
|
+
const ROOT_FILES_FROM_PACKAGE = [
|
|
13
|
+
{ name: 'deekeScript.schema.json', required: false },
|
|
14
|
+
{ name: 'update-types.js', required: false }
|
|
15
|
+
];
|
|
16
|
+
|
|
10
17
|
// 颜色输出
|
|
11
18
|
const colors = {
|
|
12
19
|
reset: '\x1b[0m',
|
|
@@ -21,98 +28,110 @@ function log(message, color = 'reset') {
|
|
|
21
28
|
console.log(`${colors[color]}${message}${colors.reset}`);
|
|
22
29
|
}
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
function cleanupLegacyTemp() {
|
|
32
|
+
if (fs.existsSync(LEGACY_TEMP_DIR)) {
|
|
33
|
+
fs.rmSync(LEGACY_TEMP_DIR, { recursive: true, force: true });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function removeDir(dir) {
|
|
38
|
+
if (dir && fs.existsSync(dir)) {
|
|
39
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
28
40
|
}
|
|
29
41
|
}
|
|
30
42
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
/**
|
|
44
|
+
* 使用 npm pack + 解压 tarball 获取包内容,避免在项目内 npm install
|
|
45
|
+
* 触发 deeke-script-app 的 postinstall(init),从而把文件写到错误目录。
|
|
46
|
+
*/
|
|
47
|
+
function updateFromNpm() {
|
|
48
|
+
log('\n📦 从 npm 拉取包并更新类型与相关文件...', 'cyan');
|
|
49
|
+
|
|
50
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'deeke-types-'));
|
|
51
|
+
|
|
35
52
|
try {
|
|
36
|
-
|
|
37
|
-
log('检查npm包版本...', 'blue');
|
|
53
|
+
log('检查 npm 包版本...', 'blue');
|
|
38
54
|
const latestVersion = execSync(`npm view ${PACKAGE_NAME} version`, { encoding: 'utf-8' }).trim();
|
|
39
55
|
log(`最新版本: ${latestVersion}`, 'green');
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
56
|
+
|
|
57
|
+
log('下载包(npm pack,不执行安装脚本)...', 'blue');
|
|
58
|
+
const packOutput = execSync(`npm pack ${PACKAGE_NAME}@${latestVersion}`, {
|
|
59
|
+
cwd: tempDir,
|
|
60
|
+
encoding: 'utf-8',
|
|
61
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
62
|
+
}).trim();
|
|
63
|
+
const tgzLine = packOutput.split(/\r?\n/).filter(Boolean).pop();
|
|
64
|
+
if (!tgzLine) {
|
|
65
|
+
throw new Error('npm pack 未返回 tarball 文件名');
|
|
44
66
|
}
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
dependencies: {
|
|
55
|
-
[PACKAGE_NAME]: 'latest'
|
|
56
|
-
}
|
|
57
|
-
}, null, 2));
|
|
58
|
-
|
|
59
|
-
execSync('npm install', {
|
|
60
|
-
cwd: TEMP_DIR,
|
|
61
|
-
stdio: 'pipe',
|
|
62
|
-
env: { ...process.env, npm_config_progress: 'false' }
|
|
67
|
+
const tgzName = path.basename(tgzLine.trim());
|
|
68
|
+
const tgzPath = path.join(tempDir, tgzName);
|
|
69
|
+
if (!fs.existsSync(tgzPath)) {
|
|
70
|
+
throw new Error(`未找到 tarball: ${tgzPath}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
execSync(`tar -xzf ${JSON.stringify(tgzName)}`, {
|
|
74
|
+
cwd: tempDir,
|
|
75
|
+
stdio: 'pipe'
|
|
63
76
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
|
|
78
|
+
const packRoot = path.join(tempDir, 'package');
|
|
79
|
+
if (!fs.existsSync(packRoot)) {
|
|
80
|
+
throw new Error('解压后未找到 package 目录(npm 包结构异常)');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const sourceTypesFolder = path.join(packRoot, '@deekeScript');
|
|
67
84
|
if (!fs.existsSync(sourceTypesFolder)) {
|
|
68
|
-
throw new Error('npm
|
|
85
|
+
throw new Error('npm 包中未找到 @deekeScript 文件夹');
|
|
69
86
|
}
|
|
70
|
-
|
|
71
|
-
// 备份现有文件夹
|
|
87
|
+
|
|
72
88
|
if (fs.existsSync(TYPES_FOLDER)) {
|
|
73
|
-
log('
|
|
89
|
+
log('备份现有类型定义...', 'yellow');
|
|
74
90
|
const backupFolder = path.join(PROJECT_ROOT, '@deekeScript.backup');
|
|
75
|
-
|
|
76
|
-
fs.rmSync(backupFolder, { recursive: true, force: true });
|
|
77
|
-
}
|
|
91
|
+
removeDir(backupFolder);
|
|
78
92
|
fs.cpSync(TYPES_FOLDER, backupFolder, { recursive: true });
|
|
79
93
|
}
|
|
80
|
-
|
|
81
|
-
// 删除旧文件夹并复制新文件夹
|
|
94
|
+
|
|
82
95
|
if (fs.existsSync(TYPES_FOLDER)) {
|
|
83
96
|
fs.rmSync(TYPES_FOLDER, { recursive: true, force: true });
|
|
84
97
|
}
|
|
85
98
|
fs.cpSync(sourceTypesFolder, TYPES_FOLDER, { recursive: true });
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
log('✅ 已更新 @deekeScript', 'green');
|
|
100
|
+
|
|
101
|
+
for (const { name, required } of ROOT_FILES_FROM_PACKAGE) {
|
|
102
|
+
const src = path.join(packRoot, name);
|
|
103
|
+
const dest = path.join(PROJECT_ROOT, name);
|
|
104
|
+
if (fs.existsSync(src)) {
|
|
105
|
+
fs.copyFileSync(src, dest);
|
|
106
|
+
log(`✅ 已更新 ${name}`, 'green');
|
|
107
|
+
} else if (required) {
|
|
108
|
+
throw new Error(`npm 包中未找到必需文件: ${name}`);
|
|
109
|
+
} else {
|
|
110
|
+
log(`⚠️ 包中暂无 ${name},跳过(发布包含该文件后即可同步)`, 'yellow');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
log(`已同步自 registry 版本: ${latestVersion}`, 'green');
|
|
115
|
+
} finally {
|
|
116
|
+
removeDir(tempDir);
|
|
93
117
|
}
|
|
94
118
|
}
|
|
95
119
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
120
|
+
function main() {
|
|
121
|
+
log('🚀 开始从远程包更新 @deekeScript 等文件...', 'cyan');
|
|
122
|
+
|
|
100
123
|
try {
|
|
101
|
-
// 确保在项目根目录
|
|
102
124
|
if (!fs.existsSync(path.join(PROJECT_ROOT, 'package.json'))) {
|
|
103
125
|
throw new Error('请在项目根目录运行此脚本');
|
|
104
126
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
127
|
+
|
|
128
|
+
updateFromNpm();
|
|
108
129
|
} catch (error) {
|
|
109
130
|
log(`\n❌ 更新失败: ${error.message}`, 'red');
|
|
110
131
|
process.exit(1);
|
|
111
132
|
} finally {
|
|
112
|
-
|
|
113
|
-
cleanup();
|
|
133
|
+
cleanupLegacyTemp();
|
|
114
134
|
}
|
|
115
135
|
}
|
|
116
136
|
|
|
117
|
-
// 运行主函数
|
|
118
137
|
main();
|