@microtronics/studio-cli 0.12.2 → 0.14.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,5 +1,30 @@
1
1
 
2
2
 
3
+ ## 0.14.0 (2025-01-29)
4
+
5
+
6
+ ### Features
7
+
8
+ * **studio-core:** allow editing the release notes of iot app versions ([2d19d13](https://bitbucket.org/microtronics-core/vscode-studio/commits/2d19d13ca32cceaf4a574a9594563d6dc0931fc5))
9
+
10
+ ## 0.13.0 (2025-01-29)
11
+
12
+
13
+ ### Features
14
+
15
+ * **studio-cli:** add `FS.copy` as filesystem function ([59c252c](https://bitbucket.org/microtronics-core/vscode-studio/commits/59c252cb2afd223a43376a2b220c20bd2d7c1761))
16
+ * **studio-cli:** allow processing dfiles from the cli ([6162326](https://bitbucket.org/microtronics-core/vscode-studio/commits/6162326b30412a05cb62ebd40a272e644bd0d970))
17
+ * **studio-cli:** generate error message if the dfile sync_mode is invalid ([87ae69b](https://bitbucket.org/microtronics-core/vscode-studio/commits/87ae69b4bcf3a928892335dadba7e49668b1a6e1))
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **studio-cli:** cliFS interface did not create target path during copy ([641886d](https://bitbucket.org/microtronics-core/vscode-studio/commits/641886d776e2fe158314effc00760b12cca514bd))
23
+ * **studio-cli:** copy dfiles from libraries ([e746dcd](https://bitbucket.org/microtronics-core/vscode-studio/commits/e746dcd31a8095226ef22434b5612536c987a595))
24
+ * **studio-cli:** invalidate manifest cache if file path changes (only needed for tests) ([db30907](https://bitbucket.org/microtronics-core/vscode-studio/commits/db309072028d59ece85167a03f3a77b9a1575f59))
25
+ * **studio-cli:** invalidate manifest cache if filesize doesn't match ([daeb437](https://bitbucket.org/microtronics-core/vscode-studio/commits/daeb4371696de9e13608cbe6f3bab1ae1c01da24))
26
+ * **studio-cli:** invalidate manifest cache if filesize doesn't match ([30947ab](https://bitbucket.org/microtronics-core/vscode-studio/commits/30947ab55152ceb5c269dda695cd3f262cae82b9))
27
+
3
28
  ## 0.12.2 (2025-01-27)
4
29
 
5
30
 
@@ -17,7 +17,8 @@ export declare namespace APM {
17
17
  dde = "dde",
18
18
  dlo = "dlo",
19
19
  pov = "pov",
20
- blo = "blo"
20
+ blo = "blo",
21
+ dfiles = "dfiles"
21
22
  }
22
23
  export interface TagHeader extends ApplicationTagInformation {
23
24
  author: string;
@@ -1612,7 +1613,7 @@ export declare namespace Dependencies {
1612
1613
  * @param libraryName
1613
1614
  */
1614
1615
  export function uninstallDependency(cwd: URI, fs: LocalFS, publisherId: string, libraryName: string): Promise<void>;
1615
- export interface DLOLibrary {
1616
+ export interface APMPartLibrary {
1616
1617
  name: string;
1617
1618
  path: URI;
1618
1619
  }
@@ -1620,12 +1621,56 @@ export declare namespace Dependencies {
1620
1621
  * Get all libraries that have dlo source
1621
1622
  * @param cwd
1622
1623
  * @param fs
1624
+ * @param apmPart currently only dlo and dfiles are supported
1623
1625
  */
1624
- export function getDloDependencies(cwd: URI, fs: LocalFS): Promise<DLOLibrary[]>;
1626
+ export function getApmPartDependencies(cwd: URI, fs: LocalFS, apmPart: APM.Part.dlo | APM.Part.dfiles): Promise<APMPartLibrary[]>;
1625
1627
  }
1626
1628
 
1627
1629
  export declare const DeviceProfiles: any;
1628
1630
 
1631
+ export declare namespace DFILES {
1632
+ export enum Type {
1633
+ static = "static",
1634
+ dynamic = "dynamic"
1635
+ }
1636
+ export enum SyncLogic {
1637
+ crcStamp = "crc_stamp",
1638
+ stampOnly = "stamp_only",
1639
+ onlyDown = "only_down",
1640
+ onlyUp = "only_up"
1641
+ }
1642
+ export enum Force {
1643
+ down = "down",
1644
+ up = "up",
1645
+ off = "off"
1646
+ }
1647
+ export interface Property {
1648
+ type: Type;
1649
+ size: number;
1650
+ sync_logic: SyncLogic;
1651
+ force: Force;
1652
+ readable: boolean;
1653
+ crc: string;
1654
+ stamp: number;
1655
+ library: string | null;
1656
+ }
1657
+ export interface PropertyList {
1658
+ [key: string]: Property;
1659
+ }
1660
+ export function process(cwd: URI, fs: LocalFS): Promise<Diagnostics.File[]>;
1661
+ /**
1662
+ *
1663
+ * @param fs
1664
+ * @param fileUri
1665
+ * @param libraryName
1666
+ * @private
1667
+ */
1668
+ export function parseYamlFile(fs: LocalFS, fileUri: URI, libraryName: string | null): Promise<{
1669
+ properties: DFILES.PropertyList;
1670
+ diagnostics: Diagnostics.File[];
1671
+ }>;
1672
+ }
1673
+
1629
1674
  export declare namespace Diagnostics {
1630
1675
  const CODE: {
1631
1676
  ddeFieldLength: string;
@@ -1899,6 +1944,13 @@ export declare namespace Helper {
1899
1944
  * @param arrayIndex
1900
1945
  */
1901
1946
  export function patchValueWithArrayInfo(valueToPatch: any, arrayIndex: number): any;
1947
+ /**
1948
+ * Defer a given named task
1949
+ * @param token
1950
+ * @param timeout Milliseconds
1951
+ * @param callback Callback
1952
+ */
1953
+ export function defer(token: string, timeout: number, callback: any): void;
1902
1954
  }
1903
1955
 
1904
1956
  export declare namespace Library {
@@ -1963,6 +2015,14 @@ declare interface LocalFS {
1963
2015
  * {@link workspace.workspaceFolders workspace folders} are opened.
1964
2016
  */
1965
2017
  findFiles: (cwd: URI, include: GlobPattern, exclude?: GlobPattern) => Promise<URI[]>;
2018
+ /**
2019
+ * Copy files or folders.
2020
+ * Overwrites existing file
2021
+ *
2022
+ * @param source The existing file.
2023
+ * @param target The destination location.
2024
+ */
2025
+ copy: (source: URI, target: URI) => Promise<any>;
1966
2026
  }
1967
2027
 
1968
2028
  export declare namespace Manifest {
@@ -1983,10 +2043,6 @@ export declare namespace Manifest {
1983
2043
  library?: boolean;
1984
2044
  libraryDependencies?: Dependencies;
1985
2045
  libraryDevDependencies?: Dependencies;
1986
- /**
1987
- * @deprecated replaced with libraryDependencies
1988
- */
1989
- libdeps?: string[];
1990
2046
  dlo?: {
1991
2047
  mainFile: string;
1992
2048
  compileOptions: string[];
@@ -1994,12 +2050,7 @@ export declare namespace Manifest {
1994
2050
  registry?: {
1995
2051
  id?: string;
1996
2052
  allowedBackends?: null | '*' | string[];
1997
- target?: 'myDatanet' | 'ONE' | 'MT360';
1998
2053
  };
1999
- /**
2000
- * @deprecated moved to registry
2001
- */
2002
- target?: 'myDatanet' | 'ONE' | 'MT360';
2003
2054
  pov?: {
2004
2055
  details?: ApmPartScripts;
2005
2056
  };
@@ -2052,15 +2103,16 @@ export declare namespace Manifest {
2052
2103
  * @param fs
2053
2104
  * @param manifest
2054
2105
  * @param env
2055
- * @param publish - validate publish related options
2056
2106
  */
2057
- export function validateManifest(cwd: URI, fs: LocalFS, manifest: Manifest.Manifest | null, publish: boolean, env?: Globals.ENV): Promise<void>;
2058
- export function validateLibraryName(libraryName: string): false | "Library name can only contain 'a' through 'z', '0' through '9', '_' and '-'. The Library name must start with an alphabetic or numeric character." | "The library name is beyond permissible length of 20 characters.";
2059
- export function validateProjectName(name: string, isLibrary?: boolean): Promise<false | "Library name can only contain 'a' through 'z', '0' through '9', '_' and '-'. The Library name must start with an alphabetic or numeric character." | "The library name is beyond permissible length of 20 characters." | "Project name can only contain 'A' through 'Z', 'a' through 'z', '0' through '9', ' ', '_' and '-'. The Project name must start with an alphabetic or numeric character." | "The project name is beyond permissible length of 40 characters.">;
2060
- export function validateDescription(description: string): Promise<false | "The description must have at least 5 characters.">;
2061
- export function validatePublisherId(publisher: string): Promise<false | "No publisher set yet" | "Publisher can only contain 'A' through 'Z', 'a' through 'z', '0' through '9' and '-'. The Publisher start with an alphabetic or numeric character.">;
2062
- export function validatePublisherOnline(token: Registry.AuthToken, publisher: string): Promise<string | false>;
2063
- export function validateRegistryAllowedBackends(allowedBackends: undefined | null | string | string[]): Promise<string | false>;
2107
+ export function validateBasicManifest(cwd: URI, fs: LocalFS, manifest: Manifest.Manifest | null, env?: Globals.ENV): Promise<void>;
2108
+ export function validateLibraryName(libraryName: string): "Library name can only contain 'a' through 'z', '0' through '9', '_' and '-'. The Library name must start with an alphabetic or numeric character." | "The library name is beyond permissible length of 20 characters." | null;
2109
+ export function validateProjectName(name: string, isLibrary?: boolean): "Library name can only contain 'a' through 'z', '0' through '9', '_' and '-'. The Library name must start with an alphabetic or numeric character." | "The library name is beyond permissible length of 20 characters." | "Project name can only contain 'A' through 'Z', 'a' through 'z', '0' through '9', ' ', '_' and '-'. The Project name must start with an alphabetic or numeric character." | "The project name is beyond permissible length of 40 characters." | null;
2110
+ export function validateDescription(description: string): "The description must have at least 5 characters." | null;
2111
+ export function validatePublisherId(publisher: string): "No publisher set yet" | "Publisher can only contain 'A' through 'Z', 'a' through 'z', '0' through '9' and '-'. The Publisher start with an alphabetic or numeric character." | null;
2112
+ export function validatePublisherOnline(token: Registry.AuthToken, publisher: string): Promise<string | null>;
2113
+ export function validateRegistryAllowedBackends(allowedBackends: undefined | null | string | string[]): Promise<string | null>;
2114
+ export function validateApplicationIcon(cwd: URI, fs: LocalFS, manifest: Manifest.Manifest): Promise<void>;
2115
+ export function validateEngineSettings(manifest: Manifest.Manifest): void;
2064
2116
  }
2065
2117
 
2066
2118
  export declare namespace Package {
@@ -2114,10 +2166,11 @@ export declare namespace Package {
2114
2166
  export function getChangelogFile(cwd: URI, fs: LocalFS): Promise<Uint8Array>;
2115
2167
  /**
2116
2168
  * Validate manifest settings that are required for the APM
2169
+ * @param cwd
2170
+ * @param fs
2117
2171
  * @param token
2118
- * @param manifest
2119
2172
  */
2120
- export function validateSpecificSettings(token: Registry.AuthToken, manifest: Manifest.Manifest): Promise<void>;
2173
+ export function validatePublishSettings(cwd: URI, fs: LocalFS, token: Registry.AuthToken): Promise<void>;
2121
2174
  }
2122
2175
 
2123
2176
  /**
@@ -3312,7 +3365,7 @@ declare interface paths {
3312
3365
  patch?: never;
3313
3366
  trace?: never;
3314
3367
  };
3315
- "/packages/{publisherId}/applications/{applicationId}/versions/{applicationVersion}/files/{fileName}": {
3368
+ "/packages/{publisherId}/applications/{applicationId}/versions/{applicationVersion}/files/{applicationFileName}": {
3316
3369
  parameters: {
3317
3370
  query?: never;
3318
3371
  header?: never;
@@ -4188,7 +4241,7 @@ export declare namespace Registry {
4188
4241
  * @param libraryId
4189
4242
  */
4190
4243
  export function getLibraryProfile(token: AuthToken, publisherId: string, libraryId: string): Promise<LibraryProfile>;
4191
- export function fetchLibraryContent(token: AuthToken, contentURL: string, json?: boolean): Promise<any>;
4244
+ export function fetchCustomContent(token: AuthToken, contentURL: string, json?: boolean, env?: Globals.ENV): Promise<ArrayBuffer | any>;
4192
4245
  export type Publisher = components['schemas']['Publisher'];
4193
4246
  export function getPublisher(token: AuthToken, publisherId: string): Promise<Publisher | null>;
4194
4247
  export type ApiNewApplication = components['schemas']['NewApplication'];
@@ -4205,6 +4258,8 @@ export declare namespace Registry {
4205
4258
  'CHANGELOG.md': Uint8Array;
4206
4259
  };
4207
4260
  export function publishLibraryVersion(token: AuthToken, publisherId: string, libraryId: string, libraryVersion: string, files: LibraryFiles, env?: Globals.ENV): Promise<void>;
4261
+ export type ApplicationFileName = components['parameters']['ApplicationFileName'];
4262
+ export function updateApplicationFile(token: AuthToken, publisherId: string, applicationId: string, applicationVersion: string, applicationFileName: ApplicationFileName, blob: Uint8Array, env?: Globals.ENV): Promise<void>;
4208
4263
  }
4209
4264
 
4210
4265
  declare function uriToMemFsPath(path: URI): string;
package/out/api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Library = exports.APM = exports.Package = exports.DLO = exports.Globals = exports.DeviceProfiles = exports.DefaultFiles = exports.Diagnostics = exports.Helper = exports.DDE = exports.DDE_Core = exports.Registry = exports.Manifest = exports.Dependencies = void 0;
3
+ exports.DFILES = exports.Library = exports.APM = exports.Package = exports.DLO = exports.Globals = exports.DeviceProfiles = exports.DefaultFiles = exports.Diagnostics = exports.Helper = exports.DDE = exports.DDE_Core = exports.Registry = exports.Manifest = exports.Dependencies = void 0;
4
4
  const dependencies_1 = require("./dependencies");
5
5
  Object.defineProperty(exports, "Dependencies", { enumerable: true, get: function () { return dependencies_1.Dependencies; } });
6
6
  const manifest_1 = require("./manifest");
@@ -29,4 +29,6 @@ const apm_1 = require("./package/apm");
29
29
  Object.defineProperty(exports, "APM", { enumerable: true, get: function () { return apm_1.APM; } });
30
30
  const library_1 = require("./package/library");
31
31
  Object.defineProperty(exports, "Library", { enumerable: true, get: function () { return library_1.Library; } });
32
+ const dfiles_1 = require("./dfiles/dfiles");
33
+ Object.defineProperty(exports, "DFILES", { enumerable: true, get: function () { return dfiles_1.DFILES; } });
32
34
  //# sourceMappingURL=api.js.map
package/out/cliFS.js CHANGED
@@ -56,6 +56,16 @@ exports.cliFS = {
56
56
  const posix = file.replace(/\\/g, '/');
57
57
  return vscode_uri_1.URI.parse(`file:///${posix}`);
58
58
  });
59
+ },
60
+ async copy(source, target) {
61
+ const stat = await promises_1.default.stat(source.fsPath);
62
+ await promises_1.default.mkdir(vscode_uri_1.Utils.dirname(target).fsPath, { recursive: true });
63
+ if (stat.isDirectory()) {
64
+ return promises_1.default.cp(source.fsPath, target.fsPath, { force: true, recursive: true });
65
+ }
66
+ else {
67
+ return promises_1.default.copyFile(source.fsPath, target.fsPath);
68
+ }
59
69
  }
60
70
  };
61
71
  //# sourceMappingURL=cliFS.js.map
@@ -44,6 +44,7 @@ const vscode_uri_1 = require("vscode-uri");
44
44
  const defaultFiles_1 = require("../../defaultFiles");
45
45
  const dependencies_1 = require("../../dependencies");
46
46
  var isNumeric = helper_1.Helper.isNumeric;
47
+ const apm_1 = require("../../package/apm");
47
48
  /** get effective field type for pawn access (may be overriden or skipped using attribute dlorw=...)
48
49
  * @return {*} | 'skip' | null - null=error occured
49
50
  */
@@ -916,7 +917,7 @@ function generateMainDDEFunctionBody(pawnSource, containerDefinition, readWrite)
916
917
  */
917
918
  async function buildDefaultInc(cwd, fs) {
918
919
  const fileContent = [];
919
- const dloLibs = await dependencies_1.Dependencies.getDloDependencies(cwd, fs);
920
+ const dloLibs = await dependencies_1.Dependencies.getApmPartDependencies(cwd, fs, apm_1.APM.Part.dlo);
920
921
  await addInclude(cwd, fs, fileContent, defaultFiles_1.DefaultFiles.fileNames.autoInc);
921
922
  const autoDdeIncs = await getAutoDDEIncludes(cwd, fs, dloLibs);
922
923
  for (const dloLib of dloLibs) {
@@ -29,6 +29,7 @@ const manifest_1 = require("./manifest");
29
29
  const semver = __importStar(require("semver"));
30
30
  const registryAPI_1 = require("./registryAPI");
31
31
  const defaultFiles_1 = require("./defaultFiles");
32
+ const apm_1 = require("./package/apm");
32
33
  const tinytar = require('tinytar-fix');
33
34
  const pako = require('pako');
34
35
  exports.LIB_DEPS_PATH = '.studio/libdeps';
@@ -236,7 +237,7 @@ var Dependencies;
236
237
  if (!libraryArchive) {
237
238
  throw new Error(`Library ${publisherIdName} has no content!`);
238
239
  }
239
- const libraryBuffer = await registryAPI_1.Registry.fetchLibraryContent(token, libraryArchive.downloadUrl);
240
+ const libraryBuffer = await registryAPI_1.Registry.fetchCustomContent(token, libraryArchive.downloadUrl);
240
241
  await extractLibraryContent(cwd, fs, libraryName, libraryBuffer);
241
242
  // update manifest
242
243
  const manifest = await manifest_1.Manifest.read(cwd, fs);
@@ -300,18 +301,22 @@ var Dependencies;
300
301
  * Get all libraries that have dlo source
301
302
  * @param cwd
302
303
  * @param fs
304
+ * @param apmPart currently only dlo and dfiles are supported
303
305
  */
304
- async function getDloDependencies(cwd, fs) {
306
+ async function getApmPartDependencies(cwd, fs, apmPart) {
305
307
  const manifest = await manifest_1.Manifest.read(cwd, fs);
306
308
  const allDependencies = await getAll(manifest);
307
- const dloDependencies = [];
309
+ const apmDependencies = [];
310
+ // @ts-ignore
311
+ const defaultApmPath = defaultFiles_1.DefaultFiles.filePaths[apmPart].path;
312
+ const includeExtension = apmPart === apm_1.APM.Part.dlo ? 'inc' : 'dfiles';
308
313
  for (const dependencyId in allDependencies) {
309
314
  const depPath = Dependencies.dependencyToPath(cwd, dependencyId);
310
315
  const name = Dependencies.dependencyIdToName(dependencyId);
311
- const incPath = vscode_uri_1.Utils.joinPath(depPath, defaultFiles_1.DefaultFiles.filePaths.dlo.path, `${name}.inc`);
316
+ const incPath = vscode_uri_1.Utils.joinPath(depPath, defaultApmPath, `${name}.${includeExtension}`);
312
317
  const exists = await fs.stat(incPath);
313
318
  if (exists) {
314
- dloDependencies.push({
319
+ apmDependencies.push({
315
320
  name,
316
321
  path: incPath
317
322
  });
@@ -319,20 +324,20 @@ var Dependencies;
319
324
  }
320
325
  // add current project file if it is a library project
321
326
  if (isLibraryProject(manifest)) {
322
- const incPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dlo.path, `${manifest.name}.inc`);
327
+ const incPath = vscode_uri_1.Utils.joinPath(cwd, defaultApmPath, `${manifest.name}.${includeExtension}`);
323
328
  if (await fs.stat(incPath)) {
324
- dloDependencies.push({
329
+ apmDependencies.push({
325
330
  name: manifest.name,
326
331
  path: incPath
327
332
  });
328
333
  }
329
334
  }
330
- return dloDependencies;
335
+ return apmDependencies;
331
336
  }
332
- Dependencies.getDloDependencies = getDloDependencies;
337
+ Dependencies.getApmPartDependencies = getApmPartDependencies;
333
338
  })(Dependencies || (exports.Dependencies = Dependencies = {}));
334
339
  async function fetchStudioJson(token, studioJsonURL) {
335
- return await registryAPI_1.Registry.fetchLibraryContent(token, studioJsonURL, true);
340
+ return await registryAPI_1.Registry.fetchCustomContent(token, studioJsonURL, true);
336
341
  }
337
342
  async function validateIfLibraryCanBeRemoved(cwd, fs, dependencies) {
338
343
  const allLibraries = {};
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DFILES = void 0;
4
+ const vscode_uri_1 = require("vscode-uri");
5
+ const dependencies_1 = require("../dependencies");
6
+ const helper_1 = require("../helper");
7
+ const yaml_1 = require("yaml");
8
+ const apm_1 = require("../package/apm");
9
+ const defaultFiles_1 = require("../defaultFiles");
10
+ var convertBlobToString = helper_1.Helper.convertBlobToString;
11
+ var yamlRangeToLineInformation = helper_1.Helper.yamlRangeToLineInformation;
12
+ var DFILES;
13
+ (function (DFILES) {
14
+ let Type;
15
+ (function (Type) {
16
+ Type["static"] = "static";
17
+ Type["dynamic"] = "dynamic";
18
+ })(Type = DFILES.Type || (DFILES.Type = {}));
19
+ let SyncLogic;
20
+ (function (SyncLogic) {
21
+ SyncLogic["crcStamp"] = "crc_stamp";
22
+ SyncLogic["stampOnly"] = "stamp_only";
23
+ SyncLogic["onlyDown"] = "only_down";
24
+ SyncLogic["onlyUp"] = "only_up";
25
+ })(SyncLogic = DFILES.SyncLogic || (DFILES.SyncLogic = {}));
26
+ let Force;
27
+ (function (Force) {
28
+ Force["down"] = "down";
29
+ Force["up"] = "up";
30
+ Force["off"] = "off";
31
+ })(Force = DFILES.Force || (DFILES.Force = {}));
32
+ async function process(cwd, fs) {
33
+ const allProperties = {};
34
+ const allDiagnostics = [];
35
+ const libraryFiles = await dependencies_1.Dependencies.getApmPartDependencies(cwd, fs, apm_1.APM.Part.dfiles);
36
+ for (const library of libraryFiles) {
37
+ const { properties, diagnostics } = await parseYamlFile(fs, library.path, library.name);
38
+ Object.assign(allProperties, properties);
39
+ allDiagnostics.push(...diagnostics);
40
+ }
41
+ const { properties, diagnostics } = await parseYamlFile(fs, vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dfiles.mainDFILES), null);
42
+ Object.assign(allProperties, properties);
43
+ allDiagnostics.push(...diagnostics);
44
+ const distDir = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.dfilesPath);
45
+ // clear dist directory beforehand
46
+ if (await fs.stat(distDir)) {
47
+ await fs.rm(distDir);
48
+ }
49
+ // copy all files to dist directory
50
+ // copy all files to the dist directory
51
+ for (const [dfileName, dfileInfo] of Object.entries(allProperties)) {
52
+ await copyDfilesToDist(cwd, fs, dfileName, dfileInfo, libraryFiles);
53
+ }
54
+ // do not write the properties file if there aren't any dfiles
55
+ if (!Object.keys(allProperties).length) {
56
+ return allDiagnostics;
57
+ }
58
+ console.log(`${Object.keys(allProperties).length} dfiles processed.`);
59
+ await fs.writeFile(vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.dfilesProperties), JSON.stringify(allProperties, null, '\t'));
60
+ return allDiagnostics;
61
+ }
62
+ DFILES.process = process;
63
+ /**
64
+ *
65
+ * @param fs
66
+ * @param fileUri
67
+ * @param libraryName
68
+ * @private
69
+ */
70
+ // eslint-disable-next-line sonarjs/cognitive-complexity
71
+ async function parseYamlFile(fs, fileUri, libraryName) {
72
+ const compilerDiagnostics = [];
73
+ const dfileProperties = {};
74
+ if (!(await fs.stat(fileUri))) {
75
+ return {
76
+ properties: dfileProperties,
77
+ diagnostics: compilerDiagnostics
78
+ };
79
+ }
80
+ const fileBlob = await fs.readFile(fileUri);
81
+ const yamlString = convertBlobToString(fileBlob);
82
+ const lineCounter = new yaml_1.LineCounter();
83
+ const yamlDoc = (0, yaml_1.parseDocument)(yamlString, { lineCounter });
84
+ const fileNodes = yamlDoc.contents || new yaml_1.YAMLMap();
85
+ for (const fileNode of fileNodes.items) {
86
+ const fileName = fileNode.key.value;
87
+ const fileValues = fileNode.value;
88
+ const yamlFileNameRange = yamlRangeToLineInformation(lineCounter, fileNode.key.range);
89
+ const hasSyncMode = fileValues.value !== null ? fileNode.value.has('syncMode') : false;
90
+ const syncMode = hasSyncMode
91
+ ? fileNode.value.get('syncMode')
92
+ : SyncLogic.crcStamp;
93
+ if (hasSyncMode) {
94
+ const values = Object.values(DFILES.SyncLogic);
95
+ if (!values.includes(syncMode)) {
96
+ const syncModeItem = fileNode.value.items.find(item => {
97
+ return item.key.value === 'syncMode';
98
+ });
99
+ const yamlSyncModeRange = yamlRangeToLineInformation(lineCounter, syncModeItem.key.range);
100
+ compilerDiagnostics.push({
101
+ file: fileUri,
102
+ code: '',
103
+ message: `Property syncMode does not match any of "${values.join(', ')}"`,
104
+ line: yamlSyncModeRange.line,
105
+ startCharacter: yamlSyncModeRange.startCharacter,
106
+ endCharacter: yamlSyncModeRange.endCharacter,
107
+ level: 'error'
108
+ });
109
+ }
110
+ }
111
+ else {
112
+ compilerDiagnostics.push({
113
+ file: fileUri,
114
+ code: '',
115
+ message: `Property "syncMode" missing`,
116
+ line: yamlFileNameRange.line,
117
+ startCharacter: yamlFileNameRange.startCharacter,
118
+ endCharacter: yamlFileNameRange.endCharacter,
119
+ level: 'error'
120
+ });
121
+ }
122
+ if (!fileName.match(/^[a-z0-9._-]*$/)) {
123
+ compilerDiagnostics.push({
124
+ file: fileUri,
125
+ code: '',
126
+ message: 'Filename does not match pattern "a-z0-9._-"',
127
+ line: yamlFileNameRange.line,
128
+ startCharacter: yamlFileNameRange.startCharacter,
129
+ endCharacter: yamlFileNameRange.endCharacter,
130
+ level: 'error'
131
+ });
132
+ }
133
+ const dfilePath = vscode_uri_1.Utils.joinPath(vscode_uri_1.Utils.dirname(fileUri), fileName);
134
+ const exists = await getFileStat(fs, dfilePath);
135
+ if (!exists) {
136
+ const yamlRange = yamlRangeToLineInformation(lineCounter, fileNode.key.range);
137
+ compilerDiagnostics.push({
138
+ file: fileUri,
139
+ code: '',
140
+ message: `Could not find file "${fileName}"`,
141
+ line: yamlRange.line,
142
+ startCharacter: yamlRange.startCharacter,
143
+ endCharacter: yamlRange.endCharacter,
144
+ level: 'error'
145
+ });
146
+ }
147
+ else {
148
+ dfileProperties[fileName] = {
149
+ crc: exists.crc,
150
+ force: Force.off,
151
+ readable: false,
152
+ size: exists.size,
153
+ stamp: exists.stamp,
154
+ sync_logic: syncMode,
155
+ type: Type.static,
156
+ library: libraryName
157
+ };
158
+ }
159
+ }
160
+ return {
161
+ properties: dfileProperties,
162
+ diagnostics: compilerDiagnostics
163
+ };
164
+ }
165
+ DFILES.parseYamlFile = parseYamlFile;
166
+ })(DFILES || (exports.DFILES = DFILES = {}));
167
+ async function getFileStat(fs, filePath) {
168
+ const stat = await fs.stat(filePath);
169
+ if (!stat) {
170
+ return null;
171
+ }
172
+ const blob = await fs.readFile(filePath);
173
+ return {
174
+ size: stat.size,
175
+ stamp: Math.trunc(stat.ctime),
176
+ crc: helper_1.Helper.generateCRC32ForFileContent(blob)
177
+ };
178
+ }
179
+ async function copyDfilesToDist(cwd, fs, fileName, property, libraryFiles) {
180
+ const isLibrary = property.library !== null;
181
+ const sourcePath = isLibrary
182
+ ? vscode_uri_1.Utils.dirname(libraryFiles.find(lib => lib.name === property.library).path)
183
+ : vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dfiles.path);
184
+ const destinationDir = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.dfilesPath, fileName);
185
+ const sourceDir = vscode_uri_1.Utils.joinPath(sourcePath, fileName);
186
+ await fs.copy(sourceDir, destinationDir);
187
+ }
188
+ //# sourceMappingURL=dfiles.js.map
@@ -34,6 +34,7 @@ const dependencies_1 = require("../dependencies");
34
34
  const iconv = __importStar(require("iconv-lite"));
35
35
  const helper_1 = require("../helper");
36
36
  var convertBlobToStringArray = helper_1.Helper.convertBlobToStringArray;
37
+ const apm_1 = require("../package/apm");
37
38
  const DLO_MODULE = require('./dlocc.js');
38
39
  class DloCompiler {
39
40
  preCompiler = new preCompiler_1.DloPreCompiler();
@@ -295,7 +296,7 @@ async function generateConfigFile(cwd, fs, manifest) {
295
296
  ];
296
297
  const defaultIncPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.defaultInc);
297
298
  compileOptions.push(`-p${uriToMemFsPath(defaultIncPath)}`);
298
- const dloLibs = await dependencies_1.Dependencies.getDloDependencies(cwd, fs);
299
+ const dloLibs = await dependencies_1.Dependencies.getApmPartDependencies(cwd, fs, apm_1.APM.Part.dlo);
299
300
  for (const dloLib of dloLibs) {
300
301
  const dirName = vscode_uri_1.Utils.dirname(dloLib.path);
301
302
  compileOptions.push(`-i${uriToMemFsPath(dirName)}`);
package/out/helper.js CHANGED
@@ -119,5 +119,27 @@ var Helper;
119
119
  }
120
120
  }
121
121
  Helper.patchValueWithArrayInfo = patchValueWithArrayInfo;
122
+ const _deferrals = {}; // <token>:{ handler:func, tmr:timeoutHandle }
123
+ /**
124
+ * Defer a given named task
125
+ * @param token
126
+ * @param timeout Milliseconds
127
+ * @param callback Callback
128
+ */
129
+ function defer(token, timeout, callback) {
130
+ const d = _deferrals[token];
131
+ if (d) {
132
+ clearTimeout(d.timer);
133
+ }
134
+ _deferrals[token] = {
135
+ // @ts-ignore
136
+ timer: setTimeout(() => {
137
+ delete _deferrals[token];
138
+ callback();
139
+ }, timeout),
140
+ handler: callback
141
+ };
142
+ }
143
+ Helper.defer = defer;
122
144
  })(Helper || (exports.Helper = Helper = {}));
123
145
  //# sourceMappingURL=helper.js.map
package/out/main.js CHANGED
@@ -73,7 +73,7 @@ program
73
73
  });
74
74
  program
75
75
  .command('build')
76
- .addOption(new commander_1.Option('-p --part <APM part>', 'APM part that should be build').choices(['dde', 'dlo', 'pov', 'blo']))
76
+ .addOption(new commander_1.Option('-p --part <APM part>', 'APM part that should be build').choices(Object.values(apm_1.APM.Part)))
77
77
  .action(async (opts) => {
78
78
  await package_1.Package.buildAll(cwd, cliFS_1.cliFS, opts.part);
79
79
  });
package/out/manifest.js CHANGED
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Manifest = void 0;
7
- exports.validateProjectVersion = validateProjectVersion;
8
7
  const vscode_uri_1 = require("vscode-uri");
9
8
  const helper_1 = require("./helper");
10
9
  const image_dimensions_1 = require("image-dimensions");
@@ -12,6 +11,7 @@ const file_type_checker_1 = require("file-type-checker");
12
11
  const registryAPI_1 = require("./registryAPI");
13
12
  const globals_1 = require("./globals");
14
13
  const preload_1 = __importDefault(require("semver/preload"));
14
+ const DeviceProfiles_1 = require("./DeviceProfiles");
15
15
  var isNumeric = helper_1.Helper.isNumeric;
16
16
  const STUDIO_JSON_NAME = 'studio.json';
17
17
  // Cache to reduce the disk read requests
@@ -58,11 +58,15 @@ var Manifest;
58
58
  const manifestUri = vscode_uri_1.Utils.joinPath(cwd, STUDIO_JSON_NAME);
59
59
  const manifestStat = await fs.stat(manifestUri);
60
60
  // if the manifest was modified, reload the cache
61
- if (manifestCache.manifest === null || manifestStat?.mtime !== manifestCache.stat?.mtime) {
61
+ if (manifestCache.manifest === null ||
62
+ manifestUri?.fsPath !== manifestCache.stat?.path.fsPath ||
63
+ manifestStat?.ctime !== manifestCache.stat?.ctime ||
64
+ manifestStat?.mtime !== manifestCache.stat?.mtime ||
65
+ manifestStat?.size !== manifestCache.stat?.size) {
62
66
  const localManifest = await fs.readFile(manifestUri);
63
67
  const manifestString = convertBlobToString(localManifest);
64
68
  manifestCache.manifest = JSON.parse(manifestString);
65
- manifestCache.stat = manifestStat;
69
+ manifestCache.stat = { ...manifestStat, path: manifestUri };
66
70
  }
67
71
  return manifestCache.manifest;
68
72
  }
@@ -84,6 +88,8 @@ var Manifest;
84
88
  */
85
89
  async function write(cwd, fs, manifest) {
86
90
  manifestCache.clear();
91
+ // patch the options if they are not valid for a specific device profile
92
+ patchDloCompileOptionsBasedOnDpid(manifest);
87
93
  return fs.writeFile(vscode_uri_1.Utils.joinPath(cwd, STUDIO_JSON_NAME), JSON.stringify(manifest, null, '\t'));
88
94
  }
89
95
  Manifest.write = write;
@@ -100,24 +106,16 @@ var Manifest;
100
106
  * @param fs
101
107
  * @param manifest
102
108
  * @param env
103
- * @param publish - validate publish related options
104
109
  */
105
- async function validateManifest(cwd, fs, manifest, publish, env = globals_1.Globals.ENV.production) {
110
+ async function validateBasicManifest(cwd, fs, manifest, env = globals_1.Globals.ENV.production) {
106
111
  if (!manifest) {
107
112
  manifest = await read(cwd, fs);
108
113
  }
109
114
  validateProjectVersion(manifest, env);
110
115
  validatePOVSettings(manifest);
111
116
  validateBLOSettings(manifest);
112
- if (!manifest.library) {
113
- validateEngineSettings(manifest);
114
- // only validate during publish process
115
- if (publish) {
116
- await validateApplicationIcon(cwd, fs, manifest);
117
- }
118
- }
119
117
  }
120
- Manifest.validateManifest = validateManifest;
118
+ Manifest.validateBasicManifest = validateBasicManifest;
121
119
  function validateLibraryName(libraryName) {
122
120
  const errorMessage = `Library name can only contain 'a' through 'z', '0' through '9', '_' and '-'. The Library name must start with an alphabetic or numeric character.`;
123
121
  const valid = libraryName.match(/^[a-z0-9-_]+$/);
@@ -133,10 +131,10 @@ var Manifest;
133
131
  if (libraryName.length < 3 || libraryName.length > 20) {
134
132
  return `The library name is beyond permissible length of 20 characters.`;
135
133
  }
136
- return false;
134
+ return null;
137
135
  }
138
136
  Manifest.validateLibraryName = validateLibraryName;
139
- async function validateProjectName(name, isLibrary) {
137
+ function validateProjectName(name, isLibrary) {
140
138
  if (isLibrary) {
141
139
  return validateLibraryName(name);
142
140
  }
@@ -154,20 +152,20 @@ var Manifest;
154
152
  if (invalidChars.includes(name[0]) || invalidChars.includes(name[name.length - 1])) {
155
153
  return errorMessage;
156
154
  }
157
- return false;
155
+ return null;
158
156
  }
159
157
  }
160
158
  Manifest.validateProjectName = validateProjectName;
161
- async function validateDescription(description) {
159
+ function validateDescription(description) {
162
160
  if (description.length < 5) {
163
161
  return `The description must have at least 5 characters.`;
164
162
  }
165
163
  else {
166
- return false;
164
+ return null;
167
165
  }
168
166
  }
169
167
  Manifest.validateDescription = validateDescription;
170
- async function validatePublisherId(publisher) {
168
+ function validatePublisherId(publisher) {
171
169
  if (!publisher) {
172
170
  return `No publisher set yet`;
173
171
  }
@@ -179,7 +177,7 @@ var Manifest;
179
177
  return errorMessage;
180
178
  }
181
179
  }
182
- return false;
180
+ return null;
183
181
  }
184
182
  Manifest.validatePublisherId = validatePublisherId;
185
183
  async function validatePublisherOnline(token, publisher) {
@@ -187,7 +185,7 @@ var Manifest;
187
185
  if (!exists) {
188
186
  return `Publisher '${publisher}' does not exist.`;
189
187
  }
190
- return false;
188
+ return null;
191
189
  }
192
190
  Manifest.validatePublisherOnline = validatePublisherOnline;
193
191
  const REGEX_SERVER_DOMAIN = /^(((?!-))(xn--)?[a-z0-9\-_]{0,61}[a-z0-9]{1,1}\.)*(xn--)?([a-z0-9-]{1,61}|[a-z0-9-]{1,30})\.[a-z]{2,}$/;
@@ -206,9 +204,45 @@ var Manifest;
206
204
  else if (!allowedBackends?.match(REGEX_SERVER_DOMAIN) && allowedBackends !== '*') {
207
205
  return `Invalid value for "allowedBackends"`;
208
206
  }
209
- return false;
207
+ return null;
210
208
  }
211
209
  Manifest.validateRegistryAllowedBackends = validateRegistryAllowedBackends;
210
+ async function validateApplicationIcon(cwd, fs, manifest) {
211
+ const iconPath = manifest.icon;
212
+ if (!iconPath) {
213
+ throw new Error('App icon is required for publishing an application!');
214
+ }
215
+ const iconUri = vscode_uri_1.Utils.joinPath(cwd, iconPath);
216
+ const iconExist = await fs.stat(iconUri);
217
+ if (!iconExist) {
218
+ throw new Error(`Could not load icon "${iconPath}"`);
219
+ }
220
+ const iconData = await fs.readFile(iconUri);
221
+ const dimensions = (0, image_dimensions_1.imageDimensionsFromData)(iconData);
222
+ if (!dimensions) {
223
+ throw new Error(`App icon could not be validated!`);
224
+ }
225
+ if (dimensions?.width !== dimensions?.height) {
226
+ throw new Error(`App icon has to be a square!`);
227
+ }
228
+ if (dimensions.width > 512 || dimensions.width < 75) {
229
+ throw new Error(`App icon size should be between 75px and 512px!`);
230
+ }
231
+ if (!(0, file_type_checker_1.isPNG)(iconData)) {
232
+ throw new Error(`App icon has to be of type PNG!`);
233
+ }
234
+ }
235
+ Manifest.validateApplicationIcon = validateApplicationIcon;
236
+ function validateEngineSettings(manifest) {
237
+ const { engines } = manifest;
238
+ // validate vor server versions >=52v006
239
+ if (engines?.backend &&
240
+ !engines.backend.match(/(^[5-9][2-9]|[6-9]\d+|\d{3,})v(0(0[6-9]|[1-9]\d)|[1-9]\d{2}|[1-9]\d{3,})$/)) {
241
+ throw new Error('Setting "engines.backend" is invalid');
242
+ }
243
+ validateHwFwOrProductId(manifest);
244
+ }
245
+ Manifest.validateEngineSettings = validateEngineSettings;
212
246
  })(Manifest || (exports.Manifest = Manifest = {}));
213
247
  function validatePOVSettings(manifest) {
214
248
  const { pov } = manifest;
@@ -240,15 +274,6 @@ function validateBLOSettings(manifest) {
240
274
  throw new Error(`Only "${Manifest.BloAccessLevel.restricted}" or "${Manifest.BloAccessLevel.global}" are allowed as value for "blo.accessLevel"!`);
241
275
  }
242
276
  }
243
- function validateEngineSettings(manifest) {
244
- const { engines } = manifest;
245
- // validate vor server versions >=52v006
246
- if (engines?.backend &&
247
- !engines.backend.match(/(^[5-9][2-9]|[6-9]\d+|\d{3,})v(0(0[6-9]|[1-9]\d)|[1-9]\d{2}|[1-9]\d{3,})$/)) {
248
- throw new Error('Setting "engines.backend" is invalid');
249
- }
250
- validateHwFwOrProductId(manifest);
251
- }
252
277
  function validateHwFwOrProductId(manifest) {
253
278
  const { backend, productId, hwfw } = manifest.engines;
254
279
  if (backend && backend >= '52v007') {
@@ -260,31 +285,6 @@ function validateHwFwOrProductId(manifest) {
260
285
  throw new Error('"engines.productId" requires "engines.backend" to be ">=52v007"');
261
286
  }
262
287
  }
263
- async function validateApplicationIcon(cwd, fs, manifest) {
264
- const iconPath = manifest.icon;
265
- if (!iconPath) {
266
- throw new Error('App icon is required for publishing an application!');
267
- }
268
- const iconUri = vscode_uri_1.Utils.joinPath(cwd, iconPath);
269
- const iconExist = await fs.stat(iconUri);
270
- if (!iconExist) {
271
- throw new Error(`Could not load icon "${iconPath}"`);
272
- }
273
- const iconData = await fs.readFile(iconUri);
274
- const dimensions = (0, image_dimensions_1.imageDimensionsFromData)(iconData);
275
- if (!dimensions) {
276
- throw new Error(`App icon could not be validated!`);
277
- }
278
- if (dimensions?.width !== dimensions?.height) {
279
- throw new Error(`App icon has to be a square!`);
280
- }
281
- if (dimensions.width > 512 || dimensions.width < 75) {
282
- throw new Error(`App icon size should be between 75px and 512px!`);
283
- }
284
- if (!(0, file_type_checker_1.isPNG)(iconData)) {
285
- throw new Error(`App icon has to be of type PNG!`);
286
- }
287
- }
288
288
  /**
289
289
  * Check based on the current env if the given version string is correct
290
290
  * @param manifest
@@ -302,4 +302,30 @@ function validateProjectVersion(manifest, env) {
302
302
  }
303
303
  }
304
304
  }
305
+ /**
306
+ * Some devices doesn't support compression. this function does patch the option if it's not supported
307
+ * @param manifest
308
+ */
309
+ function patchDloCompileOptionsBasedOnDpid(manifest) {
310
+ if (!manifest.dpid) {
311
+ return;
312
+ }
313
+ const deviceProfile = DeviceProfiles_1.DeviceProfiles[manifest.dpid];
314
+ const compileRestrictions = deviceProfile?.dlo?.compileRestrictions || {};
315
+ const { compileOptions } = manifest.dlo || {};
316
+ if (compileOptions) {
317
+ compileOptions.forEach((param, idx) => {
318
+ try {
319
+ const paramType = param.substring(0, 2);
320
+ const paramValue = param.substring(2);
321
+ if (Object.hasOwn(compileRestrictions, paramType) && `${paramValue}` !== `${compileRestrictions[paramType]}`) {
322
+ compileOptions[idx] = `${paramType}${compileRestrictions[paramType]}`;
323
+ }
324
+ }
325
+ catch (e) {
326
+ // todo?
327
+ }
328
+ });
329
+ }
330
+ }
305
331
  //# sourceMappingURL=manifest.js.map
@@ -29,6 +29,7 @@ var APM;
29
29
  Part["dlo"] = "dlo";
30
30
  Part["pov"] = "pov";
31
31
  Part["blo"] = "blo";
32
+ Part["dfiles"] = "dfiles";
32
33
  })(Part = APM.Part || (APM.Part = {}));
33
34
  /**
34
35
  * Create new release tag
@@ -141,7 +142,7 @@ var APM;
141
142
  const manifest = await manifest_1.Manifest.read(cwd, fs);
142
143
  if (!preventCreation) {
143
144
  // throws if the specific setting is invalid
144
- await package_1.Package.validateSpecificSettings(token, manifest);
145
+ await package_1.Package.validatePublishSettings(cwd, fs, token);
145
146
  }
146
147
  const { registry } = manifest;
147
148
  let applicationId = registry?.id;
@@ -186,8 +187,7 @@ var APM;
186
187
  }
187
188
  manifest.registry = {
188
189
  id: projectId,
189
- allowedBackends: newApplication.allowedBackends,
190
- target: backendTarget
190
+ allowedBackends: newApplication.allowedBackends
191
191
  };
192
192
  // write the updated manifest to disk
193
193
  await manifest_1.Manifest.write(cwd, fs, manifest);
@@ -13,6 +13,7 @@ const scriptRunner_1 = require("../scriptRunner");
13
13
  const manifest_1 = require("../manifest");
14
14
  const globals_1 = require("../globals");
15
15
  const library_1 = require("./library");
16
+ const dfiles_1 = require("../dfiles/dfiles");
16
17
  var Package;
17
18
  (function (Package) {
18
19
  /**
@@ -28,6 +29,9 @@ var Package;
28
29
  if (!apmPart || apmPart === apm_1.APM.Part.dlo) {
29
30
  await buildDLO(cwd, fs);
30
31
  }
32
+ if (!apmPart || apmPart === apm_1.APM.Part.dfiles) {
33
+ await buildDfiles(cwd, fs);
34
+ }
31
35
  if (!apmPart || apmPart === apm_1.APM.Part.pov) {
32
36
  await scriptRunner_1.Shell.tryBuildPov(cwd, fs);
33
37
  }
@@ -67,7 +71,7 @@ var Package;
67
71
  if (!Object.values(apm_1.APM.TagPhase).includes(releasePhase)) {
68
72
  throw new Error(`ReleasePhase: ${releasePhase} is not a valid release phase`);
69
73
  }
70
- await manifest_1.Manifest.validateManifest(cwd, fs, null, true, env);
74
+ await manifest_1.Manifest.validateBasicManifest(cwd, fs, null, env);
71
75
  const application = await apm_1.APM.validateAccess(cwd, fs, token, false, env);
72
76
  if (!application) {
73
77
  return;
@@ -90,8 +94,8 @@ var Package;
90
94
  */
91
95
  async function releaseLibrary(cwd, fs, token, env = globals_1.Globals.ENV.production) {
92
96
  const manifest = await manifest_1.Manifest.read(cwd, fs);
93
- await manifest_1.Manifest.validateManifest(cwd, fs, manifest, true, env);
94
- await validateSpecificSettings(token, manifest);
97
+ await manifest_1.Manifest.validateBasicManifest(cwd, fs, manifest, env);
98
+ await validatePublishSettings(cwd, fs, token);
95
99
  // build the complete project
96
100
  await buildAll(cwd, fs);
97
101
  const archive = await library_1.Library.createArchive(cwd, fs);
@@ -144,32 +148,36 @@ var Package;
144
148
  Package.getChangelogFile = getChangelogFile;
145
149
  /**
146
150
  * Validate manifest settings that are required for the APM
151
+ * @param cwd
152
+ * @param fs
147
153
  * @param token
148
- * @param manifest
149
154
  */
150
- async function validateSpecificSettings(token, manifest) {
155
+ async function validatePublishSettings(cwd, fs, token) {
156
+ const manifest = await manifest_1.Manifest.read(cwd, fs);
151
157
  const { name, publisher, description, registry } = manifest;
152
- const invalidName = await manifest_1.Manifest.validateProjectName(name);
158
+ const invalidName = manifest_1.Manifest.validateProjectName(name, manifest_1.Manifest.isLibraryProject(manifest));
153
159
  if (invalidName) {
154
160
  throw new Error(`name: ${invalidName}`);
155
161
  }
156
- const invalidDescription = await manifest_1.Manifest.validateDescription(description);
162
+ const invalidDescription = manifest_1.Manifest.validateDescription(description);
157
163
  if (invalidDescription) {
158
164
  throw new Error(`description: ${invalidDescription}`);
159
165
  }
160
- const invalidPublisher = (await manifest_1.Manifest.validatePublisherId(publisher)) || (await manifest_1.Manifest.validatePublisherOnline(token, publisher));
166
+ const invalidPublisher = manifest_1.Manifest.validatePublisherId(publisher) || (await manifest_1.Manifest.validatePublisherOnline(token, publisher));
161
167
  if (invalidPublisher) {
162
168
  throw new Error(`publisher: ${invalidPublisher}`);
163
169
  }
164
170
  // only validate if the project is not a library project
165
171
  if (!manifest_1.Manifest.isLibraryProject(manifest)) {
172
+ await manifest_1.Manifest.validateApplicationIcon(cwd, fs, manifest);
173
+ manifest_1.Manifest.validateEngineSettings(manifest);
166
174
  const invalidBackends = await manifest_1.Manifest.validateRegistryAllowedBackends(registry?.allowedBackends);
167
175
  if (invalidBackends) {
168
176
  throw new Error(`registry: ${invalidBackends}`);
169
177
  }
170
178
  }
171
179
  }
172
- Package.validateSpecificSettings = validateSpecificSettings;
180
+ Package.validatePublishSettings = validatePublishSettings;
173
181
  })(Package || (exports.Package = Package = {}));
174
182
  /**
175
183
  * Generates all needed files out of the dde declaration
@@ -177,6 +185,7 @@ var Package;
177
185
  * @param fs
178
186
  */
179
187
  async function buildDDE(cwd, fs) {
188
+ console.log('Processing DDE...');
180
189
  const result = await dde_1.DDE.compileDDE(cwd, fs);
181
190
  result.diagnostics.forEach(diagnostic => {
182
191
  const message = `${diagnostic.file.path}: ${diagnostic.message}`;
@@ -203,10 +212,16 @@ async function buildDDE(cwd, fs) {
203
212
  }
204
213
  }
205
214
  async function buildDLO(cwd, fs) {
215
+ console.log('Processing DLO...');
206
216
  const compiler = new compiler_1.DloCompiler();
207
217
  const { diagnostics } = await compiler.compile(cwd, fs);
208
218
  throwIfDiagnosticsHaveError(apm_1.APM.Part.dlo, diagnostics);
209
219
  }
220
+ async function buildDfiles(cwd, fs) {
221
+ console.log('Processing DFILES...');
222
+ const diagnostics = await dfiles_1.DFILES.process(cwd, fs);
223
+ throwIfDiagnosticsHaveError(apm_1.APM.Part.dfiles, diagnostics);
224
+ }
210
225
  function throwIfDiagnosticsHaveError(apmPart, diagnostics) {
211
226
  diagnostics.forEach(diagnostic => {
212
227
  if (diagnostic.level === 'error') {
@@ -48,9 +48,13 @@ var Registry;
48
48
  return data;
49
49
  }
50
50
  Registry.getLibraryProfile = getLibraryProfile;
51
- async function fetchLibraryContent(token, contentURL, json = false) {
51
+ async function fetchCustomContent(token, contentURL, json = false, env = globals_1.Globals.ENV.production) {
52
52
  const response = await fetch(contentURL, {
53
- headers: { ...buildAuthHeader(token) }
53
+ // @ts-ignore
54
+ headers: {
55
+ ...buildAuthHeader(token),
56
+ ...headerBasedOnEnv(env)
57
+ }
54
58
  });
55
59
  if (response.status === 200) {
56
60
  if (json) {
@@ -64,7 +68,7 @@ var Registry;
64
68
  throw new Error('Failed to fetch the library content');
65
69
  }
66
70
  }
67
- Registry.fetchLibraryContent = fetchLibraryContent;
71
+ Registry.fetchCustomContent = fetchCustomContent;
68
72
  async function getPublisher(token, publisherId) {
69
73
  try {
70
74
  const { data, error } = await GET('/publisher/{publisherId}', {
@@ -240,6 +244,33 @@ var Registry;
240
244
  }
241
245
  }
242
246
  Registry.publishLibraryVersion = publishLibraryVersion;
247
+ async function updateApplicationFile(token, publisherId, applicationId, applicationVersion, applicationFileName, blob, env = globals_1.Globals.ENV.production) {
248
+ const { error } = await POST('/packages/{publisherId}/applications/{applicationId}/versions/{applicationVersion}/files/{applicationFileName}', {
249
+ ...Registry.getAPIUrl(),
250
+ headers: {
251
+ ...buildAuthHeader(token),
252
+ ...headerBasedOnEnv(env),
253
+ 'Content-Type': 'application/octet-stream'
254
+ },
255
+ params: {
256
+ path: {
257
+ publisherId,
258
+ applicationId,
259
+ applicationVersion,
260
+ applicationFileName
261
+ }
262
+ },
263
+ //@ts-ignore
264
+ body: {},
265
+ bodySerializer() {
266
+ return blob;
267
+ }
268
+ });
269
+ if (error) {
270
+ throw new Error(error.reason);
271
+ }
272
+ }
273
+ Registry.updateApplicationFile = updateApplicationFile;
243
274
  })(Registry || (exports.Registry = Registry = {}));
244
275
  /**
245
276
  * inject the X-Semver header for application based requests
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microtronics/studio-cli",
3
- "version": "0.12.2",
3
+ "version": "0.14.0",
4
4
  "description": "Microtronics Studio CLI Tool",
5
5
  "main": "./out/api.js",
6
6
  "typings": "./dist/studio-cli.d.ts",