@platforma-sdk/tengo-builder 4.0.9 → 4.0.10
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/bin/run.js +5 -10
- package/dist/cli.cjs +28 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +26 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/build.cjs +15 -13
- package/dist/commands/build.cjs.map +1 -1
- package/dist/commands/build.js +16 -14
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/check.cjs +13 -14
- package/dist/commands/check.cjs.map +1 -1
- package/dist/commands/check.js +14 -15
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/dump/artifacts.cjs +10 -14
- package/dist/commands/dump/artifacts.cjs.map +1 -1
- package/dist/commands/dump/artifacts.js +11 -15
- package/dist/commands/dump/artifacts.js.map +1 -1
- package/dist/commands/dump/software.cjs +10 -11
- package/dist/commands/dump/software.cjs.map +1 -1
- package/dist/commands/dump/software.js +11 -12
- package/dist/commands/dump/software.js.map +1 -1
- package/dist/commands/test.cjs +13 -14
- package/dist/commands/test.cjs.map +1 -1
- package/dist/commands/test.js +14 -15
- package/dist/commands/test.js.map +1 -1
- package/dist/index.cjs +3 -17
- package/dist/index.d.ts +2 -17
- package/dist/index.js +2 -17
- package/dist/shared/basecmd.cjs +33 -44
- package/dist/shared/basecmd.cjs.map +1 -1
- package/dist/shared/basecmd.js +30 -42
- package/dist/shared/basecmd.js.map +1 -1
- package/package.json +7 -18
- package/src/cli.ts +27 -0
- package/src/commands/build.ts +16 -12
- package/src/commands/check.ts +14 -19
- package/src/commands/dump/artifacts.ts +11 -14
- package/src/commands/dump/software.ts +11 -13
- package/src/commands/test.ts +14 -15
- package/src/index.ts +1 -15
- package/src/shared/basecmd.ts +36 -32
- package/dist/commands/build.d.ts +0 -18
- package/dist/commands/build.d.ts.map +0 -1
- package/dist/commands/check.d.ts +0 -16
- package/dist/commands/check.d.ts.map +0 -1
- package/dist/commands/dump/artifacts.d.ts +0 -16
- package/dist/commands/dump/artifacts.d.ts.map +0 -1
- package/dist/commands/dump/software.d.ts +0 -15
- package/dist/commands/dump/software.d.ts.map +0 -1
- package/dist/commands/test.d.ts +0 -16
- package/dist/commands/test.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { createLogger } from "../../compiler/util.js";
|
|
2
|
-
import {
|
|
2
|
+
import { GlobalOptions, addOptions } from "../../shared/basecmd.js";
|
|
3
3
|
import { dumpSoftware } from "../../shared/dump.js";
|
|
4
|
-
import { Command } from "
|
|
4
|
+
import { Command } from "commander";
|
|
5
5
|
import { stdout } from "node:process";
|
|
6
6
|
//#region src/commands/dump/software.ts
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
7
|
+
function dumpSoftwareCommand() {
|
|
8
|
+
const cmd = new Command("software").description("parse sources in current package and dump all software descriptors used by templates");
|
|
9
|
+
addOptions(cmd, GlobalOptions());
|
|
10
|
+
cmd.action(async (o) => {
|
|
11
|
+
dumpSoftware(createLogger(o.logLevel), stdout);
|
|
12
|
+
});
|
|
13
|
+
return cmd;
|
|
14
|
+
}
|
|
16
15
|
//#endregion
|
|
17
|
-
export {
|
|
16
|
+
export { dumpSoftwareCommand as default };
|
|
18
17
|
|
|
19
18
|
//# sourceMappingURL=software.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"software.js","names":["opts.
|
|
1
|
+
{"version":3,"file":"software.js","names":["opts.GlobalOptions"],"sources":["../../../src/commands/dump/software.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { createLogger } from \"../../compiler/util\";\nimport { dumpSoftware } from \"../../shared/dump\";\nimport { stdout } from \"node:process\";\nimport * as opts from \"../../shared/basecmd\";\n\nexport default function dumpSoftwareCommand(): Command {\n const cmd = new Command(\"software\").description(\n \"parse sources in current package and dump all software descriptors used by templates\",\n );\n\n opts.addOptions(cmd, opts.GlobalOptions());\n\n cmd.action(async (o) => {\n const logger = createLogger(o.logLevel as string);\n dumpSoftware(logger, stdout);\n });\n\n return cmd;\n}\n"],"mappings":";;;;;;AAMA,SAAwB,sBAA+B;CACrD,MAAM,MAAM,IAAI,QAAQ,WAAW,CAAC,YAClC,uFACD;AAED,YAAgB,KAAKA,eAAoB,CAAC;AAE1C,KAAI,OAAO,OAAO,MAAM;AAEtB,eADe,aAAa,EAAE,SAAmB,EAC5B,OAAO;GAC5B;AAEF,QAAO"}
|
package/dist/commands/test.cjs
CHANGED
|
@@ -3,19 +3,17 @@ const require_util = require("../compiler/util.cjs");
|
|
|
3
3
|
const require_basecmd = require("../shared/basecmd.cjs");
|
|
4
4
|
const require_dump = require("../shared/dump.cjs");
|
|
5
5
|
const require_proc = require("../shared/proc.cjs");
|
|
6
|
-
let
|
|
6
|
+
let commander = require("commander");
|
|
7
7
|
let _milaboratories_tengo_tester = require("@milaboratories/tengo-tester");
|
|
8
8
|
//#region src/commands/test.ts
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const testerArgs = this.argv.length == 0 ? ["./src"] : this.argv;
|
|
18
|
-
const tester = require_proc.spawnEmbed(_milaboratories_tengo_tester.TengoTesterBinaryPath, "run", "--log-level", flags["log-level"], "--artifacts", "-", ...testerArgs);
|
|
9
|
+
function testCommand() {
|
|
10
|
+
const cmd = new commander.Command("test").description("run tengo unit tests (.test.tengo)");
|
|
11
|
+
cmd.argument("[paths...]", "source paths to test (defaults to ./src)");
|
|
12
|
+
require_basecmd.addOptions(cmd, require_basecmd.GlobalOptions());
|
|
13
|
+
cmd.action(async (paths, o) => {
|
|
14
|
+
const logLevel = o.logLevel;
|
|
15
|
+
const logger = require_util.createLogger(logLevel);
|
|
16
|
+
const tester = require_proc.spawnEmbed(_milaboratories_tengo_tester.TengoTesterBinaryPath, "run", "--log-level", logLevel, "--artifacts", "-", ...paths.length == 0 ? ["./src"] : paths);
|
|
19
17
|
try {
|
|
20
18
|
require_dump.dumpArtifacts(logger, tester.stdin);
|
|
21
19
|
} catch (err) {
|
|
@@ -25,9 +23,10 @@ var Test = class Test extends _oclif_core.Command {
|
|
|
25
23
|
const code = await require_proc.waitFor(tester);
|
|
26
24
|
process.exit(code);
|
|
27
25
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
26
|
+
});
|
|
27
|
+
return cmd;
|
|
28
|
+
}
|
|
30
29
|
//#endregion
|
|
31
|
-
exports.default =
|
|
30
|
+
exports.default = testCommand;
|
|
32
31
|
|
|
33
32
|
//# sourceMappingURL=test.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.cjs","names":["Command","
|
|
1
|
+
{"version":3,"file":"test.cjs","names":["Command","GlobalOptions","createLogger","spawnEmbed","TengoTesterBinaryPath","waitFor"],"sources":["../../src/commands/test.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { createLogger } from \"../compiler/util\";\nimport { dumpArtifacts } from \"../shared/dump\";\nimport { addOptions, GlobalOptions } from \"../shared/basecmd\";\nimport { spawnEmbed, waitFor } from \"../shared/proc\";\nimport { TengoTesterBinaryPath } from \"@milaboratories/tengo-tester\";\n\nexport default function testCommand(): Command {\n const cmd = new Command(\"test\").description(\"run tengo unit tests (.test.tengo)\");\n\n cmd.argument(\"[paths...]\", \"source paths to test (defaults to ./src)\");\n addOptions(cmd, GlobalOptions());\n\n cmd.action(async (paths: string[], o) => {\n const logLevel = o.logLevel as string;\n const logger = createLogger(logLevel);\n\n const testerArgs: string[] = paths.length == 0 ? [\"./src\"] : paths;\n\n const tester = spawnEmbed(\n TengoTesterBinaryPath,\n \"run\",\n \"--log-level\",\n logLevel,\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 return cmd;\n}\n"],"mappings":";;;;;;;;AAOA,SAAwB,cAAuB;CAC7C,MAAM,MAAM,IAAIA,UAAAA,QAAQ,OAAO,CAAC,YAAY,qCAAqC;AAEjF,KAAI,SAAS,cAAc,2CAA2C;AACtE,iBAAA,WAAW,KAAKC,gBAAAA,eAAe,CAAC;AAEhC,KAAI,OAAO,OAAO,OAAiB,MAAM;EACvC,MAAM,WAAW,EAAE;EACnB,MAAM,SAASC,aAAAA,aAAa,SAAS;EAIrC,MAAM,SAASC,aAAAA,WACbC,6BAAAA,uBACA,OACA,eACA,UACA,eACA,KACA,GAT2B,MAAM,UAAU,IAAI,CAAC,QAAQ,GAAG,MAU5D;AAED,MAAI;AACF,gBAAA,cAAc,QAAQ,OAAO,MAAM;WAC5B,KAAc;AACrB,UAAO,MAAM,IAAI;YACT;AACR,UAAO,MAAM,KAAK;GAClB,MAAM,OAAO,MAAMC,aAAAA,QAAQ,OAAO;AAClC,WAAQ,KAAK,KAAK;;GAEpB;AAEF,QAAO"}
|
package/dist/commands/test.js
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { createLogger } from "../compiler/util.js";
|
|
2
|
-
import {
|
|
2
|
+
import { GlobalOptions, addOptions } from "../shared/basecmd.js";
|
|
3
3
|
import { dumpArtifacts } from "../shared/dump.js";
|
|
4
4
|
import { spawnEmbed, waitFor } from "../shared/proc.js";
|
|
5
|
-
import { Command } from "
|
|
5
|
+
import { Command } from "commander";
|
|
6
6
|
import { TengoTesterBinaryPath } from "@milaboratories/tengo-tester";
|
|
7
7
|
//#region src/commands/test.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const testerArgs = this.argv.length == 0 ? ["./src"] : this.argv;
|
|
17
|
-
const tester = spawnEmbed(TengoTesterBinaryPath, "run", "--log-level", flags["log-level"], "--artifacts", "-", ...testerArgs);
|
|
8
|
+
function testCommand() {
|
|
9
|
+
const cmd = new Command("test").description("run tengo unit tests (.test.tengo)");
|
|
10
|
+
cmd.argument("[paths...]", "source paths to test (defaults to ./src)");
|
|
11
|
+
addOptions(cmd, GlobalOptions());
|
|
12
|
+
cmd.action(async (paths, o) => {
|
|
13
|
+
const logLevel = o.logLevel;
|
|
14
|
+
const logger = createLogger(logLevel);
|
|
15
|
+
const tester = spawnEmbed(TengoTesterBinaryPath, "run", "--log-level", logLevel, "--artifacts", "-", ...paths.length == 0 ? ["./src"] : paths);
|
|
18
16
|
try {
|
|
19
17
|
dumpArtifacts(logger, tester.stdin);
|
|
20
18
|
} catch (err) {
|
|
@@ -24,9 +22,10 @@ var Test = class Test extends Command {
|
|
|
24
22
|
const code = await waitFor(tester);
|
|
25
23
|
process.exit(code);
|
|
26
24
|
}
|
|
27
|
-
}
|
|
28
|
-
|
|
25
|
+
});
|
|
26
|
+
return cmd;
|
|
27
|
+
}
|
|
29
28
|
//#endregion
|
|
30
|
-
export {
|
|
29
|
+
export { testCommand as default };
|
|
31
30
|
|
|
32
31
|
//# sourceMappingURL=test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","names":[],"sources":["../../src/commands/test.ts"],"sourcesContent":["import { Command } from \"
|
|
1
|
+
{"version":3,"file":"test.js","names":[],"sources":["../../src/commands/test.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { createLogger } from \"../compiler/util\";\nimport { dumpArtifacts } from \"../shared/dump\";\nimport { addOptions, GlobalOptions } from \"../shared/basecmd\";\nimport { spawnEmbed, waitFor } from \"../shared/proc\";\nimport { TengoTesterBinaryPath } from \"@milaboratories/tengo-tester\";\n\nexport default function testCommand(): Command {\n const cmd = new Command(\"test\").description(\"run tengo unit tests (.test.tengo)\");\n\n cmd.argument(\"[paths...]\", \"source paths to test (defaults to ./src)\");\n addOptions(cmd, GlobalOptions());\n\n cmd.action(async (paths: string[], o) => {\n const logLevel = o.logLevel as string;\n const logger = createLogger(logLevel);\n\n const testerArgs: string[] = paths.length == 0 ? [\"./src\"] : paths;\n\n const tester = spawnEmbed(\n TengoTesterBinaryPath,\n \"run\",\n \"--log-level\",\n logLevel,\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 return cmd;\n}\n"],"mappings":";;;;;;;AAOA,SAAwB,cAAuB;CAC7C,MAAM,MAAM,IAAI,QAAQ,OAAO,CAAC,YAAY,qCAAqC;AAEjF,KAAI,SAAS,cAAc,2CAA2C;AACtE,YAAW,KAAK,eAAe,CAAC;AAEhC,KAAI,OAAO,OAAO,OAAiB,MAAM;EACvC,MAAM,WAAW,EAAE;EACnB,MAAM,SAAS,aAAa,SAAS;EAIrC,MAAM,SAAS,WACb,uBACA,OACA,eACA,UACA,eACA,KACA,GAT2B,MAAM,UAAU,IAAI,CAAC,QAAQ,GAAG,MAU5D;AAED,MAAI;AACF,iBAAc,QAAQ,OAAO,MAAM;WAC5B,KAAc;AACrB,UAAO,MAAM,IAAI;YACT;AACR,UAAO,MAAM,KAAK;GAClB,MAAM,OAAO,MAAM,QAAQ,OAAO;AAClC,WAAQ,KAAK,KAAK;;GAEpB;AAEF,QAAO"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const require_artifacts = require("./commands/dump/artifacts.cjs");
|
|
6
|
-
const require_software = require("./commands/dump/software.cjs");
|
|
7
|
-
//#region src/index.ts
|
|
8
|
-
const COMMANDS = {
|
|
9
|
-
build: require_build.default,
|
|
10
|
-
check: require_check.default,
|
|
11
|
-
test: require_test.default,
|
|
12
|
-
"dump:artifacts": require_artifacts.default,
|
|
13
|
-
"dump:software": require_software.default
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
16
|
-
exports.COMMANDS = COMMANDS;
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=index.cjs.map
|
|
2
|
+
const require_cli = require("./cli.cjs");
|
|
3
|
+
exports.buildProgram = require_cli.buildProgram;
|
|
4
|
+
exports.run = require_cli.run;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { Test } from "./commands/test.js";
|
|
4
|
-
import { DumpArtifacts } from "./commands/dump/artifacts.js";
|
|
5
|
-
import { DumpSoftware } from "./commands/dump/software.js";
|
|
6
|
-
|
|
7
|
-
//#region src/index.d.ts
|
|
8
|
-
declare const COMMANDS: {
|
|
9
|
-
build: typeof Build;
|
|
10
|
-
check: typeof Check;
|
|
11
|
-
test: typeof Test;
|
|
12
|
-
"dump:artifacts": typeof DumpArtifacts;
|
|
13
|
-
"dump:software": typeof DumpSoftware;
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
16
|
-
export { COMMANDS };
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
import { buildProgram, run } from "./cli.js";
|
|
2
|
+
export { buildProgram, run };
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import Test from "./commands/test.js";
|
|
4
|
-
import DumpArtifacts from "./commands/dump/artifacts.js";
|
|
5
|
-
import DumpSoftware from "./commands/dump/software.js";
|
|
6
|
-
//#region src/index.ts
|
|
7
|
-
const COMMANDS = {
|
|
8
|
-
build: Build,
|
|
9
|
-
check: Check,
|
|
10
|
-
test: Test,
|
|
11
|
-
"dump:artifacts": DumpArtifacts,
|
|
12
|
-
"dump:software": DumpSoftware
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
export { COMMANDS };
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { buildProgram, run } from "./cli.js";
|
|
2
|
+
export { buildProgram, run };
|
package/dist/shared/basecmd.cjs
CHANGED
|
@@ -1,49 +1,38 @@
|
|
|
1
1
|
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
let
|
|
2
|
+
let commander = require("commander");
|
|
3
3
|
//#region src/shared/basecmd.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"tags
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
description: "artifact type",
|
|
33
|
-
options: [
|
|
34
|
-
"all",
|
|
35
|
-
"library",
|
|
36
|
-
"template",
|
|
37
|
-
"test",
|
|
38
|
-
"software",
|
|
39
|
-
"asset",
|
|
40
|
-
"wasm"
|
|
41
|
-
],
|
|
42
|
-
default: "all"
|
|
43
|
-
}) };
|
|
4
|
+
/** Add one or more groups of options to a command, preserving group order. */
|
|
5
|
+
function addOptions(cmd, ...optionGroups) {
|
|
6
|
+
for (const group of optionGroups) for (const opt of group) cmd.addOption(opt);
|
|
7
|
+
return cmd;
|
|
8
|
+
}
|
|
9
|
+
function collectComma(value, previous) {
|
|
10
|
+
return previous.concat(value.split(","));
|
|
11
|
+
}
|
|
12
|
+
const GlobalOptions = () => [new commander.Option("--log-level <level>", "logging level").choices([
|
|
13
|
+
"error",
|
|
14
|
+
"warn",
|
|
15
|
+
"info",
|
|
16
|
+
"debug"
|
|
17
|
+
]).default("info")];
|
|
18
|
+
const CtagsOptions = () => [
|
|
19
|
+
new commander.Option("--generate-tags", "generate tags, default false").default(false),
|
|
20
|
+
new commander.Option("--tags-file <path>", "where to put \".tags\" file, it should be a root of VS Code project").default("../../.tags"),
|
|
21
|
+
new commander.Option("--tags-additional-args <args>", "additional flags for universal-ctags command: e.g. -e for emacs").argParser(collectComma).default([])
|
|
22
|
+
];
|
|
23
|
+
const ArtifactTypeOptions = () => [new commander.Option("-t, --type <type>", "artifact type").choices([
|
|
24
|
+
"all",
|
|
25
|
+
"library",
|
|
26
|
+
"template",
|
|
27
|
+
"test",
|
|
28
|
+
"software",
|
|
29
|
+
"asset",
|
|
30
|
+
"wasm"
|
|
31
|
+
]).default("all")];
|
|
44
32
|
//#endregion
|
|
45
|
-
exports.
|
|
46
|
-
exports.
|
|
47
|
-
exports.
|
|
33
|
+
exports.ArtifactTypeOptions = ArtifactTypeOptions;
|
|
34
|
+
exports.CtagsOptions = CtagsOptions;
|
|
35
|
+
exports.GlobalOptions = GlobalOptions;
|
|
36
|
+
exports.addOptions = addOptions;
|
|
48
37
|
|
|
49
38
|
//# sourceMappingURL=basecmd.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basecmd.cjs","names":["
|
|
1
|
+
{"version":3,"file":"basecmd.cjs","names":["Option"],"sources":["../../src/shared/basecmd.ts"],"sourcesContent":["import { Command, Option } from \"commander\";\n\n/** Add one or more groups of options to a command, preserving group order. */\nexport function addOptions(cmd: Command, ...optionGroups: Option[][]): Command {\n for (const group of optionGroups) {\n for (const opt of group) cmd.addOption(opt);\n }\n return cmd;\n}\n\n// Comma-delimited, repeatable collector: `--tags-additional-args -e,-x` and/or\n// repeated occurrences accumulate into a single string[].\nfunction collectComma(value: string, previous: string[]): string[] {\n return previous.concat(value.split(\",\"));\n}\n\nexport const GlobalOptions = (): Option[] => [\n new Option(\"--log-level <level>\", \"logging level\")\n .choices([\"error\", \"warn\", \"info\", \"debug\"])\n .default(\"info\"),\n];\n\nexport const CtagsOptions = (): Option[] => [\n new Option(\"--generate-tags\", \"generate tags, default false\").default(false),\n new Option(\n \"--tags-file <path>\",\n 'where to put \".tags\" file, it should be a root of VS Code project',\n ).default(\"../../.tags\"), // usually a user opens a directory with all blocks\n new Option(\n \"--tags-additional-args <args>\",\n \"additional flags for universal-ctags command: e.g. -e for emacs\",\n )\n .argParser(collectComma)\n .default([] as string[]),\n];\n\nexport const ArtifactTypeOptions = (): Option[] => [\n new Option(\"-t, --type <type>\", \"artifact type\")\n .choices([\"all\", \"library\", \"template\", \"test\", \"software\", \"asset\", \"wasm\"])\n .default(\"all\"),\n];\n"],"mappings":";;;;AAGA,SAAgB,WAAW,KAAc,GAAG,cAAmC;AAC7E,MAAK,MAAM,SAAS,aAClB,MAAK,MAAM,OAAO,MAAO,KAAI,UAAU,IAAI;AAE7C,QAAO;;AAKT,SAAS,aAAa,OAAe,UAA8B;AACjE,QAAO,SAAS,OAAO,MAAM,MAAM,IAAI,CAAC;;AAG1C,MAAa,sBAAgC,CAC3C,IAAIA,UAAAA,OAAO,uBAAuB,gBAAgB,CAC/C,QAAQ;CAAC;CAAS;CAAQ;CAAQ;CAAQ,CAAC,CAC3C,QAAQ,OAAO,CACnB;AAED,MAAa,qBAA+B;CAC1C,IAAIA,UAAAA,OAAO,mBAAmB,+BAA+B,CAAC,QAAQ,MAAM;CAC5E,IAAIA,UAAAA,OACF,sBACA,sEACD,CAAC,QAAQ,cAAc;CACxB,IAAIA,UAAAA,OACF,iCACA,kEACD,CACE,UAAU,aAAa,CACvB,QAAQ,EAAE,CAAa;CAC3B;AAED,MAAa,4BAAsC,CACjD,IAAIA,UAAAA,OAAO,qBAAqB,gBAAgB,CAC7C,QAAQ;CAAC;CAAO;CAAW;CAAY;CAAQ;CAAY;CAAS;CAAO,CAAC,CAC5E,QAAQ,MAAM,CAClB"}
|
package/dist/shared/basecmd.js
CHANGED
|
@@ -1,46 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Option } from "commander";
|
|
2
2
|
//#region src/shared/basecmd.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"tags
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
description: "artifact type",
|
|
32
|
-
options: [
|
|
33
|
-
"all",
|
|
34
|
-
"library",
|
|
35
|
-
"template",
|
|
36
|
-
"test",
|
|
37
|
-
"software",
|
|
38
|
-
"asset",
|
|
39
|
-
"wasm"
|
|
40
|
-
],
|
|
41
|
-
default: "all"
|
|
42
|
-
}) };
|
|
3
|
+
/** Add one or more groups of options to a command, preserving group order. */
|
|
4
|
+
function addOptions(cmd, ...optionGroups) {
|
|
5
|
+
for (const group of optionGroups) for (const opt of group) cmd.addOption(opt);
|
|
6
|
+
return cmd;
|
|
7
|
+
}
|
|
8
|
+
function collectComma(value, previous) {
|
|
9
|
+
return previous.concat(value.split(","));
|
|
10
|
+
}
|
|
11
|
+
const GlobalOptions = () => [new Option("--log-level <level>", "logging level").choices([
|
|
12
|
+
"error",
|
|
13
|
+
"warn",
|
|
14
|
+
"info",
|
|
15
|
+
"debug"
|
|
16
|
+
]).default("info")];
|
|
17
|
+
const CtagsOptions = () => [
|
|
18
|
+
new Option("--generate-tags", "generate tags, default false").default(false),
|
|
19
|
+
new Option("--tags-file <path>", "where to put \".tags\" file, it should be a root of VS Code project").default("../../.tags"),
|
|
20
|
+
new Option("--tags-additional-args <args>", "additional flags for universal-ctags command: e.g. -e for emacs").argParser(collectComma).default([])
|
|
21
|
+
];
|
|
22
|
+
const ArtifactTypeOptions = () => [new Option("-t, --type <type>", "artifact type").choices([
|
|
23
|
+
"all",
|
|
24
|
+
"library",
|
|
25
|
+
"template",
|
|
26
|
+
"test",
|
|
27
|
+
"software",
|
|
28
|
+
"asset",
|
|
29
|
+
"wasm"
|
|
30
|
+
]).default("all")];
|
|
43
31
|
//#endregion
|
|
44
|
-
export {
|
|
32
|
+
export { ArtifactTypeOptions, CtagsOptions, GlobalOptions, addOptions };
|
|
45
33
|
|
|
46
34
|
//# sourceMappingURL=basecmd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basecmd.js","names":[],"sources":["../../src/shared/basecmd.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"basecmd.js","names":[],"sources":["../../src/shared/basecmd.ts"],"sourcesContent":["import { Command, Option } from \"commander\";\n\n/** Add one or more groups of options to a command, preserving group order. */\nexport function addOptions(cmd: Command, ...optionGroups: Option[][]): Command {\n for (const group of optionGroups) {\n for (const opt of group) cmd.addOption(opt);\n }\n return cmd;\n}\n\n// Comma-delimited, repeatable collector: `--tags-additional-args -e,-x` and/or\n// repeated occurrences accumulate into a single string[].\nfunction collectComma(value: string, previous: string[]): string[] {\n return previous.concat(value.split(\",\"));\n}\n\nexport const GlobalOptions = (): Option[] => [\n new Option(\"--log-level <level>\", \"logging level\")\n .choices([\"error\", \"warn\", \"info\", \"debug\"])\n .default(\"info\"),\n];\n\nexport const CtagsOptions = (): Option[] => [\n new Option(\"--generate-tags\", \"generate tags, default false\").default(false),\n new Option(\n \"--tags-file <path>\",\n 'where to put \".tags\" file, it should be a root of VS Code project',\n ).default(\"../../.tags\"), // usually a user opens a directory with all blocks\n new Option(\n \"--tags-additional-args <args>\",\n \"additional flags for universal-ctags command: e.g. -e for emacs\",\n )\n .argParser(collectComma)\n .default([] as string[]),\n];\n\nexport const ArtifactTypeOptions = (): Option[] => [\n new Option(\"-t, --type <type>\", \"artifact type\")\n .choices([\"all\", \"library\", \"template\", \"test\", \"software\", \"asset\", \"wasm\"])\n .default(\"all\"),\n];\n"],"mappings":";;;AAGA,SAAgB,WAAW,KAAc,GAAG,cAAmC;AAC7E,MAAK,MAAM,SAAS,aAClB,MAAK,MAAM,OAAO,MAAO,KAAI,UAAU,IAAI;AAE7C,QAAO;;AAKT,SAAS,aAAa,OAAe,UAA8B;AACjE,QAAO,SAAS,OAAO,MAAM,MAAM,IAAI,CAAC;;AAG1C,MAAa,sBAAgC,CAC3C,IAAI,OAAO,uBAAuB,gBAAgB,CAC/C,QAAQ;CAAC;CAAS;CAAQ;CAAQ;CAAQ,CAAC,CAC3C,QAAQ,OAAO,CACnB;AAED,MAAa,qBAA+B;CAC1C,IAAI,OAAO,mBAAmB,+BAA+B,CAAC,QAAQ,MAAM;CAC5E,IAAI,OACF,sBACA,sEACD,CAAC,QAAQ,cAAc;CACxB,IAAI,OACF,iCACA,kEACD,CACE,UAAU,aAAa,CACvB,QAAQ,EAAE,CAAa;CAC3B;AAED,MAAa,4BAAsC,CACjD,IAAI,OAAO,qBAAqB,gBAAgB,CAC7C,QAAQ;CAAC;CAAO;CAAW;CAAY;CAAQ;CAAY;CAAS;CAAO,CAAC,CAC5E,QAAQ,MAAM,CAClB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/tengo-builder",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.10",
|
|
4
4
|
"description": "Pl Tengo Template Builder",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"bin": {
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"type": "module",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@milaboratories/tengo-tester": "^1.6.4",
|
|
17
|
-
"
|
|
17
|
+
"commander": "^15.0.0",
|
|
18
18
|
"winston": "^3.17.0",
|
|
19
|
+
"@milaboratories/ts-helpers": "1.8.3",
|
|
19
20
|
"@milaboratories/pl-model-backend": "1.4.8",
|
|
20
|
-
"@milaboratories/resolve-helper": "1.1.3"
|
|
21
|
-
"@milaboratories/ts-helpers": "1.8.3"
|
|
21
|
+
"@milaboratories/resolve-helper": "1.1.3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "~24.5.2",
|
|
@@ -26,25 +26,14 @@
|
|
|
26
26
|
"typescript": "~5.9.3",
|
|
27
27
|
"vitest": "^4.1.3",
|
|
28
28
|
"@milaboratories/build-configs": "2.0.0",
|
|
29
|
-
"@milaboratories/
|
|
30
|
-
"@milaboratories/ts-configs": "1.2.3"
|
|
31
|
-
"@milaboratories/ts-builder": "1.5.2"
|
|
32
|
-
},
|
|
33
|
-
"oclif": {
|
|
34
|
-
"bin": "pl-tengo",
|
|
35
|
-
"commands": {
|
|
36
|
-
"identifier": "COMMANDS",
|
|
37
|
-
"strategy": "explicit",
|
|
38
|
-
"target": "./dist/index.js"
|
|
39
|
-
},
|
|
40
|
-
"dirname": "pl-tengo",
|
|
41
|
-
"topicSeparator": " "
|
|
29
|
+
"@milaboratories/ts-builder": "1.5.2",
|
|
30
|
+
"@milaboratories/ts-configs": "1.2.3"
|
|
42
31
|
},
|
|
43
32
|
"engines": {
|
|
44
33
|
"node": ">=22"
|
|
45
34
|
},
|
|
46
35
|
"scripts": {
|
|
47
|
-
"build": "
|
|
36
|
+
"build": "node --run fmt && ts-builder build --target node",
|
|
48
37
|
"watch": "ts-builder build --target node --watch",
|
|
49
38
|
"check": "ts-builder check --target node",
|
|
50
39
|
"formatter:check": "ts-builder formatter --check",
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import buildCommand from "./commands/build";
|
|
3
|
+
import checkCommand from "./commands/check";
|
|
4
|
+
import testCommand from "./commands/test";
|
|
5
|
+
import dumpArtifactsCommand from "./commands/dump/artifacts";
|
|
6
|
+
import dumpSoftwareCommand from "./commands/dump/software";
|
|
7
|
+
|
|
8
|
+
export function buildProgram(): Command {
|
|
9
|
+
const program = new Command();
|
|
10
|
+
program.name("pl-tengo").description("Pl Tengo Template Builder");
|
|
11
|
+
|
|
12
|
+
program.addCommand(buildCommand());
|
|
13
|
+
program.addCommand(checkCommand());
|
|
14
|
+
program.addCommand(testCommand());
|
|
15
|
+
|
|
16
|
+
// `dump` is a pure topic (no action): `pl-tengo dump` prints help.
|
|
17
|
+
const dump = new Command("dump").description("dump parsed artifacts or software descriptors");
|
|
18
|
+
dump.addCommand(dumpArtifactsCommand());
|
|
19
|
+
dump.addCommand(dumpSoftwareCommand());
|
|
20
|
+
program.addCommand(dump);
|
|
21
|
+
|
|
22
|
+
return program;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function run(argv: string[] = process.argv): Promise<void> {
|
|
26
|
+
await buildProgram().parseAsync(argv);
|
|
27
|
+
}
|
package/src/commands/build.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SpawnSyncReturns } from "node:child_process";
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
|
-
import { Command } from "
|
|
3
|
+
import { Command } from "commander";
|
|
4
4
|
import { compile, savePacks, getPackageInfo } from "../compiler/main";
|
|
5
5
|
import { createLogger } from "../compiler/util";
|
|
6
6
|
import * as opts from "../shared/basecmd";
|
|
@@ -10,18 +10,20 @@ import * as path from "node:path";
|
|
|
10
10
|
import type * as winston from "winston";
|
|
11
11
|
import type { TemplatesAndLibs } from "../compiler/compiler";
|
|
12
12
|
|
|
13
|
-
export default
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
export default function buildCommand(): Command {
|
|
14
|
+
const cmd = new Command("build").description(
|
|
15
|
+
"build tengo sources into single distributable pack file",
|
|
16
|
+
);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
...opts.GlobalFlags,
|
|
20
|
-
...opts.CtagsFlags,
|
|
21
|
-
};
|
|
18
|
+
opts.addOptions(cmd, opts.GlobalOptions(), opts.CtagsOptions());
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
const
|
|
20
|
+
cmd.action(async (o) => {
|
|
21
|
+
const flags = {
|
|
22
|
+
"log-level": o.logLevel as string,
|
|
23
|
+
"generate-tags": o.generateTags as boolean,
|
|
24
|
+
"tags-file": o.tagsFile as string,
|
|
25
|
+
"tags-additional-args": o.tagsAdditionalArgs as string[],
|
|
26
|
+
};
|
|
25
27
|
const logger = createLogger(flags["log-level"]);
|
|
26
28
|
|
|
27
29
|
const packageInfo = getPackageInfo(process.cwd(), logger);
|
|
@@ -44,7 +46,9 @@ export default class Build extends Command {
|
|
|
44
46
|
if (flags["generate-tags"]) checkAndGenerateCtags(logger, flags);
|
|
45
47
|
|
|
46
48
|
logger.info("Template Pack build done.");
|
|
47
|
-
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return cmd;
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
function generateTsBinding(compiledDist: TemplatesAndLibs) {
|
package/src/commands/check.ts
CHANGED
|
@@ -1,34 +1,27 @@
|
|
|
1
|
-
import { Command } from "
|
|
1
|
+
import { Command } from "commander";
|
|
2
2
|
import { createLogger } from "../compiler/util";
|
|
3
3
|
import { dumpArtifacts } from "../shared/dump";
|
|
4
|
-
import {
|
|
4
|
+
import { addOptions, GlobalOptions } from "../shared/basecmd";
|
|
5
5
|
import { spawnEmbed, waitFor } from "../shared/proc";
|
|
6
6
|
import { TengoTesterBinaryPath } from "@milaboratories/tengo-tester";
|
|
7
7
|
|
|
8
|
-
export default
|
|
9
|
-
|
|
8
|
+
export default function checkCommand(): Command {
|
|
9
|
+
const cmd = new Command("check").description("check tengo sources for language processor an");
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// }
|
|
11
|
+
cmd.argument("[paths...]", "source paths to check (defaults to ./src)");
|
|
12
|
+
addOptions(cmd, GlobalOptions());
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
cmd.action(async (paths: string[], o) => {
|
|
15
|
+
const logLevel = o.logLevel as string;
|
|
16
|
+
const logger = createLogger(logLevel);
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
static override examples = ["<%= config.bin %> <%= command.id %>"];
|
|
20
|
-
|
|
21
|
-
public async run(): Promise<void> {
|
|
22
|
-
const { flags, argv } = await this.parse(Check);
|
|
23
|
-
const logger = createLogger(flags["log-level"]);
|
|
24
|
-
|
|
25
|
-
const testerArgs: string[] = argv.length == 0 ? ["./src"] : (argv as string[]);
|
|
18
|
+
const testerArgs: string[] = paths.length == 0 ? ["./src"] : paths;
|
|
26
19
|
|
|
27
20
|
const tester = spawnEmbed(
|
|
28
21
|
TengoTesterBinaryPath,
|
|
29
22
|
"check",
|
|
30
23
|
"--log-level",
|
|
31
|
-
|
|
24
|
+
logLevel,
|
|
32
25
|
"--artifacts",
|
|
33
26
|
"-",
|
|
34
27
|
...testerArgs,
|
|
@@ -43,5 +36,7 @@ export default class Check extends Command {
|
|
|
43
36
|
const code = await waitFor(tester);
|
|
44
37
|
process.exit(code);
|
|
45
38
|
}
|
|
46
|
-
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return cmd;
|
|
47
42
|
}
|