@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.
Files changed (73) hide show
  1. package/README.md +52 -0
  2. package/bin/run.js +7 -0
  3. package/dist/commands/build.d.ts +13 -0
  4. package/dist/commands/build.d.ts.map +1 -0
  5. package/dist/commands/check.d.ts +11 -0
  6. package/dist/commands/check.d.ts.map +1 -0
  7. package/dist/commands/dump/all.d.ts +7 -0
  8. package/dist/commands/dump/all.d.ts.map +1 -0
  9. package/dist/commands/dump/libs.d.ts +10 -0
  10. package/dist/commands/dump/libs.d.ts.map +1 -0
  11. package/dist/commands/dump/software.d.ts +7 -0
  12. package/dist/commands/dump/software.d.ts.map +1 -0
  13. package/dist/commands/dump/templates.d.ts +7 -0
  14. package/dist/commands/dump/templates.d.ts.map +1 -0
  15. package/dist/commands/dump/tests.d.ts +7 -0
  16. package/dist/commands/dump/tests.d.ts.map +1 -0
  17. package/dist/commands/index.d.ts +9 -0
  18. package/dist/commands/index.d.ts.map +1 -0
  19. package/dist/commands/test.d.ts +11 -0
  20. package/dist/commands/test.d.ts.map +1 -0
  21. package/dist/compiler/artifactset.d.ts +22 -0
  22. package/dist/compiler/artifactset.d.ts.map +1 -0
  23. package/dist/compiler/compiler.d.ts +34 -0
  24. package/dist/compiler/compiler.d.ts.map +1 -0
  25. package/dist/compiler/main.d.ts +17 -0
  26. package/dist/compiler/main.d.ts.map +1 -0
  27. package/dist/compiler/package.d.ts +37 -0
  28. package/dist/compiler/package.d.ts.map +1 -0
  29. package/dist/compiler/source.d.ts +27 -0
  30. package/dist/compiler/source.d.ts.map +1 -0
  31. package/dist/compiler/template.d.ts +49 -0
  32. package/dist/compiler/template.d.ts.map +1 -0
  33. package/dist/compiler/test.artifacts.d.ts +32 -0
  34. package/dist/compiler/test.artifacts.d.ts.map +1 -0
  35. package/dist/compiler/util.d.ts +5 -0
  36. package/dist/compiler/util.d.ts.map +1 -0
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +38 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/index.mjs +851 -0
  42. package/dist/index.mjs.map +1 -0
  43. package/dist/shared/basecmd.d.ts +9 -0
  44. package/dist/shared/basecmd.d.ts.map +1 -0
  45. package/dist/shared/dump.d.ts +7 -0
  46. package/dist/shared/dump.d.ts.map +1 -0
  47. package/dist/shared/proc.d.ts +5 -0
  48. package/dist/shared/proc.d.ts.map +1 -0
  49. package/package.json +44 -0
  50. package/src/commands/build.ts +175 -0
  51. package/src/commands/check.ts +45 -0
  52. package/src/commands/dump/all.ts +17 -0
  53. package/src/commands/dump/libs.ts +24 -0
  54. package/src/commands/dump/software.ts +17 -0
  55. package/src/commands/dump/templates.ts +18 -0
  56. package/src/commands/dump/tests.ts +17 -0
  57. package/src/commands/index.ts +10 -0
  58. package/src/commands/test.ts +41 -0
  59. package/src/compiler/artifactset.ts +76 -0
  60. package/src/compiler/compiler.test.ts +48 -0
  61. package/src/compiler/compiler.ts +300 -0
  62. package/src/compiler/main.ts +363 -0
  63. package/src/compiler/package.ts +96 -0
  64. package/src/compiler/source.test.ts +28 -0
  65. package/src/compiler/source.ts +319 -0
  66. package/src/compiler/template.test.ts +54 -0
  67. package/src/compiler/template.ts +90 -0
  68. package/src/compiler/test.artifacts.ts +195 -0
  69. package/src/compiler/util.ts +38 -0
  70. package/src/index.ts +1 -0
  71. package/src/shared/basecmd.ts +28 -0
  72. package/src/shared/dump.ts +164 -0
  73. package/src/shared/proc.ts +29 -0
@@ -0,0 +1,28 @@
1
+ import { Flags } from '@oclif/core'
2
+
3
+ export const GlobalFlags = {
4
+ "log-level": Flags.string({
5
+ description: "logging level",
6
+ default: "info",
7
+ options: ["error", "warn", "info", "debug"],
8
+ })
9
+ }
10
+
11
+ export const CtagsFlags = {
12
+ "generate-tags": Flags.boolean({
13
+ description: "generate tags, default false",
14
+ default: false,
15
+ }),
16
+
17
+ "tags-file": Flags.file({
18
+ description: "where to put \".tags\" file, it should be a root of VS Code project",
19
+ default: "../../.tags" // usually a user opens a directory with all blocks
20
+ }),
21
+
22
+ "tags-additional-args": Flags.string({
23
+ description: "additional flags for universal-ctags command: e.g. -e for emacs",
24
+ default: [],
25
+ multiple: true,
26
+ delimiter: ',',
27
+ })
28
+ }
@@ -0,0 +1,164 @@
1
+ import winston from 'winston';
2
+ import { getPackageInfo, newCompiler, parseSources } from '../compiler/main';
3
+ import { typedArtifactNameToString } from '../compiler/package';
4
+
5
+ export function dumpAll(
6
+ logger: winston.Logger,
7
+ stream: NodeJS.WritableStream
8
+ ): void {
9
+ const packageInfo = getPackageInfo();
10
+
11
+ const sources = parseSources(logger, packageInfo, 'dist', 'src', '');
12
+
13
+ const compiler = newCompiler(logger, packageInfo, 'dist');
14
+
15
+ // group output by type:
16
+ // - all libs
17
+ // - all templates
18
+ // - all tests
19
+
20
+ // Libs
21
+
22
+ for (const lib of compiler.allLibs()) {
23
+ logger.debug(
24
+ `Dumping to pl-tester: ${typedArtifactNameToString(lib.fullName)}`
25
+ );
26
+ stream.write(JSON.stringify(lib) + '\n');
27
+ }
28
+
29
+ for (const src of sources) {
30
+ if (src.fullName.type === 'library') {
31
+ logger.debug(
32
+ `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`
33
+ );
34
+ stream.write(JSON.stringify(src) + '\n');
35
+ }
36
+ }
37
+
38
+ // Templates
39
+
40
+ for (const tpl of compiler.allTemplates()) {
41
+ logger.debug(
42
+ `Dumping to pl-tester: ${typedArtifactNameToString(tpl.fullName)}`
43
+ );
44
+ stream.write(JSON.stringify(tpl) + '\n');
45
+ }
46
+
47
+ for (const src of sources) {
48
+ if (src.fullName.type === 'template') {
49
+ logger.debug(
50
+ `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)} ${
51
+ src.srcName
52
+ }`
53
+ );
54
+ stream.write(JSON.stringify(src) + '\n');
55
+ }
56
+ }
57
+
58
+ // Software
59
+
60
+ for (const sw of compiler.allSoftware()) {
61
+ logger.debug(
62
+ `Dumping to pl-tester: ${typedArtifactNameToString(sw.fullName)}`
63
+ );
64
+ stream.write(JSON.stringify(sw) + '\n');
65
+ }
66
+
67
+ for (const src of sources) {
68
+ if (src.fullName.type === 'software') {
69
+ logger.debug(
70
+ `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)}`
71
+ );
72
+ stream.write(JSON.stringify(src) + '\n');
73
+ }
74
+ }
75
+
76
+ // Tests
77
+
78
+ for (const src of sources) {
79
+ if (src.fullName.type === 'test') {
80
+ logger.debug(
81
+ `Dumping to pl-tester: ${typedArtifactNameToString(src.fullName)} ${
82
+ src.srcName
83
+ }`
84
+ );
85
+ stream.write(JSON.stringify(src) + '\n');
86
+ }
87
+ }
88
+ }
89
+
90
+ export function dumpLibs(
91
+ logger: winston.Logger,
92
+ dumpDeps: boolean,
93
+ stream: NodeJS.WritableStream
94
+ ): void {
95
+ const packageInfo = getPackageInfo();
96
+
97
+ const sources = parseSources(logger, packageInfo, 'dist', 'src', '');
98
+
99
+ if (!dumpDeps) {
100
+ for (const src of sources) {
101
+ if (src.fullName.type === 'library') {
102
+ stream.write(JSON.stringify(src) + '\n');
103
+ }
104
+ }
105
+
106
+ return;
107
+ }
108
+
109
+ const compiler = newCompiler(logger, packageInfo, 'dist');
110
+ for (const src of sources) {
111
+ if (src.fullName.type === 'library') {
112
+ compiler.addLib(src);
113
+ }
114
+ }
115
+
116
+ for (const lib of compiler.allLibs()) {
117
+ stream.write(JSON.stringify(lib) + '\n');
118
+ }
119
+ }
120
+
121
+ export function dumpTemplates(
122
+ logger: winston.Logger,
123
+ stream: NodeJS.WritableStream
124
+ ): void {
125
+ const packageInfo = getPackageInfo();
126
+
127
+ const sources = parseSources(logger, packageInfo, 'dist', 'src', '');
128
+
129
+ for (const src of sources) {
130
+ if (src.fullName.type === 'template') {
131
+ stream.write(JSON.stringify(src) + '\n');
132
+ }
133
+ }
134
+ }
135
+
136
+ export function dumpSoftware(
137
+ logger: winston.Logger,
138
+ stream: NodeJS.WritableStream
139
+ ): void {
140
+ const packageInfo = getPackageInfo();
141
+
142
+ const sources = parseSources(logger, packageInfo, 'dist', 'src', '');
143
+
144
+ for (const src of sources) {
145
+ if (src.fullName.type === 'software') {
146
+ stream.write(JSON.stringify(src) + '\n');
147
+ }
148
+ }
149
+ }
150
+
151
+ export function dumpTests(
152
+ logger: winston.Logger,
153
+ stream: NodeJS.WritableStream
154
+ ): void {
155
+ const packageInfo = getPackageInfo();
156
+
157
+ const sources = parseSources(logger, packageInfo, 'dist', 'src', '');
158
+
159
+ for (const src of sources) {
160
+ if (src.fullName.type === 'test') {
161
+ stream.write(JSON.stringify(src) + '\n');
162
+ }
163
+ }
164
+ }
@@ -0,0 +1,29 @@
1
+ import { spawn, ChildProcess, ChildProcessByStdio } from 'child_process';
2
+ import { Writable } from 'stream';
3
+
4
+ export function spawnEmbed(
5
+ cmd: string,
6
+ ...args: string[]
7
+ ): ChildProcessByStdio<Writable, null, null> {
8
+ const p = spawn(cmd, args, { stdio: ['pipe', 'inherit', 'inherit'] });
9
+
10
+ p.stdin.on('error', (err: any) => {
11
+ if (err.code === 'EPIPE') {
12
+ // ignore EPIPE error as it stands for broken command run.
13
+ // The command will write normal problem description by itself.
14
+ }
15
+ });
16
+
17
+ return p;
18
+ }
19
+
20
+ export function waitFor(p: ChildProcess): Promise<number> {
21
+ return new Promise((resolve, reject) => {
22
+ p.on('close', (code: number) => {
23
+ resolve(code);
24
+ });
25
+ p.on('error', (err) => {
26
+ reject(err);
27
+ });
28
+ });
29
+ }