@platforma-sdk/tengo-builder 1.14.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/README.md +52 -0
- package/bin/run.js +7 -0
- package/dist/commands/build.d.ts +13 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/check.d.ts +11 -0
- package/dist/commands/check.d.ts.map +1 -0
- package/dist/commands/dump/all.d.ts +7 -0
- package/dist/commands/dump/all.d.ts.map +1 -0
- package/dist/commands/dump/libs.d.ts +10 -0
- package/dist/commands/dump/libs.d.ts.map +1 -0
- package/dist/commands/dump/software.d.ts +7 -0
- package/dist/commands/dump/software.d.ts.map +1 -0
- package/dist/commands/dump/templates.d.ts +7 -0
- package/dist/commands/dump/templates.d.ts.map +1 -0
- package/dist/commands/dump/tests.d.ts +7 -0
- package/dist/commands/dump/tests.d.ts.map +1 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/test.d.ts +11 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/compiler/artifactset.d.ts +22 -0
- package/dist/compiler/artifactset.d.ts.map +1 -0
- package/dist/compiler/compiler.d.ts +34 -0
- package/dist/compiler/compiler.d.ts.map +1 -0
- package/dist/compiler/main.d.ts +17 -0
- package/dist/compiler/main.d.ts.map +1 -0
- package/dist/compiler/package.d.ts +37 -0
- package/dist/compiler/package.d.ts.map +1 -0
- package/dist/compiler/source.d.ts +27 -0
- package/dist/compiler/source.d.ts.map +1 -0
- package/dist/compiler/template.d.ts +49 -0
- package/dist/compiler/template.d.ts.map +1 -0
- package/dist/compiler/test.artifacts.d.ts +32 -0
- package/dist/compiler/test.artifacts.d.ts.map +1 -0
- package/dist/compiler/util.d.ts +5 -0
- package/dist/compiler/util.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +851 -0
- package/dist/index.mjs.map +1 -0
- package/dist/shared/basecmd.d.ts +9 -0
- package/dist/shared/basecmd.d.ts.map +1 -0
- package/dist/shared/dump.d.ts +7 -0
- package/dist/shared/dump.d.ts.map +1 -0
- package/dist/shared/proc.d.ts +5 -0
- package/dist/shared/proc.d.ts.map +1 -0
- package/package.json +44 -0
- package/src/commands/build.ts +175 -0
- package/src/commands/check.ts +45 -0
- package/src/commands/dump/all.ts +17 -0
- package/src/commands/dump/libs.ts +24 -0
- package/src/commands/dump/software.ts +17 -0
- package/src/commands/dump/templates.ts +18 -0
- package/src/commands/dump/tests.ts +17 -0
- package/src/commands/index.ts +10 -0
- package/src/commands/test.ts +41 -0
- package/src/compiler/artifactset.ts +76 -0
- package/src/compiler/compiler.test.ts +48 -0
- package/src/compiler/compiler.ts +300 -0
- package/src/compiler/main.ts +363 -0
- package/src/compiler/package.ts +96 -0
- package/src/compiler/source.test.ts +28 -0
- package/src/compiler/source.ts +319 -0
- package/src/compiler/template.test.ts +54 -0
- package/src/compiler/template.ts +90 -0
- package/src/compiler/test.artifacts.ts +195 -0
- package/src/compiler/util.ts +38 -0
- package/src/index.ts +1 -0
- package/src/shared/basecmd.ts +28 -0
- package/src/shared/dump.ts +164 -0
- package/src/shared/proc.ts +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
This repo contains a tool, that facilitates integration of `tengo` libraries and template build and distribution process into npm infrastructure.
|
|
4
|
+
|
|
5
|
+
<!--
|
|
6
|
+
# Example config & file layout
|
|
7
|
+
|
|
8
|
+
`package.json`
|
|
9
|
+
|
|
10
|
+
```json5
|
|
11
|
+
{
|
|
12
|
+
// if your repo is a library or template collection, this sets its name in npm repo
|
|
13
|
+
"name": "@milaboratory/tengo-test-repo-1",
|
|
14
|
+
// package version for publishing
|
|
15
|
+
"version": "1.1.0",
|
|
16
|
+
"description": "Test tengo pl template",
|
|
17
|
+
"scripts": {
|
|
18
|
+
// builds source files and puts compiled & normalized sources to ./dist folder
|
|
19
|
+
"build": "pl-tengo-build"
|
|
20
|
+
},
|
|
21
|
+
"license": "UNLICENSED",
|
|
22
|
+
// (see important comment about dependencies)
|
|
23
|
+
"dependencies": {
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
// (see important comment about dependencies)
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
// use latest version of tengo-template-builder package
|
|
31
|
+
"@milaboratory/tengo-template-builder": "1.0.1"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Standard layout:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
src
|
|
40
|
+
library-1.lib.tengo
|
|
41
|
+
library-2.lib.tengo
|
|
42
|
+
template-1.tpl.tengo
|
|
43
|
+
template-2.tpl.tengo
|
|
44
|
+
package.json
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Dependencies
|
|
48
|
+
|
|
49
|
+
Only if you are developing a library, and use external libraries or templates in your code add such dependencies
|
|
50
|
+
in `"dependencies"`, because your users will have to have those libraries as their transient dependencies. In all other
|
|
51
|
+
cases use `"devDependencies"`. For example use of `"devDependencies"` is recommended if you are consuming external
|
|
52
|
+
library code only in templates. -->
|
package/bin/run.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Build extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
"generate-tags": import('@oclif/core/interfaces').BooleanFlag<boolean>;
|
|
7
|
+
"tags-file": import('@oclif/core/interfaces').OptionFlag<string, import('@oclif/core/interfaces').CustomOptions>;
|
|
8
|
+
"tags-additional-args": import('@oclif/core/interfaces').OptionFlag<string[], import('@oclif/core/interfaces').CustomOptions>;
|
|
9
|
+
"log-level": import('@oclif/core/interfaces').OptionFlag<string, import('@oclif/core/interfaces').CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Check extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static strict: boolean;
|
|
5
|
+
static flags: {
|
|
6
|
+
"log-level": import('@oclif/core/interfaces').OptionFlag<string, import('@oclif/core/interfaces').CustomOptions>;
|
|
7
|
+
};
|
|
8
|
+
static examples: string[];
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAOtC,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,OAAO;IACxC,OAAgB,WAAW,SAAmD;IAM9E,MAAM,CAAC,MAAM,UAAS;IAEtB,OAAgB,KAAK;;MAAsB;IAE3C,OAAgB,QAAQ,WAA2C;IAEtD,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAwBlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all.d.ts","sourceRoot":"","sources":["../../../src/commands/dump/all.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAKrC,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,OAAO;IAC1C,OAAgB,WAAW,SAA4E;IAEvG,OAAgB,QAAQ,WAEvB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAIlC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class DumpLibs extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
deps: import('@oclif/core/interfaces').BooleanFlag<boolean>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=libs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libs.d.ts","sourceRoot":"","sources":["../../../src/commands/dump/libs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAK5C,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,OAAO;IAC3C,OAAgB,WAAW,SAA4E;IAEvG,OAAgB,QAAQ,WAEvB;IAED,OAAgB,KAAK;;MAEpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAMlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"software.d.ts","sourceRoot":"","sources":["../../../src/commands/dump/software.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAKrC,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAC/C,OAAgB,WAAW,SAAwE;IAEnG,OAAgB,QAAQ,WAEvB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAIlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/commands/dump/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAKrC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAChD,OAAgB,WAAW,SAA4E;IAEvG,OAAgB,QAAQ,WAEvB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAIlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tests.d.ts","sourceRoot":"","sources":["../../../src/commands/dump/tests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAKrC,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,OAAO;IAC5C,OAAgB,WAAW,SAAwE;IAEnG,OAAgB,QAAQ,WAEvB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAIlC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as Build } from './build';
|
|
2
|
+
import { default as Check } from './check';
|
|
3
|
+
import { default as Test } from './test';
|
|
4
|
+
export declare const COMMANDS: {
|
|
5
|
+
build: typeof Build;
|
|
6
|
+
check: typeof Check;
|
|
7
|
+
test: typeof Test;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAG1B,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Test extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static strict: boolean;
|
|
5
|
+
static flags: {
|
|
6
|
+
"log-level": import('@oclif/core/interfaces').OptionFlag<string, import('@oclif/core/interfaces').CustomOptions>;
|
|
7
|
+
};
|
|
8
|
+
static examples: string[];
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAOtC,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACvC,OAAgB,WAAW,SAAwC;IAEnE,MAAM,CAAC,MAAM,UAAS;IAEtB,OAAgB,KAAK;;MAAsB;IAE3C,OAAgB,QAAQ,WAA2C;IAEtD,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAwBlC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CompileMode, TypedArtifactName } from './package';
|
|
2
|
+
export declare class ArtifactMap<T> {
|
|
3
|
+
private readonly nameExtractor;
|
|
4
|
+
private readonly map;
|
|
5
|
+
constructor(nameExtractor: (obj: T) => TypedArtifactName);
|
|
6
|
+
add(obj: T, replace?: boolean): T | undefined;
|
|
7
|
+
get(name: TypedArtifactName): T | undefined;
|
|
8
|
+
get array(): T[];
|
|
9
|
+
forEach(callback: (value: T, key: TypedArtifactName) => void): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function createArtifactNameSet(): ArtifactMap<TypedArtifactName>;
|
|
12
|
+
export declare class ArtifactStore<T> {
|
|
13
|
+
private readonly nameExtractor;
|
|
14
|
+
private readonly dev;
|
|
15
|
+
private readonly dist;
|
|
16
|
+
constructor(nameExtractor: (obj: T) => TypedArtifactName);
|
|
17
|
+
add(mode: CompileMode, obj: T, replace?: boolean): T | undefined;
|
|
18
|
+
get(mode: CompileMode, name: TypedArtifactName): T | undefined;
|
|
19
|
+
array(mode: CompileMode): T[];
|
|
20
|
+
forEach(mode: CompileMode, callback: (value: T, key: TypedArtifactName) => void): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=artifactset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifactset.d.ts","sourceRoot":"","sources":["../../src/compiler/artifactset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAe,MAAM,WAAW,CAAC;AAGxE,qBAAa,WAAW,CAAC,CAAC;IAGZ,OAAO,CAAC,QAAQ,CAAC,aAAa;IAF1C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAwB;gBAEf,aAAa,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,iBAAiB;IAGzE,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,OAAO,GAAE,OAAc,GAAG,CAAC,GAAG,SAAS;IASnD,GAAG,CAAC,IAAI,EAAE,iBAAiB,GAAG,CAAC,GAAG,SAAS;IAI3C,IAAI,KAAK,IAAI,CAAC,EAAE,CAIf;IAED,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,iBAAiB,KAAK,IAAI;CAG7D;AAED,wBAAgB,qBAAqB,IAAI,WAAW,CAAC,iBAAiB,CAAC,CAEtE;AAED,qBAAa,aAAa,CAAC,CAAC;IAId,OAAO,CAAC,QAAQ,CAAC,aAAa;IAH1C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;IACpC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAgB;gBAER,aAAa,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,iBAAiB;IAKzE,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,GAAE,OAAc,GAAG,CAAC,GAAG,SAAS;IAUtE,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,iBAAiB,GAAG,CAAC,GAAG,SAAS;IAU9D,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,CAAC,EAAE;IAM7B,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,iBAAiB,KAAK,IAAI;CAGhF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ArtifactSource } from './source';
|
|
2
|
+
import { Template } from './template';
|
|
3
|
+
import { TypedArtifactName, CompileMode } from './package';
|
|
4
|
+
export interface TemplatesAndLibs {
|
|
5
|
+
templates: Template[];
|
|
6
|
+
libs: ArtifactSource[];
|
|
7
|
+
software: ArtifactSource[];
|
|
8
|
+
}
|
|
9
|
+
export declare class TengoTemplateCompiler {
|
|
10
|
+
private readonly compileMode;
|
|
11
|
+
constructor(compileMode: CompileMode);
|
|
12
|
+
private readonly libs;
|
|
13
|
+
private readonly software;
|
|
14
|
+
private readonly templates;
|
|
15
|
+
private populateTemplateDataFromDependencies;
|
|
16
|
+
/** This method assumes that all dependencies are already added to the compiler's context */
|
|
17
|
+
private compileAndAddTemplate;
|
|
18
|
+
addLib(lib: ArtifactSource): void;
|
|
19
|
+
allLibs(): ArtifactSource[];
|
|
20
|
+
getLib(name: TypedArtifactName): ArtifactSource | undefined;
|
|
21
|
+
getLibOrError(name: TypedArtifactName): ArtifactSource;
|
|
22
|
+
addSoftware(software: ArtifactSource): void;
|
|
23
|
+
allSoftware(): ArtifactSource[];
|
|
24
|
+
getSoftware(name: TypedArtifactName): ArtifactSource | undefined;
|
|
25
|
+
getSoftwareOrError(name: TypedArtifactName): ArtifactSource;
|
|
26
|
+
addTemplate(tpl: Template): void;
|
|
27
|
+
allTemplates(): Template[];
|
|
28
|
+
getTemplate(name: TypedArtifactName): Template | undefined;
|
|
29
|
+
getTemplateOrError(name: TypedArtifactName): Template;
|
|
30
|
+
getArtefact(name: TypedArtifactName): ArtifactSource | Template | undefined;
|
|
31
|
+
checkLibs(): void;
|
|
32
|
+
compileAndAdd(sources: ArtifactSource[]): TemplatesAndLibs;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -0,0 +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;CAC3B;AAED,qBAAa,qBAAqB;IAE9B,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW;IAG3C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA0D;IAC/E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0D;IACnF,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoD;IAE9E,OAAO,CAAC,oCAAoC;IAkD5C,4FAA4F;IAC5F,OAAO,CAAC,qBAAqB;IAsB7B,MAAM,CAAC,GAAG,EAAE,cAAc;IAQ1B,OAAO,IAAI,cAAc,EAAE;IAI3B,MAAM,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc,GAAG,SAAS;IAM3D,aAAa,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc;IAOtD,WAAW,CAAC,QAAQ,EAAE,cAAc;IAQpC,WAAW,IAAI,cAAc,EAAE;IAI/B,WAAW,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc,GAAG,SAAS;IAOhE,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc;IAO3D,WAAW,CAAC,GAAG,EAAE,QAAQ;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;IAiB3E,SAAS;IAYT,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,gBAAgB;CA4F3D"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TemplatesAndLibs, TengoTemplateCompiler } from './compiler';
|
|
2
|
+
import { CompileMode } from './package';
|
|
3
|
+
import { ArtifactSource } from './source';
|
|
4
|
+
import { default as winston } from 'winston';
|
|
5
|
+
interface PackageJson {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
type: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function createLogger(level?: string): winston.Logger;
|
|
11
|
+
export declare function getPackageInfo(): PackageJson;
|
|
12
|
+
export declare function parseSources(logger: winston.Logger, packageInfo: PackageJson, mode: CompileMode, root: string, subdir: string): ArtifactSource[];
|
|
13
|
+
export declare function newCompiler(logger: winston.Logger, packageInfo: PackageJson, mode: CompileMode): TengoTemplateCompiler;
|
|
14
|
+
export declare function compile(logger: winston.Logger, mode: CompileMode): TemplatesAndLibs;
|
|
15
|
+
export declare function savePacks(logger: winston.Logger, compiled: TemplatesAndLibs, mode: CompileMode): void;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +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;AAgBD,wBAAgB,YAAY,CAAC,KAAK,GAAE,MAAgB,GAAG,OAAO,CAAC,MAAM,CAapE;AAED,wBAAgB,cAAc,IAAI,WAAW,CAG5C;AAqJD,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;AA0CD,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,QAiC9F"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type CompileMode = 'dist';
|
|
2
|
+
export type ArtifactType = 'library' | 'template' | 'test' | 'software';
|
|
3
|
+
/** Artifact Name including package version */
|
|
4
|
+
export interface FullArtifactName {
|
|
5
|
+
/** Dependency type */
|
|
6
|
+
type: ArtifactType;
|
|
7
|
+
/** Fully qualified package */
|
|
8
|
+
pkg: string;
|
|
9
|
+
/** Id of the artifact inside the package */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Package version */
|
|
12
|
+
version: string;
|
|
13
|
+
}
|
|
14
|
+
export type FullArtifactNameWithoutType = Omit<FullArtifactName, 'type'>;
|
|
15
|
+
export type TypedArtifactName = Pick<FullArtifactName, 'type' | 'pkg' | 'id'>;
|
|
16
|
+
export type PackageName = Pick<FullArtifactName, 'pkg' | 'version'>;
|
|
17
|
+
export type ArtifactName = Pick<FullArtifactName, 'pkg' | 'id'>;
|
|
18
|
+
export declare function artifactKey(name: TypedArtifactName): string;
|
|
19
|
+
export declare function fullNameToString(name: FullArtifactName): string;
|
|
20
|
+
/** used for exceptions */
|
|
21
|
+
export declare function typedArtifactNameToString(name: TypedArtifactName): string;
|
|
22
|
+
export declare function typedArtifactNamesEquals(name1: TypedArtifactName, name2: TypedArtifactName): boolean;
|
|
23
|
+
/** used to format artefact name while generating output files */
|
|
24
|
+
export declare function artifactNameToString(name: ArtifactName): string;
|
|
25
|
+
/** used to format artefact name and version while generating output files */
|
|
26
|
+
export declare function formatArtefactNameAndVersion(name: FullArtifactName): {
|
|
27
|
+
name: string;
|
|
28
|
+
version: string;
|
|
29
|
+
};
|
|
30
|
+
/** used to format artefact name and version while generating output files */
|
|
31
|
+
export declare function parseArtefactNameAndVersion(nameAndVersion: {
|
|
32
|
+
name: string;
|
|
33
|
+
version: string;
|
|
34
|
+
}): FullArtifactNameWithoutType;
|
|
35
|
+
export declare function fullNameWithoutTypeToString(name: FullArtifactNameWithoutType): string;
|
|
36
|
+
export declare function fullNameWithoutType(name: FullArtifactName): FullArtifactNameWithoutType;
|
|
37
|
+
//# sourceMappingURL=package.d.ts.map
|
|
@@ -0,0 +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,GAAG,UAAU,CAAA;AAEvE,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB;IACtB,IAAI,EAAE,YAAY,CAAC;IAEnB,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAC;IAEZ,4CAA4C;IAC5C,EAAE,EAAE,MAAM,CAAC;IAEX,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;AAEzE,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC;AAE9E,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,SAAS,CAAC,CAAC;AAEpE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC;AAEhE,wBAAgB,WAAW,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAE3D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAE/D;AAED,0BAA0B;AAC1B,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAEzE;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAEpG;AAGD,iEAAiE;AACjE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAE/D;AAED,6EAA6E;AAC7E,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,gBAAgB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAEtG;AAED,6EAA6E;AAC7E,wBAAgB,2BAA2B,CAAC,cAAc,EAAE;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,2BAA2B,CAK9B;AAGD,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,2BAA2B,GAAG,MAAM,CAErF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,2BAA2B,CAEvF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TypedArtifactName, FullArtifactName, CompileMode } from './package';
|
|
2
|
+
export declare class ArtifactSource {
|
|
3
|
+
/** The mode this artifact was built (dev or dist) */
|
|
4
|
+
readonly compileMode: CompileMode;
|
|
5
|
+
/** Full artifact id, including package version */
|
|
6
|
+
readonly fullName: FullArtifactName;
|
|
7
|
+
/** Normalized source code */
|
|
8
|
+
readonly src: string;
|
|
9
|
+
/** Path to source file where artifact came from */
|
|
10
|
+
readonly srcName: string;
|
|
11
|
+
/** List of dependencies */
|
|
12
|
+
readonly dependencies: TypedArtifactName[];
|
|
13
|
+
constructor(
|
|
14
|
+
/** The mode this artifact was built (dev or dist) */
|
|
15
|
+
compileMode: CompileMode,
|
|
16
|
+
/** Full artifact id, including package version */
|
|
17
|
+
fullName: FullArtifactName,
|
|
18
|
+
/** Normalized source code */
|
|
19
|
+
src: string,
|
|
20
|
+
/** Path to source file where artifact came from */
|
|
21
|
+
srcName: string,
|
|
22
|
+
/** List of dependencies */
|
|
23
|
+
dependencies: TypedArtifactName[]);
|
|
24
|
+
}
|
|
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;
|
|
27
|
+
//# sourceMappingURL=source.d.ts.map
|
|
@@ -0,0 +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;AAqC3F,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"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { CompileMode, FullArtifactName } from './package';
|
|
2
|
+
export interface TemplateLibData {
|
|
3
|
+
/** i.e. @milaboratory/some-package:lib1 */
|
|
4
|
+
name: string;
|
|
5
|
+
/** i.e. 1.2.3 */
|
|
6
|
+
version: string;
|
|
7
|
+
/** full source code */
|
|
8
|
+
src: string;
|
|
9
|
+
}
|
|
10
|
+
export interface TemplateSoftwareData {
|
|
11
|
+
/** i.e. @milaboratory/mixcr:main */
|
|
12
|
+
name: string;
|
|
13
|
+
/** i.e. 4.2.3 */
|
|
14
|
+
version: string;
|
|
15
|
+
/** full contents of software dependency description */
|
|
16
|
+
src: string;
|
|
17
|
+
}
|
|
18
|
+
export interface TemplateData {
|
|
19
|
+
/** Discriminator for future use */
|
|
20
|
+
type: 'pl.tengo-template.v2';
|
|
21
|
+
/** i.e. @milaboratory/some-package:template */
|
|
22
|
+
name: string;
|
|
23
|
+
/** i.e. 1.2.3 */
|
|
24
|
+
version: string;
|
|
25
|
+
/** i.e. @milaboratory/some-package:some-lib -> normalized library source code */
|
|
26
|
+
libs: Record<string, TemplateLibData>;
|
|
27
|
+
/** i.e. @milaboratory/some-package:some-lib -> to nested template data */
|
|
28
|
+
templates: Record<string, TemplateData>;
|
|
29
|
+
/** i.e. @milaboratory/mixcr:main -> software metadata */
|
|
30
|
+
software: Record<string, TemplateSoftwareData>;
|
|
31
|
+
/** Template source code */
|
|
32
|
+
src: string;
|
|
33
|
+
}
|
|
34
|
+
export declare class Template {
|
|
35
|
+
readonly compileMode: CompileMode;
|
|
36
|
+
readonly fullName: FullArtifactName;
|
|
37
|
+
readonly data: TemplateData;
|
|
38
|
+
readonly content: Uint8Array;
|
|
39
|
+
constructor(compileMode: CompileMode, fullName: FullArtifactName, body: {
|
|
40
|
+
data?: TemplateData;
|
|
41
|
+
content?: Uint8Array;
|
|
42
|
+
});
|
|
43
|
+
toJSON(): {
|
|
44
|
+
compileMode: "dist";
|
|
45
|
+
fullName: FullArtifactName;
|
|
46
|
+
data: TemplateData;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=template.d.ts.map
|
|
@@ -0,0 +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,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,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAC/C,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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FullArtifactName } from './package';
|
|
2
|
+
export interface TestArtifactSource {
|
|
3
|
+
fullName: FullArtifactName;
|
|
4
|
+
src: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const testLocalLib1Name: FullArtifactName;
|
|
7
|
+
export declare const testLocalLib1Src = "\notherLib := import(\"package1:other-lib-2\" )\nplapiCustomName := import(\"plapi\" )\n\nnotplapiCustomName.getTemplateId( \"some other:parameter\")\n\nplapiCustomName.getTemplateIdAnother(\"sss:kkk\" )\nplapiCustomName.getSoftwareInfo(\":software-1\")\n\nexport {\n \"some\": \"value\",\n \"template2\": plapiCustomName.getTemplateId(\":local-template-2\" ),\n \"template3\": plapiCustomName.getTemplateId ( \"package1:template-3\")\n}\n";
|
|
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
|
+
export declare const testLocalLib2Src = "\notherLib := import(\"package1:someid\")\nll := import(\"@milaboratory/tengo-sdk:ll\")\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\")\n\nexport {\n \"some\": \"value\",\n \"template1\": ll.importTemplate(\"current-package:local-template-2\"),\n \"template2\": tplID,\n}\n";
|
|
10
|
+
export declare const testLocalTpl1Name: FullArtifactName;
|
|
11
|
+
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";
|
|
12
|
+
export declare const testLocalTpl2Name: FullArtifactName;
|
|
13
|
+
export declare const testLocalTpl2Src = "\nlib := import(\"package1:other-lib-1\")\n";
|
|
14
|
+
export declare const testLocalTpl2SrcNormalized = "\nlib := import(\"package1:other-lib-1\")\n";
|
|
15
|
+
export declare const testLocalLib1: TestArtifactSource;
|
|
16
|
+
export declare const testLocalTpl1: TestArtifactSource;
|
|
17
|
+
export declare const testLocalTpl2: TestArtifactSource;
|
|
18
|
+
export declare const testLocalPackage: TestArtifactSource[];
|
|
19
|
+
export declare const testPackage1Lib1Name: FullArtifactName;
|
|
20
|
+
export declare const testPackage1Lib1Src = "\nexport {\n \"some\": \"value1\"\n}\n";
|
|
21
|
+
export declare const testPackage1Soft1Name: FullArtifactName;
|
|
22
|
+
export declare const testPackage1Soft1Src = "\nsome software contents. Template builder should pass it 'as-is'\n";
|
|
23
|
+
export declare const testPackage1Lib2Name: FullArtifactName;
|
|
24
|
+
export declare const testPackage1Lib2Src = "\nlib := import(\"package1:other-lib-1\")\nexport {\n \"some\": \"value123\",\n \"theTpl\": getTemplateId(\"package1:template-3\")\n}\n";
|
|
25
|
+
export declare const testPackage1Tpl3Name: FullArtifactName;
|
|
26
|
+
export declare const testPackage1Tpl3Src = "\nlib := import(\"package1:other-lib-1\")\n";
|
|
27
|
+
export declare const testPackage1Tpl3CompiledBase64 = "H4sIAAAAAAAAE22PQQqDMBREr/KZVQsxELsL9CZ/E+VjQ2MiJpUWyd2LglCo2xlm3syK4LsMu2Jy/dMNYmwqD5mb4LvGbHp0o8Ce2wp57mHBUd5TmgutHImIGDmNwrDEWFx4iWFwrByhsMicfYqwMLrVN9Sq/hhFxim4Is3tBxF8R3fy4wa68OkgxnVnHPntWFUon2mvD7pIHFJz2HppzwZ9AanB7OAUAQAA";
|
|
28
|
+
export declare const testPackage1Lib1: TestArtifactSource;
|
|
29
|
+
export declare const testPackage1Lib2: TestArtifactSource;
|
|
30
|
+
export declare const testPackage1Tpl3: TestArtifactSource;
|
|
31
|
+
export declare const testPackage1: TestArtifactSource[];
|
|
32
|
+
//# sourceMappingURL=test.artifacts.d.ts.map
|
|
@@ -0,0 +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;AACF,eAAO,MAAM,gBAAgB,0bAgB5B,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,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,yOAAyO,CAAC;AAErR,eAAO,MAAM,gBAAgB,EAAE,kBAG9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,kBAG9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,kBAG9B,CAAC;AAEF,eAAO,MAAM,YAAY,sBAAyD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function assertNever(x: never): never;
|
|
2
|
+
export declare function findNodeModules(): string;
|
|
3
|
+
export type PathType = 'absent' | 'file' | 'dir' | 'link' | 'unknown';
|
|
4
|
+
export declare function pathType(path: string): PathType;
|
|
5
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";var ye=Object.defineProperty;var be=(t,e,r)=>e in t?ye(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var d=(t,e,r)=>be(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("node:child_process"),S=require("@oclif/core"),ve=require("node:path"),oe=require("node:fs"),V=require("node:zlib"),$e=require("canonicalize"),A=require("winston"),Ee=require("node:fs/promises"),se=require("@milaboratories/tengo-tester");function q(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const c=q(ve),u=q(oe),k=q(Ee);function T(t){throw new Error("Unexpected object: "+t)}function Se(){let t=process.cwd();for(;t;){const e=c.join(t,"node_modules");if(u.existsSync(e))return e;const r=c.resolve(t,"..");if(r===t)break;t=r}throw new Error("Unable to find node_modules directory.")}function v(t){try{const e=u.statSync(t);return e.isDirectory()?"dir":e.isFile()?"file":e.isSymbolicLink()?"link":"unknown"}catch(e){if(e.code=="ENOENT")return"absent";throw e}}function Z(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 K(t,e){return t.type==e.type&&t.pkg==e.pkg&&t.id==e.id}function y(t){return`${t.pkg}:${t.id}`}function F(t){return{name:y(t),version:t.version}}function Ne(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 X(t){return`${t.pkg}:${t.id}:${t.version}`}const ke=new TextDecoder,Te=new TextEncoder;class ne{constructor(e,r,s){d(this,"data");d(this,"content");this.compileMode=e,this.fullName=r;let{data:n,content:o}=s;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(ke.decode(V.gunzipSync(o))),n.type!=="pl.tengo-template.v2"))throw new Error("malformed template");o===void 0&&(o=V.gzipSync(Te.encode($e(n))));const i=Ne(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: ${X(i)} != ${X(r)}`);this.data=n,this.content=o}toJSON(){return{compileMode:this.compileMode,fullName:this.fullName,data:this.data}}}class M{constructor(e){d(this,"map",new Map);this.nameExtractor=e}add(e,r=!0){const s=Z(this.nameExtractor(e)),n=this.map.get(s);return n&&!r||this.map.set(s,e),n}get(e){return this.map.get(Z(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 De(){return new M(t=>t)}class x{constructor(e){d(this,"dev");d(this,"dist");this.nameExtractor=e,this.dev=new M(e),this.dist=new M(e)}add(e,r,s=!0){switch(e){case"dist":return this.dist.add(r,s);default:T(e)}}get(e,r){switch(e){case"dist":return this.dist.get(r);default:T(e)}}array(e){const r=[];return this.forEach(e,s=>r.push(s)),r}forEach(e,r){this.dist.forEach((s,n)=>r(this.get(e,n)??s,n))}}class Ae{constructor(e){d(this,"libs",new x(e=>e.fullName));d(this,"software",new x(e=>e.fullName));d(this,"templates",new x(e=>e.fullName));this.compileMode=e}populateTemplateDataFromDependencies(e,r,s,n){for(const o of s)switch(o.type){case"library":const i=this.getLibOrError(o),a=n.indexOf(y(o));if(a>=0){let p=`library import recursion detected: ${n.slice(a).join(" -> ")} -> ${y(o)}`;throw new Error(p)}r.libs[y(o)]={...F(i.fullName),src:i.src},this.populateTemplateDataFromDependencies(e,r,i.dependencies,[...n,y(o)]);break;case"software":const l=this.getSoftwareOrError(o);r.software[y(o)]={...F(l.fullName),src:l.src};break;case"template":if(K(e,o))continue;const f=this.getTemplateOrError(o);r.templates[y(o)]=f.data;break;case"test":throw new Error(`dependencies tree error: tests should never be part of template: ${g(o)} is dependency of ${y(e)}`);default:T(o.type)}}compileAndAddTemplate(e){if(e.fullName.type!=="template")throw new Error("unexpected source type");const r={type:"pl.tengo-template.v2",...F(e.fullName),templates:{},libs:{},software:{},src:e.src};this.populateTemplateDataFromDependencies(e.fullName,r,e.dependencies,[]);const s=new ne(e.compileMode,e.fullName,{data:r});return this.addTemplate(s),s}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: ${y(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: ${y(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: ${y(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"test":return;default:T(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:[]};let s=[];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)):s.push(n);for(;s.length>0;){const n=[];for(const o of s){const i=o.dependencies.filter(a=>!this.getArtefact(a)&&!(o.fullName.type==="template"&&K(o.fullName,a)));if(i.length>0){let a=`Unsatisfied dependencies in ${m(o.fullName)}:
|
|
2
|
+
`;for(const l of i)a+=` - ${g(l)}
|
|
3
|
+
`;n.push({src:o,err:Error(a)});continue}switch(o.fullName.type){case"library":this.addLib(o),r.libs.push(o);break;case"software":this.addSoftware(o),r.software.push(o);break;case"template":try{const a=this.compileAndAddTemplate(o);r.templates.push(a)}catch(a){let l=`Unsatisfied dependencies in ${m(o.fullName)}:
|
|
4
|
+
`;l+=` - ${a.message}
|
|
5
|
+
`,n.push({src:o,err:Error(l)})}break;case"test":break;default:T(o.fullName.type)}}if(s.length===n.length){let o="";for(const i of n)o+=`
|
|
6
|
+
${i.err.message}`;throw new Error(o)}s=n.map(({src:o})=>o)}return r}}const H="[_a-zA-Z][_a-zA-Z0-9]*",D=(t,e)=>new RegExp(`\\b${t}\\.(?<fnCall>(?<fnName>`+e+')\\s*\\(\\s*"(?<templateName>[^"]+)"\\s*\\))'),Fe=t=>D(t,"getTemplateId"),xe=t=>D(t,"getSoftwareInfo"),Q=t=>D(t,"importTemplate"),Y=t=>D(t,"importSoftware"),Me=/^\s*(\/\/)|(\/\*.*\*\/)/,je=/^\s*\/\*/,Oe=/\*\//,ie=/\s*:=\s*import\s*\(\s*"(?<moduleName>[^"]+)"\s*\)/,Re=new RegExp(`\\b(?<importName>${H}(\\.${H})*)${ie.source}`),Le=/(?<pkgName>[^"]+)?:(?<depID>[^"]+)/;class ae{constructor(e,r,s,n,o){this.compileMode=e,this.fullName=r,this.src=s,this.srcName=n,this.dependencies=o}}function le(t,e,r,s){const n=oe.readFileSync(e).toString(),{deps:o,normalized:i}=Ce(n,r,s);return new ae(t,r,i,e,o.array)}function Ce(t,e,r){const s=De(),n=t.split(`
|
|
7
|
+
`),o=[];let i={isInCommentBlock:!1,tplDepREs:new Map},a=0;for(const l of n){a++;try{const f=Ie(l,i,e.pkg,r);o.push(f.line),i=f.context,f.artifact&&s.add(f.artifact)}catch(f){throw new Error(`[line ${a}]: ${f.message}
|
|
8
|
+
${l}`)}}return{normalized:o.join(`
|
|
9
|
+
`),deps:s}}function Ie(t,e,r,s){if(e.isInCommentBlock)return Oe.exec(t)&&(e.isInCommentBlock=!1),{line:t,context:e,artifact:void 0};if(Me.exec(t))return{line:t,context:e,artifact:void 0};if(je.exec(t))return e.isInCommentBlock=!0,{line:t,context:e,artifact:void 0};const n=ie.exec(t);if(n){const o=Ge(t);if(o.module==="plapi")return e.tplDepREs.has(o.module)||e.tplDepREs.set(o.module,[["template",Fe(o.alias)],["software",xe(o.alias)]]),{line:t,context:e,artifact:void 0};(o.module==="@milaboratory/tengo-sdk:ll"||o.module==="@platforma-sdk/workflow-tengo:ll"||(r==="@milaboratory/tengo-sdk"||r==="@platforma-sdk/workflow-tengo")&&o.module===":ll")&&(e.tplDepREs.has(o.module)||e.tplDepREs.set(o.module,[["template",Q(o.alias)],["software",Y(o.alias)]])),(o.module==="@milaboratory/tengo-sdk:assets"||o.module==="@platforma-sdk/workflow-tengo:assets"||(r==="@milaboratory/tengo-sdk"||r==="@platforma-sdk/workflow-tengo")&&o.module===":assets")&&(e.tplDepREs.has(o.module)||e.tplDepREs.set(o.module,[["template",Q(o.alias)],["software",Y(o.alias)]]));const i=ee(o.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[o,i]of e.tplDepREs)for(const[a,l]of i){const f=l.exec(t);if(!f||!f.groups)continue;const{fnCall:p,templateName:b,fnName:h}=f.groups;if(!p||!b||!h)throw Error("failed to parse template import statement");const w=ee(b,a,r);if(!w)throw Error(`failed to parse artifact name in ${h} import statement`);return t=t.replace(p,`${h}("${w.pkg}:${w.id}")`),{line:t,context:e,artifact:w}}return{line:t,context:e,artifact:void 0}}function Ge(t){const e=Re.exec(t);if(!e||!e.groups)throw Error("failed to parse 'import' statement");const{importName:r,moduleName:s}=e.groups;if(!r||!s)throw Error("failed to parse 'import' statement");return{module:s,alias:r}}function ee(t,e,r){const s=Le.exec(t);if(!s)return;if(!s.groups)throw Error("failed to parse dependency name inside 'import' statement. The dependency name should have format '<package>:<templateName>'");const{pkgName:n,depID:o}=s.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??r,id:o}}const j=".plj.gz",O=".lib.tengo",R=".sw.json",te=".test.tengo",L=".tpl.tengo",C=".lib.tengo",I=".sw.json",ze=[C,L,I];function W(t="debug"){return A.createLogger({level:t,format:A.format.printf(({level:e,message:r})=>`${e.padStart(6," ")}: ${r}`),transports:[new A.transports.Console({stderrLevels:["error","warn","info","debug"],handleExceptions:!0})]})}function _(){return JSON.parse(u.readFileSync("package.json").toString())}function ce(t,e){return c.resolve(e,t,"tengo","lib")}function fe(t,e){return c.resolve(e,t,"tengo","tpl")}function de(t,e){return c.resolve(e,t,"tengo","software")}function pe(t,e,r,s,n=!1){const o=c.resolve(s,"package.json");if(v(o)!=="file"){for(const w of u.readdirSync(s)){const we=v(c.join(s,w))==="link",B=c.resolve(s,w);v(B)==="dir"&&pe(t,e,r,B,we)}return}const i=ce("dist",s),a=fe("dist",s),l=de("dist",s),f=v(i)==="dir",p=v(a)==="dir",b=v(l)==="dir";if(!f&&!p&&!b)return;const h=JSON.parse(u.readFileSync(o).toString());if(h.name!==r.name){if(v(c.resolve(s,"node_modules"))==="dir"&&n)throw new Error(`nested node_modules is a sign of library dependencies version incompatibility in ${s}`);f&&Pe(t,h,"dist",i,e),p&&qe(t,h,"dist",a,e),b&&We(t,h,"dist",l,e)}}function Pe(t,e,r,s,n){for(const o of u.readdirSync(s)){const i=c.resolve(s,o);if(!o.endsWith(O))throw new Error(`unexpected file in 'lib' folder: ${i}`);const a={type:"library",pkg:e.name,id:o.slice(0,o.length-O.length),version:e.version},l=le(r,i,a,!0);if(n.addLib(l),t.debug(`Adding dependency ${m(a)} from ${i}`),l.dependencies.length>0){t.debug("Dependencies:");for(const f of l.dependencies)t.debug(` - ${g(f)}`)}}}function qe(t,e,r,s,n){for(const o of u.readdirSync(s)){const i=c.resolve(s,o);if(!o.endsWith(j))throw new Error(`unexpected file in 'tpl' folder: ${i}`);const a={type:"template",pkg:e.name,id:o.slice(0,o.length-j.length),version:e.version},l=new ne(r,a,{content:u.readFileSync(i)});n.addTemplate(l),t.debug(`Adding dependency ${m(a)} from ${i}`)}}function We(t,e,r,s,n){for(const o of u.readdirSync(s)){const i=c.resolve(s,o);if(!o.endsWith(R))throw new Error(`unexpected file in 'software' folder: ${i}`);const a={type:"software",pkg:e.name,id:o.slice(0,o.length-R.length),version:e.version},l=new ae(r,a,u.readFileSync(i).toString(),i,[]);n.addSoftware(l),t.debug(`Adding dependency ${m(a)} from ${i}`)}}function J(t,e,r,s,n){const o=[];for(const i of u.readdirSync(c.join(s,n))){const a=c.join(n,i),l=c.join(s,a);if(v(l)==="dir"){const w=J(t,e,r,s,a);o.push(...w);continue}const f=i==="index.lib.tengo"?`${c.basename(n)}.lib.tengo`:a,p=_e(e,f.replaceAll(c.sep,"."));if(!p)continue;const b=c.resolve(s,a);t.debug(`Parsing ${m(p)} from ${b}`);const h=le(r,b,p,!0);if(h.dependencies.length>0){t.debug("Detected dependencies:");for(const w of h.dependencies)t.debug(` - ${g(w)}`)}o.push(h)}return o}function ue(t,e,r){const s=new Ae(r);return pe(t,s,e,Se()),s}function _e(t,e){const r={pkg:t.name,version:t.version};return e.endsWith(C)?{...r,id:e.substring(0,e.length-C.length),type:"library"}:e.endsWith(L)?{...r,id:e.substring(0,e.length-L.length),type:"template"}:e.endsWith(I)?{...r,id:e.substring(0,e.length-I.length),type:"software"}:e.endsWith(te)?{...r,id:e.substring(0,e.length-te.length),type:"test"}:null}function Je(t,e){const r=_(),s=ue(t,r,e),n=J(t,r,e,"src","");if(n.length===0){const i=[];for(const a of ze)i.push(`*${a}`);t.error(`Nothing to compile. Looked for ${i.join(", ")}`),process.exit(1)}t.info(`Compiling '${e}'...`);const o=s.compileAndAdd(n);return t.debug("Done."),o}function Ue(t,e,r){if(e.libs.length>0){const s=ce(r,".");u.mkdirSync(s,{recursive:!0});for(const n of e.libs){const o=c.resolve(s,n.fullName.id+O);t.info(` - writing ${o}`),u.writeFileSync(o,n.src)}}if(e.templates.length>0){const s=fe(r,".");u.mkdirSync(s,{recursive:!0});for(const n of e.templates){const o=c.resolve(s,n.fullName.id+j);t.info(` - writing ${o}`),u.writeFileSync(o,n.content)}}if(e.software.length>0){const s=de(r,".");u.mkdirSync(s,{recursive:!0});for(const n of e.software){const o=c.resolve(s,n.fullName.id+R);t.info(` - writing ${o}`),u.writeFileSync(o,n.src)}}}const U={"log-level":S.Flags.string({description:"logging level",default:"info",options:["error","warn","info","debug"]})},Be={"generate-tags":S.Flags.boolean({description:"generate tags, default false",default:!1}),"tags-file":S.Flags.file({description:'where to put ".tags" file, it should be a root of VS Code project',default:"../../.tags"}),"tags-additional-args":S.Flags.string({description:"additional flags for universal-ctags command: e.g. -e for emacs",default:[],multiple:!0,delimiter:","})},N=class N extends S.Command{async run(){const{flags:e}=await this.parse(N),r=W(e["log-level"]),s=_(),n=Je(r,"dist");Ue(r,n,"dist"),r.info("");let o=`declare type TemplateFromFile = { readonly type: "from-file"; readonly path: string; };
|
|
10
|
+
`;o+=`declare type TplName = ${n.templates.map(p=>'"'+p.fullName.id+'"').join(" | ")};
|
|
11
|
+
`,o+=`declare const Templates: Record<TplName, TemplateFromFile>;
|
|
12
|
+
`,o+=`export { Templates };
|
|
13
|
+
`;let i=`module.exports = { Templates: {
|
|
14
|
+
`,a=`import { resolve } from 'node:path';
|
|
15
|
+
export const Templates = {
|
|
16
|
+
`;const l=n.templates.map(p=>` '${p.fullName.id}': { type: 'from-file', path: require.resolve('./tengo/tpl/${p.fullName.id}.plj.gz') }`).join(`,
|
|
17
|
+
`),f=n.templates.map(p=>` '${p.fullName.id}': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/${p.fullName.id}.plj.gz') }`).join(`,
|
|
18
|
+
`);i+=l,a+=f,i+=`
|
|
19
|
+
}};
|
|
20
|
+
`,a+=`
|
|
21
|
+
};
|
|
22
|
+
`,await k.writeFile("dist/index.d.ts",o),s.type==="module"?(await k.writeFile("dist/index.cjs",i),await k.writeFile("dist/index.js",a)):(await k.writeFile("dist/index.js",i),await k.writeFile("dist/index.mjs",a)),Ve(e),e["generate-tags"]&&Ze(r,e),r.info("Template Pack build done.")}};d(N,"description","build tengo sources into single distributable pack file"),d(N,"examples",["<%= config.bin %> <%= command.id %>"]),d(N,"flags",{...U,...Be});let G=N;function Ve(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 Ze(t,e){var a;const r=c.resolve(e["tags-file"]),s=c.dirname(r),n=e["tags-additional-args"],o=Ke(s);t.info(`Generating tags for tengo autocompletion from "${s}" in "${r}", additional arguments: "${n}".
|
|
23
|
+
Found ${o.length} tengo files...`);const i=re.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",...o],{env:process.env,stdio:"inherit",cwd:s});if((a=i.error)!=null&&a.message.includes("ENOENT")){console.log(`
|
|
24
|
+
pl-tengo can create tags for tengo autocompletion,
|
|
25
|
+
but the program should be installed
|
|
26
|
+
with "brew install universal-ctags" on OSX
|
|
27
|
+
or "sudo apt install universal-ctags" on Ubuntu.
|
|
28
|
+
|
|
29
|
+
For vscode, you should also install ctags extension:
|
|
30
|
+
https://marketplace.visualstudio.com/items?itemName=jaydenlin.ctags-support`);return}Xe(i,"failed to generate ctags"),t.info("Generation of tags is done.")}function Ke(t){const e=u.readdirSync(t,{withFileTypes:!0,recursive:!0}),r=[];return e.forEach(s=>{if(!s.isDirectory()&&s.name.endsWith(".tengo")){const n=c.join(s.parentPath,s.name).replace(t,".");r.push(n)}}),r}function Xe(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 me(t,e){const r=_(),s=J(t,r,"dist","src",""),n=ue(t,r,"dist");for(const o of n.allLibs())t.debug(`Dumping to pl-tester: ${g(o.fullName)}`),e.write(JSON.stringify(o)+`
|
|
31
|
+
`);for(const o of s)o.fullName.type==="library"&&(t.debug(`Dumping to pl-tester: ${g(o.fullName)}`),e.write(JSON.stringify(o)+`
|
|
32
|
+
`));for(const o of n.allTemplates())t.debug(`Dumping to pl-tester: ${g(o.fullName)}`),e.write(JSON.stringify(o)+`
|
|
33
|
+
`);for(const o of s)o.fullName.type==="template"&&(t.debug(`Dumping to pl-tester: ${g(o.fullName)} ${o.srcName}`),e.write(JSON.stringify(o)+`
|
|
34
|
+
`));for(const o of n.allSoftware())t.debug(`Dumping to pl-tester: ${g(o.fullName)}`),e.write(JSON.stringify(o)+`
|
|
35
|
+
`);for(const o of s)o.fullName.type==="software"&&(t.debug(`Dumping to pl-tester: ${g(o.fullName)}`),e.write(JSON.stringify(o)+`
|
|
36
|
+
`));for(const o of s)o.fullName.type==="test"&&(t.debug(`Dumping to pl-tester: ${g(o.fullName)} ${o.srcName}`),e.write(JSON.stringify(o)+`
|
|
37
|
+
`))}function ge(t,...e){const r=re.spawn(t,e,{stdio:["pipe","inherit","inherit"]});return r.stdin.on("error",s=>{s.code}),r}function he(t){return new Promise((e,r)=>{t.on("close",s=>{e(s)}),t.on("error",s=>{r(s)})})}const $=class $ extends S.Command{async run(){const{flags:e,argv:r}=await this.parse($),s=W(e["log-level"]),n=r.length==0?["./src"]:r,o=ge(se.TengoTesterBinaryPath,"check","--log-level",e["log-level"],"--artifacts","-",...n);try{me(s,o.stdin)}catch(i){s.error(i)}finally{o.stdin.end();const i=await he(o);process.exit(i)}}};d($,"description","check tengo sources for language processor an"),d($,"strict",!1),d($,"flags",{...U}),d($,"examples",["<%= config.bin %> <%= command.id %>"]);let z=$;const E=class E extends S.Command{async run(){const{flags:e}=await this.parse(E),r=W(e["log-level"]),s=this.argv.length==0?["./src"]:this.argv,n=ge(se.TengoTesterBinaryPath,"run","--log-level",e["log-level"],"--artifacts","-",...s);try{me(r,n.stdin)}catch(o){r.error(o)}finally{n.stdin.end();const o=await he(n);process.exit(o)}}};d(E,"description","run tengo unit tests (.test.tengo)"),d(E,"strict",!1),d(E,"flags",{...U}),d(E,"examples",["<%= config.bin %> <%= command.id %>"]);let P=E;const He={build:G,check:z,test:P};exports.COMMANDS=He;
|
|
38
|
+
//# sourceMappingURL=index.js.map
|