autosnippet 1.1.15 → 1.1.17

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/bin/asnip.js CHANGED
@@ -176,10 +176,17 @@ commander
176
176
  commander
177
177
  .command('i')
178
178
  .description('add the shared Snippet to the Xcode environment')
179
- .action(() => {
180
- getSpecFile(function (specFile) {
181
- install.addCodeSnippets(specFile);
182
- });
179
+ .action(async () => {
180
+ // 使用异步版本查找配置文件
181
+ const specFile = await findPath.findASSpecPathAsync(CMD_PATH);
182
+ if (!specFile) {
183
+ console.error('未找到 AutoSnippet.boxspec.json 配置文件');
184
+ return;
185
+ }
186
+ // ✅ 先聚合子模块配置到主配置文件
187
+ await init.mergeSubSpecs(specFile);
188
+ // 然后安装 snippets
189
+ install.addCodeSnippets(specFile);
183
190
  });
184
191
 
185
192
  commander
package/bin/cache.js CHANGED
@@ -41,11 +41,12 @@ async function updateCache(specFile, content) {
41
41
  linkCache[key] = element['{readme}'];
42
42
  }
43
43
 
44
+ // ✅ SPM 模块:headName 已经包含相对路径,不需要 specHeadPath
44
45
  if (element['{headName}']
45
- && element['{specHeadPath}']
46
46
  && element['{language}'] !== 'Xcode.SourceCodeLanguage.Swift') {
47
-
48
- headCache[element['{headName}']] = element['{specHeadPath}'];
47
+ // headName 本身已经是相对路径,直接使用
48
+ const headerFileName = path.basename(element['{headName}']);
49
+ headCache[headerFileName] = element['{headName}'];
49
50
  }
50
51
  }
51
52
  });
package/bin/create.js CHANGED
@@ -13,23 +13,32 @@ const CMD_PATH = process.cwd();
13
13
 
14
14
  /**
15
15
  * 根据文件路径确定模块名(SPM)
16
+ * 返回路径中最近的(最深的)target 名称
16
17
  */
17
18
  function determineModuleName(filePath, packageInfo) {
18
19
  // 从路径中提取模块名
19
- // 例如:Services/Services/BDNetworkControl/Code/... -> BDNetworkControl
20
+ // 例如:Business/BDNetworkAPI/Code/... -> BDNetworkAPI(不是 Business)
20
21
  const packagePath = packageInfo.path;
21
22
  const relativePath = path.relative(packagePath, filePath);
22
23
  const segments = relativePath.split(path.sep);
23
24
 
24
- // 查找匹配的 target
25
- for (const segment of segments) {
25
+ // 从后向前查找匹配的 target(优先匹配路径中更深的 target)
26
+ // 这样可以避免匹配到聚合 target(如 Business),而匹配到实际的 target(如 BDNetworkAPI)
27
+ for (let i = segments.length - 1; i >= 0; i--) {
28
+ const segment = segments[i];
26
29
  if (packageInfo.targets.includes(segment)) {
27
30
  return segment;
28
31
  }
29
32
  }
30
33
 
31
- // 如果找不到,使用第一个 target
32
- return packageInfo.targets[0] || packageInfo.name;
34
+ // 如果找不到,使用第一个 target(排除包名,如果包名也是 target)
35
+ const firstTarget = packageInfo.targets[0];
36
+ if (firstTarget && firstTarget !== packageInfo.name) {
37
+ return firstTarget;
38
+ }
39
+
40
+ // 最后回退到包名
41
+ return packageInfo.name;
33
42
  }
34
43
 
35
44
  function updateCodeSnippets(specFile, word, key, value) {
@@ -234,7 +243,9 @@ function readStream(specFile, filePathArr, snippet, isHaveHeader) {
234
243
  if (!packagePath) {
235
244
  console.log('未找到 Package.swift 文件,请检查路径。');
236
245
  snippet['{content}'] = codeList;
237
- saveFromFile(specFile, snippet);
246
+ // ✅ SPM 模块:.boxspec 文件位置在模块根目录(与 Package.swift 同级)
247
+ const moduleSpecFile = path.join(path.dirname(packagePath), 'AutoSnippet.boxspec.json');
248
+ saveFromFile(moduleSpecFile, snippet);
238
249
  return;
239
250
  }
240
251
 
@@ -242,41 +253,51 @@ function readStream(specFile, filePathArr, snippet, isHaveHeader) {
242
253
  const packageInfo = await findPath.parsePackageSwift(packagePath);
243
254
  if (!packageInfo) {
244
255
  snippet['{content}'] = codeList;
245
- saveFromFile(specFile, snippet);
256
+ const moduleSpecFile = path.join(path.dirname(packagePath), 'AutoSnippet.boxspec.json');
257
+ saveFromFile(moduleSpecFile, snippet);
246
258
  return;
247
259
  }
248
260
 
249
261
  // 根据当前文件路径确定模块名
250
262
  const moduleName = determineModuleName(filePath, packageInfo);
251
- const headerName = fileName.substring(0, fileName.length - 2); // 移除 .h
263
+ const headerNameWithoutExt = fileName.substring(0, fileName.length - 2); // 移除 .h
264
+
265
+ // ✅ 模块根目录就是 Package.swift 所在目录(packageInfo.path)
266
+ // .boxspec.json 文件将创建在这个目录下(与 Package.swift 同级)
267
+ const moduleRoot = packageInfo.path;
252
268
 
253
269
  // ✅ 查找头文件(适配 SPM 的 include/ModuleName/ 结构)
254
- const headerPath = await findPath.findSubHeaderPath(packageInfo.path, headerName, moduleName);
270
+ // Package.swift 所在目录下查找(可能包含 Services/Services/... 这样的结构)
271
+ const headerPath = await findPath.findSubHeaderPath(moduleRoot, headerNameWithoutExt, moduleName);
255
272
 
256
273
  snippet['{content}'] = codeList;
257
- snippet['{specName}'] = moduleName;
258
- snippet['{headName}'] = fileName;
274
+ snippet['{specName}'] = moduleName; // ✅ specName 是 target 名称(如 BDNetworkAPI),不是包名(如 Business)
259
275
 
260
276
  if (headerPath) {
261
- // ✅ 使用 path.relative() 计算相对于配置文件的相对路径
262
- const specFileDir = path.dirname(specFile);
263
- const relativePath = path.relative(specFileDir, headerPath);
264
- snippet['{specHeadPath}'] = encodeURI(relativePath);
277
+ // ✅ headName 存储相对于 Package.swift 所在目录的相对路径
278
+ // 例如:如果 Package.swift 在 Business/,头文件在 Business/Business/BDNetworkAPI/Code/xxx.h
279
+ // headName = "Business/BDNetworkAPI/Code/xxx.h"
280
+ const headerRelativePath = path.relative(moduleRoot, headerPath);
281
+ snippet['{headName}'] = headerRelativePath;
282
+ } else {
283
+ // 如果找不到头文件,使用文件名
284
+ snippet['{headName}'] = fileName;
265
285
  }
266
286
 
267
287
  // 查找 README.md
268
288
  try {
269
289
  const readmePath = path.join(packageInfo.path, README_NAME);
270
290
  await fs.promises.access(readmePath);
271
- // 使用 path.relative() 计算相对于配置文件的相对路径
272
- const specFileDir = path.dirname(specFile);
273
- const readmeRelativePath = path.relative(specFileDir, readmePath);
291
+ const moduleRoot = packageInfo.path;
292
+ const readmeRelativePath = path.relative(moduleRoot, readmePath);
274
293
  snippet['{readme}'] = encodeURI(readmeRelativePath);
275
294
  } catch {
276
295
  // README.md 不存在,跳过
277
296
  }
278
297
 
279
- saveFromFile(specFile, snippet);
298
+ // ✅ SPM 模块:.boxspec 文件位置在模块根目录(与 Package.swift 同级)
299
+ const moduleSpecFile = path.join(packageInfo.path, 'AutoSnippet.boxspec.json');
300
+ saveFromFile(moduleSpecFile, snippet);
280
301
  }).catch(function (err) {
281
302
  console.error('Error finding Package.swift:', err);
282
303
  snippet['{content}'] = codeList;
@@ -304,7 +325,23 @@ function saveFromFile(specFile, snippet) {
304
325
  placeholder = JSON.parse(data);
305
326
  }
306
327
  } catch (err) {
307
- console.error(err);
328
+ // ✅ 文件不存在或读取失败,创建新的配置文件
329
+ if (err.code === 'ENOENT') {
330
+ // 确保目录存在
331
+ const specFileDir = path.dirname(specFile);
332
+ try {
333
+ fs.mkdirSync(specFileDir, { recursive: true });
334
+ } catch (mkdirErr) {
335
+ // 目录可能已存在,忽略错误
336
+ }
337
+ // 创建空的配置文件结构
338
+ placeholder = {
339
+ list: []
340
+ };
341
+ } else {
342
+ console.error(err);
343
+ return;
344
+ }
308
345
  }
309
346
 
310
347
  if (placeholder != null) {
package/bin/init.js CHANGED
@@ -5,31 +5,29 @@ const path = require('path');
5
5
  const CMD_PATH = process.cwd();
6
6
  const findPath = require('./findPath.js');
7
7
 
8
- async function initSpec() {
9
- const filePath = path.join(CMD_PATH, '/AutoSnippet.boxspec.json');
8
+ /**
9
+ * 聚合子模块的 AutoSnippet.boxspec.json 到主配置文件
10
+ * @param {string} mainSpecFile - 主配置文件路径
11
+ * @returns {Promise<void>}
12
+ */
13
+ async function mergeSubSpecs(mainSpecFile) {
10
14
  let idsArray = [];
11
15
  let specObj = {
12
16
  list: []
13
17
  };
14
18
 
15
- try {
16
- await fs.promises.access(filePath);
17
- } catch (error) {
18
- const content = JSON.stringify(specObj, null, 4);
19
- fs.writeFileSync(filePath, content, 'utf8');
20
- }
19
+ const specSlashIndex = mainSpecFile.lastIndexOf('/');
20
+ const specFilePath = mainSpecFile.substring(0, specSlashIndex + 1);
21
21
 
22
- const specSlashIndex = filePath.lastIndexOf('/');
23
- const specFilePath = filePath.substring(0, specSlashIndex + 1);
24
-
25
- const array = await findPath.findSubASSpecPath(CMD_PATH);
22
+ // 从主配置文件所在目录向下查找子模块的 AutoSnippet.boxspec.json
23
+ const array = await findPath.findSubASSpecPath(path.dirname(mainSpecFile));
26
24
 
27
25
  for (let i = 0; i < array.length; i++) {
28
26
  const filename = array[i];
29
27
 
30
28
  const slashIndex = filename.lastIndexOf('/');
31
29
  let thePath = filename.substring(0, slashIndex + 1);
32
- if (filename === filePath) {
30
+ if (filename === mainSpecFile) {
33
31
  thePath = '';
34
32
  } else {
35
33
  thePath = thePath.replace(specFilePath, '');
@@ -38,41 +36,58 @@ async function initSpec() {
38
36
  try {
39
37
  // 读取AutoSnippet的占位配置
40
38
  const data = fs.readFileSync(filename, 'utf8');
41
- const config = JSON.parse(data);
39
+ const config = JSON.parse(data);
42
40
  if (config && config.list) {
43
-
44
- const arr = config.list.filter(function (item, index, array) {
45
- for (let i = 0; i < idsArray.length; i++) {
46
- if (item['{identifier}'] === idsArray[i]) {
47
- return false;
48
- }
49
- }
50
- idsArray.push(item['{identifier}']);
51
- // ✅ 头文件相对路径需要补齐(将子配置的相对路径转换为相对于主配置的路径)
52
- if (item['{specHeadPath}']) {
53
- // 解码原始路径,拼接子配置路径,再编码
54
- const decodedPath = decodeURI(item['{specHeadPath}']);
55
- const combinedPath = thePath ? path.join(thePath, decodedPath) : decodedPath;
56
- // 规范化路径(处理 .. 和 .)
57
- item['{specHeadPath}'] = encodeURI(path.normalize(combinedPath));
41
+ const arr = config.list.filter(function (item, index, array) {
42
+ for (let i = 0; i < idsArray.length; i++) {
43
+ if (item['{identifier}'] === idsArray[i]) {
44
+ return false;
45
+ }
58
46
  }
59
- return true;
60
- });
61
- specObj.list = specObj.list.concat(arr);
47
+ idsArray.push(item['{identifier}']);
48
+ // ✅ SPM 模块:headName 已经是相对于模块根目录的相对路径
49
+ // headName 保持相对于各自模块根目录的路径(不需要转换)
50
+ return true;
51
+ });
52
+ specObj.list = specObj.list.concat(arr);
62
53
  }
63
54
  } catch (err) {
64
55
  console.error(err);
65
56
  }
66
57
  }
67
58
 
68
- try {
69
- const content = JSON.stringify(specObj, null, 4);
70
- if (content) {
71
- fs.writeFileSync(filePath, content, 'utf8');
72
- }
73
- } catch (err) {
74
- console.error(err);
75
- }
59
+ try {
60
+ const content = JSON.stringify(specObj, null, 4);
61
+ if (content) {
62
+ fs.writeFileSync(mainSpecFile, content, 'utf8');
63
+ }
64
+ } catch (err) {
65
+ console.error(err);
66
+ }
67
+ }
68
+
69
+ async function initSpec() {
70
+ // ✅ 查找 Package.swift,在其同级目录创建 AutoSnippet.boxspec.json
71
+ let packagePath = await findPath.findPackageSwiftPath(CMD_PATH);
72
+
73
+ // 如果找不到 Package.swift,使用当前目录
74
+ const configDir = packagePath ? path.dirname(packagePath) : CMD_PATH;
75
+ const filePath = path.join(configDir, 'AutoSnippet.boxspec.json');
76
+
77
+ // 如果配置文件不存在,创建一个空的
78
+ try {
79
+ await fs.promises.access(filePath);
80
+ } catch (error) {
81
+ const specObj = {
82
+ list: []
83
+ };
84
+ const content = JSON.stringify(specObj, null, 4);
85
+ fs.writeFileSync(filePath, content, 'utf8');
86
+ }
87
+
88
+ // ✅ 聚合子模块配置到主配置文件
89
+ await mergeSubSpecs(filePath);
76
90
  }
77
91
 
78
- exports.initSpec = initSpec;
92
+ exports.initSpec = initSpec;
93
+ exports.mergeSubSpecs = mergeSubSpecs;
package/bin/injection.js CHANGED
@@ -58,33 +58,117 @@ function handleHeaderLineSwift(specFile, updateFile, headerLine, importArray) {
58
58
 
59
59
  // specFile实际上是获取缓存的key,用来获取Snippet的模块空间信息,没有路径意义
60
60
  // updateFile是当前修改文件路径,用来获取当前模块空间信息
61
- function handleHeaderLine(specFile, updateFile, headerLine, importArray, isSwift) {
61
+ async function handleHeaderLine(specFile, updateFile, headerLine, importArray, isSwift) {
62
62
  if (isSwift) {
63
63
  handleHeaderLineSwift(specFile, updateFile, headerLine, importArray);
64
64
  return;
65
65
  }
66
66
  const header = createHeader(headerLine);
67
67
 
68
- // 首先识别是否是组件内部修改,默认头文件间接等于模块名
69
- cache.getHeadCache(specFile).then(function (headCache) {
70
- if (headCache) {
71
- const headPath = headCache[header.headerName];
68
+ // ✅ 重新设计:区分当前模块内部和外部
69
+ // 1. 获取当前文件所在的模块(通过 Package.swift)
70
+ // 2. 获取头文件所在的模块(从头文件路径查找 Package.swift,确定最近的 target 模块名)
71
+ // 3. 比较模块名:
72
+ // - 相同模块 -> 使用相对路径 #import "Header.h"
73
+ // - 不同模块 -> 使用 #import <ModuleName/Header.h>
74
+
75
+ // 获取当前文件所在的模块
76
+ const updateFileDir = path.dirname(updateFile);
77
+ const currentPackagePath = await findPath.findPackageSwiftPath(updateFileDir);
78
+
79
+ if (!currentPackagePath) {
80
+ // 找不到当前模块的 Package.swift,默认使用 <> 格式
81
+ handleModuleHeader(specFile, updateFile, header, importArray, true);
82
+ return;
83
+ }
72
84
 
73
- const dotIndex = headPath.lastIndexOf('.');
74
- const slashIndex = headPath.lastIndexOf('/');
75
- const currModuleName = headPath.substring(slashIndex + 1, dotIndex);
76
- if (currModuleName === header.moduleName) {
77
- handleModuleHeader(specFile, updateFile, header, importArray, false);
78
- } else {
79
- handleModuleHeader(specFile, updateFile, header, importArray, true);
80
- }
85
+ const currentPackageInfo = await findPath.parsePackageSwift(currentPackagePath);
86
+ if (!currentPackageInfo) {
87
+ handleModuleHeader(specFile, updateFile, header, importArray, true);
88
+ return;
89
+ }
90
+
91
+ // 获取当前文件所在的模块名(通过路径判断)
92
+ const currentModuleName = determineCurrentModuleName(updateFile, currentPackageInfo);
93
+
94
+ // ✅ 获取头文件缓存,然后确定头文件所在的模块名
95
+ const headCache = await cache.getHeadCache(specFile);
96
+ const headerModuleName = await determineHeaderModuleName(specFile, header, headCache);
97
+
98
+ // ✅ 更新 header 中的模块名和 specName,确保使用正确的模块名(最近的 target 模块名)
99
+ header.moduleName = headerModuleName;
100
+ header.specName = '<' + headerModuleName + '/' + header.headerName + '>';
101
+
102
+ // ✅ 判断是否为同一模块
103
+ const isSameModule = currentModuleName === headerModuleName;
104
+
105
+ // 如果是同一模块,使用相对路径;否则使用 <> 格式
106
+ handleModuleHeader(specFile, updateFile, header, importArray, !isSameModule);
107
+ }
108
+
109
+ /**
110
+ * 根据文件路径确定当前模块名(SPM)
111
+ */
112
+ function determineCurrentModuleName(filePath, packageInfo) {
113
+ const relativePath = path.relative(packageInfo.path, filePath);
114
+ const segments = relativePath.split(path.sep);
115
+
116
+ // 查找匹配的 target(最近的 target)
117
+ for (const segment of segments) {
118
+ if (packageInfo.targets.includes(segment)) {
119
+ return segment;
81
120
  }
82
- });
121
+ }
122
+
123
+ // 如果找不到,使用第一个 target
124
+ return packageInfo.targets[0] || packageInfo.name;
125
+ }
126
+
127
+ /**
128
+ * 确定头文件所在的模块名(SPM)
129
+ * 从头文件路径查找 Package.swift,确定最近的 target 模块名
130
+ */
131
+ async function determineHeaderModuleName(specFile, header, headCache) {
132
+ if (!headCache) {
133
+ // 没有缓存,使用从 headerLine 解析的模块名(可能不准确)
134
+ return header.moduleName;
135
+ }
136
+
137
+ // 从头缓存中获取头文件的相对路径
138
+ const headRelativePath = headCache[header.headerName];
139
+ if (!headRelativePath) {
140
+ // 找不到头文件路径,使用从 headerLine 解析的模块名
141
+ return header.moduleName;
142
+ }
143
+
144
+ // ✅ specFile 位于模块根目录(如 ModuleRoot/AutoSnippet.boxspec.json)
145
+ const moduleRootDir = path.dirname(specFile);
146
+ const headPath = path.join(moduleRootDir, headRelativePath);
147
+
148
+ // 从头文件路径向上查找 Package.swift
149
+ const headerPackagePath = await findPath.findPackageSwiftPath(headPath);
150
+ if (!headerPackagePath) {
151
+ // 找不到 Package.swift,使用从 headerLine 解析的模块名
152
+ return header.moduleName;
153
+ }
154
+
155
+ // 解析 Package.swift 获取模块信息
156
+ const headerPackageInfo = await findPath.parsePackageSwift(headerPackagePath);
157
+ if (!headerPackageInfo) {
158
+ return header.moduleName;
159
+ }
160
+
161
+ // ✅ 根据头文件路径确定最近的 target 模块名
162
+ return determineCurrentModuleName(headPath, headerPackageInfo);
83
163
  }
84
164
 
85
165
  // isOuter区分模块内部引用""格式和模块外部引用<>格式
166
+ // ✅ SPM 模块:
167
+ // - isOuter = false:同一模块内部,使用相对路径 #import "Header.h"
168
+ // - isOuter = true:不同模块之间,使用 #import <ModuleName/Header.h>
86
169
  function handleModuleHeader(specFile, updateFile, header, importArray, isOuter) {
87
- const headName = isOuter ? header.name : header.headerStrName;
170
+ // 根据 isOuter 选择不同的引入格式
171
+ const headName = isOuter ? header.name : header.headerStrName; // isOuter: <ModuleName/Header.h>, 否则: "Header.h"
88
172
  const moduleName = isOuter ? header.specName : header.moduleStrName;
89
173
 
90
174
  // 检查是否已经引入头文件
@@ -93,20 +177,21 @@ function handleModuleHeader(specFile, updateFile, header, importArray, isOuter)
93
177
 
94
178
  if (importHeader === headName) {
95
179
  // 已经引入头文件
96
- handelAddHeaderStatus(specFile, updateFile, header, true, false);
180
+ handelAddHeaderStatus(specFile, updateFile, header, true, false, isOuter);
97
181
  return;
98
182
  } else if (importHeader === moduleName) {
99
- // 已经引入spec头文件
100
- handelAddHeaderStatus(specFile, updateFile, header, false, true);
183
+ // 已经引入模块头文件(如 <ModuleName/ModuleName.h>)
184
+ handelAddHeaderStatus(specFile, updateFile, header, false, true, isOuter);
101
185
  return;
102
186
  }
103
187
  }
104
188
 
105
189
  // 没有找到已引入的头文件,直接添加
106
- addHeaderToFile(updateFile, header);
190
+ // addHeaderToFile 会根据 isOuter 使用不同的格式
191
+ addHeaderToFile(updateFile, header, isOuter);
107
192
  }
108
193
 
109
- function handelAddHeaderStatus(specFile, updateFile, header, isAddedHeader, isAddedSpecHeader) {
194
+ function handelAddHeaderStatus(specFile, updateFile, header, isAddedHeader, isAddedSpecHeader, isOuter) {
110
195
  if (isAddedHeader) {
111
196
  // 已经引入头文件
112
197
  removeMarkFromFile(updateFile, header, '依赖头文件已存在,不需要额外引入。');
@@ -117,22 +202,32 @@ function handelAddHeaderStatus(specFile, updateFile, header, isAddedHeader, isAd
117
202
  // spec header足够了,不需要添加头文件
118
203
  removeMarkFromFile(updateFile, header, '依赖模块头文件已存在,不需要额外引入。');
119
204
  } else {
120
- addHeaderToFile(updateFile, header);
205
+ // 使用传入的 isOuter 参数
206
+ addHeaderToFile(updateFile, header, isOuter);
121
207
  }
122
208
  });
123
209
  } else {
124
210
  // 都没找到,添加头文件
125
- addHeaderToFile(updateFile, header);
211
+ // 使用传入的 isOuter 参数
212
+ addHeaderToFile(updateFile, header, isOuter);
126
213
  }
127
214
  }
128
215
 
129
216
  function isAddedToSpecHeader(specFile, header, callback) {
130
217
  cache.getHeadCache(specFile).then(function (headCache) {
131
218
  if (headCache) {
132
- // ✅ 使用 path.join() 正确拼接配置目录和相对路径
133
- const specFileDir = path.dirname(specFile);
134
- const relativePath = decodeURI(headCache[header.headerName]);
135
- const headPath = path.join(specFileDir, relativePath);
219
+ // ✅ SPM 模块:headName 已经是相对于模块根目录的相对路径
220
+ // specFile 位于模块根目录(如 ModuleRoot/AutoSnippet.boxspec.json)
221
+ const moduleRootDir = path.dirname(specFile);
222
+ const headRelativePath = headCache[header.headerName];
223
+
224
+ if (!headRelativePath) {
225
+ callback(false);
226
+ return;
227
+ }
228
+
229
+ // 拼接头文件的完整路径
230
+ const headPath = path.join(moduleRootDir, headRelativePath);
136
231
 
137
232
  try {
138
233
  // 读取当前头文件所在工作空间里默认暴露的头文件
@@ -169,8 +264,15 @@ function removeMarkFromFile(updateFile, header, string) {
169
264
  });
170
265
  }
171
266
 
172
- function addHeaderToFile(updateFile, header) {
173
- readStream(updateFile, importMark + ' ' + header.name, importMark);
267
+ function addHeaderToFile(updateFile, header, isOuter) {
268
+ // 根据 isOuter 选择不同的引入格式
269
+ // isOuter = true: 使用 <> 格式(#import <ModuleName/Header.h>)
270
+ // isOuter = false: 使用相对路径(#import "Header.h")
271
+ const importLine = isOuter
272
+ ? importMark + ' ' + header.name // <ModuleName/Header.h>
273
+ : importMark + ' ' + header.headerStrName; // "Header.h"
274
+
275
+ readStream(updateFile, importLine, importMark);
174
276
  checkDependency(updateFile, header.moduleName, '自动注入头文件完成。').catch(err => {
175
277
  console.error('Error checking dependency:', err);
176
278
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autosnippet",
3
- "version": "1.1.15",
3
+ "version": "1.1.17",
4
4
  "description": "A iOS module management tool.",
5
5
  "main": "index.js",
6
6
  "scripts": {