@intelligentgraphics/ig.gfx.packager 3.0.22 → 3.0.23
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-f6586dd5.mjs → cli-t3HbtHpD.mjs} +73 -87
- package/build/cli-t3HbtHpD.mjs.map +1 -0
- package/build/{dependencies-e2aa1797.mjs → dependencies-DevWjwri.mjs} +2 -2
- package/build/{dependencies-e2aa1797.mjs.map → dependencies-DevWjwri.mjs.map} +1 -1
- package/build/{generateIndex-019c6946.mjs → generateIndex-BtHP1bP3.mjs} +3 -3
- package/build/{generateIndex-019c6946.mjs.map → generateIndex-BtHP1bP3.mjs.map} +1 -1
- package/build/{generateParameterType-ae69726a.mjs → generateParameterType-DyylDiF2.mjs} +3 -3
- package/build/{generateParameterType-ae69726a.mjs.map → generateParameterType-DyylDiF2.mjs.map} +1 -1
- package/build/{index-3d1291e7.mjs → index-C3Hd8xoM.mjs} +55 -40
- package/build/index-C3Hd8xoM.mjs.map +1 -0
- package/build/{index-39c79102.mjs → index-CNupsFSp.mjs} +179 -172
- package/build/index-CNupsFSp.mjs.map +1 -0
- package/build/{postinstall-3328545c.mjs → postinstall-D2hLZlaK.mjs} +3 -3
- package/build/{postinstall-3328545c.mjs.map → postinstall-D2hLZlaK.mjs.map} +1 -1
- package/build/{publishNpm-532e17a0.mjs → publishNpm-h9T6BVws.mjs} +9 -7
- package/build/publishNpm-h9T6BVws.mjs.map +1 -0
- package/build/{scripts-7ed8dff6.mjs → scripts-EvIjiH6G.mjs} +1 -1
- package/build/{scripts-7ed8dff6.mjs.map → scripts-EvIjiH6G.mjs.map} +1 -1
- package/build/{versionFile-644c7ff8.mjs → versionFile-7rrD5z3c.mjs} +3 -3
- package/build/{versionFile-644c7ff8.mjs.map → versionFile-7rrD5z3c.mjs.map} +1 -1
- package/lib/lib.mjs +226 -205
- package/package.json +9 -9
- package/readme.md +22 -0
- package/build/cli-f6586dd5.mjs.map +0 -1
- package/build/index-39c79102.mjs.map +0 -1
- package/build/index-3d1291e7.mjs.map +0 -1
- package/build/publishNpm-532e17a0.mjs.map +0 -1
package/lib/lib.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import typedoc from 'typedoc';
|
|
|
13
13
|
import EventEmitter from 'events';
|
|
14
14
|
import { SourceMapGenerator, SourceMapConsumer } from 'source-map-js';
|
|
15
15
|
import Ajv from 'ajv';
|
|
16
|
+
import { EOL } from 'os';
|
|
16
17
|
import { pipeline } from 'stream/promises';
|
|
17
18
|
import { exec } from 'child_process';
|
|
18
19
|
import { promisify } from 'util';
|
|
@@ -73,7 +74,7 @@ const readPackageCreatorManifest = (location)=>{
|
|
|
73
74
|
};
|
|
74
75
|
const writePackageCreatorManifest = (location, creatorPackage)=>{
|
|
75
76
|
const packageJsonPath = path.join(location.manifestDir, PACKAGE_FILE);
|
|
76
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(creatorPackage, null, "
|
|
77
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(creatorPackage, null, "\t") + "\n");
|
|
77
78
|
};
|
|
78
79
|
const getPackageCreatorIndexPath = (location)=>path.join(location.manifestDir, INDEX_FILE);
|
|
79
80
|
const readPackageCreatorIndex = (location)=>{
|
|
@@ -92,7 +93,7 @@ const readPackageCreatorIndex = (location)=>{
|
|
|
92
93
|
};
|
|
93
94
|
const writePackageCreatorIndex = (location, index)=>{
|
|
94
95
|
const indexPath = getPackageCreatorIndexPath(location);
|
|
95
|
-
fs.writeFileSync(indexPath, JSON.stringify(index, null, "
|
|
96
|
+
fs.writeFileSync(indexPath, JSON.stringify(index, null, "\t") + "\n");
|
|
96
97
|
};
|
|
97
98
|
const readPackageNpmManifest = (location)=>{
|
|
98
99
|
try {
|
|
@@ -265,11 +266,26 @@ const readStringFromFileOrUndefined = (filePath)=>{
|
|
|
265
266
|
}
|
|
266
267
|
};
|
|
267
268
|
|
|
268
|
-
const
|
|
269
|
+
const consoleReporter = {
|
|
270
|
+
log (message) {
|
|
271
|
+
console.log(message);
|
|
272
|
+
},
|
|
273
|
+
error (message, _error) {
|
|
274
|
+
console.error(message);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
const createPackageScopedReporter = (reporter, scope, index, total, maxNameLength = 15)=>{
|
|
269
278
|
const numLength = total === undefined ? undefined : total.toString().length;
|
|
270
279
|
const indexString = total === undefined || total < 2 ? "" : `${index.toString().padStart(numLength, "0")}/${total} `;
|
|
271
|
-
const identifierString = `${indexString}${
|
|
272
|
-
|
|
280
|
+
const identifierString = `${indexString}${scope.padEnd(maxNameLength)}`;
|
|
281
|
+
return {
|
|
282
|
+
log (message) {
|
|
283
|
+
reporter.log(`${identifierString} >> ${message}`);
|
|
284
|
+
},
|
|
285
|
+
error (message, error) {
|
|
286
|
+
reporter.error(`${identifierString} >> ${message}`, error);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
273
289
|
};
|
|
274
290
|
|
|
275
291
|
const getPackageTypescriptFiles = (location)=>glob.sync("**/*.ts", {
|
|
@@ -322,7 +338,7 @@ const closeSession = async (session)=>{
|
|
|
322
338
|
});
|
|
323
339
|
};
|
|
324
340
|
const uploadPackageFromStream = async (session, { name, version }, stream)=>{
|
|
325
|
-
await uploadPackageToUrl(session.url, `UploadPackage/${session.sessionId}/${name}_${version}
|
|
341
|
+
await uploadPackageToUrl(session.url, `UploadPackage/${session.sessionId}/${name}_${version}`, stream);
|
|
326
342
|
};
|
|
327
343
|
const uploadPackageToUrl = async (url, path, stream)=>{
|
|
328
344
|
const { data, status } = await axios.post(path, stream, {
|
|
@@ -422,7 +438,7 @@ const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
|
|
|
422
438
|
const allDiagnostics = ts.getPreEmitDiagnostics(program);
|
|
423
439
|
if (!emitResult.emitSkipped) {
|
|
424
440
|
if (allDiagnostics.length > 0) {
|
|
425
|
-
console.log(
|
|
441
|
+
console.log(ts.formatDiagnostics(allDiagnostics, host));
|
|
426
442
|
}
|
|
427
443
|
if (js === undefined || definitions === undefined) {
|
|
428
444
|
throw new Error(`Unexpected: no js or definitions were created`);
|
|
@@ -436,7 +452,7 @@ const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
|
|
|
436
452
|
}
|
|
437
453
|
});
|
|
438
454
|
} else {
|
|
439
|
-
const error =
|
|
455
|
+
const error = ts.formatDiagnostics(allDiagnostics, host);
|
|
440
456
|
throw new Error(error);
|
|
441
457
|
}
|
|
442
458
|
} catch (err) {
|
|
@@ -469,7 +485,7 @@ const createTSCWatchBuildParticipant = (location, outputDir)=>{
|
|
|
469
485
|
}
|
|
470
486
|
}
|
|
471
487
|
};
|
|
472
|
-
const
|
|
488
|
+
const registerDiagnostic = (diagnostic)=>{
|
|
473
489
|
switch(diagnostic.code){
|
|
474
490
|
// file not found - https://github.com/microsoft/TypeScript/blob/93e6b9da0c4cb164ca90a5a1b07415e81e97f2b1/src/compiler/diagnosticMessages.json#L4640
|
|
475
491
|
// probably deleted -> ignore
|
|
@@ -504,7 +520,7 @@ const createTSCWatchBuildParticipant = (location, outputDir)=>{
|
|
|
504
520
|
sourceMap: undefined
|
|
505
521
|
};
|
|
506
522
|
if (emitState.diagnostics.length > 0) {
|
|
507
|
-
const message = emitState.diagnostics
|
|
523
|
+
const message = ts.formatDiagnostics(emitState.diagnostics, formattingHost);
|
|
508
524
|
onBuildEnd({
|
|
509
525
|
type: "error",
|
|
510
526
|
error: message
|
|
@@ -531,7 +547,12 @@ const createTSCWatchBuildParticipant = (location, outputDir)=>{
|
|
|
531
547
|
break;
|
|
532
548
|
}
|
|
533
549
|
};
|
|
534
|
-
const host = ts.createWatchCompilerHost(path.join(location.scriptsDir, "tsconfig.json"), getCompilerOptions(location, outputDir), customSys, ts.createSemanticDiagnosticsBuilderProgram,
|
|
550
|
+
const host = ts.createWatchCompilerHost(path.join(location.scriptsDir, "tsconfig.json"), getCompilerOptions(location, outputDir), customSys, ts.createSemanticDiagnosticsBuilderProgram, registerDiagnostic, reportWatchStatusChanged);
|
|
551
|
+
const formattingHost = {
|
|
552
|
+
getCanonicalFileName: (path)=>path,
|
|
553
|
+
getCurrentDirectory: host.getCurrentDirectory,
|
|
554
|
+
getNewLine: ()=>ts.sys.newLine
|
|
555
|
+
};
|
|
535
556
|
const watchProgram = ts.createWatchProgram(host);
|
|
536
557
|
const files = getPackageTypescriptFiles(location);
|
|
537
558
|
if (files.length === 0) {
|
|
@@ -551,14 +572,6 @@ const createTSCWatchBuildParticipant = (location, outputDir)=>{
|
|
|
551
572
|
};
|
|
552
573
|
};
|
|
553
574
|
};
|
|
554
|
-
const createErrorMessage = (diagnostic)=>{
|
|
555
|
-
if (!diagnostic.file) {
|
|
556
|
-
return `${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`;
|
|
557
|
-
}
|
|
558
|
-
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
559
|
-
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
560
|
-
return `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`;
|
|
561
|
-
};
|
|
562
575
|
const getCompilerOptions = (location, outputDir)=>{
|
|
563
576
|
const config = tryReadTsConfig(location);
|
|
564
577
|
config.compilerOptions.lib = [
|
|
@@ -636,11 +649,11 @@ const toposort = (packages)=>{
|
|
|
636
649
|
};
|
|
637
650
|
|
|
638
651
|
class BuildManager extends EventEmitter {
|
|
639
|
-
constructor(manifest, writer,
|
|
652
|
+
constructor(manifest, writer, reporter){
|
|
640
653
|
super();
|
|
641
654
|
this.manifest = manifest;
|
|
642
655
|
this.writer = writer;
|
|
643
|
-
this.
|
|
656
|
+
this.reporter = reporter;
|
|
644
657
|
this.participants = new Map();
|
|
645
658
|
this.states = new Map();
|
|
646
659
|
}
|
|
@@ -675,7 +688,7 @@ class BuildManager extends EventEmitter {
|
|
|
675
688
|
this.states.set(name, result);
|
|
676
689
|
this.maybeEmit();
|
|
677
690
|
},
|
|
678
|
-
log: this.
|
|
691
|
+
log: (message)=>this.reporter.log(message)
|
|
679
692
|
});
|
|
680
693
|
}
|
|
681
694
|
}
|
|
@@ -1113,7 +1126,8 @@ const createAnimationWatchBuildParticipant = (location, manifest)=>(env)=>{
|
|
|
1113
1126
|
});
|
|
1114
1127
|
(async ()=>{
|
|
1115
1128
|
for await (const event of fs$1.watch(location.scriptsDir)){
|
|
1116
|
-
|
|
1129
|
+
var _event_filename;
|
|
1130
|
+
if ((_event_filename = event.filename) == null ? void 0 : _event_filename.endsWith(".animation.json")) {
|
|
1117
1131
|
env.onBuildStart();
|
|
1118
1132
|
try {
|
|
1119
1133
|
const result = await bundleAnimations(location, manifest, env.log);
|
|
@@ -1204,6 +1218,7 @@ const buildFolders = async (options)=>{
|
|
|
1204
1218
|
recursive: true
|
|
1205
1219
|
});
|
|
1206
1220
|
}
|
|
1221
|
+
const baseReporter = options.reporter ?? consoleReporter;
|
|
1207
1222
|
const workspace = options.workspace;
|
|
1208
1223
|
const folders = options.packages;
|
|
1209
1224
|
let sortedPackages = sortPackagesByBuildOrder(folders);
|
|
@@ -1216,12 +1231,12 @@ const buildFolders = async (options)=>{
|
|
|
1216
1231
|
for (const location of sortedPackages){
|
|
1217
1232
|
await ensureTsConfig(location);
|
|
1218
1233
|
const data = manifests.get(location);
|
|
1219
|
-
const
|
|
1234
|
+
const reporter = options.preparedReporter ?? createPackageScopedReporter(baseReporter, data.Package, index, folders.length, maxNameLength);
|
|
1220
1235
|
const outputDirectory = options.outDir || location.scriptsDir;
|
|
1221
1236
|
await fs$1.mkdir(outputDirectory, {
|
|
1222
1237
|
recursive: true
|
|
1223
1238
|
});
|
|
1224
|
-
const manager = new BuildManager(data, (result)=>writeBuildResult(result, data, location, workspace, outputDirectory, options.minimize,
|
|
1239
|
+
const manager = new BuildManager(data, (result)=>writeBuildResult(result, data, location, workspace, outputDirectory, options.minimize, reporter), reporter);
|
|
1225
1240
|
if (options.banner) {
|
|
1226
1241
|
manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
|
|
1227
1242
|
}
|
|
@@ -1229,19 +1244,19 @@ const buildFolders = async (options)=>{
|
|
|
1229
1244
|
manager.addParticipant("animation", createAnimationBuildParticipant(location, data));
|
|
1230
1245
|
await new Promise((resolve, reject)=>{
|
|
1231
1246
|
manager.addListener("start", ()=>{
|
|
1232
|
-
|
|
1247
|
+
reporter.log(`Build started`);
|
|
1233
1248
|
});
|
|
1234
1249
|
manager.addListener("error", (error)=>{
|
|
1235
1250
|
reject(new Error(error));
|
|
1236
1251
|
});
|
|
1237
1252
|
manager.addListener("build", ()=>{
|
|
1238
|
-
|
|
1253
|
+
reporter.log(`Build complete`);
|
|
1239
1254
|
resolve();
|
|
1240
1255
|
});
|
|
1241
1256
|
manager.run();
|
|
1242
1257
|
});
|
|
1243
1258
|
if (options.docs) {
|
|
1244
|
-
|
|
1259
|
+
reporter.log("Generating typedoc documentation");
|
|
1245
1260
|
await generateDocs(location, path.join(outputDirectory, `${data.Package}.d.ts`), path.join(workspace.path, "docs", data.Package), data.Package);
|
|
1246
1261
|
}
|
|
1247
1262
|
index++;
|
|
@@ -1264,14 +1279,14 @@ const buildFoldersWatch = async (options)=>{
|
|
|
1264
1279
|
const maxNameLength = Array.from(manifests.values(), (manifest)=>manifest.Package.length).reduce((acc, length)=>Math.max(acc, length), 0);
|
|
1265
1280
|
for (const location of sortedPackages){
|
|
1266
1281
|
await ensureTsConfig(location);
|
|
1282
|
+
const baseReporter = options.reporter ?? consoleReporter;
|
|
1267
1283
|
const data = manifests.get(location);
|
|
1268
|
-
const
|
|
1269
|
-
const logStep = (step)=>logPackageMessage(data.Package, step, currentIndex, folders.length, maxNameLength);
|
|
1284
|
+
const reporter = createPackageScopedReporter(baseReporter, data.Package, index, folders.length, maxNameLength);
|
|
1270
1285
|
const outputDirectory = options.outDir || location.scriptsDir;
|
|
1271
1286
|
await fs$1.mkdir(outputDirectory, {
|
|
1272
1287
|
recursive: true
|
|
1273
1288
|
});
|
|
1274
|
-
const manager = new BuildManager(data, (result)=>writeBuildResult(result, data, location, workspace, outputDirectory, options.minimize,
|
|
1289
|
+
const manager = new BuildManager(data, (result)=>writeBuildResult(result, data, location, workspace, outputDirectory, options.minimize, reporter), reporter);
|
|
1275
1290
|
if (options.banner) {
|
|
1276
1291
|
manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
|
|
1277
1292
|
}
|
|
@@ -1279,14 +1294,14 @@ const buildFoldersWatch = async (options)=>{
|
|
|
1279
1294
|
manager.addParticipant("animation", createAnimationWatchBuildParticipant(location, data));
|
|
1280
1295
|
await new Promise((resolve, reject)=>{
|
|
1281
1296
|
manager.addListener("start", ()=>{
|
|
1282
|
-
|
|
1297
|
+
reporter.log(`Build started`);
|
|
1283
1298
|
});
|
|
1284
1299
|
manager.addListener("error", (error)=>{
|
|
1285
|
-
|
|
1300
|
+
reporter.log(`Build failed: ${EOL}${error}`);
|
|
1286
1301
|
resolve();
|
|
1287
1302
|
});
|
|
1288
1303
|
manager.addListener("build", ()=>{
|
|
1289
|
-
|
|
1304
|
+
reporter.log(`Build complete`);
|
|
1290
1305
|
resolve();
|
|
1291
1306
|
});
|
|
1292
1307
|
manager.run();
|
|
@@ -1295,7 +1310,7 @@ const buildFoldersWatch = async (options)=>{
|
|
|
1295
1310
|
}
|
|
1296
1311
|
await new Promise(()=>{});
|
|
1297
1312
|
};
|
|
1298
|
-
const writeBuildResult = async (buildResult, manifest, location, workspace, outputDirectory, minimize,
|
|
1313
|
+
const writeBuildResult = async (buildResult, manifest, location, workspace, outputDirectory, minimize, reporter)=>{
|
|
1299
1314
|
let js = buildResult.js;
|
|
1300
1315
|
if (buildResult.sourceMap) {
|
|
1301
1316
|
js += `\n//# sourceMappingURL=${manifest.Package}.js.map`;
|
|
@@ -1314,7 +1329,7 @@ const writeBuildResult = async (buildResult, manifest, location, workspace, outp
|
|
|
1314
1329
|
});
|
|
1315
1330
|
}
|
|
1316
1331
|
if (minimize) {
|
|
1317
|
-
|
|
1332
|
+
reporter.log("Minifying the output");
|
|
1318
1333
|
const minifyResult = await terser.minify(js, {
|
|
1319
1334
|
ecma: 5,
|
|
1320
1335
|
sourceMap: {
|
|
@@ -1336,7 +1351,7 @@ const writeBuildResult = async (buildResult, manifest, location, workspace, outp
|
|
|
1336
1351
|
await fs$1.mkdir(path.join(workspace.path, "lib"), {
|
|
1337
1352
|
recursive: true
|
|
1338
1353
|
});
|
|
1339
|
-
|
|
1354
|
+
reporter.log("Copying basics definition file to the lib folder");
|
|
1340
1355
|
await fs$1.writeFile(path.join(workspace.path, "lib", `${manifest.Package}.d.ts`), buildResult.definitions, {
|
|
1341
1356
|
encoding: "utf8"
|
|
1342
1357
|
});
|
|
@@ -1361,14 +1376,14 @@ const ensureTsConfig = async (location)=>{
|
|
|
1361
1376
|
try {
|
|
1362
1377
|
const content = JSON.parse(await fs$1.readFile(tsconfigPath, "utf8"));
|
|
1363
1378
|
applyTsConfigOption(content);
|
|
1364
|
-
await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, "
|
|
1379
|
+
await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
|
|
1365
1380
|
} catch (err) {
|
|
1366
1381
|
if (!isErrorENOENT(err)) {
|
|
1367
1382
|
throw err;
|
|
1368
1383
|
}
|
|
1369
1384
|
const content = {};
|
|
1370
1385
|
applyTsConfigOption(content);
|
|
1371
|
-
await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, "
|
|
1386
|
+
await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
|
|
1372
1387
|
}
|
|
1373
1388
|
};
|
|
1374
1389
|
const applyTsConfigOption = (data)=>{
|
|
@@ -1846,27 +1861,26 @@ const notRuntimeScripts = [
|
|
|
1846
1861
|
"Context",
|
|
1847
1862
|
"Evaluator"
|
|
1848
1863
|
];
|
|
1849
|
-
const buildArchiveFromPackage = async (packageLocation, data, binDir, minified = true)=>{
|
|
1864
|
+
const buildArchiveFromPackage = async (reporter, packageLocation, data, binDir, minified = true)=>{
|
|
1850
1865
|
const { domain } = parseCreatorPackageName(data);
|
|
1851
|
-
const logStep = (step)=>logPackageMessage(data.Package, step);
|
|
1852
1866
|
const scriptDirectories = [
|
|
1853
1867
|
packageLocation.path,
|
|
1854
1868
|
packageLocation.scriptsDir
|
|
1855
1869
|
];
|
|
1856
1870
|
if (data.Package === "IG.GFX.Standard") {
|
|
1857
|
-
|
|
1871
|
+
reporter.log(`Including Images folder`);
|
|
1858
1872
|
scriptDirectories.push(path.join(packageLocation.path, "Images"));
|
|
1859
1873
|
}
|
|
1860
1874
|
const manifest = readPackageCreatorManifest(packageLocation);
|
|
1861
1875
|
if (manifest !== undefined) {
|
|
1862
1876
|
if (manifest.RunTime && notRuntimeScripts.includes(manifest.Type)) {
|
|
1863
|
-
|
|
1877
|
+
reporter.log("Setting script RunTime to false because of script type");
|
|
1864
1878
|
writePackageCreatorManifest(packageLocation, {
|
|
1865
1879
|
...manifest,
|
|
1866
1880
|
RunTime: false
|
|
1867
1881
|
});
|
|
1868
1882
|
} else if (!manifest.RunTime && runtimeScripts.includes(manifest.Type)) {
|
|
1869
|
-
|
|
1883
|
+
reporter.log("Setting script RunTime to true because of script type");
|
|
1870
1884
|
writePackageCreatorManifest(packageLocation, {
|
|
1871
1885
|
...manifest,
|
|
1872
1886
|
RunTime: true
|
|
@@ -1915,12 +1929,165 @@ const buildArchiveFromPackage = async (packageLocation, data, binDir, minified =
|
|
|
1915
1929
|
archive.file(file, fs.createReadStream(path.join(directory, file)));
|
|
1916
1930
|
}
|
|
1917
1931
|
} catch (err) {
|
|
1918
|
-
|
|
1932
|
+
reporter.error(`Script directory "${directory}" does not exist`);
|
|
1919
1933
|
}
|
|
1920
1934
|
}
|
|
1921
1935
|
return archive;
|
|
1922
1936
|
};
|
|
1923
1937
|
|
|
1938
|
+
const createAssetServiceSessionManager = async (params)=>{
|
|
1939
|
+
const targetSession = await startSession(params);
|
|
1940
|
+
let basicsSession;
|
|
1941
|
+
return {
|
|
1942
|
+
getBasicsSession: async ()=>{
|
|
1943
|
+
if (targetSession.subDomain === "Basics") {
|
|
1944
|
+
return targetSession;
|
|
1945
|
+
}
|
|
1946
|
+
if (basicsSession === undefined) {
|
|
1947
|
+
basicsSession = await startSession({
|
|
1948
|
+
...params,
|
|
1949
|
+
subDomain: "Basics"
|
|
1950
|
+
});
|
|
1951
|
+
}
|
|
1952
|
+
return basicsSession;
|
|
1953
|
+
},
|
|
1954
|
+
getTargetSession: ()=>targetSession,
|
|
1955
|
+
destroy: async ()=>{
|
|
1956
|
+
await closeSession(targetSession);
|
|
1957
|
+
if (basicsSession !== undefined) {
|
|
1958
|
+
await closeSession(basicsSession);
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
};
|
|
1962
|
+
};
|
|
1963
|
+
|
|
1964
|
+
const synchronizeDependencies = async (workspaceLocation, creatorPackage, sessionManager, prompter, reporter, logUpToDate = false)=>{
|
|
1965
|
+
const libraries = determineWorkspaceIGLibraries(workspaceLocation);
|
|
1966
|
+
// If there are no libraries, we don't need to check for required versions
|
|
1967
|
+
if (libraries.length === 0) {
|
|
1968
|
+
return true;
|
|
1969
|
+
}
|
|
1970
|
+
const targetSession = sessionManager.getTargetSession();
|
|
1971
|
+
const rawUploadedPackages = await getExistingPackages(targetSession);
|
|
1972
|
+
const uploadedPackages = rawUploadedPackages.map((entry)=>{
|
|
1973
|
+
let version;
|
|
1974
|
+
try {
|
|
1975
|
+
version = parseVersionFromNumericVersion(entry.numericVersion);
|
|
1976
|
+
} catch (err) {
|
|
1977
|
+
throw new Error(`Encountered invalid format for version ${entry.numericVersion}`);
|
|
1978
|
+
}
|
|
1979
|
+
if (version.buildNumber < 100) {
|
|
1980
|
+
version.preRelease = {
|
|
1981
|
+
type: "beta",
|
|
1982
|
+
version: version.buildNumber
|
|
1983
|
+
};
|
|
1984
|
+
} else if (version.buildNumber > 100) {
|
|
1985
|
+
version.preRelease = {
|
|
1986
|
+
type: "patch",
|
|
1987
|
+
version: version.buildNumber - 100
|
|
1988
|
+
};
|
|
1989
|
+
}
|
|
1990
|
+
return {
|
|
1991
|
+
...entry,
|
|
1992
|
+
version
|
|
1993
|
+
};
|
|
1994
|
+
});
|
|
1995
|
+
for (const libraryLocation of libraries){
|
|
1996
|
+
const libraryManifest = readPublishedPackageNpmManifest(libraryLocation);
|
|
1997
|
+
const libraryCreatorPackage = readPublishedPackageCreatorManifest(libraryLocation);
|
|
1998
|
+
if (libraryCreatorPackage === undefined || libraryManifest.main === undefined || libraryCreatorPackage.Package === (creatorPackage == null ? void 0 : creatorPackage.Package)) {
|
|
1999
|
+
continue;
|
|
2000
|
+
}
|
|
2001
|
+
const libraryVersion = PackageVersion.extractFromLine(libraryManifest.version);
|
|
2002
|
+
if (libraryVersion.preRelease) {
|
|
2003
|
+
libraryVersion.buildNumber = libraryVersion.preRelease.version;
|
|
2004
|
+
libraryVersion.preRelease = undefined;
|
|
2005
|
+
} else {
|
|
2006
|
+
libraryVersion.buildNumber = 100;
|
|
2007
|
+
}
|
|
2008
|
+
let uploadedPackageInBasics;
|
|
2009
|
+
let uploadedPackageInTarget;
|
|
2010
|
+
for (const uploadedPackage of uploadedPackages){
|
|
2011
|
+
if (uploadedPackage.scope === libraryCreatorPackage.Package) {
|
|
2012
|
+
if (uploadedPackage.support) {
|
|
2013
|
+
uploadedPackageInBasics = uploadedPackage;
|
|
2014
|
+
} else {
|
|
2015
|
+
uploadedPackageInTarget = uploadedPackage;
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
const validInBasics = uploadedPackageInBasics !== undefined && !uploadedPackageInBasics.version.isLesserThan(libraryVersion);
|
|
2020
|
+
const validInTarget = uploadedPackageInTarget !== undefined && !uploadedPackageInTarget.version.isLesserThan(libraryVersion);
|
|
2021
|
+
if (validInBasics || validInTarget) {
|
|
2022
|
+
if (targetSession.subDomain !== "Basics" && uploadedPackageInBasics !== undefined && uploadedPackageInTarget !== undefined) {
|
|
2023
|
+
reporter.log(`Package ${libraryCreatorPackage.Package} is uploaded both for Basics and ${targetSession.subDomain}. The package within ${targetSession.subDomain} will be used.`);
|
|
2024
|
+
}
|
|
2025
|
+
if (logUpToDate) {
|
|
2026
|
+
reporter.log(`Package ${libraryCreatorPackage.Package} is already uploaded with the required version ${libraryVersion.toVersionString({})}`);
|
|
2027
|
+
}
|
|
2028
|
+
continue;
|
|
2029
|
+
}
|
|
2030
|
+
const possibleTargets = [];
|
|
2031
|
+
if (uploadedPackageInBasics) {
|
|
2032
|
+
const version = uploadedPackageInBasics.version.toVersionString({
|
|
2033
|
+
buildNumber: true
|
|
2034
|
+
});
|
|
2035
|
+
possibleTargets.push({
|
|
2036
|
+
value: "Basics",
|
|
2037
|
+
name: `Basics (Current: ${version})`
|
|
2038
|
+
});
|
|
2039
|
+
} else {
|
|
2040
|
+
possibleTargets.push({
|
|
2041
|
+
value: "Basics",
|
|
2042
|
+
name: "Basics (Current: None)"
|
|
2043
|
+
});
|
|
2044
|
+
}
|
|
2045
|
+
if (targetSession.subDomain !== "Basics") {
|
|
2046
|
+
if (uploadedPackageInTarget) {
|
|
2047
|
+
const version = uploadedPackageInTarget.version.toVersionString({
|
|
2048
|
+
buildNumber: true
|
|
2049
|
+
});
|
|
2050
|
+
possibleTargets.push({
|
|
2051
|
+
value: targetSession.subDomain,
|
|
2052
|
+
name: `${targetSession.subDomain} (Current: ${version})`
|
|
2053
|
+
});
|
|
2054
|
+
} else {
|
|
2055
|
+
possibleTargets.push({
|
|
2056
|
+
value: targetSession.subDomain,
|
|
2057
|
+
name: `${targetSession.subDomain} (Current: None)`
|
|
2058
|
+
});
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
const libraryVersionString = libraryVersion.toVersionString({
|
|
2062
|
+
buildNumber: true
|
|
2063
|
+
});
|
|
2064
|
+
const uploadTargetScope = await prompter.ask({
|
|
2065
|
+
message: `Version ${libraryVersionString} of dependency ${libraryCreatorPackage.Package} is required but not available. Please select a subdomain to upload the correct dependency version to`,
|
|
2066
|
+
options: [
|
|
2067
|
+
...possibleTargets,
|
|
2068
|
+
{
|
|
2069
|
+
name: "Skip upload",
|
|
2070
|
+
value: "Skip"
|
|
2071
|
+
}
|
|
2072
|
+
],
|
|
2073
|
+
default: possibleTargets[0].value
|
|
2074
|
+
});
|
|
2075
|
+
if (uploadTargetScope === "Skip") {
|
|
2076
|
+
continue;
|
|
2077
|
+
}
|
|
2078
|
+
const archive = buildArchiveFromPublishedPackage(libraryLocation, libraryManifest, libraryCreatorPackage);
|
|
2079
|
+
const newVersionString = libraryVersion.toVersionString({
|
|
2080
|
+
buildNumber: true
|
|
2081
|
+
});
|
|
2082
|
+
const session = uploadTargetScope === "Basics" ? await sessionManager.getBasicsSession() : targetSession;
|
|
2083
|
+
reporter.log(`Uploading package ${libraryCreatorPackage.Package} with version ${newVersionString} to ${session.domain}.${session.subDomain}`);
|
|
2084
|
+
await uploadPackageFromStream(session, {
|
|
2085
|
+
name: libraryCreatorPackage.Package,
|
|
2086
|
+
version: newVersionString
|
|
2087
|
+
}, archive.generateNodeStream());
|
|
2088
|
+
}
|
|
2089
|
+
};
|
|
2090
|
+
|
|
1924
2091
|
const execAsync = promisify(exec);
|
|
1925
2092
|
const releaseFolder = async (options)=>{
|
|
1926
2093
|
const workspace = options.workspace;
|
|
@@ -1928,6 +2095,7 @@ const releaseFolder = async (options)=>{
|
|
|
1928
2095
|
const { write: writeVersionFile, reset: resetVersionFile } = getVersionFileHandler(location);
|
|
1929
2096
|
const packageDescription = readPackageCreatorManifest(location);
|
|
1930
2097
|
const fullPackageName = packageDescription.Package;
|
|
2098
|
+
const reporter = options.reporter ?? createPackageScopedReporter(consoleReporter, packageDescription.Package);
|
|
1931
2099
|
const { domain, subdomain } = parseCreatorPackageName(packageDescription);
|
|
1932
2100
|
const publishDomain = options.domain ?? domain;
|
|
1933
2101
|
const publishSubdomain = options.subdomain ?? subdomain;
|
|
@@ -1954,7 +2122,7 @@ const releaseFolder = async (options)=>{
|
|
|
1954
2122
|
};
|
|
1955
2123
|
}
|
|
1956
2124
|
if (sharedPackageJson !== undefined) {
|
|
1957
|
-
|
|
2125
|
+
reporter.log(`Running npm install to make sure all dependencies are up to date`);
|
|
1958
2126
|
await execAsync(`npm install`, {
|
|
1959
2127
|
encoding: "utf-8",
|
|
1960
2128
|
cwd: workspace.path
|
|
@@ -2010,7 +2178,8 @@ const releaseFolder = async (options)=>{
|
|
|
2010
2178
|
buildNumber: true
|
|
2011
2179
|
}),
|
|
2012
2180
|
date: new Date(Date.now())
|
|
2013
|
-
} : undefined
|
|
2181
|
+
} : undefined,
|
|
2182
|
+
preparedReporter: reporter
|
|
2014
2183
|
});
|
|
2015
2184
|
newVersion.preRelease = undefined;
|
|
2016
2185
|
try {
|
|
@@ -2036,14 +2205,14 @@ const releaseFolder = async (options)=>{
|
|
|
2036
2205
|
}
|
|
2037
2206
|
}
|
|
2038
2207
|
}
|
|
2039
|
-
|
|
2040
|
-
const archive = await buildArchiveFromPackage(location, packageDescription, binDir, options.minimize);
|
|
2208
|
+
reporter.log(`Creating zip file`);
|
|
2209
|
+
const archive = await buildArchiveFromPackage(reporter, location, packageDescription, binDir, options.minimize);
|
|
2041
2210
|
try {
|
|
2042
2211
|
const zipOutputStream = createWriteStream(zipFilePath);
|
|
2043
2212
|
await pipeline(archive.generateNodeStream(), zipOutputStream);
|
|
2044
2213
|
} catch (err) {
|
|
2045
2214
|
if (isErrorEACCES(err) || isErrorEPERM(err)) {
|
|
2046
|
-
|
|
2215
|
+
reporter.log(`Could not create zip file in the bin directory because of a permissions error. Only using it in-memory`);
|
|
2047
2216
|
uploadable = {
|
|
2048
2217
|
getStream: ()=>archive.generateNodeStream()
|
|
2049
2218
|
};
|
|
@@ -2056,8 +2225,8 @@ const releaseFolder = async (options)=>{
|
|
|
2056
2225
|
if (!options.authentication) {
|
|
2057
2226
|
throw new Error(`Expected authentication to be available`);
|
|
2058
2227
|
}
|
|
2059
|
-
|
|
2060
|
-
const sessionManager = await
|
|
2228
|
+
reporter.log(`Opening connection to IG.Asset.Server`);
|
|
2229
|
+
const sessionManager = await createAssetServiceSessionManager({
|
|
2061
2230
|
url: options.service,
|
|
2062
2231
|
address: options.address,
|
|
2063
2232
|
domain: publishDomain,
|
|
@@ -2066,13 +2235,13 @@ const releaseFolder = async (options)=>{
|
|
|
2066
2235
|
});
|
|
2067
2236
|
try {
|
|
2068
2237
|
if (!options.skipDependencies) {
|
|
2069
|
-
await
|
|
2238
|
+
await synchronizeDependencies(workspace, packageDescription, sessionManager, options.prompter, reporter);
|
|
2070
2239
|
}
|
|
2071
|
-
|
|
2240
|
+
reporter.log(`Uploading package to ${publishDomain}.${publishSubdomain}`);
|
|
2072
2241
|
await uploadPackageFromStream(sessionManager.getTargetSession(), assetServerPackageDetails, uploadable.getStream());
|
|
2073
2242
|
} finally{
|
|
2074
2243
|
await sessionManager.destroy().catch((err)=>{
|
|
2075
|
-
|
|
2244
|
+
reporter.error(`Failed to close IG.Asset.Server session(s)`, err);
|
|
2076
2245
|
});
|
|
2077
2246
|
}
|
|
2078
2247
|
}
|
|
@@ -2081,7 +2250,7 @@ const releaseFolder = async (options)=>{
|
|
|
2081
2250
|
throw err;
|
|
2082
2251
|
}
|
|
2083
2252
|
if (newVersion.buildNumber >= 100 && !options.pushOnly) {
|
|
2084
|
-
|
|
2253
|
+
reporter.error("Copying zip to releases folder");
|
|
2085
2254
|
const zipFileName = `${packageNameWithVersion}.zip`;
|
|
2086
2255
|
const releasesPath = getPackageReleasesDirectory(location);
|
|
2087
2256
|
await fs$1.mkdir(releasesPath, {
|
|
@@ -2090,154 +2259,6 @@ const releaseFolder = async (options)=>{
|
|
|
2090
2259
|
await pipeline(uploadable.getStream(), createWriteStream(path.join(releasesPath, zipFileName)));
|
|
2091
2260
|
}
|
|
2092
2261
|
};
|
|
2093
|
-
const ensureRequiredVersions = async (workspaceLocation, creatorPackage, sessionManager, prompter)=>{
|
|
2094
|
-
const libraries = determineWorkspaceIGLibraries(workspaceLocation);
|
|
2095
|
-
// If there are no libraries, we don't need to check for required versions
|
|
2096
|
-
if (libraries.length === 0) {
|
|
2097
|
-
return true;
|
|
2098
|
-
}
|
|
2099
|
-
const targetSession = sessionManager.getTargetSession();
|
|
2100
|
-
const rawUploadedPackages = await getExistingPackages(targetSession);
|
|
2101
|
-
const uploadedPackages = rawUploadedPackages.map((entry)=>{
|
|
2102
|
-
let version;
|
|
2103
|
-
try {
|
|
2104
|
-
version = parseVersionFromNumericVersion(entry.numericVersion);
|
|
2105
|
-
} catch (err) {
|
|
2106
|
-
throw new Error(`Encountered invalid format for version ${entry.numericVersion}`);
|
|
2107
|
-
}
|
|
2108
|
-
if (version.buildNumber < 100) {
|
|
2109
|
-
version.preRelease = {
|
|
2110
|
-
type: "beta",
|
|
2111
|
-
version: version.buildNumber
|
|
2112
|
-
};
|
|
2113
|
-
} else if (version.buildNumber > 100) {
|
|
2114
|
-
version.preRelease = {
|
|
2115
|
-
type: "patch",
|
|
2116
|
-
version: version.buildNumber - 100
|
|
2117
|
-
};
|
|
2118
|
-
}
|
|
2119
|
-
return {
|
|
2120
|
-
...entry,
|
|
2121
|
-
version
|
|
2122
|
-
};
|
|
2123
|
-
});
|
|
2124
|
-
for (const libraryLocation of libraries){
|
|
2125
|
-
const libraryManifest = readPublishedPackageNpmManifest(libraryLocation);
|
|
2126
|
-
const libraryCreatorPackage = readPublishedPackageCreatorManifest(libraryLocation);
|
|
2127
|
-
if (libraryCreatorPackage === undefined || libraryManifest.main === undefined || libraryCreatorPackage.Package === creatorPackage.Package) {
|
|
2128
|
-
continue;
|
|
2129
|
-
}
|
|
2130
|
-
const libraryVersion = PackageVersion.extractFromLine(libraryManifest.version);
|
|
2131
|
-
if (libraryVersion.preRelease) {
|
|
2132
|
-
libraryVersion.buildNumber = libraryVersion.preRelease.version;
|
|
2133
|
-
libraryVersion.preRelease = undefined;
|
|
2134
|
-
} else {
|
|
2135
|
-
libraryVersion.buildNumber = 100;
|
|
2136
|
-
}
|
|
2137
|
-
let uploadedPackageInBasics;
|
|
2138
|
-
let uploadedPackageInTarget;
|
|
2139
|
-
for (const uploadedPackage of uploadedPackages){
|
|
2140
|
-
if (uploadedPackage.scope === libraryCreatorPackage.Package) {
|
|
2141
|
-
if (uploadedPackage.support) {
|
|
2142
|
-
uploadedPackageInBasics = uploadedPackage;
|
|
2143
|
-
} else {
|
|
2144
|
-
uploadedPackageInTarget = uploadedPackage;
|
|
2145
|
-
}
|
|
2146
|
-
}
|
|
2147
|
-
}
|
|
2148
|
-
const validInBasics = uploadedPackageInBasics !== undefined && !uploadedPackageInBasics.version.isLesserThan(libraryVersion);
|
|
2149
|
-
const validInTarget = uploadedPackageInTarget !== undefined && !uploadedPackageInTarget.version.isLesserThan(libraryVersion);
|
|
2150
|
-
if (validInBasics || validInTarget) {
|
|
2151
|
-
if (targetSession.subDomain !== "Basics" && uploadedPackageInBasics !== undefined && uploadedPackageInTarget !== undefined) {
|
|
2152
|
-
logPackageMessage(creatorPackage.Package, `Package ${libraryCreatorPackage.Package} is uploaded both for Basics and ${targetSession.subDomain}. The package within ${targetSession.subDomain} will be used.`);
|
|
2153
|
-
}
|
|
2154
|
-
continue;
|
|
2155
|
-
}
|
|
2156
|
-
const possibleTargets = [];
|
|
2157
|
-
if (uploadedPackageInBasics) {
|
|
2158
|
-
const version = uploadedPackageInBasics.version.toVersionString({
|
|
2159
|
-
buildNumber: true
|
|
2160
|
-
});
|
|
2161
|
-
possibleTargets.push({
|
|
2162
|
-
value: "Basics",
|
|
2163
|
-
name: `Basics (Current: ${version})`
|
|
2164
|
-
});
|
|
2165
|
-
} else {
|
|
2166
|
-
possibleTargets.push({
|
|
2167
|
-
value: "Basics",
|
|
2168
|
-
name: "Basics (Current: None)"
|
|
2169
|
-
});
|
|
2170
|
-
}
|
|
2171
|
-
if (targetSession.subDomain !== "Basics") {
|
|
2172
|
-
if (uploadedPackageInTarget) {
|
|
2173
|
-
const version = uploadedPackageInTarget.version.toVersionString({
|
|
2174
|
-
buildNumber: true
|
|
2175
|
-
});
|
|
2176
|
-
possibleTargets.push({
|
|
2177
|
-
value: targetSession.subDomain,
|
|
2178
|
-
name: `${targetSession.subDomain} (Current: ${version})`
|
|
2179
|
-
});
|
|
2180
|
-
} else {
|
|
2181
|
-
possibleTargets.push({
|
|
2182
|
-
value: targetSession.subDomain,
|
|
2183
|
-
name: `${targetSession.subDomain} (Current: None)`
|
|
2184
|
-
});
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
|
-
const libraryVersionString = libraryVersion.toVersionString({
|
|
2188
|
-
buildNumber: true
|
|
2189
|
-
});
|
|
2190
|
-
const uploadTargetScope = await prompter.ask({
|
|
2191
|
-
message: `Version ${libraryVersionString} of dependency ${libraryCreatorPackage.Package} is required but not available. Please select a subdomain to upload the correct dependency version to`,
|
|
2192
|
-
options: [
|
|
2193
|
-
...possibleTargets,
|
|
2194
|
-
{
|
|
2195
|
-
name: "Skip upload",
|
|
2196
|
-
value: "Skip"
|
|
2197
|
-
}
|
|
2198
|
-
],
|
|
2199
|
-
default: possibleTargets[0].value
|
|
2200
|
-
});
|
|
2201
|
-
if (uploadTargetScope === "Skip") {
|
|
2202
|
-
continue;
|
|
2203
|
-
}
|
|
2204
|
-
const archive = buildArchiveFromPublishedPackage(libraryLocation, libraryManifest, libraryCreatorPackage);
|
|
2205
|
-
const newVersionString = libraryVersion.toVersionString({
|
|
2206
|
-
buildNumber: true
|
|
2207
|
-
});
|
|
2208
|
-
const session = uploadTargetScope === "Basics" ? await sessionManager.getBasicsSession() : targetSession;
|
|
2209
|
-
logPackageMessage(creatorPackage.Package, `Uploading package ${libraryCreatorPackage.Package} with version ${newVersionString} to ${session.domain}.${session.subDomain}`);
|
|
2210
|
-
await uploadPackageFromStream(session, {
|
|
2211
|
-
name: libraryCreatorPackage.Package,
|
|
2212
|
-
version: newVersionString
|
|
2213
|
-
}, archive.generateNodeStream());
|
|
2214
|
-
}
|
|
2215
|
-
};
|
|
2216
|
-
const createSessionManager = async (params)=>{
|
|
2217
|
-
const targetSession = await startSession(params);
|
|
2218
|
-
let basicsSession;
|
|
2219
|
-
return {
|
|
2220
|
-
getBasicsSession: async ()=>{
|
|
2221
|
-
if (targetSession.subDomain === "Basics") {
|
|
2222
|
-
return targetSession;
|
|
2223
|
-
}
|
|
2224
|
-
if (basicsSession === undefined) {
|
|
2225
|
-
basicsSession = await startSession({
|
|
2226
|
-
...params,
|
|
2227
|
-
subDomain: "Basics"
|
|
2228
|
-
});
|
|
2229
|
-
}
|
|
2230
|
-
return basicsSession;
|
|
2231
|
-
},
|
|
2232
|
-
getTargetSession: ()=>targetSession,
|
|
2233
|
-
destroy: async ()=>{
|
|
2234
|
-
await closeSession(targetSession);
|
|
2235
|
-
if (basicsSession !== undefined) {
|
|
2236
|
-
await closeSession(basicsSession);
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
};
|
|
2240
|
-
};
|
|
2241
2262
|
|
|
2242
2263
|
/**
|
|
2243
2264
|
* Extracts and returns script array for _Index.json from a src folder
|
|
@@ -2513,5 +2534,5 @@ const detectScriptingClass = (node)=>{
|
|
|
2513
2534
|
}
|
|
2514
2535
|
};
|
|
2515
2536
|
|
|
2516
|
-
export { buildFolders, buildFoldersWatch, generateIndex, releaseFolder };
|
|
2537
|
+
export { buildFolders, buildFoldersWatch, createAssetServiceSessionManager, generateIndex, releaseFolder, synchronizeDependencies };
|
|
2517
2538
|
//# sourceMappingURL=lib.mjs.map
|