@microtronics/studio-cli 0.16.0 → 0.17.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,23 @@
1
1
 
2
2
 
3
+ ## 0.17.0 (2025-02-13)
4
+
5
+
6
+ ### Features
7
+
8
+ * **studio-cli:** added function to validate if a given apm part is enabled or not ([1dce992](https://bitbucket.org/microtronics-core/vscode-studio/commits/1dce99291f0629aed450af5413b128b0b80f29eb))
9
+ * **studio-cli:** allow set the `MYDATANET_CUSTOMER` env ([a34297a](https://bitbucket.org/microtronics-core/vscode-studio/commits/a34297ae1e670ef665b5991d065f74e6401466e3))
10
+ * **studio-cli:** make `ENV` namespace available ([09a8b80](https://bitbucket.org/microtronics-core/vscode-studio/commits/09a8b80a1b0f99eada300e273bb84029d28132bb))
11
+ * **studio-cli:** only add dlo binarys if the dlo part is enabled ([6d106ab](https://bitbucket.org/microtronics-core/vscode-studio/commits/6d106ab411c44057ca71e04d301d1c984a6b253b))
12
+ * **studio-cli:** only start compiler if the apm part is enabled ([dfbc701](https://bitbucket.org/microtronics-core/vscode-studio/commits/dfbc70173abf81eb5635a6d360d89a2f8734868a))
13
+ * **studio-cli:** support to read `.env.local` to support local build settings ([3376dbf](https://bitbucket.org/microtronics-core/vscode-studio/commits/3376dbf16f757f06829556eb2fc1d92d628253c1))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * **studio-cli:** only return boolean for `isApmPartEnabled` function ([c80468a](https://bitbucket.org/microtronics-core/vscode-studio/commits/c80468ae245b49fb1f5209fbf5a948df9f5bc7d2))
19
+ * **studio-cli:** validate if `.env.local` file exist ([eeea393](https://bitbucket.org/microtronics-core/vscode-studio/commits/eeea3932bc28a259975c4755a4f5a6a107ab34b7))
20
+
3
21
  ## 0.16.0 (2025-02-07)
4
22
 
5
23
 
@@ -1782,6 +1782,23 @@ declare class DloPreCompiler {
1782
1782
  }>;
1783
1783
  }
1784
1784
 
1785
+ export declare namespace ENV {
1786
+ /**
1787
+ *
1788
+ */
1789
+ export interface ENV {
1790
+ MYDATANET_HOST?: string;
1791
+ MYDATANET_API_TOKEN?: string;
1792
+ MYDATANET_CUSTOMER?: string;
1793
+ }
1794
+ /**
1795
+ * Read/parse the supported .env file
1796
+ * @param cwd
1797
+ * @param fs
1798
+ */
1799
+ export function read(cwd: URI, fs: LocalFS): Promise<ENV.ENV>;
1800
+ }
1801
+
1785
1802
  /**
1786
1803
  * Permissions of a file.
1787
1804
  */
@@ -2130,6 +2147,14 @@ export declare namespace Manifest {
2130
2147
  export function validateRegistryAllowedBackends(allowedBackends: undefined | null | string | string[]): Promise<string | null>;
2131
2148
  export function validateApplicationIcon(cwd: URI, fs: LocalFS, manifest: Manifest.Manifest): Promise<void>;
2132
2149
  export function validateEngineSettings(manifest: Manifest.Manifest): void;
2150
+ /**
2151
+ * Validate if the given apm part is used
2152
+ * @param cwd
2153
+ * @param fs
2154
+ * @param apmPart
2155
+ * @param manifest
2156
+ */
2157
+ export function isApmPartEnabled(cwd: URI, fs: LocalFS, apmPart: APM.Part, manifest?: Manifest.Manifest): Promise<boolean>;
2133
2158
  }
2134
2159
 
2135
2160
  export declare namespace Package {
package/out/api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ exports.ENV = 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");
@@ -31,4 +31,6 @@ const library_1 = require("./package/library");
31
31
  Object.defineProperty(exports, "Library", { enumerable: true, get: function () { return library_1.Library; } });
32
32
  const dfiles_1 = require("./dfiles/dfiles");
33
33
  Object.defineProperty(exports, "DFILES", { enumerable: true, get: function () { return dfiles_1.DFILES; } });
34
+ const dotenv_1 = require("./dotenv");
35
+ Object.defineProperty(exports, "ENV", { enumerable: true, get: function () { return dotenv_1.ENV; } });
34
36
  //# sourceMappingURL=api.js.map
@@ -65,6 +65,15 @@ class DloCompiler {
65
65
  }
66
66
  async compile(cwd, fs) {
67
67
  const manifest = await manifest_1.Manifest.read(cwd, fs);
68
+ if (!(await manifest_1.Manifest.isApmPartEnabled(cwd, fs, apm_1.APM.Part.dlo, manifest))) {
69
+ console.log('DLO not enabled. Skipped.');
70
+ return {
71
+ code: 0,
72
+ stdout: [],
73
+ stderr: [],
74
+ diagnostics: []
75
+ };
76
+ }
68
77
  await this.initDloCC();
69
78
  const precompilerDiagnostics = await this.persistDloFiles(cwd, fs, manifest);
70
79
  const mainFile = vscode_uri_1.Utils.joinPath(cwd, manifest.dlo?.mainFile || defaultFiles_1.DefaultFiles.filePaths.dlo.mainDLO);
package/out/dotenv.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ENV = void 0;
7
+ const dotenv_1 = __importDefault(require("dotenv"));
8
+ const vscode_uri_1 = require("vscode-uri");
9
+ const helper_1 = require("./helper");
10
+ const envLocalFile = '.env.local';
11
+ var ENV;
12
+ (function (ENV) {
13
+ /**
14
+ * Read/parse the supported .env file
15
+ * @param cwd
16
+ * @param fs
17
+ */
18
+ async function read(cwd, fs) {
19
+ const envPath = vscode_uri_1.Utils.joinPath(cwd, envLocalFile);
20
+ if (await fs.stat(envPath)) {
21
+ const envData = await fs.readFile(envPath);
22
+ return dotenv_1.default.parse(helper_1.Helper.convertBlobToString(envData));
23
+ }
24
+ return {};
25
+ }
26
+ ENV.read = read;
27
+ })(ENV || (exports.ENV = ENV = {}));
28
+ //# sourceMappingURL=dotenv.js.map
package/out/manifest.js CHANGED
@@ -13,6 +13,7 @@ const globals_1 = require("./globals");
13
13
  const preload_1 = __importDefault(require("semver/preload"));
14
14
  const DeviceProfiles_1 = require("./DeviceProfiles");
15
15
  var isNumeric = helper_1.Helper.isNumeric;
16
+ const apm_1 = require("./package/apm");
16
17
  // Cache to reduce the disk read requests
17
18
  const manifestCache = {
18
19
  _manifest: null,
@@ -263,6 +264,33 @@ var Manifest;
263
264
  validateHwFwOrProductId(manifest);
264
265
  }
265
266
  Manifest.validateEngineSettings = validateEngineSettings;
267
+ /**
268
+ * Validate if the given apm part is used
269
+ * @param cwd
270
+ * @param fs
271
+ * @param apmPart
272
+ * @param manifest
273
+ */
274
+ async function isApmPartEnabled(cwd, fs, apmPart, manifest) {
275
+ if (!manifest) {
276
+ manifest = await Manifest.read(cwd, fs);
277
+ }
278
+ switch (apmPart) {
279
+ case apm_1.APM.Part.dlo:
280
+ return !!manifest?.dlo?.mainFile;
281
+ case apm_1.APM.Part.blo:
282
+ return !!(manifest.blo?.buildCommand && manifest.blo?.workingPath);
283
+ case apm_1.APM.Part.pov:
284
+ return !!(manifest.pov?.details?.buildCommand && manifest.pov.details.workingPath);
285
+ // dde and dfiles are always enabled
286
+ case apm_1.APM.Part.dde:
287
+ case apm_1.APM.Part.dfiles:
288
+ return true;
289
+ default:
290
+ return false;
291
+ }
292
+ }
293
+ Manifest.isApmPartEnabled = isApmPartEnabled;
266
294
  })(Manifest || (exports.Manifest = Manifest = {}));
267
295
  function validatePOVSettings(manifest) {
268
296
  const { pov } = manifest;
@@ -99,8 +99,6 @@ var APM;
99
99
  apmBuffer.append(`src/${manifest_1.Manifest.fileName}`, new Blob([await manifest_1.Manifest.readAsBlob(cwd, fs)]));
100
100
  const xmlBlob = new Blob([await fs.readFile(vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.ddeXmlPath))]);
101
101
  apmBuffer.append('bin/dde/xml', xmlBlob);
102
- const amxBlob = new Blob([await fs.readFile(vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.mainAmxPath))]);
103
- apmBuffer.append('bin/dlo/amx', amxBlob);
104
102
  if (manifest.icon) {
105
103
  const appIcon = await fs.readFile(vscode_uri_1.Utils.joinPath(cwd, manifest.icon));
106
104
  const base64 = bufferToBase64(appIcon);
@@ -113,8 +111,12 @@ var APM;
113
111
  apmBuffer.append(`previews/README.md`, new Blob([readme]));
114
112
  apmBuffer.append(`previews/CHANGELOG.md`, new Blob([changelog]));
115
113
  }
114
+ if (await manifest_1.Manifest.isApmPartEnabled(cwd, fs, APM.Part.dlo)) {
115
+ const amxBlob = new Blob([await fs.readFile(vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.mainAmxPath))]);
116
+ apmBuffer.append('bin/dlo/amx', amxBlob);
117
+ }
116
118
  // handle pov binaries
117
- if (manifest.pov?.details) {
119
+ if (await manifest_1.Manifest.isApmPartEnabled(cwd, fs, APM.Part.pov, manifest)) {
118
120
  // get files in details dir
119
121
  await insertRelativePathFilesToBuffer(cwd, fs, apmBuffer, defaultFiles_1.DefaultFiles.filePaths.dist.povDetailsPath, 'bin/pov/details');
120
122
  //site list not supported yet -> add an empty index.html
@@ -128,7 +130,7 @@ var APM;
128
130
  apmBuffer.append(`bin/dfiles/${vscode_uri_1.Utils.basename(fileName)}`, dfileBlob);
129
131
  }
130
132
  // handle blo files
131
- if (manifest.blo) {
133
+ if (await manifest_1.Manifest.isApmPartEnabled(cwd, fs, APM.Part.pov, manifest)) {
132
134
  // get files in blo dir
133
135
  await insertRelativePathFilesToBuffer(cwd, fs, apmBuffer, defaultFiles_1.DefaultFiles.filePaths.dist.bloPath, 'bin/blo');
134
136
  }
@@ -37,7 +37,7 @@ var Shell;
37
37
  */
38
38
  async function tryBuildPov(cwd, fs) {
39
39
  const manifest = await manifest_1.Manifest.read(cwd, fs);
40
- if (manifest.pov?.details?.buildCommand && manifest.pov.details.workingPath) {
40
+ if (await manifest_1.Manifest.isApmPartEnabled(cwd, fs, apm_1.APM.Part.pov)) {
41
41
  console.log('Executing POV build script', manifest.pov?.details.buildCommand);
42
42
  const { buildCommand, workingPath } = manifest.pov.details;
43
43
  const povDir = vscode_uri_1.Utils.joinPath(cwd, workingPath);
@@ -62,7 +62,7 @@ var Shell;
62
62
  */
63
63
  async function tryBuildBlo(cwd, fs) {
64
64
  const manifest = await manifest_1.Manifest.read(cwd, fs);
65
- if (manifest.blo?.buildCommand && manifest.blo?.workingPath) {
65
+ if (await manifest_1.Manifest.isApmPartEnabled(cwd, fs, apm_1.APM.Part.blo, manifest)) {
66
66
  console.log('Executing BLO build script', manifest.blo?.buildCommand);
67
67
  const { buildCommand, workingPath } = manifest.blo;
68
68
  const bloDir = vscode_uri_1.Utils.joinPath(cwd, workingPath);
package/package.json CHANGED
@@ -1,76 +1,77 @@
1
- {
2
- "name": "@microtronics/studio-cli",
3
- "version": "0.16.0",
4
- "description": "Microtronics Studio CLI Tool",
5
- "main": "./out/api.js",
6
- "typings": "./dist/studio-cli.d.ts",
7
- "bin": {
8
- "studio-cli": "studio-cli"
9
- },
10
- "publishConfig": {
11
- "access": "public"
12
- },
13
- "scripts": {
14
- "release": "release-it --ci",
15
- "compile": "npm run build:registryApiTypings && tsc",
16
- "api": "api-extractor run --local --verbose",
17
- "build": "npm run compile && npm run api",
18
- "watch:build": "npm run compile -- --watch",
19
- "test": "cross-env STUDIO_ENV=lucky mocha",
20
- "test-ci": "cross-env STUDIO_ENV=lucky mocha --reporter mocha-junit-reporter",
21
- "watch:test": "npm run test -- --watch",
22
- "prepublishOnly": "npm run build",
23
- "build:registryApiTypings": "npx openapi-typescript https://api.registry.stage.microtronics.com/v1/openapi.yaml -o ./src/typings/registry.ts"
24
- },
25
- "author": "Microtronics",
26
- "license": "ISC",
27
- "dependencies": {
28
- "ajv": "^8.17.1",
29
- "ajv-formats": "^3.0.1",
30
- "ajv-keywords": "^5.1.0",
31
- "commander": "^12.1.0",
32
- "cross-fetch": "^4.0.0",
33
- "glob": "^11.0.1",
34
- "iconv-lite": "^0.6.3",
35
- "minimatch": "^10.0.1",
36
- "ini": "^5.0.0",
37
- "openapi-fetch": "^0.13.0",
38
- "pako": "^2.1.0",
39
- "semver": "^7.6.3",
40
- "tarballjs": "github:ankitrohatgi/tarballjs",
41
- "tinytar-fix": "^0.1.1",
42
- "vscode-uri": "^3.0.8",
43
- "yaml": "^2.6.1",
44
- "image-dimensions": "^2.3.0",
45
- "file-type-checker": "^1.1.2"
46
- },
47
- "engines": {
48
- "node": ">= 22"
49
- },
50
- "devDependencies": {
51
- "@microsoft/api-extractor": "^7.47.11",
52
- "@types/chai": "^4.3.6",
53
- "@types/chai-as-promised": "^7.1.5",
54
- "@types/ini": "^4.1.1",
55
- "@types/mocha": "^10.0.9",
56
- "@types/node": "^22.9.1",
57
- "@types/semver": "^7.5.6",
58
- "@types/vscode": "^1.86.2",
59
- "chai": "^4.3.8",
60
- "chai-as-promised": "^7.1.2",
61
- "cross-env": "^7.0.3",
62
- "mocha": "^10.8.2",
63
- "mocha-junit-reporter": "^2.2.1",
64
- "openapi-typescript": "^7.6.0",
65
- "ts-node": "^10.9.2",
66
- "typescript": "^5.6.3"
67
- },
68
- "mocha": {
69
- "require": [
70
- "ts-node/register"
71
- ],
72
- "watch-files": "src/**",
73
- "spec": "./test/**/*.spec.ts",
74
- "recursive": true
75
- }
76
- }
1
+ {
2
+ "name": "@microtronics/studio-cli",
3
+ "version": "0.17.0",
4
+ "description": "Microtronics Studio CLI Tool",
5
+ "main": "./out/api.js",
6
+ "typings": "./dist/studio-cli.d.ts",
7
+ "bin": {
8
+ "studio-cli": "studio-cli"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "scripts": {
14
+ "release": "release-it --ci",
15
+ "compile": "npm run build:registryApiTypings && tsc",
16
+ "api": "api-extractor run --local --verbose",
17
+ "build": "npm run compile && npm run api",
18
+ "watch:build": "npm run compile -- --watch",
19
+ "test": "cross-env STUDIO_ENV=lucky mocha",
20
+ "test-ci": "cross-env STUDIO_ENV=lucky mocha --reporter mocha-junit-reporter",
21
+ "watch:test": "npm run test -- --watch",
22
+ "prepublishOnly": "npm run build",
23
+ "build:registryApiTypings": "npx openapi-typescript https://api.registry.stage.microtronics.com/v1/openapi.yaml -o ./src/typings/registry.ts"
24
+ },
25
+ "author": "Microtronics",
26
+ "license": "ISC",
27
+ "dependencies": {
28
+ "ajv": "^8.17.1",
29
+ "ajv-formats": "^3.0.1",
30
+ "ajv-keywords": "^5.1.0",
31
+ "commander": "^12.1.0",
32
+ "cross-fetch": "^4.0.0",
33
+ "dotenv": "^16.4.7",
34
+ "file-type-checker": "^1.1.2",
35
+ "glob": "^11.0.1",
36
+ "iconv-lite": "^0.6.3",
37
+ "image-dimensions": "^2.3.0",
38
+ "ini": "^5.0.0",
39
+ "minimatch": "^10.0.1",
40
+ "openapi-fetch": "^0.13.0",
41
+ "pako": "^2.1.0",
42
+ "semver": "^7.6.3",
43
+ "tarballjs": "github:ankitrohatgi/tarballjs",
44
+ "tinytar-fix": "^0.1.1",
45
+ "vscode-uri": "^3.0.8",
46
+ "yaml": "^2.6.1"
47
+ },
48
+ "engines": {
49
+ "node": ">= 22"
50
+ },
51
+ "devDependencies": {
52
+ "@microsoft/api-extractor": "^7.47.11",
53
+ "@types/chai": "^4.3.6",
54
+ "@types/chai-as-promised": "^7.1.5",
55
+ "@types/ini": "^4.1.1",
56
+ "@types/mocha": "^10.0.9",
57
+ "@types/node": "^22.9.1",
58
+ "@types/semver": "^7.5.6",
59
+ "@types/vscode": "^1.86.2",
60
+ "chai": "^4.3.8",
61
+ "chai-as-promised": "^7.1.2",
62
+ "cross-env": "^7.0.3",
63
+ "mocha": "^10.8.2",
64
+ "mocha-junit-reporter": "^2.2.1",
65
+ "openapi-typescript": "^7.6.0",
66
+ "ts-node": "^10.9.2",
67
+ "typescript": "^5.6.3"
68
+ },
69
+ "mocha": {
70
+ "require": [
71
+ "ts-node/register"
72
+ ],
73
+ "watch-files": "src/**",
74
+ "spec": "./test/**/*.spec.ts",
75
+ "recursive": true
76
+ }
77
+ }