@microtronics/studio-cli 0.28.0 → 0.29.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/CHANGELOG.md CHANGED
@@ -1,11 +1,25 @@
1
1
 
2
2
 
3
- ## 0.28.0 (2025-03-27)
3
+ ## 0.29.0 (2025-04-03)
4
4
 
5
5
 
6
6
  ### Features
7
7
 
8
- * **studio-cli:** run precompiler on the fly during dlo compile time ([354ebcf](https://bitbucket.org/microtronics-core/vscode-studio/commits/354ebcf72400b6f1956c85cae9bc7587a1680a16))
8
+ * **studio-cli:** add functionality to fetch previous DDE history JSON ([ae4a22b](https://bitbucket.org/microtronics-core/vscode-studio/commits/ae4a22b704d207e52d16d524b0b11043db175484))
9
+ * **studio-cli:** add the versions history.json to the apm tag ([1c3e35e](https://bitbucket.org/microtronics-core/vscode-studio/commits/1c3e35ef53d508987485103b0220a0eb84f4414c))
10
+ * **studio-cli:** write the actual history.json to the dist/dde directory ([1fc5b32](https://bitbucket.org/microtronics-core/vscode-studio/commits/1fc5b3232f3d86f40bd7dfdeb9c6ef7a6d3c5491))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **studio-cli:** requesting the previous container by name was not correctly implemented ([78076a9](https://bitbucket.org/microtronics-core/vscode-studio/commits/78076a9b0fc6647e33f5ddfc0554d651fe7bc30e))
16
+
17
+ ## 0.28.0 (2025-03-27)
18
+
19
+
20
+ ### Features
21
+
22
+ * **studio-cli:** run precompiler on the fly during dlo compile time ([354ebcf](https://bitbucket.org/microtronics-core/vscode-studio/commits/354ebcf72400b6f1956c85cae9bc7587a1680a16))
9
23
  * **studio-cli:** updated dlo compiler to suport dlo.cfg instead of pawn.cfg files ([9c56440](https://bitbucket.org/microtronics-core/vscode-studio/commits/9c564407a8d4118b7bb04cd6ffdaeb93ebed8290))
10
24
 
11
25
  ## 0.27.3 (2025-03-26)
@@ -121,11 +121,13 @@ declare interface BaseTagHeader {
121
121
  * @param {URI} cwd - The current working directory where the build process will be executed.
122
122
  * @param {LocalFS} fs - The local file system instance used for file operations during the build.
123
123
  * @param {Logger} logger - Logger instance for logging details during the build process.
124
+ * @param {Globals.ENV} env - The global environment configuration used during the installation.
125
+ * @param {string|null} apiToken - The API token for authentication, if required, or null if not applicable.
124
126
  * @param {APM.Part} selectedParts - The project parts to be built.
125
127
  * @param {boolean} [errorWithDiagnostics] - If true, includes diagnostic details in case of an error.
126
128
  * @return {Promise<Object>} A promise resolved with an object containing diagnostics information for the specified project parts: `dde`, `dlo`, and `dfiles`.
127
129
  */
128
- export declare function build(cwd: URI, fs: LocalFS, logger: Log.Logger, selectedParts?: APM.Part[] | boolean, errorWithDiagnostics?: boolean): Promise<{
130
+ export declare function build(cwd: URI, fs: LocalFS, logger: Log.Logger, env: Globals.ENV, apiToken?: string | null, selectedParts?: APM.Part[] | boolean, errorWithDiagnostics?: boolean): Promise<{
129
131
  [APM.Part.dde]: Diagnostics.File[];
130
132
  [APM.Part.dlo]: Diagnostics.File[];
131
133
  [APM.Part.dfiles]: Diagnostics.File[];
@@ -373,7 +375,7 @@ declare interface components {
373
375
  ApplicationVersion: string | number;
374
376
  ApplicationVersionInSemver: boolean;
375
377
  /** @description File that can be downloaded */
376
- ApplicationFileName: "release-notes.md" | "app.tar.gz" | "studio.json";
378
+ ApplicationFileName: "release-notes.md" | "app.tar.gz" | "studio.json" | "dde.json";
377
379
  /** @description User Id */
378
380
  MemberId: string;
379
381
  /** @description User Id */
@@ -1164,7 +1166,7 @@ export declare namespace DDE {
1164
1166
  * @param ddeHistory
1165
1167
  * @constructor
1166
1168
  */
1167
- const PreCompiler: (manifest: Manifest.Manifest, libraries: DDE_Core.LibraryFile[], ddeHistory: any) => YamlPreCompiler.PreCompiler;
1169
+ const PreCompiler: (libraries: DDE_Core.LibraryFile[], ddeHistory: HistoryJson | null) => YamlPreCompiler.PreCompiler;
1168
1170
  /**
1169
1171
  * File Generators
1170
1172
  */
@@ -1180,23 +1182,46 @@ export declare namespace DDE {
1180
1182
  * @param ddeJSON
1181
1183
  */
1182
1184
  export function exportMyDatanetXML(cwd: URI, fs: LocalFS, logger: Log.Logger, ddeJSON: DDEJson): Promise<void>;
1185
+ export interface HistoryJson {
1186
+ version: string;
1187
+ containers: {
1188
+ [p: string]: DDE_Core.DDEJsonContainer;
1189
+ };
1190
+ setPointList: DDE_Core.DDESetpointList;
1191
+ }
1192
+ /**
1193
+ * Fetches the DDE history JSON of a previous version of an app and saves it to a designated file path.
1194
+ *
1195
+ * The method removes any previously fetched version of the DDE JSON file and fetches the configuration
1196
+ * of the previous stable version of the app from a remote registry. If a valid DDE file exists for the previous version, it is downloaded
1197
+ * and stored at the specified location.
1198
+ *
1199
+ * @param {URI} cwd - The current working directory of the project.
1200
+ * @param {LocalFS} fs - The local filesystem utility for performing file operations.
1201
+ * @param {Log.Logger} logger - Logger instance for logging informational, warning, and error messages.
1202
+ * @param {Globals.ENV} env - The environment configuration parameters.
1203
+ * @param {string|null} apiToken - The API authentication token for accessing the registry. A null value will prevent fetching the DDE JSON file.
1204
+ * @return {Promise<void>} Resolves with no value if the process completes successfully or returns early for validation or fetch failures.
1205
+ */
1206
+ export function fetchPreviousHistoryJson(cwd: URI, fs: LocalFS, logger: Log.Logger, env: Globals.ENV, apiToken: string | null): Promise<void>;
1183
1207
  /**
1184
1208
  * Read the correct history.json file from the project
1185
1209
  * @param cwd
1186
1210
  * @param fs
1211
+ * @param logger
1187
1212
  */
1188
- export function getHistoryJson(cwd: URI, fs: LocalFS, logger: Log.Logger): Promise<any>;
1213
+ export function getHistoryJson(cwd: URI, fs: LocalFS, logger: Log.Logger): Promise<HistoryJson | null>;
1189
1214
  /**
1190
1215
  * Generate the object for the history.json
1191
1216
  * @param ddeJson
1192
- * @param currentHistory
1193
1217
  * @param manifest
1194
1218
  */
1195
- export function buildHistoryJson(ddeJson: DDEJson, currentHistory: any, manifest: Manifest.Manifest): {};
1219
+ export function buildHistoryJson(ddeJson: DDEJson, manifest: Manifest.Manifest): HistoryJson;
1196
1220
  /**
1197
1221
  * Generate the history.json file for the current version
1198
1222
  * @param cwd
1199
1223
  * @param fs
1224
+ * @param logger
1200
1225
  * @param ddeJSON
1201
1226
  */
1202
1227
  export function exportHistoryJson(cwd: URI, fs: LocalFS, logger: Log.Logger, ddeJSON: DDEJson): Promise<void>;
@@ -1227,7 +1252,7 @@ export declare namespace DDE {
1227
1252
  * @param fs
1228
1253
  * @internal
1229
1254
  */
1230
- export function exportDefaultInc(cwd: URI, fs: LocalFS): Promise<void>;
1255
+ export function exportDefaultInc(cwd: URI, fs: LocalFS, logger: Log.Logger): Promise<void>;
1231
1256
  }
1232
1257
 
1233
1258
  export declare namespace DDE_Core {
@@ -1526,6 +1551,10 @@ export declare namespace DefaultFiles {
1526
1551
  legacyAutoUplinkInc: string;
1527
1552
  cfg: string;
1528
1553
  };
1554
+ dde: {
1555
+ path: string;
1556
+ historyJson: string;
1557
+ };
1529
1558
  };
1530
1559
  libdeps: string;
1531
1560
  };
@@ -2309,7 +2338,7 @@ export declare namespace Package {
2309
2338
  * @param selectedParts - choose a specific part that should be build or if true all parts are build
2310
2339
  * @param errorWithDiagnostics
2311
2340
  */
2312
- export function buildAll(cwd: URI, fs: LocalFS, logger: Log.Logger, selectedParts?: APM.Part[] | boolean, errorWithDiagnostics?: boolean): Promise<MergedDiagnostics>;
2341
+ export function buildAll(cwd: URI, fs: LocalFS, logger: Log.Logger, env: Globals.ENV, apiToken: string | null, selectedParts?: APM.Part[] | boolean, errorWithDiagnostics?: boolean): Promise<MergedDiagnostics>;
2313
2342
  /**
2314
2343
  * Trigger the release based on the manifest settings
2315
2344
  * @param cwd
@@ -4674,14 +4703,13 @@ declare interface XMLField {
4674
4703
 
4675
4704
  declare namespace YamlPreCompiler {
4676
4705
  class PreCompiler {
4677
- private manifest;
4678
4706
  private libraryFiles;
4679
4707
  private ddeHistory;
4680
4708
  private readonly fieldNamesPerContainer;
4681
4709
  private readonly usedContainerNames;
4682
4710
  private fileDiagnostics;
4683
4711
  private readonly libraryDDE;
4684
- constructor(manifest: Manifest.Manifest, libraryFiles: DDE_Core.LibraryFile[], ddeHistory: any);
4712
+ constructor(libraryFiles: DDE_Core.LibraryFile[], ddeHistory: DDE.HistoryJson | null);
4685
4713
  /**
4686
4714
  * Parse the given library files and return the diagnostics
4687
4715
  */
package/out/api.js CHANGED
@@ -70,12 +70,14 @@ async function install(cwd, fs, env, apiToken, dependencies) {
70
70
  * @param {URI} cwd - The current working directory where the build process will be executed.
71
71
  * @param {LocalFS} fs - The local file system instance used for file operations during the build.
72
72
  * @param {Logger} logger - Logger instance for logging details during the build process.
73
+ * @param {Globals.ENV} env - The global environment configuration used during the installation.
74
+ * @param {string|null} apiToken - The API token for authentication, if required, or null if not applicable.
73
75
  * @param {APM.Part} selectedParts - The project parts to be built.
74
76
  * @param {boolean} [errorWithDiagnostics] - If true, includes diagnostic details in case of an error.
75
77
  * @return {Promise<Object>} A promise resolved with an object containing diagnostics information for the specified project parts: `dde`, `dlo`, and `dfiles`.
76
78
  */
77
- async function build(cwd, fs, logger, selectedParts = true, errorWithDiagnostics) {
78
- return package_1.Package.buildAll(cwd, fs, logger, selectedParts, errorWithDiagnostics);
79
+ async function build(cwd, fs, logger, env, apiToken = null, selectedParts = true, errorWithDiagnostics) {
80
+ return package_1.Package.buildAll(cwd, fs, logger, env, apiToken, selectedParts, errorWithDiagnostics);
79
81
  }
80
82
  /**
81
83
  * Publishes a package to the registry with the specified settings and configurations.
package/out/dde/dde.js CHANGED
@@ -42,6 +42,7 @@ const dlo_1 = require("./fileGenerators/dlo");
42
42
  const globals_1 = require("../globals");
43
43
  const api_1 = require("./fileGenerators/api");
44
44
  const helper_1 = require("../helper");
45
+ const registryAPI_1 = require("../registryAPI");
45
46
  exports.DDE_PATH = defaultFiles_1.DefaultFiles.filePaths.dde.path;
46
47
  // create file cache.
47
48
  // yaml & json
@@ -94,7 +95,7 @@ var DDE;
94
95
  async function compileDDE(cwd, fs, logger, fileName = defaultFiles_1.DefaultFiles.fileNames.mainDDE) {
95
96
  const validated = await validate(cwd, fs, logger, fileName);
96
97
  const historyJson = await getHistoryJson(cwd, fs, logger);
97
- const preCompiler = new yamlDdePreCompiler_1.YamlPreCompiler.PreCompiler(validated.manifest, validated.libraryFiles, historyJson);
98
+ const preCompiler = new yamlDdePreCompiler_1.YamlPreCompiler.PreCompiler(validated.libraryFiles, historyJson);
98
99
  const libraryDiagnostics = preCompiler.parseLibraries();
99
100
  const librariesHaveError = libraryDiagnostics.find(diagnostics => diagnostics.level === 'error');
100
101
  if (librariesHaveError) {
@@ -136,8 +137,8 @@ var DDE;
136
137
  * @param ddeHistory
137
138
  * @constructor
138
139
  */
139
- DDE.PreCompiler = (manifest, libraries, ddeHistory) => {
140
- return new yamlDdePreCompiler_1.YamlPreCompiler.PreCompiler(manifest, libraries, ddeHistory);
140
+ DDE.PreCompiler = (libraries, ddeHistory) => {
141
+ return new yamlDdePreCompiler_1.YamlPreCompiler.PreCompiler(libraries, ddeHistory);
141
142
  };
142
143
  /**
143
144
  * File Generators
@@ -163,54 +164,130 @@ var DDE;
163
164
  logger.log('Generated', defaultFiles_1.DefaultFiles.filePaths.dist.ddeXmlPath);
164
165
  }
165
166
  DDE.exportMyDatanetXML = exportMyDatanetXML;
167
+ /**
168
+ * Fetches the DDE history JSON of a previous version of an app and saves it to a designated file path.
169
+ *
170
+ * The method removes any previously fetched version of the DDE JSON file and fetches the configuration
171
+ * of the previous stable version of the app from a remote registry. If a valid DDE file exists for the previous version, it is downloaded
172
+ * and stored at the specified location.
173
+ *
174
+ * @param {URI} cwd - The current working directory of the project.
175
+ * @param {LocalFS} fs - The local filesystem utility for performing file operations.
176
+ * @param {Log.Logger} logger - Logger instance for logging informational, warning, and error messages.
177
+ * @param {Globals.ENV} env - The environment configuration parameters.
178
+ * @param {string|null} apiToken - The API authentication token for accessing the registry. A null value will prevent fetching the DDE JSON file.
179
+ * @return {Promise<void>} Resolves with no value if the process completes successfully or returns early for validation or fetch failures.
180
+ */
181
+ async function fetchPreviousHistoryJson(cwd, fs, logger, env, apiToken) {
182
+ // remove the previous fetched version beforehand.
183
+ const previousDDEPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.studio.auto.dde.historyJson);
184
+ await fs.rm(previousDDEPath).catch(console.error);
185
+ const manifest = await manifest_1.Manifest.read(cwd, fs);
186
+ // only validate if the project is an app and has a registry id
187
+ if (!manifest_1.Manifest.isApp(manifest) || !manifest.registry?.id) {
188
+ return;
189
+ }
190
+ if (!apiToken) {
191
+ logger.warn('Could not fetch dde of previous version: No API token provided.');
192
+ return;
193
+ }
194
+ const currentVersion = semver.valid(manifest.version) ? manifest.version : semver.coerce(manifest.version);
195
+ try {
196
+ const appProfile = await registryAPI_1.Registry.getExistingApplication(apiToken, manifest.publisher, manifest.registry.id, env);
197
+ const appVersions = appProfile.versions;
198
+ // find the previous version
199
+ const previousVersion = appVersions.find(version => {
200
+ // the appProfile is fetched with semver header true, therefore is the version.version a valid semver string.
201
+ return !semver.prerelease(version.version) && semver.lt(version.version, currentVersion);
202
+ });
203
+ const versionFile = previousVersion?.files.find(file => file.name === 'dde.json');
204
+ if (!versionFile) {
205
+ // the version does not have a dde.json file
206
+ logger.warn('Could not find a valid previous released app version to fetch the previous dde from.');
207
+ return;
208
+ }
209
+ const request = await fetch(versionFile.downloadUrl, {
210
+ headers: {
211
+ ...(0, registryAPI_1.buildAuthHeader)(apiToken),
212
+ ...registryAPI_1.Registry.injectSemverHeader(true)
213
+ }
214
+ });
215
+ if (request.status !== 200) {
216
+ // the version does not have a dde.json file
217
+ logger.warn(`Could not fetch the dde.json of version "${previousVersion?.version}"`);
218
+ return;
219
+ }
220
+ const historyJson = await request.text();
221
+ await fs.writeFile(previousDDEPath, historyJson);
222
+ logger.log(`Saved history.json of previous app version ${previousVersion.version}`);
223
+ }
224
+ catch (e) {
225
+ logger.error('Failed to fetch the dde of previous version', e);
226
+ }
227
+ }
228
+ DDE.fetchPreviousHistoryJson = fetchPreviousHistoryJson;
166
229
  /**
167
230
  * Read the correct history.json file from the project
168
231
  * @param cwd
169
232
  * @param fs
233
+ * @param logger
170
234
  */
171
235
  async function getHistoryJson(cwd, fs, logger) {
172
- const historyPath = vscode_uri_1.Utils.joinPath(cwd, exports.DDE_PATH, 'history.json');
173
236
  try {
174
- const binary = await fs.readFile(historyPath);
175
- const historyString = convertBlobToString(binary);
176
- return JSON.parse(historyString);
237
+ const prevHistoryPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.studio.auto.dde.historyJson);
238
+ if (await fs.stat(prevHistoryPath)) {
239
+ const binary = await fs.readFile(prevHistoryPath);
240
+ return JSON.parse(convertBlobToString(binary));
241
+ }
242
+ // fallback to previous history.json located within the projects dde directory
243
+ const historyPath = vscode_uri_1.Utils.joinPath(cwd, exports.DDE_PATH, 'history.json');
244
+ if (await fs.stat(historyPath)) {
245
+ logger.warn(`"${defaultFiles_1.DefaultFiles.filePaths.studio.auto.dde.historyJson}" does not exist - fallback to "${exports.DDE_PATH}history.json"`);
246
+ const binary = await fs.readFile(historyPath);
247
+ const historyJson = JSON.parse(convertBlobToString(binary));
248
+ const manifest = await manifest_1.Manifest.read(cwd, fs);
249
+ const currentSemver = semver.coerce(manifest.version)?.version;
250
+ // get previous dde version
251
+ const prev = Object.keys(historyJson || {})
252
+ .sort(semver.rcompare)
253
+ .find(version => version !== currentSemver);
254
+ if (!prev) {
255
+ return null;
256
+ }
257
+ const newHistoryFormat = historyJson[prev];
258
+ return { version: prev, ...newHistoryFormat };
259
+ }
177
260
  }
178
261
  catch (e) {
179
- logger.warn('history.json does not exist');
180
- return {};
262
+ logger.error('Failed to read history.json', e);
181
263
  }
264
+ logger.warn('history.json does not exist');
265
+ return null;
182
266
  }
183
267
  DDE.getHistoryJson = getHistoryJson;
184
268
  /**
185
269
  * Generate the object for the history.json
186
270
  * @param ddeJson
187
- * @param currentHistory
188
271
  * @param manifest
189
272
  */
190
- function buildHistoryJson(ddeJson, currentHistory, manifest) {
273
+ function buildHistoryJson(ddeJson, manifest) {
191
274
  const currentVersion = semver.coerce(manifest.version)?.version || '1.0.0';
192
- const fullMap = { ...currentHistory };
193
- fullMap[currentVersion] = { ...ddeJson };
194
- delete fullMap[currentVersion]['defines'];
195
- return Object.keys(fullMap)
196
- .sort(semver.rcompare)
197
- .reduce((obj, key) => {
198
- //@ts-ignore
199
- obj[key] = fullMap[key];
200
- return obj;
201
- }, {});
275
+ return {
276
+ version: currentVersion,
277
+ ...structuredClone(ddeJson)
278
+ };
202
279
  }
203
280
  DDE.buildHistoryJson = buildHistoryJson;
204
281
  /**
205
282
  * Generate the history.json file for the current version
206
283
  * @param cwd
207
284
  * @param fs
285
+ * @param logger
208
286
  * @param ddeJSON
209
287
  */
210
288
  async function exportHistoryJson(cwd, fs, logger, ddeJSON) {
211
- const currentHistory = await getHistoryJson(cwd, fs, logger);
212
289
  const manifest = await manifest_1.Manifest.read(cwd, fs);
213
- const newHistory = buildHistoryJson(ddeJSON, currentHistory, manifest);
290
+ const newHistory = buildHistoryJson(ddeJSON, manifest);
214
291
  const historyPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.historyJson);
215
292
  await fs.writeFile(historyPath, JSON.stringify(newHistory, null, '\t'));
216
293
  logger.log('Generated', defaultFiles_1.DefaultFiles.filePaths.dist.historyJson);
@@ -266,7 +343,7 @@ var DDE;
266
343
  const autoDdeMainPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.autoDdeInc.replace('X', 'main'));
267
344
  await fs.writeFile(autoDdeMainPath, mainDDEInc);
268
345
  logger.log('Generated', defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.autoDdeInc.replace('X', 'main'));
269
- await exportDefaultInc(cwd, fs);
346
+ await exportDefaultInc(cwd, fs, logger);
270
347
  }
271
348
  DDE.exportAutoDloFiles = exportAutoDloFiles;
272
349
  /**
@@ -301,11 +378,11 @@ var DDE;
301
378
  * @param fs
302
379
  * @internal
303
380
  */
304
- async function exportDefaultInc(cwd, fs) {
381
+ async function exportDefaultInc(cwd, fs, logger) {
305
382
  const defaultIncPaht = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.defaultInc);
306
383
  const content = await (0, dlo_1.buildDefaultInc)(cwd, fs);
307
384
  await fs.writeFile(defaultIncPaht, content);
308
- console.log('Generated', defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.defaultInc);
385
+ logger.log('Generated', defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.defaultInc);
309
386
  }
310
387
  DDE.exportDefaultInc = exportDefaultInc;
311
388
  })(DDE || (exports.DDE = DDE = {}));
@@ -1,32 +1,8 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.YamlPreCompiler = void 0;
27
4
  const yaml_1 = require("yaml");
28
5
  const diagnostics_1 = require("../diagnostics");
29
- const semver = __importStar(require("semver"));
30
6
  const coreDefinitions_1 = require("./coreDefinitions");
31
7
  const helper_1 = require("../helper");
32
8
  var DDEContainerName = coreDefinitions_1.DDE_Core.DDEContainerName;
@@ -45,15 +21,13 @@ var yamlRangeToLineInformation = helper_1.Helper.yamlRangeToLineInformation;
45
21
  var YamlPreCompiler;
46
22
  (function (YamlPreCompiler) {
47
23
  class PreCompiler {
48
- manifest;
49
24
  libraryFiles;
50
25
  ddeHistory;
51
26
  fieldNamesPerContainer = {};
52
27
  usedContainerNames = {};
53
28
  fileDiagnostics = [];
54
29
  libraryDDE = [];
55
- constructor(manifest, libraryFiles, ddeHistory) {
56
- this.manifest = manifest;
30
+ constructor(libraryFiles, ddeHistory) {
57
31
  this.libraryFiles = libraryFiles;
58
32
  this.ddeHistory = ddeHistory;
59
33
  }
@@ -71,33 +45,11 @@ var YamlPreCompiler;
71
45
  return libDiagnostics;
72
46
  }
73
47
  get previousVersion() {
74
- const currentSemver = semver.coerce(this.manifest.version)?.version;
75
- // get previous dde version
76
- const prev = Object.keys(this.ddeHistory || {})
77
- .sort(semver.rcompare)
78
- .find(version => version !== currentSemver);
79
- const previousDDE = prev ? this.ddeHistory[prev] : { setPointList: {}, containers: {} };
80
- // 04.04.2024 handle old DDEJson description:
81
- if (!Object.hasOwn(previousDDE, 'containers')) {
82
- previousDDE.containers = {};
83
- for (const [container, containerDefinition] of Object.entries(previousDDE)) {
84
- if (['setPointList', 'containers'].includes(container)) {
85
- continue;
86
- }
87
- previousDDE.containers[container] = containerDefinition;
88
- delete previousDDE[container];
89
- }
90
- }
91
- return previousDDE;
48
+ return { setPointList: { ...this.ddeHistory?.setPointList }, containers: { ...this.ddeHistory?.containers } };
92
49
  }
93
50
  getContainerOfPreviousVersion(containerName) {
94
51
  const previousDDE = this.previousVersion;
95
- if (Object.hasOwn(previousDDE.containers, containerName)) {
96
- return previousDDE.containers[containerName];
97
- }
98
- else {
99
- return null;
100
- }
52
+ return (Object.values(previousDDE.containers).find(containerDefinition => containerDefinition.title === containerName) || null);
101
53
  }
102
54
  parseMainDDE(filePath, yaml) {
103
55
  const { parsedDDE, diagnostics } = this.parseYamlFile(filePath, yaml);
@@ -30,6 +30,7 @@ var DefaultFiles;
30
30
  };
31
31
  const studioAutoPath = `${studioDirectoryName}auto/`;
32
32
  const studioAutoDloPath = `${studioAutoPath}dlo/`;
33
+ const studioAutoDdePath = `${studioAutoPath}dde/`;
33
34
  DefaultFiles.filePaths = {
34
35
  studio: {
35
36
  // init file to test if we can write to the workspace
@@ -48,6 +49,10 @@ var DefaultFiles;
48
49
  legacyAutoDdeInc: `${studioAutoDloPath}${DefaultFiles.fileNames.legacyAutoDdeInc}`,
49
50
  legacyAutoUplinkInc: `${studioAutoDloPath}${DefaultFiles.fileNames.legacyAutoUplinkInc}`,
50
51
  cfg: `${studioAutoDloPath}${DefaultFiles.fileNames.dloCfg}`
52
+ },
53
+ dde: {
54
+ path: studioAutoDdePath,
55
+ historyJson: `${studioAutoDdePath}${DefaultFiles.fileNames.historyJson}`
51
56
  }
52
57
  },
53
58
  libdeps: `${studioDirectoryName}libdeps/`
@@ -61,7 +66,7 @@ var DefaultFiles;
61
66
  ddeApiPath: `${deployDirectoryName}api/`,
62
67
  ddeApi: `${deployDirectoryName}api/${DefaultFiles.fileNames.ddeOpenApi}`,
63
68
  // ddeJson has changed to history.json and is now in dde/ dir
64
- historyJson: `${ddeDirectoryName}${DefaultFiles.fileNames.historyJson}`,
69
+ historyJson: `${deployDirectoryName}dde/${DefaultFiles.fileNames.historyJson}`,
65
70
  povPath: `${deployDirectoryName}pov`,
66
71
  povDetailsPath: `${deployDirectoryName}pov/details`,
67
72
  dfilesPath: `${deployDirectoryName}dfiles`,
package/out/main.js CHANGED
@@ -84,8 +84,12 @@ program
84
84
  program
85
85
  .command('build')
86
86
  .addOption(new commander_1.Option('-p --part <APM part>', 'APM part that should be build').choices(Object.values(apm_1.APM.Part)))
87
+ .allowExcessArguments(true)
88
+ .addOption(optionStudioEnv)
89
+ .addOption(optionStudioToken)
87
90
  .action(opts => {
88
- main((0, api_1.build)(cwd, cliFS_1.cliFS, logger, opts.part));
91
+ const { env, token } = getDefaultOptions(opts);
92
+ main((0, api_1.build)(cwd, cliFS_1.cliFS, logger, env, token, opts.part));
89
93
  });
90
94
  const releasePhaseArguments = Object.values(apm_1.APM.TagPhase);
91
95
  program
@@ -285,7 +285,10 @@ async function addAdditionalFiles(cwd, fs, apmBuffer) {
285
285
  const reportTemplateBlob = new Blob([await fs.readFile(reportTemplate)]);
286
286
  apmBuffer.append(`bin/pov/mdn_report_template.json`, reportTemplateBlob);
287
287
  }
288
+ // pass the current versions history json to the apm tag
288
289
  const historyPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.historyJson);
289
- apmBuffer.append(`src/dde/${manifest_1.Manifest.fileName}`, new Blob([await fs.readFile(historyPath)]));
290
+ if (await fs.stat(historyPath)) {
291
+ apmBuffer.append(`src/dde/history.json`, new Blob([await fs.readFile(historyPath)]));
292
+ }
290
293
  }
291
294
  //# sourceMappingURL=apm.js.map
@@ -36,8 +36,9 @@ var Package;
36
36
  * @param selectedParts - choose a specific part that should be build or if true all parts are build
37
37
  * @param errorWithDiagnostics
38
38
  */
39
- async function buildAll(cwd, fs, logger, selectedParts = true, errorWithDiagnostics) {
39
+ async function buildAll(cwd, fs, logger, env, apiToken, selectedParts = true, errorWithDiagnostics) {
40
40
  selectedParts = normalizeSelectedParts(logger, selectedParts);
41
+ await preBuild(cwd, fs, logger, env, apiToken, selectedParts);
41
42
  const mergedDiagnostics = {
42
43
  [apm_1.APM.Part.dde]: [],
43
44
  [apm_1.APM.Part.dlo]: [],
@@ -133,7 +134,7 @@ var Package;
133
134
  return;
134
135
  }
135
136
  // build the complete project
136
- await buildAll(cwd, fs, logger);
137
+ await buildAll(cwd, fs, logger, env, token);
137
138
  // update the store apm with the actual name/description/...
138
139
  await apm_1.APM.updateProfile(cwd, fs, token, env);
139
140
  const tagContent = await apm_1.APM.createTag(cwd, fs, releasePhase);
@@ -162,7 +163,7 @@ var Package;
162
163
  await manifest_1.Manifest.validateBasicManifest(cwd, fs, manifest);
163
164
  await validatePublishSettings(cwd, fs, token, env);
164
165
  // build the complete project
165
- await buildAll(cwd, fs, logger);
166
+ await buildAll(cwd, fs, logger, env, token);
166
167
  const archive = await library_1.Library.createArchive(cwd, fs);
167
168
  await library_1.Library.publishPackage(cwd, fs, token, archive, env);
168
169
  logger.done(`Library "${manifest.publisher}/${manifest.name}" with version "${manifest.version}" published!`);
@@ -264,6 +265,22 @@ function normalizeSelectedParts(logger, selectedParts) {
264
265
  }
265
266
  return selectedParts;
266
267
  }
268
+ /**
269
+ * Prepares the build process by performing pre-build operations based on the selected parts.
270
+ *
271
+ * @param {URI} cwd - The current working directory for the build process.
272
+ * @param {LocalFS} fs - The file system abstraction used for file operations.
273
+ * @param {Log.Logger} logger - The logger instance for logging messages during the process.
274
+ * @param {Globals.ENV} env - The environment variables and configuration for the process.
275
+ * @param {string|null} apiToken - The API token used for authentication, or null if not required.
276
+ * @param {APM.Part[]} selectedParts - An array of selected parts indicating specific build steps to execute.
277
+ * @return {Promise<void>} A promise that resolves when the pre-build process completes.
278
+ */
279
+ async function preBuild(cwd, fs, logger, env, apiToken, selectedParts) {
280
+ if (selectedParts.includes(apm_1.APM.Part.dde)) {
281
+ await dde_1.DDE.fetchPreviousHistoryJson(cwd, fs, logger, env, apiToken);
282
+ }
283
+ }
267
284
  /**
268
285
  * Generates all needed files out of the dde declaration
269
286
  * @param cwd
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microtronics/studio-cli",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "Microtronics Studio CLI Tool",
5
5
  "main": "./out/api.js",
6
6
  "typings": "./dist/studio-cli.d.ts",