@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.
- package/README.md +4 -4
- package/bin/run.js +5 -5
- package/dist/commands/build.cjs +36 -36
- package/dist/commands/build.cjs.map +1 -1
- package/dist/commands/build.d.ts +5 -5
- package/dist/commands/build.js +36 -36
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/check.cjs +5 -5
- package/dist/commands/check.cjs.map +1 -1
- package/dist/commands/check.d.ts +2 -2
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +5 -5
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/dump/artifacts.cjs +4 -6
- package/dist/commands/dump/artifacts.cjs.map +1 -1
- package/dist/commands/dump/artifacts.d.ts +2 -2
- package/dist/commands/dump/artifacts.d.ts.map +1 -1
- package/dist/commands/dump/artifacts.js +4 -6
- package/dist/commands/dump/artifacts.js.map +1 -1
- package/dist/commands/dump/software.cjs +3 -5
- package/dist/commands/dump/software.cjs.map +1 -1
- package/dist/commands/dump/software.d.ts +2 -2
- package/dist/commands/dump/software.d.ts.map +1 -1
- package/dist/commands/dump/software.js +3 -5
- package/dist/commands/dump/software.js.map +1 -1
- package/dist/commands/test.cjs +5 -5
- package/dist/commands/test.cjs.map +1 -1
- package/dist/commands/test.d.ts +2 -2
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +5 -5
- package/dist/commands/test.js.map +1 -1
- package/dist/compiler/artifactset.cjs +2 -2
- package/dist/compiler/artifactset.cjs.map +1 -1
- package/dist/compiler/artifactset.d.ts +1 -1
- package/dist/compiler/artifactset.d.ts.map +1 -1
- package/dist/compiler/artifactset.js +2 -2
- package/dist/compiler/artifactset.js.map +1 -1
- package/dist/compiler/compiler.cjs +37 -34
- package/dist/compiler/compiler.cjs.map +1 -1
- package/dist/compiler/compiler.d.ts +3 -3
- package/dist/compiler/compiler.d.ts.map +1 -1
- package/dist/compiler/compiler.js +37 -34
- package/dist/compiler/compiler.js.map +1 -1
- package/dist/compiler/compileroptions.cjs +12 -12
- package/dist/compiler/compileroptions.cjs.map +1 -1
- package/dist/compiler/compileroptions.d.ts +2 -2
- package/dist/compiler/compileroptions.js +12 -12
- package/dist/compiler/compileroptions.js.map +1 -1
- package/dist/compiler/main.cjs +58 -58
- package/dist/compiler/main.cjs.map +1 -1
- package/dist/compiler/main.d.ts +6 -6
- package/dist/compiler/main.d.ts.map +1 -1
- package/dist/compiler/main.js +58 -58
- package/dist/compiler/main.js.map +1 -1
- package/dist/compiler/package.cjs +5 -2
- package/dist/compiler/package.cjs.map +1 -1
- package/dist/compiler/package.d.ts +6 -6
- package/dist/compiler/package.d.ts.map +1 -1
- package/dist/compiler/package.js +5 -2
- package/dist/compiler/package.js.map +1 -1
- package/dist/compiler/source.cjs +50 -52
- package/dist/compiler/source.cjs.map +1 -1
- package/dist/compiler/source.d.ts +2 -2
- package/dist/compiler/source.d.ts.map +1 -1
- package/dist/compiler/source.js +50 -52
- package/dist/compiler/source.js.map +1 -1
- package/dist/compiler/template.cjs +7 -7
- package/dist/compiler/template.cjs.map +1 -1
- package/dist/compiler/template.d.ts +2 -2
- package/dist/compiler/template.d.ts.map +1 -1
- package/dist/compiler/template.js +7 -7
- package/dist/compiler/template.js.map +1 -1
- package/dist/compiler/test.artifacts.d.ts +1 -1
- package/dist/compiler/test.artifacts.d.ts.map +1 -1
- package/dist/compiler/util.cjs +12 -12
- package/dist/compiler/util.cjs.map +1 -1
- package/dist/compiler/util.d.ts +2 -2
- package/dist/compiler/util.js +12 -12
- package/dist/compiler/util.js.map +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/shared/basecmd.cjs +15 -15
- package/dist/shared/basecmd.cjs.map +1 -1
- package/dist/shared/basecmd.d.ts +4 -4
- package/dist/shared/basecmd.js +15 -15
- package/dist/shared/basecmd.js.map +1 -1
- package/dist/shared/dump.cjs +28 -28
- package/dist/shared/dump.cjs.map +1 -1
- package/dist/shared/dump.d.ts +2 -2
- package/dist/shared/dump.d.ts.map +1 -1
- package/dist/shared/dump.js +28 -28
- package/dist/shared/dump.js.map +1 -1
- package/dist/shared/proc.cjs +5 -5
- package/dist/shared/proc.cjs.map +1 -1
- package/dist/shared/proc.d.ts +2 -2
- package/dist/shared/proc.js +5 -5
- package/dist/shared/proc.js.map +1 -1
- package/package.json +21 -19
- package/src/commands/build.ts +57 -55
- package/src/commands/check.ts +15 -12
- package/src/commands/dump/artifacts.ts +11 -15
- package/src/commands/dump/software.ts +9 -10
- package/src/commands/test.ts +15 -12
- package/src/compiler/artifactset.ts +7 -9
- package/src/compiler/compiler.test.ts +134 -137
- package/src/compiler/compiler.ts +62 -62
- package/src/compiler/compileroptions.ts +15 -15
- package/src/compiler/main.test.ts +23 -23
- package/src/compiler/main.ts +83 -100
- package/src/compiler/package.ts +14 -12
- package/src/compiler/source.test.ts +191 -183
- package/src/compiler/source.ts +106 -79
- package/src/compiler/template.test.ts +50 -49
- package/src/compiler/template.ts +11 -21
- package/src/compiler/test.artifacts.ts +47 -47
- package/src/compiler/util.ts +17 -17
- package/src/index.ts +10 -10
- package/src/shared/basecmd.ts +16 -16
- package/src/shared/dump.ts +49 -70
- package/src/shared/proc.ts +8 -8
|
@@ -7,18 +7,16 @@ var node_process = require('node:process');
|
|
|
7
7
|
var basecmd = require('../../shared/basecmd.cjs');
|
|
8
8
|
|
|
9
9
|
class DumpArtifacts extends core.Command {
|
|
10
|
-
static description =
|
|
11
|
-
static examples = [
|
|
12
|
-
'<%= config.bin %> <%= command.id %>',
|
|
13
|
-
];
|
|
10
|
+
static description = "parse sources in current package and dump all found artifacts to stdout";
|
|
11
|
+
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
14
12
|
static flags = {
|
|
15
13
|
...basecmd.GlobalFlags,
|
|
16
14
|
...basecmd.ArtifactTypeFlag,
|
|
17
15
|
};
|
|
18
16
|
async run() {
|
|
19
17
|
const { flags } = await this.parse(DumpArtifacts);
|
|
20
|
-
const logger = util.createLogger(flags[
|
|
21
|
-
dump.dumpArtifacts(logger, node_process.stdout, flags.type ==
|
|
18
|
+
const logger = util.createLogger(flags["log-level"]);
|
|
19
|
+
dump.dumpArtifacts(logger, node_process.stdout, flags.type == "all" ? undefined : flags.type);
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
22
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.cjs","sources":["../../../src/commands/dump/artifacts.ts"],"sourcesContent":["import { Command } from
|
|
1
|
+
{"version":3,"file":"artifacts.cjs","sources":["../../../src/commands/dump/artifacts.ts"],"sourcesContent":["import { Command } from \"@oclif/core\";\nimport { createLogger } from \"../../compiler/util\";\nimport { dumpArtifacts } from \"../../shared/dump\";\nimport { stdout } from \"node:process\";\nimport type { ArtifactType } from \"../../compiler/package\";\nimport * as opts from \"../../shared/basecmd\";\n\nexport default class DumpArtifacts extends Command {\n static override description =\n \"parse sources in current package and dump all found artifacts to stdout\";\n\n static override examples = [\"<%= config.bin %> <%= command.id %>\"];\n\n static override flags = {\n ...opts.GlobalFlags,\n ...opts.ArtifactTypeFlag,\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(DumpArtifacts);\n const logger = createLogger(flags[\"log-level\"]);\n dumpArtifacts(logger, stdout, flags.type == \"all\" ? undefined : (flags.type as ArtifactType));\n }\n}\n"],"names":["Command","opts.GlobalFlags","opts.ArtifactTypeFlag","createLogger","dumpArtifacts","stdout"],"mappings":";;;;;;;;AAOc,MAAO,aAAc,SAAQA,YAAO,CAAA;AAChD,IAAA,OAAgB,WAAW,GACzB,yEAAyE;AAE3E,IAAA,OAAgB,QAAQ,GAAG,CAAC,qCAAqC,CAAC;IAElE,OAAgB,KAAK,GAAG;QACtB,GAAGC,mBAAgB;QACnB,GAAGC,wBAAqB;KACzB;AAEM,IAAA,MAAM,GAAG,GAAA;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;QACjD,MAAM,MAAM,GAAGC,iBAAY,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC/CC,kBAAa,CAAC,MAAM,EAAEC,mBAAM,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK,GAAG,SAAS,GAAI,KAAK,CAAC,IAAqB,CAAC;IAC/F;;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Command } from
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
2
|
export default class DumpArtifacts extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
type: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
-
|
|
7
|
+
"log-level": import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
8
|
};
|
|
9
9
|
run(): Promise<void>;
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../../../src/commands/dump/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAOtC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAChD,OAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../../../src/commands/dump/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAOtC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAChD,OAAgB,WAAW,SACiD;IAE5E,OAAgB,QAAQ,WAA2C;IAEnE,OAAgB,KAAK;;;MAGnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAKlC"}
|
|
@@ -5,18 +5,16 @@ import { stdout } from 'node:process';
|
|
|
5
5
|
import { ArtifactTypeFlag, GlobalFlags } from '../../shared/basecmd.js';
|
|
6
6
|
|
|
7
7
|
class DumpArtifacts extends Command {
|
|
8
|
-
static description =
|
|
9
|
-
static examples = [
|
|
10
|
-
'<%= config.bin %> <%= command.id %>',
|
|
11
|
-
];
|
|
8
|
+
static description = "parse sources in current package and dump all found artifacts to stdout";
|
|
9
|
+
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
12
10
|
static flags = {
|
|
13
11
|
...GlobalFlags,
|
|
14
12
|
...ArtifactTypeFlag,
|
|
15
13
|
};
|
|
16
14
|
async run() {
|
|
17
15
|
const { flags } = await this.parse(DumpArtifacts);
|
|
18
|
-
const logger = createLogger(flags[
|
|
19
|
-
dumpArtifacts(logger, stdout, flags.type ==
|
|
16
|
+
const logger = createLogger(flags["log-level"]);
|
|
17
|
+
dumpArtifacts(logger, stdout, flags.type == "all" ? undefined : flags.type);
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
20
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.js","sources":["../../../src/commands/dump/artifacts.ts"],"sourcesContent":["import { Command } from
|
|
1
|
+
{"version":3,"file":"artifacts.js","sources":["../../../src/commands/dump/artifacts.ts"],"sourcesContent":["import { Command } from \"@oclif/core\";\nimport { createLogger } from \"../../compiler/util\";\nimport { dumpArtifacts } from \"../../shared/dump\";\nimport { stdout } from \"node:process\";\nimport type { ArtifactType } from \"../../compiler/package\";\nimport * as opts from \"../../shared/basecmd\";\n\nexport default class DumpArtifacts extends Command {\n static override description =\n \"parse sources in current package and dump all found artifacts to stdout\";\n\n static override examples = [\"<%= config.bin %> <%= command.id %>\"];\n\n static override flags = {\n ...opts.GlobalFlags,\n ...opts.ArtifactTypeFlag,\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(DumpArtifacts);\n const logger = createLogger(flags[\"log-level\"]);\n dumpArtifacts(logger, stdout, flags.type == \"all\" ? undefined : (flags.type as ArtifactType));\n }\n}\n"],"names":["opts.GlobalFlags","opts.ArtifactTypeFlag"],"mappings":";;;;;;AAOc,MAAO,aAAc,SAAQ,OAAO,CAAA;AAChD,IAAA,OAAgB,WAAW,GACzB,yEAAyE;AAE3E,IAAA,OAAgB,QAAQ,GAAG,CAAC,qCAAqC,CAAC;IAElE,OAAgB,KAAK,GAAG;QACtB,GAAGA,WAAgB;QACnB,GAAGC,gBAAqB;KACzB;AAEM,IAAA,MAAM,GAAG,GAAA;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;QACjD,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC/C,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK,GAAG,SAAS,GAAI,KAAK,CAAC,IAAqB,CAAC;IAC/F;;;;;"}
|
|
@@ -7,16 +7,14 @@ var node_process = require('node:process');
|
|
|
7
7
|
var basecmd = require('../../shared/basecmd.cjs');
|
|
8
8
|
|
|
9
9
|
class DumpSoftware extends core.Command {
|
|
10
|
-
static description =
|
|
11
|
-
static examples = [
|
|
12
|
-
'<%= config.bin %> <%= command.id %>',
|
|
13
|
-
];
|
|
10
|
+
static description = "parse sources in current package and dump all software descriptors used by templates";
|
|
11
|
+
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
14
12
|
static flags = {
|
|
15
13
|
...basecmd.GlobalFlags,
|
|
16
14
|
};
|
|
17
15
|
async run() {
|
|
18
16
|
const { flags } = await this.parse(DumpSoftware);
|
|
19
|
-
const logger = util.createLogger(flags[
|
|
17
|
+
const logger = util.createLogger(flags["log-level"]);
|
|
20
18
|
dump.dumpSoftware(logger, node_process.stdout);
|
|
21
19
|
}
|
|
22
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"software.cjs","sources":["../../../src/commands/dump/software.ts"],"sourcesContent":["import { Command } from
|
|
1
|
+
{"version":3,"file":"software.cjs","sources":["../../../src/commands/dump/software.ts"],"sourcesContent":["import { Command } from \"@oclif/core\";\nimport { createLogger } from \"../../compiler/util\";\nimport { dumpSoftware } from \"../../shared/dump\";\nimport { stdout } from \"node:process\";\nimport * as opts from \"../../shared/basecmd\";\n\nexport default class DumpSoftware extends Command {\n static override description =\n \"parse sources in current package and dump all software descriptors used by templates\";\n\n static override examples = [\"<%= config.bin %> <%= command.id %>\"];\n\n static override flags = {\n ...opts.GlobalFlags,\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(DumpSoftware);\n const logger = createLogger(flags[\"log-level\"]);\n dumpSoftware(logger, stdout);\n }\n}\n"],"names":["Command","opts.GlobalFlags","createLogger","dumpSoftware","stdout"],"mappings":";;;;;;;;AAMc,MAAO,YAAa,SAAQA,YAAO,CAAA;AAC/C,IAAA,OAAgB,WAAW,GACzB,sFAAsF;AAExF,IAAA,OAAgB,QAAQ,GAAG,CAAC,qCAAqC,CAAC;IAElE,OAAgB,KAAK,GAAG;QACtB,GAAGC,mBAAgB;KACpB;AAEM,IAAA,MAAM,GAAG,GAAA;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;QAChD,MAAM,MAAM,GAAGC,iBAAY,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAC/C,QAAAC,iBAAY,CAAC,MAAM,EAAEC,mBAAM,CAAC;IAC9B;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Command } from
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
2
|
export default class DumpSoftware extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
|
|
6
|
+
"log-level": import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
7
|
};
|
|
8
8
|
run(): Promise<void>;
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"software.d.ts","sourceRoot":"","sources":["../../../src/commands/dump/software.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAMtC,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAC/C,OAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"software.d.ts","sourceRoot":"","sources":["../../../src/commands/dump/software.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAMtC,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAC/C,OAAgB,WAAW,SAC8D;IAEzF,OAAgB,QAAQ,WAA2C;IAEnE,OAAgB,KAAK;;MAEnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAKlC"}
|
|
@@ -5,16 +5,14 @@ import { stdout } from 'node:process';
|
|
|
5
5
|
import { GlobalFlags } from '../../shared/basecmd.js';
|
|
6
6
|
|
|
7
7
|
class DumpSoftware extends Command {
|
|
8
|
-
static description =
|
|
9
|
-
static examples = [
|
|
10
|
-
'<%= config.bin %> <%= command.id %>',
|
|
11
|
-
];
|
|
8
|
+
static description = "parse sources in current package and dump all software descriptors used by templates";
|
|
9
|
+
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
12
10
|
static flags = {
|
|
13
11
|
...GlobalFlags,
|
|
14
12
|
};
|
|
15
13
|
async run() {
|
|
16
14
|
const { flags } = await this.parse(DumpSoftware);
|
|
17
|
-
const logger = createLogger(flags[
|
|
15
|
+
const logger = createLogger(flags["log-level"]);
|
|
18
16
|
dumpSoftware(logger, stdout);
|
|
19
17
|
}
|
|
20
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"software.js","sources":["../../../src/commands/dump/software.ts"],"sourcesContent":["import { Command } from
|
|
1
|
+
{"version":3,"file":"software.js","sources":["../../../src/commands/dump/software.ts"],"sourcesContent":["import { Command } from \"@oclif/core\";\nimport { createLogger } from \"../../compiler/util\";\nimport { dumpSoftware } from \"../../shared/dump\";\nimport { stdout } from \"node:process\";\nimport * as opts from \"../../shared/basecmd\";\n\nexport default class DumpSoftware extends Command {\n static override description =\n \"parse sources in current package and dump all software descriptors used by templates\";\n\n static override examples = [\"<%= config.bin %> <%= command.id %>\"];\n\n static override flags = {\n ...opts.GlobalFlags,\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(DumpSoftware);\n const logger = createLogger(flags[\"log-level\"]);\n dumpSoftware(logger, stdout);\n }\n}\n"],"names":["opts.GlobalFlags"],"mappings":";;;;;;AAMc,MAAO,YAAa,SAAQ,OAAO,CAAA;AAC/C,IAAA,OAAgB,WAAW,GACzB,sFAAsF;AAExF,IAAA,OAAgB,QAAQ,GAAG,CAAC,qCAAqC,CAAC;IAElE,OAAgB,KAAK,GAAG;QACtB,GAAGA,WAAgB;KACpB;AAEM,IAAA,MAAM,GAAG,GAAA;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;QAChD,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAC/C,QAAA,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC;IAC9B;;;;;"}
|
package/dist/commands/test.cjs
CHANGED
|
@@ -8,15 +8,15 @@ var proc = require('../shared/proc.cjs');
|
|
|
8
8
|
var tengoTester = require('@milaboratories/tengo-tester');
|
|
9
9
|
|
|
10
10
|
class Test extends core.Command {
|
|
11
|
-
static description =
|
|
11
|
+
static description = "run tengo unit tests (.test.tengo)";
|
|
12
12
|
static strict = false;
|
|
13
13
|
static flags = { ...basecmd.GlobalFlags };
|
|
14
|
-
static examples = [
|
|
14
|
+
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
15
15
|
async run() {
|
|
16
16
|
const { flags } = await this.parse(Test);
|
|
17
|
-
const logger = util.createLogger(flags[
|
|
18
|
-
const testerArgs = this.argv.length == 0 ? [
|
|
19
|
-
const tester = proc.spawnEmbed(tengoTester.TengoTesterBinaryPath,
|
|
17
|
+
const logger = util.createLogger(flags["log-level"]);
|
|
18
|
+
const testerArgs = this.argv.length == 0 ? ["./src"] : this.argv;
|
|
19
|
+
const tester = proc.spawnEmbed(tengoTester.TengoTesterBinaryPath, "run", "--log-level", flags["log-level"], "--artifacts", "-", ...testerArgs);
|
|
20
20
|
try {
|
|
21
21
|
dump.dumpArtifacts(logger, tester.stdin);
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.cjs","sources":["../../src/commands/test.ts"],"sourcesContent":["import { Command } from
|
|
1
|
+
{"version":3,"file":"test.cjs","sources":["../../src/commands/test.ts"],"sourcesContent":["import { Command } from \"@oclif/core\";\nimport { createLogger } from \"../compiler/util\";\nimport { dumpArtifacts } from \"../shared/dump\";\nimport { GlobalFlags } from \"../shared/basecmd\";\nimport { spawnEmbed, waitFor } from \"../shared/proc\";\nimport { TengoTesterBinaryPath } from \"@milaboratories/tengo-tester\";\n\nexport default class Test extends Command {\n static override description = \"run tengo unit tests (.test.tengo)\";\n\n static strict = false;\n\n static override flags = { ...GlobalFlags };\n\n static override examples = [\"<%= config.bin %> <%= command.id %>\"];\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(Test);\n const logger = createLogger(flags[\"log-level\"]);\n\n const testerArgs: string[] = this.argv.length == 0 ? [\"./src\"] : this.argv;\n\n const tester = spawnEmbed(\n TengoTesterBinaryPath,\n \"run\",\n \"--log-level\",\n flags[\"log-level\"],\n \"--artifacts\",\n \"-\",\n ...testerArgs,\n );\n\n try {\n dumpArtifacts(logger, tester.stdin);\n } catch (err: unknown) {\n logger.error(err);\n } finally {\n tester.stdin.end();\n const code = await waitFor(tester);\n process.exit(code);\n }\n }\n}\n"],"names":["Command","GlobalFlags","createLogger","spawnEmbed","TengoTesterBinaryPath","dumpArtifacts","waitFor"],"mappings":";;;;;;;;;AAOc,MAAO,IAAK,SAAQA,YAAO,CAAA;AACvC,IAAA,OAAgB,WAAW,GAAG,oCAAoC;AAElE,IAAA,OAAO,MAAM,GAAG,KAAK;AAErB,IAAA,OAAgB,KAAK,GAAG,EAAE,GAAGC,mBAAW,EAAE;AAE1C,IAAA,OAAgB,QAAQ,GAAG,CAAC,qCAAqC,CAAC;AAE3D,IAAA,MAAM,GAAG,GAAA;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;QACxC,MAAM,MAAM,GAAGC,iBAAY,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAE/C,MAAM,UAAU,GAAa,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI;QAE1E,MAAM,MAAM,GAAGC,eAAU,CACvBC,iCAAqB,EACrB,KAAK,EACL,aAAa,EACb,KAAK,CAAC,WAAW,CAAC,EAClB,aAAa,EACb,GAAG,EACH,GAAG,UAAU,CACd;AAED,QAAA,IAAI;AACF,YAAAC,kBAAa,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC;QACrC;QAAE,OAAO,GAAY,EAAE;AACrB,YAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QACnB;gBAAU;AACR,YAAA,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;AAClB,YAAA,MAAM,IAAI,GAAG,MAAMC,YAAO,CAAC,MAAM,CAAC;AAClC,YAAA,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;QACpB;IACF;;;;;"}
|
package/dist/commands/test.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Command } from
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
2
|
export default class Test extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static strict: boolean;
|
|
5
5
|
static flags: {
|
|
6
|
-
|
|
6
|
+
"log-level": import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
7
|
};
|
|
8
8
|
static examples: string[];
|
|
9
9
|
run(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAOtC,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACvC,OAAgB,WAAW,SAAwC;IAEnE,MAAM,CAAC,MAAM,UAAS;IAEtB,OAAgB,KAAK;;MAAsB;IAE3C,OAAgB,QAAQ,WAA2C;IAEtD,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAOtC,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACvC,OAAgB,WAAW,SAAwC;IAEnE,MAAM,CAAC,MAAM,UAAS;IAEtB,OAAgB,KAAK;;MAAsB;IAE3C,OAAgB,QAAQ,WAA2C;IAEtD,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA0BlC"}
|
package/dist/commands/test.js
CHANGED
|
@@ -6,15 +6,15 @@ import { spawnEmbed, waitFor } from '../shared/proc.js';
|
|
|
6
6
|
import { TengoTesterBinaryPath } from '@milaboratories/tengo-tester';
|
|
7
7
|
|
|
8
8
|
class Test extends Command {
|
|
9
|
-
static description =
|
|
9
|
+
static description = "run tengo unit tests (.test.tengo)";
|
|
10
10
|
static strict = false;
|
|
11
11
|
static flags = { ...GlobalFlags };
|
|
12
|
-
static examples = [
|
|
12
|
+
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
13
13
|
async run() {
|
|
14
14
|
const { flags } = await this.parse(Test);
|
|
15
|
-
const logger = createLogger(flags[
|
|
16
|
-
const testerArgs = this.argv.length == 0 ? [
|
|
17
|
-
const tester = spawnEmbed(TengoTesterBinaryPath,
|
|
15
|
+
const logger = createLogger(flags["log-level"]);
|
|
16
|
+
const testerArgs = this.argv.length == 0 ? ["./src"] : this.argv;
|
|
17
|
+
const tester = spawnEmbed(TengoTesterBinaryPath, "run", "--log-level", flags["log-level"], "--artifacts", "-", ...testerArgs);
|
|
18
18
|
try {
|
|
19
19
|
dumpArtifacts(logger, tester.stdin);
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sources":["../../src/commands/test.ts"],"sourcesContent":["import { Command } from
|
|
1
|
+
{"version":3,"file":"test.js","sources":["../../src/commands/test.ts"],"sourcesContent":["import { Command } from \"@oclif/core\";\nimport { createLogger } from \"../compiler/util\";\nimport { dumpArtifacts } from \"../shared/dump\";\nimport { GlobalFlags } from \"../shared/basecmd\";\nimport { spawnEmbed, waitFor } from \"../shared/proc\";\nimport { TengoTesterBinaryPath } from \"@milaboratories/tengo-tester\";\n\nexport default class Test extends Command {\n static override description = \"run tengo unit tests (.test.tengo)\";\n\n static strict = false;\n\n static override flags = { ...GlobalFlags };\n\n static override examples = [\"<%= config.bin %> <%= command.id %>\"];\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(Test);\n const logger = createLogger(flags[\"log-level\"]);\n\n const testerArgs: string[] = this.argv.length == 0 ? [\"./src\"] : this.argv;\n\n const tester = spawnEmbed(\n TengoTesterBinaryPath,\n \"run\",\n \"--log-level\",\n flags[\"log-level\"],\n \"--artifacts\",\n \"-\",\n ...testerArgs,\n );\n\n try {\n dumpArtifacts(logger, tester.stdin);\n } catch (err: unknown) {\n logger.error(err);\n } finally {\n tester.stdin.end();\n const code = await waitFor(tester);\n process.exit(code);\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;AAOc,MAAO,IAAK,SAAQ,OAAO,CAAA;AACvC,IAAA,OAAgB,WAAW,GAAG,oCAAoC;AAElE,IAAA,OAAO,MAAM,GAAG,KAAK;AAErB,IAAA,OAAgB,KAAK,GAAG,EAAE,GAAG,WAAW,EAAE;AAE1C,IAAA,OAAgB,QAAQ,GAAG,CAAC,qCAAqC,CAAC;AAE3D,IAAA,MAAM,GAAG,GAAA;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;QACxC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAE/C,MAAM,UAAU,GAAa,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI;QAE1E,MAAM,MAAM,GAAG,UAAU,CACvB,qBAAqB,EACrB,KAAK,EACL,aAAa,EACb,KAAK,CAAC,WAAW,CAAC,EAClB,aAAa,EACb,GAAG,EACH,GAAG,UAAU,CACd;AAED,QAAA,IAAI;AACF,YAAA,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC;QACrC;QAAE,OAAO,GAAY,EAAE;AACrB,YAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QACnB;gBAAU;AACR,YAAA,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;AAClB,YAAA,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC;AAClC,YAAA,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;QACpB;IACF;;;;;"}
|
|
@@ -45,7 +45,7 @@ class ArtifactStore {
|
|
|
45
45
|
}
|
|
46
46
|
add(mode, obj, replace = true) {
|
|
47
47
|
switch (mode) {
|
|
48
|
-
case
|
|
48
|
+
case "dist":
|
|
49
49
|
return this.dist.add(obj, replace);
|
|
50
50
|
default:
|
|
51
51
|
util.assertNever(mode);
|
|
@@ -53,7 +53,7 @@ class ArtifactStore {
|
|
|
53
53
|
}
|
|
54
54
|
get(mode, name) {
|
|
55
55
|
switch (mode) {
|
|
56
|
-
case
|
|
56
|
+
case "dist":
|
|
57
57
|
return this.dist.get(name);
|
|
58
58
|
default:
|
|
59
59
|
util.assertNever(mode);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifactset.cjs","sources":["../../src/compiler/artifactset.ts"],"sourcesContent":["import type { CompileMode, TypedArtifactName } from
|
|
1
|
+
{"version":3,"file":"artifactset.cjs","sources":["../../src/compiler/artifactset.ts"],"sourcesContent":["import type { CompileMode, TypedArtifactName } from \"./package\";\nimport { artifactKey } from \"./package\";\nimport { assertNever } from \"./util\";\n\nexport class ArtifactMap<T> {\n private readonly map = new Map<string, T>();\n\n constructor(private readonly nameExtractor: (obj: T) => TypedArtifactName) {}\n\n add(obj: T, replace: boolean = true): T | undefined {\n const key = artifactKey(this.nameExtractor(obj));\n const ret = this.map.get(key);\n if (ret && !replace) return ret;\n this.map.set(key, obj);\n return ret;\n }\n\n get(name: TypedArtifactName): T | undefined {\n return this.map.get(artifactKey(name));\n }\n\n get array(): T[] {\n const ret: T[] = [];\n this.map.forEach((obj) => ret.push(obj));\n return ret;\n }\n\n forEach(callback: (value: T, key: TypedArtifactName) => void) {\n this.map.forEach((v) => callback(v, this.nameExtractor(v)));\n }\n}\n\nexport function createArtifactNameSet(): ArtifactMap<TypedArtifactName> {\n return new ArtifactMap<TypedArtifactName>((obj) => obj);\n}\n\n/**\n * ArtifactStore is a store for artifacts that are compiled for different modes.\n * It is used to collect all artifacts from the dependency tree and compile them for different modes.\n */\nexport class ArtifactStore<T> {\n // private readonly dev: ArtifactMap<T>;\n private readonly dist: ArtifactMap<T>;\n\n constructor(nameExtractor: (obj: T) => TypedArtifactName) {\n // this.dev = new ArtifactMap<T>(nameExtractor);\n this.dist = new ArtifactMap<T>(nameExtractor);\n }\n\n add(mode: CompileMode, obj: T, replace: boolean = true): T | undefined {\n switch (mode) {\n case \"dist\":\n return this.dist.add(obj, replace);\n\n default:\n assertNever(mode);\n }\n }\n\n get(mode: CompileMode, name: TypedArtifactName): T | undefined {\n switch (mode) {\n case \"dist\":\n return this.dist.get(name);\n\n default:\n assertNever(mode);\n }\n }\n\n array(mode: CompileMode): T[] {\n const ret: T[] = [];\n this.forEach(mode, (obj) => ret.push(obj));\n return ret;\n }\n\n forEach(mode: CompileMode, callback: (value: T, key: TypedArtifactName) => void) {\n this.dist.forEach((obj, k) => callback(this.get(mode, k) ?? obj, k));\n }\n}\n"],"names":["artifactKey","assertNever"],"mappings":";;;;;MAIa,WAAW,CAAA;AAGO,IAAA,aAAA;AAFZ,IAAA,GAAG,GAAG,IAAI,GAAG,EAAa;AAE3C,IAAA,WAAA,CAA6B,aAA4C,EAAA;QAA5C,IAAA,CAAA,aAAa,GAAb,aAAa;IAAkC;AAE5E,IAAA,GAAG,CAAC,GAAM,EAAE,OAAA,GAAmB,IAAI,EAAA;QACjC,MAAM,GAAG,GAAGA,oBAAW,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAChD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;QAC7B,IAAI,GAAG,IAAI,CAAC,OAAO;AAAE,YAAA,OAAO,GAAG;QAC/B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;AACtB,QAAA,OAAO,GAAG;IACZ;AAEA,IAAA,GAAG,CAAC,IAAuB,EAAA;QACzB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAACA,oBAAW,CAAC,IAAI,CAAC,CAAC;IACxC;AAEA,IAAA,IAAI,KAAK,GAAA;QACP,MAAM,GAAG,GAAQ,EAAE;AACnB,QAAA,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxC,QAAA,OAAO,GAAG;IACZ;AAEA,IAAA,OAAO,CAAC,QAAoD,EAAA;QAC1D,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D;AACD;SAEe,qBAAqB,GAAA;IACnC,OAAO,IAAI,WAAW,CAAoB,CAAC,GAAG,KAAK,GAAG,CAAC;AACzD;AAEA;;;AAGG;MACU,aAAa,CAAA;;AAEP,IAAA,IAAI;AAErB,IAAA,WAAA,CAAY,aAA4C,EAAA;;QAEtD,IAAI,CAAC,IAAI,GAAG,IAAI,WAAW,CAAI,aAAa,CAAC;IAC/C;AAEA,IAAA,GAAG,CAAC,IAAiB,EAAE,GAAM,EAAE,UAAmB,IAAI,EAAA;QACpD,QAAQ,IAAI;AACV,YAAA,KAAK,MAAM;gBACT,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC;AAEpC,YAAA;gBACEC,gBAAW,CAAC,IAAI,CAAC;;IAEvB;IAEA,GAAG,CAAC,IAAiB,EAAE,IAAuB,EAAA;QAC5C,QAAQ,IAAI;AACV,YAAA,KAAK,MAAM;gBACT,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;AAE5B,YAAA;gBACEA,gBAAW,CAAC,IAAI,CAAC;;IAEvB;AAEA,IAAA,KAAK,CAAC,IAAiB,EAAA;QACrB,MAAM,GAAG,GAAQ,EAAE;AACnB,QAAA,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1C,QAAA,OAAO,GAAG;IACZ;IAEA,OAAO,CAAC,IAAiB,EAAE,QAAoD,EAAA;AAC7E,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;IACtE;AACD;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifactset.d.ts","sourceRoot":"","sources":["../../src/compiler/artifactset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAIhE,qBAAa,WAAW,CAAC,CAAC;IAGZ,OAAO,CAAC,QAAQ,CAAC,aAAa;IAF1C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAwB;gBAEf,aAAa,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,iBAAiB;
|
|
1
|
+
{"version":3,"file":"artifactset.d.ts","sourceRoot":"","sources":["../../src/compiler/artifactset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAIhE,qBAAa,WAAW,CAAC,CAAC;IAGZ,OAAO,CAAC,QAAQ,CAAC,aAAa;IAF1C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAwB;gBAEf,aAAa,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,iBAAiB;IAEzE,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,OAAO,GAAE,OAAc,GAAG,CAAC,GAAG,SAAS;IAQnD,GAAG,CAAC,IAAI,EAAE,iBAAiB,GAAG,CAAC,GAAG,SAAS;IAI3C,IAAI,KAAK,IAAI,CAAC,EAAE,CAIf;IAED,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,iBAAiB,KAAK,IAAI;CAG7D;AAED,wBAAgB,qBAAqB,IAAI,WAAW,CAAC,iBAAiB,CAAC,CAEtE;AAED;;;GAGG;AACH,qBAAa,aAAa,CAAC,CAAC;IAE1B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiB;gBAE1B,aAAa,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,iBAAiB;IAKxD,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,GAAE,OAAc,GAAG,CAAC,GAAG,SAAS;IAUtE,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,iBAAiB,GAAG,CAAC,GAAG,SAAS;IAU9D,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,CAAC,EAAE;IAM7B,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,iBAAiB,KAAK,IAAI;CAGhF"}
|
|
@@ -43,7 +43,7 @@ class ArtifactStore {
|
|
|
43
43
|
}
|
|
44
44
|
add(mode, obj, replace = true) {
|
|
45
45
|
switch (mode) {
|
|
46
|
-
case
|
|
46
|
+
case "dist":
|
|
47
47
|
return this.dist.add(obj, replace);
|
|
48
48
|
default:
|
|
49
49
|
assertNever(mode);
|
|
@@ -51,7 +51,7 @@ class ArtifactStore {
|
|
|
51
51
|
}
|
|
52
52
|
get(mode, name) {
|
|
53
53
|
switch (mode) {
|
|
54
|
-
case
|
|
54
|
+
case "dist":
|
|
55
55
|
return this.dist.get(name);
|
|
56
56
|
default:
|
|
57
57
|
assertNever(mode);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifactset.js","sources":["../../src/compiler/artifactset.ts"],"sourcesContent":["import type { CompileMode, TypedArtifactName } from
|
|
1
|
+
{"version":3,"file":"artifactset.js","sources":["../../src/compiler/artifactset.ts"],"sourcesContent":["import type { CompileMode, TypedArtifactName } from \"./package\";\nimport { artifactKey } from \"./package\";\nimport { assertNever } from \"./util\";\n\nexport class ArtifactMap<T> {\n private readonly map = new Map<string, T>();\n\n constructor(private readonly nameExtractor: (obj: T) => TypedArtifactName) {}\n\n add(obj: T, replace: boolean = true): T | undefined {\n const key = artifactKey(this.nameExtractor(obj));\n const ret = this.map.get(key);\n if (ret && !replace) return ret;\n this.map.set(key, obj);\n return ret;\n }\n\n get(name: TypedArtifactName): T | undefined {\n return this.map.get(artifactKey(name));\n }\n\n get array(): T[] {\n const ret: T[] = [];\n this.map.forEach((obj) => ret.push(obj));\n return ret;\n }\n\n forEach(callback: (value: T, key: TypedArtifactName) => void) {\n this.map.forEach((v) => callback(v, this.nameExtractor(v)));\n }\n}\n\nexport function createArtifactNameSet(): ArtifactMap<TypedArtifactName> {\n return new ArtifactMap<TypedArtifactName>((obj) => obj);\n}\n\n/**\n * ArtifactStore is a store for artifacts that are compiled for different modes.\n * It is used to collect all artifacts from the dependency tree and compile them for different modes.\n */\nexport class ArtifactStore<T> {\n // private readonly dev: ArtifactMap<T>;\n private readonly dist: ArtifactMap<T>;\n\n constructor(nameExtractor: (obj: T) => TypedArtifactName) {\n // this.dev = new ArtifactMap<T>(nameExtractor);\n this.dist = new ArtifactMap<T>(nameExtractor);\n }\n\n add(mode: CompileMode, obj: T, replace: boolean = true): T | undefined {\n switch (mode) {\n case \"dist\":\n return this.dist.add(obj, replace);\n\n default:\n assertNever(mode);\n }\n }\n\n get(mode: CompileMode, name: TypedArtifactName): T | undefined {\n switch (mode) {\n case \"dist\":\n return this.dist.get(name);\n\n default:\n assertNever(mode);\n }\n }\n\n array(mode: CompileMode): T[] {\n const ret: T[] = [];\n this.forEach(mode, (obj) => ret.push(obj));\n return ret;\n }\n\n forEach(mode: CompileMode, callback: (value: T, key: TypedArtifactName) => void) {\n this.dist.forEach((obj, k) => callback(this.get(mode, k) ?? obj, k));\n }\n}\n"],"names":[],"mappings":";;;MAIa,WAAW,CAAA;AAGO,IAAA,aAAA;AAFZ,IAAA,GAAG,GAAG,IAAI,GAAG,EAAa;AAE3C,IAAA,WAAA,CAA6B,aAA4C,EAAA;QAA5C,IAAA,CAAA,aAAa,GAAb,aAAa;IAAkC;AAE5E,IAAA,GAAG,CAAC,GAAM,EAAE,OAAA,GAAmB,IAAI,EAAA;QACjC,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAChD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;QAC7B,IAAI,GAAG,IAAI,CAAC,OAAO;AAAE,YAAA,OAAO,GAAG;QAC/B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;AACtB,QAAA,OAAO,GAAG;IACZ;AAEA,IAAA,GAAG,CAAC,IAAuB,EAAA;QACzB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACxC;AAEA,IAAA,IAAI,KAAK,GAAA;QACP,MAAM,GAAG,GAAQ,EAAE;AACnB,QAAA,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxC,QAAA,OAAO,GAAG;IACZ;AAEA,IAAA,OAAO,CAAC,QAAoD,EAAA;QAC1D,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D;AACD;SAEe,qBAAqB,GAAA;IACnC,OAAO,IAAI,WAAW,CAAoB,CAAC,GAAG,KAAK,GAAG,CAAC;AACzD;AAEA;;;AAGG;MACU,aAAa,CAAA;;AAEP,IAAA,IAAI;AAErB,IAAA,WAAA,CAAY,aAA4C,EAAA;;QAEtD,IAAI,CAAC,IAAI,GAAG,IAAI,WAAW,CAAI,aAAa,CAAC;IAC/C;AAEA,IAAA,GAAG,CAAC,IAAiB,EAAE,GAAM,EAAE,UAAmB,IAAI,EAAA;QACpD,QAAQ,IAAI;AACV,YAAA,KAAK,MAAM;gBACT,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC;AAEpC,YAAA;gBACE,WAAW,CAAC,IAAI,CAAC;;IAEvB;IAEA,GAAG,CAAC,IAAiB,EAAE,IAAuB,EAAA;QAC5C,QAAQ,IAAI;AACV,YAAA,KAAK,MAAM;gBACT,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;AAE5B,YAAA;gBACE,WAAW,CAAC,IAAI,CAAC;;IAEvB;AAEA,IAAA,KAAK,CAAC,IAAiB,EAAA;QACrB,MAAM,GAAG,GAAQ,EAAE;AACnB,QAAA,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1C,QAAA,OAAO,GAAG;IACZ;IAEA,OAAO,CAAC,IAAiB,EAAE,QAAoD,EAAA;AAC7E,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;IACtE;AACD;;;;"}
|
|
@@ -19,12 +19,12 @@ class TengoTemplateCompiler {
|
|
|
19
19
|
populateTemplateDataFromDependencies(fullName, data, deps, trace) {
|
|
20
20
|
for (const dep of deps) {
|
|
21
21
|
switch (dep.type) {
|
|
22
|
-
case
|
|
22
|
+
case "library": {
|
|
23
23
|
const lib = this.getLibOrError(dep);
|
|
24
24
|
const recursionStart = trace.indexOf(_package.artifactNameToString(dep));
|
|
25
25
|
if (recursionStart >= 0) {
|
|
26
|
-
const errorMessage = `library import recursion detected: `
|
|
27
|
-
|
|
26
|
+
const errorMessage = `library import recursion detected: ` +
|
|
27
|
+
`${trace.slice(recursionStart).join(" -> ")} -> ${_package.artifactNameToString(dep)}`;
|
|
28
28
|
throw new Error(errorMessage);
|
|
29
29
|
}
|
|
30
30
|
const tplLib = {
|
|
@@ -35,10 +35,13 @@ class TengoTemplateCompiler {
|
|
|
35
35
|
data.template.libs[_package.artifactNameToString(dep)] = tplLib;
|
|
36
36
|
data.hashToSource[tplLib.sourceHash] = lib.src;
|
|
37
37
|
// populate with transient library dependencies
|
|
38
|
-
this.populateTemplateDataFromDependencies(fullName, data, lib.dependencies, [
|
|
38
|
+
this.populateTemplateDataFromDependencies(fullName, data, lib.dependencies, [
|
|
39
|
+
...trace,
|
|
40
|
+
_package.artifactNameToString(dep),
|
|
41
|
+
]);
|
|
39
42
|
break;
|
|
40
43
|
}
|
|
41
|
-
case
|
|
44
|
+
case "software": {
|
|
42
45
|
const software = this.getSoftwareOrError(dep);
|
|
43
46
|
data.template.software[_package.artifactNameToString(dep)] = {
|
|
44
47
|
..._package.formatArtefactNameAndVersion(software.fullName),
|
|
@@ -47,7 +50,7 @@ class TengoTemplateCompiler {
|
|
|
47
50
|
data.hashToSource[software.sourceHash] = software.src;
|
|
48
51
|
break;
|
|
49
52
|
}
|
|
50
|
-
case
|
|
53
|
+
case "asset": {
|
|
51
54
|
const asset = this.getAssetOrError(dep);
|
|
52
55
|
// Yes, we temporarily put assets into 'software' section of template, so controller can
|
|
53
56
|
// handle it the right way without updates
|
|
@@ -58,7 +61,7 @@ class TengoTemplateCompiler {
|
|
|
58
61
|
data.hashToSource[asset.sourceHash] = asset.src;
|
|
59
62
|
break;
|
|
60
63
|
}
|
|
61
|
-
case
|
|
64
|
+
case "template": {
|
|
62
65
|
if (_package.typedArtifactNamesEquals(fullName, dep))
|
|
63
66
|
// skipping self reference
|
|
64
67
|
continue;
|
|
@@ -71,9 +74,9 @@ class TengoTemplateCompiler {
|
|
|
71
74
|
}
|
|
72
75
|
break;
|
|
73
76
|
}
|
|
74
|
-
case
|
|
75
|
-
throw new Error(`dependencies tree error: tests should never be part of template: `
|
|
76
|
-
|
|
77
|
+
case "test":
|
|
78
|
+
throw new Error(`dependencies tree error: tests should never be part of template: ` +
|
|
79
|
+
`${_package.typedArtifactNameToString(dep)} is dependency of ${_package.artifactNameToString(fullName)}`);
|
|
77
80
|
default:
|
|
78
81
|
util.assertNever(dep.type);
|
|
79
82
|
}
|
|
@@ -81,11 +84,11 @@ class TengoTemplateCompiler {
|
|
|
81
84
|
}
|
|
82
85
|
/** This method assumes that all dependencies are already added to the compiler's context */
|
|
83
86
|
compileAndAddTemplate(tplSrc) {
|
|
84
|
-
if (tplSrc.fullName.type !==
|
|
85
|
-
throw new Error(
|
|
87
|
+
if (tplSrc.fullName.type !== "template")
|
|
88
|
+
throw new Error("unexpected source type");
|
|
86
89
|
// creating template with unpopulated dependencies
|
|
87
90
|
const tplData = {
|
|
88
|
-
type:
|
|
91
|
+
type: "pl.tengo-template.v3",
|
|
89
92
|
hashToSource: {
|
|
90
93
|
[tplSrc.sourceHash]: tplSrc.src,
|
|
91
94
|
},
|
|
@@ -112,7 +115,7 @@ class TengoTemplateCompiler {
|
|
|
112
115
|
return this.libs.array(this.compileMode);
|
|
113
116
|
}
|
|
114
117
|
getLib(name) {
|
|
115
|
-
if (name.type !==
|
|
118
|
+
if (name.type !== "library")
|
|
116
119
|
throw new Error(`illegal artifact type: got ${name.type} instead of 'library`);
|
|
117
120
|
return this.libs.get(this.compileMode, name);
|
|
118
121
|
}
|
|
@@ -125,7 +128,7 @@ class TengoTemplateCompiler {
|
|
|
125
128
|
checkLibs() {
|
|
126
129
|
this.libs.forEach(this.compileMode, (lib) => {
|
|
127
130
|
for (const dep of lib.dependencies) {
|
|
128
|
-
if (dep.type ===
|
|
131
|
+
if (dep.type === "test")
|
|
129
132
|
throw new Error(`test should never be dependency of production code: ${_package.typedArtifactNameToString(dep)} test is dependency of ${_package.fullNameToString(lib.fullName)}`);
|
|
130
133
|
if (!this.getArtefact(dep))
|
|
131
134
|
throw new Error(`unresolved dependency ${_package.typedArtifactNameToString(dep)} for ${_package.fullNameToString(lib.fullName)}`);
|
|
@@ -141,7 +144,7 @@ class TengoTemplateCompiler {
|
|
|
141
144
|
return this.software.array(this.compileMode);
|
|
142
145
|
}
|
|
143
146
|
getSoftware(name) {
|
|
144
|
-
if (name.type !==
|
|
147
|
+
if (name.type !== "software")
|
|
145
148
|
throw new Error(`illegal artifact type: got ${name.type} instead of 'software`);
|
|
146
149
|
return this.software.get(this.compileMode, name);
|
|
147
150
|
}
|
|
@@ -160,7 +163,7 @@ class TengoTemplateCompiler {
|
|
|
160
163
|
return this.assets.array(this.compileMode);
|
|
161
164
|
}
|
|
162
165
|
getAsset(name) {
|
|
163
|
-
if (name.type !==
|
|
166
|
+
if (name.type !== "asset")
|
|
164
167
|
throw new Error(`illegal artifact type: got ${name.type} instead of 'asset`);
|
|
165
168
|
return this.assets.get(this.compileMode, name);
|
|
166
169
|
}
|
|
@@ -179,7 +182,7 @@ class TengoTemplateCompiler {
|
|
|
179
182
|
return this.templates.array(this.compileMode);
|
|
180
183
|
}
|
|
181
184
|
getTemplate(name) {
|
|
182
|
-
if (name.type !==
|
|
185
|
+
if (name.type !== "template")
|
|
183
186
|
throw new Error(`illegal artifact type: got ${name.type} instead of 'template`);
|
|
184
187
|
return this.templates.get(this.compileMode, name);
|
|
185
188
|
}
|
|
@@ -191,15 +194,15 @@ class TengoTemplateCompiler {
|
|
|
191
194
|
}
|
|
192
195
|
getArtefact(name) {
|
|
193
196
|
switch (name.type) {
|
|
194
|
-
case
|
|
197
|
+
case "template":
|
|
195
198
|
return this.getTemplate(name);
|
|
196
|
-
case
|
|
199
|
+
case "library":
|
|
197
200
|
return this.getLib(name);
|
|
198
|
-
case
|
|
201
|
+
case "software":
|
|
199
202
|
return this.getSoftware(name);
|
|
200
|
-
case
|
|
203
|
+
case "asset":
|
|
201
204
|
return this.getAsset(name);
|
|
202
|
-
case
|
|
205
|
+
case "test":
|
|
203
206
|
// Tests are ignored by the complier. They should never be compiled into templates or libs and
|
|
204
207
|
// should never be a dependency.
|
|
205
208
|
return undefined;
|
|
@@ -216,17 +219,17 @@ class TengoTemplateCompiler {
|
|
|
216
219
|
};
|
|
217
220
|
let current = [];
|
|
218
221
|
for (const src of sources) {
|
|
219
|
-
if (src.fullName.type ===
|
|
222
|
+
if (src.fullName.type === "library") {
|
|
220
223
|
// add libraries 'as-is' to be able to resolve them as dependencies
|
|
221
224
|
this.addLib(src);
|
|
222
225
|
result.libs.push(src);
|
|
223
226
|
}
|
|
224
|
-
else if (src.fullName.type ===
|
|
227
|
+
else if (src.fullName.type === "software") {
|
|
225
228
|
// add software 'as-is' to be able to resolve them as dependencies
|
|
226
229
|
this.addSoftware(src);
|
|
227
230
|
result.software.push(src);
|
|
228
231
|
}
|
|
229
|
-
else if (src.fullName.type ===
|
|
232
|
+
else if (src.fullName.type === "asset") {
|
|
230
233
|
// add assets 'as-is' to be able to resolve them as dependencies
|
|
231
234
|
this.addAsset(src);
|
|
232
235
|
result.assets.push(src);
|
|
@@ -245,9 +248,9 @@ class TengoTemplateCompiler {
|
|
|
245
248
|
//
|
|
246
249
|
// This is equivalent to topological sorting of input sources.
|
|
247
250
|
//
|
|
248
|
-
const unsatisfied = src.dependencies.filter((dep) => !this.getArtefact(dep)
|
|
251
|
+
const unsatisfied = src.dependencies.filter((dep) => !this.getArtefact(dep) &&
|
|
249
252
|
// allow self reference for templates
|
|
250
|
-
|
|
253
|
+
!(src.fullName.type === "template" && _package.typedArtifactNamesEquals(src.fullName, dep)));
|
|
251
254
|
if (unsatisfied.length > 0) {
|
|
252
255
|
let errorMessage = `Unsatisfied dependencies in ${_package.fullNameToString(src.fullName)}:\n`;
|
|
253
256
|
for (const dep of unsatisfied) {
|
|
@@ -258,22 +261,22 @@ class TengoTemplateCompiler {
|
|
|
258
261
|
}
|
|
259
262
|
// type specific processing
|
|
260
263
|
switch (src.fullName.type) {
|
|
261
|
-
case
|
|
264
|
+
case "library":
|
|
262
265
|
// libraries are added as is
|
|
263
266
|
this.addLib(src);
|
|
264
267
|
result.libs.push(src);
|
|
265
268
|
break;
|
|
266
|
-
case
|
|
269
|
+
case "software":
|
|
267
270
|
// software dependencies are added as is
|
|
268
271
|
this.addSoftware(src);
|
|
269
272
|
result.software.push(src);
|
|
270
273
|
break;
|
|
271
|
-
case
|
|
274
|
+
case "asset":
|
|
272
275
|
// software dependencies are added as is
|
|
273
276
|
this.addAsset(src);
|
|
274
277
|
result.assets.push(src);
|
|
275
278
|
break;
|
|
276
|
-
case
|
|
279
|
+
case "template":
|
|
277
280
|
// templates are compiled and then added
|
|
278
281
|
try {
|
|
279
282
|
const tpl = this.compileAndAddTemplate(src);
|
|
@@ -288,7 +291,7 @@ class TengoTemplateCompiler {
|
|
|
288
291
|
unprocessed.push({ src, err: Error(errorMessage) }); // one or more dependencies are not resolvable yet
|
|
289
292
|
}
|
|
290
293
|
break;
|
|
291
|
-
case
|
|
294
|
+
case "test":
|
|
292
295
|
// Ignore tests: they never should be part of compiled code or be a dependency.
|
|
293
296
|
break;
|
|
294
297
|
default:
|
|
@@ -298,7 +301,7 @@ class TengoTemplateCompiler {
|
|
|
298
301
|
// checking that we successfully added at least one source,
|
|
299
302
|
// if not all the source files in unprocessed array have unmet dependencies
|
|
300
303
|
if (current.length === unprocessed.length) {
|
|
301
|
-
let errorMessage =
|
|
304
|
+
let errorMessage = "";
|
|
302
305
|
for (const u of unprocessed) {
|
|
303
306
|
errorMessage += `\n${u.err.message}`;
|
|
304
307
|
}
|