@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,16 +1,15 @@
1
- import { Command } from '@oclif/core';
2
- import { createLogger } from '../../compiler/util';
3
- import { dumpArtifacts } from '../../shared/dump';
4
- import { stdout } from 'node:process';
5
- import type { ArtifactType } from '../../compiler/package';
6
- import * as opts from '../../shared/basecmd';
1
+ import { Command } from "@oclif/core";
2
+ import { createLogger } from "../../compiler/util";
3
+ import { dumpArtifacts } from "../../shared/dump";
4
+ import { stdout } from "node:process";
5
+ import type { ArtifactType } from "../../compiler/package";
6
+ import * as opts from "../../shared/basecmd";
7
7
 
8
8
  export default class DumpArtifacts extends Command {
9
- static override description = 'parse sources in current package and dump all found artifacts to stdout';
9
+ static override description =
10
+ "parse sources in current package and dump all found artifacts to stdout";
10
11
 
11
- static override examples = [
12
- '<%= config.bin %> <%= command.id %>',
13
- ];
12
+ static override examples = ["<%= config.bin %> <%= command.id %>"];
14
13
 
15
14
  static override flags = {
16
15
  ...opts.GlobalFlags,
@@ -19,10 +18,7 @@ export default class DumpArtifacts extends Command {
19
18
 
20
19
  public async run(): Promise<void> {
21
20
  const { flags } = await this.parse(DumpArtifacts);
22
- const logger = createLogger(flags['log-level']);
23
- dumpArtifacts(
24
- logger, stdout,
25
- flags.type == 'all' ? undefined : flags.type as ArtifactType,
26
- );
21
+ const logger = createLogger(flags["log-level"]);
22
+ dumpArtifacts(logger, stdout, flags.type == "all" ? undefined : (flags.type as ArtifactType));
27
23
  }
28
24
  }
@@ -1,15 +1,14 @@
1
- import { Command } from '@oclif/core';
2
- import { createLogger } from '../../compiler/util';
3
- import { dumpSoftware } from '../../shared/dump';
4
- import { stdout } from 'node:process';
5
- import * as opts from '../../shared/basecmd';
1
+ import { Command } from "@oclif/core";
2
+ import { createLogger } from "../../compiler/util";
3
+ import { dumpSoftware } from "../../shared/dump";
4
+ import { stdout } from "node:process";
5
+ import * as opts from "../../shared/basecmd";
6
6
 
7
7
  export default class DumpSoftware extends Command {
8
- static override description = 'parse sources in current package and dump all software descriptors used by templates';
8
+ static override description =
9
+ "parse sources in current package and dump all software descriptors used by templates";
9
10
 
10
- static override examples = [
11
- '<%= config.bin %> <%= command.id %>',
12
- ];
11
+ static override examples = ["<%= config.bin %> <%= command.id %>"];
13
12
 
14
13
  static override flags = {
15
14
  ...opts.GlobalFlags,
@@ -17,7 +16,7 @@ export default class DumpSoftware extends Command {
17
16
 
18
17
  public async run(): Promise<void> {
19
18
  const { flags } = await this.parse(DumpSoftware);
20
- const logger = createLogger(flags['log-level']);
19
+ const logger = createLogger(flags["log-level"]);
21
20
  dumpSoftware(logger, stdout);
22
21
  }
23
22
  }
@@ -1,29 +1,32 @@
1
- import { Command } from '@oclif/core';
2
- import { createLogger } from '../compiler/util';
3
- import { dumpArtifacts } from '../shared/dump';
4
- import { GlobalFlags } from '../shared/basecmd';
5
- import { spawnEmbed, waitFor } from '../shared/proc';
6
- import { TengoTesterBinaryPath } from '@milaboratories/tengo-tester';
1
+ import { Command } from "@oclif/core";
2
+ import { createLogger } from "../compiler/util";
3
+ import { dumpArtifacts } from "../shared/dump";
4
+ import { GlobalFlags } from "../shared/basecmd";
5
+ import { spawnEmbed, waitFor } from "../shared/proc";
6
+ import { TengoTesterBinaryPath } from "@milaboratories/tengo-tester";
7
7
 
8
8
  export default class Test extends Command {
9
- static override description = 'run tengo unit tests (.test.tengo)';
9
+ static override description = "run tengo unit tests (.test.tengo)";
10
10
 
11
11
  static strict = false;
12
12
 
13
13
  static override flags = { ...GlobalFlags };
14
14
 
15
- static override examples = ['<%= config.bin %> <%= command.id %>'];
15
+ static override examples = ["<%= config.bin %> <%= command.id %>"];
16
16
 
17
17
  public async run(): Promise<void> {
18
18
  const { flags } = await this.parse(Test);
19
- const logger = createLogger(flags['log-level']);
19
+ const logger = createLogger(flags["log-level"]);
20
20
 
21
- const testerArgs: string[] = this.argv.length == 0 ? ['./src'] : this.argv;
21
+ const testerArgs: string[] = this.argv.length == 0 ? ["./src"] : this.argv;
22
22
 
23
23
  const tester = spawnEmbed(
24
24
  TengoTesterBinaryPath,
25
- 'run', '--log-level', flags['log-level'],
26
- '--artifacts', '-',
25
+ "run",
26
+ "--log-level",
27
+ flags["log-level"],
28
+ "--artifacts",
29
+ "-",
27
30
  ...testerArgs,
28
31
  );
29
32
 
@@ -1,18 +1,16 @@
1
- import type { CompileMode, TypedArtifactName } from './package';
2
- import { artifactKey } from './package';
3
- import { assertNever } from './util';
1
+ import type { CompileMode, TypedArtifactName } from "./package";
2
+ import { artifactKey } from "./package";
3
+ import { assertNever } from "./util";
4
4
 
5
5
  export class ArtifactMap<T> {
6
6
  private readonly map = new Map<string, T>();
7
7
 
8
- constructor(private readonly nameExtractor: (obj: T) => TypedArtifactName) {
9
- }
8
+ constructor(private readonly nameExtractor: (obj: T) => TypedArtifactName) {}
10
9
 
11
10
  add(obj: T, replace: boolean = true): T | undefined {
12
11
  const key = artifactKey(this.nameExtractor(obj));
13
12
  const ret = this.map.get(key);
14
- if (ret && !replace)
15
- return ret;
13
+ if (ret && !replace) return ret;
16
14
  this.map.set(key, obj);
17
15
  return ret;
18
16
  }
@@ -51,7 +49,7 @@ export class ArtifactStore<T> {
51
49
 
52
50
  add(mode: CompileMode, obj: T, replace: boolean = true): T | undefined {
53
51
  switch (mode) {
54
- case 'dist':
52
+ case "dist":
55
53
  return this.dist.add(obj, replace);
56
54
 
57
55
  default:
@@ -61,7 +59,7 @@ export class ArtifactStore<T> {
61
59
 
62
60
  get(mode: CompileMode, name: TypedArtifactName): T | undefined {
63
61
  switch (mode) {
64
- case 'dist':
62
+ case "dist":
65
63
  return this.dist.get(name);
66
64
 
67
65
  default:
@@ -1,51 +1,51 @@
1
- import { TemplatesAndLibs, TengoTemplateCompiler } from './compiler';
2
- import { ArtifactSource, parseSource } from './source';
3
- import * as ta from './test.artifacts';
4
- import { artifactNameToString } from './package';
5
- import { createLogger } from './util';
6
- import { test, expect, describe, it } from 'vitest';
7
- import { MiLogger } from '@milaboratories/ts-helpers';
8
- import type { FullArtifactName, TypedArtifactName } from './package';
9
- import { TemplateDataV3, TemplateLibDataV3 } from '@milaboratories/pl-model-backend';
1
+ import { TemplatesAndLibs, TengoTemplateCompiler } from "./compiler";
2
+ import { ArtifactSource, parseSource } from "./source";
3
+ import * as ta from "./test.artifacts";
4
+ import { artifactNameToString } from "./package";
5
+ import { createLogger } from "./util";
6
+ import { test, expect, describe, it } from "vitest";
7
+ import { MiLogger } from "@milaboratories/ts-helpers";
8
+ import type { FullArtifactName, TypedArtifactName } from "./package";
9
+ import { TemplateDataV3, TemplateLibDataV3 } from "@milaboratories/pl-model-backend";
10
10
 
11
11
  function parseSrc(logger: MiLogger, src: ta.TestArtifactSource[]): ArtifactSource[] {
12
12
  return src.map((tp) => {
13
- const aSrc = parseSource(logger, 'dist', tp.src, tp.fullName, true);
13
+ const aSrc = parseSource(logger, "dist", tp.src, tp.fullName, true);
14
14
  return aSrc;
15
15
  });
16
16
  }
17
17
 
18
- test('compile package 1', () => {
19
- const logger = createLogger('error');
18
+ test("compile package 1", () => {
19
+ const logger = createLogger("error");
20
20
 
21
- const compiler = new TengoTemplateCompiler('dist');
21
+ const compiler = new TengoTemplateCompiler("dist");
22
22
  const compiled = compiler.compileAndAdd(parseSrc(logger, ta.testPackage1));
23
23
 
24
24
  expect(compiled.templates[0]).toMatchObject({
25
25
  data: {
26
- type: 'pl.tengo-template.v3',
26
+ type: "pl.tengo-template.v3",
27
27
  hashToSource: {
28
- '2e0d81deae0220df5901292911fd96065be96bc2187debb24bd869b47e1caa77': `
29
- lib := import(\"package1:other-lib-1\")
28
+ "2e0d81deae0220df5901292911fd96065be96bc2187debb24bd869b47e1caa77": `
29
+ lib := import("package1:other-lib-1")
30
30
  `,
31
- '3f850fa4c5f6a8a3017fa883fc03fc2dee159f65e2dbb9c6cd0c6dff0aae6419': `
31
+ "3f850fa4c5f6a8a3017fa883fc03fc2dee159f65e2dbb9c6cd0c6dff0aae6419": `
32
32
  export {
33
- \"some\": \"value1\"
33
+ "some": "value1"
34
34
  }
35
35
  `,
36
36
  },
37
37
  template: {
38
- name: 'package1:template-3',
39
- version: '1.2.3',
40
- sourceHash: '2e0d81deae0220df5901292911fd96065be96bc2187debb24bd869b47e1caa77',
38
+ name: "package1:template-3",
39
+ version: "1.2.3",
40
+ sourceHash: "2e0d81deae0220df5901292911fd96065be96bc2187debb24bd869b47e1caa77",
41
41
  templates: {},
42
42
  software: {},
43
43
  assets: {},
44
44
  libs: {
45
- 'package1:other-lib-1': {
46
- name: 'package1:other-lib-1',
47
- version: '1.2.3',
48
- sourceHash: '3f850fa4c5f6a8a3017fa883fc03fc2dee159f65e2dbb9c6cd0c6dff0aae6419',
45
+ "package1:other-lib-1": {
46
+ name: "package1:other-lib-1",
47
+ version: "1.2.3",
48
+ sourceHash: "3f850fa4c5f6a8a3017fa883fc03fc2dee159f65e2dbb9c6cd0c6dff0aae6419",
49
49
  },
50
50
  },
51
51
  },
@@ -54,19 +54,19 @@ export {
54
54
  });
55
55
 
56
56
  // FIXME: how to rewrite test to the new template version? It has a strange base64-encoded thing.
57
- test.skip('compile main source set', () => {
58
- const compiler = new TengoTemplateCompiler('dist');
59
- const logger = createLogger('error');
57
+ test.skip("compile main source set", () => {
58
+ const compiler = new TengoTemplateCompiler("dist");
59
+ const logger = createLogger("error");
60
60
 
61
61
  // emulate adding compiled artifacts
62
62
  compiler.addLib(
63
- parseSource(logger, 'dist', ta.testPackage1Lib1Src, ta.testPackage1Lib1Name, true)
63
+ parseSource(logger, "dist", ta.testPackage1Lib1Src, ta.testPackage1Lib1Name, true),
64
64
  );
65
65
  compiler.addLib(
66
- parseSource(logger, 'dist', ta.testPackage1Lib2Src, ta.testPackage1Lib2Name, true)
66
+ parseSource(logger, "dist", ta.testPackage1Lib2Src, ta.testPackage1Lib2Name, true),
67
67
  );
68
68
  compiler.addSoftware(
69
- parseSource(logger, 'dist', ta.testPackage1Soft1Src, ta.testPackage1Soft1Name, true)
69
+ parseSource(logger, "dist", ta.testPackage1Soft1Src, ta.testPackage1Soft1Name, true),
70
70
  );
71
71
 
72
72
  // FIXME: how to rewrite test to the new template?
@@ -85,145 +85,140 @@ test.skip('compile main source set', () => {
85
85
 
86
86
  // main package compilation
87
87
  const compiled = compiler.compileAndAdd(parseSrc(logger, ta.testLocalPackage));
88
- const tpl1 = compiled.templates.find((t) => t.fullName.id === 'local-template-1')!;
88
+ const tpl1 = compiled.templates.find((t) => t.fullName.id === "local-template-1")!;
89
89
  expect(tpl1).toBeDefined();
90
90
 
91
91
  // checking that transient library dependency was resolved
92
- expect(tpl1.data.template.templates).toHaveProperty('package1:template-3');
92
+ expect(tpl1.data.template.templates).toHaveProperty("package1:template-3");
93
93
  });
94
94
 
95
- test('compile template with hash override', () => {
96
- const compiler = new TengoTemplateCompiler('dist');
97
- const logger = createLogger('error');
95
+ test("compile template with hash override", () => {
96
+ const compiler = new TengoTemplateCompiler("dist");
97
+ const logger = createLogger("error");
98
98
 
99
99
  // main package compilation
100
100
  const compiled = compiler.compileAndAdd(parseSrc(logger, ta.testPackage2));
101
- const tpl3 = compiled.templates.find((t) => t.fullName.id === 'local-template-3')!;
102
- console.log('Tpl3: ' + JSON.stringify(tpl3));
101
+ const tpl3 = compiled.templates.find((t) => t.fullName.id === "local-template-3")!;
102
+ console.log("Tpl3: " + JSON.stringify(tpl3));
103
103
  expect(tpl3).toBeDefined();
104
104
 
105
105
  // checking that transient library dependency was resolved
106
- expect(tpl3.data.template.hashOverride).toEqual('CE0F6EDF-D97C-44E7-B16B-D661D4C799C1'.toLowerCase());
106
+ expect(tpl3.data.template.hashOverride).toEqual(
107
+ "CE0F6EDF-D97C-44E7-B16B-D661D4C799C1".toLowerCase(),
108
+ );
107
109
  expect(tpl3.data.template.libs[artifactNameToString(ta.testLocalLib3.fullName)]).toBeDefined();
108
110
  });
109
111
 
110
- test('wrong hash override value throws error', () => {
111
- const compiler = new TengoTemplateCompiler('dist');
112
- const logger = createLogger('error');
112
+ test("wrong hash override value throws error", () => {
113
+ const compiler = new TengoTemplateCompiler("dist");
114
+ const logger = createLogger("error");
113
115
 
114
- expect(() => compiler.compileAndAdd(parseSrc(logger, ta.testPackage2BrokenHash))).toThrow('must contain valid UUID as an override');
116
+ expect(() => compiler.compileAndAdd(parseSrc(logger, ta.testPackage2BrokenHash))).toThrow(
117
+ "must contain valid UUID as an override",
118
+ );
115
119
  });
116
120
 
117
121
  /** Functions for generating test data. */
118
122
 
119
- const genHash = (nameId: string) => nameId + '-hash';
120
- const genName = (nameId: string) => nameId + '-name';
123
+ const genHash = (nameId: string) => nameId + "-hash";
124
+ const genName = (nameId: string) => nameId + "-name";
121
125
  const genArtifactName = artifactNameToString;
122
126
 
123
- const genArtifactSource = (name: FullArtifactName, src: string, dependencies: TypedArtifactName[]) =>
124
- new ArtifactSource('dist', name, genHash(name.id), src, genName(name.id), dependencies, []);
127
+ const genArtifactSource = (
128
+ name: FullArtifactName,
129
+ src: string,
130
+ dependencies: TypedArtifactName[],
131
+ ) => new ArtifactSource("dist", name, genHash(name.id), src, genName(name.id), dependencies, []);
125
132
 
126
- const genTemplateData = (name: FullArtifactName, templates: TemplateDataV3[], libs: TemplateLibDataV3[]) => (
127
- {
128
- name: genArtifactName(name),
129
- version: name.version,
130
- sourceHash: genHash(name.id),
131
- templates: Object.fromEntries(templates.map(t => [t.name, t])),
132
- libs: Object.fromEntries(libs.map(l => [l.name, l])),
133
- software: {},
134
- assets: {},
135
- }
136
- );
133
+ const genTemplateData = (
134
+ name: FullArtifactName,
135
+ templates: TemplateDataV3[],
136
+ libs: TemplateLibDataV3[],
137
+ ) => ({
138
+ name: genArtifactName(name),
139
+ version: name.version,
140
+ sourceHash: genHash(name.id),
141
+ templates: Object.fromEntries(templates.map((t) => [t.name, t])),
142
+ libs: Object.fromEntries(libs.map((l) => [l.name, l])),
143
+ software: {},
144
+ assets: {},
145
+ });
137
146
 
138
- const genLibData = (name: FullArtifactName) => (
139
- {
140
- name: genArtifactName(name),
141
- version: name.version,
142
- sourceHash: genHash(name.id),
143
- }
144
- );
147
+ const genLibData = (name: FullArtifactName) => ({
148
+ name: genArtifactName(name),
149
+ version: name.version,
150
+ sourceHash: genHash(name.id),
151
+ });
145
152
 
146
- describe('TengoTemplateCompiler.compileAndAdd', () => {
153
+ describe("TengoTemplateCompiler.compileAndAdd", () => {
147
154
  const testCases: {
148
155
  name: string;
149
156
  sources: ArtifactSource[];
150
157
  expected: TemplatesAndLibs;
151
158
  }[] = [
152
159
  {
153
- name: 'should process a single library and pass it as-is',
154
- sources: [
155
- genArtifactSource(ta.testLocalLib3Name, ta.testLocalLib3Src, []),
156
- ],
160
+ name: "should process a single library and pass it as-is",
161
+ sources: [genArtifactSource(ta.testLocalLib3Name, ta.testLocalLib3Src, [])],
157
162
  expected: {
158
- libs: [
159
- genArtifactSource(ta.testLocalLib3Name, ta.testLocalLib3Src, []),
160
- ],
163
+ libs: [genArtifactSource(ta.testLocalLib3Name, ta.testLocalLib3Src, [])],
161
164
  templates: [],
162
165
  software: [],
163
- assets: []
164
- }
166
+ assets: [],
167
+ },
165
168
  },
166
169
  {
167
- name: 'should process a single software and pass it as-is',
168
- sources: [
169
- genArtifactSource(ta.testPackage1Soft1Name, ta.testPackage1Soft1Src, []),
170
- ],
170
+ name: "should process a single software and pass it as-is",
171
+ sources: [genArtifactSource(ta.testPackage1Soft1Name, ta.testPackage1Soft1Src, [])],
171
172
  expected: {
172
173
  libs: [],
173
174
  templates: [],
174
- software: [
175
- genArtifactSource(ta.testPackage1Soft1Name, ta.testPackage1Soft1Src, []),
176
- ],
177
- assets: []
178
- }
175
+ software: [genArtifactSource(ta.testPackage1Soft1Name, ta.testPackage1Soft1Src, [])],
176
+ assets: [],
177
+ },
179
178
  },
180
179
  {
181
- name: 'should process a single asset and pass it as-is',
182
- sources: [
183
- genArtifactSource(ta.testPackage1Asset1Name, ta.testPackage1Asset1Src, []),
184
- ],
180
+ name: "should process a single asset and pass it as-is",
181
+ sources: [genArtifactSource(ta.testPackage1Asset1Name, ta.testPackage1Asset1Src, [])],
185
182
  expected: {
186
183
  libs: [],
187
184
  templates: [],
188
185
  software: [],
189
- assets: [
190
- genArtifactSource(ta.testPackage1Asset1Name, ta.testPackage1Asset1Src, []),
191
- ]
192
- }
186
+ assets: [genArtifactSource(ta.testPackage1Asset1Name, ta.testPackage1Asset1Src, [])],
187
+ },
193
188
  },
194
189
  {
195
- name: 'should process a template with 1 library dependency',
190
+ name: "should process a template with 1 library dependency",
196
191
  sources: [
197
192
  genArtifactSource(ta.testLocalTpl2Name, ta.testLocalTpl2Src, [ta.testLocalLib1Name]),
198
193
  genArtifactSource(ta.testLocalLib1Name, ta.testLocalLib1Src, []),
199
194
  ],
200
195
  expected: {
201
- libs: [
202
- genArtifactSource(ta.testLocalLib1Name, ta.testLocalLib1Src, []),
203
- ],
196
+ libs: [genArtifactSource(ta.testLocalLib1Name, ta.testLocalLib1Src, [])],
204
197
  templates: [
205
198
  {
206
- compileMode: 'dist',
199
+ compileMode: "dist",
207
200
  fullName: ta.testLocalTpl2Name,
208
201
  source: ta.testLocalTpl2Src,
209
202
  data: {
210
- type: 'pl.tengo-template.v3',
203
+ type: "pl.tengo-template.v3",
211
204
  hashToSource: {
212
205
  [genHash(ta.testLocalLib1Name.id)]: ta.testLocalLib1Src,
213
206
  [genHash(ta.testLocalTpl2Name.id)]: ta.testLocalTpl2Src,
214
207
  },
215
- template: genTemplateData(ta.testLocalTpl2Name, [], [
216
- genLibData(ta.testLocalLib1Name),
217
- ]),
208
+ template: genTemplateData(
209
+ ta.testLocalTpl2Name,
210
+ [],
211
+ [genLibData(ta.testLocalLib1Name)],
212
+ ),
218
213
  },
219
- }
214
+ },
220
215
  ],
221
216
  software: [],
222
- assets: []
223
- }
217
+ assets: [],
218
+ },
224
219
  },
225
220
  {
226
- name: 'should process a template with another template dependency',
221
+ name: "should process a template with another template dependency",
227
222
  sources: [
228
223
  genArtifactSource(ta.testLocalTpl1Name, ta.testLocalTpl1Src, [ta.testLocalTpl2Name]),
229
224
  genArtifactSource(ta.testLocalTpl2Name, ta.testLocalTpl2Src, []),
@@ -232,93 +227,95 @@ describe('TengoTemplateCompiler.compileAndAdd', () => {
232
227
  libs: [],
233
228
  templates: [
234
229
  {
235
- compileMode: 'dist',
230
+ compileMode: "dist",
236
231
  fullName: ta.testLocalTpl2Name,
237
232
  source: ta.testLocalTpl2Src,
238
233
  data: {
239
- type: 'pl.tengo-template.v3',
234
+ type: "pl.tengo-template.v3",
240
235
  hashToSource: {
241
236
  [genHash(ta.testLocalTpl2Name.id)]: ta.testLocalTpl2Src,
242
237
  },
243
238
  template: genTemplateData(ta.testLocalTpl2Name, [], []),
244
- }
239
+ },
245
240
  },
246
241
  {
247
- compileMode: 'dist',
242
+ compileMode: "dist",
248
243
  fullName: ta.testLocalTpl1Name,
249
244
  source: ta.testLocalTpl1Src,
250
245
  data: {
251
- type: 'pl.tengo-template.v3',
246
+ type: "pl.tengo-template.v3",
252
247
  hashToSource: {
253
248
  [genHash(ta.testLocalTpl1Name.id)]: ta.testLocalTpl1Src,
254
249
  [genHash(ta.testLocalTpl2Name.id)]: ta.testLocalTpl2Src,
255
250
  },
256
- template: genTemplateData(ta.testLocalTpl1Name, [
257
- genTemplateData(ta.testLocalTpl2Name, [], []),
258
- ], []),
251
+ template: genTemplateData(
252
+ ta.testLocalTpl1Name,
253
+ [genTemplateData(ta.testLocalTpl2Name, [], [])],
254
+ [],
255
+ ),
259
256
  },
260
257
  },
261
258
  ],
262
259
  software: [],
263
- assets: []
264
- }
260
+ assets: [],
261
+ },
265
262
  },
266
263
  {
267
- name: 'should process a template with another template dependency and a nested library dependency',
264
+ name: "should process a template with another template dependency and a nested library dependency",
268
265
  sources: [
269
266
  genArtifactSource(ta.testLocalTpl1Name, ta.testLocalTpl1Src, [ta.testLocalTpl2Name]),
270
267
  genArtifactSource(ta.testLocalTpl2Name, ta.testLocalTpl2Src, [ta.testLocalLib3Name]),
271
268
  genArtifactSource(ta.testLocalLib3Name, ta.testLocalLib3Src, []),
272
269
  ],
273
270
  expected: {
274
- libs: [
275
- genArtifactSource(ta.testLocalLib3Name, ta.testLocalLib3Src, []),
276
- ],
271
+ libs: [genArtifactSource(ta.testLocalLib3Name, ta.testLocalLib3Src, [])],
277
272
  templates: [
278
273
  {
279
- compileMode: 'dist',
274
+ compileMode: "dist",
280
275
  fullName: ta.testLocalTpl2Name,
281
276
  source: ta.testLocalTpl2Src,
282
277
  data: {
283
- type: 'pl.tengo-template.v3',
278
+ type: "pl.tengo-template.v3",
284
279
  hashToSource: {
285
280
  [genHash(ta.testLocalTpl2Name.id)]: ta.testLocalTpl2Src,
286
281
  [genHash(ta.testLocalLib3Name.id)]: ta.testLocalLib3Src,
287
282
  },
288
- template: genTemplateData(ta.testLocalTpl2Name, [], [
289
- genLibData(ta.testLocalLib3Name),
290
- ]),
283
+ template: genTemplateData(
284
+ ta.testLocalTpl2Name,
285
+ [],
286
+ [genLibData(ta.testLocalLib3Name)],
287
+ ),
291
288
  },
292
289
  },
293
290
  {
294
- compileMode: 'dist',
291
+ compileMode: "dist",
295
292
  fullName: ta.testLocalTpl1Name,
296
293
  source: ta.testLocalTpl1Src,
297
294
  data: {
298
- type: 'pl.tengo-template.v3',
295
+ type: "pl.tengo-template.v3",
299
296
  hashToSource: {
300
297
  [genHash(ta.testLocalTpl1Name.id)]: ta.testLocalTpl1Src,
301
298
  [genHash(ta.testLocalTpl2Name.id)]: ta.testLocalTpl2Src,
302
299
  [genHash(ta.testLocalLib3Name.id)]: ta.testLocalLib3Src,
303
300
  },
304
- template: genTemplateData(ta.testLocalTpl1Name, [
305
- genTemplateData(ta.testLocalTpl2Name, [], [
306
- genLibData(ta.testLocalLib3Name),
307
- ]),
308
- ], []),
301
+ template: genTemplateData(
302
+ ta.testLocalTpl1Name,
303
+ [genTemplateData(ta.testLocalTpl2Name, [], [genLibData(ta.testLocalLib3Name)])],
304
+ [],
305
+ ),
309
306
  },
310
307
  },
311
308
  ],
312
309
  software: [],
313
- assets: []
314
- }
310
+ assets: [],
311
+ },
315
312
  },
316
313
  ];
317
314
 
318
315
  // Execute all test cases
319
- testCases.forEach(tc => {
316
+ testCases.forEach((tc) => {
320
317
  it(tc.name, () => {
321
- const compiler = new TengoTemplateCompiler('dist');
318
+ const compiler = new TengoTemplateCompiler("dist");
322
319
 
323
320
  const result = compiler.compileAndAdd(tc.sources);
324
321
 
@@ -326,8 +323,8 @@ describe('TengoTemplateCompiler.compileAndAdd', () => {
326
323
  });
327
324
  });
328
325
 
329
- it('should throw error for unresolvable dependencies', () => {
330
- const compiler = new TengoTemplateCompiler('dist');
326
+ it("should throw error for unresolvable dependencies", () => {
327
+ const compiler = new TengoTemplateCompiler("dist");
331
328
 
332
329
  const sources = [
333
330
  genArtifactSource(ta.testLocalTpl1Name, ta.testLocalTpl1Src, [ta.testLocalLib1Name]),