@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.
Files changed (56) hide show
  1. package/bin/run.js +5 -10
  2. package/dist/cli.cjs +28 -0
  3. package/dist/cli.cjs.map +1 -0
  4. package/dist/cli.d.ts +8 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +26 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/commands/build.cjs +15 -13
  9. package/dist/commands/build.cjs.map +1 -1
  10. package/dist/commands/build.js +16 -14
  11. package/dist/commands/build.js.map +1 -1
  12. package/dist/commands/check.cjs +13 -14
  13. package/dist/commands/check.cjs.map +1 -1
  14. package/dist/commands/check.js +14 -15
  15. package/dist/commands/check.js.map +1 -1
  16. package/dist/commands/dump/artifacts.cjs +10 -14
  17. package/dist/commands/dump/artifacts.cjs.map +1 -1
  18. package/dist/commands/dump/artifacts.js +11 -15
  19. package/dist/commands/dump/artifacts.js.map +1 -1
  20. package/dist/commands/dump/software.cjs +10 -11
  21. package/dist/commands/dump/software.cjs.map +1 -1
  22. package/dist/commands/dump/software.js +11 -12
  23. package/dist/commands/dump/software.js.map +1 -1
  24. package/dist/commands/test.cjs +13 -14
  25. package/dist/commands/test.cjs.map +1 -1
  26. package/dist/commands/test.js +14 -15
  27. package/dist/commands/test.js.map +1 -1
  28. package/dist/index.cjs +3 -17
  29. package/dist/index.d.ts +2 -17
  30. package/dist/index.js +2 -17
  31. package/dist/shared/basecmd.cjs +33 -44
  32. package/dist/shared/basecmd.cjs.map +1 -1
  33. package/dist/shared/basecmd.js +30 -42
  34. package/dist/shared/basecmd.js.map +1 -1
  35. package/package.json +7 -18
  36. package/src/cli.ts +27 -0
  37. package/src/commands/build.ts +16 -12
  38. package/src/commands/check.ts +14 -19
  39. package/src/commands/dump/artifacts.ts +11 -14
  40. package/src/commands/dump/software.ts +11 -13
  41. package/src/commands/test.ts +14 -15
  42. package/src/index.ts +1 -15
  43. package/src/shared/basecmd.ts +36 -32
  44. package/dist/commands/build.d.ts +0 -18
  45. package/dist/commands/build.d.ts.map +0 -1
  46. package/dist/commands/check.d.ts +0 -16
  47. package/dist/commands/check.d.ts.map +0 -1
  48. package/dist/commands/dump/artifacts.d.ts +0 -16
  49. package/dist/commands/dump/artifacts.d.ts.map +0 -1
  50. package/dist/commands/dump/software.d.ts +0 -15
  51. package/dist/commands/dump/software.d.ts.map +0 -1
  52. package/dist/commands/test.d.ts +0 -16
  53. package/dist/commands/test.d.ts.map +0 -1
  54. package/dist/index.cjs.map +0 -1
  55. package/dist/index.d.ts.map +0 -1
  56. package/dist/index.js.map +0 -1
@@ -1,24 +1,21 @@
1
- import { Command } from "@oclif/core";
1
+ import { Command } from "commander";
2
2
  import { createLogger } from "../../compiler/util";
3
3
  import { dumpArtifacts } from "../../shared/dump";
4
4
  import { stdout } from "node:process";
5
5
  import type { ArtifactType } from "../../compiler/package";
6
6
  import * as opts from "../../shared/basecmd";
7
7
 
8
- export default class DumpArtifacts extends Command {
9
- static override description =
10
- "parse sources in current package and dump all found artifacts to stdout";
8
+ export default function dumpArtifactsCommand(): Command {
9
+ const cmd = new Command("artifacts").description(
10
+ "parse sources in current package and dump all found artifacts to stdout",
11
+ );
11
12
 
12
- static override examples = ["<%= config.bin %> <%= command.id %>"];
13
+ opts.addOptions(cmd, opts.GlobalOptions(), opts.ArtifactTypeOptions());
13
14
 
14
- static override flags = {
15
- ...opts.GlobalFlags,
16
- ...opts.ArtifactTypeFlag,
17
- };
15
+ cmd.action(async (o) => {
16
+ const logger = createLogger(o.logLevel as string);
17
+ dumpArtifacts(logger, stdout, o.type == "all" ? undefined : (o.type as ArtifactType));
18
+ });
18
19
 
19
- public async run(): Promise<void> {
20
- const { flags } = await this.parse(DumpArtifacts);
21
- const logger = createLogger(flags["log-level"]);
22
- dumpArtifacts(logger, stdout, flags.type == "all" ? undefined : (flags.type as ArtifactType));
23
- }
20
+ return cmd;
24
21
  }
@@ -1,22 +1,20 @@
1
- import { Command } from "@oclif/core";
1
+ import { Command } from "commander";
2
2
  import { createLogger } from "../../compiler/util";
3
3
  import { dumpSoftware } from "../../shared/dump";
4
4
  import { stdout } from "node:process";
5
5
  import * as opts from "../../shared/basecmd";
6
6
 
7
- export default class DumpSoftware extends Command {
8
- static override description =
9
- "parse sources in current package and dump all software descriptors used by templates";
7
+ export default function dumpSoftwareCommand(): Command {
8
+ const cmd = new Command("software").description(
9
+ "parse sources in current package and dump all software descriptors used by templates",
10
+ );
10
11
 
11
- static override examples = ["<%= config.bin %> <%= command.id %>"];
12
+ opts.addOptions(cmd, opts.GlobalOptions());
12
13
 
13
- static override flags = {
14
- ...opts.GlobalFlags,
15
- };
16
-
17
- public async run(): Promise<void> {
18
- const { flags } = await this.parse(DumpSoftware);
19
- const logger = createLogger(flags["log-level"]);
14
+ cmd.action(async (o) => {
15
+ const logger = createLogger(o.logLevel as string);
20
16
  dumpSoftware(logger, stdout);
21
- }
17
+ });
18
+
19
+ return cmd;
22
20
  }
@@ -1,30 +1,27 @@
1
- import { Command } from "@oclif/core";
1
+ import { Command } from "commander";
2
2
  import { createLogger } from "../compiler/util";
3
3
  import { dumpArtifacts } from "../shared/dump";
4
- import { GlobalFlags } from "../shared/basecmd";
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 class Test extends Command {
9
- static override description = "run tengo unit tests (.test.tengo)";
8
+ export default function testCommand(): Command {
9
+ const cmd = new Command("test").description("run tengo unit tests (.test.tengo)");
10
10
 
11
- static strict = false;
11
+ cmd.argument("[paths...]", "source paths to test (defaults to ./src)");
12
+ addOptions(cmd, GlobalOptions());
12
13
 
13
- static override flags = { ...GlobalFlags };
14
+ cmd.action(async (paths: string[], o) => {
15
+ const logLevel = o.logLevel as string;
16
+ const logger = createLogger(logLevel);
14
17
 
15
- static override examples = ["<%= config.bin %> <%= command.id %>"];
16
-
17
- public async run(): Promise<void> {
18
- const { flags } = await this.parse(Test);
19
- const logger = createLogger(flags["log-level"]);
20
-
21
- const testerArgs: string[] = this.argv.length == 0 ? ["./src"] : this.argv;
18
+ const testerArgs: string[] = paths.length == 0 ? ["./src"] : paths;
22
19
 
23
20
  const tester = spawnEmbed(
24
21
  TengoTesterBinaryPath,
25
22
  "run",
26
23
  "--log-level",
27
- flags["log-level"],
24
+ logLevel,
28
25
  "--artifacts",
29
26
  "-",
30
27
  ...testerArgs,
@@ -39,5 +36,7 @@ export default class Test extends Command {
39
36
  const code = await waitFor(tester);
40
37
  process.exit(code);
41
38
  }
42
- }
39
+ });
40
+
41
+ return cmd;
43
42
  }
package/src/index.ts CHANGED
@@ -1,15 +1 @@
1
- // DO NOT EDIT. This file was generated by oclif-index utility.
2
-
3
- import Cmd0 from "./commands/build";
4
- import Cmd1 from "./commands/check";
5
- import Cmd2 from "./commands/test";
6
- import Cmd3 from "./commands/dump/artifacts";
7
- import Cmd4 from "./commands/dump/software";
8
-
9
- export const COMMANDS = {
10
- build: Cmd0,
11
- check: Cmd1,
12
- test: Cmd2,
13
- "dump:artifacts": Cmd3,
14
- "dump:software": Cmd4,
15
- };
1
+ export { run, buildProgram } from "./cli";
@@ -1,37 +1,41 @@
1
- import { Flags } from "@oclif/core";
1
+ import { Command, Option } from "commander";
2
2
 
3
- export const GlobalFlags = {
4
- "log-level": Flags.string({
5
- description: "logging level",
6
- default: "info",
7
- options: ["error", "warn", "info", "debug"],
8
- }),
9
- };
3
+ /** Add one or more groups of options to a command, preserving group order. */
4
+ export function addOptions(cmd: Command, ...optionGroups: Option[][]): Command {
5
+ for (const group of optionGroups) {
6
+ for (const opt of group) cmd.addOption(opt);
7
+ }
8
+ return cmd;
9
+ }
10
10
 
11
- export const CtagsFlags = {
12
- "generate-tags": Flags.boolean({
13
- description: "generate tags, default false",
14
- default: false,
15
- }),
11
+ // Comma-delimited, repeatable collector: `--tags-additional-args -e,-x` and/or
12
+ // repeated occurrences accumulate into a single string[].
13
+ function collectComma(value: string, previous: string[]): string[] {
14
+ return previous.concat(value.split(","));
15
+ }
16
16
 
17
- "tags-file": Flags.file({
18
- description: 'where to put ".tags" file, it should be a root of VS Code project',
19
- default: "../../.tags", // usually a user opens a directory with all blocks
20
- }),
17
+ export const GlobalOptions = (): Option[] => [
18
+ new Option("--log-level <level>", "logging level")
19
+ .choices(["error", "warn", "info", "debug"])
20
+ .default("info"),
21
+ ];
21
22
 
22
- "tags-additional-args": Flags.string({
23
- description: "additional flags for universal-ctags command: e.g. -e for emacs",
24
- default: [],
25
- multiple: true,
26
- delimiter: ",",
27
- }),
28
- };
23
+ export const CtagsOptions = (): Option[] => [
24
+ new Option("--generate-tags", "generate tags, default false").default(false),
25
+ new Option(
26
+ "--tags-file <path>",
27
+ 'where to put ".tags" file, it should be a root of VS Code project',
28
+ ).default("../../.tags"), // usually a user opens a directory with all blocks
29
+ new Option(
30
+ "--tags-additional-args <args>",
31
+ "additional flags for universal-ctags command: e.g. -e for emacs",
32
+ )
33
+ .argParser(collectComma)
34
+ .default([] as string[]),
35
+ ];
29
36
 
30
- export const ArtifactTypeFlag = {
31
- type: Flags.string({
32
- aliases: ["t"],
33
- description: "artifact type",
34
- options: ["all", "library", "template", "test", "software", "asset", "wasm"],
35
- default: "all",
36
- }),
37
- };
37
+ export const ArtifactTypeOptions = (): Option[] => [
38
+ new Option("-t, --type <type>", "artifact type")
39
+ .choices(["all", "library", "template", "test", "software", "asset", "wasm"])
40
+ .default("all"),
41
+ ];
@@ -1,18 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- import * as _$_oclif_core_interfaces0 from "@oclif/core/interfaces";
3
-
4
- //#region src/commands/build.d.ts
5
- declare class Build extends Command {
6
- static description: string;
7
- static examples: string[];
8
- static flags: {
9
- "generate-tags": _$_oclif_core_interfaces0.BooleanFlag<boolean>;
10
- "tags-file": _$_oclif_core_interfaces0.OptionFlag<string, _$_oclif_core_interfaces0.CustomOptions>;
11
- "tags-additional-args": _$_oclif_core_interfaces0.OptionFlag<string[], _$_oclif_core_interfaces0.CustomOptions>;
12
- "log-level": _$_oclif_core_interfaces0.OptionFlag<string, _$_oclif_core_interfaces0.CustomOptions>;
13
- };
14
- run(): Promise<void>;
15
- }
16
- //#endregion
17
- export { Build };
18
- //# sourceMappingURL=build.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.d.ts","names":[],"sources":["../../src/commands/build.ts"],"mappings":";;;;cAYqB,KAAA,SAAc,OAAA;EAAA,OACjB,WAAA;EAAA,OAEA,QAAA;EAAA,OAEA,KAAA;qBALS,yBAAA,CAAA,WAAA;;;;;EAUZ,GAAA,CAAA,GAAO,OAAA;AAAA"}
@@ -1,16 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- import * as _$_oclif_core_interfaces0 from "@oclif/core/interfaces";
3
-
4
- //#region src/commands/check.d.ts
5
- declare class Check extends Command {
6
- static description: string;
7
- static strict: boolean;
8
- static flags: {
9
- "log-level": _$_oclif_core_interfaces0.OptionFlag<string, _$_oclif_core_interfaces0.CustomOptions>;
10
- };
11
- static examples: string[];
12
- run(): Promise<void>;
13
- }
14
- //#endregion
15
- export { Check };
16
- //# sourceMappingURL=check.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"check.d.ts","names":[],"sources":["../../src/commands/check.ts"],"mappings":";;;;cAOqB,KAAA,SAAc,OAAA;EAAA,OACjB,WAAA;EAAA,OAMT,MAAA;EAAA,OAES,KAAA;8DATS,yBAAA,CAAA,aAAA;EAAA;EAAA,OAWT,QAAA;EAEH,GAAA,CAAA,GAAO,OAAA;AAAA"}
@@ -1,16 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- import * as _$_oclif_core_interfaces0 from "@oclif/core/interfaces";
3
-
4
- //#region src/commands/dump/artifacts.d.ts
5
- declare class DumpArtifacts extends Command {
6
- static description: string;
7
- static examples: string[];
8
- static flags: {
9
- type: _$_oclif_core_interfaces0.OptionFlag<string, _$_oclif_core_interfaces0.CustomOptions>;
10
- "log-level": _$_oclif_core_interfaces0.OptionFlag<string, _$_oclif_core_interfaces0.CustomOptions>;
11
- };
12
- run(): Promise<void>;
13
- }
14
- //#endregion
15
- export { DumpArtifacts };
16
- //# sourceMappingURL=artifacts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"artifacts.d.ts","names":[],"sources":["../../../src/commands/dump/artifacts.ts"],"mappings":";;;;cAOqB,aAAA,SAAsB,OAAA;EAAA,OACzB,WAAA;EAAA,OAGA,QAAA;EAAA,OAEA,KAAA;uDANiB,yBAAA,CAAA,aAAA;;;EAWpB,GAAA,CAAA,GAAO,OAAA;AAAA"}
@@ -1,15 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- import * as _$_oclif_core_interfaces0 from "@oclif/core/interfaces";
3
-
4
- //#region src/commands/dump/software.d.ts
5
- declare class DumpSoftware extends Command {
6
- static description: string;
7
- static examples: string[];
8
- static flags: {
9
- "log-level": _$_oclif_core_interfaces0.OptionFlag<string, _$_oclif_core_interfaces0.CustomOptions>;
10
- };
11
- run(): Promise<void>;
12
- }
13
- //#endregion
14
- export { DumpSoftware };
15
- //# sourceMappingURL=software.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"software.d.ts","names":[],"sources":["../../../src/commands/dump/software.ts"],"mappings":";;;;cAMqB,YAAA,SAAqB,OAAA;EAAA,OACxB,WAAA;EAAA,OAGA,QAAA;EAAA,OAEA,KAAA;8DANgB,yBAAA,CAAA,aAAA;EAAA;EAUnB,GAAA,CAAA,GAAO,OAAA;AAAA"}
@@ -1,16 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- import * as _$_oclif_core_interfaces0 from "@oclif/core/interfaces";
3
-
4
- //#region src/commands/test.d.ts
5
- declare class Test extends Command {
6
- static description: string;
7
- static strict: boolean;
8
- static flags: {
9
- "log-level": _$_oclif_core_interfaces0.OptionFlag<string, _$_oclif_core_interfaces0.CustomOptions>;
10
- };
11
- static examples: string[];
12
- run(): Promise<void>;
13
- }
14
- //#endregion
15
- export { Test };
16
- //# sourceMappingURL=test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test.d.ts","names":[],"sources":["../../src/commands/test.ts"],"mappings":";;;;cAOqB,IAAA,SAAa,OAAA;EAAA,OAChB,WAAA;EAAA,OAET,MAAA;EAAA,OAES,KAAA;8DALQ,yBAAA,CAAA,aAAA;EAAA;EAAA,OAOR,QAAA;EAEH,GAAA,CAAA,GAAO,OAAA;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["Cmd0","Cmd1","Cmd2","Cmd3","Cmd4"],"sources":["../src/index.ts"],"sourcesContent":["// DO NOT EDIT. This file was generated by oclif-index utility.\n\nimport Cmd0 from \"./commands/build\";\nimport Cmd1 from \"./commands/check\";\nimport Cmd2 from \"./commands/test\";\nimport Cmd3 from \"./commands/dump/artifacts\";\nimport Cmd4 from \"./commands/dump/software\";\n\nexport const COMMANDS = {\n build: Cmd0,\n check: Cmd1,\n test: Cmd2,\n \"dump:artifacts\": Cmd3,\n \"dump:software\": Cmd4,\n};\n"],"mappings":";;;;;;;AAQA,MAAa,WAAW;CACtB,OAAOA,cAAAA;CACP,OAAOC,cAAAA;CACP,MAAMC,aAAAA;CACN,kBAAkBC,kBAAAA;CAClB,iBAAiBC,iBAAAA;CAClB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;cAQa,QAAA"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["Cmd0","Cmd1","Cmd2","Cmd3","Cmd4"],"sources":["../src/index.ts"],"sourcesContent":["// DO NOT EDIT. This file was generated by oclif-index utility.\n\nimport Cmd0 from \"./commands/build\";\nimport Cmd1 from \"./commands/check\";\nimport Cmd2 from \"./commands/test\";\nimport Cmd3 from \"./commands/dump/artifacts\";\nimport Cmd4 from \"./commands/dump/software\";\n\nexport const COMMANDS = {\n build: Cmd0,\n check: Cmd1,\n test: Cmd2,\n \"dump:artifacts\": Cmd3,\n \"dump:software\": Cmd4,\n};\n"],"mappings":";;;;;;AAQA,MAAa,WAAW;CACtB,OAAOA;CACP,OAAOC;CACP,MAAMC;CACN,kBAAkBC;CAClB,iBAAiBC;CAClB"}