autosnippet 3.2.21 → 3.3.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.
- package/dashboard/dist/assets/{icons-C1dUryS-.js → icons-BofcEZ3f.js} +1 -1
- package/dashboard/dist/assets/index-SiN1GChm.js +128 -0
- package/dashboard/dist/index.html +2 -2
- package/dist/bin/cli.d.ts +0 -1
- package/dist/bin/cli.js +0 -133
- package/dist/lib/cli/SetupService.d.ts +46 -2
- package/dist/lib/cli/SetupService.js +2 -27
- package/dist/lib/{platform/ios/spm → core/discovery}/SpmDiscoverer.d.ts +2 -5
- package/dist/lib/{platform/ios/spm → core/discovery}/SpmDiscoverer.js +159 -44
- package/dist/lib/core/discovery/index.d.ts +1 -1
- package/dist/lib/core/discovery/index.js +2 -2
- package/dist/lib/external/mcp/handlers/guard.js +6 -3
- package/dist/lib/http/HttpServer.js +0 -6
- package/dist/lib/http/routes/commands.d.ts +1 -1
- package/dist/lib/http/routes/commands.js +1 -66
- package/dist/lib/http/routes/remote.js +0 -5
- package/dist/lib/injection/ServiceMap.d.ts +0 -9
- package/dist/lib/injection/modules/AppModule.d.ts +2 -3
- package/dist/lib/injection/modules/AppModule.js +3 -30
- package/dist/lib/injection/modules/GuardModule.js +33 -1
- package/dist/lib/service/guard/GuardCheckEngine.d.ts +13 -1
- package/dist/lib/service/guard/GuardCheckEngine.js +44 -2
- package/dist/lib/service/module/ModuleService.js +3 -13
- package/dist/lib/service/search/SearchEngine.js +1 -1
- package/dist/lib/shared/constants.d.ts +0 -15
- package/dist/lib/shared/constants.js +0 -10
- package/dist/lib/shared/schemas/config.d.ts +4 -1
- package/dist/lib/shared/schemas/config.js +8 -1
- package/dist/scripts/release.js +2 -10
- package/package.json +4 -19
- package/dashboard/dist/assets/index-DdvZE4Yd.js +0 -128
- package/dist/lib/http/routes/snippets.d.ts +0 -6
- package/dist/lib/http/routes/snippets.js +0 -49
- package/dist/lib/platform/ClipboardManager.d.ts +0 -24
- package/dist/lib/platform/ClipboardManager.js +0 -142
- package/dist/lib/platform/NativeUi.d.ts +0 -53
- package/dist/lib/platform/NativeUi.js +0 -284
- package/dist/lib/platform/ios/index.d.ts +0 -38
- package/dist/lib/platform/ios/index.js +0 -42
- package/dist/lib/platform/ios/routes/spm.d.ts +0 -9
- package/dist/lib/platform/ios/routes/spm.js +0 -371
- package/dist/lib/platform/ios/snippet/PlaceholderConverter.d.ts +0 -21
- package/dist/lib/platform/ios/snippet/PlaceholderConverter.js +0 -48
- package/dist/lib/platform/ios/snippet/XcodeCodec.d.ts +0 -23
- package/dist/lib/platform/ios/snippet/XcodeCodec.js +0 -96
- package/dist/lib/platform/ios/spm/DependencyGraph.d.ts +0 -56
- package/dist/lib/platform/ios/spm/DependencyGraph.js +0 -195
- package/dist/lib/platform/ios/spm/PackageSwiftParser.d.ts +0 -69
- package/dist/lib/platform/ios/spm/PackageSwiftParser.js +0 -231
- package/dist/lib/platform/ios/spm/PathFinder.d.ts +0 -28
- package/dist/lib/platform/ios/spm/PathFinder.js +0 -117
- package/dist/lib/platform/ios/spm/PolicyEngine.d.ts +0 -44
- package/dist/lib/platform/ios/spm/PolicyEngine.js +0 -79
- package/dist/lib/platform/ios/spm/SpmHelper.d.ts +0 -102
- package/dist/lib/platform/ios/spm/SpmHelper.js +0 -464
- package/dist/lib/platform/ios/xcode/HeaderResolver.d.ts +0 -33
- package/dist/lib/platform/ios/xcode/HeaderResolver.js +0 -90
- package/dist/lib/platform/ios/xcode/SaveEventFilter.d.ts +0 -66
- package/dist/lib/platform/ios/xcode/SaveEventFilter.js +0 -142
- package/dist/lib/platform/ios/xcode/XcodeAutomation.d.ts +0 -71
- package/dist/lib/platform/ios/xcode/XcodeAutomation.js +0 -327
- package/dist/lib/platform/ios/xcode/XcodeImportResolver.d.ts +0 -130
- package/dist/lib/platform/ios/xcode/XcodeImportResolver.js +0 -404
- package/dist/lib/platform/ios/xcode/XcodeIntegration.d.ts +0 -89
- package/dist/lib/platform/ios/xcode/XcodeIntegration.js +0 -588
- package/dist/lib/platform/ios/xcode/XcodeWriteUtils.d.ts +0 -99
- package/dist/lib/platform/ios/xcode/XcodeWriteUtils.js +0 -190
- package/dist/lib/service/automation/ActionPipeline.d.ts +0 -34
- package/dist/lib/service/automation/ActionPipeline.js +0 -53
- package/dist/lib/service/automation/AutomationOrchestrator.d.ts +0 -86
- package/dist/lib/service/automation/AutomationOrchestrator.js +0 -57
- package/dist/lib/service/automation/ContextCollector.d.ts +0 -24
- package/dist/lib/service/automation/ContextCollector.js +0 -35
- package/dist/lib/service/automation/DirectiveDetector.d.ts +0 -51
- package/dist/lib/service/automation/DirectiveDetector.js +0 -112
- package/dist/lib/service/automation/FileWatcher.d.ts +0 -51
- package/dist/lib/service/automation/FileWatcher.js +0 -366
- package/dist/lib/service/automation/TriggerResolver.d.ts +0 -36
- package/dist/lib/service/automation/TriggerResolver.js +0 -62
- package/dist/lib/service/automation/handlers/AlinkHandler.d.ts +0 -7
- package/dist/lib/service/automation/handlers/AlinkHandler.js +0 -80
- package/dist/lib/service/automation/handlers/CreateHandler.d.ts +0 -11
- package/dist/lib/service/automation/handlers/CreateHandler.js +0 -170
- package/dist/lib/service/automation/handlers/GuardHandler.d.ts +0 -17
- package/dist/lib/service/automation/handlers/GuardHandler.js +0 -218
- package/dist/lib/service/automation/handlers/HeaderHandler.d.ts +0 -2
- package/dist/lib/service/automation/handlers/HeaderHandler.js +0 -32
- package/dist/lib/service/automation/handlers/SearchHandler.d.ts +0 -11
- package/dist/lib/service/automation/handlers/SearchHandler.js +0 -278
- package/dist/lib/service/snippet/SnippetFactory.d.ts +0 -101
- package/dist/lib/service/snippet/SnippetFactory.js +0 -145
- package/dist/lib/service/snippet/SnippetInstaller.d.ts +0 -91
- package/dist/lib/service/snippet/SnippetInstaller.js +0 -276
- package/dist/lib/service/snippet/codecs/SnippetCodec.d.ts +0 -44
- package/dist/lib/service/snippet/codecs/SnippetCodec.js +0 -35
- package/dist/lib/service/snippet/codecs/VSCodeCodec.d.ts +0 -27
- package/dist/lib/service/snippet/codecs/VSCodeCodec.js +0 -82
- package/dist/scripts/build-native-ui.d.ts +0 -3
- package/dist/scripts/build-native-ui.js +0 -62
- package/dist/scripts/init-snippets.d.ts +0 -30
- package/dist/scripts/init-snippets.js +0 -298
- package/dist/scripts/install-full.d.ts +0 -7
- package/dist/scripts/install-full.js +0 -38
- package/resources/native-ui/README.md +0 -29
- package/resources/native-ui/combined-window.swift +0 -494
- package/resources/native-ui/main.swift +0 -598
- package/scripts/postinstall-safe.mjs +0 -89
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Snippet 统一初始化脚本
|
|
4
|
-
*
|
|
5
|
-
* 为 AutoSnippet 生成快速触发 Snippet(ass/asc/asa)到目标 IDE:
|
|
6
|
-
* - Xcode: ~/Library/Developer/Xcode/UserData/CodeSnippets/*.codesnippet
|
|
7
|
-
* - VSCode: .vscode/autosnippet-triggers.code-snippets (项目级)
|
|
8
|
-
*
|
|
9
|
-
* 用法:
|
|
10
|
-
* node scripts/init-snippets.js [init|list|remove] [--target xcode|vscode|all]
|
|
11
|
-
* npm run init:snippets
|
|
12
|
-
*/
|
|
13
|
-
import { execSync } from 'node:child_process';
|
|
14
|
-
import fs from 'node:fs';
|
|
15
|
-
import os from 'node:os';
|
|
16
|
-
import path from 'node:path';
|
|
17
|
-
// ─── Trigger Snippet 定义 (IDE 无关) ─────────────────────
|
|
18
|
-
const TRIGGER_SNIPPETS = [
|
|
19
|
-
{
|
|
20
|
-
id: 'com.autosnippet.search.long',
|
|
21
|
-
shortcut: 'ass',
|
|
22
|
-
title: 'AutoSnippet: Search (Long)',
|
|
23
|
-
summary: 'Search and insert Recipe/Snippet from knowledge base',
|
|
24
|
-
xcodeContent: '// as:search <#keyword#>',
|
|
25
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: VSCode snippet placeholder syntax
|
|
26
|
-
vscodeBody: ['// as:search ${1:keyword}'],
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
id: 'com.autosnippet.create',
|
|
30
|
-
shortcut: 'asc',
|
|
31
|
-
title: 'AutoSnippet: Create Recipe',
|
|
32
|
-
summary: 'Create new Recipe (Dashboard or clipboard/file)',
|
|
33
|
-
xcodeContent: '// as:create <#-c or -f#>',
|
|
34
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: VSCode snippet placeholder syntax
|
|
35
|
-
vscodeBody: ['// as:create ${1:-c or -f}'],
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
id: 'com.autosnippet.audit',
|
|
39
|
-
shortcut: 'asa',
|
|
40
|
-
title: 'AutoSnippet: Audit Code',
|
|
41
|
-
summary: 'AI code review against knowledge base',
|
|
42
|
-
xcodeContent: '// as:audit <#keyword or scope (file/target/project)#>',
|
|
43
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: VSCode snippet placeholder syntax
|
|
44
|
-
vscodeBody: ['// as:audit ${1:keyword or scope (file/target/project)}'],
|
|
45
|
-
},
|
|
46
|
-
];
|
|
47
|
-
// ─── Xcode 初始化器 ─────────────────────
|
|
48
|
-
class XcodeInitializer {
|
|
49
|
-
snippetsDir;
|
|
50
|
-
constructor() {
|
|
51
|
-
this.snippetsDir = path.join(os.homedir(), 'Library/Developer/Xcode/UserData/CodeSnippets');
|
|
52
|
-
}
|
|
53
|
-
isAvailable() {
|
|
54
|
-
if (process.platform !== 'darwin') {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
try {
|
|
58
|
-
execSync('xcode-select -p', { stdio: 'ignore' });
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
ensureDir() {
|
|
66
|
-
if (!fs.existsSync(this.snippetsDir)) {
|
|
67
|
-
try {
|
|
68
|
-
fs.mkdirSync(this.snippetsDir, { recursive: true });
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
generatePlist(snippet) {
|
|
78
|
-
const escapeXml = (s) => String(s || '')
|
|
79
|
-
.replace(/&/g, '&')
|
|
80
|
-
.replace(/</g, '<')
|
|
81
|
-
.replace(/>/g, '>')
|
|
82
|
-
.replace(/"/g, '"')
|
|
83
|
-
.replace(/'/g, ''');
|
|
84
|
-
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
85
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
86
|
-
<plist version="1.0">
|
|
87
|
-
<dict>
|
|
88
|
-
<key>IDECodeSnippetCompletionPrefix</key>
|
|
89
|
-
<string>${escapeXml(snippet.shortcut)}</string>
|
|
90
|
-
<key>IDECodeSnippetCompletionScopes</key>
|
|
91
|
-
<array>
|
|
92
|
-
<string>All</string>
|
|
93
|
-
</array>
|
|
94
|
-
<key>IDECodeSnippetContents</key>
|
|
95
|
-
<string>${escapeXml(snippet.xcodeContent)}</string>
|
|
96
|
-
<key>IDECodeSnippetIdentifier</key>
|
|
97
|
-
<string>${escapeXml(snippet.id)}</string>
|
|
98
|
-
<key>IDECodeSnippetLanguage</key>
|
|
99
|
-
<string>Xcode.SourceCodeLanguage.Generic</string>
|
|
100
|
-
<key>IDECodeSnippetSummary</key>
|
|
101
|
-
<string>${escapeXml(snippet.summary)}</string>
|
|
102
|
-
<key>IDECodeSnippetTitle</key>
|
|
103
|
-
<string>${escapeXml(snippet.title)}</string>
|
|
104
|
-
<key>IDECodeSnippetUserSnippet</key>
|
|
105
|
-
<true/>
|
|
106
|
-
<key>IDECodeSnippetVersion</key>
|
|
107
|
-
<integer>2</integer>
|
|
108
|
-
</dict>
|
|
109
|
-
</plist>`;
|
|
110
|
-
}
|
|
111
|
-
init() {
|
|
112
|
-
if (!this.isAvailable()) {
|
|
113
|
-
return { skipped: true, reason: 'Xcode not available' };
|
|
114
|
-
}
|
|
115
|
-
if (!this.ensureDir()) {
|
|
116
|
-
return { skipped: true, reason: 'Cannot create snippets dir' };
|
|
117
|
-
}
|
|
118
|
-
let count = 0;
|
|
119
|
-
for (const snippet of TRIGGER_SNIPPETS) {
|
|
120
|
-
const filePath = path.join(this.snippetsDir, `${snippet.id}.codesnippet`);
|
|
121
|
-
fs.writeFileSync(filePath, this.generatePlist(snippet), 'utf-8');
|
|
122
|
-
count++;
|
|
123
|
-
}
|
|
124
|
-
return { success: true, count };
|
|
125
|
-
}
|
|
126
|
-
list() {
|
|
127
|
-
if (!fs.existsSync(this.snippetsDir)) {
|
|
128
|
-
return [];
|
|
129
|
-
}
|
|
130
|
-
return fs
|
|
131
|
-
.readdirSync(this.snippetsDir)
|
|
132
|
-
.filter((f) => f.startsWith('com.autosnippet') && f.endsWith('.codesnippet'));
|
|
133
|
-
}
|
|
134
|
-
remove() {
|
|
135
|
-
const files = this.list();
|
|
136
|
-
let removed = 0;
|
|
137
|
-
for (const f of files) {
|
|
138
|
-
try {
|
|
139
|
-
fs.unlinkSync(path.join(this.snippetsDir, f));
|
|
140
|
-
removed++;
|
|
141
|
-
}
|
|
142
|
-
catch {
|
|
143
|
-
/* ignore */
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return { removed };
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
// ─── VSCode 初始化器 ─────────────────────
|
|
150
|
-
class VSCodeInitializer {
|
|
151
|
-
filename;
|
|
152
|
-
projectRoot;
|
|
153
|
-
vscodeDir;
|
|
154
|
-
constructor(projectRoot) {
|
|
155
|
-
this.projectRoot = projectRoot || process.cwd();
|
|
156
|
-
this.vscodeDir = path.join(this.projectRoot, '.vscode');
|
|
157
|
-
this.filename = 'autosnippet-triggers.code-snippets';
|
|
158
|
-
}
|
|
159
|
-
isAvailable() {
|
|
160
|
-
// VSCode snippets 跨平台可用
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
ensureDir() {
|
|
164
|
-
if (!fs.existsSync(this.vscodeDir)) {
|
|
165
|
-
try {
|
|
166
|
-
fs.mkdirSync(this.vscodeDir, { recursive: true });
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
catch {
|
|
170
|
-
return false;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
init() {
|
|
176
|
-
if (!this.ensureDir()) {
|
|
177
|
-
return { skipped: true, reason: 'Cannot create .vscode dir' };
|
|
178
|
-
}
|
|
179
|
-
const bundle = {};
|
|
180
|
-
for (const snippet of TRIGGER_SNIPPETS) {
|
|
181
|
-
bundle[snippet.title] = {
|
|
182
|
-
prefix: snippet.shortcut,
|
|
183
|
-
body: snippet.vscodeBody,
|
|
184
|
-
description: snippet.summary,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
const filePath = path.join(this.vscodeDir, this.filename);
|
|
188
|
-
fs.writeFileSync(filePath, `${JSON.stringify(bundle, null, 2)}\n`, 'utf-8');
|
|
189
|
-
return { success: true, count: TRIGGER_SNIPPETS.length, path: filePath };
|
|
190
|
-
}
|
|
191
|
-
list() {
|
|
192
|
-
const filePath = path.join(this.vscodeDir, this.filename);
|
|
193
|
-
if (!fs.existsSync(filePath)) {
|
|
194
|
-
return [];
|
|
195
|
-
}
|
|
196
|
-
try {
|
|
197
|
-
const content = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
198
|
-
return Object.keys(content);
|
|
199
|
-
}
|
|
200
|
-
catch {
|
|
201
|
-
return [];
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
remove() {
|
|
205
|
-
const filePath = path.join(this.vscodeDir, this.filename);
|
|
206
|
-
if (fs.existsSync(filePath)) {
|
|
207
|
-
fs.unlinkSync(filePath);
|
|
208
|
-
return { removed: 1 };
|
|
209
|
-
}
|
|
210
|
-
return { removed: 0 };
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
// ─── 统一入口 ─────────────────────
|
|
214
|
-
export class SnippetInitializer {
|
|
215
|
-
vscode;
|
|
216
|
-
xcode;
|
|
217
|
-
constructor(projectRoot) {
|
|
218
|
-
this.xcode = new XcodeInitializer();
|
|
219
|
-
this.vscode = new VSCodeInitializer(projectRoot);
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* 初始化 snippet 到指定目标
|
|
223
|
-
* @param target — 'xcode' | 'vscode' | 'all'
|
|
224
|
-
* @returns }
|
|
225
|
-
*/
|
|
226
|
-
async initialize(target = 'all') {
|
|
227
|
-
const result = {};
|
|
228
|
-
if (target === 'all' || target === 'xcode') {
|
|
229
|
-
result.xcode = this.xcode.init();
|
|
230
|
-
}
|
|
231
|
-
if (target === 'all' || target === 'vscode') {
|
|
232
|
-
result.vscode = this.vscode.init();
|
|
233
|
-
}
|
|
234
|
-
return result;
|
|
235
|
-
}
|
|
236
|
-
list(target = 'all') {
|
|
237
|
-
const result = {};
|
|
238
|
-
if (target === 'all' || target === 'xcode') {
|
|
239
|
-
result.xcode = this.xcode.list();
|
|
240
|
-
}
|
|
241
|
-
if (target === 'all' || target === 'vscode') {
|
|
242
|
-
result.vscode = this.vscode.list();
|
|
243
|
-
}
|
|
244
|
-
return result;
|
|
245
|
-
}
|
|
246
|
-
remove(target = 'all') {
|
|
247
|
-
const result = {};
|
|
248
|
-
if (target === 'all' || target === 'xcode') {
|
|
249
|
-
result.xcode = this.xcode.remove();
|
|
250
|
-
}
|
|
251
|
-
if (target === 'all' || target === 'vscode') {
|
|
252
|
-
result.vscode = this.vscode.remove();
|
|
253
|
-
}
|
|
254
|
-
return result;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
// 导出供其他脚本使用
|
|
258
|
-
export default {
|
|
259
|
-
SnippetInitializer,
|
|
260
|
-
initialize: async (projectRoot, target) => {
|
|
261
|
-
const init = new SnippetInitializer(projectRoot);
|
|
262
|
-
return init.initialize(target);
|
|
263
|
-
},
|
|
264
|
-
};
|
|
265
|
-
// ─── CLI 入口 ─────────────────────
|
|
266
|
-
async function main() {
|
|
267
|
-
const args = process.argv.slice(2);
|
|
268
|
-
const command = args.find((a) => !a.startsWith('-')) || 'init';
|
|
269
|
-
const targetFlag = args.find((a) => a.startsWith('--target='));
|
|
270
|
-
const target = targetFlag ? targetFlag.split('=')[1] : 'all';
|
|
271
|
-
const init = new SnippetInitializer(process.cwd());
|
|
272
|
-
switch (command) {
|
|
273
|
-
case 'init': {
|
|
274
|
-
const _result = await init.initialize(target);
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
case 'list': {
|
|
278
|
-
const _result = init.list(target);
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
case 'remove': {
|
|
282
|
-
const _result = init.remove(target);
|
|
283
|
-
break;
|
|
284
|
-
}
|
|
285
|
-
case 'help':
|
|
286
|
-
break;
|
|
287
|
-
default:
|
|
288
|
-
console.error(`Unknown command: ${command}`);
|
|
289
|
-
process.exit(1);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
const isMain = process.argv[1] && import.meta.url === `file://${process.argv[1]}`;
|
|
293
|
-
if (isMain) {
|
|
294
|
-
main().catch((err) => {
|
|
295
|
-
console.error('❌ 初始化失败:', err.message);
|
|
296
|
-
process.exit(1);
|
|
297
|
-
});
|
|
298
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* 全量安装 / 按需安装:统一入口
|
|
4
|
-
* asd install:full - 核心 + 可选依赖 + Dashboard
|
|
5
|
-
* asd install:full --parser - 上述 + Swift 解析器
|
|
6
|
-
*/
|
|
7
|
-
const __dirname = import.meta.dirname;
|
|
8
|
-
import { execSync } from 'node:child_process';
|
|
9
|
-
import fs from 'node:fs';
|
|
10
|
-
import path from 'node:path';
|
|
11
|
-
import { PACKAGE_ROOT } from '../lib/shared/package-root.js';
|
|
12
|
-
const rootDir = PACKAGE_ROOT;
|
|
13
|
-
const withParser = process.env.ASD_INSTALL_PARSER === '1' || process.env.ASD_INSTALL_PARSER === 'true';
|
|
14
|
-
const withNativeUi = process.env.ASD_INSTALL_NATIVE_UI === '1' || process.env.ASD_INSTALL_NATIVE_UI === 'true';
|
|
15
|
-
const dashboardDist = path.join(rootDir, 'dashboard', 'dist');
|
|
16
|
-
execSync('npm install', { cwd: rootDir, stdio: 'inherit' });
|
|
17
|
-
// 2. Dashboard(仅当前端不存在时安装并构建)
|
|
18
|
-
if (!fs.existsSync(dashboardDist)) {
|
|
19
|
-
const dashboardDir = path.join(rootDir, 'dashboard');
|
|
20
|
-
execSync('npm install', { cwd: dashboardDir, stdio: 'inherit' });
|
|
21
|
-
execSync('npm run build:dashboard', { cwd: rootDir, stdio: 'inherit' });
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
}
|
|
25
|
-
// 3. ParsePackage / Native UI(可选)
|
|
26
|
-
if (withParser) {
|
|
27
|
-
execSync('npm run build:parser', { cwd: rootDir, stdio: 'inherit' });
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
}
|
|
31
|
-
if (withNativeUi || process.platform === 'darwin') {
|
|
32
|
-
try {
|
|
33
|
-
await import('./build-native-ui.js');
|
|
34
|
-
}
|
|
35
|
-
catch (_) { }
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# Native UI Helper (macOS)
|
|
2
|
-
|
|
3
|
-
为 AutoSnippet 提供高级原生弹窗交互,解决 Xcode 无内置终端的问题。
|
|
4
|
-
|
|
5
|
-
## 构建
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm run build:native-ui
|
|
9
|
-
# 或
|
|
10
|
-
swiftc resources/native-ui/main.swift -o resources/native-ui/native-ui -framework AppKit
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
`asd install:full` 在 macOS 上会自动构建。
|
|
14
|
-
|
|
15
|
-
## 用法
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
# 列表选择(返回选中的索引,stdout 输出 0-based 数字)
|
|
19
|
-
./resources/native-ui/native-ui list "选项1" "选项2" "选项3"
|
|
20
|
-
|
|
21
|
-
# 预览确认(展示代码块,用户确认后 exit 0)
|
|
22
|
-
./resources/native-ui/native-ui preview "标题" "代码内容"
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## 集成
|
|
26
|
-
|
|
27
|
-
- `lib/infra/nativeUi.js` 默认优先使用 Swift Helper 高级弹窗
|
|
28
|
-
- 未构建时回退到 AppleScript (`osascript`) 或 `inquirer`,并提示 `npm run build:native-ui`
|
|
29
|
-
- 强制使用 AppleScript(如弹窗无响应时):`ASD_USE_APPLESCRIPT=1`
|