@platforma-sdk/tengo-builder 4.0.9 → 4.0.11
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 +27 -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 +18 -16
- 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 -15
- 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 -15
- 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 -12
- 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 -15
- 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/compiler/artifactset.cjs +2 -0
- package/dist/compiler/artifactset.cjs.map +1 -1
- package/dist/compiler/artifactset.js +2 -1
- package/dist/compiler/artifactset.js.map +1 -1
- package/dist/compiler/compiler.cjs +1 -0
- package/dist/compiler/compiler.cjs.map +1 -1
- package/dist/compiler/compiler.js +1 -0
- package/dist/compiler/compiler.js.map +1 -1
- package/dist/compiler/compileroptions.cjs +1 -0
- package/dist/compiler/compileroptions.cjs.map +1 -1
- package/dist/compiler/compileroptions.js +1 -1
- package/dist/compiler/compileroptions.js.map +1 -1
- package/dist/compiler/main.cjs +5 -3
- package/dist/compiler/main.cjs.map +1 -1
- package/dist/compiler/main.js +1 -1
- package/dist/compiler/main.js.map +1 -1
- package/dist/compiler/pack_limits.cjs +2 -0
- package/dist/compiler/pack_limits.cjs.map +1 -1
- package/dist/compiler/pack_limits.js +1 -1
- package/dist/compiler/pack_limits.js.map +1 -1
- package/dist/compiler/package.cjs.map +1 -1
- package/dist/compiler/package.js.map +1 -1
- package/dist/compiler/source.cjs +10 -1
- package/dist/compiler/source.cjs.map +1 -1
- package/dist/compiler/source.js +8 -1
- package/dist/compiler/source.js.map +1 -1
- package/dist/compiler/template.cjs +0 -1
- package/dist/compiler/template.cjs.map +1 -1
- package/dist/compiler/template.js.map +1 -1
- package/dist/compiler/util.cjs +3 -3
- package/dist/compiler/util.cjs.map +1 -1
- package/dist/compiler/util.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 -45
- package/dist/shared/basecmd.cjs.map +1 -1
- package/dist/shared/basecmd.js +30 -42
- package/dist/shared/basecmd.js.map +1 -1
- package/dist/shared/dump.cjs.map +1 -1
- package/dist/shared/dump.js.map +1 -1
- package/dist/shared/proc.cjs +0 -1
- package/dist/shared/proc.cjs.map +1 -1
- package/dist/shared/proc.js.map +1 -1
- package/package.json +9 -20
- 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
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;CAC7E,KAAK,MAAM,SAAS,cAClB,KAAK,MAAM,OAAO,OAAO,IAAI,UAAU,GAAG;CAE5C,OAAO;AACT;AAIA,SAAS,aAAa,OAAe,UAA8B;CACjE,OAAO,SAAS,OAAO,MAAM,MAAM,GAAG,CAAC;AACzC;AAEA,MAAa,sBAAgC,CAC3C,IAAI,OAAO,uBAAuB,eAAe,CAAC,CAC/C,QAAQ;CAAC;CAAS;CAAQ;CAAQ;AAAO,CAAC,CAAC,CAC3C,QAAQ,MAAM,CACnB;AAEA,MAAa,qBAA+B;CAC1C,IAAI,OAAO,mBAAmB,8BAA8B,CAAC,CAAC,QAAQ,KAAK;CAC3E,IAAI,OACF,sBACA,qEACF,CAAC,CAAC,QAAQ,aAAa;CACvB,IAAI,OACF,iCACA,iEACF,CAAC,CACE,UAAU,YAAY,CAAC,CACvB,QAAQ,CAAC,CAAa;AAC3B;AAEA,MAAa,4BAAsC,CACjD,IAAI,OAAO,qBAAqB,eAAe,CAAC,CAC7C,QAAQ;CAAC;CAAO;CAAW;CAAY;CAAQ;CAAY;CAAS;AAAM,CAAC,CAAC,CAC5E,QAAQ,KAAK,CAClB"}
|
package/dist/shared/dump.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dump.cjs","names":["getPackageInfo","parseSources","newCompiler","typedArtifactNameToString","compile"],"sources":["../../src/shared/dump.ts"],"sourcesContent":["import type winston from \"winston\";\nimport { getPackageInfo, newCompiler, compile, parseSources } from \"../compiler/main\";\nimport type { ArtifactType } from \"../compiler/package\";\nimport { typedArtifactNameToString } from \"../compiler/package\";\nimport type { TemplateDataV3 } from \"@milaboratories/pl-model-backend\";\n\nexport function dumpArtifacts(\n logger: winston.Logger,\n stream: NodeJS.WritableStream,\n aType?: ArtifactType,\n): void {\n const packageInfo = getPackageInfo(process.cwd(), logger);\n\n const sources = parseSources(logger, packageInfo, \"dist\", \"src\", \"\");\n\n const compiler = newCompiler(logger, packageInfo, \"dist\");\n\n // group output by type:\n // - all libs\n // - all templates\n // - all software\n // - all assets\n // - all tests\n\n // Libs\n\n if (!aType || aType === \"library\") {\n for (const lib of compiler.allLibs()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(lib.fullName)}`);\n stream.write(JSON.stringify(lib) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"library\") {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Templates\n\n if (!aType || aType === \"template\") {\n for (const tpl of compiler.allTemplates()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(tpl.fullName)}`);\n stream.write(JSON.stringify(tpl) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"template\") {\n logger.debug(\n `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)} ${src.srcName}`,\n );\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Software\n\n if (!aType || aType === \"software\") {\n for (const sw of compiler.allSoftware()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(sw.fullName)}`);\n stream.write(JSON.stringify(sw) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"software\") {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Assets\n\n if (!aType || aType === \"asset\") {\n for (const asset of compiler.allAssets()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(asset.fullName)}`);\n stream.write(JSON.stringify(asset) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"asset\") {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Wasm\n\n if (!aType || aType === \"wasm\") {\n for (const wasm of compiler.allWasm()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(wasm.fullName)}`);\n stream.write(JSON.stringify(wasm) + \"\\n\");\n }\n }\n\n // Tests\n\n if (!aType || aType === \"test\") {\n for (const src of sources) {\n if (src.fullName.type === \"test\") {\n logger.debug(\n `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)} ${src.srcName}`,\n );\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n}\n\nexport function dumpLibs(\n logger: winston.Logger,\n stream: NodeJS.WritableStream,\n recursive: boolean,\n): void {\n const packageInfo = getPackageInfo(process.cwd(), logger);\n\n const sources = parseSources(logger, packageInfo, \"dist\", \"src\", \"\");\n\n if (!recursive) {\n for (const src of sources) {\n if (src.fullName.type === \"library\") {\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n\n return;\n }\n\n const compiler = newCompiler(logger, packageInfo, \"dist\");\n for (const src of sources) {\n if (src.fullName.type === \"library\") {\n compiler.addLib(src);\n }\n }\n\n for (const lib of compiler.allLibs()) {\n stream.write(JSON.stringify(lib) + \"\\n\");\n }\n}\n\nexport function dumpSoftware(logger: winston.Logger, stream: NodeJS.WritableStream): void {\n const packageInfo = getPackageInfo(process.cwd(), logger);\n const compiled = compile(logger, packageInfo, \"dist\");\n\n const hashes = new Set<string>();\n const sourceMap = new Map<string, string>();\n for (const tpl of compiled.templates) {\n Object.entries(tpl.data.hashToSource).forEach(([hash, src]) => sourceMap.set(hash, src));\n getTemplateSoftware(tpl.data.template).forEach((hash) => hashes.add(hash));\n }\n\n for (const hash of hashes) {\n const src = sourceMap.get(hash);\n if (src) {\n if (Object.hasOwn(JSON.parse(src) as object, \"asset\")) {\n // Skip assets. They are kept in templates software because of backward compatibility with backend.\n continue;\n }\n stream.write(src);\n if (!src.endsWith(\"\\n\")) {\n stream.write(\"\\n\");\n }\n } else {\n throw new Error(`Source not found for hash: ${hash}`);\n }\n }\n}\n\nfunction getTemplateSoftware(tpl: TemplateDataV3): Set<string> {\n const hashes = new Set<string>();\n for (const sw of Object.values(tpl.software)) {\n hashes.add(sw.sourceHash);\n }\n for (const subTpl of Object.values(tpl.templates)) {\n getTemplateSoftware(subTpl).forEach((hash) => hashes.add(hash));\n }\n\n return new Set(hashes);\n}\n"],"mappings":";;;AAMA,SAAgB,cACd,QACA,QACA,OACM;CACN,MAAM,cAAcA,aAAAA,eAAe,QAAQ,
|
|
1
|
+
{"version":3,"file":"dump.cjs","names":["getPackageInfo","parseSources","newCompiler","typedArtifactNameToString","compile"],"sources":["../../src/shared/dump.ts"],"sourcesContent":["import type winston from \"winston\";\nimport { getPackageInfo, newCompiler, compile, parseSources } from \"../compiler/main\";\nimport type { ArtifactType } from \"../compiler/package\";\nimport { typedArtifactNameToString } from \"../compiler/package\";\nimport type { TemplateDataV3 } from \"@milaboratories/pl-model-backend\";\n\nexport function dumpArtifacts(\n logger: winston.Logger,\n stream: NodeJS.WritableStream,\n aType?: ArtifactType,\n): void {\n const packageInfo = getPackageInfo(process.cwd(), logger);\n\n const sources = parseSources(logger, packageInfo, \"dist\", \"src\", \"\");\n\n const compiler = newCompiler(logger, packageInfo, \"dist\");\n\n // group output by type:\n // - all libs\n // - all templates\n // - all software\n // - all assets\n // - all tests\n\n // Libs\n\n if (!aType || aType === \"library\") {\n for (const lib of compiler.allLibs()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(lib.fullName)}`);\n stream.write(JSON.stringify(lib) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"library\") {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Templates\n\n if (!aType || aType === \"template\") {\n for (const tpl of compiler.allTemplates()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(tpl.fullName)}`);\n stream.write(JSON.stringify(tpl) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"template\") {\n logger.debug(\n `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)} ${src.srcName}`,\n );\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Software\n\n if (!aType || aType === \"software\") {\n for (const sw of compiler.allSoftware()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(sw.fullName)}`);\n stream.write(JSON.stringify(sw) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"software\") {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Assets\n\n if (!aType || aType === \"asset\") {\n for (const asset of compiler.allAssets()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(asset.fullName)}`);\n stream.write(JSON.stringify(asset) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"asset\") {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Wasm\n\n if (!aType || aType === \"wasm\") {\n for (const wasm of compiler.allWasm()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(wasm.fullName)}`);\n stream.write(JSON.stringify(wasm) + \"\\n\");\n }\n }\n\n // Tests\n\n if (!aType || aType === \"test\") {\n for (const src of sources) {\n if (src.fullName.type === \"test\") {\n logger.debug(\n `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)} ${src.srcName}`,\n );\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n}\n\nexport function dumpLibs(\n logger: winston.Logger,\n stream: NodeJS.WritableStream,\n recursive: boolean,\n): void {\n const packageInfo = getPackageInfo(process.cwd(), logger);\n\n const sources = parseSources(logger, packageInfo, \"dist\", \"src\", \"\");\n\n if (!recursive) {\n for (const src of sources) {\n if (src.fullName.type === \"library\") {\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n\n return;\n }\n\n const compiler = newCompiler(logger, packageInfo, \"dist\");\n for (const src of sources) {\n if (src.fullName.type === \"library\") {\n compiler.addLib(src);\n }\n }\n\n for (const lib of compiler.allLibs()) {\n stream.write(JSON.stringify(lib) + \"\\n\");\n }\n}\n\nexport function dumpSoftware(logger: winston.Logger, stream: NodeJS.WritableStream): void {\n const packageInfo = getPackageInfo(process.cwd(), logger);\n const compiled = compile(logger, packageInfo, \"dist\");\n\n const hashes = new Set<string>();\n const sourceMap = new Map<string, string>();\n for (const tpl of compiled.templates) {\n Object.entries(tpl.data.hashToSource).forEach(([hash, src]) => sourceMap.set(hash, src));\n getTemplateSoftware(tpl.data.template).forEach((hash) => hashes.add(hash));\n }\n\n for (const hash of hashes) {\n const src = sourceMap.get(hash);\n if (src) {\n if (Object.hasOwn(JSON.parse(src) as object, \"asset\")) {\n // Skip assets. They are kept in templates software because of backward compatibility with backend.\n continue;\n }\n stream.write(src);\n if (!src.endsWith(\"\\n\")) {\n stream.write(\"\\n\");\n }\n } else {\n throw new Error(`Source not found for hash: ${hash}`);\n }\n }\n}\n\nfunction getTemplateSoftware(tpl: TemplateDataV3): Set<string> {\n const hashes = new Set<string>();\n for (const sw of Object.values(tpl.software)) {\n hashes.add(sw.sourceHash);\n }\n for (const subTpl of Object.values(tpl.templates)) {\n getTemplateSoftware(subTpl).forEach((hash) => hashes.add(hash));\n }\n\n return new Set(hashes);\n}\n"],"mappings":";;;AAMA,SAAgB,cACd,QACA,QACA,OACM;CACN,MAAM,cAAcA,aAAAA,eAAe,QAAQ,IAAI,GAAG,MAAM;CAExD,MAAM,UAAUC,aAAAA,aAAa,QAAQ,aAAa,QAAQ,OAAO,EAAE;CAEnE,MAAM,WAAWC,aAAAA,YAA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AAM,UAAU,IAAI,IAAI;EAC9B,IAAI,KAAK;GACP,IAAI,OAAO,OAAO,KAAK,MAAM,GAAG,GAAa,OAAO,GAElD;GAEF,OAAO,MAAM,GAAG;GAChB,IAAI,CAAC,IAAI,SAAS,IAAI,GACpB,OAAO,MAAM,IAAI;EAErB,OACE,MAAM,IAAI,MAAM,8BAA8B,MAAM;CAExD;AACF;AAEA,SAAS,oBAAoB,KAAkC;CAC7D,MAAM,yBAAS,IAAI,IAAY;CAC/B,KAAK,MAAM,MAAM,OAAO,OAAO,IAAI,QAAQ,GACzC,OAAO,IAAI,GAAG,UAAU;CAE1B,KAAK,MAAM,UAAU,OAAO,OAAO,IAAI,SAAS,GAC9C,oBAAoB,MAAM,CAAC,CAAC,SAAS,SAAS,OAAO,IAAI,IAAI,CAAC;CAGhE,OAAO,IAAI,IAAI,MAAM;AACvB"}
|
package/dist/shared/dump.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dump.js","names":[],"sources":["../../src/shared/dump.ts"],"sourcesContent":["import type winston from \"winston\";\nimport { getPackageInfo, newCompiler, compile, parseSources } from \"../compiler/main\";\nimport type { ArtifactType } from \"../compiler/package\";\nimport { typedArtifactNameToString } from \"../compiler/package\";\nimport type { TemplateDataV3 } from \"@milaboratories/pl-model-backend\";\n\nexport function dumpArtifacts(\n logger: winston.Logger,\n stream: NodeJS.WritableStream,\n aType?: ArtifactType,\n): void {\n const packageInfo = getPackageInfo(process.cwd(), logger);\n\n const sources = parseSources(logger, packageInfo, \"dist\", \"src\", \"\");\n\n const compiler = newCompiler(logger, packageInfo, \"dist\");\n\n // group output by type:\n // - all libs\n // - all templates\n // - all software\n // - all assets\n // - all tests\n\n // Libs\n\n if (!aType || aType === \"library\") {\n for (const lib of compiler.allLibs()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(lib.fullName)}`);\n stream.write(JSON.stringify(lib) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"library\") {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Templates\n\n if (!aType || aType === \"template\") {\n for (const tpl of compiler.allTemplates()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(tpl.fullName)}`);\n stream.write(JSON.stringify(tpl) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"template\") {\n logger.debug(\n `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)} ${src.srcName}`,\n );\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Software\n\n if (!aType || aType === \"software\") {\n for (const sw of compiler.allSoftware()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(sw.fullName)}`);\n stream.write(JSON.stringify(sw) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"software\") {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Assets\n\n if (!aType || aType === \"asset\") {\n for (const asset of compiler.allAssets()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(asset.fullName)}`);\n stream.write(JSON.stringify(asset) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"asset\") {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Wasm\n\n if (!aType || aType === \"wasm\") {\n for (const wasm of compiler.allWasm()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(wasm.fullName)}`);\n stream.write(JSON.stringify(wasm) + \"\\n\");\n }\n }\n\n // Tests\n\n if (!aType || aType === \"test\") {\n for (const src of sources) {\n if (src.fullName.type === \"test\") {\n logger.debug(\n `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)} ${src.srcName}`,\n );\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n}\n\nexport function dumpLibs(\n logger: winston.Logger,\n stream: NodeJS.WritableStream,\n recursive: boolean,\n): void {\n const packageInfo = getPackageInfo(process.cwd(), logger);\n\n const sources = parseSources(logger, packageInfo, \"dist\", \"src\", \"\");\n\n if (!recursive) {\n for (const src of sources) {\n if (src.fullName.type === \"library\") {\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n\n return;\n }\n\n const compiler = newCompiler(logger, packageInfo, \"dist\");\n for (const src of sources) {\n if (src.fullName.type === \"library\") {\n compiler.addLib(src);\n }\n }\n\n for (const lib of compiler.allLibs()) {\n stream.write(JSON.stringify(lib) + \"\\n\");\n }\n}\n\nexport function dumpSoftware(logger: winston.Logger, stream: NodeJS.WritableStream): void {\n const packageInfo = getPackageInfo(process.cwd(), logger);\n const compiled = compile(logger, packageInfo, \"dist\");\n\n const hashes = new Set<string>();\n const sourceMap = new Map<string, string>();\n for (const tpl of compiled.templates) {\n Object.entries(tpl.data.hashToSource).forEach(([hash, src]) => sourceMap.set(hash, src));\n getTemplateSoftware(tpl.data.template).forEach((hash) => hashes.add(hash));\n }\n\n for (const hash of hashes) {\n const src = sourceMap.get(hash);\n if (src) {\n if (Object.hasOwn(JSON.parse(src) as object, \"asset\")) {\n // Skip assets. They are kept in templates software because of backward compatibility with backend.\n continue;\n }\n stream.write(src);\n if (!src.endsWith(\"\\n\")) {\n stream.write(\"\\n\");\n }\n } else {\n throw new Error(`Source not found for hash: ${hash}`);\n }\n }\n}\n\nfunction getTemplateSoftware(tpl: TemplateDataV3): Set<string> {\n const hashes = new Set<string>();\n for (const sw of Object.values(tpl.software)) {\n hashes.add(sw.sourceHash);\n }\n for (const subTpl of Object.values(tpl.templates)) {\n getTemplateSoftware(subTpl).forEach((hash) => hashes.add(hash));\n }\n\n return new Set(hashes);\n}\n"],"mappings":";;;AAMA,SAAgB,cACd,QACA,QACA,OACM;CACN,MAAM,cAAc,eAAe,QAAQ,
|
|
1
|
+
{"version":3,"file":"dump.js","names":[],"sources":["../../src/shared/dump.ts"],"sourcesContent":["import type winston from \"winston\";\nimport { getPackageInfo, newCompiler, compile, parseSources } from \"../compiler/main\";\nimport type { ArtifactType } from \"../compiler/package\";\nimport { typedArtifactNameToString } from \"../compiler/package\";\nimport type { TemplateDataV3 } from \"@milaboratories/pl-model-backend\";\n\nexport function dumpArtifacts(\n logger: winston.Logger,\n stream: NodeJS.WritableStream,\n aType?: ArtifactType,\n): void {\n const packageInfo = getPackageInfo(process.cwd(), logger);\n\n const sources = parseSources(logger, packageInfo, \"dist\", \"src\", \"\");\n\n const compiler = newCompiler(logger, packageInfo, \"dist\");\n\n // group output by type:\n // - all libs\n // - all templates\n // - all software\n // - all assets\n // - all tests\n\n // Libs\n\n if (!aType || aType === \"library\") {\n for (const lib of compiler.allLibs()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(lib.fullName)}`);\n stream.write(JSON.stringify(lib) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"library\") {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Templates\n\n if (!aType || aType === \"template\") {\n for (const tpl of compiler.allTemplates()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(tpl.fullName)}`);\n stream.write(JSON.stringify(tpl) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"template\") {\n logger.debug(\n `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)} ${src.srcName}`,\n );\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Software\n\n if (!aType || aType === \"software\") {\n for (const sw of compiler.allSoftware()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(sw.fullName)}`);\n stream.write(JSON.stringify(sw) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"software\") {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Assets\n\n if (!aType || aType === \"asset\") {\n for (const asset of compiler.allAssets()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(asset.fullName)}`);\n stream.write(JSON.stringify(asset) + \"\\n\");\n }\n\n for (const src of sources) {\n if (src.fullName.type === \"asset\") {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`);\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n\n // Wasm\n\n if (!aType || aType === \"wasm\") {\n for (const wasm of compiler.allWasm()) {\n logger.debug(`Dumping to pl-tester: ${typedArtifactNameToString(wasm.fullName)}`);\n stream.write(JSON.stringify(wasm) + \"\\n\");\n }\n }\n\n // Tests\n\n if (!aType || aType === \"test\") {\n for (const src of sources) {\n if (src.fullName.type === \"test\") {\n logger.debug(\n `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)} ${src.srcName}`,\n );\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n }\n}\n\nexport function dumpLibs(\n logger: winston.Logger,\n stream: NodeJS.WritableStream,\n recursive: boolean,\n): void {\n const packageInfo = getPackageInfo(process.cwd(), logger);\n\n const sources = parseSources(logger, packageInfo, \"dist\", \"src\", \"\");\n\n if (!recursive) {\n for (const src of sources) {\n if (src.fullName.type === \"library\") {\n stream.write(JSON.stringify(src) + \"\\n\");\n }\n }\n\n return;\n }\n\n const compiler = newCompiler(logger, packageInfo, \"dist\");\n for (const src of sources) {\n if (src.fullName.type === \"library\") {\n compiler.addLib(src);\n }\n }\n\n for (const lib of compiler.allLibs()) {\n stream.write(JSON.stringify(lib) + \"\\n\");\n }\n}\n\nexport function dumpSoftware(logger: winston.Logger, stream: NodeJS.WritableStream): void {\n const packageInfo = getPackageInfo(process.cwd(), logger);\n const compiled = compile(logger, packageInfo, \"dist\");\n\n const hashes = new Set<string>();\n const sourceMap = new Map<string, string>();\n for (const tpl of compiled.templates) {\n Object.entries(tpl.data.hashToSource).forEach(([hash, src]) => sourceMap.set(hash, src));\n getTemplateSoftware(tpl.data.template).forEach((hash) => hashes.add(hash));\n }\n\n for (const hash of hashes) {\n const src = sourceMap.get(hash);\n if (src) {\n if (Object.hasOwn(JSON.parse(src) as object, \"asset\")) {\n // Skip assets. They are kept in templates software because of backward compatibility with backend.\n continue;\n }\n stream.write(src);\n if (!src.endsWith(\"\\n\")) {\n stream.write(\"\\n\");\n }\n } else {\n throw new Error(`Source not found for hash: ${hash}`);\n }\n }\n}\n\nfunction getTemplateSoftware(tpl: TemplateDataV3): Set<string> {\n const hashes = new Set<string>();\n for (const sw of Object.values(tpl.software)) {\n hashes.add(sw.sourceHash);\n }\n for (const subTpl of Object.values(tpl.templates)) {\n getTemplateSoftware(subTpl).forEach((hash) => hashes.add(hash));\n }\n\n return new Set(hashes);\n}\n"],"mappings":";;;AAMA,SAAgB,cACd,QACA,QACA,OACM;CACN,MAAM,cAAc,eAAe,QAAQ,IAAI,GAAG,MAAM;CAExD,MAAM,UAAU,aAAa,QAAQ,aAAa,QAAQ,OAAO,EAAE;CAEnE,MAAM,WAAW,YAAY,QAAQ,aAAa,MAAM;CAWxD,IAAI,CAAC,SAAS,UAAU,WAAW;EACjC,KAAK,MAAM,OAAO,SAAS,QAAQ,GAAG;GACpC,OAAO,MAAM,yBAAyB,0BAA0B,IAAI,QAAQ,GAAG;GAC/E,OAAO,MAAM,KAAK,UAAU,GAAG,IAAI,IAAI;EACzC;EAEA,KAAK,MAAM,OAAO,SAChB,IAAI,IAAI,SAAS,SAAS,WAAW;GACnC,OAAO,MAAM,yBAAyB,0BAA0B,IAAI,QAAQ,GAAG;GAC/E,OAAO,MAAM,KAAK,UAAU,GAAG,IAAI,IAAI;EACzC;CAEJ;CAIA,IAAI,CAAC,SAAS,UAAU,YAAY;EAClC,KAAK,MAAM,OAAO,SAAS,aAAa,GAAG;GACzC,OAAO,MAAM,yBAAyB,0BAA0B,IAAI,QAA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{"version":3,"file":"proc.cjs","names":[],"sources":["../../src/shared/proc.ts"],"sourcesContent":["import type { ChildProcess, ChildProcessByStdio } from \"node:child_process\";\nimport { spawn } from \"node:child_process\";\nimport type { Writable } from \"node:stream\";\n\nexport function spawnEmbed(\n cmd: string,\n ...args: string[]\n): ChildProcessByStdio<Writable, null, null> {\n const p = spawn(cmd, args, { stdio: [\"pipe\", \"inherit\", \"inherit\"] });\n\n p.stdin.on(\"error\", (err: Error) => {\n const systemError = err as NodeJS.ErrnoException;\n if (systemError.code === \"EPIPE\") {\n // ignore EPIPE error as it stands for broken command run.\n // The command will write normal problem description by itself.\n }\n });\n\n return p;\n}\n\nexport function waitFor(p: ChildProcess): Promise<number> {\n return new Promise((resolve, reject) => {\n p.on(\"close\", (code: number) => {\n resolve(code);\n });\n p.on(\"error\", (err) => {\n reject(err);\n });\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"proc.cjs","names":["systemError"],"sources":["../../src/shared/proc.ts"],"sourcesContent":["import type { ChildProcess, ChildProcessByStdio } from \"node:child_process\";\nimport { spawn } from \"node:child_process\";\nimport type { Writable } from \"node:stream\";\n\nexport function spawnEmbed(\n cmd: string,\n ...args: string[]\n): ChildProcessByStdio<Writable, null, null> {\n const p = spawn(cmd, args, { stdio: [\"pipe\", \"inherit\", \"inherit\"] });\n\n p.stdin.on(\"error\", (err: Error) => {\n const systemError = err as NodeJS.ErrnoException;\n if (systemError.code === \"EPIPE\") {\n // ignore EPIPE error as it stands for broken command run.\n // The command will write normal problem description by itself.\n }\n });\n\n return p;\n}\n\nexport function waitFor(p: ChildProcess): Promise<number> {\n return new Promise((resolve, reject) => {\n p.on(\"close\", (code: number) => {\n resolve(code);\n });\n p.on(\"error\", (err) => {\n reject(err);\n });\n });\n}\n"],"mappings":";;AAIA,SAAgB,WACd,KACA,GAAG,MACwC;CAC3C,MAAM,KAAA,GAAA,mBAAA,MAAA,CAAU,KAAK,MAAM,EAAE,OAAO;EAAC;EAAQ;EAAW;CAAS,EAAE,CAAC;CAEpE,EAAE,MAAM,GAAG,UAAU,QAAe;EAElC,IAAIA,IAAY,SAAS,SAAS,CAGlC;CACF,CAAC;CAED,OAAO;AACT;AAEA,SAAgB,QAAQ,GAAkC;CACxD,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,EAAE,GAAG,UAAU,SAAiB;GAC9B,QAAQ,IAAI;EACd,CAAC;EACD,EAAE,GAAG,UAAU,QAAQ;GACrB,OAAO,GAAG;EACZ,CAAC;CACH,CAAC;AACH"}
|
package/dist/shared/proc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proc.js","names":[],"sources":["../../src/shared/proc.ts"],"sourcesContent":["import type { ChildProcess, ChildProcessByStdio } from \"node:child_process\";\nimport { spawn } from \"node:child_process\";\nimport type { Writable } from \"node:stream\";\n\nexport function spawnEmbed(\n cmd: string,\n ...args: string[]\n): ChildProcessByStdio<Writable, null, null> {\n const p = spawn(cmd, args, { stdio: [\"pipe\", \"inherit\", \"inherit\"] });\n\n p.stdin.on(\"error\", (err: Error) => {\n const systemError = err as NodeJS.ErrnoException;\n if (systemError.code === \"EPIPE\") {\n // ignore EPIPE error as it stands for broken command run.\n // The command will write normal problem description by itself.\n }\n });\n\n return p;\n}\n\nexport function waitFor(p: ChildProcess): Promise<number> {\n return new Promise((resolve, reject) => {\n p.on(\"close\", (code: number) => {\n resolve(code);\n });\n p.on(\"error\", (err) => {\n reject(err);\n });\n });\n}\n"],"mappings":";;AAIA,SAAgB,WACd,KACA,GAAG,MACwC;CAC3C,MAAM,IAAI,MAAM,KAAK,MAAM,EAAE,OAAO;EAAC;EAAQ;EAAW;
|
|
1
|
+
{"version":3,"file":"proc.js","names":["systemError"],"sources":["../../src/shared/proc.ts"],"sourcesContent":["import type { ChildProcess, ChildProcessByStdio } from \"node:child_process\";\nimport { spawn } from \"node:child_process\";\nimport type { Writable } from \"node:stream\";\n\nexport function spawnEmbed(\n cmd: string,\n ...args: string[]\n): ChildProcessByStdio<Writable, null, null> {\n const p = spawn(cmd, args, { stdio: [\"pipe\", \"inherit\", \"inherit\"] });\n\n p.stdin.on(\"error\", (err: Error) => {\n const systemError = err as NodeJS.ErrnoException;\n if (systemError.code === \"EPIPE\") {\n // ignore EPIPE error as it stands for broken command run.\n // The command will write normal problem description by itself.\n }\n });\n\n return p;\n}\n\nexport function waitFor(p: ChildProcess): Promise<number> {\n return new Promise((resolve, reject) => {\n p.on(\"close\", (code: number) => {\n resolve(code);\n });\n p.on(\"error\", (err) => {\n reject(err);\n });\n });\n}\n"],"mappings":";;AAIA,SAAgB,WACd,KACA,GAAG,MACwC;CAC3C,MAAM,IAAI,MAAM,KAAK,MAAM,EAAE,OAAO;EAAC;EAAQ;EAAW;CAAS,EAAE,CAAC;CAEpE,EAAE,MAAM,GAAG,UAAU,QAAe;EAElC,IAAIA,IAAY,SAAS,SAAS,CAGlC;CACF,CAAC;CAED,OAAO;AACT;AAEA,SAAgB,QAAQ,GAAkC;CACxD,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,EAAE,GAAG,UAAU,SAAiB;GAC9B,QAAQ,IAAI;EACd,CAAC;EACD,EAAE,GAAG,UAAU,QAAQ;GACrB,OAAO,GAAG;EACZ,CAAC;CACH,CAAC;AACH"}
|
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.11",
|
|
4
4
|
"description": "Pl Tengo Template Builder",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"bin": {
|
|
@@ -14,37 +14,26 @@
|
|
|
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/pl-model-backend": "1.4.
|
|
20
|
-
"@milaboratories/
|
|
21
|
-
"@milaboratories/
|
|
19
|
+
"@milaboratories/pl-model-backend": "1.4.9",
|
|
20
|
+
"@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",
|
|
25
25
|
"@vitest/coverage-istanbul": "^4.1.3",
|
|
26
26
|
"typescript": "~5.9.3",
|
|
27
27
|
"vitest": "^4.1.3",
|
|
28
|
-
"@milaboratories/
|
|
29
|
-
"@milaboratories/
|
|
30
|
-
"@milaboratories/
|
|
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": " "
|
|
28
|
+
"@milaboratories/ts-configs": "1.3.0",
|
|
29
|
+
"@milaboratories/ts-builder": "1.6.0",
|
|
30
|
+
"@milaboratories/build-configs": "2.0.0"
|
|
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
|
}
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import { Command } from "
|
|
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
|
|
9
|
-
|
|
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
|
-
|
|
13
|
+
opts.addOptions(cmd, opts.GlobalOptions(), opts.ArtifactTypeOptions());
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
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 "
|
|
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
|
|
8
|
-
|
|
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
|
-
|
|
12
|
+
opts.addOptions(cmd, opts.GlobalOptions());
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
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
|
}
|
package/src/commands/test.ts
CHANGED
|
@@ -1,30 +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 testCommand(): Command {
|
|
9
|
+
const cmd = new Command("test").description("run tengo unit tests (.test.tengo)");
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
cmd.argument("[paths...]", "source paths to test (defaults to ./src)");
|
|
12
|
+
addOptions(cmd, GlobalOptions());
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
cmd.action(async (paths: string[], o) => {
|
|
15
|
+
const logLevel = o.logLevel as string;
|
|
16
|
+
const logger = createLogger(logLevel);
|
|
14
17
|
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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";
|