@microtronics/studio-cli 0.49.0 → 0.51.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.
@@ -138,7 +138,7 @@ export declare function build(cwd: URI, fs: LocalFS, logger: Log.Logger, env: Gl
138
138
  /**
139
139
  * Build development installation info from manifest and options
140
140
  */
141
- export declare function buildDevelopmentInstallInfo(cwd: URI, fs: LocalFS, serialNumber: string, userName: string, customerUid: string | null): Promise<DevelopmentInstallInfo>;
141
+ export declare function buildDevelopmentInstallInfo(cwd: URI, fs: LocalFS, logger: Log.Logger, serialNumber: string, userName: string, customerUid: string | null, customSiteName?: string): Promise<DevelopmentInstallInfo>;
142
142
 
143
143
  declare interface components {
144
144
  schemas: {
@@ -1843,7 +1843,12 @@ declare class DloCompiler {
1843
1843
  diagnostics: Diagnostics.File[];
1844
1844
  }>;
1845
1845
  /**
1846
- * Get a symbol compiler instance
1846
+ * Run the symbol compiler and return its output lines.
1847
+ * Handles WASM-specific path patching (`.` prefix for PROXYFS, `-R` flag).
1848
+ */
1849
+ getDloSymbols(mainFile: string, compileOptions: string[]): Promise<string[] | null>;
1850
+ /**
1851
+ * Get a symbol compiler instance with direct disk access via CUSTOM_WASM_FS.
1847
1852
  */
1848
1853
  getSymbolCompiler(): Promise<{
1849
1854
  compiler: any;
@@ -2179,10 +2184,12 @@ export declare namespace Log {
2179
2184
  };
2180
2185
  export class Logger {
2181
2186
  private _logHandler;
2187
+ private _silent;
2182
2188
  constructor(logOutput?: {
2183
2189
  log: (...args: any[]) => void;
2184
2190
  });
2185
2191
  _log(type: LogMessageType, msg: any, ...args: any[]): void;
2192
+ set silent(value: boolean);
2186
2193
  log(msg: any, ...args: any[]): void;
2187
2194
  error(msg: any, ...args: any[]): void;
2188
2195
  info(msg: any, ...args: any[]): void;
@@ -91,15 +91,36 @@ class DloCompiler {
91
91
  diagnostics: [...CustomWasmFS_1.precompilerDiagnostics, ...parseWarningsAndErrors(cwd, this.stderr, mainFile)]
92
92
  };
93
93
  }
94
+ /**
95
+ * Run the symbol compiler and return its output lines.
96
+ * Handles WASM-specific path patching (`.` prefix for PROXYFS, `-R` flag).
97
+ */
98
+ async getDloSymbols(mainFile, compileOptions) {
99
+ const symbolOptions = compileOptions.map(option => {
100
+ const command = option.substring(0, 2);
101
+ if (['-D', '-e', '-i', '-o', '-p', '-r', '-T'].includes(command)) {
102
+ return `${command}.${option.substring(2)}`;
103
+ }
104
+ return option;
105
+ });
106
+ const { compiler: symbolCompiler, print } = await this.getSymbolCompiler();
107
+ try {
108
+ const res = await symbolCompiler.callMain(['.' + mainFile, ...symbolOptions, '-R']);
109
+ if (res)
110
+ return null;
111
+ }
112
+ catch (e) {
113
+ if (e.stack?.startsWith('RuntimeError'))
114
+ return null;
115
+ throw e;
116
+ }
117
+ return [...print.stdout, ...print.stderr];
118
+ }
94
119
  //Symbol Compiler handling
95
120
  /**
96
- * Get a symbol compiler instance
121
+ * Get a symbol compiler instance with direct disk access via CUSTOM_WASM_FS.
97
122
  */
98
123
  async getSymbolCompiler() {
99
- // generate a none exiting wasm compiler runtime as main filesystem
100
- if (!this.dloCC) {
101
- await this.initDloCC(true);
102
- }
103
124
  const compilerLog = {
104
125
  stdout: [],
105
126
  stderr: []
@@ -113,13 +134,14 @@ class DloCompiler {
113
134
  compilerLog.stderr.push(err);
114
135
  }
115
136
  });
116
- // mount the main filesystem
117
- dloSymbol.FS.mkdir('/baseDir');
118
- dloSymbol.FS.mount(dloSymbol.PROXYFS, {
119
- root: '/',
120
- fs: this.dloCC.FS
121
- }, '/baseDir');
122
- dloSymbol.FS.chdir('baseDir');
137
+ // Mount CUSTOM_WASM_FS for direct disk access (same as initDloCC)
138
+ const currentCWD = (0, CustomWasmFS_1.uriToMemFsPath)(this.cwd);
139
+ const [rootDir] = currentCWD.split('/');
140
+ const FS = dloSymbol.FS;
141
+ const manifest = await manifest_1.Manifest.read(this.cwd, this.fs);
142
+ FS.filesystems.NODEFS_TS = (0, CustomWasmFS_1.CUSTOM_WASM_FS)(FS, this.cwd, manifest, this.logger);
143
+ FS.mkdir(rootDir);
144
+ FS.mount(FS.filesystems.NODEFS_TS, { root: '/' }, rootDir);
123
145
  return {
124
146
  compiler: dloSymbol,
125
147
  print: compilerLog
package/out/log.js CHANGED
@@ -24,13 +24,21 @@ var Log;
24
24
  };
25
25
  class Logger {
26
26
  _logHandler;
27
+ _silent = false;
27
28
  constructor(logOutput = console) {
28
29
  this._logHandler = logOutput;
29
30
  }
30
31
  _log(type, msg, ...args) {
32
+ // only log errors if silent is set
33
+ if (this._silent && type !== LogMessageType.error) {
34
+ return;
35
+ }
31
36
  args = [Log.LOG_PREFIX[type], msg, ...args];
32
37
  this._logHandler.log(...args);
33
38
  }
39
+ set silent(value) {
40
+ this._silent = value;
41
+ }
34
42
  log(msg, ...args) {
35
43
  this._log(LogMessageType.log, msg, ...args);
36
44
  }
@@ -265,7 +265,7 @@ function generateDevApmId(developmentReference) {
265
265
  /**
266
266
  * Build development installation info from manifest and options
267
267
  */
268
- async function buildDevelopmentInstallInfo(cwd, fs, serialNumber, userName, customerUid) {
268
+ async function buildDevelopmentInstallInfo(cwd, fs, logger, serialNumber, userName, customerUid, customSiteName) {
269
269
  const manifest = await manifest_1.Manifest.read(cwd, fs);
270
270
  const currentUserId = userName.replaceAll(' ', '_').replace(/[^a-zA-Z0-9-]+/g, '');
271
271
  const appName = manifest.name.replaceAll(' ', '_').replace(/[^a-zA-Z0-9-]+/g, '');
@@ -273,10 +273,15 @@ async function buildDevelopmentInstallInfo(cwd, fs, serialNumber, userName, cust
273
273
  const useDeviceSerial = hasDlo && serialNumber;
274
274
  const siteName = useDeviceSerial ? serialNumber.toUpperCase() : `${appName}_${currentUserId}`;
275
275
  const developmentReference = useDeviceSerial ? serialNumber : siteName;
276
+ let realSiteName = customSiteName || siteName;
277
+ if (realSiteName.length > 50) {
278
+ logger.warn(`Site name "${realSiteName}" is too long. Truncating to 50 characters.`);
279
+ realSiteName = realSiteName.substring(0, 50);
280
+ }
276
281
  return {
277
282
  apmId: generateDevApmId(developmentReference),
278
283
  applicationId: null,
279
- name: `${siteName}`.substring(0, 50), // site name can have a max number of 50 chars
284
+ name: realSiteName,
280
285
  version: 1,
281
286
  serialNumber: hasDlo ? serialNumber : undefined,
282
287
  siteUid: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microtronics/studio-cli",
3
- "version": "0.49.0",
3
+ "version": "0.51.0",
4
4
  "description": "Microtronics Studio CLI Tool",
5
5
  "main": "./out/api.js",
6
6
  "typings": "./dist/studio-cli.d.ts",