@platforma-sdk/tengo-builder 1.16.1 → 1.17.1

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 (40) hide show
  1. package/dist/commands/build.d.ts.map +1 -1
  2. package/dist/compiler/compiler.d.ts.map +1 -1
  3. package/dist/compiler/compileroptions.d.ts +6 -0
  4. package/dist/compiler/compileroptions.d.ts.map +1 -0
  5. package/dist/compiler/main.d.ts +0 -1
  6. package/dist/compiler/main.d.ts.map +1 -1
  7. package/dist/compiler/package.d.ts +6 -0
  8. package/dist/compiler/package.d.ts.map +1 -1
  9. package/dist/compiler/source.d.ts +9 -4
  10. package/dist/compiler/source.d.ts.map +1 -1
  11. package/dist/compiler/template.d.ts +5 -0
  12. package/dist/compiler/template.d.ts.map +1 -1
  13. package/dist/compiler/test.artifacts.d.ts +9 -0
  14. package/dist/compiler/test.artifacts.d.ts.map +1 -1
  15. package/dist/compiler/util.d.ts +3 -0
  16. package/dist/compiler/util.d.ts.map +1 -1
  17. package/dist/index.js +28 -28
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +575 -513
  20. package/dist/index.mjs.map +1 -1
  21. package/package.json +4 -4
  22. package/src/commands/build.ts +2 -1
  23. package/src/commands/check.ts +1 -1
  24. package/src/commands/dump/all.ts +1 -1
  25. package/src/commands/dump/assets.ts +1 -1
  26. package/src/commands/dump/libs.ts +1 -1
  27. package/src/commands/dump/software.ts +1 -1
  28. package/src/commands/dump/templates.ts +1 -1
  29. package/src/commands/dump/tests.ts +1 -1
  30. package/src/commands/test.ts +1 -1
  31. package/src/compiler/compiler.test.ts +51 -20
  32. package/src/compiler/compiler.ts +10 -4
  33. package/src/compiler/compileroptions.ts +51 -0
  34. package/src/compiler/main.ts +4 -19
  35. package/src/compiler/package.ts +21 -13
  36. package/src/compiler/source.test.ts +18 -4
  37. package/src/compiler/source.ts +94 -20
  38. package/src/compiler/template.ts +6 -0
  39. package/src/compiler/test.artifacts.ts +66 -8
  40. package/src/compiler/util.ts +21 -0
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAQtC,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,OAAO;IACxC,OAAgB,WAAW,SAA6D;IAExF,OAAgB,QAAQ,WAA2C;IAEnE,OAAgB,KAAK;;;;;MAGnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAiDlC"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAStC,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,OAAO;IACxC,OAAgB,WAAW,SAA6D;IAExF,OAAgB,QAAQ,WAA2C;IAEnE,OAAgB,KAAK;;;;;MAGnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAiDlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/compiler/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AACpD,OAAO,EACL,iBAAiB,EAMjB,WAAW,EACZ,MAAM,WAAW,CAAC;AAInB,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,IAAI,EAAE,cAAc,EAAE,CAAC;IACvB,QAAQ,EAAE,cAAc,EAAE,CAAA;IAC1B,MAAM,EAAE,cAAc,EAAE,CAAA;CACzB;AAED,qBAAa,qBAAqB;IAE9B,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW;IAG3C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA0D;IAC/E,OAAO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Q;IAQzB,YAAY,IAAI,QAAQ,EAAE;IAI1B,WAAW,CAAC,IAAI,EAAE,iBAAiB,GAAG,QAAQ,GAAG,SAAS;IAM1D,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,GAAG,QAAQ;IAOrD,WAAW,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc,GAAG,QAAQ,GAAG,SAAS;IAmB3E,SAAS;IAYT,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,gBAAgB;CAqG3D"}
@@ -0,0 +1,6 @@
1
+ import { CompilerOption } from './package';
2
+ import { TemplateData, TemplateLibData } from './template';
3
+ export declare function applyTemplateCompilerOptions(opts: CompilerOption[], tpl: TemplateData): void;
4
+ export declare function applyLibraryCompilerOptions(opts: CompilerOption[], lib: TemplateLibData): void;
5
+ export declare function hashOverride(args: string[]): string;
6
+ //# sourceMappingURL=compileroptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compileroptions.d.ts","sourceRoot":"","sources":["../../src/compiler/compileroptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG3D,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,GAAG,EAAE,YAAY,QASrF;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,GAAG,EAAE,eAAe,QAavF;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAoBnD"}
@@ -7,7 +7,6 @@ interface PackageJson {
7
7
  version: string;
8
8
  type: string;
9
9
  }
10
- export declare function createLogger(level?: string): winston.Logger;
11
10
  export declare function getPackageInfo(): PackageJson;
12
11
  export declare function parseSources(logger: winston.Logger, packageInfo: PackageJson, mode: CompileMode, root: string, subdir: string): ArtifactSource[];
13
12
  export declare function newCompiler(logger: winston.Logger, packageInfo: PackageJson, mode: CompileMode): TengoTemplateCompiler;
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/compiler/main.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAEL,WAAW,EAIZ,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAmB,MAAM,UAAU,CAAC;AAE3D,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAkBD,wBAAgB,YAAY,CAAC,KAAK,GAAE,MAAgB,GAAG,OAAO,CAAC,MAAM,CAapE;AAED,wBAAgB,cAAc,IAAI,WAAW,CAG5C;AAwLD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,CAAC,MAAM,EACtB,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,cAAc,EAAE,CAwClB;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,OAAO,CAAC,MAAM,EACtB,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,WAAW,GAChB,qBAAqB,CAOvB;AAkDD,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,gBAAgB,CAsBnF;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,QA4C9F"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/compiler/main.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAEL,WAAW,EAIZ,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAmB,MAAM,UAAU,CAAC;AAE3D,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAkBD,wBAAgB,cAAc,IAAI,WAAW,CAG5C;AAwLD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,CAAC,MAAM,EACtB,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,cAAc,EAAE,CAwClB;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,OAAO,CAAC,MAAM,EACtB,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,WAAW,GAChB,qBAAqB,CAOvB;AAkDD,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,gBAAgB,CAsBnF;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,QA4C9F"}
@@ -1,4 +1,10 @@
1
1
  export type CompileMode = 'dist';
2
+ export type CompilerOption = {
3
+ /** Option name, like 'hash_override' */
4
+ name: string;
5
+ /** Arguments of the option. Everything that follows option name */
6
+ args: string[];
7
+ };
2
8
  export type ArtifactType = 'library' | 'template' | 'test' | 'software' | 'asset';
3
9
  /** Artifact Name including package version */
4
10
  export interface FullArtifactName {
@@ -1 +1 @@
1
- {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/compiler/package.ts"],"names":[],"mappings":"AAsBA,MAAM,MAAM,WAAW,GAAG,MAAM,CAAA;AAEhC,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,GAA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AAE,gBAAgB,GAAG,MAAM,CAE/D;AAED,0BAA0B;AAC1B,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAEzE;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,iBAAiB,EACxB,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAET;AAED,iEAAiE;AACjE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAE/D;AAED,6EAA6E;AAC7E,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,gBAAgB,GAAG;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAEA;AAED,6EAA6E;AAC7E,wBAAgB,2BAA2B,CAAC,cAAc,EAAE;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,2BAA2B,CAI9B;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,2BAA2B,GAAG,MAAM,CAErF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,2BAA2B,CAEvF"}
@@ -1,4 +1,5 @@
1
- import { TypedArtifactName, FullArtifactName, CompileMode } from './package';
1
+ import { default as winston } from 'winston';
2
+ import { TypedArtifactName, FullArtifactName, CompileMode, CompilerOption } from './package';
2
3
  export declare class ArtifactSource {
3
4
  /** The mode this artifact was built (dev or dist) */
4
5
  readonly compileMode: CompileMode;
@@ -10,6 +11,8 @@ export declare class ArtifactSource {
10
11
  readonly srcName: string;
11
12
  /** List of dependencies */
12
13
  readonly dependencies: TypedArtifactName[];
14
+ /** Additional compiler options detected in source code */
15
+ readonly compilerOptions: CompilerOption[];
13
16
  constructor(
14
17
  /** The mode this artifact was built (dev or dist) */
15
18
  compileMode: CompileMode,
@@ -20,8 +23,10 @@ export declare class ArtifactSource {
20
23
  /** Path to source file where artifact came from */
21
24
  srcName: string,
22
25
  /** List of dependencies */
23
- dependencies: TypedArtifactName[]);
26
+ dependencies: TypedArtifactName[],
27
+ /** Additional compiler options detected in source code */
28
+ compilerOptions: CompilerOption[]);
24
29
  }
25
- export declare function parseSourceFile(mode: CompileMode, srcFile: string, fullSourceName: FullArtifactName, normalize: boolean): ArtifactSource;
26
- export declare function parseSource(mode: CompileMode, src: string, fullSourceName: FullArtifactName, normalize: boolean): ArtifactSource;
30
+ export declare function parseSourceFile(logger: winston.Logger, mode: CompileMode, srcFile: string, fullSourceName: FullArtifactName, normalize: boolean): ArtifactSource;
31
+ export declare function parseSource(logger: winston.Logger, mode: CompileMode, src: string, fullSourceName: FullArtifactName, normalize: boolean): ArtifactSource;
27
32
  //# sourceMappingURL=source.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/compiler/source.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAgB,WAAW,EAAE,MAAM,WAAW,CAAC;AAwC3F,qBAAa,cAAc;IAEvB,qDAAqD;aACrC,WAAW,EAAE,WAAW;IACxC,kDAAkD;aAClC,QAAQ,EAAE,gBAAgB;IAC1C,6BAA6B;aACb,GAAG,EAAE,MAAM;IAC3B,mDAAmD;aACnC,OAAO,EAAE,MAAM;IAC/B,2BAA2B;aACX,YAAY,EAAE,iBAAiB,EAAE;;IATjD,qDAAqD;IACrC,WAAW,EAAE,WAAW;IACxC,kDAAkD;IAClC,QAAQ,EAAE,gBAAgB;IAC1C,6BAA6B;IACb,GAAG,EAAE,MAAM;IAC3B,mDAAmD;IACnC,OAAO,EAAE,MAAM;IAC/B,2BAA2B;IACX,YAAY,EAAE,iBAAiB,EAAE;CAEpD;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,gBAAgB,EAChC,SAAS,EAAE,OAAO,GACjB,cAAc,CAKhB;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,gBAAgB,EAChC,SAAS,EAAE,OAAO,GACjB,cAAc,CAIhB"}
1
+ {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/compiler/source.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAEhB,WAAW,EACX,cAAc,EACf,MAAM,WAAW,CAAC;AAmEnB,qBAAa,cAAc;IAEvB,qDAAqD;aACrC,WAAW,EAAE,WAAW;IACxC,kDAAkD;aAClC,QAAQ,EAAE,gBAAgB;IAC1C,6BAA6B;aACb,GAAG,EAAE,MAAM;IAC3B,mDAAmD;aACnC,OAAO,EAAE,MAAM;IAC/B,2BAA2B;aACX,YAAY,EAAE,iBAAiB,EAAE;IACjD,0DAA0D;aAC1C,eAAe,EAAE,cAAc,EAAE;;IAXjD,qDAAqD;IACrC,WAAW,EAAE,WAAW;IACxC,kDAAkD;IAClC,QAAQ,EAAE,gBAAgB;IAC1C,6BAA6B;IACb,GAAG,EAAE,MAAM;IAC3B,mDAAmD;IACnC,OAAO,EAAE,MAAM;IAC/B,2BAA2B;IACX,YAAY,EAAE,iBAAiB,EAAE;IACjD,0DAA0D;IAC1C,eAAe,EAAE,cAAc,EAAE;CAEpD;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,OAAO,CAAC,MAAM,EACtB,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,gBAAgB,EAChC,SAAS,EAAE,OAAO,GACjB,cAAc,CAKhB;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,OAAO,CAAC,MAAM,EACtB,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,gBAAgB,EAChC,SAAS,EAAE,OAAO,GACjB,cAAc,CAIhB"}
@@ -30,6 +30,11 @@ export interface TemplateData {
30
30
  name: string;
31
31
  /** i.e. 1.2.3 */
32
32
  version: string;
33
+ /**
34
+ * Custom hash token of the template for deduplication purposes. Can be set with 'hash_override' compiler option.
35
+ * Dangerous! Remember: great power comes with great responsibility.
36
+ */
37
+ hashOverride?: string;
33
38
  /** i.e. @milaboratory/some-package:some-lib -> normalized library source code */
34
39
  libs: Record<string, TemplateLibData>;
35
40
  /** i.e. @milaboratory/some-package:some-lib -> to nested template data */
@@ -1 +1 @@
1
- {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/compiler/template.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,EACX,gBAAgB,EAIjB,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,eAAe;IAC9B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,oBAAoB;IACnC,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,IAAI,EAAE,sBAAsB,CAAC;IAE7B,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,OAAO,EAAE,MAAM,CAAC;IAEhB,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACtC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACxC,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC,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,iBAAiB;IACjB,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACtC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACxC,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAC/C,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC1C,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb;AAKD,qBAAa,QAAQ;aAKD,WAAW,EAAE,WAAW;aACxB,QAAQ,EAAE,gBAAgB;IAL5C,SAAgB,IAAI,EAAE,YAAY,CAAC;IACnC,SAAgB,OAAO,EAAE,UAAU,CAAC;gBAGlB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,gBAAgB,EAC1C,IAAI,EAAE;QACJ,IAAI,CAAC,EAAE,YAAY,CAAC;QACpB,OAAO,CAAC,EAAE,UAAU,CAAA;KACrB;IA0BH,MAAM;;;;;CAGP"}
@@ -8,14 +8,21 @@ export declare const testLocalLib1Src = "\notherLib := import(\"package1:other-l
8
8
  export declare const testLocalLib1SrcNormalized = "\notherLib := import(\"package1:other-lib-2\")\nplapiCustomName := import(\"plapi\" )\n\nnotplapiCustomName.getTemplateId( \"some other:parameter\")\n\nplapiCustomName.getTemplateIdAnother(\"sss:kkk\" )\nplapiCustomName.getSoftwareInfo(\"current-package:software-1\")\n\nexport {\n \"some\": \"value\",\n \"template2\": plapiCustomName.getTemplateId(\"current-package:local-template-2\"),\n \"template3\": plapiCustomName.getTemplateId(\"package1:template-3\")\n}\n";
9
9
  export declare const testLocalLib2Name: FullArtifactName;
10
10
  export declare const testLocalLib2Src = "\notherLib := import(\"package1:someid\")\nll := import(\"@platforma-sdk/workflow-tengo:assets\")\n\n/* multiline comments should be ignored\n a := import(\":non-existent-library\")\n */\n\ntplID := ll.importTemplate(\"package2:template-1\")\nsoftwareID := ll.importSoftware(\"package2:software-1\")\nassetID := ll.importAsset(\"package2:asset-1\")\n\nexport {\n \"some\": \"value\",\n \"template1\": ll.importTemplate(\"current-package:local-template-2\"),\n \"template2\": tplID,\n}\n";
11
+ export declare const testLocalLib3Name: FullArtifactName;
12
+ export declare const testLocalLib3Src = "\nexport {\n \"some\": \"value\"\n}\n";
11
13
  export declare const testLocalTpl1Name: FullArtifactName;
12
14
  export declare const testLocalTpl1Src = "\nlib1 := import( \":local-library-1\")\nlib2 := import(\"package1:other-lib-1\")\nplapi := import(\"plapi\")\n\ntpl2 := plapi.getTemplateId(\"current-package:local-template-1\" )\n";
13
15
  export declare const testLocalTpl2Name: FullArtifactName;
14
16
  export declare const testLocalTpl2Src = "\nlib := import(\"package1:other-lib-1\")\n";
15
17
  export declare const testLocalTpl2SrcNormalized = "\nlib := import(\"package1:other-lib-1\")\n";
18
+ export declare const testLocalTpl3Name: FullArtifactName;
19
+ export declare const testLocalTpl3Src = "\n//tengo:hash_override CE0F6EDF-D97C-44E7-B16B-D661D4C799C1\n\na := \"some instruction\"\nlib := import(\":local-library-3\")\n";
20
+ export declare const testLocalTpl3SrcWrongOverride = "\n//tengo:hash_override broken-hash-override\n\na := \"some instruction\"\nlib := import(\":local-library-3\")\n";
16
21
  export declare const testLocalLib1: TestArtifactSource;
22
+ export declare const testLocalLib3: TestArtifactSource;
17
23
  export declare const testLocalTpl1: TestArtifactSource;
18
24
  export declare const testLocalTpl2: TestArtifactSource;
25
+ export declare const testLocalTpl3: TestArtifactSource;
19
26
  export declare const testLocalPackage: TestArtifactSource[];
20
27
  export declare const testPackage1Lib1Name: FullArtifactName;
21
28
  export declare const testPackage1Lib1Src = "\nexport {\n \"some\": \"value1\"\n}\n";
@@ -30,4 +37,6 @@ export declare const testPackage1Lib1: TestArtifactSource;
30
37
  export declare const testPackage1Lib2: TestArtifactSource;
31
38
  export declare const testPackage1Tpl3: TestArtifactSource;
32
39
  export declare const testPackage1: TestArtifactSource[];
40
+ export declare const testPackage2: TestArtifactSource[];
41
+ export declare const testPackage2BrokenHash: TestArtifactSource[];
33
42
  //# sourceMappingURL=test.artifacts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"test.artifacts.d.ts","sourceRoot":"","sources":["../../src/compiler/test.artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb;AA4BD,eAAO,MAAM,iBAAiB,EAAE,gBAK/B,CAAC;AACF,eAAO,MAAM,gBAAgB,qcAc5B,CAAC;AACF,eAAO,MAAM,0BAA0B,+dActC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAK/B,CAAC;AACF,eAAO,MAAM,gBAAgB,qfAiB5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAK/B,CAAC;AACF,eAAO,MAAM,gBAAgB,0LAM5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAK/B,CAAC;AACF,eAAO,MAAM,gBAAgB,gDAE5B,CAAC;AACF,eAAO,MAAM,0BAA0B,gDAEtC,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AAEF,eAAO,MAAM,gBAAgB,sBAAgD,CAAC;AAE9E,eAAO,MAAM,oBAAoB,EAAE,gBAKlC,CAAC;AACF,eAAO,MAAM,mBAAmB,8CAI/B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,gBAKnC,CAAC;AACF,eAAO,MAAM,oBAAoB,wEAEhC,CAAC;AAEF,eA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AAM,6BAA6B,qHAKzC,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,kBAG3B,CAAC;AAEF,eAAO,MAAM,gBAAgB,sBAAgD,CAAC;AAE9E,eAAO,MAAM,oBAAoB,EAAE,gBAKlC,CAAC;AACF,eAAO,MAAM,mBAAmB,8CAI/B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,gBAKnC,CAAC;AACF,eAAO,MAAM,oBAAoB,wEAEhC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,gBAKlC,CAAC;AACF,eAAO,MAAM,mBAAmB,kJAM/B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,gBAKlC,CAAC;AACF,eAAO,MAAM,mBAAmB,gDAE/B,CAAC;AAEF,eAAO,MAAM,8BAA8B,yOAC6L,CAAC;AAEzO,eAAO,MAAM,gBAAgB,EAAE,kBAG9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,kBAG9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,kBAG9B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,kBAAkB,EAI5C,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,kBAAkB,EAAmC,CAAC;AAEjF,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,EAMtD,CAAC"}
@@ -1,5 +1,8 @@
1
+ import * as winston from 'winston';
1
2
  export declare function assertNever(x: never): never;
3
+ export declare function createLogger(level?: string): winston.Logger;
2
4
  export declare function findNodeModules(): string;
3
5
  export type PathType = 'absent' | 'file' | 'dir' | 'link' | 'unknown';
4
6
  export declare function pathType(path: string): PathType;
7
+ export declare function isUUID(uuid: string): boolean;
5
8
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/compiler/util.ts"],"names":[],"mappings":"AAGA,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAE3C;AAED,wBAAgB,eAAe,IAAI,MAAM,CAexC;AAED,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAW/C"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/compiler/util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAE3C;AAED,wBAAgB,YAAY,CAAC,KAAK,GAAE,MAAgB,GAAG,OAAO,CAAC,MAAM,CAapE;AAED,wBAAgB,eAAe,IAAI,MAAM,CAexC;AAED,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAW/C;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAG5C"}
package/dist/index.js CHANGED
@@ -1,43 +1,43 @@
1
- "use strict";var Me=Object.defineProperty;var je=(t,e,r)=>e in t?Me(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var l=(t,e,r)=>je(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ye=require("node:child_process"),h=require("@oclif/core"),Re=require("node:path"),be=require("node:fs"),ce=require("node:zlib"),Le=require("canonicalize"),I=require("winston"),Ce=require("node:fs/promises"),$e=require("@milaboratories/tengo-tester"),T=require("node:process");function se(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const d=se(Re),p=se(be),F=se(Ce);function x(t){throw new Error("Unexpected object: "+t)}function Ie(){let t=process.cwd();for(;t;){const e=d.join(t,"node_modules");if(p.existsSync(e))return e;const r=d.resolve(t,"..");if(r===t)break;t=r}throw new Error("Unable to find node_modules directory.")}function v(t){try{const e=p.statSync(t);return e.isDirectory()?"dir":e.isFile()?"file":e.isSymbolicLink()?"link":"unknown"}catch(e){if(e.code=="ENOENT")return"absent";throw e}}function de(t){return`${t.type}||${t.pkg}||${t.id}`}function m(t){return`${t.type}:${t.pkg}:${t.id}:${t.version}`}function g(t){return`${t.type}:${t.pkg}:${t.id}`}function fe(t,e){return t.type==e.type&&t.pkg==e.pkg&&t.id==e.id}function w(t){return`${t.pkg}:${t.id}`}function R(t){return{name:w(t),version:t.version}}function Ge(t){const e=t.name.match(/^(?<pkg>[^:]*):(?<id>[^:]*)$/);if(!e)throw new Error(`malformed artifact name: ${t.name}`);return{pkg:e.groups.pkg,id:e.groups.id,version:t.version}}function pe(t){return`${t.pkg}:${t.id}:${t.version}`}const ze=new TextDecoder,Pe=new TextEncoder;class ve{constructor(e,r,o){l(this,"data");l(this,"content");this.compileMode=e,this.fullName=r;let{data:n,content:s}=o;if(n===void 0&&s===void 0)throw new Error("Neither data nor content is provided for template constructor");if(n!==void 0&&s!==void 0)throw new Error("Both data and content are provided for template constructor");if(n===void 0&&(n=JSON.parse(ze.decode(ce.gunzipSync(s))),n.type!=="pl.tengo-template.v2"))throw new Error("malformed template");s===void 0&&(s=ce.gzipSync(Pe.encode(Le(n))));const i=Ge(n);if(i.pkg!==r.pkg||i.id!==r.id||i.version!==r.version)throw new Error(`Compiled template name don't match it's package and file names: ${pe(i)} != ${pe(r)}`);this.data=n,this.content=s}toJSON(){return{compileMode:this.compileMode,fullName:this.fullName,data:this.data}}}class G{constructor(e){l(this,"map",new Map);this.nameExtractor=e}add(e,r=!0){const o=de(this.nameExtractor(e)),n=this.map.get(o);return n&&!r||this.map.set(o,e),n}get(e){return this.map.get(de(e))}get array(){const e=[];return this.map.forEach(r=>e.push(r)),e}forEach(e){this.map.forEach(r=>e(r,this.nameExtractor(r)))}}function Je(){return new G(t=>t)}class L{constructor(e){l(this,"dev");l(this,"dist");this.nameExtractor=e,this.dev=new G(e),this.dist=new G(e)}add(e,r,o=!0){switch(e){case"dist":return this.dist.add(r,o);default:x(e)}}get(e,r){switch(e){case"dist":return this.dist.get(r);default:x(e)}}array(e){const r=[];return this.forEach(e,o=>r.push(o)),r}forEach(e,r){this.dist.forEach((o,n)=>r(this.get(e,n)??o,n))}}class qe{constructor(e){l(this,"libs",new L(e=>e.fullName));l(this,"software",new L(e=>e.fullName));l(this,"assets",new L(e=>e.fullName));l(this,"templates",new L(e=>e.fullName));this.compileMode=e}populateTemplateDataFromDependencies(e,r,o,n){for(const s of o)switch(s.type){case"library":const i=this.getLibOrError(s),a=n.indexOf(w(s));if(a>=0){let b=`library import recursion detected: ${n.slice(a).join(" -> ")} -> ${w(s)}`;throw new Error(b)}r.libs[w(s)]={...R(i.fullName),src:i.src},this.populateTemplateDataFromDependencies(e,r,i.dependencies,[...n,w(s)]);break;case"software":const c=this.getSoftwareOrError(s);r.software[w(s)]={...R(c.fullName),src:c.src};break;case"asset":const f=this.getAssetOrError(s);r.software[w(s)]={...R(f.fullName),src:f.src};break;case"template":if(fe(e,s))continue;const u=this.getTemplateOrError(s);r.templates[w(s)]=u.data;break;case"test":throw new Error(`dependencies tree error: tests should never be part of template: ${g(s)} is dependency of ${w(e)}`);default:x(s.type)}}compileAndAddTemplate(e){if(e.fullName.type!=="template")throw new Error("unexpected source type");const r={type:"pl.tengo-template.v2",...R(e.fullName),templates:{},libs:{},software:{},assets:{},src:e.src};this.populateTemplateDataFromDependencies(e.fullName,r,e.dependencies,[]);const o=new ve(e.compileMode,e.fullName,{data:r});return this.addTemplate(o),o}addLib(e){const r=this.libs.add(e.compileMode,e,!1);if(r)throw new Error(`compiler already contain such library: adding = ${m(e.fullName)}, contains = ${m(r.fullName)}`)}allLibs(){return this.libs.array(this.compileMode)}getLib(e){if(e.type!=="library")throw new Error(`illegal artifact type: got ${e.type} instead of 'library`);return this.libs.get(this.compileMode,e)}getLibOrError(e){const r=this.getLib(e);if(!r)throw new Error(`library not found: ${w(e)}`);return r}addSoftware(e){const r=this.software.add(e.compileMode,e,!1);if(r)throw new Error(`compiler already contain info for software: adding = ${m(e.fullName)}, contains = ${m(r.fullName)}`)}allSoftware(){return this.software.array(this.compileMode)}getSoftware(e){if(e.type!=="software")throw new Error(`illegal artifact type: got ${e.type} instead of 'software`);return this.software.get(this.compileMode,e)}getSoftwareOrError(e){const r=this.getSoftware(e);if(!r)throw new Error(`software info not found: ${w(e)}`);return r}addAsset(e){const r=this.assets.add(e.compileMode,e,!1);if(r)throw new Error(`compiler already contain info for asset: adding = ${m(e.fullName)}, contains = ${m(r.fullName)}`)}allAssets(){return this.assets.array(this.compileMode)}getAsset(e){if(e.type!=="asset")throw new Error(`illegal artifact type: got ${e.type} instead of 'asset`);return this.assets.get(this.compileMode,e)}getAssetOrError(e){const r=this.getAsset(e);if(!r)throw new Error(`asset info not found: ${w(e)}`);return r}addTemplate(e){const r=this.templates.add(e.compileMode,e,!1);if(r)throw new Error(`compiler already contain such template: adding = ${m(e.fullName)}, contains = ${m(r.fullName)}`)}allTemplates(){return this.templates.array(this.compileMode)}getTemplate(e){if(e.type!=="template")throw new Error(`illegal artifact type: got ${e.type} instead of 'template`);return this.templates.get(this.compileMode,e)}getTemplateOrError(e){const r=this.getTemplate(e);if(!r)throw new Error(`template not found: ${w(e)}`);return r}getArtefact(e){switch(e.type){case"template":return this.getTemplate(e);case"library":return this.getLib(e);case"software":return this.getSoftware(e);case"asset":return this.getAsset(e);case"test":return;default:x(e.type)}}checkLibs(){this.libs.forEach(this.compileMode,e=>{for(const r of e.dependencies){if(r.type==="test")throw new Error(`test should never be dependency of production code: ${g(r)} test is dependency of ${m(e.fullName)}`);if(!this.getArtefact(r))throw new Error(`unresolved dependency ${g(r)} for ${m(e.fullName)}`)}})}compileAndAdd(e){const r={templates:[],libs:[],software:[],assets:[]};let o=[];for(const n of e)n.fullName.type==="library"?(this.addLib(n),r.libs.push(n)):n.fullName.type==="software"?(this.addSoftware(n),r.software.push(n)):n.fullName.type==="asset"?(this.addAsset(n),r.assets.push(n)):o.push(n);for(;o.length>0;){const n=[];for(const s of o){const i=s.dependencies.filter(a=>!this.getArtefact(a)&&!(s.fullName.type==="template"&&fe(s.fullName,a)));if(i.length>0){let a=`Unsatisfied dependencies in ${m(s.fullName)}:
1
+ "use strict";var Me=Object.defineProperty;var Re=(s,e,t)=>e in s?Me(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var l=(s,e,t)=>Re(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ye=require("node:child_process"),h=require("@oclif/core"),je=require("node:path"),be=require("node:fs"),Le=require("winston"),ce=require("node:zlib"),Ce=require("canonicalize"),Ie=require("node:fs/promises"),ve=require("@milaboratories/tengo-tester"),D=require("node:process");function C(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const f=C(je),p=C(be),_=C(Le),O=C(Ie);function x(s){throw new Error("Unexpected object: "+s)}function $(s="debug"){return _.createLogger({level:s,format:_.format.printf(({level:e,message:t})=>`${e.padStart(6," ")}: ${t}`),transports:[new _.transports.Console({stderrLevels:["error","warn","info","debug"],handleExceptions:!0})]})}function _e(){let s=process.cwd();for(;s;){const e=f.join(s,"node_modules");if(p.existsSync(e))return e;const t=f.resolve(s,"..");if(t===s)break;s=t}throw new Error("Unable to find node_modules directory.")}function N(s){try{const e=p.statSync(s);return e.isDirectory()?"dir":e.isFile()?"file":e.isSymbolicLink()?"link":"unknown"}catch(e){if(e.code=="ENOENT")return"absent";throw e}}function Ge(s){return/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(s.toLowerCase())}function de(s){return`${s.type}||${s.pkg}||${s.id}`}function m(s){return`${s.type}:${s.pkg}:${s.id}:${s.version}`}function g(s){return`${s.type}:${s.pkg}:${s.id}`}function fe(s,e){return s.type==e.type&&s.pkg==e.pkg&&s.id==e.id}function w(s){return`${s.pkg}:${s.id}`}function j(s){return{name:w(s),version:s.version}}function Pe(s){const e=s.name.match(/^(?<pkg>[^:]*):(?<id>[^:]*)$/);if(!e)throw new Error(`malformed artifact name: ${s.name}`);return{pkg:e.groups.pkg,id:e.groups.id,version:s.version}}function pe(s){return`${s.pkg}:${s.id}:${s.version}`}const ze=new TextDecoder,qe=new TextEncoder;class Ee{constructor(e,t,r){l(this,"data");l(this,"content");this.compileMode=e,this.fullName=t;let{data:n,content:o}=r;if(n===void 0&&o===void 0)throw new Error("Neither data nor content is provided for template constructor");if(n!==void 0&&o!==void 0)throw new Error("Both data and content are provided for template constructor");if(n===void 0&&(n=JSON.parse(ze.decode(ce.gunzipSync(o))),n.type!=="pl.tengo-template.v2"))throw new Error("malformed template");o===void 0&&(o=ce.gzipSync(qe.encode(Ce(n))));const i=Pe(n);if(i.pkg!==t.pkg||i.id!==t.id||i.version!==t.version)throw new Error(`Compiled template name don't match it's package and file names: ${pe(i)} != ${pe(t)}`);this.data=n,this.content=o}toJSON(){return{compileMode:this.compileMode,fullName:this.fullName,data:this.data}}}class G{constructor(e){l(this,"map",new Map);this.nameExtractor=e}add(e,t=!0){const r=de(this.nameExtractor(e)),n=this.map.get(r);return n&&!t||this.map.set(r,e),n}get(e){return this.map.get(de(e))}get array(){const e=[];return this.map.forEach(t=>e.push(t)),e}forEach(e){this.map.forEach(t=>e(t,this.nameExtractor(t)))}}function Je(){return new G(s=>s)}class L{constructor(e){l(this,"dev");l(this,"dist");this.nameExtractor=e,this.dev=new G(e),this.dist=new G(e)}add(e,t,r=!0){switch(e){case"dist":return this.dist.add(t,r);default:x(e)}}get(e,t){switch(e){case"dist":return this.dist.get(t);default:x(e)}}array(e){const t=[];return this.forEach(e,r=>t.push(r)),t}forEach(e,t){this.dist.forEach((r,n)=>t(this.get(e,n)??r,n))}}function Ue(s,e){for(const t of s)switch(t.name){case"hash_override":{e.hashOverride=Be(t.args);break}}}function We(s,e){for(const t of s)switch(t.name){case"hash_override":throw new Error("hash_override compiler option can be used ONLY on template level. Even in templates it is already dangerous enough to potentially break everything in Platforma Backend. In libraries with the transitive dependencies resolution and flattening of libraries list on template level, it becomes so unpredictibally disasterous, that we are doomed to never find the ends of a knot if anything goes wrong.")}}function Be(s){if(s.length!=1)throw new Error("hash_override compiler option expects exactly one argument: hash_override <some string>. Note, you can use only UUID as a value.");const e=s[0].toLowerCase();if(!Ge(e))throw new Error(`hash_override must contain valid UUID as an override. As hash_override affects deduplication, it becomes completely not possible to distinguish several different templates from each other on backend's side. This means, if you set hash_override to a simple value (say, letter "a") on two completely different templates, they will be marked as interchangeable on backend's side with unpredictable consequences. UUID looks like a safe enough tradeoff between the feature usage simplicity and duplication safety`);return e}class Ve{constructor(e){l(this,"libs",new L(e=>e.fullName));l(this,"software",new L(e=>e.fullName));l(this,"assets",new L(e=>e.fullName));l(this,"templates",new L(e=>e.fullName));this.compileMode=e}populateTemplateDataFromDependencies(e,t,r,n){for(const o of r)switch(o.type){case"library":{const u=this.getLibOrError(o),d=n.indexOf(w(o));if(d>=0){let y=`library import recursion detected: ${n.slice(d).join(" -> ")} -> ${w(o)}`;throw new Error(y)}const b={...j(u.fullName),src:u.src};We(u.compilerOptions),t.libs[w(o)]=b,this.populateTemplateDataFromDependencies(e,t,u.dependencies,[...n,w(o)]);break}case"software":const i=this.getSoftwareOrError(o);t.software[w(o)]={...j(i.fullName),src:i.src};break;case"asset":const a=this.getAssetOrError(o);t.software[w(o)]={...j(a.fullName),src:a.src};break;case"template":if(fe(e,o))continue;const c=this.getTemplateOrError(o);t.templates[w(o)]=c.data;break;case"test":throw new Error(`dependencies tree error: tests should never be part of template: ${g(o)} is dependency of ${w(e)}`);default:x(o.type)}}compileAndAddTemplate(e){if(e.fullName.type!=="template")throw new Error("unexpected source type");const t={type:"pl.tengo-template.v2",...j(e.fullName),templates:{},libs:{},software:{},assets:{},src:e.src};Ue(e.compilerOptions,t),this.populateTemplateDataFromDependencies(e.fullName,t,e.dependencies,[]);const r=new Ee(e.compileMode,e.fullName,{data:t});return this.addTemplate(r),r}addLib(e){const t=this.libs.add(e.compileMode,e,!1);if(t)throw new Error(`compiler already contain such library: adding = ${m(e.fullName)}, contains = ${m(t.fullName)}`)}allLibs(){return this.libs.array(this.compileMode)}getLib(e){if(e.type!=="library")throw new Error(`illegal artifact type: got ${e.type} instead of 'library`);return this.libs.get(this.compileMode,e)}getLibOrError(e){const t=this.getLib(e);if(!t)throw new Error(`library not found: ${w(e)}`);return t}addSoftware(e){const t=this.software.add(e.compileMode,e,!1);if(t)throw new Error(`compiler already contain info for software: adding = ${m(e.fullName)}, contains = ${m(t.fullName)}`)}allSoftware(){return this.software.array(this.compileMode)}getSoftware(e){if(e.type!=="software")throw new Error(`illegal artifact type: got ${e.type} instead of 'software`);return this.software.get(this.compileMode,e)}getSoftwareOrError(e){const t=this.getSoftware(e);if(!t)throw new Error(`software info not found: ${w(e)}`);return t}addAsset(e){const t=this.assets.add(e.compileMode,e,!1);if(t)throw new Error(`compiler already contain info for asset: adding = ${m(e.fullName)}, contains = ${m(t.fullName)}`)}allAssets(){return this.assets.array(this.compileMode)}getAsset(e){if(e.type!=="asset")throw new Error(`illegal artifact type: got ${e.type} instead of 'asset`);return this.assets.get(this.compileMode,e)}getAssetOrError(e){const t=this.getAsset(e);if(!t)throw new Error(`asset info not found: ${w(e)}`);return t}addTemplate(e){const t=this.templates.add(e.compileMode,e,!1);if(t)throw new Error(`compiler already contain such template: adding = ${m(e.fullName)}, contains = ${m(t.fullName)}`)}allTemplates(){return this.templates.array(this.compileMode)}getTemplate(e){if(e.type!=="template")throw new Error(`illegal artifact type: got ${e.type} instead of 'template`);return this.templates.get(this.compileMode,e)}getTemplateOrError(e){const t=this.getTemplate(e);if(!t)throw new Error(`template not found: ${w(e)}`);return t}getArtefact(e){switch(e.type){case"template":return this.getTemplate(e);case"library":return this.getLib(e);case"software":return this.getSoftware(e);case"asset":return this.getAsset(e);case"test":return;default:x(e.type)}}checkLibs(){this.libs.forEach(this.compileMode,e=>{for(const t of e.dependencies){if(t.type==="test")throw new Error(`test should never be dependency of production code: ${g(t)} test is dependency of ${m(e.fullName)}`);if(!this.getArtefact(t))throw new Error(`unresolved dependency ${g(t)} for ${m(e.fullName)}`)}})}compileAndAdd(e){const t={templates:[],libs:[],software:[],assets:[]};let r=[];for(const n of e)n.fullName.type==="library"?(this.addLib(n),t.libs.push(n)):n.fullName.type==="software"?(this.addSoftware(n),t.software.push(n)):n.fullName.type==="asset"?(this.addAsset(n),t.assets.push(n)):r.push(n);for(;r.length>0;){const n=[];for(const o of r){const i=o.dependencies.filter(a=>!this.getArtefact(a)&&!(o.fullName.type==="template"&&fe(o.fullName,a)));if(i.length>0){let a=`Unsatisfied dependencies in ${m(o.fullName)}:
2
2
  `;for(const c of i)a+=` - ${g(c)}
3
- `;n.push({src:s,err:Error(a)});continue}switch(s.fullName.type){case"library":this.addLib(s),r.libs.push(s);break;case"software":this.addSoftware(s),r.software.push(s);break;case"asset":this.addAsset(s),r.assets.push(s);break;case"template":try{const a=this.compileAndAddTemplate(s);r.templates.push(a)}catch(a){let c=`Unsatisfied dependencies in ${m(s.fullName)}:
3
+ `;n.push({src:o,err:Error(a)});continue}switch(o.fullName.type){case"library":this.addLib(o),t.libs.push(o);break;case"software":this.addSoftware(o),t.software.push(o);break;case"asset":this.addAsset(o),t.assets.push(o);break;case"template":try{const a=this.compileAndAddTemplate(o);t.templates.push(a)}catch(a){let c=`Unsatisfied dependencies in ${m(o.fullName)}:
4
4
  `;c+=` - ${a.message}
5
- `,n.push({src:s,err:Error(c)})}break;case"test":break;default:x(s.fullName.type)}}if(o.length===n.length){let s="";for(const i of n)s+=`
6
- ${i.err.message}`;throw new Error(s)}o=n.map(({src:s})=>s)}return r}}const ue="[_a-zA-Z][_a-zA-Z0-9]*",O=(t,e)=>new RegExp(`\\b${t}\\.(?<fnCall>(?<fnName>`+e+')\\s*\\(\\s*"(?<templateName>[^"]+)"\\s*\\))'),We=t=>O(t,"getTemplateId"),_e=t=>O(t,"getSoftwareInfo"),me=t=>O(t,"importTemplate"),ge=t=>O(t,"importSoftware"),Ue=t=>O(t,"importAsset"),Be=/^\s*(\/\/)|(\/\*.*\*\/)/,Ve=/^\s*\/\*/,Ze=/\*\//,Ee=/\s*:=\s*import\s*\(\s*"(?<moduleName>[^"]+)"\s*\)/,Ke=new RegExp(`\\b(?<importName>${ue}(\\.${ue})*)${Ee.source}`),Xe=/(?<pkgName>[^"]+)?:(?<depID>[^"]+)/;class re{constructor(e,r,o,n,s){this.compileMode=e,this.fullName=r,this.src=o,this.srcName=n,this.dependencies=s}}function Ne(t,e,r,o){const n=be.readFileSync(e).toString(),{deps:s,normalized:i}=He(n,r,o);return new re(t,r,i,e,s.array)}function He(t,e,r){const o=Je(),n=t.split(`
7
- `),s=[];let i={isInCommentBlock:!1,tplDepREs:new Map},a=0;for(const c of n){a++;try{const f=Qe(c,i,e.pkg,r);s.push(f.line),i=f.context,f.artifact&&o.add(f.artifact)}catch(f){throw new Error(`[line ${a}]: ${f.message}
8
- ${c}`)}}return{normalized:s.join(`
9
- `),deps:o}}function Qe(t,e,r,o){if(e.isInCommentBlock)return Ze.exec(t)&&(e.isInCommentBlock=!1),{line:t,context:e,artifact:void 0};if(Be.exec(t))return{line:t,context:e,artifact:void 0};if(Ve.exec(t))return e.isInCommentBlock=!0,{line:t,context:e,artifact:void 0};const n=Ee.exec(t);if(n){const s=Ye(t);if(s.module==="plapi")return e.tplDepREs.has(s.module)||e.tplDepREs.set(s.module,[["template",We(s.alias)],["software",_e(s.alias)]]),{line:t,context:e,artifact:void 0};(s.module==="@milaboratory/tengo-sdk:ll"||s.module==="@platforma-sdk/workflow-tengo:ll"||(r==="@milaboratory/tengo-sdk"||r==="@platforma-sdk/workflow-tengo")&&s.module===":ll")&&(e.tplDepREs.has(s.module)||e.tplDepREs.set(s.module,[["template",me(s.alias)],["software",ge(s.alias)]])),(s.module==="@milaboratory/tengo-sdk:assets"||s.module==="@platforma-sdk/workflow-tengo:assets"||(r==="@milaboratory/tengo-sdk"||r==="@platforma-sdk/workflow-tengo")&&s.module===":assets")&&(e.tplDepREs.has(s.module)||e.tplDepREs.set(s.module,[["template",me(s.alias)],["software",ge(s.alias)],["asset",Ue(s.alias)]]));const i=he(s.module,"library",r);return i?(t=t.replace(n[0],` := import("${i.pkg}:${i.id}")`),{line:t,context:e,artifact:i}):{line:t,context:e,artifact:void 0}}if(e.tplDepREs.size>0)for(const[s,i]of e.tplDepREs)for(const[a,c]of i){const f=c.exec(t);if(!f||!f.groups)continue;const{fnCall:u,templateName:b,fnName:$}=f.groups;if(!u||!b||!$)throw Error("failed to parse template import statement");const y=he(b,a,r);if(!y)throw Error(`failed to parse artifact name in ${$} import statement`);return t=t.replace(u,`${$}("${y.pkg}:${y.id}")`),{line:t,context:e,artifact:y}}return{line:t,context:e,artifact:void 0}}function Ye(t){const e=Ke.exec(t);if(!e||!e.groups)throw Error("failed to parse 'import' statement");const{importName:r,moduleName:o}=e.groups;if(!r||!o)throw Error("failed to parse 'import' statement");return{module:o,alias:r}}function he(t,e,r){const o=Xe.exec(t);if(!o)return;if(!o.groups)throw Error("failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'");const{pkgName:n,depID:s}=o.groups;if(!s)throw Error("failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'");return{type:e,pkg:n??r,id:s}}const z=".plj.gz",P=".lib.tengo",J=".sw.json",q=".as.json",we=".test.tengo",W=".tpl.tengo",_=".lib.tengo",U=".sw.json",B=".as.json",et=[_,W,U,B];function E(t="debug"){return I.createLogger({level:t,format:I.format.printf(({level:e,message:r})=>`${e.padStart(6," ")}: ${r}`),transports:[new I.transports.Console({stderrLevels:["error","warn","info","debug"],handleExceptions:!0})]})}function M(){return JSON.parse(p.readFileSync("package.json").toString())}function Se(t,e){return d.resolve(e,t,"tengo","lib")}function ke(t,e){return d.resolve(e,t,"tengo","tpl")}function Ae(t,e){return d.resolve(e,t,"tengo","software")}function Te(t,e){return d.resolve(e,t,"tengo","asset")}function De(t,e,r,o,n=!1){const s=d.resolve(o,"package.json");if(v(s)!=="file"){for(const ae of p.readdirSync(o)){const Oe=v(d.join(o,ae))==="link",le=d.resolve(o,ae);v(le)==="dir"&&De(t,e,r,le,Oe)}return}const i=Se("dist",o),a=ke("dist",o),c=Ae("dist",o),f=Te("dist",o),u=v(i)==="dir",b=v(a)==="dir",$=v(c)==="dir",y=v(f)==="dir";if(!u&&!b&&!$&&!y)return;const D=JSON.parse(p.readFileSync(s).toString());if(D.name!==r.name){if(v(d.resolve(o,"node_modules"))==="dir"&&n)throw new Error(`nested node_modules is a sign of library dependencies version incompatibility in ${o}`);u&&tt(t,D,"dist",i,e),b&&st(t,D,"dist",a,e),$&&rt(t,D,"dist",c,e),y&&ot(t,D,"dist",f,e)}}function tt(t,e,r,o,n){for(const s of p.readdirSync(o)){const i=d.resolve(o,s);if(!s.endsWith(P))throw new Error(`unexpected file in 'lib' folder: ${i}`);const a={type:"library",pkg:e.name,id:s.slice(0,s.length-P.length),version:e.version},c=Ne(r,i,a,!0);if(n.addLib(c),t.debug(`Adding dependency ${m(a)} from ${i}`),c.dependencies.length>0){t.debug("Dependencies:");for(const f of c.dependencies)t.debug(` - ${g(f)}`)}}}function st(t,e,r,o,n){for(const s of p.readdirSync(o)){const i=d.resolve(o,s);if(!s.endsWith(z))throw new Error(`unexpected file in 'tpl' folder: ${i}`);const a={type:"template",pkg:e.name,id:s.slice(0,s.length-z.length),version:e.version},c=new ve(r,a,{content:p.readFileSync(i)});n.addTemplate(c),t.debug(`Adding dependency ${m(a)} from ${i}`)}}function rt(t,e,r,o,n){for(const s of p.readdirSync(o)){const i=d.resolve(o,s);if(!s.endsWith(J))throw new Error(`unexpected file in 'software' folder: ${i}`);const a={type:"software",pkg:e.name,id:s.slice(0,s.length-J.length),version:e.version},c=new re(r,a,p.readFileSync(i).toString(),i,[]);t.debug(`Adding dependency ${m(a)} from ${i}`),n.addSoftware(c)}}function ot(t,e,r,o,n){for(const s of p.readdirSync(o)){const i=d.resolve(o,s);if(!s.endsWith(q))throw new Error(`unexpected file in 'asset' folder: ${i}`);const a={type:"asset",pkg:e.name,id:s.slice(0,s.length-q.length),version:e.version},c=new re(r,a,p.readFileSync(i).toString(),i,[]);t.debug(`Adding dependency ${m(a)} from ${i}`),n.addAsset(c)}}function j(t,e,r,o,n){const s=[];for(const i of p.readdirSync(d.join(o,n))){const a=d.join(n,i),c=d.join(o,a);if(v(c)==="dir"){const y=j(t,e,r,o,a);s.push(...y);continue}const f=i==="index.lib.tengo"?`${d.basename(n)}.lib.tengo`:a,u=nt(e,f.replaceAll(d.sep,"."));if(!u)continue;const b=d.resolve(o,a);t.debug(`Parsing ${m(u)} from ${b}`);const $=Ne(r,b,u,!0);if($.dependencies.length>0){t.debug("Detected dependencies:");for(const y of $.dependencies)t.debug(` - ${g(y)}`)}s.push($)}return s}function oe(t,e,r){const o=new qe(r);return De(t,o,e,Ie()),o}function nt(t,e){const r={pkg:t.name,version:t.version};return e.endsWith(_)?{...r,id:e.substring(0,e.length-_.length),type:"library"}:e.endsWith(W)?{...r,id:e.substring(0,e.length-W.length),type:"template"}:e.endsWith(U)?{...r,id:e.substring(0,e.length-U.length),type:"software"}:e.endsWith(B)?{...r,id:e.substring(0,e.length-B.length),type:"asset"}:e.endsWith(we)?{...r,id:e.substring(0,e.length-we.length),type:"test"}:null}function it(t,e){const r=M(),o=oe(t,r,e),n=j(t,r,e,"src","");if(n.length===0){const i=[];for(const a of et)i.push(`*${a}`);t.error(`Nothing to compile. Looked for ${i.join(", ")}`),process.exit(1)}t.info(`Compiling '${e}'...`);const s=o.compileAndAdd(n);return t.debug("Done."),s}function at(t,e,r){if(e.libs.length>0){const o=Se(r,".");p.mkdirSync(o,{recursive:!0});for(const n of e.libs){const s=d.resolve(o,n.fullName.id+P);t.info(` - writing ${s}`),p.writeFileSync(s,n.src)}}if(e.templates.length>0){const o=ke(r,".");p.mkdirSync(o,{recursive:!0});for(const n of e.templates){const s=d.resolve(o,n.fullName.id+z);t.info(` - writing ${s}`),p.writeFileSync(s,n.content)}}if(e.software.length>0){const o=Ae(r,".");p.mkdirSync(o,{recursive:!0});for(const n of e.software){const s=d.resolve(o,n.fullName.id+J);t.info(` - writing ${s}`),p.writeFileSync(s,n.src)}}if(e.assets.length>0){const o=Te(r,".");p.mkdirSync(o,{recursive:!0});for(const n of e.software){const s=d.resolve(o,n.fullName.id+q);t.info(` - writing ${s}`),p.writeFileSync(s,n.src)}}}const ne={"log-level":h.Flags.string({description:"logging level",default:"info",options:["error","warn","info","debug"]})},lt={"generate-tags":h.Flags.boolean({description:"generate tags, default false",default:!1}),"tags-file":h.Flags.file({description:'where to put ".tags" file, it should be a root of VS Code project',default:"../../.tags"}),"tags-additional-args":h.Flags.string({description:"additional flags for universal-ctags command: e.g. -e for emacs",default:[],multiple:!0,delimiter:","})},k=class k extends h.Command{async run(){const{flags:e}=await this.parse(k),r=E(e["log-level"]),o=M(),n=it(r,"dist");at(r,n,"dist"),r.info("");let s=`declare type TemplateFromFile = { readonly type: "from-file"; readonly path: string; };
10
- `;s+=`declare type TplName = ${n.templates.map(u=>'"'+u.fullName.id+'"').join(" | ")};
11
- `,s+=`declare const Templates: Record<TplName, TemplateFromFile>;
12
- `,s+=`export { Templates };
5
+ `,n.push({src:o,err:Error(c)})}break;case"test":break;default:x(o.fullName.type)}}if(r.length===n.length){let o="";for(const i of n)o+=`
6
+ ${i.err.message}`;throw new Error(o)}r=n.map(({src:o})=>o)}return t}}const ue="[_a-zA-Z][_a-zA-Z0-9]*",F=(s,e)=>new RegExp(`\\b${s}\\.(?<fnCall>(?<fnName>`+e+')\\s*\\(\\s*"(?<templateName>[^"]+)"\\s*\\))'),Ze=s=>F(s,"getTemplateId"),Ke=s=>F(s,"getSoftwareInfo"),me=s=>F(s,"importTemplate"),ge=s=>F(s,"importSoftware"),Xe=s=>F(s,"importAsset"),Ye=/^\s*$/,He=/^\/\/tengo:[\w]/,Qe=/^\s*\/\/\s*tengo:\s*./,et=/^\s*(\/\/)|(\/\*.*\*\/)/,tt=/^\s*\/\*/,st=/\*\//,Ne=/\s*:=\s*import\s*\(\s*"(?<moduleName>[^"]+)"\s*\)/,ot=new RegExp(`\\b(?<importName>${ue}(\\.${ue})*)${Ne.source}`),rt=/(?<pkgName>[^"]+)?:(?<depID>[^"]+)/,nt=s=>{const e=s.split(" "),t=e[0].split(":");if(t.length!=2)throw new Error("compiler option format is wrong: expect to have option name after 'tengo:' prefix, like 'tengo:MyOption'");return{name:t[1],args:e.slice(1)}};class oe{constructor(e,t,r,n,o,i){this.compileMode=e,this.fullName=t,this.src=r,this.srcName=n,this.dependencies=o,this.compilerOptions=i}}function $e(s,e,t,r,n){const o=be.readFileSync(t).toString(),{deps:i,normalized:a,opts:c}=it(s,o,r,n);return new oe(e,r,a,t,i.array,c)}function it(s,e,t,r){const n=Je(),o=[],i=e.split(`
7
+ `),a=[];let c={isInCommentBlock:!1,canDetectOptions:!0,tplDepREs:new Map,lineNo:0};for(const u of i){c.lineNo++;try{const d=at(s,u,c,t.pkg,r);a.push(d.line),c=d.context,d.artifact&&n.add(d.artifact),d.option&&o.push(d.option)}catch(d){throw new Error(`[line ${c.lineNo}]: ${d.message}
8
+ ${u}`)}}return{normalized:a.join(`
9
+ `),deps:n,opts:o}}function at(s,e,t,r,n){if(t.isInCommentBlock)return st.exec(e)&&(t.isInCommentBlock=!1),{line:e,context:t,artifact:void 0,option:void 0};if(He.exec(e)){if(!t.canDetectOptions)throw s.error(`[line ${t.lineNo}]: compiler option '//tengo:' was detected, but it cannot be applied as compiler options can be set only at the file header, before any code line'`),new Error("tengo compiler options ('//tengo:' comments) can be set only in file header");return{line:e,context:t,artifact:void 0,option:nt(e)}}if(Qe.exec(e)&&t.canDetectOptions)return s.warn(`[line ${t.lineNo}]: text simillar to compiler option ('//tengo:...') was detected, but it has wrong format. Leave it as is, if you did not mean to use a line as compiler option. Or format it to '//tengo:<option>' otherwise (no spaces between '//' and 'tengo', no spaces between ':' and option name)`),{line:e,context:t,artifact:void 0,option:void 0};if(et.exec(e))return{line:e,context:t,artifact:void 0,option:void 0};if(tt.exec(e))return t.isInCommentBlock=!0,{line:e,context:t,artifact:void 0,option:void 0};if(Ye.exec(e))return{line:e,context:t,artifact:void 0,option:void 0};t.canDetectOptions=!1;const o=Ne.exec(e);if(o){const i=lt(e);if(i.module==="plapi")return t.tplDepREs.has(i.module)||t.tplDepREs.set(i.module,[["template",Ze(i.alias)],["software",Ke(i.alias)]]),{line:e,context:t,artifact:void 0,option:void 0};(i.module==="@milaboratory/tengo-sdk:ll"||i.module==="@platforma-sdk/workflow-tengo:ll"||(r==="@milaboratory/tengo-sdk"||r==="@platforma-sdk/workflow-tengo")&&i.module===":ll")&&(t.tplDepREs.has(i.module)||t.tplDepREs.set(i.module,[["template",me(i.alias)],["software",ge(i.alias)]])),(i.module==="@milaboratory/tengo-sdk:assets"||i.module==="@platforma-sdk/workflow-tengo:assets"||(r==="@milaboratory/tengo-sdk"||r==="@platforma-sdk/workflow-tengo")&&i.module===":assets")&&(t.tplDepREs.has(i.module)||t.tplDepREs.set(i.module,[["template",me(i.alias)],["software",ge(i.alias)],["asset",Xe(i.alias)]]));const a=he(i.module,"library",r);return a?(e=e.replace(o[0],` := import("${a.pkg}:${a.id}")`),{line:e,context:t,artifact:a,option:void 0}):{line:e,context:t,artifact:void 0,option:void 0}}if(t.tplDepREs.size>0)for(const[i,a]of t.tplDepREs)for(const[c,u]of a){const d=u.exec(e);if(!d||!d.groups)continue;const{fnCall:b,templateName:y,fnName:v}=d.groups;if(!b||!y||!v)throw Error("failed to parse template import statement");const E=he(y,c,r);if(!E)throw Error(`failed to parse artifact name in ${v} import statement`);return e=e.replace(b,`${v}("${E.pkg}:${E.id}")`),{line:e,context:t,artifact:E,option:void 0}}return{line:e,context:t,artifact:void 0,option:void 0}}function lt(s){const e=ot.exec(s);if(!e||!e.groups)throw Error("failed to parse 'import' statement");const{importName:t,moduleName:r}=e.groups;if(!t||!r)throw Error("failed to parse 'import' statement");return{module:r,alias:t}}function he(s,e,t){const r=rt.exec(s);if(!r)return;if(!r.groups)throw Error("failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'");const{pkgName:n,depID:o}=r.groups;if(!o)throw Error("failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'");return{type:e,pkg:n??t,id:o}}const P=".plj.gz",z=".lib.tengo",q=".sw.json",J=".as.json",we=".test.tengo",U=".tpl.tengo",W=".lib.tengo",B=".sw.json",V=".as.json",ct=[W,U,B,V];function M(){return JSON.parse(p.readFileSync("package.json").toString())}function Se(s,e){return f.resolve(e,s,"tengo","lib")}function ke(s,e){return f.resolve(e,s,"tengo","tpl")}function Ae(s,e){return f.resolve(e,s,"tengo","software")}function Te(s,e){return f.resolve(e,s,"tengo","asset")}function De(s,e,t,r,n=!1){const o=f.resolve(r,"package.json");if(N(o)!=="file"){for(const ae of p.readdirSync(r)){const Fe=N(f.join(r,ae))==="link",le=f.resolve(r,ae);N(le)==="dir"&&De(s,e,t,le,Fe)}return}const i=Se("dist",r),a=ke("dist",r),c=Ae("dist",r),u=Te("dist",r),d=N(i)==="dir",b=N(a)==="dir",y=N(c)==="dir",v=N(u)==="dir";if(!d&&!b&&!y&&!v)return;const E=JSON.parse(p.readFileSync(o).toString());if(E.name!==t.name){if(N(f.resolve(r,"node_modules"))==="dir"&&n)throw new Error(`nested node_modules is a sign of library dependencies version incompatibility in ${r}`);d&&dt(s,E,"dist",i,e),b&&ft(s,E,"dist",a,e),y&&pt(s,E,"dist",c,e),v&&ut(s,E,"dist",u,e)}}function dt(s,e,t,r,n){for(const o of p.readdirSync(r)){const i=f.resolve(r,o);if(!o.endsWith(z))throw new Error(`unexpected file in 'lib' folder: ${i}`);const a={type:"library",pkg:e.name,id:o.slice(0,o.length-z.length),version:e.version},c=$e(s,t,i,a,!0);if(n.addLib(c),s.debug(`Adding dependency ${m(a)} from ${i}`),c.dependencies.length>0){s.debug("Dependencies:");for(const u of c.dependencies)s.debug(` - ${g(u)}`)}}}function ft(s,e,t,r,n){for(const o of p.readdirSync(r)){const i=f.resolve(r,o);if(!o.endsWith(P))throw new Error(`unexpected file in 'tpl' folder: ${i}`);const a={type:"template",pkg:e.name,id:o.slice(0,o.length-P.length),version:e.version},c=new Ee(t,a,{content:p.readFileSync(i)});n.addTemplate(c),s.debug(`Adding dependency ${m(a)} from ${i}`)}}function pt(s,e,t,r,n){for(const o of p.readdirSync(r)){const i=f.resolve(r,o);if(!o.endsWith(q))throw new Error(`unexpected file in 'software' folder: ${i}`);const a={type:"software",pkg:e.name,id:o.slice(0,o.length-q.length),version:e.version},c=new oe(t,a,p.readFileSync(i).toString(),i,[],[]);s.debug(`Adding dependency ${m(a)} from ${i}`),n.addSoftware(c)}}function ut(s,e,t,r,n){for(const o of p.readdirSync(r)){const i=f.resolve(r,o);if(!o.endsWith(J))throw new Error(`unexpected file in 'asset' folder: ${i}`);const a={type:"asset",pkg:e.name,id:o.slice(0,o.length-J.length),version:e.version},c=new oe(t,a,p.readFileSync(i).toString(),i,[],[]);s.debug(`Adding dependency ${m(a)} from ${i}`),n.addAsset(c)}}function R(s,e,t,r,n){const o=[];for(const i of p.readdirSync(f.join(r,n))){const a=f.join(n,i),c=f.join(r,a);if(N(c)==="dir"){const v=R(s,e,t,r,a);o.push(...v);continue}const u=i==="index.lib.tengo"?`${f.basename(n)}.lib.tengo`:a,d=mt(e,u.replaceAll(f.sep,"."));if(!d)continue;const b=f.resolve(r,a);s.debug(`Parsing ${m(d)} from ${b}`);const y=$e(s,t,b,d,!0);if(y.dependencies.length>0){s.debug("Detected dependencies:");for(const v of y.dependencies)s.debug(` - ${g(v)}`)}o.push(y)}return o}function re(s,e,t){const r=new Ve(t);return De(s,r,e,_e()),r}function mt(s,e){const t={pkg:s.name,version:s.version};return e.endsWith(W)?{...t,id:e.substring(0,e.length-W.length),type:"library"}:e.endsWith(U)?{...t,id:e.substring(0,e.length-U.length),type:"template"}:e.endsWith(B)?{...t,id:e.substring(0,e.length-B.length),type:"software"}:e.endsWith(V)?{...t,id:e.substring(0,e.length-V.length),type:"asset"}:e.endsWith(we)?{...t,id:e.substring(0,e.length-we.length),type:"test"}:null}function gt(s,e){const t=M(),r=re(s,t,e),n=R(s,t,e,"src","");if(n.length===0){const i=[];for(const a of ct)i.push(`*${a}`);s.error(`Nothing to compile. Looked for ${i.join(", ")}`),process.exit(1)}s.info(`Compiling '${e}'...`);const o=r.compileAndAdd(n);return s.debug("Done."),o}function ht(s,e,t){if(e.libs.length>0){const r=Se(t,".");p.mkdirSync(r,{recursive:!0});for(const n of e.libs){const o=f.resolve(r,n.fullName.id+z);s.info(` - writing ${o}`),p.writeFileSync(o,n.src)}}if(e.templates.length>0){const r=ke(t,".");p.mkdirSync(r,{recursive:!0});for(const n of e.templates){const o=f.resolve(r,n.fullName.id+P);s.info(` - writing ${o}`),p.writeFileSync(o,n.content)}}if(e.software.length>0){const r=Ae(t,".");p.mkdirSync(r,{recursive:!0});for(const n of e.software){const o=f.resolve(r,n.fullName.id+q);s.info(` - writing ${o}`),p.writeFileSync(o,n.src)}}if(e.assets.length>0){const r=Te(t,".");p.mkdirSync(r,{recursive:!0});for(const n of e.software){const o=f.resolve(r,n.fullName.id+J);s.info(` - writing ${o}`),p.writeFileSync(o,n.src)}}}const ne={"log-level":h.Flags.string({description:"logging level",default:"info",options:["error","warn","info","debug"]})},wt={"generate-tags":h.Flags.boolean({description:"generate tags, default false",default:!1}),"tags-file":h.Flags.file({description:'where to put ".tags" file, it should be a root of VS Code project',default:"../../.tags"}),"tags-additional-args":h.Flags.string({description:"additional flags for universal-ctags command: e.g. -e for emacs",default:[],multiple:!0,delimiter:","})},A=class A extends h.Command{async run(){const{flags:e}=await this.parse(A),t=$(e["log-level"]),r=M(),n=gt(t,"dist");ht(t,n,"dist"),t.info("");let o=`declare type TemplateFromFile = { readonly type: "from-file"; readonly path: string; };
10
+ `;o+=`declare type TplName = ${n.templates.map(d=>'"'+d.fullName.id+'"').join(" | ")};
11
+ `,o+=`declare const Templates: Record<TplName, TemplateFromFile>;
12
+ `,o+=`export { Templates };
13
13
  `;let i=`module.exports = { Templates: {
14
14
  `,a=`import { resolve } from 'node:path';
15
15
  export const Templates = {
16
- `;const c=n.templates.map(u=>` '${u.fullName.id}': { type: 'from-file', path: require.resolve('./tengo/tpl/${u.fullName.id}.plj.gz') }`).join(`,
17
- `),f=n.templates.map(u=>` '${u.fullName.id}': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/${u.fullName.id}.plj.gz') }`).join(`,
18
- `);i+=c,a+=f,i+=`
16
+ `;const c=n.templates.map(d=>` '${d.fullName.id}': { type: 'from-file', path: require.resolve('./tengo/tpl/${d.fullName.id}.plj.gz') }`).join(`,
17
+ `),u=n.templates.map(d=>` '${d.fullName.id}': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/${d.fullName.id}.plj.gz') }`).join(`,
18
+ `);i+=c,a+=u,i+=`
19
19
  }};
20
20
  `,a+=`
21
21
  };
22
- `,await F.writeFile("dist/index.d.ts",s),o.type==="module"?(await F.writeFile("dist/index.cjs",i),await F.writeFile("dist/index.js",a)):(await F.writeFile("dist/index.js",i),await F.writeFile("dist/index.mjs",a)),ct(e),e["generate-tags"]&&dt(r,e),r.info("Template Pack build done.")}};l(k,"description","build tengo sources into single distributable pack file"),l(k,"examples",["<%= config.bin %> <%= command.id %>"]),l(k,"flags",{...ne,...lt});let V=k;function ct(t){process.env.GENERATE_TAGS!=null&&(t["generate-tags"]=process.env.GENERATE_TAGS=="true"),process.env.TAGS_FILE!=null&&(t["tags-file"]=process.env.TAGS_FILE),process.env.TAGS_ADDITIONAL_ARGS!=null&&(t["tags-additional-args"]=process.env.TAGS_ADDITIONAL_ARGS.split(","))}function dt(t,e){var a;const r=d.resolve(e["tags-file"]),o=d.dirname(r),n=e["tags-additional-args"],s=ft(o);t.info(`Generating tags for tengo autocompletion from "${o}" in "${r}", additional arguments: "${n}".
23
- Found ${s.length} tengo files...`);const i=ye.spawnSync("ctags",["-f",r,...n,"--langdef=tengo","--map-tengo=+.tengo","--kinddef-tengo=f,function,function","--regex-tengo=/^\\s*(.*)(:| :=| =) ?func.*/\\1/f/","--kinddef-tengo=c,constant,constant",'--regex-tengo=/^\\s*(.*) := ("|\\{).*/\\1/c/',"-R",...s],{env:process.env,stdio:"inherit",cwd:o});if((a=i.error)!=null&&a.message.includes("ENOENT")){console.log(`
22
+ `,await O.writeFile("dist/index.d.ts",o),r.type==="module"?(await O.writeFile("dist/index.cjs",i),await O.writeFile("dist/index.js",a)):(await O.writeFile("dist/index.js",i),await O.writeFile("dist/index.mjs",a)),yt(e),e["generate-tags"]&&bt(t,e),t.info("Template Pack build done.")}};l(A,"description","build tengo sources into single distributable pack file"),l(A,"examples",["<%= config.bin %> <%= command.id %>"]),l(A,"flags",{...ne,...wt});let Z=A;function yt(s){process.env.GENERATE_TAGS!=null&&(s["generate-tags"]=process.env.GENERATE_TAGS=="true"),process.env.TAGS_FILE!=null&&(s["tags-file"]=process.env.TAGS_FILE),process.env.TAGS_ADDITIONAL_ARGS!=null&&(s["tags-additional-args"]=process.env.TAGS_ADDITIONAL_ARGS.split(","))}function bt(s,e){var a;const t=f.resolve(e["tags-file"]),r=f.dirname(t),n=e["tags-additional-args"],o=vt(r);s.info(`Generating tags for tengo autocompletion from "${r}" in "${t}", additional arguments: "${n}".
23
+ Found ${o.length} tengo files...`);const i=ye.spawnSync("ctags",["-f",t,...n,"--langdef=tengo","--map-tengo=+.tengo","--kinddef-tengo=f,function,function","--regex-tengo=/^\\s*(.*)(:| :=| =) ?func.*/\\1/f/","--kinddef-tengo=c,constant,constant",'--regex-tengo=/^\\s*(.*) := ("|\\{).*/\\1/c/',"-R",...o],{env:process.env,stdio:"inherit",cwd:r});if((a=i.error)!=null&&a.message.includes("ENOENT")){console.log(`
24
24
  pl-tengo can create tags for tengo autocompletion,
25
25
  but the program should be installed
26
26
  with "brew install universal-ctags" on OSX
27
27
  or "sudo apt install universal-ctags" on Ubuntu.
28
28
 
29
29
  For vscode, you should also install ctags extension:
30
- https://marketplace.visualstudio.com/items?itemName=jaydenlin.ctags-support`);return}pt(i,"failed to generate ctags"),t.info("Generation of tags is done.")}function ft(t){const e=p.readdirSync(t,{withFileTypes:!0,recursive:!0}),r=[];return e.forEach(o=>{if(!o.isDirectory()&&o.name.endsWith(".tengo")){const n=d.join(o.parentPath,o.name).replace(t,".");r.push(n)}}),r}function pt(t,e){t.error&&console.log(t.error);const r=e;t.status!==0&&console.log(`WARN: ${r} the build will continue as-is`)}function ie(t,e){const r=M(),o=j(t,r,"dist","src",""),n=oe(t,r,"dist");for(const s of n.allLibs())t.debug(`Dumping to pl-tester: ${g(s.fullName)}`),e.write(JSON.stringify(s)+`
31
- `);for(const s of o)s.fullName.type==="library"&&(t.debug(`Dumping to pl-tester: ${g(s.fullName)}`),e.write(JSON.stringify(s)+`
32
- `));for(const s of n.allTemplates())t.debug(`Dumping to pl-tester: ${g(s.fullName)}`),e.write(JSON.stringify(s)+`
33
- `);for(const s of o)s.fullName.type==="template"&&(t.debug(`Dumping to pl-tester: ${g(s.fullName)} ${s.srcName}`),e.write(JSON.stringify(s)+`
34
- `));for(const s of n.allSoftware())t.debug(`Dumping to pl-tester: ${g(s.fullName)}`),e.write(JSON.stringify(s)+`
35
- `);for(const s of o)s.fullName.type==="software"&&(t.debug(`Dumping to pl-tester: ${g(s.fullName)}`),e.write(JSON.stringify(s)+`
36
- `));for(const s of n.allAssets())t.debug(`Dumping to pl-tester: ${g(s.fullName)}`),e.write(JSON.stringify(s)+`
37
- `);for(const s of o)s.fullName.type==="asset"&&(t.debug(`Dumping to pl-tester: ${g(s.fullName)}`),e.write(JSON.stringify(s)+`
38
- `));for(const s of o)s.fullName.type==="test"&&(t.debug(`Dumping to pl-tester: ${g(s.fullName)} ${s.srcName}`),e.write(JSON.stringify(s)+`
39
- `))}function ut(t,e,r){const o=M(),n=j(t,o,"dist","src","");if(!e){for(const i of n)i.fullName.type==="library"&&r.write(JSON.stringify(i)+`
40
- `);return}const s=oe(t,o,"dist");for(const i of n)i.fullName.type==="library"&&s.addLib(i);for(const i of s.allLibs())r.write(JSON.stringify(i)+`
41
- `)}function C(t,e,r){const o=M(),n=j(t,o,"dist","src","");for(const s of n)s.fullName.type===r&&e.write(JSON.stringify(s)+`
42
- `)}function mt(t,e){C(t,e,"template")}function gt(t,e){C(t,e,"software")}function ht(t,e){C(t,e,"asset")}function wt(t,e){C(t,e,"test")}function Fe(t,...e){const r=ye.spawn(t,e,{stdio:["pipe","inherit","inherit"]});return r.stdin.on("error",o=>{o.code}),r}function xe(t){return new Promise((e,r)=>{t.on("close",o=>{e(o)}),t.on("error",o=>{r(o)})})}const N=class N extends h.Command{async run(){const{flags:e,argv:r}=await this.parse(N),o=E(e["log-level"]),n=r.length==0?["./src"]:r,s=Fe($e.TengoTesterBinaryPath,"check","--log-level",e["log-level"],"--artifacts","-",...n);try{ie(o,s.stdin)}catch(i){o.error(i)}finally{s.stdin.end();const i=await xe(s);process.exit(i)}}};l(N,"description","check tengo sources for language processor an"),l(N,"strict",!1),l(N,"flags",{...ne}),l(N,"examples",["<%= config.bin %> <%= command.id %>"]);let Z=N;const S=class S extends h.Command{async run(){const{flags:e}=await this.parse(S),r=E(e["log-level"]),o=this.argv.length==0?["./src"]:this.argv,n=Fe($e.TengoTesterBinaryPath,"run","--log-level",e["log-level"],"--artifacts","-",...o);try{ie(r,n.stdin)}catch(s){r.error(s)}finally{n.stdin.end();const s=await xe(n);process.exit(s)}}};l(S,"description","run tengo unit tests (.test.tengo)"),l(S,"strict",!1),l(S,"flags",{...ne}),l(S,"examples",["<%= config.bin %> <%= command.id %>"]);let K=S;class X extends h.Command{async run(){const e=E();ie(e,T.stdout)}}l(X,"description","parse sources in current package and dump all found artifacts to stdout"),l(X,"examples",["<%= config.bin %> <%= command.id %>"]);class H extends h.Command{async run(){const e=E();ht(e,T.stdout)}}l(H,"description","parse sources in current package and dump all found tests to stdout"),l(H,"examples",["<%= config.bin %> <%= command.id %>"]);const A=class A extends h.Command{async run(){const{flags:e}=await this.parse(A),r=E();ut(r,e.deps,T.stdout)}};l(A,"description","parse sources in current package and dump all found templates to stdout"),l(A,"examples",["<%= config.bin %> <%= command.id %>"]),l(A,"flags",{deps:h.Flags.boolean({name:"deps",description:"add also all libraries found in node_modules"})});let Q=A;class Y extends h.Command{async run(){const e=E();gt(e,T.stdout)}}l(Y,"description","parse sources in current package and dump all found tests to stdout"),l(Y,"examples",["<%= config.bin %> <%= command.id %>"]);class ee extends h.Command{async run(){const e=E();mt(e,T.stdout)}}l(ee,"description","parse sources in current package and dump all found templates to stdout"),l(ee,"examples",["<%= config.bin %> <%= command.id %>"]);class te extends h.Command{async run(){const e=E();wt(e,T.stdout)}}l(te,"description","parse sources in current package and dump all found tests to stdout"),l(te,"examples",["<%= config.bin %> <%= command.id %>"]);const yt={build:V,check:Z,test:K,"dump:all":X,"dump:assets":H,"dump:libs":Q,"dump:software":Y,"dump:templates":ee,"dump:tests":te};exports.COMMANDS=yt;
30
+ https://marketplace.visualstudio.com/items?itemName=jaydenlin.ctags-support`);return}Et(i,"failed to generate ctags"),s.info("Generation of tags is done.")}function vt(s){const e=p.readdirSync(s,{withFileTypes:!0,recursive:!0}),t=[];return e.forEach(r=>{if(!r.isDirectory()&&r.name.endsWith(".tengo")){const n=f.join(r.parentPath,r.name).replace(s,".");t.push(n)}}),t}function Et(s,e){s.error&&console.log(s.error);const t=e;s.status!==0&&console.log(`WARN: ${t} the build will continue as-is`)}function ie(s,e){const t=M(),r=R(s,t,"dist","src",""),n=re(s,t,"dist");for(const o of n.allLibs())s.debug(`Dumping to pl-tester: ${g(o.fullName)}`),e.write(JSON.stringify(o)+`
31
+ `);for(const o of r)o.fullName.type==="library"&&(s.debug(`Dumping to pl-tester: ${g(o.fullName)}`),e.write(JSON.stringify(o)+`
32
+ `));for(const o of n.allTemplates())s.debug(`Dumping to pl-tester: ${g(o.fullName)}`),e.write(JSON.stringify(o)+`
33
+ `);for(const o of r)o.fullName.type==="template"&&(s.debug(`Dumping to pl-tester: ${g(o.fullName)} ${o.srcName}`),e.write(JSON.stringify(o)+`
34
+ `));for(const o of n.allSoftware())s.debug(`Dumping to pl-tester: ${g(o.fullName)}`),e.write(JSON.stringify(o)+`
35
+ `);for(const o of r)o.fullName.type==="software"&&(s.debug(`Dumping to pl-tester: ${g(o.fullName)}`),e.write(JSON.stringify(o)+`
36
+ `));for(const o of n.allAssets())s.debug(`Dumping to pl-tester: ${g(o.fullName)}`),e.write(JSON.stringify(o)+`
37
+ `);for(const o of r)o.fullName.type==="asset"&&(s.debug(`Dumping to pl-tester: ${g(o.fullName)}`),e.write(JSON.stringify(o)+`
38
+ `));for(const o of r)o.fullName.type==="test"&&(s.debug(`Dumping to pl-tester: ${g(o.fullName)} ${o.srcName}`),e.write(JSON.stringify(o)+`
39
+ `))}function Nt(s,e,t){const r=M(),n=R(s,r,"dist","src","");if(!e){for(const i of n)i.fullName.type==="library"&&t.write(JSON.stringify(i)+`
40
+ `);return}const o=re(s,r,"dist");for(const i of n)i.fullName.type==="library"&&o.addLib(i);for(const i of o.allLibs())t.write(JSON.stringify(i)+`
41
+ `)}function I(s,e,t){const r=M(),n=R(s,r,"dist","src","");for(const o of n)o.fullName.type===t&&e.write(JSON.stringify(o)+`
42
+ `)}function $t(s,e){I(s,e,"template")}function St(s,e){I(s,e,"software")}function kt(s,e){I(s,e,"asset")}function At(s,e){I(s,e,"test")}function Oe(s,...e){const t=ye.spawn(s,e,{stdio:["pipe","inherit","inherit"]});return t.stdin.on("error",r=>{r.code}),t}function xe(s){return new Promise((e,t)=>{s.on("close",r=>{e(r)}),s.on("error",r=>{t(r)})})}const S=class S extends h.Command{async run(){const{flags:e,argv:t}=await this.parse(S),r=$(e["log-level"]),n=t.length==0?["./src"]:t,o=Oe(ve.TengoTesterBinaryPath,"check","--log-level",e["log-level"],"--artifacts","-",...n);try{ie(r,o.stdin)}catch(i){r.error(i)}finally{o.stdin.end();const i=await xe(o);process.exit(i)}}};l(S,"description","check tengo sources for language processor an"),l(S,"strict",!1),l(S,"flags",{...ne}),l(S,"examples",["<%= config.bin %> <%= command.id %>"]);let K=S;const k=class k extends h.Command{async run(){const{flags:e}=await this.parse(k),t=$(e["log-level"]),r=this.argv.length==0?["./src"]:this.argv,n=Oe(ve.TengoTesterBinaryPath,"run","--log-level",e["log-level"],"--artifacts","-",...r);try{ie(t,n.stdin)}catch(o){t.error(o)}finally{n.stdin.end();const o=await xe(n);process.exit(o)}}};l(k,"description","run tengo unit tests (.test.tengo)"),l(k,"strict",!1),l(k,"flags",{...ne}),l(k,"examples",["<%= config.bin %> <%= command.id %>"]);let X=k;class Y extends h.Command{async run(){const e=$();ie(e,D.stdout)}}l(Y,"description","parse sources in current package and dump all found artifacts to stdout"),l(Y,"examples",["<%= config.bin %> <%= command.id %>"]);class H extends h.Command{async run(){const e=$();kt(e,D.stdout)}}l(H,"description","parse sources in current package and dump all found tests to stdout"),l(H,"examples",["<%= config.bin %> <%= command.id %>"]);const T=class T extends h.Command{async run(){const{flags:e}=await this.parse(T),t=$();Nt(t,e.deps,D.stdout)}};l(T,"description","parse sources in current package and dump all found templates to stdout"),l(T,"examples",["<%= config.bin %> <%= command.id %>"]),l(T,"flags",{deps:h.Flags.boolean({name:"deps",description:"add also all libraries found in node_modules"})});let Q=T;class ee extends h.Command{async run(){const e=$();St(e,D.stdout)}}l(ee,"description","parse sources in current package and dump all found tests to stdout"),l(ee,"examples",["<%= config.bin %> <%= command.id %>"]);class te extends h.Command{async run(){const e=$();$t(e,D.stdout)}}l(te,"description","parse sources in current package and dump all found templates to stdout"),l(te,"examples",["<%= config.bin %> <%= command.id %>"]);class se extends h.Command{async run(){const e=$();At(e,D.stdout)}}l(se,"description","parse sources in current package and dump all found tests to stdout"),l(se,"examples",["<%= config.bin %> <%= command.id %>"]);const Tt={build:Z,check:K,test:X,"dump:all":Y,"dump:assets":H,"dump:libs":Q,"dump:software":ee,"dump:templates":te,"dump:tests":se};exports.COMMANDS=Tt;
43
43
  //# sourceMappingURL=index.js.map