@microtronics/studio-cli 0.54.0 → 0.55.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/out/dde/dde.js CHANGED
@@ -396,7 +396,7 @@ var DDE;
396
396
  const manifest = await manifest_1.Manifest.read(cwd, fs);
397
397
  const dependencies = await getDependencies(cwd, fs, manifest);
398
398
  const resolvedConfig = await globals_1.Globals.read(cwd, fs, logger);
399
- const autoInc = (0, dlo_1.generateAutoIncFromMap)(ddeJSON, resolvedConfig.flat, manifest);
399
+ const autoInc = (0, dlo_1.generateAutoIncFromMap)(ddeJSON, resolvedConfig, manifest);
400
400
  const appAutoDDE = new dlo_1.AutoDDEGenerator(manifest, ddeJSON, null);
401
401
  const appDDEInc = appAutoDDE.generate();
402
402
  // generate AutoDDe Files for the libraries:
@@ -97,7 +97,7 @@ function dloCoreSupportsFlags(manifest) {
97
97
  return semver.gte(releaseVersion, '1.1.0');
98
98
  }
99
99
  // eslint-disable-next-line sonarjs/cognitive-complexity
100
- function generateAutoIncFromMap(ddeMap, globalDefines, manifest) {
100
+ function generateAutoIncFromMap(ddeMap, resolvedConfig, manifest) {
101
101
  const _pwn = []; // sample code output for pawn
102
102
  const pwn = _pwn.push.bind(_pwn);
103
103
  function pwn_section(s) {
@@ -139,8 +139,24 @@ function generateAutoIncFromMap(ddeMap, globalDefines, manifest) {
139
139
  /**
140
140
  * generate global dlo defines if there are any
141
141
  */
142
+ const globalDefines = resolvedConfig.flat;
143
+ const { definesWithSource } = resolvedConfig;
142
144
  pwn_section('GLOBAL DEFINES');
143
145
  for (const [define, value] of Object.entries(globalDefines)) {
146
+ const comment = definesWithSource[define]?.comment;
147
+ if (comment) {
148
+ const lines = comment.split('\n');
149
+ if (lines.length === 1) {
150
+ pwn(`/** ${lines[0]} */`);
151
+ }
152
+ else {
153
+ pwn('/**');
154
+ for (const line of lines) {
155
+ pwn(` * ${line}`);
156
+ }
157
+ pwn(' */');
158
+ }
159
+ }
144
160
  const valueIsDefine = Object.hasOwn(globalDefines, value);
145
161
  addDefinition(define, `${value}`, valueIsDefine);
146
162
  }
package/out/globals.js CHANGED
@@ -67,10 +67,10 @@ var Globals;
67
67
  const depPath = dependencies_1.Dependencies.dependencyToPath(cwd, dependencyId);
68
68
  const name = dependencies_1.Dependencies.dependencyIdToName(dependencyId);
69
69
  const libIniPath = vscode_uri_1.Utils.joinPath(depPath, DLO_PATH, `${name}.ini`);
70
- await mergeIniFile(fs, libIniPath, allDefines, sections, definesWithSource);
70
+ await mergeIniFile(fs, libIniPath, allDefines, sections, definesWithSource, name);
71
71
  // defaults.ini files
72
72
  const libDefaultsPath = vscode_uri_1.Utils.joinPath(depPath, defaultFiles_1.DefaultFiles.filePaths.defaultsIni);
73
- await mergeIniFile(fs, libDefaultsPath, allDefines, sections, definesWithSource);
73
+ await mergeIniFile(fs, libDefaultsPath, allDefines, sections, definesWithSource, name);
74
74
  }
75
75
  // Load the library project's specific ini file (deprecated location)
76
76
  if (manifest_1.Manifest.isLibrary(manifest)) {
@@ -78,7 +78,7 @@ var Globals;
78
78
  if (logger && (await fs.stat(libIni))) {
79
79
  logger.warn(`dlo/${manifest.name}.ini is deprecated. Please migrate your defines to defaults.ini in the project root.`);
80
80
  }
81
- await mergeIniFile(fs, libIni, allDefines, sections, definesWithSource);
81
+ await mergeIniFile(fs, libIni, allDefines, sections, definesWithSource, manifest.name);
82
82
  }
83
83
  // Load the project's main.ini and overwrite existing defines (deprecated location)
84
84
  const mainIniRelPath = manifest.dlo?.iniFile || defaultFiles_1.DefaultFiles.filePaths.dlo.mainINI;
@@ -86,17 +86,18 @@ var Globals;
86
86
  if (logger && (await fs.stat(mainIni))) {
87
87
  logger.warn(`${mainIniRelPath} is deprecated. Please migrate your defines to app.ini in the project root.`);
88
88
  }
89
- await mergeIniFile(fs, mainIni, allDefines, sections, definesWithSource);
89
+ const mainIniLabel = iniFileLabel(mainIniRelPath);
90
+ await mergeIniFile(fs, mainIni, allDefines, sections, definesWithSource, mainIniLabel);
90
91
  // Project root: defaults.ini (library) or app.ini (app/addon/analytics)
91
92
  if (manifest_1.Manifest.isLibrary(manifest)) {
92
93
  const defaultsIni = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.defaultsIni);
93
- await mergeIniFile(fs, defaultsIni, allDefines, sections, definesWithSource);
94
+ await mergeIniFile(fs, defaultsIni, allDefines, sections, definesWithSource, 'defaults');
94
95
  }
95
96
  // Snapshot defaults-only state before app.ini merge (for library dual-defines)
96
97
  const defaultsOnly = snapshotDefaultsOnly(manifest, allDefines, sections, definesWithSource);
97
98
  // app.ini is always loaded (provides local dev overrides for libraries, main config for apps)
98
99
  const appIni = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.appIni);
99
- await mergeIniFile(fs, appIni, allDefines, sections, definesWithSource);
100
+ await mergeIniFile(fs, appIni, allDefines, sections, definesWithSource, 'app');
100
101
  return { flat: allDefines, sections, definesWithSource, defaultsOnly };
101
102
  }
102
103
  Globals.read = read;
@@ -269,10 +270,35 @@ function formatJsDoc(comment) {
269
270
  function isNumericValue(value) {
270
271
  return value !== '' && !isNaN(Number(value));
271
272
  }
273
+ /**
274
+ * Derive a human-readable source label from an ini file path.
275
+ * Strips the directory prefix and `.ini` extension.
276
+ * E.g. `dlo/main.ini` → `main`, `app.ini` → `app`.
277
+ */
278
+ function iniFileLabel(relPath) {
279
+ const filename = relPath.split('/').pop() || relPath;
280
+ return filename.replace(/\.ini$/i, '');
281
+ }
282
+ /**
283
+ * Merge an incoming comment with an existing one.
284
+ *
285
+ * - Both present → join existing (already prefixed) and new (prefixed) with `\n`
286
+ * - Only existing → keep it
287
+ * - Only new → use it (prefixed)
288
+ * - Neither → undefined
289
+ */
290
+ function mergeComment(existingComment, newRawComment, sourceLabel) {
291
+ const prefixedNew = newRawComment ? `${sourceLabel}: ${newRawComment}` : undefined;
292
+ if (existingComment && prefixedNew) {
293
+ return `${existingComment}\n${prefixedNew}`;
294
+ }
295
+ return prefixedNew || existingComment;
296
+ }
272
297
  /**
273
298
  * Create a DefineEntry, attaching a comment from the comment map if available.
299
+ * The comment is prefixed with the source label for provenance tracking.
274
300
  */
275
- function createDefineEntry(stringValue, fileUri, lines, key, sectionName, commentMap) {
301
+ function createDefineEntry(stringValue, fileUri, lines, key, sectionName, commentMap, sourceLabel) {
276
302
  const flatKey = sectionName ? `${sectionName}_${key}` : key;
277
303
  const entry = {
278
304
  value: stringValue,
@@ -280,23 +306,26 @@ function createDefineEntry(stringValue, fileUri, lines, key, sectionName, commen
280
306
  sourceLine: findLineNumber(lines, key, sectionName)
281
307
  };
282
308
  if (commentMap[flatKey]) {
283
- entry.comment = commentMap[flatKey];
309
+ entry.comment = `${sourceLabel}: ${commentMap[flatKey]}`;
284
310
  }
285
311
  return entry;
286
312
  }
287
313
  /**
288
314
  * Merge all keys from a parsed ini section into the accumulators.
289
315
  */
290
- function mergeSectionEntries(sectionName, sectionData, allDefines, sections, definesWithSource, fileUri, lines, commentMap) {
316
+ function mergeSectionEntries(sectionName, sectionData, allDefines, sections, definesWithSource, fileUri, lines, commentMap, sourceLabel) {
291
317
  if (!sections[sectionName]) {
292
318
  sections[sectionName] = {};
293
319
  }
294
320
  for (const [key, sectionValue] of Object.entries(sectionData)) {
295
321
  const flatKey = `${sectionName}_${key}`;
322
+ const rawComment = commentMap[flatKey];
296
323
  const stringValue = `${sectionValue}`;
297
324
  allDefines[flatKey] = stringValue;
298
325
  sections[sectionName][key] = stringValue;
299
- definesWithSource[flatKey] = createDefineEntry(stringValue, fileUri, lines, key, sectionName, commentMap);
326
+ const newEntry = createDefineEntry(stringValue, fileUri, lines, key, sectionName, commentMap, sourceLabel);
327
+ newEntry.comment = mergeComment(definesWithSource[flatKey]?.comment, rawComment, sourceLabel);
328
+ definesWithSource[flatKey] = newEntry;
300
329
  }
301
330
  }
302
331
  /**
@@ -309,7 +338,7 @@ function mergeSectionEntries(sectionName, sectionData, allDefines, sections, def
309
338
  * @param sections - accumulated sectioned config (mutated)
310
339
  * @param definesWithSource - accumulated source tracking (mutated)
311
340
  */
312
- async function mergeIniFile(fs, filePath, allDefines, sections, definesWithSource) {
341
+ async function mergeIniFile(fs, filePath, allDefines, sections, definesWithSource, sourceLabel) {
313
342
  // early return if the file doesn't exist
314
343
  if (!(await fs.stat(filePath))) {
315
344
  return;
@@ -322,12 +351,15 @@ async function mergeIniFile(fs, filePath, allDefines, sections, definesWithSourc
322
351
  const commentMap = extractComments(rawText);
323
352
  for (const [sectionOrKey, value] of Object.entries(parsed)) {
324
353
  if (typeof value === 'object' && value !== null) {
325
- mergeSectionEntries(sectionOrKey, value, allDefines, sections, definesWithSource, fileUri, lines, commentMap);
354
+ mergeSectionEntries(sectionOrKey, value, allDefines, sections, definesWithSource, fileUri, lines, commentMap, sourceLabel);
326
355
  }
327
356
  else {
357
+ const rawComment = commentMap[sectionOrKey];
328
358
  const stringValue = `${value}`;
329
359
  allDefines[sectionOrKey] = stringValue;
330
- definesWithSource[sectionOrKey] = createDefineEntry(stringValue, fileUri, lines, sectionOrKey, null, commentMap);
360
+ const newEntry = createDefineEntry(stringValue, fileUri, lines, sectionOrKey, null, commentMap, sourceLabel);
361
+ newEntry.comment = mergeComment(definesWithSource[sectionOrKey]?.comment, rawComment, sourceLabel);
362
+ definesWithSource[sectionOrKey] = newEntry;
331
363
  }
332
364
  }
333
365
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microtronics/studio-cli",
3
- "version": "0.54.0",
3
+ "version": "0.55.0",
4
4
  "description": "Microtronics Studio CLI Tool",
5
5
  "main": "./out/api.js",
6
6
  "typings": "./dist/studio-cli.d.ts",