@platforma-sdk/tengo-builder 2.4.13 → 2.4.15
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 +4 -4
- package/bin/run.js +5 -5
- package/dist/commands/build.cjs +36 -36
- package/dist/commands/build.cjs.map +1 -1
- package/dist/commands/build.d.ts +5 -5
- package/dist/commands/build.js +36 -36
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/check.cjs +5 -5
- package/dist/commands/check.cjs.map +1 -1
- package/dist/commands/check.d.ts +2 -2
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +5 -5
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/dump/artifacts.cjs +4 -6
- package/dist/commands/dump/artifacts.cjs.map +1 -1
- package/dist/commands/dump/artifacts.d.ts +2 -2
- package/dist/commands/dump/artifacts.d.ts.map +1 -1
- package/dist/commands/dump/artifacts.js +4 -6
- package/dist/commands/dump/artifacts.js.map +1 -1
- package/dist/commands/dump/software.cjs +3 -5
- package/dist/commands/dump/software.cjs.map +1 -1
- package/dist/commands/dump/software.d.ts +2 -2
- package/dist/commands/dump/software.d.ts.map +1 -1
- package/dist/commands/dump/software.js +3 -5
- package/dist/commands/dump/software.js.map +1 -1
- package/dist/commands/test.cjs +5 -5
- package/dist/commands/test.cjs.map +1 -1
- package/dist/commands/test.d.ts +2 -2
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +5 -5
- package/dist/commands/test.js.map +1 -1
- package/dist/compiler/artifactset.cjs +2 -2
- package/dist/compiler/artifactset.cjs.map +1 -1
- package/dist/compiler/artifactset.d.ts +1 -1
- package/dist/compiler/artifactset.d.ts.map +1 -1
- package/dist/compiler/artifactset.js +2 -2
- package/dist/compiler/artifactset.js.map +1 -1
- package/dist/compiler/compiler.cjs +37 -34
- package/dist/compiler/compiler.cjs.map +1 -1
- package/dist/compiler/compiler.d.ts +3 -3
- package/dist/compiler/compiler.d.ts.map +1 -1
- package/dist/compiler/compiler.js +37 -34
- package/dist/compiler/compiler.js.map +1 -1
- package/dist/compiler/compileroptions.cjs +12 -12
- package/dist/compiler/compileroptions.cjs.map +1 -1
- package/dist/compiler/compileroptions.d.ts +2 -2
- package/dist/compiler/compileroptions.js +12 -12
- package/dist/compiler/compileroptions.js.map +1 -1
- package/dist/compiler/main.cjs +58 -58
- package/dist/compiler/main.cjs.map +1 -1
- package/dist/compiler/main.d.ts +6 -6
- package/dist/compiler/main.d.ts.map +1 -1
- package/dist/compiler/main.js +58 -58
- package/dist/compiler/main.js.map +1 -1
- package/dist/compiler/package.cjs +5 -2
- package/dist/compiler/package.cjs.map +1 -1
- package/dist/compiler/package.d.ts +6 -6
- package/dist/compiler/package.d.ts.map +1 -1
- package/dist/compiler/package.js +5 -2
- package/dist/compiler/package.js.map +1 -1
- package/dist/compiler/source.cjs +50 -52
- package/dist/compiler/source.cjs.map +1 -1
- package/dist/compiler/source.d.ts +2 -2
- package/dist/compiler/source.d.ts.map +1 -1
- package/dist/compiler/source.js +50 -52
- package/dist/compiler/source.js.map +1 -1
- package/dist/compiler/template.cjs +7 -7
- package/dist/compiler/template.cjs.map +1 -1
- package/dist/compiler/template.d.ts +2 -2
- package/dist/compiler/template.d.ts.map +1 -1
- package/dist/compiler/template.js +7 -7
- package/dist/compiler/template.js.map +1 -1
- package/dist/compiler/test.artifacts.d.ts +1 -1
- package/dist/compiler/test.artifacts.d.ts.map +1 -1
- package/dist/compiler/util.cjs +12 -12
- package/dist/compiler/util.cjs.map +1 -1
- package/dist/compiler/util.d.ts +2 -2
- package/dist/compiler/util.js +12 -12
- package/dist/compiler/util.js.map +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/shared/basecmd.cjs +15 -15
- package/dist/shared/basecmd.cjs.map +1 -1
- package/dist/shared/basecmd.d.ts +4 -4
- package/dist/shared/basecmd.js +15 -15
- package/dist/shared/basecmd.js.map +1 -1
- package/dist/shared/dump.cjs +28 -28
- package/dist/shared/dump.cjs.map +1 -1
- package/dist/shared/dump.d.ts +2 -2
- package/dist/shared/dump.d.ts.map +1 -1
- package/dist/shared/dump.js +28 -28
- package/dist/shared/dump.js.map +1 -1
- package/dist/shared/proc.cjs +5 -5
- package/dist/shared/proc.cjs.map +1 -1
- package/dist/shared/proc.d.ts +2 -2
- package/dist/shared/proc.js +5 -5
- package/dist/shared/proc.js.map +1 -1
- package/package.json +21 -19
- package/src/commands/build.ts +57 -55
- package/src/commands/check.ts +15 -12
- package/src/commands/dump/artifacts.ts +11 -15
- package/src/commands/dump/software.ts +9 -10
- package/src/commands/test.ts +15 -12
- package/src/compiler/artifactset.ts +7 -9
- package/src/compiler/compiler.test.ts +134 -137
- package/src/compiler/compiler.ts +62 -62
- package/src/compiler/compileroptions.ts +15 -15
- package/src/compiler/main.test.ts +23 -23
- package/src/compiler/main.ts +83 -100
- package/src/compiler/package.ts +14 -12
- package/src/compiler/source.test.ts +191 -183
- package/src/compiler/source.ts +106 -79
- package/src/compiler/template.test.ts +50 -49
- package/src/compiler/template.ts +11 -21
- package/src/compiler/test.artifacts.ts +47 -47
- package/src/compiler/util.ts +17 -17
- package/src/index.ts +10 -10
- package/src/shared/basecmd.ts +16 -16
- package/src/shared/dump.ts +49 -70
- package/src/shared/proc.ts +8 -8
package/dist/compiler/main.js
CHANGED
|
@@ -8,18 +8,18 @@ import { newTemplateFromContent, templateToSource } from './template.js';
|
|
|
8
8
|
import { tryResolve, tryResolveOrError } from '@milaboratories/resolve-helper';
|
|
9
9
|
import { serializeTemplate } from '@milaboratories/pl-model-backend';
|
|
10
10
|
|
|
11
|
-
const compiledTplSuffix =
|
|
12
|
-
const compiledLibSuffix =
|
|
13
|
-
const compiledSoftwareSuffix =
|
|
14
|
-
const compiledAssetSuffix =
|
|
11
|
+
const compiledTplSuffix = ".plj.gz";
|
|
12
|
+
const compiledLibSuffix = ".lib.tengo";
|
|
13
|
+
const compiledSoftwareSuffix = ".sw.json";
|
|
14
|
+
const compiledAssetSuffix = ".as.json";
|
|
15
15
|
// We need to keep track of dependencies for correct tgo-test CLI utility configuraiton.
|
|
16
16
|
// It is much simpler to do this here, than duplicate all tle logic regarding dependencies
|
|
17
17
|
// in go code.
|
|
18
|
-
const srcTestSuffix =
|
|
19
|
-
const srcTplSuffix =
|
|
20
|
-
const srcLibSuffix =
|
|
21
|
-
const srcSoftwareSuffix =
|
|
22
|
-
const srcAssetSuffix =
|
|
18
|
+
const srcTestSuffix = ".test.tengo";
|
|
19
|
+
const srcTplSuffix = ".tpl.tengo";
|
|
20
|
+
const srcLibSuffix = ".lib.tengo";
|
|
21
|
+
const srcSoftwareSuffix = ".sw.json";
|
|
22
|
+
const srcAssetSuffix = ".as.json";
|
|
23
23
|
const compilableSuffixes = [srcLibSuffix, srcTplSuffix, srcSoftwareSuffix, srcAssetSuffix];
|
|
24
24
|
/**
|
|
25
25
|
* Resolves path to package.json file of the given dependency package.
|
|
@@ -34,20 +34,20 @@ function resolvePackageJsonPackage(root, depPackageName) {
|
|
|
34
34
|
if (resolved) {
|
|
35
35
|
let depth = 0;
|
|
36
36
|
do {
|
|
37
|
-
const p = path.join(resolved,
|
|
38
|
-
if (pathType(p) ===
|
|
37
|
+
const p = path.join(resolved, "package.json");
|
|
38
|
+
if (pathType(p) === "file")
|
|
39
39
|
return p;
|
|
40
40
|
depth++;
|
|
41
41
|
resolved = path.dirname(resolved);
|
|
42
|
-
} while (depth < 7 && path.basename(resolved) !==
|
|
42
|
+
} while (depth < 7 && path.basename(resolved) !== "node_modules");
|
|
43
43
|
}
|
|
44
44
|
// Second approach: trying to find package.json in the package dir.
|
|
45
45
|
const resolved2 = tryResolveOrError(root, `${depPackageName}/package.json`);
|
|
46
46
|
if (resolved2.result === undefined) {
|
|
47
|
-
if (resolved2.err ===
|
|
47
|
+
if (resolved2.err === "ERR_PACKAGE_PATH_NOT_EXPORTED")
|
|
48
48
|
// tolerating not-exported package.json for dev dependencies
|
|
49
49
|
return undefined;
|
|
50
|
-
throw new Error(`Can't resolve package.json for package ${depPackageName ??
|
|
50
|
+
throw new Error(`Can't resolve package.json for package ${depPackageName ?? "."} relative to ${root}`);
|
|
51
51
|
}
|
|
52
52
|
return resolved2.result;
|
|
53
53
|
}
|
|
@@ -55,29 +55,29 @@ function resolvePackageJsonRoot(root) {
|
|
|
55
55
|
if (!path.isAbsolute(root)) {
|
|
56
56
|
throw new Error(`Root path must be absolute: ${root}`);
|
|
57
57
|
}
|
|
58
|
-
const p = path.join(root,
|
|
59
|
-
if (pathType(p) ===
|
|
58
|
+
const p = path.join(root, "package.json");
|
|
59
|
+
if (pathType(p) === "file")
|
|
60
60
|
return p;
|
|
61
61
|
throw new Error(`Can't resolve package.json in ${root}`);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Get package info from package.json and all dependencies.
|
|
65
65
|
*/
|
|
66
|
-
function getPackageInfo(root, logger, context =
|
|
66
|
+
function getPackageInfo(root, logger, context = "root") {
|
|
67
67
|
const packageJsonPath = resolvePackageJsonRoot(root);
|
|
68
68
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString());
|
|
69
69
|
// resolving dependencies
|
|
70
70
|
const depInfos = [];
|
|
71
|
-
if (packageJson.dependencies && context !==
|
|
71
|
+
if (packageJson.dependencies && context !== "devDependency") {
|
|
72
72
|
for (const dep of Object.keys(packageJson.dependencies)) {
|
|
73
73
|
const depPackageJson = resolvePackageJsonPackage(root, dep);
|
|
74
74
|
if (depPackageJson === undefined)
|
|
75
75
|
throw new Error(`Can't resolve package.json for dependency ${dep} of ${root}`);
|
|
76
76
|
const depRoot = path.dirname(depPackageJson);
|
|
77
|
-
depInfos.push(getPackageInfo(depRoot, logger,
|
|
77
|
+
depInfos.push(getPackageInfo(depRoot, logger, "dependency"));
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
if (packageJson.devDependencies && context ===
|
|
80
|
+
if (packageJson.devDependencies && context === "root") {
|
|
81
81
|
for (const dep of Object.keys(packageJson.devDependencies)) {
|
|
82
82
|
const depPackageJson = resolvePackageJsonPackage(root, dep);
|
|
83
83
|
if (depPackageJson === undefined) {
|
|
@@ -86,7 +86,7 @@ function getPackageInfo(root, logger, context = 'root') {
|
|
|
86
86
|
continue;
|
|
87
87
|
}
|
|
88
88
|
const depRoot = path.dirname(depPackageJson);
|
|
89
|
-
depInfos.push(getPackageInfo(depRoot, logger,
|
|
89
|
+
depInfos.push(getPackageInfo(depRoot, logger, "devDependency"));
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
return {
|
|
@@ -99,47 +99,47 @@ function getPackageInfo(root, logger, context = 'root') {
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
function resolveLibsDst(mode, root) {
|
|
102
|
-
return path.resolve(root, mode,
|
|
102
|
+
return path.resolve(root, mode, "tengo", "lib");
|
|
103
103
|
}
|
|
104
104
|
function resolveTemplatesDst(mode, root) {
|
|
105
|
-
return path.resolve(root, mode,
|
|
105
|
+
return path.resolve(root, mode, "tengo", "tpl");
|
|
106
106
|
}
|
|
107
107
|
function resolveSoftwareDst(mode, root) {
|
|
108
|
-
return path.resolve(root, mode,
|
|
108
|
+
return path.resolve(root, mode, "tengo", "software");
|
|
109
109
|
}
|
|
110
110
|
function resolveAssetsDst(mode, root) {
|
|
111
|
-
return path.resolve(root, mode,
|
|
111
|
+
return path.resolve(root, mode, "tengo", "asset");
|
|
112
112
|
}
|
|
113
113
|
function loadDependencies(logger, compiler, packageInfo) {
|
|
114
114
|
for (const dep of packageInfo.dependencies)
|
|
115
115
|
loadDependencies(logger, compiler, dep);
|
|
116
|
-
if (packageInfo.context ===
|
|
116
|
+
if (packageInfo.context === "root")
|
|
117
117
|
// we are not reading compiled files for root package
|
|
118
118
|
return;
|
|
119
119
|
// we are in package folder
|
|
120
|
-
const libDistFolder = resolveLibsDst(
|
|
121
|
-
const tplDistFolder = resolveTemplatesDst(
|
|
122
|
-
const softwareDistFolder = resolveSoftwareDst(
|
|
123
|
-
const assetDistFolder = resolveAssetsDst(
|
|
124
|
-
const libDistExists = pathType(libDistFolder) ===
|
|
125
|
-
const tplDistExists = pathType(tplDistFolder) ===
|
|
126
|
-
const softwareDistExists = pathType(softwareDistFolder) ===
|
|
127
|
-
const assetDistExists = pathType(assetDistFolder) ===
|
|
120
|
+
const libDistFolder = resolveLibsDst("dist", packageInfo.root);
|
|
121
|
+
const tplDistFolder = resolveTemplatesDst("dist", packageInfo.root);
|
|
122
|
+
const softwareDistFolder = resolveSoftwareDst("dist", packageInfo.root);
|
|
123
|
+
const assetDistFolder = resolveAssetsDst("dist", packageInfo.root);
|
|
124
|
+
const libDistExists = pathType(libDistFolder) === "dir";
|
|
125
|
+
const tplDistExists = pathType(tplDistFolder) === "dir";
|
|
126
|
+
const softwareDistExists = pathType(softwareDistFolder) === "dir";
|
|
127
|
+
const assetDistExists = pathType(assetDistFolder) === "dir";
|
|
128
128
|
if (!libDistExists && !tplDistExists && !softwareDistExists && !assetDistExists)
|
|
129
129
|
// if neither of tengo-specific folders detected, skipping package
|
|
130
130
|
return;
|
|
131
131
|
const packageId = { name: packageInfo.name, version: packageInfo.version };
|
|
132
132
|
if (libDistExists) {
|
|
133
|
-
loadLibsFromDir(logger, packageId,
|
|
133
|
+
loadLibsFromDir(logger, packageId, "dist", libDistFolder, compiler);
|
|
134
134
|
}
|
|
135
135
|
if (tplDistExists) {
|
|
136
|
-
loadTemplatesFromDir(logger, packageId,
|
|
136
|
+
loadTemplatesFromDir(logger, packageId, "dist", tplDistFolder, compiler);
|
|
137
137
|
}
|
|
138
138
|
if (softwareDistExists) {
|
|
139
|
-
loadSoftwareFromDir(logger, packageId,
|
|
139
|
+
loadSoftwareFromDir(logger, packageId, "dist", softwareDistFolder, compiler);
|
|
140
140
|
}
|
|
141
141
|
if (assetDistExists) {
|
|
142
|
-
loadAssetsFromDir(logger, packageId,
|
|
142
|
+
loadAssetsFromDir(logger, packageId, "dist", assetDistFolder, compiler);
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
function loadLibsFromDir(logger, packageId, mode, folder, compiler) {
|
|
@@ -148,7 +148,7 @@ function loadLibsFromDir(logger, packageId, mode, folder, compiler) {
|
|
|
148
148
|
if (!f.endsWith(compiledLibSuffix))
|
|
149
149
|
throw new Error(`unexpected file in 'lib' folder: ${file}`);
|
|
150
150
|
const fullName = {
|
|
151
|
-
type:
|
|
151
|
+
type: "library",
|
|
152
152
|
pkg: packageId.name,
|
|
153
153
|
id: f.slice(0, f.length - compiledLibSuffix.length),
|
|
154
154
|
version: packageId.version,
|
|
@@ -157,7 +157,7 @@ function loadLibsFromDir(logger, packageId, mode, folder, compiler) {
|
|
|
157
157
|
compiler.addLib(src);
|
|
158
158
|
logger.debug(`Adding dependency ${fullNameToString(fullName)} from ${file}`);
|
|
159
159
|
if (src.dependencies.length > 0) {
|
|
160
|
-
logger.debug(
|
|
160
|
+
logger.debug("Dependencies:");
|
|
161
161
|
for (const dep of src.dependencies)
|
|
162
162
|
logger.debug(` - ${typedArtifactNameToString(dep)}`);
|
|
163
163
|
}
|
|
@@ -170,7 +170,7 @@ function loadTemplatesFromDir(logger, packageId, mode, folder, compiler) {
|
|
|
170
170
|
if (!f.endsWith(compiledTplSuffix))
|
|
171
171
|
throw new Error(`unexpected file in 'tpl' folder: ${file}`);
|
|
172
172
|
const fullName = {
|
|
173
|
-
type:
|
|
173
|
+
type: "template",
|
|
174
174
|
pkg: packageId.name,
|
|
175
175
|
id: f.slice(0, f.length - compiledTplSuffix.length),
|
|
176
176
|
version: packageId.version,
|
|
@@ -186,7 +186,7 @@ function loadSoftwareFromDir(logger, packageId, mode, folder, compiler) {
|
|
|
186
186
|
if (!f.endsWith(compiledSoftwareSuffix))
|
|
187
187
|
throw new Error(`unexpected file in 'software' folder: ${file}`);
|
|
188
188
|
const fullName = {
|
|
189
|
-
type:
|
|
189
|
+
type: "software",
|
|
190
190
|
pkg: packageId.name,
|
|
191
191
|
id: f.slice(0, f.length - compiledSoftwareSuffix.length),
|
|
192
192
|
version: packageId.version,
|
|
@@ -203,7 +203,7 @@ function loadAssetsFromDir(logger, packageId, mode, folder, compiler) {
|
|
|
203
203
|
if (!f.endsWith(compiledAssetSuffix))
|
|
204
204
|
throw new Error(`unexpected file in 'asset' folder: ${file}`);
|
|
205
205
|
const fullName = {
|
|
206
|
-
type:
|
|
206
|
+
type: "asset",
|
|
207
207
|
pkg: packageId.name,
|
|
208
208
|
id: f.slice(0, f.length - compiledAssetSuffix.length),
|
|
209
209
|
version: packageId.version,
|
|
@@ -219,14 +219,14 @@ function parseSources(logger, packageId, mode, root, subdir) {
|
|
|
219
219
|
for (const f of fs.readdirSync(path.join(root, subdir))) {
|
|
220
220
|
const inRootPath = path.join(subdir, f); // path to item inside given <root>
|
|
221
221
|
const fullPath = path.join(root, inRootPath); // full path to item from CWD (or abs path, if <root> is abs path)
|
|
222
|
-
if (pathType(fullPath) ===
|
|
222
|
+
if (pathType(fullPath) === "dir") {
|
|
223
223
|
const nested = parseSources(logger, packageId, mode, root, inRootPath);
|
|
224
224
|
sources.push(...nested);
|
|
225
225
|
continue;
|
|
226
226
|
}
|
|
227
227
|
// Handling index.lib.tengo files: rename them to <package-name>.lib.tengo
|
|
228
|
-
const artifactName = f ===
|
|
229
|
-
const fullName = fullNameFromFileName(packageId, artifactName.replaceAll(path.sep,
|
|
228
|
+
const artifactName = f === "index.lib.tengo" ? `${path.dirname(inRootPath)}.lib.tengo` : inRootPath;
|
|
229
|
+
const fullName = fullNameFromFileName(packageId, artifactName.replaceAll(path.sep, "."));
|
|
230
230
|
if (!fullName) {
|
|
231
231
|
logger.info(`Skipping unknown file type: ${artifactName}`);
|
|
232
232
|
continue; // skip unknown file types
|
|
@@ -240,7 +240,7 @@ function parseSources(logger, packageId, mode, root, subdir) {
|
|
|
240
240
|
logger.debug(`Parsing ${fullNameToString(fullName)} from ${file}`);
|
|
241
241
|
const newSrc = parseSourceFile(logger, mode, file, fullName, true);
|
|
242
242
|
if (newSrc.dependencies.length > 0) {
|
|
243
|
-
logger.debug(
|
|
243
|
+
logger.debug("Detected dependencies:");
|
|
244
244
|
for (const dep of newSrc.dependencies)
|
|
245
245
|
logger.debug(` - ${typedArtifactNameToString(dep)}`);
|
|
246
246
|
}
|
|
@@ -260,49 +260,49 @@ function fullNameFromFileName(packageId, artifactName) {
|
|
|
260
260
|
return {
|
|
261
261
|
...pkgAndVersion,
|
|
262
262
|
id: artifactName.substring(0, artifactName.length - srcLibSuffix.length),
|
|
263
|
-
type:
|
|
263
|
+
type: "library",
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
266
|
if (artifactName.endsWith(srcTplSuffix)) {
|
|
267
267
|
return {
|
|
268
268
|
...pkgAndVersion,
|
|
269
269
|
id: artifactName.substring(0, artifactName.length - srcTplSuffix.length),
|
|
270
|
-
type:
|
|
270
|
+
type: "template",
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
273
|
if (artifactName.endsWith(srcSoftwareSuffix)) {
|
|
274
274
|
return {
|
|
275
275
|
...pkgAndVersion,
|
|
276
276
|
id: artifactName.substring(0, artifactName.length - srcSoftwareSuffix.length),
|
|
277
|
-
type:
|
|
277
|
+
type: "software",
|
|
278
278
|
};
|
|
279
279
|
}
|
|
280
280
|
if (artifactName.endsWith(srcAssetSuffix)) {
|
|
281
281
|
return {
|
|
282
282
|
...pkgAndVersion,
|
|
283
283
|
id: artifactName.substring(0, artifactName.length - srcAssetSuffix.length),
|
|
284
|
-
type:
|
|
284
|
+
type: "asset",
|
|
285
285
|
};
|
|
286
286
|
}
|
|
287
287
|
if (artifactName.endsWith(srcTestSuffix)) {
|
|
288
288
|
return {
|
|
289
289
|
...pkgAndVersion,
|
|
290
290
|
id: artifactName.substring(0, artifactName.length - srcTestSuffix.length),
|
|
291
|
-
type:
|
|
291
|
+
type: "test",
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
294
|
return null;
|
|
295
295
|
}
|
|
296
296
|
function compile(logger, packageInfo, mode) {
|
|
297
297
|
const compiler = newCompiler(logger, packageInfo, mode);
|
|
298
|
-
const sources = parseSources(logger, packageInfo, mode,
|
|
298
|
+
const sources = parseSources(logger, packageInfo, mode, "src", "");
|
|
299
299
|
// checking that we have something to do
|
|
300
300
|
if (sources.length === 0) {
|
|
301
301
|
const lookFor = [];
|
|
302
302
|
for (const suffix of compilableSuffixes) {
|
|
303
303
|
lookFor.push(`*${suffix}`);
|
|
304
304
|
}
|
|
305
|
-
logger.error(`Nothing to compile. Looked for ${lookFor.join(
|
|
305
|
+
logger.error(`Nothing to compile. Looked for ${lookFor.join(", ")}`);
|
|
306
306
|
process.exit(1);
|
|
307
307
|
}
|
|
308
308
|
// compilation
|
|
@@ -314,7 +314,7 @@ function compile(logger, packageInfo, mode) {
|
|
|
314
314
|
function savePacks(logger, compiled, mode) {
|
|
315
315
|
// writing libs
|
|
316
316
|
if (compiled.libs.length > 0) {
|
|
317
|
-
const libOutput = resolveLibsDst(mode,
|
|
317
|
+
const libOutput = resolveLibsDst(mode, ".");
|
|
318
318
|
fs.mkdirSync(libOutput, { recursive: true });
|
|
319
319
|
for (const lib of compiled.libs) {
|
|
320
320
|
const file = path.resolve(libOutput, lib.fullName.id + compiledLibSuffix);
|
|
@@ -324,7 +324,7 @@ function savePacks(logger, compiled, mode) {
|
|
|
324
324
|
}
|
|
325
325
|
// writing templates
|
|
326
326
|
if (compiled.templates.length > 0) {
|
|
327
|
-
const tplOutput = resolveTemplatesDst(mode,
|
|
327
|
+
const tplOutput = resolveTemplatesDst(mode, ".");
|
|
328
328
|
fs.mkdirSync(tplOutput, { recursive: true });
|
|
329
329
|
for (const tpl of compiled.templates) {
|
|
330
330
|
const file = path.resolve(tplOutput, tpl.fullName.id + compiledTplSuffix);
|
|
@@ -334,7 +334,7 @@ function savePacks(logger, compiled, mode) {
|
|
|
334
334
|
}
|
|
335
335
|
// writing software
|
|
336
336
|
if (compiled.software.length > 0) {
|
|
337
|
-
const swOutput = resolveSoftwareDst(mode,
|
|
337
|
+
const swOutput = resolveSoftwareDst(mode, ".");
|
|
338
338
|
fs.mkdirSync(swOutput, { recursive: true });
|
|
339
339
|
for (const sw of compiled.software) {
|
|
340
340
|
const file = path.resolve(swOutput, sw.fullName.id + compiledSoftwareSuffix);
|
|
@@ -344,7 +344,7 @@ function savePacks(logger, compiled, mode) {
|
|
|
344
344
|
}
|
|
345
345
|
// writing assets
|
|
346
346
|
if (compiled.assets.length > 0) {
|
|
347
|
-
const swOutput = resolveAssetsDst(mode,
|
|
347
|
+
const swOutput = resolveAssetsDst(mode, ".");
|
|
348
348
|
fs.mkdirSync(swOutput, { recursive: true });
|
|
349
349
|
for (const sw of compiled.software) {
|
|
350
350
|
const file = path.resolve(swOutput, sw.fullName.id + compiledAssetSuffix);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sources":["../../src/compiler/main.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as path from 'node:path';\nimport * as fs from 'node:fs';\nimport { pathType } from './util';\nimport type { TemplatesAndLibs } from './compiler';\nimport { TengoTemplateCompiler } from './compiler';\nimport { getSha256 } from './source';\nimport type {\n CompileMode,\n FullArtifactName } from './package';\nimport {\n fullNameToString,\n typedArtifactNameToString,\n} from './package';\nimport { ArtifactSource, parseSourceFile } from './source';\nimport { newTemplateFromContent, templateToSource } from './template';\nimport type winston from 'winston';\nimport { tryResolve, tryResolveOrError } from '@milaboratories/resolve-helper';\nimport { serializeTemplate } from '@milaboratories/pl-model-backend';\n\ninterface PackageId {\n /** Package name from package.json */\n readonly name: string;\n /** Package version from package.json */\n readonly version: string;\n}\n\ninterface PackageInfo extends PackageId {\n /** Package type from package.json */\n readonly type: string | undefined;\n /** Path to package root */\n readonly root: string;\n /** Context of package info */\n readonly context: PackageInfoContext;\n /** Dependencies */\n readonly dependencies: PackageInfo[];\n}\n\ninterface PackageJson {\n name: string;\n version: string;\n type: string | undefined;\n dependencies: Record<string, string>;\n devDependencies: Record<string, string>;\n}\n\nconst compiledTplSuffix = '.plj.gz';\nconst compiledLibSuffix = '.lib.tengo';\nconst compiledSoftwareSuffix = '.sw.json';\nconst compiledAssetSuffix = '.as.json';\n\n// We need to keep track of dependencies for correct tgo-test CLI utility configuraiton.\n// It is much simpler to do this here, than duplicate all tle logic regarding dependencies\n// in go code.\nconst srcTestSuffix = '.test.tengo';\n\nconst srcTplSuffix = '.tpl.tengo';\nconst srcLibSuffix = '.lib.tengo';\nconst srcSoftwareSuffix = '.sw.json';\nconst srcAssetSuffix = '.as.json';\nconst compilableSuffixes = [srcLibSuffix, srcTplSuffix, srcSoftwareSuffix, srcAssetSuffix];\n\n/**\n * Resolves path to package.json file of the given dependency package.\n */\nfunction resolvePackageJsonPackage(root: string, depPackageName: string): string | undefined {\n if (!path.isAbsolute(root)) {\n throw new Error(`Root path must be absolute: ${root}`);\n }\n\n // First approach: resolving package's main entry point and try to find package.json\n // in dir tree upwards.\n let resolved = tryResolve(root, depPackageName);\n if (resolved) {\n let depth = 0;\n do {\n const p = path.join(resolved, 'package.json');\n if (pathType(p) === 'file')\n return p;\n depth++;\n resolved = path.dirname(resolved);\n } while (depth < 7 && path.basename(resolved) !== 'node_modules');\n }\n\n // Second approach: trying to find package.json in the package dir.\n const resolved2 = tryResolveOrError(root, `${depPackageName}/package.json`);\n if (resolved2.result === undefined) {\n if (resolved2.err === 'ERR_PACKAGE_PATH_NOT_EXPORTED')\n // tolerating not-exported package.json for dev dependencies\n return undefined;\n throw new Error(`Can't resolve package.json for package ${depPackageName ?? '.'} relative to ${root}`);\n }\n return resolved2.result;\n}\n\nexport function resolvePackageJsonRoot(root: string): string {\n if (!path.isAbsolute(root)) {\n throw new Error(`Root path must be absolute: ${root}`);\n }\n\n const p = path.join(root, 'package.json');\n if (pathType(p) === 'file')\n return p;\n throw new Error(`Can't resolve package.json in ${root}`);\n}\n\ntype PackageInfoContext = 'root' | 'dependency' | 'devDependency';\n\n/**\n * Get package info from package.json and all dependencies.\n */\nexport function getPackageInfo(\n root: string,\n logger: winston.Logger,\n context: PackageInfoContext = 'root',\n): PackageInfo {\n const packageJsonPath = resolvePackageJsonRoot(root);\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString()) as PackageJson;\n\n // resolving dependencies\n const depInfos: PackageInfo[] = [];\n\n if (packageJson.dependencies && context !== 'devDependency') {\n for (const dep of Object.keys(packageJson.dependencies)) {\n const depPackageJson = resolvePackageJsonPackage(root, dep);\n if (depPackageJson === undefined)\n throw new Error(`Can't resolve package.json for dependency ${dep} of ${root}`);\n const depRoot = path.dirname(depPackageJson);\n depInfos.push(getPackageInfo(depRoot, logger, 'dependency'));\n }\n }\n\n if (packageJson.devDependencies && context === 'root') {\n for (const dep of Object.keys(packageJson.devDependencies)) {\n const depPackageJson = resolvePackageJsonPackage(root, dep);\n if (depPackageJson === undefined) {\n logger.warn(`Can't resolve package.json for dev dependency ${dep} of ${root}`);\n // tolerating not-exported package.json for dev dependencies\n continue;\n }\n const depRoot = path.dirname(depPackageJson);\n depInfos.push(getPackageInfo(depRoot, logger, 'devDependency'));\n }\n }\n\n return {\n name: packageJson.name,\n version: packageJson.version,\n type: packageJson.type,\n dependencies: depInfos,\n root,\n context,\n };\n}\n\nfunction resolveLibsDst(mode: CompileMode, root: string) {\n return path.resolve(root, mode, 'tengo', 'lib');\n}\n\nfunction resolveTemplatesDst(mode: CompileMode, root: string) {\n return path.resolve(root, mode, 'tengo', 'tpl');\n}\n\nfunction resolveSoftwareDst(mode: CompileMode, root: string) {\n return path.resolve(root, mode, 'tengo', 'software');\n}\n\nfunction resolveAssetsDst(mode: CompileMode, root: string) {\n return path.resolve(root, mode, 'tengo', 'asset');\n}\n\nfunction loadDependencies(\n logger: winston.Logger,\n compiler: TengoTemplateCompiler,\n packageInfo: PackageInfo,\n): void {\n for (const dep of packageInfo.dependencies)\n loadDependencies(logger, compiler, dep);\n\n if (packageInfo.context === 'root')\n // we are not reading compiled files for root package\n return;\n\n // we are in package folder\n const libDistFolder = resolveLibsDst('dist', packageInfo.root);\n const tplDistFolder = resolveTemplatesDst('dist', packageInfo.root);\n const softwareDistFolder = resolveSoftwareDst('dist', packageInfo.root);\n const assetDistFolder = resolveAssetsDst('dist', packageInfo.root);\n\n const libDistExists = pathType(libDistFolder) === 'dir';\n const tplDistExists = pathType(tplDistFolder) === 'dir';\n const softwareDistExists = pathType(softwareDistFolder) === 'dir';\n const assetDistExists = pathType(assetDistFolder) === 'dir';\n\n if (!libDistExists && !tplDistExists && !softwareDistExists && !assetDistExists)\n // if neither of tengo-specific folders detected, skipping package\n return;\n\n const packageId = { name: packageInfo.name, version: packageInfo.version };\n\n if (libDistExists) {\n loadLibsFromDir(logger, packageId, 'dist', libDistFolder, compiler);\n }\n\n if (tplDistExists) {\n loadTemplatesFromDir(logger, packageId, 'dist', tplDistFolder, compiler);\n }\n\n if (softwareDistExists) {\n loadSoftwareFromDir(logger, packageId, 'dist', softwareDistFolder, compiler);\n }\n\n if (assetDistExists) {\n loadAssetsFromDir(logger, packageId, 'dist', assetDistFolder, compiler);\n }\n}\n\nfunction loadLibsFromDir(\n logger: winston.Logger,\n packageId: PackageId,\n mode: CompileMode,\n folder: string,\n compiler: TengoTemplateCompiler,\n) {\n for (const f of fs.readdirSync(folder)) {\n const file = path.resolve(folder, f);\n if (!f.endsWith(compiledLibSuffix)) throw new Error(`unexpected file in 'lib' folder: ${file}`);\n const fullName: FullArtifactName = {\n type: 'library',\n pkg: packageId.name,\n id: f.slice(0, f.length - compiledLibSuffix.length),\n version: packageId.version,\n };\n const src = parseSourceFile(logger, mode, file, fullName, true);\n compiler.addLib(src);\n logger.debug(`Adding dependency ${fullNameToString(fullName)} from ${file}`);\n if (src.dependencies.length > 0) {\n logger.debug('Dependencies:');\n for (const dep of src.dependencies) logger.debug(` - ${typedArtifactNameToString(dep)}`);\n }\n }\n}\n\nfunction loadTemplatesFromDir(\n logger: winston.Logger,\n packageId: PackageId,\n mode: CompileMode,\n folder: string,\n compiler: TengoTemplateCompiler,\n) {\n // adding templates\n for (const f of fs.readdirSync(folder)) {\n const file = path.resolve(folder, f);\n if (!f.endsWith(compiledTplSuffix)) throw new Error(`unexpected file in 'tpl' folder: ${file}`);\n const fullName: FullArtifactName = {\n type: 'template',\n pkg: packageId.name,\n id: f.slice(0, f.length - compiledTplSuffix.length),\n version: packageId.version,\n };\n const tpl = newTemplateFromContent(mode, fullName, fs.readFileSync(file));\n compiler.addTemplate(templateToSource(tpl));\n logger.debug(`Adding dependency ${fullNameToString(fullName)} from ${file}`);\n }\n}\n\nfunction loadSoftwareFromDir(\n logger: winston.Logger,\n packageId: PackageId,\n mode: CompileMode,\n folder: string,\n compiler: TengoTemplateCompiler,\n) {\n for (const f of fs.readdirSync(folder)) {\n const file = path.resolve(folder, f);\n if (!f.endsWith(compiledSoftwareSuffix))\n throw new Error(`unexpected file in 'software' folder: ${file}`);\n const fullName: FullArtifactName = {\n type: 'software',\n pkg: packageId.name,\n id: f.slice(0, f.length - compiledSoftwareSuffix.length),\n version: packageId.version,\n };\n\n const source = fs.readFileSync(file).toString();\n\n const software = new ArtifactSource(\n mode,\n fullName,\n getSha256(source),\n source,\n file,\n [],\n [],\n );\n\n logger.debug(`Adding dependency ${fullNameToString(fullName)} from ${file}`);\n compiler.addSoftware(software);\n }\n}\n\nfunction loadAssetsFromDir(\n logger: winston.Logger,\n packageId: PackageId,\n mode: CompileMode,\n folder: string,\n compiler: TengoTemplateCompiler,\n) {\n for (const f of fs.readdirSync(folder)) {\n const file = path.resolve(folder, f);\n if (!f.endsWith(compiledAssetSuffix))\n throw new Error(`unexpected file in 'asset' folder: ${file}`);\n const fullName: FullArtifactName = {\n type: 'asset',\n pkg: packageId.name,\n id: f.slice(0, f.length - compiledAssetSuffix.length),\n version: packageId.version,\n };\n\n const source = fs.readFileSync(file).toString();\n\n const asset = new ArtifactSource(\n mode,\n fullName,\n getSha256(source),\n source,\n file,\n [],\n [],\n );\n\n logger.debug(`Adding dependency ${fullNameToString(fullName)} from ${file}`);\n compiler.addAsset(asset);\n }\n}\n\nexport function parseSources(\n logger: winston.Logger,\n packageId: PackageId,\n mode: CompileMode,\n root: string,\n subdir: string,\n): ArtifactSource[] {\n const sources: ArtifactSource[] = [];\n\n for (const f of fs.readdirSync(path.join(root, subdir))) {\n const inRootPath = path.join(subdir, f); // path to item inside given <root>\n const fullPath = path.join(root, inRootPath); // full path to item from CWD (or abs path, if <root> is abs path)\n\n if (pathType(fullPath) === 'dir') {\n const nested = parseSources(logger, packageId, mode, root, inRootPath);\n sources.push(...nested);\n continue;\n }\n\n // Handling index.lib.tengo files: rename them to <package-name>.lib.tengo\n const artifactName = f === 'index.lib.tengo' ? `${path.dirname(inRootPath)}.lib.tengo` : inRootPath;\n\n const fullName = fullNameFromFileName(packageId, artifactName.replaceAll(path.sep, '.'));\n if (!fullName) {\n logger.info(`Skipping unknown file type: ${artifactName}`);\n continue; // skip unknown file types\n }\n\n // if (subdir != '') {\n // throw new Error(`Templates and libraries should reside only inside '${root}' dir.\n // You are free to have any file and dirs structure inside '${root}' keeping other files where you want,\n // but regarding ${compilableSuffixes.join(', ')}, the flat file structure is mandatory.`);\n // }\n\n const file = path.resolve(root, inRootPath);\n logger.debug(`Parsing ${fullNameToString(fullName)} from ${file}`);\n const newSrc = parseSourceFile(logger, mode, file, fullName, true);\n if (newSrc.dependencies.length > 0) {\n logger.debug('Detected dependencies:');\n for (const dep of newSrc.dependencies) logger.debug(` - ${typedArtifactNameToString(dep)}`);\n }\n\n sources.push(newSrc);\n }\n\n return sources;\n}\n\nexport function newCompiler(\n logger: winston.Logger,\n packageInfo: PackageInfo,\n mode: CompileMode,\n): TengoTemplateCompiler {\n const compiler = new TengoTemplateCompiler(mode);\n\n // collect all data (templates, libs and software) from dependency tree\n loadDependencies(logger, compiler, packageInfo);\n\n return compiler;\n}\n\nexport function fullNameFromFileName(\n packageId: PackageId,\n artifactName: string,\n): FullArtifactName | null {\n const pkgAndVersion = { pkg: packageId.name, version: packageId.version };\n if (artifactName.endsWith(srcLibSuffix)) {\n return {\n ...pkgAndVersion,\n id: artifactName.substring(0, artifactName.length - srcLibSuffix.length),\n type: 'library',\n };\n }\n\n if (artifactName.endsWith(srcTplSuffix)) {\n return {\n ...pkgAndVersion,\n id: artifactName.substring(0, artifactName.length - srcTplSuffix.length),\n type: 'template',\n };\n }\n\n if (artifactName.endsWith(srcSoftwareSuffix)) {\n return {\n ...pkgAndVersion,\n id: artifactName.substring(0, artifactName.length - srcSoftwareSuffix.length),\n type: 'software',\n };\n }\n\n if (artifactName.endsWith(srcAssetSuffix)) {\n return {\n ...pkgAndVersion,\n id: artifactName.substring(0, artifactName.length - srcAssetSuffix.length),\n type: 'asset',\n };\n }\n\n if (artifactName.endsWith(srcTestSuffix)) {\n return {\n ...pkgAndVersion,\n id: artifactName.substring(0, artifactName.length - srcTestSuffix.length),\n type: 'test',\n };\n }\n\n return null;\n}\n\nexport function compile(logger: winston.Logger, packageInfo: PackageInfo, mode: CompileMode): TemplatesAndLibs {\n const compiler = newCompiler(logger, packageInfo, mode);\n const sources = parseSources(logger, packageInfo, mode, 'src', '');\n\n // checking that we have something to do\n if (sources.length === 0) {\n const lookFor: string[] = [];\n for (const suffix of compilableSuffixes) {\n lookFor.push(`*${suffix}`);\n }\n\n logger.error(`Nothing to compile. Looked for ${lookFor.join(', ')}`);\n process.exit(1);\n }\n\n // compilation\n logger.info(`Compiling '${mode}'...`);\n const compiled = compiler.compileAndAdd(sources);\n logger.debug(`Done.`);\n\n return compiled;\n}\n\nexport function savePacks(logger: winston.Logger, compiled: TemplatesAndLibs, mode: CompileMode) {\n // writing libs\n if (compiled.libs.length > 0) {\n const libOutput = resolveLibsDst(mode, '.');\n fs.mkdirSync(libOutput, { recursive: true });\n for (const lib of compiled.libs) {\n const file = path.resolve(libOutput, lib.fullName.id + compiledLibSuffix);\n logger.info(` - writing ${file}`);\n fs.writeFileSync(file, lib.src);\n }\n }\n\n // writing templates\n if (compiled.templates.length > 0) {\n const tplOutput = resolveTemplatesDst(mode, '.');\n fs.mkdirSync(tplOutput, { recursive: true });\n for (const tpl of compiled.templates) {\n const file = path.resolve(tplOutput, tpl.fullName.id + compiledTplSuffix);\n logger.info(` - writing ${file}`);\n fs.writeFileSync(file, serializeTemplate(tpl.data));\n }\n }\n\n // writing software\n if (compiled.software.length > 0) {\n const swOutput = resolveSoftwareDst(mode, '.');\n fs.mkdirSync(swOutput, { recursive: true });\n for (const sw of compiled.software) {\n const file = path.resolve(swOutput, sw.fullName.id + compiledSoftwareSuffix);\n logger.info(` - writing ${file}`);\n fs.writeFileSync(file, sw.src);\n }\n }\n\n // writing assets\n if (compiled.assets.length > 0) {\n const swOutput = resolveAssetsDst(mode, '.');\n fs.mkdirSync(swOutput, { recursive: true });\n for (const sw of compiled.software) {\n const file = path.resolve(swOutput, sw.fullName.id + compiledAssetSuffix);\n logger.info(` - writing ${file}`);\n fs.writeFileSync(file, sw.src);\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AA+CA,MAAM,iBAAiB,GAAG,SAAS;AACnC,MAAM,iBAAiB,GAAG,YAAY;AACtC,MAAM,sBAAsB,GAAG,UAAU;AACzC,MAAM,mBAAmB,GAAG,UAAU;AAEtC;AACA;AACA;AACA,MAAM,aAAa,GAAG,aAAa;AAEnC,MAAM,YAAY,GAAG,YAAY;AACjC,MAAM,YAAY,GAAG,YAAY;AACjC,MAAM,iBAAiB,GAAG,UAAU;AACpC,MAAM,cAAc,GAAG,UAAU;AACjC,MAAM,kBAAkB,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,CAAC;AAE1F;;AAEG;AACH,SAAS,yBAAyB,CAAC,IAAY,EAAE,cAAsB,EAAA;IACrE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;AAC1B,QAAA,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,CAAA,CAAE,CAAC;IACxD;;;IAIA,IAAI,QAAQ,GAAG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CAAC,GAAG,CAAC;QAChC;IACF;;IAGA,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QAC9B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC;QAC5C,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAC3C,QAAA,KAAK,MAAM,EAAE,IAAI,QAAQ,CAAC,QAAQ,EAAE;AAClC,YAAA,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,mBAAmB,CAAC;AACzE,YAAA,MAAM,CAAC,IAAI,CAAC,eAAe,IAAI,CAAA,CAAE,CAAC;YAClC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC;QAChC;IACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"main.js","sources":["../../src/compiler/main.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as path from \"node:path\";\nimport * as fs from \"node:fs\";\nimport { pathType } from \"./util\";\nimport type { TemplatesAndLibs } from \"./compiler\";\nimport { TengoTemplateCompiler } from \"./compiler\";\nimport { getSha256 } from \"./source\";\nimport type { CompileMode, FullArtifactName } from \"./package\";\nimport { fullNameToString, typedArtifactNameToString } from \"./package\";\nimport { ArtifactSource, parseSourceFile } from \"./source\";\nimport { newTemplateFromContent, templateToSource } from \"./template\";\nimport type winston from \"winston\";\nimport { tryResolve, tryResolveOrError } from \"@milaboratories/resolve-helper\";\nimport { serializeTemplate } from \"@milaboratories/pl-model-backend\";\n\ninterface PackageId {\n /** Package name from package.json */\n readonly name: string;\n /** Package version from package.json */\n readonly version: string;\n}\n\ninterface PackageInfo extends PackageId {\n /** Package type from package.json */\n readonly type: string | undefined;\n /** Path to package root */\n readonly root: string;\n /** Context of package info */\n readonly context: PackageInfoContext;\n /** Dependencies */\n readonly dependencies: PackageInfo[];\n}\n\ninterface PackageJson {\n name: string;\n version: string;\n type: string | undefined;\n dependencies: Record<string, string>;\n devDependencies: Record<string, string>;\n}\n\nconst compiledTplSuffix = \".plj.gz\";\nconst compiledLibSuffix = \".lib.tengo\";\nconst compiledSoftwareSuffix = \".sw.json\";\nconst compiledAssetSuffix = \".as.json\";\n\n// We need to keep track of dependencies for correct tgo-test CLI utility configuraiton.\n// It is much simpler to do this here, than duplicate all tle logic regarding dependencies\n// in go code.\nconst srcTestSuffix = \".test.tengo\";\n\nconst srcTplSuffix = \".tpl.tengo\";\nconst srcLibSuffix = \".lib.tengo\";\nconst srcSoftwareSuffix = \".sw.json\";\nconst srcAssetSuffix = \".as.json\";\nconst compilableSuffixes = [srcLibSuffix, srcTplSuffix, srcSoftwareSuffix, srcAssetSuffix];\n\n/**\n * Resolves path to package.json file of the given dependency package.\n */\nfunction resolvePackageJsonPackage(root: string, depPackageName: string): string | undefined {\n if (!path.isAbsolute(root)) {\n throw new Error(`Root path must be absolute: ${root}`);\n }\n\n // First approach: resolving package's main entry point and try to find package.json\n // in dir tree upwards.\n let resolved = tryResolve(root, depPackageName);\n if (resolved) {\n let depth = 0;\n do {\n const p = path.join(resolved, \"package.json\");\n if (pathType(p) === \"file\") return p;\n depth++;\n resolved = path.dirname(resolved);\n } while (depth < 7 && path.basename(resolved) !== \"node_modules\");\n }\n\n // Second approach: trying to find package.json in the package dir.\n const resolved2 = tryResolveOrError(root, `${depPackageName}/package.json`);\n if (resolved2.result === undefined) {\n if (resolved2.err === \"ERR_PACKAGE_PATH_NOT_EXPORTED\")\n // tolerating not-exported package.json for dev dependencies\n return undefined;\n throw new Error(\n `Can't resolve package.json for package ${depPackageName ?? \".\"} relative to ${root}`,\n );\n }\n return resolved2.result;\n}\n\nexport function resolvePackageJsonRoot(root: string): string {\n if (!path.isAbsolute(root)) {\n throw new Error(`Root path must be absolute: ${root}`);\n }\n\n const p = path.join(root, \"package.json\");\n if (pathType(p) === \"file\") return p;\n throw new Error(`Can't resolve package.json in ${root}`);\n}\n\ntype PackageInfoContext = \"root\" | \"dependency\" | \"devDependency\";\n\n/**\n * Get package info from package.json and all dependencies.\n */\nexport function getPackageInfo(\n root: string,\n logger: winston.Logger,\n context: PackageInfoContext = \"root\",\n): PackageInfo {\n const packageJsonPath = resolvePackageJsonRoot(root);\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString()) as PackageJson;\n\n // resolving dependencies\n const depInfos: PackageInfo[] = [];\n\n if (packageJson.dependencies && context !== \"devDependency\") {\n for (const dep of Object.keys(packageJson.dependencies)) {\n const depPackageJson = resolvePackageJsonPackage(root, dep);\n if (depPackageJson === undefined)\n throw new Error(`Can't resolve package.json for dependency ${dep} of ${root}`);\n const depRoot = path.dirname(depPackageJson);\n depInfos.push(getPackageInfo(depRoot, logger, \"dependency\"));\n }\n }\n\n if (packageJson.devDependencies && context === \"root\") {\n for (const dep of Object.keys(packageJson.devDependencies)) {\n const depPackageJson = resolvePackageJsonPackage(root, dep);\n if (depPackageJson === undefined) {\n logger.warn(`Can't resolve package.json for dev dependency ${dep} of ${root}`);\n // tolerating not-exported package.json for dev dependencies\n continue;\n }\n const depRoot = path.dirname(depPackageJson);\n depInfos.push(getPackageInfo(depRoot, logger, \"devDependency\"));\n }\n }\n\n return {\n name: packageJson.name,\n version: packageJson.version,\n type: packageJson.type,\n dependencies: depInfos,\n root,\n context,\n };\n}\n\nfunction resolveLibsDst(mode: CompileMode, root: string) {\n return path.resolve(root, mode, \"tengo\", \"lib\");\n}\n\nfunction resolveTemplatesDst(mode: CompileMode, root: string) {\n return path.resolve(root, mode, \"tengo\", \"tpl\");\n}\n\nfunction resolveSoftwareDst(mode: CompileMode, root: string) {\n return path.resolve(root, mode, \"tengo\", \"software\");\n}\n\nfunction resolveAssetsDst(mode: CompileMode, root: string) {\n return path.resolve(root, mode, \"tengo\", \"asset\");\n}\n\nfunction loadDependencies(\n logger: winston.Logger,\n compiler: TengoTemplateCompiler,\n packageInfo: PackageInfo,\n): void {\n for (const dep of packageInfo.dependencies) loadDependencies(logger, compiler, dep);\n\n if (packageInfo.context === \"root\")\n // we are not reading compiled files for root package\n return;\n\n // we are in package folder\n const libDistFolder = resolveLibsDst(\"dist\", packageInfo.root);\n const tplDistFolder = resolveTemplatesDst(\"dist\", packageInfo.root);\n const softwareDistFolder = resolveSoftwareDst(\"dist\", packageInfo.root);\n const assetDistFolder = resolveAssetsDst(\"dist\", packageInfo.root);\n\n const libDistExists = pathType(libDistFolder) === \"dir\";\n const tplDistExists = pathType(tplDistFolder) === \"dir\";\n const softwareDistExists = pathType(softwareDistFolder) === \"dir\";\n const assetDistExists = pathType(assetDistFolder) === \"dir\";\n\n if (!libDistExists && !tplDistExists && !softwareDistExists && !assetDistExists)\n // if neither of tengo-specific folders detected, skipping package\n return;\n\n const packageId = { name: packageInfo.name, version: packageInfo.version };\n\n if (libDistExists) {\n loadLibsFromDir(logger, packageId, \"dist\", libDistFolder, compiler);\n }\n\n if (tplDistExists) {\n loadTemplatesFromDir(logger, packageId, \"dist\", tplDistFolder, compiler);\n }\n\n if (softwareDistExists) {\n loadSoftwareFromDir(logger, packageId, \"dist\", softwareDistFolder, compiler);\n }\n\n if (assetDistExists) {\n loadAssetsFromDir(logger, packageId, \"dist\", assetDistFolder, compiler);\n }\n}\n\nfunction loadLibsFromDir(\n logger: winston.Logger,\n packageId: PackageId,\n mode: CompileMode,\n folder: string,\n compiler: TengoTemplateCompiler,\n) {\n for (const f of fs.readdirSync(folder)) {\n const file = path.resolve(folder, f);\n if (!f.endsWith(compiledLibSuffix)) throw new Error(`unexpected file in 'lib' folder: ${file}`);\n const fullName: FullArtifactName = {\n type: \"library\",\n pkg: packageId.name,\n id: f.slice(0, f.length - compiledLibSuffix.length),\n version: packageId.version,\n };\n const src = parseSourceFile(logger, mode, file, fullName, true);\n compiler.addLib(src);\n logger.debug(`Adding dependency ${fullNameToString(fullName)} from ${file}`);\n if (src.dependencies.length > 0) {\n logger.debug(\"Dependencies:\");\n for (const dep of src.dependencies) logger.debug(` - ${typedArtifactNameToString(dep)}`);\n }\n }\n}\n\nfunction loadTemplatesFromDir(\n logger: winston.Logger,\n packageId: PackageId,\n mode: CompileMode,\n folder: string,\n compiler: TengoTemplateCompiler,\n) {\n // adding templates\n for (const f of fs.readdirSync(folder)) {\n const file = path.resolve(folder, f);\n if (!f.endsWith(compiledTplSuffix)) throw new Error(`unexpected file in 'tpl' folder: ${file}`);\n const fullName: FullArtifactName = {\n type: \"template\",\n pkg: packageId.name,\n id: f.slice(0, f.length - compiledTplSuffix.length),\n version: packageId.version,\n };\n const tpl = newTemplateFromContent(mode, fullName, fs.readFileSync(file));\n compiler.addTemplate(templateToSource(tpl));\n logger.debug(`Adding dependency ${fullNameToString(fullName)} from ${file}`);\n }\n}\n\nfunction loadSoftwareFromDir(\n logger: winston.Logger,\n packageId: PackageId,\n mode: CompileMode,\n folder: string,\n compiler: TengoTemplateCompiler,\n) {\n for (const f of fs.readdirSync(folder)) {\n const file = path.resolve(folder, f);\n if (!f.endsWith(compiledSoftwareSuffix))\n throw new Error(`unexpected file in 'software' folder: ${file}`);\n const fullName: FullArtifactName = {\n type: \"software\",\n pkg: packageId.name,\n id: f.slice(0, f.length - compiledSoftwareSuffix.length),\n version: packageId.version,\n };\n\n const source = fs.readFileSync(file).toString();\n\n const software = new ArtifactSource(mode, fullName, getSha256(source), source, file, [], []);\n\n logger.debug(`Adding dependency ${fullNameToString(fullName)} from ${file}`);\n compiler.addSoftware(software);\n }\n}\n\nfunction loadAssetsFromDir(\n logger: winston.Logger,\n packageId: PackageId,\n mode: CompileMode,\n folder: string,\n compiler: TengoTemplateCompiler,\n) {\n for (const f of fs.readdirSync(folder)) {\n const file = path.resolve(folder, f);\n if (!f.endsWith(compiledAssetSuffix))\n throw new Error(`unexpected file in 'asset' folder: ${file}`);\n const fullName: FullArtifactName = {\n type: \"asset\",\n pkg: packageId.name,\n id: f.slice(0, f.length - compiledAssetSuffix.length),\n version: packageId.version,\n };\n\n const source = fs.readFileSync(file).toString();\n\n const asset = new ArtifactSource(mode, fullName, getSha256(source), source, file, [], []);\n\n logger.debug(`Adding dependency ${fullNameToString(fullName)} from ${file}`);\n compiler.addAsset(asset);\n }\n}\n\nexport function parseSources(\n logger: winston.Logger,\n packageId: PackageId,\n mode: CompileMode,\n root: string,\n subdir: string,\n): ArtifactSource[] {\n const sources: ArtifactSource[] = [];\n\n for (const f of fs.readdirSync(path.join(root, subdir))) {\n const inRootPath = path.join(subdir, f); // path to item inside given <root>\n const fullPath = path.join(root, inRootPath); // full path to item from CWD (or abs path, if <root> is abs path)\n\n if (pathType(fullPath) === \"dir\") {\n const nested = parseSources(logger, packageId, mode, root, inRootPath);\n sources.push(...nested);\n continue;\n }\n\n // Handling index.lib.tengo files: rename them to <package-name>.lib.tengo\n const artifactName =\n f === \"index.lib.tengo\" ? `${path.dirname(inRootPath)}.lib.tengo` : inRootPath;\n\n const fullName = fullNameFromFileName(packageId, artifactName.replaceAll(path.sep, \".\"));\n if (!fullName) {\n logger.info(`Skipping unknown file type: ${artifactName}`);\n continue; // skip unknown file types\n }\n\n // if (subdir != '') {\n // throw new Error(`Templates and libraries should reside only inside '${root}' dir.\n // You are free to have any file and dirs structure inside '${root}' keeping other files where you want,\n // but regarding ${compilableSuffixes.join(', ')}, the flat file structure is mandatory.`);\n // }\n\n const file = path.resolve(root, inRootPath);\n logger.debug(`Parsing ${fullNameToString(fullName)} from ${file}`);\n const newSrc = parseSourceFile(logger, mode, file, fullName, true);\n if (newSrc.dependencies.length > 0) {\n logger.debug(\"Detected dependencies:\");\n for (const dep of newSrc.dependencies) logger.debug(` - ${typedArtifactNameToString(dep)}`);\n }\n\n sources.push(newSrc);\n }\n\n return sources;\n}\n\nexport function newCompiler(\n logger: winston.Logger,\n packageInfo: PackageInfo,\n mode: CompileMode,\n): TengoTemplateCompiler {\n const compiler = new TengoTemplateCompiler(mode);\n\n // collect all data (templates, libs and software) from dependency tree\n loadDependencies(logger, compiler, packageInfo);\n\n return compiler;\n}\n\nexport function fullNameFromFileName(\n packageId: PackageId,\n artifactName: string,\n): FullArtifactName | null {\n const pkgAndVersion = { pkg: packageId.name, version: packageId.version };\n if (artifactName.endsWith(srcLibSuffix)) {\n return {\n ...pkgAndVersion,\n id: artifactName.substring(0, artifactName.length - srcLibSuffix.length),\n type: \"library\",\n };\n }\n\n if (artifactName.endsWith(srcTplSuffix)) {\n return {\n ...pkgAndVersion,\n id: artifactName.substring(0, artifactName.length - srcTplSuffix.length),\n type: \"template\",\n };\n }\n\n if (artifactName.endsWith(srcSoftwareSuffix)) {\n return {\n ...pkgAndVersion,\n id: artifactName.substring(0, artifactName.length - srcSoftwareSuffix.length),\n type: \"software\",\n };\n }\n\n if (artifactName.endsWith(srcAssetSuffix)) {\n return {\n ...pkgAndVersion,\n id: artifactName.substring(0, artifactName.length - srcAssetSuffix.length),\n type: \"asset\",\n };\n }\n\n if (artifactName.endsWith(srcTestSuffix)) {\n return {\n ...pkgAndVersion,\n id: artifactName.substring(0, artifactName.length - srcTestSuffix.length),\n type: \"test\",\n };\n }\n\n return null;\n}\n\nexport function compile(\n logger: winston.Logger,\n packageInfo: PackageInfo,\n mode: CompileMode,\n): TemplatesAndLibs {\n const compiler = newCompiler(logger, packageInfo, mode);\n const sources = parseSources(logger, packageInfo, mode, \"src\", \"\");\n\n // checking that we have something to do\n if (sources.length === 0) {\n const lookFor: string[] = [];\n for (const suffix of compilableSuffixes) {\n lookFor.push(`*${suffix}`);\n }\n\n logger.error(`Nothing to compile. Looked for ${lookFor.join(\", \")}`);\n process.exit(1);\n }\n\n // compilation\n logger.info(`Compiling '${mode}'...`);\n const compiled = compiler.compileAndAdd(sources);\n logger.debug(`Done.`);\n\n return compiled;\n}\n\nexport function savePacks(logger: winston.Logger, compiled: TemplatesAndLibs, mode: CompileMode) {\n // writing libs\n if (compiled.libs.length > 0) {\n const libOutput = resolveLibsDst(mode, \".\");\n fs.mkdirSync(libOutput, { recursive: true });\n for (const lib of compiled.libs) {\n const file = path.resolve(libOutput, lib.fullName.id + compiledLibSuffix);\n logger.info(` - writing ${file}`);\n fs.writeFileSync(file, lib.src);\n }\n }\n\n // writing templates\n if (compiled.templates.length > 0) {\n const tplOutput = resolveTemplatesDst(mode, \".\");\n fs.mkdirSync(tplOutput, { recursive: true });\n for (const tpl of compiled.templates) {\n const file = path.resolve(tplOutput, tpl.fullName.id + compiledTplSuffix);\n logger.info(` - writing ${file}`);\n fs.writeFileSync(file, serializeTemplate(tpl.data));\n }\n }\n\n // writing software\n if (compiled.software.length > 0) {\n const swOutput = resolveSoftwareDst(mode, \".\");\n fs.mkdirSync(swOutput, { recursive: true });\n for (const sw of compiled.software) {\n const file = path.resolve(swOutput, sw.fullName.id + compiledSoftwareSuffix);\n logger.info(` - writing ${file}`);\n fs.writeFileSync(file, sw.src);\n }\n }\n\n // writing assets\n if (compiled.assets.length > 0) {\n const swOutput = resolveAssetsDst(mode, \".\");\n fs.mkdirSync(swOutput, { recursive: true });\n for (const sw of compiled.software) {\n const file = path.resolve(swOutput, sw.fullName.id + compiledAssetSuffix);\n logger.info(` - writing ${file}`);\n fs.writeFileSync(file, sw.src);\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AA0CA,MAAM,iBAAiB,GAAG,SAAS;AACnC,MAAM,iBAAiB,GAAG,YAAY;AACtC,MAAM,sBAAsB,GAAG,UAAU;AACzC,MAAM,mBAAmB,GAAG,UAAU;AAEtC;AACA;AACA;AACA,MAAM,aAAa,GAAG,aAAa;AAEnC,MAAM,YAAY,GAAG,YAAY;AACjC,MAAM,YAAY,GAAG,YAAY;AACjC,MAAM,iBAAiB,GAAG,UAAU;AACpC,MAAM,cAAc,GAAG,UAAU;AACjC,MAAM,kBAAkB,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,CAAC;AAE1F;;AAEG;AACH,SAAS,yBAAyB,CAAC,IAAY,EAAE,cAAsB,EAAA;IACrE,IAAI,CAAC,IAAI,CA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,CAAC,EAAE,GAAG,sBAAsB,CAAC;AAC5E,YAAA,MAAM,CAAC,IAAI,CAAC,eAAe,IAAI,CAAA,CAAE,CAAC;YAClC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC;QAChC;IACF;;IAGA,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QAC9B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC;QAC5C,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAC3C,QAAA,KAAK,MAAM,EAAE,IAAI,QAAQ,CAAC,QAAQ,EAAE;AAClC,YAAA,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,mBAAmB,CAAC;AACzE,YAAA,MAAM,CAAC,IAAI,CAAC,eAAe,IAAI,CAAA,CAAE,CAAC;YAClC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC;QAChC;IACF;AACF;;;;"}
|
|
@@ -32,7 +32,10 @@ function typedArtifactNamesEquals(name1, name2) {
|
|
|
32
32
|
return name1.type == name2.type && name1.pkg == name2.pkg && name1.id == name2.id;
|
|
33
33
|
}
|
|
34
34
|
function fullNameEquals(name1, name2) {
|
|
35
|
-
return name1.type == name2.type &&
|
|
35
|
+
return (name1.type == name2.type &&
|
|
36
|
+
name1.pkg == name2.pkg &&
|
|
37
|
+
name1.id == name2.id &&
|
|
38
|
+
name1.version == name2.version);
|
|
36
39
|
}
|
|
37
40
|
/** used to format artefact name while generating output files */
|
|
38
41
|
function artifactNameToString(name) {
|
|
@@ -47,7 +50,7 @@ function parseArtefactNameAndVersion(nameAndVersion) {
|
|
|
47
50
|
const match = nameAndVersion.name.match(/^(?<pkg>[^:]*):(?<id>[^:]*)$/);
|
|
48
51
|
if (!match)
|
|
49
52
|
throw new Error(`malformed artifact name: ${nameAndVersion.name}`);
|
|
50
|
-
return { pkg: match.groups[
|
|
53
|
+
return { pkg: match.groups["pkg"], id: match.groups["id"], version: nameAndVersion.version };
|
|
51
54
|
}
|
|
52
55
|
function fullNameWithoutTypeToString(name) {
|
|
53
56
|
return `${name.pkg}:${name.id}:${name.version}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.cjs","sources":["../../src/compiler/package.ts"],"sourcesContent":["/*\n Package \"@milaboratory/current-tengo-package\".\n\n Structure:\n\n src/\n local-template.pl.tengo <- this one will be compiled and put into ./dist/tengo/tpl/local-template.pl.pkg\n local-library.tengo <- this one will be normalized and put into ./dist/tengo/lib/local-library.tengo\n main.tpl.tengo <- this one will be compiled into ./dist/tengo/tpl/main.pl.pkg and published by external tool\n\n Code of \"main.tpl.tengo\":\n\n plapi := import(\"plapi\")\n\n plapi.getTemplateId(\"@milaboratory/some-tengo-template\") // -> getTemplateId(\"@milaboratory/some-tengo-template:main\")\n import(\"@milaboratory/some-tengo-library\") // -> import(\"@milaboratory/some-tengo-library:main\")\n\n */\n\nexport type CompileMode =
|
|
1
|
+
{"version":3,"file":"package.cjs","sources":["../../src/compiler/package.ts"],"sourcesContent":["/*\n Package \"@milaboratory/current-tengo-package\".\n\n Structure:\n\n src/\n local-template.pl.tengo <- this one will be compiled and put into ./dist/tengo/tpl/local-template.pl.pkg\n local-library.tengo <- this one will be normalized and put into ./dist/tengo/lib/local-library.tengo\n main.tpl.tengo <- this one will be compiled into ./dist/tengo/tpl/main.pl.pkg and published by external tool\n\n Code of \"main.tpl.tengo\":\n\n plapi := import(\"plapi\")\n\n plapi.getTemplateId(\"@milaboratory/some-tengo-template\") // -> getTemplateId(\"@milaboratory/some-tengo-template:main\")\n import(\"@milaboratory/some-tengo-library\") // -> import(\"@milaboratory/some-tengo-library:main\")\n\n */\n\nexport type CompileMode = \"dist\";\n\nexport type CompilerOption = {\n /** Option name, like 'hash_override' */\n name: string; // we can't use strict literals typing here as we will break compatibility of the code through the lifetime of the compiler.\n\n /** Arguments of the option. Everything that follows option name */\n args: string[];\n};\n\nexport type ArtifactType = \"library\" | \"template\" | \"test\" | \"software\" | \"asset\";\n\n/** Artifact Name including package version */\nexport interface FullArtifactName {\n /** Dependency type */\n type: ArtifactType;\n\n /** Fully qualified package */\n pkg: string;\n\n /** Id of the artifact inside the package */\n id: string;\n\n /** Package version */\n version: string;\n}\n\nexport type FullArtifactNameWithoutType = Omit<FullArtifactName, \"type\">;\n\nexport type TypedArtifactName = Pick<FullArtifactName, \"type\" | \"pkg\" | \"id\">;\n\nexport type PackageName = Pick<FullArtifactName, \"pkg\" | \"version\">;\n\nexport type ArtifactName = Pick<FullArtifactName, \"pkg\" | \"id\">;\n\nexport function artifactKey(name: TypedArtifactName): string {\n return `${name.type}||${name.pkg}||${name.id}`;\n}\n\nexport function fullNameToString(name: FullArtifactName): string {\n return `${name.type}:${name.pkg}:${name.id}:${name.version}`;\n}\n\n/** used for exceptions */\nexport function typedArtifactNameToString(name: TypedArtifactName): string {\n return `${name.type}:${name.pkg}:${name.id}`;\n}\n\nexport function typedArtifactNamesEquals(\n name1: TypedArtifactName,\n name2: TypedArtifactName,\n): boolean {\n return name1.type == name2.type && name1.pkg == name2.pkg && name1.id == name2.id;\n}\n\nexport function fullNameEquals(name1: FullArtifactName, name2: FullArtifactName): boolean {\n return (\n name1.type == name2.type &&\n name1.pkg == name2.pkg &&\n name1.id == name2.id &&\n name1.version == name2.version\n );\n}\n\n/** used to format artefact name while generating output files */\nexport function artifactNameToString(name: ArtifactName): string {\n return `${name.pkg}:${name.id}`;\n}\n\n/** used to format artefact name and version while generating output files */\nexport function formatArtefactNameAndVersion(name: FullArtifactName): {\n name: string;\n version: string;\n} {\n return { name: artifactNameToString(name), version: name.version };\n}\n\n/** used to format artefact name and version while generating output files */\nexport function parseArtefactNameAndVersion(nameAndVersion: {\n name: string;\n version: string;\n}): FullArtifactNameWithoutType {\n const match = nameAndVersion.name.match(/^(?<pkg>[^:]*):(?<id>[^:]*)$/);\n if (!match) throw new Error(`malformed artifact name: ${nameAndVersion.name}`);\n return { pkg: match.groups![\"pkg\"], id: match.groups![\"id\"], version: nameAndVersion.version };\n}\n\nexport function fullNameWithoutTypeToString(name: FullArtifactNameWithoutType): string {\n return `${name.pkg}:${name.id}:${name.version}`;\n}\n\nexport function fullNameWithoutType(name: FullArtifactName): FullArtifactNameWithoutType {\n return { pkg: name.pkg, id: name.id, version: name.version };\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;AAiBG;AAqCG,SAAU,WAAW,CAAC,IAAuB,EAAA;AACjD,IAAA,OAAO,CAAA,EAAG,IAAI,CAAC,IAAI,CAAA,EAAA,EAAK,IAAI,CAAC,GAAG,CAAA,EAAA,EAAK,IAAI,CAAC,EAAE,EAAE;AAChD;AAEM,SAAU,gBAAgB,CAAC,IAAsB,EAAA;AACrD,IAAA,OAAO,GAAG,IAAI,CAAC,IAAI,CAAA,CAAA,EAAI,IAAI,CAAC,GAAG,CAAA,CAAA,EAAI,IAAI,CAAC,EAAE,CAAA,CAAA,EAAI,IAAI,CAAC,OAAO,EAAE;AAC9D;AAEA;AACM,SAAU,yBAAyB,CAAC,IAAuB,EAAA;AAC/D,IAAA,OAAO,CAAA,EAAG,IAAI,CAAC,IAAI,CAAA,CAAA,EAAI,IAAI,CAAC,GAAG,CAAA,CAAA,EAAI,IAAI,CAAC,EAAE,EAAE;AAC9C;AAEM,SAAU,wBAAwB,CACtC,KAAwB,EACxB,KAAwB,EAAA;IAExB,OAAO,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE;AACnF;AAEM,SAAU,cAAc,CAAC,KAAuB,EAAE,KAAuB,EAAA;AAC7E,IAAA,QACE,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI;AACxB,QAAA,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG;AACtB,QAAA,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE;AACpB,QAAA,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO;AAElC;AAEA;AACM,SAAU,oBAAoB,CAAC,IAAkB,EAAA;IACrD,OAAO,CAAA,EAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,EAAE,CAAA,CAAE;AACjC;AAEA;AACM,SAAU,4BAA4B,CAAC,IAAsB,EAAA;AAIjE,IAAA,OAAO,EAAE,IAAI,EAAE,oBAAoB,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;AACpE;AAEA;AACM,SAAU,2BAA2B,CAAC,cAG3C,EAAA;IACC,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,8BAA8B,CAAC;AACvE,IAAA,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,CAAA,yBAAA,EAA4B,cAAc,CAAC,IAAI,CAAA,CAAE,CAAC;IAC9E,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,MAAO,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,MAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,cAAc,CAAC,OAAO,EAAE;AAChG;AAEM,SAAU,2BAA2B,CAAC,IAAiC,EAAA;AAC3E,IAAA,OAAO,CAAA,EAAG,IAAI,CAAC,GAAG,CAAA,CAAA,EAAI,IAAI,CAAC,EAAE,CAAA,CAAA,EAAI,IAAI,CAAC,OAAO,EAAE;AACjD;;;;;;;;;;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export type CompileMode =
|
|
1
|
+
export type CompileMode = "dist";
|
|
2
2
|
export type CompilerOption = {
|
|
3
3
|
/** Option name, like 'hash_override' */
|
|
4
4
|
name: string;
|
|
5
5
|
/** Arguments of the option. Everything that follows option name */
|
|
6
6
|
args: string[];
|
|
7
7
|
};
|
|
8
|
-
export type ArtifactType =
|
|
8
|
+
export type ArtifactType = "library" | "template" | "test" | "software" | "asset";
|
|
9
9
|
/** Artifact Name including package version */
|
|
10
10
|
export interface FullArtifactName {
|
|
11
11
|
/** Dependency type */
|
|
@@ -17,10 +17,10 @@ export interface FullArtifactName {
|
|
|
17
17
|
/** Package version */
|
|
18
18
|
version: string;
|
|
19
19
|
}
|
|
20
|
-
export type FullArtifactNameWithoutType = Omit<FullArtifactName,
|
|
21
|
-
export type TypedArtifactName = Pick<FullArtifactName,
|
|
22
|
-
export type PackageName = Pick<FullArtifactName,
|
|
23
|
-
export type ArtifactName = Pick<FullArtifactName,
|
|
20
|
+
export type FullArtifactNameWithoutType = Omit<FullArtifactName, "type">;
|
|
21
|
+
export type TypedArtifactName = Pick<FullArtifactName, "type" | "pkg" | "id">;
|
|
22
|
+
export type PackageName = Pick<FullArtifactName, "pkg" | "version">;
|
|
23
|
+
export type ArtifactName = Pick<FullArtifactName, "pkg" | "id">;
|
|
24
24
|
export declare function artifactKey(name: TypedArtifactName): string;
|
|
25
25
|
export declare function fullNameToString(name: FullArtifactName): string;
|
|
26
26
|
/** used for exceptions */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/compiler/package.ts"],"names":[],"mappings":"AAmBA,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC,MAAM,MAAM,cAAc,GAAG;IAC3B,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IAEb,mEAAmE;IACnE,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC;AAElF,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB;IACtB,IAAI,EAAE,YAAY,CAAC;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M,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"}
|
package/dist/compiler/package.js
CHANGED
|
@@ -30,7 +30,10 @@ function typedArtifactNamesEquals(name1, name2) {
|
|
|
30
30
|
return name1.type == name2.type && name1.pkg == name2.pkg && name1.id == name2.id;
|
|
31
31
|
}
|
|
32
32
|
function fullNameEquals(name1, name2) {
|
|
33
|
-
return name1.type == name2.type &&
|
|
33
|
+
return (name1.type == name2.type &&
|
|
34
|
+
name1.pkg == name2.pkg &&
|
|
35
|
+
name1.id == name2.id &&
|
|
36
|
+
name1.version == name2.version);
|
|
34
37
|
}
|
|
35
38
|
/** used to format artefact name while generating output files */
|
|
36
39
|
function artifactNameToString(name) {
|
|
@@ -45,7 +48,7 @@ function parseArtefactNameAndVersion(nameAndVersion) {
|
|
|
45
48
|
const match = nameAndVersion.name.match(/^(?<pkg>[^:]*):(?<id>[^:]*)$/);
|
|
46
49
|
if (!match)
|
|
47
50
|
throw new Error(`malformed artifact name: ${nameAndVersion.name}`);
|
|
48
|
-
return { pkg: match.groups[
|
|
51
|
+
return { pkg: match.groups["pkg"], id: match.groups["id"], version: nameAndVersion.version };
|
|
49
52
|
}
|
|
50
53
|
function fullNameWithoutTypeToString(name) {
|
|
51
54
|
return `${name.pkg}:${name.id}:${name.version}`;
|