@microtronics/studio-cli 0.25.0 → 0.27.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 +16 -1
- package/dist/studio-cli.d.ts +85 -21
- package/out/api.js +12 -7
- package/out/dde/dde.js +26 -24
- package/out/dfiles/dfiles.js +35 -18
- package/out/dlo/compiler.js +5 -3
- package/out/dlo/dlo.js +2 -2
- package/out/log.js +52 -0
- package/out/main.js +4 -2
- package/out/package/package.js +110 -57
- package/out/scriptRunner.js +14 -9
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.27.0 (2025-03-20)
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
### Features
|
|
7
7
|
|
|
8
|
+
* **studio-core:** support to allow preview of the app version manifest ([fdfe18b](https://bitbucket.org/microtronics-core/vscode-studio/commits/fdfe18bf873de150b6870004249880a3e990a811))
|
|
9
|
+
|
|
10
|
+
## 0.26.0 (2025-03-18)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* implemented generic logger ([46b72a1](https://bitbucket.org/microtronics-core/vscode-studio/commits/46b72a1f5bcf9cfe85e58deb7e69bf3e56aa0875))
|
|
16
|
+
* **studio-cli:** introduced generic logger with chalk as colorization tool ([6593494](https://bitbucket.org/microtronics-core/vscode-studio/commits/65934942e2d30b3dfcc965e798ad8c508bf2ed52))
|
|
17
|
+
|
|
18
|
+
## 0.25.0 (2025-03-12)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
8
23
|
* **studio-cli:** show update notification after each cli command ([c719fd8](https://bitbucket.org/microtronics-core/vscode-studio/commits/c719fd8ea6a7dda16589764d2ae77f70e006d80a))
|
|
9
24
|
|
|
10
25
|
## 0.24.1 (2025-03-12)
|
package/dist/studio-cli.d.ts
CHANGED
|
@@ -120,10 +120,15 @@ declare interface BaseTagHeader {
|
|
|
120
120
|
*
|
|
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
|
-
* @param {
|
|
124
|
-
* @
|
|
123
|
+
* @param {Logger} logger - Logger instance for logging details during the build process.
|
|
124
|
+
* @param {APM.Part} selectedParts - The project parts to be built.
|
|
125
|
+
* @return A promise that resolves when the build process is complete.
|
|
125
126
|
*/
|
|
126
|
-
export declare function build(cwd: URI, fs: LocalFS,
|
|
127
|
+
export declare function build(cwd: URI, fs: LocalFS, logger: Log.Logger, selectedParts?: APM.Part[] | boolean): Promise<{
|
|
128
|
+
[APM.Part.dde]: Diagnostics.File[];
|
|
129
|
+
[APM.Part.dlo]: Diagnostics.File[];
|
|
130
|
+
[APM.Part.dfiles]: Diagnostics.File[];
|
|
131
|
+
}>;
|
|
127
132
|
|
|
128
133
|
declare interface components {
|
|
129
134
|
schemas: {
|
|
@@ -367,7 +372,7 @@ declare interface components {
|
|
|
367
372
|
ApplicationVersion: string | number;
|
|
368
373
|
ApplicationVersionInSemver: boolean;
|
|
369
374
|
/** @description File that can be downloaded */
|
|
370
|
-
ApplicationFileName: "release-notes.md" | "app.tar.gz";
|
|
375
|
+
ApplicationFileName: "release-notes.md" | "app.tar.gz" | "studio.json";
|
|
371
376
|
/** @description User Id */
|
|
372
377
|
MemberId: string;
|
|
373
378
|
/** @description User Id */
|
|
@@ -1125,7 +1130,7 @@ export declare namespace DDE {
|
|
|
1125
1130
|
* @param fs
|
|
1126
1131
|
* @param fileName
|
|
1127
1132
|
*/
|
|
1128
|
-
export function validate(cwd: URI, fs: LocalFS, fileName?: string): Promise<{
|
|
1133
|
+
export function validate(cwd: URI, fs: LocalFS, logger: Log.Logger, fileName?: string): Promise<{
|
|
1129
1134
|
manifest: Manifest.Manifest;
|
|
1130
1135
|
libraryFiles: DDE_Core.LibraryFile[];
|
|
1131
1136
|
main: {
|
|
@@ -1137,9 +1142,10 @@ export declare namespace DDE {
|
|
|
1137
1142
|
* Run dde compiler in the given studio directory
|
|
1138
1143
|
* @param cwd
|
|
1139
1144
|
* @param fs
|
|
1145
|
+
* @param logger
|
|
1140
1146
|
* @param fileName
|
|
1141
1147
|
*/
|
|
1142
|
-
export function compileDDE(cwd: URI, fs: LocalFS, fileName?: string): Promise<{
|
|
1148
|
+
export function compileDDE(cwd: URI, fs: LocalFS, logger: Log.Logger, fileName?: string): Promise<{
|
|
1143
1149
|
ddeJSON: DDEJson | null;
|
|
1144
1150
|
diagnostics: Diagnostics.File[];
|
|
1145
1151
|
}>;
|
|
@@ -1147,8 +1153,9 @@ export declare namespace DDE {
|
|
|
1147
1153
|
* Validate a given dde file against the dynamic dde schema
|
|
1148
1154
|
* @param ddeFilePath
|
|
1149
1155
|
* @param yaml
|
|
1156
|
+
* @param logger
|
|
1150
1157
|
*/
|
|
1151
|
-
export function validateJsonSchema(ddeFilePath: URI, yaml: string): Promise<void>;
|
|
1158
|
+
export function validateJsonSchema(ddeFilePath: URI, yaml: string, logger: Log.Logger): Promise<void>;
|
|
1152
1159
|
/**
|
|
1153
1160
|
* Creates and returns a new precompiler instance
|
|
1154
1161
|
* @param manifest
|
|
@@ -1171,13 +1178,13 @@ export declare namespace DDE {
|
|
|
1171
1178
|
* @param fs
|
|
1172
1179
|
* @param ddeJSON
|
|
1173
1180
|
*/
|
|
1174
|
-
export function exportMyDatanetXML(cwd: URI, fs: LocalFS, ddeJSON: DDEJson): Promise<void>;
|
|
1181
|
+
export function exportMyDatanetXML(cwd: URI, fs: LocalFS, logger: Log.Logger, ddeJSON: DDEJson): Promise<void>;
|
|
1175
1182
|
/**
|
|
1176
1183
|
* Read the correct history.json file from the project
|
|
1177
1184
|
* @param cwd
|
|
1178
1185
|
* @param fs
|
|
1179
1186
|
*/
|
|
1180
|
-
export function getHistoryJson(cwd: URI, fs: LocalFS): Promise<any>;
|
|
1187
|
+
export function getHistoryJson(cwd: URI, fs: LocalFS, logger: Log.Logger): Promise<any>;
|
|
1181
1188
|
/**
|
|
1182
1189
|
* Generate the object for the history.json
|
|
1183
1190
|
* @param ddeJson
|
|
@@ -1191,7 +1198,7 @@ export declare namespace DDE {
|
|
|
1191
1198
|
* @param fs
|
|
1192
1199
|
* @param ddeJSON
|
|
1193
1200
|
*/
|
|
1194
|
-
export function exportHistoryJson(cwd: URI, fs: LocalFS, ddeJSON: DDEJson): Promise<void>;
|
|
1201
|
+
export function exportHistoryJson(cwd: URI, fs: LocalFS, logger: Log.Logger, ddeJSON: DDEJson): Promise<void>;
|
|
1195
1202
|
/**
|
|
1196
1203
|
* Clean up the .studio/auto/dlo directory
|
|
1197
1204
|
* @param cwd
|
|
@@ -1205,14 +1212,14 @@ export declare namespace DDE {
|
|
|
1205
1212
|
* @param fs
|
|
1206
1213
|
* @param ddeJSON
|
|
1207
1214
|
*/
|
|
1208
|
-
export function exportAutoDloFiles(cwd: URI, fs: LocalFS, ddeJSON: DDEJson): Promise<void>;
|
|
1215
|
+
export function exportAutoDloFiles(cwd: URI, fs: LocalFS, logger: Log.Logger, ddeJSON: DDEJson): Promise<void>;
|
|
1209
1216
|
/**
|
|
1210
1217
|
* Generate all dde related openapi files
|
|
1211
1218
|
* @param cwd
|
|
1212
1219
|
* @param fs
|
|
1213
1220
|
* @param ddeMap
|
|
1214
1221
|
*/
|
|
1215
|
-
export function exportOpenApi(cwd: URI, fs: LocalFS, ddeMap: DDEJson): Promise<void>;
|
|
1222
|
+
export function exportOpenApi(cwd: URI, fs: LocalFS, logger: Log.Logger, ddeMap: DDEJson): Promise<void>;
|
|
1216
1223
|
/**
|
|
1217
1224
|
* Generate and export the default.inc file
|
|
1218
1225
|
* @param cwd
|
|
@@ -1700,7 +1707,20 @@ export declare namespace DFILES {
|
|
|
1700
1707
|
export interface PropertyList {
|
|
1701
1708
|
[key: string]: Property;
|
|
1702
1709
|
}
|
|
1703
|
-
export function process(cwd: URI, fs: LocalFS): Promise<Diagnostics.File[]>;
|
|
1710
|
+
export function process(cwd: URI, fs: LocalFS, logger: Log.Logger): Promise<Diagnostics.File[]>;
|
|
1711
|
+
/**
|
|
1712
|
+
* Parses DFILES from the specified directory and aggregates properties, diagnostics, and library files.
|
|
1713
|
+
*
|
|
1714
|
+
* @param {URI} cwd - The current working directory URI.
|
|
1715
|
+
* @param {LocalFS} fs - The local file system instance used for file operations.
|
|
1716
|
+
* @return {Promise<{properties: PropertyList, diagnostics: Diagnostics.File[], libraryFiles: any[]}>}
|
|
1717
|
+
* Resolves to an object containing the aggregated properties, diagnostics, and library files information.
|
|
1718
|
+
*/
|
|
1719
|
+
export function parseDfile(cwd: URI, fs: LocalFS): Promise<{
|
|
1720
|
+
properties: PropertyList;
|
|
1721
|
+
diagnostics: Diagnostics.File[];
|
|
1722
|
+
libraryFiles: Dependencies.APMPartLibrary[];
|
|
1723
|
+
}>;
|
|
1704
1724
|
/**
|
|
1705
1725
|
*
|
|
1706
1726
|
* @param fs
|
|
@@ -1749,15 +1769,16 @@ export declare namespace DLO {
|
|
|
1749
1769
|
* @param cwd
|
|
1750
1770
|
* @param fs
|
|
1751
1771
|
*/
|
|
1752
|
-
export function exportDloConfig(cwd: URI, fs: LocalFS): Promise<void>;
|
|
1772
|
+
export function exportDloConfig(cwd: URI, fs: LocalFS, logger: Log.Logger): Promise<void>;
|
|
1753
1773
|
}
|
|
1754
1774
|
|
|
1755
1775
|
declare class DloCompiler {
|
|
1776
|
+
private logger;
|
|
1756
1777
|
private preCompiler;
|
|
1757
1778
|
private dloCC;
|
|
1758
1779
|
private stdout;
|
|
1759
1780
|
private stderr;
|
|
1760
|
-
constructor();
|
|
1781
|
+
constructor(logger: Log.Logger);
|
|
1761
1782
|
private initDloCC;
|
|
1762
1783
|
private get MEMFS();
|
|
1763
1784
|
compile(cwd: URI, fs: LocalFS): Promise<{
|
|
@@ -2097,6 +2118,35 @@ declare interface LocalFS {
|
|
|
2097
2118
|
copy: (source: URI, target: URI) => Promise<any>;
|
|
2098
2119
|
}
|
|
2099
2120
|
|
|
2121
|
+
export declare namespace Log {
|
|
2122
|
+
export enum LogMessageType {
|
|
2123
|
+
log = 0,
|
|
2124
|
+
done = 1,
|
|
2125
|
+
info = 2,
|
|
2126
|
+
warning = 3,
|
|
2127
|
+
error = 4
|
|
2128
|
+
}
|
|
2129
|
+
const LOG_PREFIX: {
|
|
2130
|
+
1: string;
|
|
2131
|
+
0: string;
|
|
2132
|
+
2: string;
|
|
2133
|
+
3: string;
|
|
2134
|
+
4: string;
|
|
2135
|
+
};
|
|
2136
|
+
export class Logger {
|
|
2137
|
+
private _logHandler;
|
|
2138
|
+
constructor(logOutput?: {
|
|
2139
|
+
log: (...args: any[]) => void;
|
|
2140
|
+
});
|
|
2141
|
+
_log(type: LogMessageType, msg: any, ...args: any[]): void;
|
|
2142
|
+
log(msg: any, ...args: any[]): void;
|
|
2143
|
+
error(msg: any, ...args: any[]): void;
|
|
2144
|
+
info(msg: any, ...args: any[]): void;
|
|
2145
|
+
warn(msg: any, ...args: any[]): void;
|
|
2146
|
+
done(msg: any, ...args: any[]): void;
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2100
2150
|
export declare namespace Manifest {
|
|
2101
2151
|
/**
|
|
2102
2152
|
* The source filename where the information is stored in
|
|
@@ -2244,37 +2294,45 @@ export declare namespace Package {
|
|
|
2244
2294
|
* Build the whole project or only a specific part
|
|
2245
2295
|
* @param cwd
|
|
2246
2296
|
* @param fs
|
|
2247
|
-
* @param
|
|
2297
|
+
* @param logger
|
|
2298
|
+
* @param selectedParts - choose a specific part that should be build or if true all parts are build
|
|
2248
2299
|
*/
|
|
2249
|
-
export function buildAll(cwd: URI, fs: LocalFS,
|
|
2300
|
+
export function buildAll(cwd: URI, fs: LocalFS, logger: Log.Logger, selectedParts?: APM.Part[] | boolean): Promise<{
|
|
2301
|
+
[APM.Part.dde]: Diagnostics.File[];
|
|
2302
|
+
[APM.Part.dlo]: Diagnostics.File[];
|
|
2303
|
+
[APM.Part.dfiles]: Diagnostics.File[];
|
|
2304
|
+
}>;
|
|
2250
2305
|
/**
|
|
2251
2306
|
* Trigger the release based on the manifest settings
|
|
2252
2307
|
* @param cwd
|
|
2253
2308
|
* @param fs
|
|
2309
|
+
* @param logger
|
|
2254
2310
|
* @param token
|
|
2255
2311
|
* @param releasePhase
|
|
2256
2312
|
* @param allowedBackends
|
|
2257
2313
|
* @param env
|
|
2258
2314
|
*/
|
|
2259
|
-
export function release(cwd: URI, fs: LocalFS, token: Registry.AuthToken, releasePhase: APM.TagPhase, allowedBackends: Registry.ApiNewApplication['allowedBackends'], env: Globals.ENV): Promise<void>;
|
|
2315
|
+
export function release(cwd: URI, fs: LocalFS, logger: Log.Logger, token: Registry.AuthToken, releasePhase: APM.TagPhase, allowedBackends: Registry.ApiNewApplication['allowedBackends'], env: Globals.ENV): Promise<void>;
|
|
2260
2316
|
/**
|
|
2261
2317
|
* Publish an application model tag
|
|
2262
2318
|
* @param cwd
|
|
2263
2319
|
* @param fs
|
|
2320
|
+
* @param logger
|
|
2264
2321
|
* @param token
|
|
2265
2322
|
* @param releasePhase
|
|
2266
2323
|
* @param allowedBackends
|
|
2267
2324
|
* @param env
|
|
2268
2325
|
*/
|
|
2269
|
-
export function releaseAPM(cwd: URI, fs: LocalFS, token: Registry.AuthToken, releasePhase: APM.TagPhase, allowedBackends: Registry.ApiNewApplication['allowedBackends'], env: Globals.ENV): Promise<void>;
|
|
2326
|
+
export function releaseAPM(cwd: URI, fs: LocalFS, logger: Log.Logger, token: Registry.AuthToken, releasePhase: APM.TagPhase, allowedBackends: Registry.ApiNewApplication['allowedBackends'], env: Globals.ENV): Promise<void>;
|
|
2270
2327
|
/**
|
|
2271
2328
|
* Publish a library project
|
|
2272
2329
|
* @param cwd
|
|
2273
2330
|
* @param fs
|
|
2331
|
+
* @param logger
|
|
2274
2332
|
* @param token
|
|
2275
2333
|
* @param env
|
|
2276
2334
|
*/
|
|
2277
|
-
export function releaseLibrary(cwd: URI, fs: LocalFS, token: Registry.AuthToken, env: Globals.ENV): Promise<void>;
|
|
2335
|
+
export function releaseLibrary(cwd: URI, fs: LocalFS, logger: Log.Logger, token: Registry.AuthToken, env: Globals.ENV): Promise<void>;
|
|
2278
2336
|
/**
|
|
2279
2337
|
* Read the projects README.md file
|
|
2280
2338
|
* validates if the file content is the initial content
|
|
@@ -3526,6 +3584,11 @@ declare interface paths {
|
|
|
3526
3584
|
[name: string]: unknown;
|
|
3527
3585
|
};
|
|
3528
3586
|
content: {
|
|
3587
|
+
"application/json": {
|
|
3588
|
+
name?: string;
|
|
3589
|
+
} & {
|
|
3590
|
+
[key: string]: unknown;
|
|
3591
|
+
};
|
|
3529
3592
|
"application/gzip": string;
|
|
3530
3593
|
"text/markdown": string;
|
|
3531
3594
|
};
|
|
@@ -4507,13 +4570,14 @@ declare interface paths {
|
|
|
4507
4570
|
*
|
|
4508
4571
|
* @param {URI} cwd - The current working directory of the package.
|
|
4509
4572
|
* @param {LocalFS} fs - The file system interface for reading and writing files.
|
|
4573
|
+
* @param {Logger} logger - Logger instance for logging details during the publish process.
|
|
4510
4574
|
* @param {Globals.ENV} env - The environment configuration for the publishing process.
|
|
4511
4575
|
* @param {string | null} apiToken - The API token for authentication, or null if not applicable.
|
|
4512
4576
|
* @param {string | undefined} optsAllowedBackends - A semicolon-separated list of allowed backends, or '*' to allow all, or undefined if not specified.
|
|
4513
4577
|
* @param {APM.TagPhase} optsPhase - The release phase tag associated with the package publishing.
|
|
4514
4578
|
* @return {Promise<void>} A promise that resolves when the package has been successfully published or rejects with an error if the process fails.
|
|
4515
4579
|
*/
|
|
4516
|
-
export declare function publish(cwd: URI, fs: LocalFS, env: Globals.ENV, apiToken: string | null, optsAllowedBackends: string | undefined, optsPhase: APM.TagPhase): Promise<void>;
|
|
4580
|
+
export declare function publish(cwd: URI, fs: LocalFS, logger: Log.Logger, env: Globals.ENV, apiToken: string | null, optsAllowedBackends: string | undefined, optsPhase: APM.TagPhase): Promise<void>;
|
|
4517
4581
|
|
|
4518
4582
|
export declare namespace Registry {
|
|
4519
4583
|
export type AuthToken = string | null;
|
package/out/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
3
|
+
exports.Log = 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
|
exports.install = install;
|
|
5
5
|
exports.build = build;
|
|
6
6
|
exports.publish = publish;
|
|
@@ -36,6 +36,8 @@ const dfiles_1 = require("./dfiles/dfiles");
|
|
|
36
36
|
Object.defineProperty(exports, "DFILES", { enumerable: true, get: function () { return dfiles_1.DFILES; } });
|
|
37
37
|
const dotenv_1 = require("./dotenv");
|
|
38
38
|
Object.defineProperty(exports, "ENV", { enumerable: true, get: function () { return dotenv_1.ENV; } });
|
|
39
|
+
const log_1 = require("./log");
|
|
40
|
+
Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return log_1.Log; } });
|
|
39
41
|
/**
|
|
40
42
|
* Installs the specified dependencies or all dependencies if none are provided.
|
|
41
43
|
*
|
|
@@ -67,24 +69,27 @@ async function install(cwd, fs, env, apiToken, dependencies) {
|
|
|
67
69
|
*
|
|
68
70
|
* @param {URI} cwd - The current working directory where the build process will be executed.
|
|
69
71
|
* @param {LocalFS} fs - The local file system instance used for file operations during the build.
|
|
70
|
-
* @param {
|
|
71
|
-
* @
|
|
72
|
+
* @param {Logger} logger - Logger instance for logging details during the build process.
|
|
73
|
+
* @param {APM.Part} selectedParts - The project parts to be built.
|
|
74
|
+
* @return A promise that resolves when the build process is complete.
|
|
72
75
|
*/
|
|
73
|
-
async function build(cwd, fs,
|
|
74
|
-
return package_1.Package.buildAll(cwd, fs,
|
|
76
|
+
async function build(cwd, fs, logger, selectedParts = true) {
|
|
77
|
+
return package_1.Package.buildAll(cwd, fs, logger, selectedParts);
|
|
75
78
|
}
|
|
76
79
|
/**
|
|
77
80
|
* Publishes a package to the registry with the specified settings and configurations.
|
|
78
81
|
*
|
|
79
82
|
* @param {URI} cwd - The current working directory of the package.
|
|
80
83
|
* @param {LocalFS} fs - The file system interface for reading and writing files.
|
|
84
|
+
* @param {Logger} logger - Logger instance for logging details during the publish process.
|
|
81
85
|
* @param {Globals.ENV} env - The environment configuration for the publishing process.
|
|
82
86
|
* @param {string | null} apiToken - The API token for authentication, or null if not applicable.
|
|
83
87
|
* @param {string | undefined} optsAllowedBackends - A semicolon-separated list of allowed backends, or '*' to allow all, or undefined if not specified.
|
|
84
88
|
* @param {APM.TagPhase} optsPhase - The release phase tag associated with the package publishing.
|
|
85
89
|
* @return {Promise<void>} A promise that resolves when the package has been successfully published or rejects with an error if the process fails.
|
|
86
90
|
*/
|
|
87
|
-
async function publish(cwd, fs, env, apiToken, optsAllowedBackends, optsPhase) {
|
|
91
|
+
async function publish(cwd, fs, logger, env, apiToken, optsAllowedBackends, optsPhase) {
|
|
92
|
+
logger.info('Publishing package...');
|
|
88
93
|
let allowedBackends = null;
|
|
89
94
|
if (optsAllowedBackends) {
|
|
90
95
|
allowedBackends = optsAllowedBackends === '*' ? optsAllowedBackends : optsAllowedBackends.split(';');
|
|
@@ -93,6 +98,6 @@ async function publish(cwd, fs, env, apiToken, optsAllowedBackends, optsPhase) {
|
|
|
93
98
|
throw new Error(errorMessage);
|
|
94
99
|
}
|
|
95
100
|
}
|
|
96
|
-
|
|
101
|
+
return package_1.Package.release(cwd, fs, logger, apiToken, optsPhase, allowedBackends, env);
|
|
97
102
|
}
|
|
98
103
|
//# sourceMappingURL=api.js.map
|
package/out/dde/dde.js
CHANGED
|
@@ -64,16 +64,16 @@ var DDE;
|
|
|
64
64
|
* @param fs
|
|
65
65
|
* @param fileName
|
|
66
66
|
*/
|
|
67
|
-
async function validate(cwd, fs, fileName = defaultFiles_1.DefaultFiles.fileNames.mainDDE) {
|
|
67
|
+
async function validate(cwd, fs, logger, fileName = defaultFiles_1.DefaultFiles.fileNames.mainDDE) {
|
|
68
68
|
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
69
69
|
const allLibraryFiles = await getDependencies(cwd, fs, manifest);
|
|
70
70
|
for (const libraryFile of allLibraryFiles) {
|
|
71
|
-
await validateJsonSchema(libraryFile.path, libraryFile.yaml);
|
|
71
|
+
await validateJsonSchema(libraryFile.path, libraryFile.yaml, logger);
|
|
72
72
|
}
|
|
73
73
|
// read project dde
|
|
74
74
|
const mainDdePath = vscode_uri_1.Utils.joinPath(cwd, exports.DDE_PATH, fileName);
|
|
75
75
|
const mainDdeYaml = await readYamlFile(mainDdePath, fs);
|
|
76
|
-
await validateJsonSchema(mainDdePath, mainDdeYaml);
|
|
76
|
+
await validateJsonSchema(mainDdePath, mainDdeYaml, logger);
|
|
77
77
|
return {
|
|
78
78
|
manifest,
|
|
79
79
|
libraryFiles: allLibraryFiles,
|
|
@@ -88,11 +88,12 @@ var DDE;
|
|
|
88
88
|
* Run dde compiler in the given studio directory
|
|
89
89
|
* @param cwd
|
|
90
90
|
* @param fs
|
|
91
|
+
* @param logger
|
|
91
92
|
* @param fileName
|
|
92
93
|
*/
|
|
93
|
-
async function compileDDE(cwd, fs, fileName = defaultFiles_1.DefaultFiles.fileNames.mainDDE) {
|
|
94
|
-
const validated = await validate(cwd, fs, fileName);
|
|
95
|
-
const historyJson = await getHistoryJson(cwd, fs);
|
|
94
|
+
async function compileDDE(cwd, fs, logger, fileName = defaultFiles_1.DefaultFiles.fileNames.mainDDE) {
|
|
95
|
+
const validated = await validate(cwd, fs, logger, fileName);
|
|
96
|
+
const historyJson = await getHistoryJson(cwd, fs, logger);
|
|
96
97
|
const preCompiler = new yamlDdePreCompiler_1.YamlPreCompiler.PreCompiler(validated.manifest, validated.libraryFiles, historyJson);
|
|
97
98
|
const libraryDiagnostics = preCompiler.parseLibraries();
|
|
98
99
|
const librariesHaveError = libraryDiagnostics.find(diagnostics => diagnostics.level === 'error');
|
|
@@ -115,14 +116,15 @@ var DDE;
|
|
|
115
116
|
* Validate a given dde file against the dynamic dde schema
|
|
116
117
|
* @param ddeFilePath
|
|
117
118
|
* @param yaml
|
|
119
|
+
* @param logger
|
|
118
120
|
*/
|
|
119
|
-
async function validateJsonSchema(ddeFilePath, yaml) {
|
|
121
|
+
async function validateJsonSchema(ddeFilePath, yaml, logger) {
|
|
120
122
|
const json = (0, yaml_1.parseDocument)(yaml).toJSON();
|
|
121
123
|
const result = validateDynamicDde(json);
|
|
122
124
|
if (!result) {
|
|
123
125
|
const errors = validateDynamicDde.errors || [];
|
|
124
126
|
const error = new Error(`${vscode_uri_1.Utils.basename(ddeFilePath)} has "${errors.length}" errors"`);
|
|
125
|
-
errors.forEach(error =>
|
|
127
|
+
errors.forEach(error => logger.error(error));
|
|
126
128
|
throw error;
|
|
127
129
|
}
|
|
128
130
|
}
|
|
@@ -154,11 +156,11 @@ var DDE;
|
|
|
154
156
|
* @param fs
|
|
155
157
|
* @param ddeJSON
|
|
156
158
|
*/
|
|
157
|
-
async function exportMyDatanetXML(cwd, fs, ddeJSON) {
|
|
159
|
+
async function exportMyDatanetXML(cwd, fs, logger, ddeJSON) {
|
|
158
160
|
const xml = (0, xml_1.generateXMLFromMap)(ddeJSON);
|
|
159
161
|
const distFile = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.ddeXmlPath);
|
|
160
162
|
await fs.writeFile(distFile, xml);
|
|
161
|
-
|
|
163
|
+
logger.log('Generated', defaultFiles_1.DefaultFiles.filePaths.dist.ddeXmlPath);
|
|
162
164
|
}
|
|
163
165
|
DDE.exportMyDatanetXML = exportMyDatanetXML;
|
|
164
166
|
/**
|
|
@@ -166,7 +168,7 @@ var DDE;
|
|
|
166
168
|
* @param cwd
|
|
167
169
|
* @param fs
|
|
168
170
|
*/
|
|
169
|
-
async function getHistoryJson(cwd, fs) {
|
|
171
|
+
async function getHistoryJson(cwd, fs, logger) {
|
|
170
172
|
const historyPath = vscode_uri_1.Utils.joinPath(cwd, exports.DDE_PATH, 'history.json');
|
|
171
173
|
try {
|
|
172
174
|
const binary = await fs.readFile(historyPath);
|
|
@@ -174,7 +176,7 @@ var DDE;
|
|
|
174
176
|
return JSON.parse(historyString);
|
|
175
177
|
}
|
|
176
178
|
catch (e) {
|
|
177
|
-
|
|
179
|
+
logger.warn('history.json does not exist');
|
|
178
180
|
return {};
|
|
179
181
|
}
|
|
180
182
|
}
|
|
@@ -205,13 +207,13 @@ var DDE;
|
|
|
205
207
|
* @param fs
|
|
206
208
|
* @param ddeJSON
|
|
207
209
|
*/
|
|
208
|
-
async function exportHistoryJson(cwd, fs, ddeJSON) {
|
|
209
|
-
const currentHistory = await getHistoryJson(cwd, fs);
|
|
210
|
+
async function exportHistoryJson(cwd, fs, logger, ddeJSON) {
|
|
211
|
+
const currentHistory = await getHistoryJson(cwd, fs, logger);
|
|
210
212
|
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
211
213
|
const newHistory = buildHistoryJson(ddeJSON, currentHistory, manifest);
|
|
212
214
|
const historyPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.historyJson);
|
|
213
215
|
await fs.writeFile(historyPath, JSON.stringify(newHistory, null, '\t'));
|
|
214
|
-
|
|
216
|
+
logger.log('Generated', defaultFiles_1.DefaultFiles.filePaths.dist.historyJson);
|
|
215
217
|
}
|
|
216
218
|
DDE.exportHistoryJson = exportHistoryJson;
|
|
217
219
|
/**
|
|
@@ -230,7 +232,7 @@ var DDE;
|
|
|
230
232
|
* @param fs
|
|
231
233
|
* @param ddeJSON
|
|
232
234
|
*/
|
|
233
|
-
async function exportAutoDloFiles(cwd, fs, ddeJSON) {
|
|
235
|
+
async function exportAutoDloFiles(cwd, fs, logger, ddeJSON) {
|
|
234
236
|
await clearAutoDloDir(cwd, fs);
|
|
235
237
|
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
236
238
|
const dependencies = await getDependencies(cwd, fs, manifest);
|
|
@@ -246,7 +248,7 @@ var DDE;
|
|
|
246
248
|
const autoIncName = defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.autoDdeInc.replace('X', dependency.libraryName);
|
|
247
249
|
const incPath = vscode_uri_1.Utils.joinPath(cwd, autoIncName);
|
|
248
250
|
if (libraryInc.length) {
|
|
249
|
-
|
|
251
|
+
logger.log(`Generated`, autoIncName);
|
|
250
252
|
await fs.writeFile(incPath, libraryInc);
|
|
251
253
|
}
|
|
252
254
|
}
|
|
@@ -254,16 +256,16 @@ var DDE;
|
|
|
254
256
|
const autoUplink = (0, dlo_1.generateAutoUplinkIncFromMap)(ddeJSON, dependencies.map(dep => dep.libraryName));
|
|
255
257
|
const autoIncPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.autoInc);
|
|
256
258
|
await fs.writeFile(autoIncPath, autoInc);
|
|
257
|
-
|
|
259
|
+
logger.log(`Generated`, defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.autoInc);
|
|
258
260
|
const autoUplinkIncPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.autoUplinkInc);
|
|
259
261
|
await fs.writeFile(autoUplinkIncPath, autoUplink);
|
|
260
|
-
|
|
262
|
+
logger.log(`Generated`, defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.autoUplinkInc);
|
|
261
263
|
const autoDdeAppPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.autoDdeInc.replace('X', 'app'));
|
|
262
264
|
await fs.writeFile(autoDdeAppPath, [...appDDEInc.globals, ...appDDEInc.helper].join('\n'));
|
|
263
|
-
|
|
265
|
+
logger.log('Generated', defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.autoDdeInc.replace('X', 'app'));
|
|
264
266
|
const autoDdeMainPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.autoDdeInc.replace('X', 'main'));
|
|
265
267
|
await fs.writeFile(autoDdeMainPath, mainDDEInc);
|
|
266
|
-
|
|
268
|
+
logger.log('Generated', defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.autoDdeInc.replace('X', 'main'));
|
|
267
269
|
await exportDefaultInc(cwd, fs);
|
|
268
270
|
}
|
|
269
271
|
DDE.exportAutoDloFiles = exportAutoDloFiles;
|
|
@@ -273,7 +275,7 @@ var DDE;
|
|
|
273
275
|
* @param fs
|
|
274
276
|
* @param ddeMap
|
|
275
277
|
*/
|
|
276
|
-
async function exportOpenApi(cwd, fs, ddeMap) {
|
|
278
|
+
async function exportOpenApi(cwd, fs, logger, ddeMap) {
|
|
277
279
|
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
278
280
|
const isLibrary = manifest_1.Manifest.isLibrary(manifest);
|
|
279
281
|
// remove previous api description:
|
|
@@ -281,14 +283,14 @@ var DDE;
|
|
|
281
283
|
await fs.rm(previousOpenAPIFileName).catch(() => { });
|
|
282
284
|
const appPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.ddeApi);
|
|
283
285
|
await fs.writeFile(appPath, (0, api_1.generateAPIFromMap)(ddeMap, manifest));
|
|
284
|
-
|
|
286
|
+
logger.log(`Generated`, defaultFiles_1.DefaultFiles.filePaths.dist.ddeApi);
|
|
285
287
|
// generate the api description for the library part of the project
|
|
286
288
|
if (isLibrary) {
|
|
287
289
|
const libPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.ddeApiPath, `${manifest.name}.yaml`);
|
|
288
290
|
const content = (0, api_1.generateAPIFromMap)(ddeMap, manifest, manifest.name);
|
|
289
291
|
if (content.length) {
|
|
290
292
|
await fs.writeFile(libPath, content);
|
|
291
|
-
|
|
293
|
+
logger.log(`Generated`, defaultFiles_1.DefaultFiles.filePaths.dist.ddeApiPath + `${manifest.name}.yaml`);
|
|
292
294
|
}
|
|
293
295
|
}
|
|
294
296
|
}
|
package/out/dfiles/dfiles.js
CHANGED
|
@@ -29,18 +29,8 @@ var DFILES;
|
|
|
29
29
|
Force["up"] = "up";
|
|
30
30
|
Force["off"] = "off";
|
|
31
31
|
})(Force = DFILES.Force || (DFILES.Force = {}));
|
|
32
|
-
async function process(cwd, fs) {
|
|
33
|
-
const
|
|
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);
|
|
32
|
+
async function process(cwd, fs, logger) {
|
|
33
|
+
const { properties, diagnostics, libraryFiles } = await parseDfile(cwd, fs);
|
|
44
34
|
const distDir = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.dfilesPath);
|
|
45
35
|
// clear dist directory beforehand
|
|
46
36
|
if (await fs.stat(distDir)) {
|
|
@@ -48,18 +38,45 @@ var DFILES;
|
|
|
48
38
|
}
|
|
49
39
|
// copy all files to dist directory
|
|
50
40
|
// copy all files to the dist directory
|
|
51
|
-
for (const [dfileName, dfileInfo] of Object.entries(
|
|
41
|
+
for (const [dfileName, dfileInfo] of Object.entries(properties)) {
|
|
52
42
|
await copyDfilesToDist(cwd, fs, dfileName, dfileInfo, libraryFiles);
|
|
53
43
|
}
|
|
54
44
|
// do not write the properties file if there aren't any dfiles
|
|
55
|
-
if (!Object.keys(
|
|
56
|
-
return
|
|
45
|
+
if (!Object.keys(properties).length) {
|
|
46
|
+
return diagnostics;
|
|
57
47
|
}
|
|
58
|
-
|
|
59
|
-
await fs.writeFile(vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.dfilesProperties), JSON.stringify(
|
|
60
|
-
return
|
|
48
|
+
logger.done(`${Object.keys(properties).length} dfiles processed.`);
|
|
49
|
+
await fs.writeFile(vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.dfilesProperties), JSON.stringify(properties, null, '\t'));
|
|
50
|
+
return diagnostics;
|
|
61
51
|
}
|
|
62
52
|
DFILES.process = process;
|
|
53
|
+
/**
|
|
54
|
+
* Parses DFILES from the specified directory and aggregates properties, diagnostics, and library files.
|
|
55
|
+
*
|
|
56
|
+
* @param {URI} cwd - The current working directory URI.
|
|
57
|
+
* @param {LocalFS} fs - The local file system instance used for file operations.
|
|
58
|
+
* @return {Promise<{properties: PropertyList, diagnostics: Diagnostics.File[], libraryFiles: any[]}>}
|
|
59
|
+
* Resolves to an object containing the aggregated properties, diagnostics, and library files information.
|
|
60
|
+
*/
|
|
61
|
+
async function parseDfile(cwd, fs) {
|
|
62
|
+
const allDiagnostics = [];
|
|
63
|
+
const allProperties = {};
|
|
64
|
+
const libraryFiles = await dependencies_1.Dependencies.getApmPartDependencies(cwd, fs, apm_1.APM.Part.dfiles);
|
|
65
|
+
for (const library of libraryFiles) {
|
|
66
|
+
const { properties, diagnostics } = await parseYamlFile(fs, library.path, library.name);
|
|
67
|
+
Object.assign(allProperties, properties);
|
|
68
|
+
allDiagnostics.push(...diagnostics);
|
|
69
|
+
}
|
|
70
|
+
const { properties, diagnostics } = await parseYamlFile(fs, vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dfiles.mainDFILES), null);
|
|
71
|
+
Object.assign(allProperties, properties);
|
|
72
|
+
allDiagnostics.push(...diagnostics);
|
|
73
|
+
return {
|
|
74
|
+
properties: allProperties,
|
|
75
|
+
diagnostics: allDiagnostics,
|
|
76
|
+
libraryFiles: libraryFiles
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
DFILES.parseDfile = parseDfile;
|
|
63
80
|
/**
|
|
64
81
|
*
|
|
65
82
|
* @param fs
|
package/out/dlo/compiler.js
CHANGED
|
@@ -37,11 +37,13 @@ var convertBlobToStringArray = helper_1.Helper.convertBlobToStringArray;
|
|
|
37
37
|
const apm_1 = require("../package/apm");
|
|
38
38
|
const DLO_MODULE = require('./dlocc.js');
|
|
39
39
|
class DloCompiler {
|
|
40
|
+
logger;
|
|
40
41
|
preCompiler = new preCompiler_1.DloPreCompiler();
|
|
41
42
|
dloCC;
|
|
42
43
|
stdout = [];
|
|
43
44
|
stderr = [];
|
|
44
|
-
constructor() {
|
|
45
|
+
constructor(logger) {
|
|
46
|
+
this.logger = logger;
|
|
45
47
|
this.dloCC = null;
|
|
46
48
|
}
|
|
47
49
|
async initDloCC(noExit = false) {
|
|
@@ -50,11 +52,11 @@ class DloCompiler {
|
|
|
50
52
|
this.dloCC = await DLO_MODULE({
|
|
51
53
|
noExitRuntime: noExit,
|
|
52
54
|
print: (data) => {
|
|
53
|
-
|
|
55
|
+
this.logger.log(data);
|
|
54
56
|
this.stdout.push(data);
|
|
55
57
|
},
|
|
56
58
|
printErr: (err) => {
|
|
57
|
-
|
|
59
|
+
this.logger.error(err);
|
|
58
60
|
this.stderr.push(err);
|
|
59
61
|
this.stdout.push(err);
|
|
60
62
|
}
|
package/out/dlo/dlo.js
CHANGED
|
@@ -20,11 +20,11 @@ var DLO;
|
|
|
20
20
|
* @param cwd
|
|
21
21
|
* @param fs
|
|
22
22
|
*/
|
|
23
|
-
async function exportDloConfig(cwd, fs) {
|
|
23
|
+
async function exportDloConfig(cwd, fs, logger) {
|
|
24
24
|
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
25
25
|
const cfgData = await (0, compiler_1.generateConfigFile)(cwd, fs, manifest);
|
|
26
26
|
await fs.writeFile(cfgData.path, cfgData.data);
|
|
27
|
-
|
|
27
|
+
logger.log('Generated', defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.cfg);
|
|
28
28
|
}
|
|
29
29
|
DLO.exportDloConfig = exportDloConfig;
|
|
30
30
|
})(DLO || (exports.DLO = DLO = {}));
|
package/out/log.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
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.Log = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
var Log;
|
|
9
|
+
(function (Log) {
|
|
10
|
+
let LogMessageType;
|
|
11
|
+
(function (LogMessageType) {
|
|
12
|
+
LogMessageType[LogMessageType["log"] = 0] = "log";
|
|
13
|
+
LogMessageType[LogMessageType["done"] = 1] = "done";
|
|
14
|
+
LogMessageType[LogMessageType["info"] = 2] = "info";
|
|
15
|
+
LogMessageType[LogMessageType["warning"] = 3] = "warning";
|
|
16
|
+
LogMessageType[LogMessageType["error"] = 4] = "error";
|
|
17
|
+
})(LogMessageType = Log.LogMessageType || (Log.LogMessageType = {}));
|
|
18
|
+
Log.LOG_PREFIX = {
|
|
19
|
+
[LogMessageType.done]: chalk_1.default.bgGreen.black(' DONE '),
|
|
20
|
+
[LogMessageType.log]: '',
|
|
21
|
+
[LogMessageType.info]: chalk_1.default.bgBlueBright.black(' INFO '),
|
|
22
|
+
[LogMessageType.warning]: chalk_1.default.bgYellow.black(' WARNING '),
|
|
23
|
+
[LogMessageType.error]: chalk_1.default.bgRed.black(' ERROR ')
|
|
24
|
+
};
|
|
25
|
+
class Logger {
|
|
26
|
+
_logHandler;
|
|
27
|
+
constructor(logOutput = console) {
|
|
28
|
+
this._logHandler = logOutput;
|
|
29
|
+
}
|
|
30
|
+
_log(type, msg, ...args) {
|
|
31
|
+
args = [Log.LOG_PREFIX[type], msg, ...args];
|
|
32
|
+
this._logHandler.log(...args);
|
|
33
|
+
}
|
|
34
|
+
log(msg, ...args) {
|
|
35
|
+
this._log(LogMessageType.log, msg, ...args);
|
|
36
|
+
}
|
|
37
|
+
error(msg, ...args) {
|
|
38
|
+
this._log(LogMessageType.error, msg, ...args);
|
|
39
|
+
}
|
|
40
|
+
info(msg, ...args) {
|
|
41
|
+
this._log(LogMessageType.info, msg, ...args);
|
|
42
|
+
}
|
|
43
|
+
warn(msg, ...args) {
|
|
44
|
+
this._log(LogMessageType.warning, msg, ...args);
|
|
45
|
+
}
|
|
46
|
+
done(msg, ...args) {
|
|
47
|
+
this._log(LogMessageType.done, msg, ...args);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
Log.Logger = Logger;
|
|
51
|
+
})(Log || (exports.Log = Log = {}));
|
|
52
|
+
//# sourceMappingURL=log.js.map
|
package/out/main.js
CHANGED
|
@@ -11,8 +11,10 @@ const apm_1 = require("./package/apm");
|
|
|
11
11
|
const globals_1 = require("./globals");
|
|
12
12
|
const update_notifier_1 = __importDefault(require("update-notifier"));
|
|
13
13
|
const api_1 = require("./api");
|
|
14
|
+
const log_1 = require("./log");
|
|
14
15
|
const program = new commander_1.Command();
|
|
15
16
|
const notifier = (0, update_notifier_1.default)({ pkg: package_json_1.default });
|
|
17
|
+
const logger = new log_1.Log.Logger();
|
|
16
18
|
// dummy cwd
|
|
17
19
|
const devPath = () => {
|
|
18
20
|
if (process.env.NODE_ENV === 'local-dev-app') {
|
|
@@ -83,7 +85,7 @@ program
|
|
|
83
85
|
.command('build')
|
|
84
86
|
.addOption(new commander_1.Option('-p --part <APM part>', 'APM part that should be build').choices(Object.values(apm_1.APM.Part)))
|
|
85
87
|
.action(opts => {
|
|
86
|
-
main((0, api_1.build)(cwd, cliFS_1.cliFS, opts.part));
|
|
88
|
+
main((0, api_1.build)(cwd, cliFS_1.cliFS, logger, opts.part));
|
|
87
89
|
});
|
|
88
90
|
const releasePhaseArguments = Object.values(apm_1.APM.TagPhase);
|
|
89
91
|
program
|
|
@@ -96,7 +98,7 @@ program
|
|
|
96
98
|
.addOption(optionStudioToken)
|
|
97
99
|
.action(async (opts) => {
|
|
98
100
|
const { env, token } = getDefaultOptions(opts);
|
|
99
|
-
main((0, api_1.publish)(cwd, cliFS_1.cliFS, env, token, opts.allowedBackends, opts.phase));
|
|
101
|
+
main((0, api_1.publish)(cwd, cliFS_1.cliFS, logger, env, token, opts.allowedBackends, opts.phase));
|
|
100
102
|
});
|
|
101
103
|
module.exports = function (argv) {
|
|
102
104
|
program.parse(argv);
|
package/out/package/package.js
CHANGED
|
@@ -20,43 +20,76 @@ var Package;
|
|
|
20
20
|
* Build the whole project or only a specific part
|
|
21
21
|
* @param cwd
|
|
22
22
|
* @param fs
|
|
23
|
-
* @param
|
|
23
|
+
* @param logger
|
|
24
|
+
* @param selectedParts - choose a specific part that should be build or if true all parts are build
|
|
24
25
|
*/
|
|
25
|
-
async function buildAll(cwd, fs,
|
|
26
|
-
if (
|
|
27
|
-
|
|
26
|
+
async function buildAll(cwd, fs, logger, selectedParts = true) {
|
|
27
|
+
if (selectedParts === true) {
|
|
28
|
+
logger.info('Building project...');
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
selectedParts = Object.values(apm_1.APM.Part);
|
|
31
|
+
const mergedDiagnostics = {
|
|
32
|
+
[apm_1.APM.Part.dde]: [],
|
|
33
|
+
[apm_1.APM.Part.dlo]: [],
|
|
34
|
+
[apm_1.APM.Part.dfiles]: []
|
|
35
|
+
};
|
|
36
|
+
// Helper for building parts
|
|
37
|
+
const buildMapping = {
|
|
38
|
+
[apm_1.APM.Part.dde]: buildDDE,
|
|
39
|
+
[apm_1.APM.Part.dlo]: buildDLO,
|
|
40
|
+
[apm_1.APM.Part.dfiles]: buildDfiles
|
|
41
|
+
};
|
|
42
|
+
// Build and validate specific parts
|
|
43
|
+
for (const part of [apm_1.APM.Part.dde, apm_1.APM.Part.dlo, apm_1.APM.Part.dfiles]) {
|
|
44
|
+
if (selectedParts.includes(part)) {
|
|
45
|
+
logger.info(`Building ${part.toUpperCase()}...`);
|
|
46
|
+
const hasError = await buildAndValidatePart(logger, part,
|
|
47
|
+
/*@ts-ignore*/
|
|
48
|
+
buildMapping[part],
|
|
49
|
+
/*@ts-ignore*/
|
|
50
|
+
mergedDiagnostics[part], cwd, fs);
|
|
51
|
+
if (hasError) {
|
|
52
|
+
return mergedDiagnostics; // Early exit on error
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Handle pov and blo parts that do not return diagnostics
|
|
57
|
+
if (selectedParts.includes(apm_1.APM.Part.pov)) {
|
|
58
|
+
await scriptRunner_1.Shell.tryBuildPov(cwd, fs, logger);
|
|
31
59
|
}
|
|
32
|
-
|
|
33
|
-
|
|
60
|
+
else {
|
|
61
|
+
logger.info('Skipping pov build');
|
|
34
62
|
}
|
|
35
|
-
if (
|
|
36
|
-
await scriptRunner_1.Shell.
|
|
63
|
+
if (selectedParts.includes(apm_1.APM.Part.blo)) {
|
|
64
|
+
await scriptRunner_1.Shell.tryBuildBlo(cwd, fs, logger);
|
|
37
65
|
}
|
|
38
|
-
|
|
39
|
-
|
|
66
|
+
else {
|
|
67
|
+
logger.info('Skipping blo build');
|
|
40
68
|
}
|
|
41
|
-
|
|
69
|
+
await processAdditionalFiles(cwd, fs, logger);
|
|
70
|
+
logger.done('Project build completed.');
|
|
71
|
+
return mergedDiagnostics;
|
|
42
72
|
}
|
|
43
73
|
Package.buildAll = buildAll;
|
|
44
74
|
/**
|
|
45
75
|
* Trigger the release based on the manifest settings
|
|
46
76
|
* @param cwd
|
|
47
77
|
* @param fs
|
|
78
|
+
* @param logger
|
|
48
79
|
* @param token
|
|
49
80
|
* @param releasePhase
|
|
50
81
|
* @param allowedBackends
|
|
51
82
|
* @param env
|
|
52
83
|
*/
|
|
53
|
-
async function release(cwd, fs, token, releasePhase, allowedBackends, env) {
|
|
84
|
+
async function release(cwd, fs, logger, token, releasePhase, allowedBackends, env) {
|
|
54
85
|
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
55
86
|
if (manifest_1.Manifest.isLibrary(manifest)) {
|
|
56
|
-
|
|
87
|
+
logger.info('Library project detected. Publishing library...');
|
|
88
|
+
return releaseLibrary(cwd, fs, logger, token, env);
|
|
57
89
|
}
|
|
58
90
|
else {
|
|
59
|
-
|
|
91
|
+
logger.info('App project detected. Publishing app...');
|
|
92
|
+
return releaseAPM(cwd, fs, logger, token, releasePhase, allowedBackends, env);
|
|
60
93
|
}
|
|
61
94
|
}
|
|
62
95
|
Package.release = release;
|
|
@@ -64,12 +97,13 @@ var Package;
|
|
|
64
97
|
* Publish an application model tag
|
|
65
98
|
* @param cwd
|
|
66
99
|
* @param fs
|
|
100
|
+
* @param logger
|
|
67
101
|
* @param token
|
|
68
102
|
* @param releasePhase
|
|
69
103
|
* @param allowedBackends
|
|
70
104
|
* @param env
|
|
71
105
|
*/
|
|
72
|
-
async function releaseAPM(cwd, fs, token, releasePhase, allowedBackends = null, env) {
|
|
106
|
+
async function releaseAPM(cwd, fs, logger, token, releasePhase, allowedBackends = null, env) {
|
|
73
107
|
if (!Object.values(apm_1.APM.TagPhase).includes(releasePhase)) {
|
|
74
108
|
throw new Error(`ReleasePhase: ${releasePhase} is not a valid release phase`);
|
|
75
109
|
}
|
|
@@ -79,7 +113,7 @@ var Package;
|
|
|
79
113
|
return;
|
|
80
114
|
}
|
|
81
115
|
// build the complete project
|
|
82
|
-
await buildAll(cwd, fs);
|
|
116
|
+
await buildAll(cwd, fs, logger);
|
|
83
117
|
// update the store apm with the actual name/description/...
|
|
84
118
|
await apm_1.APM.updateProfile(cwd, fs, token, env);
|
|
85
119
|
const tagContent = await apm_1.APM.createTag(cwd, fs, releasePhase);
|
|
@@ -90,27 +124,28 @@ var Package;
|
|
|
90
124
|
await registryAPI_1.Registry.updateExistingApplicationVersion(token, manifest.publisher, manifest.registry?.id, manifest.version, {
|
|
91
125
|
allowedBackends
|
|
92
126
|
}, env);
|
|
93
|
-
|
|
127
|
+
logger.info(`Tag "${newTag.version}" with phase "${newTag.phase}" shared with ${[...allowedBackends].join(';')}!`);
|
|
94
128
|
}
|
|
95
|
-
|
|
129
|
+
logger.done(`Tag "${newTag.version}" with phase "${newTag.phase}" published!`);
|
|
96
130
|
}
|
|
97
131
|
Package.releaseAPM = releaseAPM;
|
|
98
132
|
/**
|
|
99
133
|
* Publish a library project
|
|
100
134
|
* @param cwd
|
|
101
135
|
* @param fs
|
|
136
|
+
* @param logger
|
|
102
137
|
* @param token
|
|
103
138
|
* @param env
|
|
104
139
|
*/
|
|
105
|
-
async function releaseLibrary(cwd, fs, token, env) {
|
|
140
|
+
async function releaseLibrary(cwd, fs, logger, token, env) {
|
|
106
141
|
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
107
142
|
await manifest_1.Manifest.validateBasicManifest(cwd, fs, manifest);
|
|
108
143
|
await validatePublishSettings(cwd, fs, token, env);
|
|
109
144
|
// build the complete project
|
|
110
|
-
await buildAll(cwd, fs);
|
|
145
|
+
await buildAll(cwd, fs, logger);
|
|
111
146
|
const archive = await library_1.Library.createArchive(cwd, fs);
|
|
112
147
|
await library_1.Library.publishPackage(cwd, fs, token, archive, env);
|
|
113
|
-
|
|
148
|
+
logger.done(`Library "${manifest.publisher}/${manifest.name}" with version "${manifest.version}" published!`);
|
|
114
149
|
}
|
|
115
150
|
Package.releaseLibrary = releaseLibrary;
|
|
116
151
|
/**
|
|
@@ -196,55 +231,73 @@ var Package;
|
|
|
196
231
|
* Generates all needed files out of the dde declaration
|
|
197
232
|
* @param cwd
|
|
198
233
|
* @param fs
|
|
234
|
+
* @param logger
|
|
199
235
|
*/
|
|
200
|
-
async function buildDDE(cwd, fs) {
|
|
201
|
-
|
|
202
|
-
const result = await dde_1.DDE.compileDDE(cwd, fs);
|
|
203
|
-
result.diagnostics.forEach(diagnostic => {
|
|
204
|
-
const message = `${diagnostic.file.path}: ${diagnostic.message}`;
|
|
205
|
-
if (diagnostic.level === 'error') {
|
|
206
|
-
console.error(message);
|
|
207
|
-
}
|
|
208
|
-
else if (diagnostic.level === 'warning') {
|
|
209
|
-
console.warn(message);
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
console.log(message);
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
throwIfDiagnosticsHaveError(apm_1.APM.Part.dde, result.diagnostics);
|
|
236
|
+
async function buildDDE(cwd, fs, logger) {
|
|
237
|
+
const result = await dde_1.DDE.compileDDE(cwd, fs, logger);
|
|
216
238
|
if (result.ddeJSON) {
|
|
217
|
-
await dde_1.DDE.exportMyDatanetXML(cwd, fs, result.ddeJSON);
|
|
239
|
+
await dde_1.DDE.exportMyDatanetXML(cwd, fs, logger, result.ddeJSON);
|
|
218
240
|
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
219
241
|
// a library does not need a history.json
|
|
220
242
|
if (!manifest_1.Manifest.isLibrary(manifest)) {
|
|
221
|
-
await dde_1.DDE.exportHistoryJson(cwd, fs, result.ddeJSON);
|
|
243
|
+
await dde_1.DDE.exportHistoryJson(cwd, fs, logger, result.ddeJSON);
|
|
222
244
|
}
|
|
223
|
-
await dde_1.DDE.exportOpenApi(cwd, fs, result.ddeJSON);
|
|
245
|
+
await dde_1.DDE.exportOpenApi(cwd, fs, logger, result.ddeJSON);
|
|
224
246
|
if (await manifest_1.Manifest.isApmPartEnabled(cwd, fs, apm_1.APM.Part.dlo, manifest)) {
|
|
225
|
-
await dde_1.DDE.exportAutoDloFiles(cwd, fs, result.ddeJSON);
|
|
226
|
-
await dlo_1.DLO.exportDloConfig(cwd, fs);
|
|
247
|
+
await dde_1.DDE.exportAutoDloFiles(cwd, fs, logger, result.ddeJSON);
|
|
248
|
+
await dlo_1.DLO.exportDloConfig(cwd, fs, logger);
|
|
227
249
|
}
|
|
228
250
|
}
|
|
229
|
-
|
|
230
|
-
throw new Error('Project has errors!');
|
|
231
|
-
}
|
|
251
|
+
return result.diagnostics;
|
|
232
252
|
}
|
|
233
|
-
async function buildDLO(cwd, fs) {
|
|
234
|
-
|
|
235
|
-
const compiler = new compiler_1.DloCompiler();
|
|
253
|
+
async function buildDLO(cwd, fs, logger) {
|
|
254
|
+
const compiler = new compiler_1.DloCompiler(logger);
|
|
236
255
|
const { diagnostics } = await compiler.compile(cwd, fs);
|
|
237
|
-
|
|
256
|
+
return diagnostics;
|
|
238
257
|
}
|
|
239
|
-
async function buildDfiles(cwd, fs) {
|
|
240
|
-
|
|
241
|
-
const diagnostics = await dfiles_1.DFILES.process(cwd, fs);
|
|
242
|
-
throwIfDiagnosticsHaveError(apm_1.APM.Part.dfiles, diagnostics);
|
|
258
|
+
async function buildDfiles(cwd, fs, logger) {
|
|
259
|
+
return await dfiles_1.DFILES.process(cwd, fs, logger);
|
|
243
260
|
}
|
|
244
|
-
|
|
261
|
+
/**
|
|
262
|
+
* Handle additional files like `mdn_report_template.json`
|
|
263
|
+
* @private
|
|
264
|
+
*/
|
|
265
|
+
async function processAdditionalFiles(cwd, fs, logger) {
|
|
266
|
+
const reportTemplate = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.fileNames.reportTemplate);
|
|
267
|
+
if (await fs.stat(reportTemplate)) {
|
|
268
|
+
const distFolder = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.reportTemplate);
|
|
269
|
+
await fs.copy(reportTemplate, distFolder);
|
|
270
|
+
logger.log(`Copied "${defaultFiles_1.DefaultFiles.fileNames.reportTemplate}" to dist folder.`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function validateDiagnostics(logger, apmPart, diagnostics) {
|
|
274
|
+
if (apmPart !== apm_1.APM.Part.dlo) {
|
|
275
|
+
// dlo compiler does log diagnostics by itself
|
|
276
|
+
logDiagnostics(logger, diagnostics);
|
|
277
|
+
}
|
|
278
|
+
const hasErrors = diagnostics.some(diagnostic => diagnostic.level === 'error');
|
|
279
|
+
if (hasErrors) {
|
|
280
|
+
const message = `APM part "${apmPart}" has errors. Aborted.`;
|
|
281
|
+
throw new Error(message);
|
|
282
|
+
}
|
|
283
|
+
return hasErrors;
|
|
284
|
+
}
|
|
285
|
+
async function buildAndValidatePart(logger, part, buildFn, mergedDiagnostics, cwd, fs) {
|
|
286
|
+
const diagnostics = await buildFn(cwd, fs, logger);
|
|
287
|
+
mergedDiagnostics.push(...diagnostics);
|
|
288
|
+
return validateDiagnostics(logger, part, diagnostics);
|
|
289
|
+
}
|
|
290
|
+
function logDiagnostics(logger, diagnostics) {
|
|
245
291
|
diagnostics.forEach(diagnostic => {
|
|
292
|
+
const message = `${diagnostic.file.path}: ${diagnostic.message}`;
|
|
246
293
|
if (diagnostic.level === 'error') {
|
|
247
|
-
|
|
294
|
+
logger.error(message);
|
|
295
|
+
}
|
|
296
|
+
else if (diagnostic.level === 'warning') {
|
|
297
|
+
logger.warn(message);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
logger.log(message);
|
|
248
301
|
}
|
|
249
302
|
});
|
|
250
303
|
}
|
package/out/scriptRunner.js
CHANGED
|
@@ -34,15 +34,16 @@ var Shell;
|
|
|
34
34
|
* Calls the POV build command defined within the manifest
|
|
35
35
|
* @param cwd
|
|
36
36
|
* @param fs
|
|
37
|
+
* @param logger
|
|
37
38
|
*/
|
|
38
|
-
async function tryBuildPov(cwd, fs) {
|
|
39
|
+
async function tryBuildPov(cwd, fs, logger) {
|
|
39
40
|
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
40
41
|
if (await manifest_1.Manifest.isApmPartEnabled(cwd, fs, apm_1.APM.Part.pov)) {
|
|
41
|
-
|
|
42
|
+
logger.info('Executing POV build script', manifest.pov?.details.buildCommand);
|
|
42
43
|
const { buildCommand, workingPath } = manifest.pov.details;
|
|
43
44
|
const povDir = vscode_uri_1.Utils.joinPath(cwd, workingPath);
|
|
44
45
|
try {
|
|
45
|
-
await execShell(povDir, buildCommand);
|
|
46
|
+
await execShell(povDir, buildCommand, logger);
|
|
46
47
|
}
|
|
47
48
|
catch (e) {
|
|
48
49
|
if (e.code) {
|
|
@@ -59,15 +60,16 @@ var Shell;
|
|
|
59
60
|
* Calls the BLO build command defined within the manifest
|
|
60
61
|
* @param cwd
|
|
61
62
|
* @param fs
|
|
63
|
+
* @param logger
|
|
62
64
|
*/
|
|
63
|
-
async function tryBuildBlo(cwd, fs) {
|
|
65
|
+
async function tryBuildBlo(cwd, fs, logger) {
|
|
64
66
|
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
65
67
|
if (await manifest_1.Manifest.isApmPartEnabled(cwd, fs, apm_1.APM.Part.blo, manifest)) {
|
|
66
|
-
|
|
68
|
+
logger.info('Executing BLO build script', manifest.blo?.buildCommand);
|
|
67
69
|
const { buildCommand, workingPath } = manifest.blo;
|
|
68
70
|
const bloDir = vscode_uri_1.Utils.joinPath(cwd, workingPath);
|
|
69
71
|
try {
|
|
70
|
-
await execShell(bloDir, buildCommand);
|
|
72
|
+
await execShell(bloDir, buildCommand, logger);
|
|
71
73
|
}
|
|
72
74
|
catch (e) {
|
|
73
75
|
if (e.code) {
|
|
@@ -85,13 +87,16 @@ var Shell;
|
|
|
85
87
|
* Generic shell executor
|
|
86
88
|
* @param cwd - working dir where the command should be executed in
|
|
87
89
|
* @param cmd - the shell command
|
|
90
|
+
* @param logger
|
|
88
91
|
*/
|
|
89
|
-
async function execShell(cwd, cmd) {
|
|
92
|
+
async function execShell(cwd, cmd, logger) {
|
|
90
93
|
return new Promise((resolve, reject) => {
|
|
91
94
|
// todo use spawn instead of exec to allow streaming to the console
|
|
92
95
|
child_process.exec(cmd, { cwd: cwd.fsPath, env: process.env }, (error, stdout, stderr) => {
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
logger.log(stdout);
|
|
97
|
+
if (stderr) {
|
|
98
|
+
logger.error(stderr);
|
|
99
|
+
}
|
|
95
100
|
if (error) {
|
|
96
101
|
reject(error);
|
|
97
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microtronics/studio-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Microtronics Studio CLI Tool",
|
|
5
5
|
"main": "./out/api.js",
|
|
6
6
|
"typings": "./dist/studio-cli.d.ts",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"ajv": "^8.17.1",
|
|
29
29
|
"ajv-formats": "^3.0.1",
|
|
30
30
|
"ajv-keywords": "^5.1.0",
|
|
31
|
+
"chalk": "^5.4.1",
|
|
31
32
|
"commander": "^12.1.0",
|
|
32
33
|
"cross-fetch": "^4.0.0",
|
|
33
34
|
"dotenv": "^16.4.7",
|