@intelligentgraphics/ig.gfx.packager 3.0.27 → 3.1.0-alpha.0
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/build/bin.mjs +1 -1
- package/build/{cli-e279c41e.mjs → cli-CuiqZ39_.mjs} +52 -85
- package/build/cli-CuiqZ39_.mjs.map +1 -0
- package/build/{dependencies-9afff33c.mjs → dependencies-BiYItaVS.mjs} +2 -2
- package/build/{dependencies-9afff33c.mjs.map → dependencies-BiYItaVS.mjs.map} +1 -1
- package/build/{generateIndex-9864e722.mjs → generateIndex-hg6jRXQv.mjs} +97 -84
- package/build/generateIndex-hg6jRXQv.mjs.map +1 -0
- package/build/{generateParameterType-32abb018.mjs → generateParameterType-CDjqLM4J.mjs} +3 -4
- package/build/{generateParameterType-32abb018.mjs.map → generateParameterType-CDjqLM4J.mjs.map} +1 -1
- package/build/{index-a87a7800.mjs → index-B2kXo6K7.mjs} +301 -89
- package/build/index-B2kXo6K7.mjs.map +1 -0
- package/build/{index-56178e55.mjs → index-BoGrZubW.mjs} +27 -25
- package/build/index-BoGrZubW.mjs.map +1 -0
- package/build/{postinstall-472e0106.mjs → postinstall-CbMUz2zy.mjs} +3 -4
- package/build/{postinstall-472e0106.mjs.map → postinstall-CbMUz2zy.mjs.map} +1 -1
- package/build/{publishNpm-7d02c52b.mjs → publishNpm-CrnuTwss.mjs} +12 -11
- package/build/publishNpm-CrnuTwss.mjs.map +1 -0
- package/build/rollup-UR3DADp8.mjs +198 -0
- package/build/rollup-UR3DADp8.mjs.map +1 -0
- package/build/scripts-Bfojy_uD.mjs +48 -0
- package/build/scripts-Bfojy_uD.mjs.map +1 -0
- package/build/versionFile-DSqOw-XB.mjs +208 -0
- package/build/versionFile-DSqOw-XB.mjs.map +1 -0
- package/lib/lib.mjs +448 -359
- package/package.json +15 -10
- package/readme.md +91 -10
- package/build/cli-e279c41e.mjs.map +0 -1
- package/build/generateIndex-9864e722.mjs.map +0 -1
- package/build/index-56178e55.mjs.map +0 -1
- package/build/index-a87a7800.mjs.map +0 -1
- package/build/publishNpm-7d02c52b.mjs.map +0 -1
- package/build/scripts-7ed8dff6.mjs +0 -10
- package/build/scripts-7ed8dff6.mjs.map +0 -1
- package/build/versionFile-4b06435d.mjs +0 -384
- package/build/versionFile-4b06435d.mjs.map +0 -1
package/lib/lib.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
2
|
import * as fs$1 from 'fs/promises';
|
|
3
3
|
import * as terser from 'terser';
|
|
4
|
+
import { EOL } from 'os';
|
|
5
|
+
import ts from 'typescript';
|
|
4
6
|
import * as fs from 'fs';
|
|
5
7
|
import { createWriteStream, createReadStream } from 'fs';
|
|
6
8
|
import resolve from 'resolve';
|
|
@@ -8,18 +10,17 @@ import 'write-pkg';
|
|
|
8
10
|
import glob from 'glob';
|
|
9
11
|
import 'write-json-file';
|
|
10
12
|
import axios, { AxiosError } from 'axios';
|
|
11
|
-
import ts from 'typescript';
|
|
12
13
|
import typedoc from 'typedoc';
|
|
13
14
|
import EventEmitter from 'events';
|
|
14
15
|
import { SourceMapGenerator, SourceMapConsumer } from 'source-map-js';
|
|
15
16
|
import Ajv from 'ajv';
|
|
16
|
-
import { EOL } from 'os';
|
|
17
17
|
import { pipeline } from 'stream/promises';
|
|
18
18
|
import { exec } from 'child_process';
|
|
19
19
|
import { promisify } from 'util';
|
|
20
20
|
import simpleGit from 'simple-git';
|
|
21
21
|
import JSZip from 'jszip';
|
|
22
22
|
import { buffer } from 'node:stream/consumers';
|
|
23
|
+
import { resolveNamespaces, resolveNamespaceFullName } from '@intelligentgraphics/declarationbundler';
|
|
23
24
|
|
|
24
25
|
const stripUtf8Bom = (text)=>{
|
|
25
26
|
// Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
|
|
@@ -59,13 +60,16 @@ const isErrorEPERM = (error)=>getNodeErrorCode(error) === "EPERM";
|
|
|
59
60
|
const PACKAGE_FILE = "_Package.json";
|
|
60
61
|
const INDEX_FILE = "_Index.json";
|
|
61
62
|
const ANIMATION_FILE_SUFFIX = ".animation.json";
|
|
62
|
-
|
|
63
|
+
function parseCreatorPackageName(manifest) {
|
|
63
64
|
const [domain, subdomain] = manifest.Package.split(".");
|
|
65
|
+
if (subdomain === undefined) {
|
|
66
|
+
throw new Error(`Expected "Package" field of the _Package.json file to contain a value in the form of Domain.SubDomain`);
|
|
67
|
+
}
|
|
64
68
|
return {
|
|
65
69
|
domain,
|
|
66
70
|
subdomain
|
|
67
71
|
};
|
|
68
|
-
}
|
|
72
|
+
}
|
|
69
73
|
const readPackageCreatorManifest = (location)=>{
|
|
70
74
|
const packageJsonPath = path.join(location.manifestDir, PACKAGE_FILE);
|
|
71
75
|
const packageJson = stripUtf8Bom(fs.readFileSync(packageJsonPath, {
|
|
@@ -301,7 +305,7 @@ const PLUGIN_ID = "0feba3a0-b6d1-11e6-9598-0800200c9a66";
|
|
|
301
305
|
*
|
|
302
306
|
* @param {SessionStartParams} params
|
|
303
307
|
* @returns
|
|
304
|
-
*/ const startSession = async ({ url
|
|
308
|
+
*/ const startSession = async ({ url, authentication, ...params })=>{
|
|
305
309
|
const payload = {
|
|
306
310
|
...params,
|
|
307
311
|
user: undefined,
|
|
@@ -315,7 +319,7 @@ const PLUGIN_ID = "0feba3a0-b6d1-11e6-9598-0800200c9a66";
|
|
|
315
319
|
} else if (authentication.type === "license") {
|
|
316
320
|
payload.license = authentication.license;
|
|
317
321
|
}
|
|
318
|
-
const { data: { session: sessionId
|
|
322
|
+
const { data: { session: sessionId, state, response } } = await axios.post(`Session/Start2`, JSON.stringify(payload), {
|
|
319
323
|
baseURL: url
|
|
320
324
|
});
|
|
321
325
|
if (state !== "SUCCESS") {
|
|
@@ -338,7 +342,7 @@ const closeSession = async (session)=>{
|
|
|
338
342
|
baseURL: session.url
|
|
339
343
|
});
|
|
340
344
|
};
|
|
341
|
-
const uploadPackageFromBuffer = async (session, { name
|
|
345
|
+
const uploadPackageFromBuffer = async (session, { name, version }, buffer)=>{
|
|
342
346
|
try {
|
|
343
347
|
await uploadPackageToUrl(session.url, `UploadPackage/${session.sessionId}/${name}_${version}`, buffer);
|
|
344
348
|
} catch (err) {
|
|
@@ -354,7 +358,7 @@ const uploadPackageFromBuffer = async (session, { name , version }, buffer)=>{
|
|
|
354
358
|
}
|
|
355
359
|
};
|
|
356
360
|
const uploadPackageToUrl = async (url, path, buffer)=>{
|
|
357
|
-
const { data
|
|
361
|
+
const { data, status } = await axios.post(path, buffer, {
|
|
358
362
|
baseURL: url
|
|
359
363
|
});
|
|
360
364
|
let objectBody;
|
|
@@ -389,7 +393,7 @@ const uploadPackageToUrl = async (url, path, buffer)=>{
|
|
|
389
393
|
return data;
|
|
390
394
|
};
|
|
391
395
|
const getExistingPackages = async (session)=>{
|
|
392
|
-
const { data
|
|
396
|
+
const { data } = await axios.get(`Script/GetInformation/${session.sessionId}`, {
|
|
393
397
|
baseURL: session.url,
|
|
394
398
|
validateStatus: (status)=>status === 404 || status === 200
|
|
395
399
|
}).catch((err)=>{
|
|
@@ -398,8 +402,37 @@ const getExistingPackages = async (session)=>{
|
|
|
398
402
|
return data;
|
|
399
403
|
};
|
|
400
404
|
|
|
405
|
+
function resolveScriptPackageEntryModule(location, manifest) {
|
|
406
|
+
let candidates = [
|
|
407
|
+
"index.ts"
|
|
408
|
+
];
|
|
409
|
+
if (manifest.Type === "Context") {
|
|
410
|
+
candidates.push("Context.ts");
|
|
411
|
+
}
|
|
412
|
+
for (const candidate of candidates){
|
|
413
|
+
const candidatePath = path.join(location.scriptsDir, candidate);
|
|
414
|
+
if (fs.existsSync(candidatePath)) {
|
|
415
|
+
return candidatePath;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
function readScriptPackageTSConfig(location) {
|
|
420
|
+
const { config } = ts.readConfigFile(path.join(location.scriptsDir, "tsconfig.json"), (path)=>{
|
|
421
|
+
try {
|
|
422
|
+
return fs.readFileSync(path, "utf8");
|
|
423
|
+
} catch {
|
|
424
|
+
return undefined;
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
const parsedTsConfig = ts.parseJsonConfigFileContent(config, ts.sys, location.scriptsDir);
|
|
428
|
+
return parsedTsConfig;
|
|
429
|
+
}
|
|
430
|
+
function isScriptPackageModules(options) {
|
|
431
|
+
return options.module === ts.ModuleKind.ES2015;
|
|
432
|
+
}
|
|
433
|
+
|
|
401
434
|
const tryReadTsConfig = (location)=>{
|
|
402
|
-
const { config
|
|
435
|
+
const { config } = ts.readConfigFile(path.join(location.scriptsDir, "tsconfig.json"), (path)=>{
|
|
403
436
|
try {
|
|
404
437
|
return fs.readFileSync(path, "utf8");
|
|
405
438
|
} catch {
|
|
@@ -410,19 +443,6 @@ const tryReadTsConfig = (location)=>{
|
|
|
410
443
|
};
|
|
411
444
|
const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
|
|
412
445
|
const files = getPackageTypescriptFiles(location);
|
|
413
|
-
if (files.length === 0) {
|
|
414
|
-
env.onBuildStart();
|
|
415
|
-
env.onBuildEnd({
|
|
416
|
-
type: "success",
|
|
417
|
-
artefacts: {
|
|
418
|
-
js: "",
|
|
419
|
-
definitions: ""
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
return {
|
|
423
|
-
destroy: ()=>{}
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
446
|
try {
|
|
427
447
|
env.onBuildStart();
|
|
428
448
|
env.log("Compiling typescript files");
|
|
@@ -460,7 +480,7 @@ const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
|
|
|
460
480
|
type: "success",
|
|
461
481
|
artefacts: {
|
|
462
482
|
js: js.replace(`//# sourceMappingURL=out.js.map`, ""),
|
|
463
|
-
definitions,
|
|
483
|
+
declarations: definitions,
|
|
464
484
|
sourceMap
|
|
465
485
|
}
|
|
466
486
|
});
|
|
@@ -479,7 +499,7 @@ const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
|
|
|
479
499
|
};
|
|
480
500
|
};
|
|
481
501
|
const createTSCWatchBuildParticipant = (location, outputDir)=>{
|
|
482
|
-
return ({ onBuildStart
|
|
502
|
+
return ({ onBuildStart, onBuildEnd })=>{
|
|
483
503
|
let state = {
|
|
484
504
|
diagnostics: [],
|
|
485
505
|
js: undefined,
|
|
@@ -553,7 +573,7 @@ const createTSCWatchBuildParticipant = (location, outputDir)=>{
|
|
|
553
573
|
type: "success",
|
|
554
574
|
artefacts: {
|
|
555
575
|
js: emitState.js.replace(`//# sourceMappingURL=out.js.map`, ""),
|
|
556
|
-
|
|
576
|
+
declarations: emitState.definitions,
|
|
557
577
|
sourceMap: emitState.sourceMap
|
|
558
578
|
}
|
|
559
579
|
});
|
|
@@ -567,17 +587,6 @@ const createTSCWatchBuildParticipant = (location, outputDir)=>{
|
|
|
567
587
|
getNewLine: ()=>ts.sys.newLine
|
|
568
588
|
};
|
|
569
589
|
const watchProgram = ts.createWatchProgram(host);
|
|
570
|
-
const files = getPackageTypescriptFiles(location);
|
|
571
|
-
if (files.length === 0) {
|
|
572
|
-
onBuildStart();
|
|
573
|
-
onBuildEnd({
|
|
574
|
-
type: "success",
|
|
575
|
-
artefacts: {
|
|
576
|
-
js: "",
|
|
577
|
-
definitions: ""
|
|
578
|
-
}
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
590
|
return {
|
|
582
591
|
destroy: ()=>{
|
|
583
592
|
watchProgram.close();
|
|
@@ -663,12 +672,7 @@ const toposort = (packages)=>{
|
|
|
663
672
|
|
|
664
673
|
class BuildManager extends EventEmitter {
|
|
665
674
|
constructor(manifest, writer, reporter){
|
|
666
|
-
super();
|
|
667
|
-
this.manifest = manifest;
|
|
668
|
-
this.writer = writer;
|
|
669
|
-
this.reporter = reporter;
|
|
670
|
-
this.participants = new Map();
|
|
671
|
-
this.states = new Map();
|
|
675
|
+
super(), this.manifest = manifest, this.writer = writer, this.reporter = reporter, this.participants = new Map(), this.states = new Map();
|
|
672
676
|
}
|
|
673
677
|
addParticipant(name, participant) {
|
|
674
678
|
this.participants.set(name, participant);
|
|
@@ -741,14 +745,16 @@ class BuildManager extends EventEmitter {
|
|
|
741
745
|
line: lines + mapping.generatedLine,
|
|
742
746
|
column: mapping.generatedColumn
|
|
743
747
|
},
|
|
744
|
-
original: {
|
|
748
|
+
original: mapping.originalLine !== null && mapping.originalColumn !== null ? {
|
|
745
749
|
line: mapping.originalLine,
|
|
746
750
|
column: mapping.originalColumn
|
|
747
|
-
},
|
|
751
|
+
} : undefined,
|
|
748
752
|
source: mapping.source,
|
|
749
753
|
name: mapping.name
|
|
750
754
|
});
|
|
751
|
-
|
|
755
|
+
if (mapping.source !== null) {
|
|
756
|
+
sources.add(mapping.source);
|
|
757
|
+
}
|
|
752
758
|
});
|
|
753
759
|
for (const source of sources){
|
|
754
760
|
const content = sourceMap.sourceContentFor(source);
|
|
@@ -759,13 +765,13 @@ class BuildManager extends EventEmitter {
|
|
|
759
765
|
}
|
|
760
766
|
completeResult.js += result.artefacts.js;
|
|
761
767
|
}
|
|
762
|
-
if (result.artefacts.
|
|
763
|
-
if (completeResult.
|
|
764
|
-
completeResult.
|
|
768
|
+
if (result.artefacts.declarations) {
|
|
769
|
+
if (completeResult.declarations) {
|
|
770
|
+
completeResult.declarations += "\n";
|
|
765
771
|
} else {
|
|
766
|
-
completeResult.
|
|
772
|
+
completeResult.declarations = "";
|
|
767
773
|
}
|
|
768
|
-
completeResult.
|
|
774
|
+
completeResult.declarations += result.artefacts.declarations;
|
|
769
775
|
}
|
|
770
776
|
}
|
|
771
777
|
completeResult.sourceMap = sourceMapGenerator.toString();
|
|
@@ -1122,8 +1128,7 @@ const createAnimationBuildParticipant = (location, manifest)=>{
|
|
|
1122
1128
|
};
|
|
1123
1129
|
};
|
|
1124
1130
|
};
|
|
1125
|
-
const createAnimationWatchBuildParticipant = (location, manifest)=>{
|
|
1126
|
-
return (env)=>{
|
|
1131
|
+
const createAnimationWatchBuildParticipant = (location, manifest)=>(env)=>{
|
|
1127
1132
|
env.onBuildStart();
|
|
1128
1133
|
bundleAnimations(location, manifest, env.log).then((result)=>{
|
|
1129
1134
|
env.onBuildEnd({
|
|
@@ -1164,7 +1169,6 @@ const createAnimationWatchBuildParticipant = (location, manifest)=>{
|
|
|
1164
1169
|
destroy: ()=>{}
|
|
1165
1170
|
};
|
|
1166
1171
|
};
|
|
1167
|
-
};
|
|
1168
1172
|
const bundleAnimations = async (location, manifest, logStep)=>{
|
|
1169
1173
|
const animations = new Map();
|
|
1170
1174
|
for (const scriptFilePath of readPackageAnimationList(location)){
|
|
@@ -1227,7 +1231,183 @@ const getAnimationJsonValidation = async ()=>{
|
|
|
1227
1231
|
return validateAnimationJson;
|
|
1228
1232
|
};
|
|
1229
1233
|
|
|
1230
|
-
|
|
1234
|
+
// Stolen from ig.tools.core
|
|
1235
|
+
class PackageVersion {
|
|
1236
|
+
static #_ = // https://regex101.com/r/90PEY9/1
|
|
1237
|
+
this.fullTextMatcher = /(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?/;
|
|
1238
|
+
static #_2 = this.lineMatcher = /^(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?$/;
|
|
1239
|
+
static extractFromText(input, description) {
|
|
1240
|
+
if (input === undefined) {
|
|
1241
|
+
throw new Error(`Can not parse version from undefined`);
|
|
1242
|
+
}
|
|
1243
|
+
const match = input.match(PackageVersion.fullTextMatcher);
|
|
1244
|
+
if (!match) {
|
|
1245
|
+
throw new Error(`Could not extract a version from input: ${input}`);
|
|
1246
|
+
}
|
|
1247
|
+
return PackageVersion.fromMatch(match, description);
|
|
1248
|
+
}
|
|
1249
|
+
static extractFromLine(input, description) {
|
|
1250
|
+
if (input === undefined) {
|
|
1251
|
+
throw new Error(`Can not parse version from undefined`);
|
|
1252
|
+
}
|
|
1253
|
+
const match = input.match(PackageVersion.lineMatcher);
|
|
1254
|
+
if (!match) {
|
|
1255
|
+
throw new Error(`Could not parse version from input: ${input}`);
|
|
1256
|
+
}
|
|
1257
|
+
return PackageVersion.fromMatch(match, description);
|
|
1258
|
+
}
|
|
1259
|
+
static equals(a, b, checkPrerelease = false) {
|
|
1260
|
+
if (a.major !== b.major || a.minor !== b.minor || a.patch !== b.patch) {
|
|
1261
|
+
return false;
|
|
1262
|
+
}
|
|
1263
|
+
if (checkPrerelease === false) {
|
|
1264
|
+
return true;
|
|
1265
|
+
}
|
|
1266
|
+
if (a.preRelease === b.preRelease) {
|
|
1267
|
+
return true;
|
|
1268
|
+
}
|
|
1269
|
+
if (a.preRelease === undefined || b.preRelease === undefined) {
|
|
1270
|
+
return false;
|
|
1271
|
+
}
|
|
1272
|
+
return a.preRelease.type === b.preRelease.type && a.preRelease.version === b.preRelease.version;
|
|
1273
|
+
}
|
|
1274
|
+
static fromMatch([, major, , minor = "0", , patch = "0", , build, , preReleaseType, preReleaseNumber], description) {
|
|
1275
|
+
let preRelease = undefined;
|
|
1276
|
+
let buildNumber = 100;
|
|
1277
|
+
if (preReleaseType && preReleaseNumber) {
|
|
1278
|
+
preRelease = {
|
|
1279
|
+
type: preReleaseType,
|
|
1280
|
+
version: parseInt(preReleaseNumber)
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
if (build) {
|
|
1284
|
+
buildNumber = Number(build);
|
|
1285
|
+
} else if (description) {
|
|
1286
|
+
const descriptionMatch = description.match(/(\d+)\)$/);
|
|
1287
|
+
if (descriptionMatch) {
|
|
1288
|
+
buildNumber = parseInt(descriptionMatch[1]);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
return new PackageVersion(parseInt(major), parseInt(minor), parseInt(patch), preRelease, buildNumber);
|
|
1292
|
+
}
|
|
1293
|
+
static sort(a, b, ascending = true) {
|
|
1294
|
+
const createSortResult = (a, b)=>ascending ? a - b : b - a;
|
|
1295
|
+
if (a.major !== b.major) {
|
|
1296
|
+
return createSortResult(a.major, b.major);
|
|
1297
|
+
}
|
|
1298
|
+
if (a.minor !== b.minor) {
|
|
1299
|
+
return createSortResult(a.minor, b.minor);
|
|
1300
|
+
}
|
|
1301
|
+
if (a.patch !== b.patch) {
|
|
1302
|
+
return createSortResult(a.patch, b.patch);
|
|
1303
|
+
}
|
|
1304
|
+
return createSortResult(a.preRelease ? a.preRelease.version : 0, b.preRelease ? b.preRelease.version : 0);
|
|
1305
|
+
}
|
|
1306
|
+
static toNumber(version) {
|
|
1307
|
+
return ((version.major * 1000 + version.minor) * 1000 + version.patch) * 1000 + version.buildNumber;
|
|
1308
|
+
}
|
|
1309
|
+
constructor(major, minor, patch, preRelease, buildNumber){
|
|
1310
|
+
this.major = major;
|
|
1311
|
+
this.minor = minor;
|
|
1312
|
+
this.patch = patch;
|
|
1313
|
+
this.preRelease = preRelease;
|
|
1314
|
+
this.buildNumber = buildNumber;
|
|
1315
|
+
}
|
|
1316
|
+
isPreRelease() {
|
|
1317
|
+
return this.preRelease !== undefined;
|
|
1318
|
+
}
|
|
1319
|
+
clone() {
|
|
1320
|
+
return new PackageVersion(this.major, this.minor, this.patch, this.preRelease ? {
|
|
1321
|
+
...this.preRelease
|
|
1322
|
+
} : undefined, this.buildNumber);
|
|
1323
|
+
}
|
|
1324
|
+
incrementMajor() {
|
|
1325
|
+
this.preRelease = undefined;
|
|
1326
|
+
this.patch = 0;
|
|
1327
|
+
this.minor = 0;
|
|
1328
|
+
this.major++;
|
|
1329
|
+
}
|
|
1330
|
+
incrementMinor() {
|
|
1331
|
+
this.preRelease = undefined;
|
|
1332
|
+
this.patch = 0;
|
|
1333
|
+
this.minor++;
|
|
1334
|
+
}
|
|
1335
|
+
incrementPatch() {
|
|
1336
|
+
this.preRelease = undefined;
|
|
1337
|
+
this.patch++;
|
|
1338
|
+
}
|
|
1339
|
+
createPreRelease(type) {
|
|
1340
|
+
if (!this.preRelease) {
|
|
1341
|
+
this.buildNumber = 1;
|
|
1342
|
+
} else {
|
|
1343
|
+
this.buildNumber++;
|
|
1344
|
+
}
|
|
1345
|
+
if (this.preRelease && type === this.preRelease.type) {
|
|
1346
|
+
this.preRelease.version++;
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
this.preRelease = {
|
|
1350
|
+
version: 0,
|
|
1351
|
+
type
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
createRelease() {
|
|
1355
|
+
this.preRelease = undefined;
|
|
1356
|
+
this.buildNumber = 100;
|
|
1357
|
+
}
|
|
1358
|
+
toVersionString({ buildNumber } = {}) {
|
|
1359
|
+
let version = [
|
|
1360
|
+
this.major,
|
|
1361
|
+
this.minor,
|
|
1362
|
+
this.patch
|
|
1363
|
+
].join(".");
|
|
1364
|
+
if (buildNumber) {
|
|
1365
|
+
version += "." + this.buildNumber;
|
|
1366
|
+
}
|
|
1367
|
+
if (this.preRelease) {
|
|
1368
|
+
version += `-${this.preRelease.type}.${this.preRelease.version}`;
|
|
1369
|
+
}
|
|
1370
|
+
return version;
|
|
1371
|
+
}
|
|
1372
|
+
toDescriptionString(packageName) {
|
|
1373
|
+
const base = [
|
|
1374
|
+
this.major,
|
|
1375
|
+
this.minor,
|
|
1376
|
+
this.patch
|
|
1377
|
+
].join(".");
|
|
1378
|
+
const parts = [
|
|
1379
|
+
packageName,
|
|
1380
|
+
base
|
|
1381
|
+
];
|
|
1382
|
+
if (this.preRelease) {
|
|
1383
|
+
parts.push(upperCaseFirst(this.preRelease.type));
|
|
1384
|
+
parts.push(this.preRelease.version);
|
|
1385
|
+
}
|
|
1386
|
+
parts.push(`(${base}.${this.buildNumber})`);
|
|
1387
|
+
return parts.join(" ");
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Determines wether the version is lesser than the input version
|
|
1391
|
+
*
|
|
1392
|
+
* @param {PackageVersion} version
|
|
1393
|
+
* @returns
|
|
1394
|
+
*/ isLesserThan(version) {
|
|
1395
|
+
return PackageVersion.toNumber(this) < PackageVersion.toNumber(version);
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Determines wether the version is greater than the input version
|
|
1399
|
+
*
|
|
1400
|
+
* @param {PackageVersion} version
|
|
1401
|
+
* @returns
|
|
1402
|
+
*/ isGreaterThan(version) {
|
|
1403
|
+
return PackageVersion.toNumber(this) > PackageVersion.toNumber(version);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
const upperCaseFirst = (input)=>{
|
|
1407
|
+
return input.slice(0, 1).toUpperCase() + input.slice(1);
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1410
|
+
async function buildFolders(options) {
|
|
1231
1411
|
if (options.outDir !== undefined && options.clean) {
|
|
1232
1412
|
await fs$1.rm(options.outDir, {
|
|
1233
1413
|
recursive: true
|
|
@@ -1244,7 +1424,7 @@ const buildFolders = async (options)=>{
|
|
|
1244
1424
|
]));
|
|
1245
1425
|
const maxNameLength = Array.from(manifests.values(), (manifest)=>manifest.Package.length).reduce((acc, length)=>Math.max(acc, length), 0);
|
|
1246
1426
|
for (const location of sortedPackages){
|
|
1247
|
-
await ensureTsConfig(location);
|
|
1427
|
+
const tsConfig = await ensureTsConfig(location);
|
|
1248
1428
|
const data = manifests.get(location);
|
|
1249
1429
|
const reporter = options.preparedReporter ?? createPackageScopedReporter(baseReporter, data.Package, index, folders.length, maxNameLength);
|
|
1250
1430
|
const outputDirectory = options.outDir || location.scriptsDir;
|
|
@@ -1255,7 +1435,18 @@ const buildFolders = async (options)=>{
|
|
|
1255
1435
|
if (options.banner) {
|
|
1256
1436
|
manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
|
|
1257
1437
|
}
|
|
1258
|
-
|
|
1438
|
+
const typescriptFiles = getPackageTypescriptFiles(location);
|
|
1439
|
+
if (!typescriptFiles.some((file)=>path.basename(file).toLowerCase() === "version.ts")) {
|
|
1440
|
+
manager.addParticipant("version", createVersionLogBuildParticipant(data));
|
|
1441
|
+
}
|
|
1442
|
+
if (typescriptFiles.length > 0) {
|
|
1443
|
+
if (isScriptPackageModules(tsConfig.options)) {
|
|
1444
|
+
const { createRollupBuildParticipant } = await import('./rollup-BITLKeAN.mjs');
|
|
1445
|
+
manager.addParticipant("rollup", createRollupBuildParticipant(location, data, outputDirectory));
|
|
1446
|
+
} else {
|
|
1447
|
+
manager.addParticipant("tsc", createTSCBuildParticipant(location, outputDirectory));
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1259
1450
|
manager.addParticipant("animation", createAnimationBuildParticipant(location, data));
|
|
1260
1451
|
await new Promise((resolve, reject)=>{
|
|
1261
1452
|
manager.addListener("start", ()=>{
|
|
@@ -1276,8 +1467,8 @@ const buildFolders = async (options)=>{
|
|
|
1276
1467
|
}
|
|
1277
1468
|
index++;
|
|
1278
1469
|
}
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1470
|
+
}
|
|
1471
|
+
async function buildFoldersWatch(options) {
|
|
1281
1472
|
if (options.outDir !== undefined && options.clean) {
|
|
1282
1473
|
await fs$1.rm(options.outDir, {
|
|
1283
1474
|
recursive: true
|
|
@@ -1293,7 +1484,7 @@ const buildFoldersWatch = async (options)=>{
|
|
|
1293
1484
|
]));
|
|
1294
1485
|
const maxNameLength = Array.from(manifests.values(), (manifest)=>manifest.Package.length).reduce((acc, length)=>Math.max(acc, length), 0);
|
|
1295
1486
|
for (const location of sortedPackages){
|
|
1296
|
-
await ensureTsConfig(location);
|
|
1487
|
+
const tsConfig = await ensureTsConfig(location);
|
|
1297
1488
|
const baseReporter = options.reporter ?? consoleReporter;
|
|
1298
1489
|
const data = manifests.get(location);
|
|
1299
1490
|
const reporter = createPackageScopedReporter(baseReporter, data.Package, index, folders.length, maxNameLength);
|
|
@@ -1305,7 +1496,18 @@ const buildFoldersWatch = async (options)=>{
|
|
|
1305
1496
|
if (options.banner) {
|
|
1306
1497
|
manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
|
|
1307
1498
|
}
|
|
1308
|
-
|
|
1499
|
+
const typescriptFiles = getPackageTypescriptFiles(location);
|
|
1500
|
+
if (!typescriptFiles.some((file)=>path.basename(file).toLowerCase() === "version.ts")) {
|
|
1501
|
+
manager.addParticipant("version", createVersionLogBuildParticipant(data));
|
|
1502
|
+
}
|
|
1503
|
+
if (typescriptFiles.length > 0) {
|
|
1504
|
+
if (isScriptPackageModules(tsConfig.options)) {
|
|
1505
|
+
const { createRollupWatchBuildParticipant } = await import('./rollup-BITLKeAN.mjs');
|
|
1506
|
+
manager.addParticipant("rollup", createRollupWatchBuildParticipant(location, data, outputDirectory));
|
|
1507
|
+
} else {
|
|
1508
|
+
manager.addParticipant("tsc", createTSCWatchBuildParticipant(location, outputDirectory));
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1309
1511
|
manager.addParticipant("animation", createAnimationWatchBuildParticipant(location, data));
|
|
1310
1512
|
await new Promise((resolve, reject)=>{
|
|
1311
1513
|
manager.addListener("start", ()=>{
|
|
@@ -1324,8 +1526,8 @@ const buildFoldersWatch = async (options)=>{
|
|
|
1324
1526
|
index++;
|
|
1325
1527
|
}
|
|
1326
1528
|
await new Promise(()=>{});
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1529
|
+
}
|
|
1530
|
+
async function writeBuildResult(buildResult, manifest, location, workspace, outputDirectory, minimize, reporter) {
|
|
1329
1531
|
let js = buildResult.js;
|
|
1330
1532
|
if (buildResult.sourceMap) {
|
|
1331
1533
|
js += `\n//# sourceMappingURL=${manifest.Package}.js.map`;
|
|
@@ -1333,8 +1535,8 @@ const writeBuildResult = async (buildResult, manifest, location, workspace, outp
|
|
|
1333
1535
|
await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.js`), js, {
|
|
1334
1536
|
encoding: "utf8"
|
|
1335
1537
|
});
|
|
1336
|
-
if (buildResult.
|
|
1337
|
-
await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.d.ts`), buildResult.
|
|
1538
|
+
if (buildResult.declarations !== undefined) {
|
|
1539
|
+
await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.d.ts`), buildResult.declarations, {
|
|
1338
1540
|
encoding: "utf8"
|
|
1339
1541
|
});
|
|
1340
1542
|
}
|
|
@@ -1362,54 +1564,95 @@ const writeBuildResult = async (buildResult, manifest, location, workspace, outp
|
|
|
1362
1564
|
});
|
|
1363
1565
|
}
|
|
1364
1566
|
}
|
|
1365
|
-
if (location.path.includes("Basics") && buildResult.
|
|
1567
|
+
if (location.path.includes("Basics") && buildResult.declarations !== undefined) {
|
|
1366
1568
|
await fs$1.mkdir(path.join(workspace.path, "lib"), {
|
|
1367
1569
|
recursive: true
|
|
1368
1570
|
});
|
|
1369
1571
|
reporter.log("Copying basics definition file to the lib folder");
|
|
1370
|
-
await fs$1.writeFile(path.join(workspace.path, "lib", `${manifest.Package}.d.ts`), buildResult.
|
|
1572
|
+
await fs$1.writeFile(path.join(workspace.path, "lib", `${manifest.Package}.d.ts`), buildResult.declarations, {
|
|
1371
1573
|
encoding: "utf8"
|
|
1372
1574
|
});
|
|
1373
1575
|
}
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1576
|
+
}
|
|
1577
|
+
function createVersionLogBuildParticipant(manifest) {
|
|
1578
|
+
return (env)=>{
|
|
1579
|
+
env.onBuildStart();
|
|
1580
|
+
const parsedVersion = manifest.Version !== undefined ? PackageVersion.extractFromLine(manifest.Version) : undefined;
|
|
1581
|
+
let logText;
|
|
1582
|
+
if (parsedVersion !== undefined) {
|
|
1583
|
+
logText = parsedVersion.toDescriptionString(manifest.Package);
|
|
1584
|
+
} else {
|
|
1585
|
+
logText = manifest.Package;
|
|
1586
|
+
}
|
|
1587
|
+
logText += ".";
|
|
1588
|
+
if (manifest.Copyright !== undefined) {
|
|
1589
|
+
logText += " " + manifest.Copyright;
|
|
1590
|
+
}
|
|
1591
|
+
env.onBuildEnd({
|
|
1592
|
+
type: "success",
|
|
1593
|
+
artefacts: {
|
|
1594
|
+
js: `console.log(${JSON.stringify(logText)})`
|
|
1595
|
+
}
|
|
1596
|
+
});
|
|
1597
|
+
return {
|
|
1598
|
+
destroy: ()=>{}
|
|
1599
|
+
};
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
function createBannerCommentBuildParticipant(options) {
|
|
1603
|
+
return (env)=>{
|
|
1376
1604
|
env.onBuildStart();
|
|
1377
1605
|
const banner = createBannerComment(options);
|
|
1378
1606
|
env.onBuildEnd({
|
|
1379
1607
|
type: "success",
|
|
1380
1608
|
artefacts: {
|
|
1381
1609
|
js: banner ?? "",
|
|
1382
|
-
|
|
1610
|
+
declarations: banner ?? ""
|
|
1383
1611
|
}
|
|
1384
1612
|
});
|
|
1385
1613
|
return {
|
|
1386
1614
|
destroy: ()=>{}
|
|
1387
1615
|
};
|
|
1388
1616
|
};
|
|
1389
|
-
|
|
1617
|
+
}
|
|
1618
|
+
async function ensureTsConfig(location) {
|
|
1390
1619
|
const tsconfigPath = path.join(location.scriptsDir, "tsconfig.json");
|
|
1391
1620
|
try {
|
|
1392
1621
|
const content = JSON.parse(await fs$1.readFile(tsconfigPath, "utf8"));
|
|
1393
|
-
|
|
1622
|
+
applyTsConfigOptions(content);
|
|
1394
1623
|
await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
|
|
1624
|
+
return ts.parseJsonConfigFileContent(content, ts.sys, location.scriptsDir);
|
|
1395
1625
|
} catch (err) {
|
|
1396
1626
|
if (!isErrorENOENT(err)) {
|
|
1397
1627
|
throw err;
|
|
1398
1628
|
}
|
|
1399
1629
|
const content = {};
|
|
1400
|
-
|
|
1630
|
+
applyTsConfigOptions(content);
|
|
1401
1631
|
await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
|
|
1632
|
+
return ts.parseJsonConfigFileContent(content, ts.sys, location.scriptsDir);
|
|
1402
1633
|
}
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
data.compilerOptions
|
|
1407
|
-
|
|
1408
|
-
"
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1634
|
+
}
|
|
1635
|
+
function applyTsConfigOptions(data) {
|
|
1636
|
+
var _data_compilerOptions_module, _data_compilerOptions;
|
|
1637
|
+
if ((_data_compilerOptions = data.compilerOptions) == null ? void 0 : (_data_compilerOptions_module = _data_compilerOptions.module) == null ? void 0 : _data_compilerOptions_module.toLowerCase().startsWith("es")) {
|
|
1638
|
+
data.compilerOptions = data.compilerOptions ?? {};
|
|
1639
|
+
data.compilerOptions.target = "esnext";
|
|
1640
|
+
data.compilerOptions.lib = [
|
|
1641
|
+
"esnext",
|
|
1642
|
+
"dom"
|
|
1643
|
+
];
|
|
1644
|
+
data.compilerOptions.module = "es2015";
|
|
1645
|
+
data.compilerOptions.moduleResolution = "node";
|
|
1646
|
+
} else {
|
|
1647
|
+
data.compilerOptions = data.compilerOptions ?? {};
|
|
1648
|
+
data.compilerOptions.target = "es5";
|
|
1649
|
+
data.compilerOptions.lib = [
|
|
1650
|
+
"es5",
|
|
1651
|
+
"dom"
|
|
1652
|
+
];
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
function sortPackagesByBuildOrder(folders) {
|
|
1413
1656
|
const packages = Array.from(folders).reduce((acc, location)=>{
|
|
1414
1657
|
const data = readPackageNpmManifest(location);
|
|
1415
1658
|
if (data !== undefined) {
|
|
@@ -1449,8 +1692,8 @@ const sortPackagesByBuildOrder = (folders)=>{
|
|
|
1449
1692
|
}
|
|
1450
1693
|
}
|
|
1451
1694
|
return result;
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1695
|
+
}
|
|
1696
|
+
function createBannerComment(banner) {
|
|
1454
1697
|
const bannerParts = [];
|
|
1455
1698
|
if (banner.text) {
|
|
1456
1699
|
bannerParts.push(" * " + banner.text);
|
|
@@ -1484,7 +1727,7 @@ ${bannerText}
|
|
|
1484
1727
|
*/`;
|
|
1485
1728
|
}
|
|
1486
1729
|
return undefined;
|
|
1487
|
-
}
|
|
1730
|
+
}
|
|
1488
1731
|
|
|
1489
1732
|
const getVersionInformationFromGit = async (workspaceLocation, packageLocation)=>{
|
|
1490
1733
|
try {
|
|
@@ -1535,186 +1778,6 @@ const getWorkspaceBannerText = (manifest)=>{
|
|
|
1535
1778
|
return bannerText;
|
|
1536
1779
|
};
|
|
1537
1780
|
|
|
1538
|
-
// Stolen from ig.tools.core
|
|
1539
|
-
class PackageVersion {
|
|
1540
|
-
static #_ = (()=>{
|
|
1541
|
-
// https://regex101.com/r/90PEY9/1
|
|
1542
|
-
this.fullTextMatcher = /(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?/;
|
|
1543
|
-
})();
|
|
1544
|
-
static #_1 = (()=>{
|
|
1545
|
-
this.lineMatcher = /^(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?$/;
|
|
1546
|
-
})();
|
|
1547
|
-
static extractFromText(input, description) {
|
|
1548
|
-
if (input === undefined) {
|
|
1549
|
-
throw new Error(`Can not parse version from undefined`);
|
|
1550
|
-
}
|
|
1551
|
-
const match = input.match(PackageVersion.fullTextMatcher);
|
|
1552
|
-
if (!match) {
|
|
1553
|
-
throw new Error(`Could not extract a version from input: ${input}`);
|
|
1554
|
-
}
|
|
1555
|
-
return PackageVersion.fromMatch(match, description);
|
|
1556
|
-
}
|
|
1557
|
-
static extractFromLine(input, description) {
|
|
1558
|
-
if (input === undefined) {
|
|
1559
|
-
throw new Error(`Can not parse version from undefined`);
|
|
1560
|
-
}
|
|
1561
|
-
const match = input.match(PackageVersion.lineMatcher);
|
|
1562
|
-
if (!match) {
|
|
1563
|
-
throw new Error(`Could not parse version from input: ${input}`);
|
|
1564
|
-
}
|
|
1565
|
-
return PackageVersion.fromMatch(match, description);
|
|
1566
|
-
}
|
|
1567
|
-
static equals(a, b, checkPrerelease = false) {
|
|
1568
|
-
if (a.major !== b.major || a.minor !== b.minor || a.patch !== b.patch) {
|
|
1569
|
-
return false;
|
|
1570
|
-
}
|
|
1571
|
-
if (checkPrerelease === false) {
|
|
1572
|
-
return true;
|
|
1573
|
-
}
|
|
1574
|
-
if (a.preRelease === b.preRelease) {
|
|
1575
|
-
return true;
|
|
1576
|
-
}
|
|
1577
|
-
if (a.preRelease === undefined || b.preRelease === undefined) {
|
|
1578
|
-
return false;
|
|
1579
|
-
}
|
|
1580
|
-
return a.preRelease.type === b.preRelease.type && a.preRelease.version === b.preRelease.version;
|
|
1581
|
-
}
|
|
1582
|
-
static fromMatch([, major, , minor = "0", , patch = "0", , build, , preReleaseType, preReleaseNumber], description) {
|
|
1583
|
-
let preRelease = undefined;
|
|
1584
|
-
let buildNumber = 100;
|
|
1585
|
-
if (preReleaseType && preReleaseNumber) {
|
|
1586
|
-
preRelease = {
|
|
1587
|
-
type: preReleaseType,
|
|
1588
|
-
version: parseInt(preReleaseNumber)
|
|
1589
|
-
};
|
|
1590
|
-
}
|
|
1591
|
-
if (build) {
|
|
1592
|
-
buildNumber = Number(build);
|
|
1593
|
-
} else if (description) {
|
|
1594
|
-
const descriptionMatch = description.match(/(\d+)\)$/);
|
|
1595
|
-
if (descriptionMatch) {
|
|
1596
|
-
buildNumber = parseInt(descriptionMatch[1]);
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
return new PackageVersion(parseInt(major), parseInt(minor), parseInt(patch), preRelease, buildNumber);
|
|
1600
|
-
}
|
|
1601
|
-
static sort(a, b, ascending = true) {
|
|
1602
|
-
const createSortResult = (a, b)=>ascending ? a - b : b - a;
|
|
1603
|
-
if (a.major !== b.major) {
|
|
1604
|
-
return createSortResult(a.major, b.major);
|
|
1605
|
-
}
|
|
1606
|
-
if (a.minor !== b.minor) {
|
|
1607
|
-
return createSortResult(a.minor, b.minor);
|
|
1608
|
-
}
|
|
1609
|
-
if (a.patch !== b.patch) {
|
|
1610
|
-
return createSortResult(a.patch, b.patch);
|
|
1611
|
-
}
|
|
1612
|
-
return createSortResult(a.preRelease ? a.preRelease.version : 0, b.preRelease ? b.preRelease.version : 0);
|
|
1613
|
-
}
|
|
1614
|
-
static toNumber(version) {
|
|
1615
|
-
return ((version.major * 1000 + version.minor) * 1000 + version.patch) * 1000 + version.buildNumber;
|
|
1616
|
-
}
|
|
1617
|
-
constructor(major, minor, patch, preRelease, buildNumber){
|
|
1618
|
-
this.major = major;
|
|
1619
|
-
this.minor = minor;
|
|
1620
|
-
this.patch = patch;
|
|
1621
|
-
this.preRelease = preRelease;
|
|
1622
|
-
this.buildNumber = buildNumber;
|
|
1623
|
-
}
|
|
1624
|
-
isPreRelease() {
|
|
1625
|
-
return this.preRelease !== undefined;
|
|
1626
|
-
}
|
|
1627
|
-
clone() {
|
|
1628
|
-
return new PackageVersion(this.major, this.minor, this.patch, this.preRelease ? {
|
|
1629
|
-
...this.preRelease
|
|
1630
|
-
} : undefined, this.buildNumber);
|
|
1631
|
-
}
|
|
1632
|
-
incrementMajor() {
|
|
1633
|
-
this.preRelease = undefined;
|
|
1634
|
-
this.patch = 0;
|
|
1635
|
-
this.minor = 0;
|
|
1636
|
-
this.major++;
|
|
1637
|
-
}
|
|
1638
|
-
incrementMinor() {
|
|
1639
|
-
this.preRelease = undefined;
|
|
1640
|
-
this.patch = 0;
|
|
1641
|
-
this.minor++;
|
|
1642
|
-
}
|
|
1643
|
-
incrementPatch() {
|
|
1644
|
-
this.preRelease = undefined;
|
|
1645
|
-
this.patch++;
|
|
1646
|
-
}
|
|
1647
|
-
createPreRelease(type) {
|
|
1648
|
-
if (!this.preRelease) {
|
|
1649
|
-
this.buildNumber = 1;
|
|
1650
|
-
} else {
|
|
1651
|
-
this.buildNumber++;
|
|
1652
|
-
}
|
|
1653
|
-
if (this.preRelease && type === this.preRelease.type) {
|
|
1654
|
-
this.preRelease.version++;
|
|
1655
|
-
return;
|
|
1656
|
-
}
|
|
1657
|
-
this.preRelease = {
|
|
1658
|
-
version: 0,
|
|
1659
|
-
type
|
|
1660
|
-
};
|
|
1661
|
-
}
|
|
1662
|
-
createRelease() {
|
|
1663
|
-
this.preRelease = undefined;
|
|
1664
|
-
this.buildNumber = 100;
|
|
1665
|
-
}
|
|
1666
|
-
toVersionString({ buildNumber } = {}) {
|
|
1667
|
-
let version = [
|
|
1668
|
-
this.major,
|
|
1669
|
-
this.minor,
|
|
1670
|
-
this.patch
|
|
1671
|
-
].join(".");
|
|
1672
|
-
if (buildNumber) {
|
|
1673
|
-
version += "." + this.buildNumber;
|
|
1674
|
-
}
|
|
1675
|
-
if (this.preRelease) {
|
|
1676
|
-
version += `-${this.preRelease.type}.${this.preRelease.version}`;
|
|
1677
|
-
}
|
|
1678
|
-
return version;
|
|
1679
|
-
}
|
|
1680
|
-
toDescriptionString(packageName) {
|
|
1681
|
-
const base = [
|
|
1682
|
-
this.major,
|
|
1683
|
-
this.minor,
|
|
1684
|
-
this.patch
|
|
1685
|
-
].join(".");
|
|
1686
|
-
const parts = [
|
|
1687
|
-
packageName,
|
|
1688
|
-
base
|
|
1689
|
-
];
|
|
1690
|
-
if (this.preRelease) {
|
|
1691
|
-
parts.push(upperCaseFirst(this.preRelease.type));
|
|
1692
|
-
parts.push(this.preRelease.version);
|
|
1693
|
-
}
|
|
1694
|
-
parts.push(`(${base}.${this.buildNumber})`);
|
|
1695
|
-
return parts.join(" ");
|
|
1696
|
-
}
|
|
1697
|
-
/**
|
|
1698
|
-
* Determines wether the version is lesser than the input version
|
|
1699
|
-
*
|
|
1700
|
-
* @param {PackageVersion} version
|
|
1701
|
-
* @returns
|
|
1702
|
-
*/ isLesserThan(version) {
|
|
1703
|
-
return PackageVersion.toNumber(this) < PackageVersion.toNumber(version);
|
|
1704
|
-
}
|
|
1705
|
-
/**
|
|
1706
|
-
* Determines wether the version is greater than the input version
|
|
1707
|
-
*
|
|
1708
|
-
* @param {PackageVersion} version
|
|
1709
|
-
* @returns
|
|
1710
|
-
*/ isGreaterThan(version) {
|
|
1711
|
-
return PackageVersion.toNumber(this) > PackageVersion.toNumber(version);
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
const upperCaseFirst = (input)=>{
|
|
1715
|
-
return input.slice(0, 1).toUpperCase() + input.slice(1);
|
|
1716
|
-
};
|
|
1717
|
-
|
|
1718
1781
|
const parseVersionFromString = (input)=>{
|
|
1719
1782
|
if (input === undefined) {
|
|
1720
1783
|
throw new Error(`Can not parse version from undefined`);
|
|
@@ -1766,10 +1829,11 @@ const parseVersionFromNumericVersion = (version)=>{
|
|
|
1766
1829
|
// https://regex101.com/r/LtGAu5/1
|
|
1767
1830
|
const logRegex = /console\.log\(\s*"([\w\s\.\(\)]+)\ *Copyright[\w\s\(\)\.]+(\d{4}|\d{4} - \d{4})([\w\s\(\)\.]+)?",?\s*\)/i;
|
|
1768
1831
|
const currentYear = new Date(Date.now()).getFullYear();
|
|
1769
|
-
|
|
1832
|
+
function getVersionFileHandler(location) {
|
|
1770
1833
|
const filePath = path.join(location.scriptsDir, "Version.ts");
|
|
1771
|
-
|
|
1772
|
-
|
|
1834
|
+
function invalidVersionFile(versionFile, exists) {
|
|
1835
|
+
return {
|
|
1836
|
+
exists,
|
|
1773
1837
|
write: (name, newVersion)=>{
|
|
1774
1838
|
const scriptsContent = fs.readdirSync(location.scriptsDir);
|
|
1775
1839
|
const tsFiles = scriptsContent.filter((file)=>file.endsWith(".ts"));
|
|
@@ -1794,10 +1858,12 @@ const getVersionFileHandler = (location)=>{
|
|
|
1794
1858
|
}
|
|
1795
1859
|
}
|
|
1796
1860
|
}
|
|
1797
|
-
}
|
|
1798
|
-
|
|
1861
|
+
};
|
|
1862
|
+
}
|
|
1863
|
+
function createVersionFileWriter(copyright = [
|
|
1799
1864
|
currentYear
|
|
1800
|
-
], copyrightStuff = "")
|
|
1865
|
+
], copyrightStuff = "") {
|
|
1866
|
+
return (name, newVersion)=>{
|
|
1801
1867
|
const descriptionText = newVersion.toDescriptionString(name);
|
|
1802
1868
|
const copyrightText = createYearString(copyright);
|
|
1803
1869
|
const result = `console.log("${descriptionText}. Copyright (C) ${copyrightText}${copyrightStuff}");`;
|
|
@@ -1805,14 +1871,15 @@ const getVersionFileHandler = (location)=>{
|
|
|
1805
1871
|
encoding: "utf-8"
|
|
1806
1872
|
});
|
|
1807
1873
|
};
|
|
1874
|
+
}
|
|
1808
1875
|
let rawVersionFile = readStringFromFileOrUndefined(filePath);
|
|
1809
1876
|
if (rawVersionFile === undefined) {
|
|
1810
|
-
return invalidVersionFile(rawVersionFile);
|
|
1877
|
+
return invalidVersionFile(rawVersionFile, false);
|
|
1811
1878
|
}
|
|
1812
1879
|
const versionFile = rawVersionFile.replace(/\n/g, "");
|
|
1813
1880
|
const match = versionFile.match(logRegex);
|
|
1814
1881
|
if (!match) {
|
|
1815
|
-
return invalidVersionFile(versionFile);
|
|
1882
|
+
return invalidVersionFile(versionFile, true);
|
|
1816
1883
|
}
|
|
1817
1884
|
const [_full, _description, copyright, copyrightStuff] = match;
|
|
1818
1885
|
const copyrightYears = copyright.match(/^(\d+)( ?- ?(\d+))?$/);
|
|
@@ -1828,6 +1895,7 @@ const getVersionFileHandler = (location)=>{
|
|
|
1828
1895
|
];
|
|
1829
1896
|
}
|
|
1830
1897
|
return {
|
|
1898
|
+
exists: true,
|
|
1831
1899
|
write: createVersionFileWriter(years, copyrightStuff),
|
|
1832
1900
|
reset: ()=>{
|
|
1833
1901
|
fs.writeFileSync(filePath, versionFile, {
|
|
@@ -1835,7 +1903,7 @@ const getVersionFileHandler = (location)=>{
|
|
|
1835
1903
|
});
|
|
1836
1904
|
}
|
|
1837
1905
|
};
|
|
1838
|
-
}
|
|
1906
|
+
}
|
|
1839
1907
|
const createYearString = (years)=>{
|
|
1840
1908
|
if (years[1] === undefined || years[0] === years[1]) {
|
|
1841
1909
|
return years[0].toString();
|
|
@@ -1856,7 +1924,7 @@ const buildArchiveFromPublishedPackage = (location, manifest, creatorPackage)=>{
|
|
|
1856
1924
|
if (fs.existsSync(source)) {
|
|
1857
1925
|
const images = fs.readdirSync(source);
|
|
1858
1926
|
for (const file of images){
|
|
1859
|
-
const { ext
|
|
1927
|
+
const { ext } = path.parse(file);
|
|
1860
1928
|
switch(ext){
|
|
1861
1929
|
case ".png":
|
|
1862
1930
|
case ".jpeg":
|
|
@@ -1881,7 +1949,7 @@ const notRuntimeScripts = [
|
|
|
1881
1949
|
"Evaluator"
|
|
1882
1950
|
];
|
|
1883
1951
|
const buildArchiveFromPackage = async (reporter, packageLocation, data, binDir, minified = true)=>{
|
|
1884
|
-
const { domain
|
|
1952
|
+
const { domain } = parseCreatorPackageName(data);
|
|
1885
1953
|
const scriptDirectories = [
|
|
1886
1954
|
packageLocation.path,
|
|
1887
1955
|
packageLocation.scriptsDir
|
|
@@ -1936,7 +2004,7 @@ const buildArchiveFromPackage = async (reporter, packageLocation, data, binDir,
|
|
|
1936
2004
|
for (const directory of scriptDirectories){
|
|
1937
2005
|
try {
|
|
1938
2006
|
for (const file of fs.readdirSync(directory)){
|
|
1939
|
-
const { ext
|
|
2007
|
+
const { ext } = path.parse(file);
|
|
1940
2008
|
switch(ext){
|
|
1941
2009
|
case ".png":
|
|
1942
2010
|
case ".jpeg":
|
|
@@ -2113,11 +2181,11 @@ const execAsync = promisify(exec);
|
|
|
2113
2181
|
const releaseFolder = async (options)=>{
|
|
2114
2182
|
const workspace = options.workspace;
|
|
2115
2183
|
const location = options.directory;
|
|
2116
|
-
const
|
|
2184
|
+
const versionFile = getVersionFileHandler(location);
|
|
2117
2185
|
const packageDescription = readPackageCreatorManifest(location);
|
|
2118
2186
|
const fullPackageName = packageDescription.Package;
|
|
2119
2187
|
const reporter = options.reporter ?? createPackageScopedReporter(consoleReporter, packageDescription.Package);
|
|
2120
|
-
const { domain
|
|
2188
|
+
const { domain, subdomain } = parseCreatorPackageName(packageDescription);
|
|
2121
2189
|
const publishDomain = options.domain ?? domain;
|
|
2122
2190
|
const publishSubdomain = options.subdomain ?? subdomain;
|
|
2123
2191
|
const sharedPackageJson = readWorkspaceNpmManifest(workspace);
|
|
@@ -2142,13 +2210,15 @@ const releaseFolder = async (options)=>{
|
|
|
2142
2210
|
version: newVersion.buildNumber - 100
|
|
2143
2211
|
};
|
|
2144
2212
|
}
|
|
2145
|
-
if (sharedPackageJson !== undefined) {
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2213
|
+
// if (sharedPackageJson !== undefined) {
|
|
2214
|
+
// reporter.log(
|
|
2215
|
+
// `Running npm install to make sure all dependencies are up to date`,
|
|
2216
|
+
// );
|
|
2217
|
+
// await execAsync(`npm install`, {
|
|
2218
|
+
// encoding: "utf-8",
|
|
2219
|
+
// cwd: workspace.path,
|
|
2220
|
+
// });
|
|
2221
|
+
// }
|
|
2152
2222
|
const binDir = options.outDir ?? getWorkspaceOutputPath(workspace);
|
|
2153
2223
|
await fs$1.mkdir(binDir, {
|
|
2154
2224
|
recursive: true
|
|
@@ -2184,7 +2254,9 @@ const releaseFolder = async (options)=>{
|
|
|
2184
2254
|
}
|
|
2185
2255
|
} else {
|
|
2186
2256
|
const gitVersionInformation = await getVersionInformationFromGit(workspace, location);
|
|
2187
|
-
|
|
2257
|
+
if (versionFile.exists) {
|
|
2258
|
+
versionFile.write(fullPackageName, newVersion);
|
|
2259
|
+
}
|
|
2188
2260
|
const bannerText = sharedPackageJson !== undefined ? getWorkspaceBannerText(sharedPackageJson) : undefined;
|
|
2189
2261
|
await buildFolders({
|
|
2190
2262
|
...options,
|
|
@@ -2271,7 +2343,7 @@ const releaseFolder = async (options)=>{
|
|
|
2271
2343
|
}
|
|
2272
2344
|
}
|
|
2273
2345
|
} catch (err) {
|
|
2274
|
-
|
|
2346
|
+
versionFile.reset();
|
|
2275
2347
|
throw err;
|
|
2276
2348
|
}
|
|
2277
2349
|
if (newVersion.buildNumber >= 100 && !options.pushOnly) {
|
|
@@ -2289,64 +2361,91 @@ const releaseFolder = async (options)=>{
|
|
|
2289
2361
|
* Extracts and returns script array for _Index.json from a src folder
|
|
2290
2362
|
*
|
|
2291
2363
|
* @param folderPath path to a src folder
|
|
2292
|
-
*/ function generateIndex({ location
|
|
2293
|
-
const files = getPackageTypescriptFiles(location);
|
|
2294
|
-
const filtered = files.filter((path)=>{
|
|
2295
|
-
return !ignore.some((suffix)=>path.endsWith(suffix));
|
|
2296
|
-
});
|
|
2364
|
+
*/ function generateIndex({ location, ignore = [], strictOptional = false }) {
|
|
2297
2365
|
const arr = [];
|
|
2298
2366
|
const existingIndex = readPackageCreatorIndex(location) ?? [];
|
|
2299
|
-
const
|
|
2300
|
-
|
|
2301
|
-
|
|
2367
|
+
const manifest = readPackageCreatorManifest(location);
|
|
2368
|
+
const compilerOptions = readScriptPackageTSConfig(location).options;
|
|
2369
|
+
const isModule = compilerOptions.module === ts.ModuleKind.ES2015 || compilerOptions.module === ts.ModuleKind.ESNext;
|
|
2370
|
+
const files = getPackageTypescriptFiles(location).filter((path)=>!ignore.some((suffix)=>path.endsWith(suffix)));
|
|
2371
|
+
let program;
|
|
2372
|
+
let namespaces;
|
|
2373
|
+
if (isModule) {
|
|
2374
|
+
const entryFilePath = resolveScriptPackageEntryModule(location, manifest);
|
|
2375
|
+
if (entryFilePath === undefined) {
|
|
2376
|
+
throw new Error(`Could not resolve entry module`);
|
|
2377
|
+
}
|
|
2378
|
+
const host = ts.createCompilerHost({}, true);
|
|
2379
|
+
program = ts.createProgram([
|
|
2380
|
+
entryFilePath
|
|
2381
|
+
], {
|
|
2382
|
+
allowJs: true,
|
|
2383
|
+
...compilerOptions
|
|
2384
|
+
}, host);
|
|
2385
|
+
const entryFile = program.getSourceFile(entryFilePath);
|
|
2386
|
+
if (entryFile === undefined) {
|
|
2387
|
+
throw new Error(`Failed to find entry module`);
|
|
2388
|
+
}
|
|
2389
|
+
namespaces = resolveNamespaces(entryFile, program, host, manifest.Scope ?? manifest.Package);
|
|
2390
|
+
} else {
|
|
2391
|
+
program = ts.createProgram(files, {
|
|
2392
|
+
allowJs: true
|
|
2393
|
+
});
|
|
2394
|
+
namespaces = [];
|
|
2395
|
+
}
|
|
2302
2396
|
const typeChecker = program.getTypeChecker();
|
|
2303
|
-
|
|
2397
|
+
files.forEach((file)=>{
|
|
2304
2398
|
// Create a Program to represent the project, then pull out the
|
|
2305
2399
|
// source file to parse its AST.
|
|
2306
2400
|
const sourceFile = program.getSourceFile(file);
|
|
2401
|
+
const namespace = namespaces.find((namespace)=>namespace.files.includes(sourceFile));
|
|
2307
2402
|
// Loop through the root AST nodes of the file
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2403
|
+
for (const scriptingClass of findScriptingClasses(sourceFile)){
|
|
2404
|
+
if (scriptingClass.node.name === undefined) {
|
|
2405
|
+
throw new Error(`Expected ${scriptingClass.type} class to have a name`);
|
|
2406
|
+
}
|
|
2407
|
+
let name;
|
|
2408
|
+
if (isModule && namespace !== undefined) {
|
|
2409
|
+
const moduleNamespace = resolveNamespaceFullName(namespace);
|
|
2410
|
+
name = `${moduleNamespace}.${scriptingClass.node.name.text}`;
|
|
2411
|
+
} else {
|
|
2412
|
+
name = typeChecker.getFullyQualifiedName(typeChecker.getSymbolAtLocation(scriptingClass.node.name));
|
|
2413
|
+
}
|
|
2414
|
+
if (name.length > 45) {
|
|
2415
|
+
throw new Error(`Package name length >45 '${name}'`);
|
|
2416
|
+
}
|
|
2417
|
+
const parameterDeclaration = getScriptingClassParameterdeclaration(scriptingClass);
|
|
2418
|
+
const parametersType = parameterDeclaration === undefined ? undefined : typeChecker.getTypeAtLocation(parameterDeclaration);
|
|
2419
|
+
if (parametersType === undefined) {
|
|
2420
|
+
console.log(`Failed to find parameters type declaration for ${scriptingClass.type} ${name}. Skipping parameter list generation`);
|
|
2421
|
+
}
|
|
2422
|
+
const existingIndexEntry = existingIndex.find((entry)=>entry.Name === name);
|
|
2423
|
+
const obj = {
|
|
2424
|
+
Name: name,
|
|
2425
|
+
Description: (existingIndexEntry == null ? void 0 : existingIndexEntry.Description) ?? name,
|
|
2426
|
+
Type: scriptingClass.type === "evaluator" ? "Evaluator" : "Interactor",
|
|
2427
|
+
Parameters: []
|
|
2428
|
+
};
|
|
2429
|
+
const rawDocTags = ts.getJSDocTags(scriptingClass.node);
|
|
2430
|
+
const dict = getTagDict(rawDocTags);
|
|
2431
|
+
if (dict.summary) {
|
|
2432
|
+
obj.Description = dict.summary;
|
|
2433
|
+
} else {
|
|
2434
|
+
const comment = typeChecker.getTypeAtLocation(scriptingClass.node).symbol.getDocumentationComment(typeChecker).map((comment)=>comment.text).join(" ");
|
|
2435
|
+
if (comment) {
|
|
2436
|
+
obj.Description = comment;
|
|
2338
2437
|
}
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
} else if (existingIndexEntry !== undefined) {
|
|
2345
|
-
obj.Parameters = existingIndexEntry.Parameters;
|
|
2438
|
+
}
|
|
2439
|
+
if (parametersType !== undefined) {
|
|
2440
|
+
obj.Parameters = parseParametersList(typeChecker.getPropertiesOfType(parametersType), strictOptional);
|
|
2441
|
+
if (obj.Parameters.length === 0 && parametersType.getStringIndexType() !== undefined) {
|
|
2442
|
+
obj.Parameters = (existingIndexEntry == null ? void 0 : existingIndexEntry.Parameters) ?? [];
|
|
2346
2443
|
}
|
|
2347
|
-
|
|
2444
|
+
} else if (existingIndexEntry !== undefined) {
|
|
2445
|
+
obj.Parameters = existingIndexEntry.Parameters;
|
|
2348
2446
|
}
|
|
2349
|
-
|
|
2447
|
+
arr.push(obj);
|
|
2448
|
+
}
|
|
2350
2449
|
});
|
|
2351
2450
|
arr.sort((a, b)=>a.Name.localeCompare(b.Name));
|
|
2352
2451
|
writePackageCreatorIndex(location, arr);
|
|
@@ -2509,28 +2608,18 @@ const isScriptingClassParameterDeclaration = (scriptingClass, memberNode, parame
|
|
|
2509
2608
|
*
|
|
2510
2609
|
* @param {ts.Node} node
|
|
2511
2610
|
* @return {*}
|
|
2512
|
-
*/
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
ts.forEachChild(body, (child)=>{
|
|
2523
|
-
if (!ts.isClassDeclaration(child)) {
|
|
2524
|
-
return;
|
|
2525
|
-
}
|
|
2526
|
-
const scriptingClass = detectScriptingClass(child);
|
|
2527
|
-
if (scriptingClass !== undefined) {
|
|
2528
|
-
classes.push(scriptingClass);
|
|
2529
|
-
}
|
|
2530
|
-
});
|
|
2611
|
+
*/ function* findScriptingClasses(node) {
|
|
2612
|
+
for (const child of node.getChildren()){
|
|
2613
|
+
if (!ts.isClassDeclaration(child)) {
|
|
2614
|
+
yield* findScriptingClasses(child);
|
|
2615
|
+
continue;
|
|
2616
|
+
}
|
|
2617
|
+
const scriptingClass = detectScriptingClass(child);
|
|
2618
|
+
if (scriptingClass !== undefined) {
|
|
2619
|
+
yield scriptingClass;
|
|
2620
|
+
}
|
|
2531
2621
|
}
|
|
2532
|
-
|
|
2533
|
-
};
|
|
2622
|
+
}
|
|
2534
2623
|
const detectScriptingClass = (node)=>{
|
|
2535
2624
|
var _node_heritageClauses, _node_heritageClauses1;
|
|
2536
2625
|
const isEvaluator = (_node_heritageClauses = node.heritageClauses) == null ? void 0 : _node_heritageClauses.some((clause)=>{
|
|
@@ -2559,5 +2648,5 @@ const detectScriptingClass = (node)=>{
|
|
|
2559
2648
|
}
|
|
2560
2649
|
};
|
|
2561
2650
|
|
|
2562
|
-
export { buildFolders, buildFoldersWatch, createAssetServiceSessionManager, generateIndex, releaseFolder, synchronizeDependencies };
|
|
2651
|
+
export { buildFolders, buildFoldersWatch, createAssetServiceSessionManager, generateIndex, isScriptPackageModules, readScriptPackageTSConfig, releaseFolder, resolveScriptPackageEntryModule, synchronizeDependencies };
|
|
2563
2652
|
//# sourceMappingURL=lib.mjs.map
|