@platforma-sdk/tengo-builder 2.4.13 → 2.4.15

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.
Files changed (123) hide show
  1. package/README.md +4 -4
  2. package/bin/run.js +5 -5
  3. package/dist/commands/build.cjs +36 -36
  4. package/dist/commands/build.cjs.map +1 -1
  5. package/dist/commands/build.d.ts +5 -5
  6. package/dist/commands/build.js +36 -36
  7. package/dist/commands/build.js.map +1 -1
  8. package/dist/commands/check.cjs +5 -5
  9. package/dist/commands/check.cjs.map +1 -1
  10. package/dist/commands/check.d.ts +2 -2
  11. package/dist/commands/check.d.ts.map +1 -1
  12. package/dist/commands/check.js +5 -5
  13. package/dist/commands/check.js.map +1 -1
  14. package/dist/commands/dump/artifacts.cjs +4 -6
  15. package/dist/commands/dump/artifacts.cjs.map +1 -1
  16. package/dist/commands/dump/artifacts.d.ts +2 -2
  17. package/dist/commands/dump/artifacts.d.ts.map +1 -1
  18. package/dist/commands/dump/artifacts.js +4 -6
  19. package/dist/commands/dump/artifacts.js.map +1 -1
  20. package/dist/commands/dump/software.cjs +3 -5
  21. package/dist/commands/dump/software.cjs.map +1 -1
  22. package/dist/commands/dump/software.d.ts +2 -2
  23. package/dist/commands/dump/software.d.ts.map +1 -1
  24. package/dist/commands/dump/software.js +3 -5
  25. package/dist/commands/dump/software.js.map +1 -1
  26. package/dist/commands/test.cjs +5 -5
  27. package/dist/commands/test.cjs.map +1 -1
  28. package/dist/commands/test.d.ts +2 -2
  29. package/dist/commands/test.d.ts.map +1 -1
  30. package/dist/commands/test.js +5 -5
  31. package/dist/commands/test.js.map +1 -1
  32. package/dist/compiler/artifactset.cjs +2 -2
  33. package/dist/compiler/artifactset.cjs.map +1 -1
  34. package/dist/compiler/artifactset.d.ts +1 -1
  35. package/dist/compiler/artifactset.d.ts.map +1 -1
  36. package/dist/compiler/artifactset.js +2 -2
  37. package/dist/compiler/artifactset.js.map +1 -1
  38. package/dist/compiler/compiler.cjs +37 -34
  39. package/dist/compiler/compiler.cjs.map +1 -1
  40. package/dist/compiler/compiler.d.ts +3 -3
  41. package/dist/compiler/compiler.d.ts.map +1 -1
  42. package/dist/compiler/compiler.js +37 -34
  43. package/dist/compiler/compiler.js.map +1 -1
  44. package/dist/compiler/compileroptions.cjs +12 -12
  45. package/dist/compiler/compileroptions.cjs.map +1 -1
  46. package/dist/compiler/compileroptions.d.ts +2 -2
  47. package/dist/compiler/compileroptions.js +12 -12
  48. package/dist/compiler/compileroptions.js.map +1 -1
  49. package/dist/compiler/main.cjs +58 -58
  50. package/dist/compiler/main.cjs.map +1 -1
  51. package/dist/compiler/main.d.ts +6 -6
  52. package/dist/compiler/main.d.ts.map +1 -1
  53. package/dist/compiler/main.js +58 -58
  54. package/dist/compiler/main.js.map +1 -1
  55. package/dist/compiler/package.cjs +5 -2
  56. package/dist/compiler/package.cjs.map +1 -1
  57. package/dist/compiler/package.d.ts +6 -6
  58. package/dist/compiler/package.d.ts.map +1 -1
  59. package/dist/compiler/package.js +5 -2
  60. package/dist/compiler/package.js.map +1 -1
  61. package/dist/compiler/source.cjs +50 -52
  62. package/dist/compiler/source.cjs.map +1 -1
  63. package/dist/compiler/source.d.ts +2 -2
  64. package/dist/compiler/source.d.ts.map +1 -1
  65. package/dist/compiler/source.js +50 -52
  66. package/dist/compiler/source.js.map +1 -1
  67. package/dist/compiler/template.cjs +7 -7
  68. package/dist/compiler/template.cjs.map +1 -1
  69. package/dist/compiler/template.d.ts +2 -2
  70. package/dist/compiler/template.d.ts.map +1 -1
  71. package/dist/compiler/template.js +7 -7
  72. package/dist/compiler/template.js.map +1 -1
  73. package/dist/compiler/test.artifacts.d.ts +1 -1
  74. package/dist/compiler/test.artifacts.d.ts.map +1 -1
  75. package/dist/compiler/util.cjs +12 -12
  76. package/dist/compiler/util.cjs.map +1 -1
  77. package/dist/compiler/util.d.ts +2 -2
  78. package/dist/compiler/util.js +12 -12
  79. package/dist/compiler/util.js.map +1 -1
  80. package/dist/index.cjs +5 -5
  81. package/dist/index.cjs.map +1 -1
  82. package/dist/index.d.ts +7 -7
  83. package/dist/index.js +5 -5
  84. package/dist/index.js.map +1 -1
  85. package/dist/shared/basecmd.cjs +15 -15
  86. package/dist/shared/basecmd.cjs.map +1 -1
  87. package/dist/shared/basecmd.d.ts +4 -4
  88. package/dist/shared/basecmd.js +15 -15
  89. package/dist/shared/basecmd.js.map +1 -1
  90. package/dist/shared/dump.cjs +28 -28
  91. package/dist/shared/dump.cjs.map +1 -1
  92. package/dist/shared/dump.d.ts +2 -2
  93. package/dist/shared/dump.d.ts.map +1 -1
  94. package/dist/shared/dump.js +28 -28
  95. package/dist/shared/dump.js.map +1 -1
  96. package/dist/shared/proc.cjs +5 -5
  97. package/dist/shared/proc.cjs.map +1 -1
  98. package/dist/shared/proc.d.ts +2 -2
  99. package/dist/shared/proc.js +5 -5
  100. package/dist/shared/proc.js.map +1 -1
  101. package/package.json +21 -19
  102. package/src/commands/build.ts +57 -55
  103. package/src/commands/check.ts +15 -12
  104. package/src/commands/dump/artifacts.ts +11 -15
  105. package/src/commands/dump/software.ts +9 -10
  106. package/src/commands/test.ts +15 -12
  107. package/src/compiler/artifactset.ts +7 -9
  108. package/src/compiler/compiler.test.ts +134 -137
  109. package/src/compiler/compiler.ts +62 -62
  110. package/src/compiler/compileroptions.ts +15 -15
  111. package/src/compiler/main.test.ts +23 -23
  112. package/src/compiler/main.ts +83 -100
  113. package/src/compiler/package.ts +14 -12
  114. package/src/compiler/source.test.ts +191 -183
  115. package/src/compiler/source.ts +106 -79
  116. package/src/compiler/template.test.ts +50 -49
  117. package/src/compiler/template.ts +11 -21
  118. package/src/compiler/test.artifacts.ts +47 -47
  119. package/src/compiler/util.ts +17 -17
  120. package/src/index.ts +10 -10
  121. package/src/shared/basecmd.ts +16 -16
  122. package/src/shared/dump.ts +49 -70
  123. package/src/shared/proc.ts +8 -8
@@ -1,4 +1,4 @@
1
- import type { FullArtifactName } from './package';
1
+ import type { FullArtifactName } from "./package";
2
2
 
3
3
  export interface TestArtifactSource {
4
4
  fullName: FullArtifactName;
@@ -32,10 +32,10 @@ export interface TestArtifactSource {
32
32
  */
33
33
 
34
34
  export const testLocalLib1Name: FullArtifactName = {
35
- type: 'library',
36
- pkg: 'current-package',
37
- id: 'local-library-1',
38
- version: '1.2.3',
35
+ type: "library",
36
+ pkg: "current-package",
37
+ id: "local-library-1",
38
+ version: "1.2.3",
39
39
  };
40
40
  export const testLocalLib1Src = `
41
41
  otherLib := import("package1:other-lib-2" )
@@ -73,10 +73,10 @@ export {
73
73
  `;
74
74
 
75
75
  export const testLocalLib2Name: FullArtifactName = {
76
- type: 'library',
77
- pkg: 'current-package',
78
- id: 'local-library-2',
79
- version: '2.3.4',
76
+ type: "library",
77
+ pkg: "current-package",
78
+ id: "local-library-2",
79
+ version: "2.3.4",
80
80
  };
81
81
  export const testLocalLib2Src = `
82
82
  otherLib := import("package1:someid")
@@ -116,10 +116,10 @@ export {
116
116
  `;
117
117
 
118
118
  export const testLocalLib3Name: FullArtifactName = {
119
- type: 'library',
120
- pkg: 'current-package',
121
- id: 'local-library-3',
122
- version: '6.6.6',
119
+ type: "library",
120
+ pkg: "current-package",
121
+ id: "local-library-3",
122
+ version: "6.6.6",
123
123
  };
124
124
  export const testLocalLib3Src = `
125
125
  export {
@@ -128,10 +128,10 @@ export {
128
128
  `;
129
129
 
130
130
  export const testLocalTpl1Name: FullArtifactName = {
131
- type: 'template',
132
- pkg: 'current-package',
133
- id: 'local-template-1',
134
- version: '1.2.3',
131
+ type: "template",
132
+ pkg: "current-package",
133
+ id: "local-template-1",
134
+ version: "1.2.3",
135
135
  };
136
136
  export const testLocalTpl1Src = `
137
137
  lib1 := import( ":local-library-1")
@@ -142,10 +142,10 @@ tpl2 := plapi.getTemplateId("current-package:local-template-1" )
142
142
  `;
143
143
 
144
144
  export const testLocalTpl2Name: FullArtifactName = {
145
- type: 'template',
146
- pkg: 'current-package',
147
- id: 'local-template-2',
148
- version: '1.2.3',
145
+ type: "template",
146
+ pkg: "current-package",
147
+ id: "local-template-2",
148
+ version: "1.2.3",
149
149
  };
150
150
  export const testLocalTpl2Src = `
151
151
  lib := import("package1:other-lib-1")
@@ -155,10 +155,10 @@ lib := import("package1:other-lib-1")
155
155
  `;
156
156
 
157
157
  export const testLocalTpl3Name: FullArtifactName = {
158
- type: 'template',
159
- pkg: 'current-package',
160
- id: 'local-template-3',
161
- version: '1.2.3',
158
+ type: "template",
159
+ pkg: "current-package",
160
+ id: "local-template-3",
161
+ version: "1.2.3",
162
162
  };
163
163
 
164
164
  export const testLocalTpl3Src = `
@@ -203,10 +203,10 @@ export const testLocalTpl3: TestArtifactSource = {
203
203
  export const testLocalPackage = [testLocalTpl1, testLocalLib1, testLocalTpl2];
204
204
 
205
205
  export const testPackage1Lib1Name: FullArtifactName = {
206
- type: 'library',
207
- pkg: 'package1',
208
- id: 'other-lib-1',
209
- version: '1.2.3',
206
+ type: "library",
207
+ pkg: "package1",
208
+ id: "other-lib-1",
209
+ version: "1.2.3",
210
210
  };
211
211
  export const testPackage1Lib1Src = `
212
212
  export {
@@ -215,30 +215,30 @@ export {
215
215
  `;
216
216
 
217
217
  export const testPackage1Soft1Name: FullArtifactName = {
218
- type: 'software',
219
- pkg: 'current-package',
220
- id: 'software-1',
221
- version: '1.2.3',
218
+ type: "software",
219
+ pkg: "current-package",
220
+ id: "software-1",
221
+ version: "1.2.3",
222
222
  };
223
223
  export const testPackage1Soft1Src = `
224
224
  some software contents. Template builder should pass it 'as-is'
225
225
  `;
226
226
 
227
227
  export const testPackage1Asset1Name: FullArtifactName = {
228
- type: 'asset',
229
- pkg: 'current-package',
230
- id: 'asset-1',
231
- version: '1.2.3',
228
+ type: "asset",
229
+ pkg: "current-package",
230
+ id: "asset-1",
231
+ version: "1.2.3",
232
232
  };
233
233
  export const testPackage1Asset1Src = `
234
234
  some asset contents. Template builder should pass it 'as-is'
235
235
  `;
236
236
 
237
237
  export const testPackage1Lib2Name: FullArtifactName = {
238
- type: 'library',
239
- pkg: 'package1',
240
- id: 'other-lib-2',
241
- version: '1.2.3',
238
+ type: "library",
239
+ pkg: "package1",
240
+ id: "other-lib-2",
241
+ version: "1.2.3",
242
242
  };
243
243
  export const testPackage1Lib2Src = `
244
244
  lib := import("package1:other-lib-1")
@@ -249,17 +249,17 @@ export {
249
249
  `;
250
250
 
251
251
  export const testPackage1Tpl3Name: FullArtifactName = {
252
- type: 'template',
253
- pkg: 'package1',
254
- id: 'template-3',
255
- version: '1.2.3',
252
+ type: "template",
253
+ pkg: "package1",
254
+ id: "template-3",
255
+ version: "1.2.3",
256
256
  };
257
257
  export const testPackage1Tpl3Src = `
258
258
  lib := import("package1:other-lib-1")
259
259
  `;
260
260
 
261
- export const testPackage1Tpl3CompiledBase64
262
- = 'H4sIAAAAAAAAE22PQQqDMBREr/KZVQsxELsL9CZ/E+VjQ2MiJpUWyd2LglCo2xlm3syK4LsMu2Jy/dMNYmwqD5mb4LvGbHp0o8Ce2wp57mHBUd5TmgutHImIGDmNwrDEWFx4iWFwrByhsMicfYqwMLrVN9Sq/hhFxim4Is3tBxF8R3fy4wa68OkgxnVnHPntWFUon2mvD7pIHFJz2HppzwZ9AanB7OAUAQAA';
261
+ export const testPackage1Tpl3CompiledBase64 =
262
+ "H4sIAAAAAAAAE22PQQqDMBREr/KZVQsxELsL9CZ/E+VjQ2MiJpUWyd2LglCo2xlm3syK4LsMu2Jy/dMNYmwqD5mb4LvGbHp0o8Ce2wp57mHBUd5TmgutHImIGDmNwrDEWFx4iWFwrByhsMicfYqwMLrVN9Sq/hhFxim4Is3tBxF8R3fy4wa68OkgxnVnHPntWFUon2mvD7pIHFJz2HppzwZ9AanB7OAUAQAA";
263
263
 
264
264
  export const testPackage1Lib1: TestArtifactSource = {
265
265
  fullName: testPackage1Lib1Name,
@@ -1,25 +1,25 @@
1
- import * as fs from 'node:fs';
2
- import * as path from 'node:path';
3
- import * as winston from 'winston';
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import * as winston from "winston";
4
4
 
5
5
  export function assertNever(x: never): never {
6
6
  // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
7
- throw new Error('Unexpected object: ' + x);
7
+ throw new Error("Unexpected object: " + x);
8
8
  }
9
9
 
10
- export function createLogger(level: string = 'debug'): winston.Logger {
10
+ export function createLogger(level: string = "debug"): winston.Logger {
11
11
  return winston.createLogger({
12
12
  level: level,
13
13
  format: winston.format.combine(
14
14
  winston.format.errors({ stack: true }),
15
15
  winston.format.printf(({ level, message, stack }) => {
16
- const baseMessage = `${level.padStart(6, ' ')}: ${message as string}`;
16
+ const baseMessage = `${level.padStart(6, " ")}: ${message as string}`;
17
17
  return stack ? `${baseMessage}\n${stack as string}` : baseMessage;
18
18
  }),
19
19
  ),
20
20
  transports: [
21
21
  new winston.transports.Console({
22
- stderrLevels: ['error', 'warn', 'info', 'debug'],
22
+ stderrLevels: ["error", "warn", "info", "debug"],
23
23
  handleExceptions: true,
24
24
  }),
25
25
  ],
@@ -30,32 +30,32 @@ export function findNodeModules(): string {
30
30
  let currentDir = process.cwd();
31
31
 
32
32
  while (currentDir) {
33
- const possibleNodeModulesPath = path.join(currentDir, 'node_modules');
33
+ const possibleNodeModulesPath = path.join(currentDir, "node_modules");
34
34
 
35
35
  if (fs.existsSync(possibleNodeModulesPath)) return possibleNodeModulesPath;
36
36
 
37
- const parentDir = path.resolve(currentDir, '..');
37
+ const parentDir = path.resolve(currentDir, "..");
38
38
  if (parentDir === currentDir) break; // reached the root directory
39
39
 
40
40
  currentDir = parentDir;
41
41
  }
42
42
 
43
- throw new Error('Unable to find node_modules directory.');
43
+ throw new Error("Unable to find node_modules directory.");
44
44
  }
45
45
 
46
- export type PathType = 'absent' | 'file' | 'dir' | 'link' | 'unknown';
46
+ export type PathType = "absent" | "file" | "dir" | "link" | "unknown";
47
47
 
48
48
  export function pathType(path: string): PathType {
49
49
  try {
50
50
  const s = fs.statSync(path);
51
- if (s.isDirectory()) return 'dir';
52
- if (s.isFile()) return 'file';
53
- if (s.isSymbolicLink()) return 'link';
54
- return 'unknown';
51
+ if (s.isDirectory()) return "dir";
52
+ if (s.isFile()) return "file";
53
+ if (s.isSymbolicLink()) return "link";
54
+ return "unknown";
55
55
  } catch (error: unknown) {
56
56
  const err = error as NodeJS.ErrnoException;
57
- if (err.code == 'ENOENT') return 'absent';
58
- if (err.code == 'ENOTDIR') return 'absent';
57
+ if (err.code == "ENOENT") return "absent";
58
+ if (err.code == "ENOTDIR") return "absent";
59
59
  else throw err;
60
60
  }
61
61
  }
package/src/index.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  // DO NOT EDIT. This file was generated by oclif-index utility.
2
2
 
3
- import Cmd0 from './commands/build';
4
- import Cmd1 from './commands/check';
5
- import Cmd2 from './commands/test';
6
- import Cmd3 from './commands/dump/artifacts';
7
- import Cmd4 from './commands/dump/software';
3
+ import Cmd0 from "./commands/build";
4
+ import Cmd1 from "./commands/check";
5
+ import Cmd2 from "./commands/test";
6
+ import Cmd3 from "./commands/dump/artifacts";
7
+ import Cmd4 from "./commands/dump/software";
8
8
 
9
9
  export const COMMANDS = {
10
- 'build': Cmd0,
11
- 'check': Cmd1,
12
- 'test': Cmd2,
13
- 'dump:artifacts': Cmd3,
14
- 'dump:software': Cmd4,
10
+ build: Cmd0,
11
+ check: Cmd1,
12
+ test: Cmd2,
13
+ "dump:artifacts": Cmd3,
14
+ "dump:software": Cmd4,
15
15
  };
@@ -1,37 +1,37 @@
1
- import { Flags } from '@oclif/core';
1
+ import { Flags } from "@oclif/core";
2
2
 
3
3
  export const GlobalFlags = {
4
- 'log-level': Flags.string({
5
- description: 'logging level',
6
- default: 'info',
7
- options: ['error', 'warn', 'info', 'debug'],
4
+ "log-level": Flags.string({
5
+ description: "logging level",
6
+ default: "info",
7
+ options: ["error", "warn", "info", "debug"],
8
8
  }),
9
9
  };
10
10
 
11
11
  export const CtagsFlags = {
12
- 'generate-tags': Flags.boolean({
13
- description: 'generate tags, default false',
12
+ "generate-tags": Flags.boolean({
13
+ description: "generate tags, default false",
14
14
  default: false,
15
15
  }),
16
16
 
17
- 'tags-file': Flags.file({
17
+ "tags-file": Flags.file({
18
18
  description: 'where to put ".tags" file, it should be a root of VS Code project',
19
- default: '../../.tags', // usually a user opens a directory with all blocks
19
+ default: "../../.tags", // usually a user opens a directory with all blocks
20
20
  }),
21
21
 
22
- 'tags-additional-args': Flags.string({
23
- description: 'additional flags for universal-ctags command: e.g. -e for emacs',
22
+ "tags-additional-args": Flags.string({
23
+ description: "additional flags for universal-ctags command: e.g. -e for emacs",
24
24
  default: [],
25
25
  multiple: true,
26
- delimiter: ',',
26
+ delimiter: ",",
27
27
  }),
28
28
  };
29
29
 
30
30
  export const ArtifactTypeFlag = {
31
31
  type: Flags.string({
32
- aliases: ['t'],
33
- description: 'artifact type',
34
- options: ['all', 'library', 'template', 'test', 'software', 'asset'],
35
- default: 'all',
32
+ aliases: ["t"],
33
+ description: "artifact type",
34
+ options: ["all", "library", "template", "test", "software", "asset"],
35
+ default: "all",
36
36
  }),
37
37
  };
@@ -1,8 +1,8 @@
1
- import type winston from 'winston';
2
- import { getPackageInfo, newCompiler, compile, parseSources } from '../compiler/main';
3
- import type { ArtifactType } from '../compiler/package';
4
- import { typedArtifactNameToString } from '../compiler/package';
5
- import type { TemplateDataV3 } from '@milaboratories/pl-model-backend';
1
+ import type winston from "winston";
2
+ import { getPackageInfo, newCompiler, compile, parseSources } from "../compiler/main";
3
+ import type { ArtifactType } from "../compiler/package";
4
+ import { typedArtifactNameToString } from "../compiler/package";
5
+ import type { TemplateDataV3 } from "@milaboratories/pl-model-backend";
6
6
 
7
7
  export function dumpArtifacts(
8
8
  logger: winston.Logger,
@@ -11,9 +11,9 @@ export function dumpArtifacts(
11
11
  ): void {
12
12
  const packageInfo = getPackageInfo(process.cwd(), logger);
13
13
 
14
- const sources = parseSources(logger, packageInfo, 'dist', 'src', '');
14
+ const sources = parseSources(logger, packageInfo, "dist", "src", "");
15
15
 
16
- const compiler = newCompiler(logger, packageInfo, 'dist');
16
+ const compiler = newCompiler(logger, packageInfo, "dist");
17
17
 
18
18
  // group output by type:
19
19
  // - all libs
@@ -24,97 +24,79 @@ export function dumpArtifacts(
24
24
 
25
25
  // Libs
26
26
 
27
- if (!aType || aType === 'library') {
27
+ if (!aType || aType === "library") {
28
28
  for (const lib of compiler.allLibs()) {
29
- logger.debug(
30
- `Dumping to pl-tester: ${typedArtifactNameToString(lib.fullName)}`,
31
- );
32
- stream.write(JSON.stringify(lib) + '\n');
29
+ logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(lib.fullName)}`);
30
+ stream.write(JSON.stringify(lib) + "\n");
33
31
  }
34
32
 
35
33
  for (const src of sources) {
36
- if (src.fullName.type === 'library') {
37
- logger.debug(
38
- `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`,
39
- );
40
- stream.write(JSON.stringify(src) + '\n');
34
+ if (src.fullName.type === "library") {
35
+ logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);
36
+ stream.write(JSON.stringify(src) + "\n");
41
37
  }
42
38
  }
43
39
  }
44
40
 
45
41
  // Templates
46
42
 
47
- if (!aType || aType === 'template') {
43
+ if (!aType || aType === "template") {
48
44
  for (const tpl of compiler.allTemplates()) {
49
- logger.debug(
50
- `Dumping to pl-tester: ${typedArtifactNameToString(tpl.fullName)}`,
51
- );
52
- stream.write(JSON.stringify(tpl) + '\n');
45
+ logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(tpl.fullName)}`);
46
+ stream.write(JSON.stringify(tpl) + "\n");
53
47
  }
54
48
 
55
49
  for (const src of sources) {
56
- if (src.fullName.type === 'template') {
50
+ if (src.fullName.type === "template") {
57
51
  logger.debug(
58
- `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)} ${
59
- src.srcName
60
- }`,
52
+ `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)} ${src.srcName}`,
61
53
  );
62
- stream.write(JSON.stringify(src) + '\n');
54
+ stream.write(JSON.stringify(src) + "\n");
63
55
  }
64
56
  }
65
57
  }
66
58
 
67
59
  // Software
68
60
 
69
- if (!aType || aType === 'software') {
61
+ if (!aType || aType === "software") {
70
62
  for (const sw of compiler.allSoftware()) {
71
- logger.debug(
72
- `Dumping to pl-tester: ${typedArtifactNameToString(sw.fullName)}`,
73
- );
74
- stream.write(JSON.stringify(sw) + '\n');
63
+ logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(sw.fullName)}`);
64
+ stream.write(JSON.stringify(sw) + "\n");
75
65
  }
76
66
 
77
67
  for (const src of sources) {
78
- if (src.fullName.type === 'software') {
79
- logger.debug(
80
- `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`,
81
- );
82
- stream.write(JSON.stringify(src) + '\n');
68
+ if (src.fullName.type === "software") {
69
+ logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);
70
+ stream.write(JSON.stringify(src) + "\n");
83
71
  }
84
72
  }
85
73
  }
86
74
 
87
75
  // Assets
88
76
 
89
- if (!aType || aType === 'asset') {
77
+ if (!aType || aType === "asset") {
90
78
  for (const asset of compiler.allAssets()) {
91
- logger.debug(
92
- `Dumping to pl-tester: ${typedArtifactNameToString(asset.fullName)}`,
93
- );
94
- stream.write(JSON.stringify(asset) + '\n');
79
+ logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(asset.fullName)}`);
80
+ stream.write(JSON.stringify(asset) + "\n");
95
81
  }
96
82
 
97
83
  for (const src of sources) {
98
- if (src.fullName.type === 'asset') {
99
- logger.debug(
100
- `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`,
101
- );
102
- stream.write(JSON.stringify(src) + '\n');
84
+ if (src.fullName.type === "asset") {
85
+ logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);
86
+ stream.write(JSON.stringify(src) + "\n");
103
87
  }
104
88
  }
105
89
  }
106
90
 
107
91
  // Tests
108
92
 
109
- if (!aType || aType === 'test') {
93
+ if (!aType || aType === "test") {
110
94
  for (const src of sources) {
111
- if (src.fullName.type === 'test') {
95
+ if (src.fullName.type === "test") {
112
96
  logger.debug(
113
- `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)} ${
114
- src.srcName
115
- }`,
97
+ `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)} ${src.srcName}`,
116
98
  );
117
- stream.write(JSON.stringify(src) + '\n');
99
+ stream.write(JSON.stringify(src) + "\n");
118
100
  }
119
101
  }
120
102
  }
@@ -127,54 +109,51 @@ export function dumpLibs(
127
109
  ): void {
128
110
  const packageInfo = getPackageInfo(process.cwd(), logger);
129
111
 
130
- const sources = parseSources(logger, packageInfo, 'dist', 'src', '');
112
+ const sources = parseSources(logger, packageInfo, "dist", "src", "");
131
113
 
132
114
  if (!recursive) {
133
115
  for (const src of sources) {
134
- if (src.fullName.type === 'library') {
135
- stream.write(JSON.stringify(src) + '\n');
116
+ if (src.fullName.type === "library") {
117
+ stream.write(JSON.stringify(src) + "\n");
136
118
  }
137
119
  }
138
120
 
139
121
  return;
140
122
  }
141
123
 
142
- const compiler = newCompiler(logger, packageInfo, 'dist');
124
+ const compiler = newCompiler(logger, packageInfo, "dist");
143
125
  for (const src of sources) {
144
- if (src.fullName.type === 'library') {
126
+ if (src.fullName.type === "library") {
145
127
  compiler.addLib(src);
146
128
  }
147
129
  }
148
130
 
149
131
  for (const lib of compiler.allLibs()) {
150
- stream.write(JSON.stringify(lib) + '\n');
132
+ stream.write(JSON.stringify(lib) + "\n");
151
133
  }
152
134
  }
153
135
 
154
- export function dumpSoftware(
155
- logger: winston.Logger,
156
- stream: NodeJS.WritableStream,
157
- ): void {
136
+ export function dumpSoftware(logger: winston.Logger, stream: NodeJS.WritableStream): void {
158
137
  const packageInfo = getPackageInfo(process.cwd(), logger);
159
- const compiled = compile(logger, packageInfo, 'dist');
138
+ const compiled = compile(logger, packageInfo, "dist");
160
139
 
161
140
  const hashes = new Set<string>();
162
141
  const sourceMap = new Map<string, string>();
163
142
  for (const tpl of compiled.templates) {
164
143
  Object.entries(tpl.data.hashToSource).forEach(([hash, src]) => sourceMap.set(hash, src));
165
- getTemplateSoftware(stream, tpl.data.template).forEach((hash) => hashes.add(hash));
144
+ getTemplateSoftware(tpl.data.template).forEach((hash) => hashes.add(hash));
166
145
  }
167
146
 
168
147
  for (const hash of hashes) {
169
148
  const src = sourceMap.get(hash);
170
149
  if (src) {
171
- if (Object.hasOwn(JSON.parse(src) as object, 'asset')) {
150
+ if (Object.hasOwn(JSON.parse(src) as object, "asset")) {
172
151
  // Skip assets. They are kept in templates software because of backward compatibility with backend.
173
152
  continue;
174
153
  }
175
154
  stream.write(src);
176
- if (!src.endsWith('\n')) {
177
- stream.write('\n');
155
+ if (!src.endsWith("\n")) {
156
+ stream.write("\n");
178
157
  }
179
158
  } else {
180
159
  throw new Error(`Source not found for hash: ${hash}`);
@@ -182,13 +161,13 @@ export function dumpSoftware(
182
161
  }
183
162
  }
184
163
 
185
- function getTemplateSoftware(stream: NodeJS.WritableStream, tpl: TemplateDataV3): Set<string> {
164
+ function getTemplateSoftware(tpl: TemplateDataV3): Set<string> {
186
165
  const hashes = new Set<string>();
187
166
  for (const sw of Object.values(tpl.software)) {
188
167
  hashes.add(sw.sourceHash);
189
168
  }
190
169
  for (const subTpl of Object.values(tpl.templates)) {
191
- getTemplateSoftware(stream, subTpl).forEach((hash) => hashes.add(hash));
170
+ getTemplateSoftware(subTpl).forEach((hash) => hashes.add(hash));
192
171
  }
193
172
 
194
173
  return new Set(hashes);
@@ -1,16 +1,16 @@
1
- import type { ChildProcess, ChildProcessByStdio } from 'node:child_process';
2
- import { spawn } from 'node:child_process';
3
- import type { Writable } from 'node:stream';
1
+ import type { ChildProcess, ChildProcessByStdio } from "node:child_process";
2
+ import { spawn } from "node:child_process";
3
+ import type { Writable } from "node:stream";
4
4
 
5
5
  export function spawnEmbed(
6
6
  cmd: string,
7
7
  ...args: string[]
8
8
  ): ChildProcessByStdio<Writable, null, null> {
9
- const p = spawn(cmd, args, { stdio: ['pipe', 'inherit', 'inherit'] });
9
+ const p = spawn(cmd, args, { stdio: ["pipe", "inherit", "inherit"] });
10
10
 
11
- p.stdin.on('error', (err: Error) => {
11
+ p.stdin.on("error", (err: Error) => {
12
12
  const systemError = err as NodeJS.ErrnoException;
13
- if (systemError.code === 'EPIPE') {
13
+ if (systemError.code === "EPIPE") {
14
14
  // ignore EPIPE error as it stands for broken command run.
15
15
  // The command will write normal problem description by itself.
16
16
  }
@@ -21,10 +21,10 @@ export function spawnEmbed(
21
21
 
22
22
  export function waitFor(p: ChildProcess): Promise<number> {
23
23
  return new Promise((resolve, reject) => {
24
- p.on('close', (code: number) => {
24
+ p.on("close", (code: number) => {
25
25
  resolve(code);
26
26
  });
27
- p.on('error', (err) => {
27
+ p.on("error", (err) => {
28
28
  reject(err);
29
29
  });
30
30
  });