@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.
Files changed (35) hide show
  1. package/build/bin.mjs +1 -1
  2. package/build/{cli-e279c41e.mjs → cli-CuiqZ39_.mjs} +52 -85
  3. package/build/cli-CuiqZ39_.mjs.map +1 -0
  4. package/build/{dependencies-9afff33c.mjs → dependencies-BiYItaVS.mjs} +2 -2
  5. package/build/{dependencies-9afff33c.mjs.map → dependencies-BiYItaVS.mjs.map} +1 -1
  6. package/build/{generateIndex-9864e722.mjs → generateIndex-hg6jRXQv.mjs} +97 -84
  7. package/build/generateIndex-hg6jRXQv.mjs.map +1 -0
  8. package/build/{generateParameterType-32abb018.mjs → generateParameterType-CDjqLM4J.mjs} +3 -4
  9. package/build/{generateParameterType-32abb018.mjs.map → generateParameterType-CDjqLM4J.mjs.map} +1 -1
  10. package/build/{index-a87a7800.mjs → index-B2kXo6K7.mjs} +301 -89
  11. package/build/index-B2kXo6K7.mjs.map +1 -0
  12. package/build/{index-56178e55.mjs → index-BoGrZubW.mjs} +27 -25
  13. package/build/index-BoGrZubW.mjs.map +1 -0
  14. package/build/{postinstall-472e0106.mjs → postinstall-CbMUz2zy.mjs} +3 -4
  15. package/build/{postinstall-472e0106.mjs.map → postinstall-CbMUz2zy.mjs.map} +1 -1
  16. package/build/{publishNpm-7d02c52b.mjs → publishNpm-CrnuTwss.mjs} +12 -11
  17. package/build/publishNpm-CrnuTwss.mjs.map +1 -0
  18. package/build/rollup-UR3DADp8.mjs +198 -0
  19. package/build/rollup-UR3DADp8.mjs.map +1 -0
  20. package/build/scripts-Bfojy_uD.mjs +48 -0
  21. package/build/scripts-Bfojy_uD.mjs.map +1 -0
  22. package/build/versionFile-DSqOw-XB.mjs +208 -0
  23. package/build/versionFile-DSqOw-XB.mjs.map +1 -0
  24. package/lib/lib.mjs +448 -359
  25. package/package.json +15 -10
  26. package/readme.md +91 -10
  27. package/build/cli-e279c41e.mjs.map +0 -1
  28. package/build/generateIndex-9864e722.mjs.map +0 -1
  29. package/build/index-56178e55.mjs.map +0 -1
  30. package/build/index-a87a7800.mjs.map +0 -1
  31. package/build/publishNpm-7d02c52b.mjs.map +0 -1
  32. package/build/scripts-7ed8dff6.mjs +0 -10
  33. package/build/scripts-7ed8dff6.mjs.map +0 -1
  34. package/build/versionFile-4b06435d.mjs +0 -384
  35. package/build/versionFile-4b06435d.mjs.map +0 -1
@@ -1,21 +1,21 @@
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 'resolve';
6
8
  import 'write-pkg';
7
- import { e as readPackageAnimationList, r as readPackageCreatorManifest, i as isErrorENOENT, q as readPackageNpmManifest } from './cli-e279c41e.mjs';
8
- import glob from 'glob';
9
+ import { e as readPackageAnimationList, r as readPackageCreatorManifest, q as readPackageNpmManifest, i as isErrorENOENT } from './cli-CuiqZ39_.mjs';
10
+ import { g as getPackageTypescriptFiles, i as isScriptPackageModules } from './scripts-Bfojy_uD.mjs';
9
11
  import 'node:path';
10
12
  import 'node:fs';
11
13
  import 'axios';
12
- import ts from 'typescript';
13
- import { g as getPackageTypescriptFiles } from './scripts-7ed8dff6.mjs';
14
14
  import typedoc from 'typedoc';
15
+ import glob from 'glob';
15
16
  import require$$2 from 'events';
16
17
  import { SourceMapGenerator, SourceMapConsumer } from 'source-map-js';
17
18
  import Ajv from 'ajv';
18
- import { EOL } from 'os';
19
19
 
20
20
  const consoleReporter = {
21
21
  log (message) {
@@ -40,7 +40,7 @@ const createPackageScopedReporter = (reporter, scope, index, total, maxNameLengt
40
40
  };
41
41
 
42
42
  const tryReadTsConfig = (location)=>{
43
- const { config } = ts.readConfigFile(path.join(location.scriptsDir, "tsconfig.json"), (path)=>{
43
+ const { config } = ts.readConfigFile(path.join(location.scriptsDir, "tsconfig.json"), (path)=>{
44
44
  try {
45
45
  return fs.readFileSync(path, "utf8");
46
46
  } catch {
@@ -51,19 +51,6 @@ const tryReadTsConfig = (location)=>{
51
51
  };
52
52
  const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
53
53
  const files = getPackageTypescriptFiles(location);
54
- if (files.length === 0) {
55
- env.onBuildStart();
56
- env.onBuildEnd({
57
- type: "success",
58
- artefacts: {
59
- js: "",
60
- definitions: ""
61
- }
62
- });
63
- return {
64
- destroy: ()=>{}
65
- };
66
- }
67
54
  try {
68
55
  env.onBuildStart();
69
56
  env.log("Compiling typescript files");
@@ -101,7 +88,7 @@ const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
101
88
  type: "success",
102
89
  artefacts: {
103
90
  js: js.replace(`//# sourceMappingURL=out.js.map`, ""),
104
- definitions,
91
+ declarations: definitions,
105
92
  sourceMap
106
93
  }
107
94
  });
@@ -120,7 +107,7 @@ const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
120
107
  };
121
108
  };
122
109
  const createTSCWatchBuildParticipant = (location, outputDir)=>{
123
- return ({ onBuildStart , onBuildEnd })=>{
110
+ return ({ onBuildStart, onBuildEnd })=>{
124
111
  let state = {
125
112
  diagnostics: [],
126
113
  js: undefined,
@@ -194,7 +181,7 @@ const createTSCWatchBuildParticipant = (location, outputDir)=>{
194
181
  type: "success",
195
182
  artefacts: {
196
183
  js: emitState.js.replace(`//# sourceMappingURL=out.js.map`, ""),
197
- definitions: emitState.definitions,
184
+ declarations: emitState.definitions,
198
185
  sourceMap: emitState.sourceMap
199
186
  }
200
187
  });
@@ -208,17 +195,6 @@ const createTSCWatchBuildParticipant = (location, outputDir)=>{
208
195
  getNewLine: ()=>ts.sys.newLine
209
196
  };
210
197
  const watchProgram = ts.createWatchProgram(host);
211
- const files = getPackageTypescriptFiles(location);
212
- if (files.length === 0) {
213
- onBuildStart();
214
- onBuildEnd({
215
- type: "success",
216
- artefacts: {
217
- js: "",
218
- definitions: ""
219
- }
220
- });
221
- }
222
198
  return {
223
199
  destroy: ()=>{
224
200
  watchProgram.close();
@@ -304,12 +280,7 @@ const toposort = (packages)=>{
304
280
 
305
281
  class BuildManager extends require$$2 {
306
282
  constructor(manifest, writer, reporter){
307
- super();
308
- this.manifest = manifest;
309
- this.writer = writer;
310
- this.reporter = reporter;
311
- this.participants = new Map();
312
- this.states = new Map();
283
+ super(), this.manifest = manifest, this.writer = writer, this.reporter = reporter, this.participants = new Map(), this.states = new Map();
313
284
  }
314
285
  addParticipant(name, participant) {
315
286
  this.participants.set(name, participant);
@@ -382,14 +353,16 @@ class BuildManager extends require$$2 {
382
353
  line: lines + mapping.generatedLine,
383
354
  column: mapping.generatedColumn
384
355
  },
385
- original: {
356
+ original: mapping.originalLine !== null && mapping.originalColumn !== null ? {
386
357
  line: mapping.originalLine,
387
358
  column: mapping.originalColumn
388
- },
359
+ } : undefined,
389
360
  source: mapping.source,
390
361
  name: mapping.name
391
362
  });
392
- sources.add(mapping.source);
363
+ if (mapping.source !== null) {
364
+ sources.add(mapping.source);
365
+ }
393
366
  });
394
367
  for (const source of sources){
395
368
  const content = sourceMap.sourceContentFor(source);
@@ -400,13 +373,13 @@ class BuildManager extends require$$2 {
400
373
  }
401
374
  completeResult.js += result.artefacts.js;
402
375
  }
403
- if (result.artefacts.definitions) {
404
- if (completeResult.definitions) {
405
- completeResult.definitions += "\n";
376
+ if (result.artefacts.declarations) {
377
+ if (completeResult.declarations) {
378
+ completeResult.declarations += "\n";
406
379
  } else {
407
- completeResult.definitions = "";
380
+ completeResult.declarations = "";
408
381
  }
409
- completeResult.definitions += result.artefacts.definitions;
382
+ completeResult.declarations += result.artefacts.declarations;
410
383
  }
411
384
  }
412
385
  completeResult.sourceMap = sourceMapGenerator.toString();
@@ -749,7 +722,7 @@ const createAnimationBuildParticipant = (location, manifest)=>{
749
722
  env.onBuildEnd({
750
723
  type: "success",
751
724
  artefacts: {
752
- js: (result == null ? void 0 : result.js) ?? ""
725
+ js: result?.js ?? ""
753
726
  }
754
727
  });
755
728
  }).catch((err)=>{
@@ -763,14 +736,13 @@ const createAnimationBuildParticipant = (location, manifest)=>{
763
736
  };
764
737
  };
765
738
  };
766
- const createAnimationWatchBuildParticipant = (location, manifest)=>{
767
- return (env)=>{
739
+ const createAnimationWatchBuildParticipant = (location, manifest)=>(env)=>{
768
740
  env.onBuildStart();
769
741
  bundleAnimations(location, manifest, env.log).then((result)=>{
770
742
  env.onBuildEnd({
771
743
  type: "success",
772
744
  artefacts: {
773
- js: (result == null ? void 0 : result.js) ?? ""
745
+ js: result?.js ?? ""
774
746
  }
775
747
  });
776
748
  }).catch((err)=>{
@@ -781,15 +753,14 @@ const createAnimationWatchBuildParticipant = (location, manifest)=>{
781
753
  });
782
754
  (async ()=>{
783
755
  for await (const event of fs$1.watch(location.scriptsDir)){
784
- var _event_filename;
785
- if ((_event_filename = event.filename) == null ? void 0 : _event_filename.endsWith(".animation.json")) {
756
+ if (event.filename?.endsWith(".animation.json")) {
786
757
  env.onBuildStart();
787
758
  try {
788
759
  const result = await bundleAnimations(location, manifest, env.log);
789
760
  env.onBuildEnd({
790
761
  type: "success",
791
762
  artefacts: {
792
- js: (result == null ? void 0 : result.js) ?? ""
763
+ js: result?.js ?? ""
793
764
  }
794
765
  });
795
766
  } catch (err) {
@@ -805,7 +776,6 @@ const createAnimationWatchBuildParticipant = (location, manifest)=>{
805
776
  destroy: ()=>{}
806
777
  };
807
778
  };
808
- };
809
779
  const bundleAnimations = async (location, manifest, logStep)=>{
810
780
  const animations = new Map();
811
781
  for (const scriptFilePath of readPackageAnimationList(location)){
@@ -868,7 +838,187 @@ const getAnimationJsonValidation = async ()=>{
868
838
  return validateAnimationJson;
869
839
  };
870
840
 
871
- const buildFolders = async (options)=>{
841
+ // Stolen from ig.tools.core
842
+ class PackageVersion {
843
+ static{
844
+ // https://regex101.com/r/90PEY9/1
845
+ this.fullTextMatcher = /(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?/;
846
+ }
847
+ static{
848
+ this.lineMatcher = /^(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?$/;
849
+ }
850
+ static extractFromText(input, description) {
851
+ if (input === undefined) {
852
+ throw new Error(`Can not parse version from undefined`);
853
+ }
854
+ const match = input.match(PackageVersion.fullTextMatcher);
855
+ if (!match) {
856
+ throw new Error(`Could not extract a version from input: ${input}`);
857
+ }
858
+ return PackageVersion.fromMatch(match, description);
859
+ }
860
+ static extractFromLine(input, description) {
861
+ if (input === undefined) {
862
+ throw new Error(`Can not parse version from undefined`);
863
+ }
864
+ const match = input.match(PackageVersion.lineMatcher);
865
+ if (!match) {
866
+ throw new Error(`Could not parse version from input: ${input}`);
867
+ }
868
+ return PackageVersion.fromMatch(match, description);
869
+ }
870
+ static equals(a, b, checkPrerelease = false) {
871
+ if (a.major !== b.major || a.minor !== b.minor || a.patch !== b.patch) {
872
+ return false;
873
+ }
874
+ if (checkPrerelease === false) {
875
+ return true;
876
+ }
877
+ if (a.preRelease === b.preRelease) {
878
+ return true;
879
+ }
880
+ if (a.preRelease === undefined || b.preRelease === undefined) {
881
+ return false;
882
+ }
883
+ return a.preRelease.type === b.preRelease.type && a.preRelease.version === b.preRelease.version;
884
+ }
885
+ static fromMatch([, major, , minor = "0", , patch = "0", , build, , preReleaseType, preReleaseNumber], description) {
886
+ let preRelease = undefined;
887
+ let buildNumber = 100;
888
+ if (preReleaseType && preReleaseNumber) {
889
+ preRelease = {
890
+ type: preReleaseType,
891
+ version: parseInt(preReleaseNumber)
892
+ };
893
+ }
894
+ if (build) {
895
+ buildNumber = Number(build);
896
+ } else if (description) {
897
+ const descriptionMatch = description.match(/(\d+)\)$/);
898
+ if (descriptionMatch) {
899
+ buildNumber = parseInt(descriptionMatch[1]);
900
+ }
901
+ }
902
+ return new PackageVersion(parseInt(major), parseInt(minor), parseInt(patch), preRelease, buildNumber);
903
+ }
904
+ static sort(a, b, ascending = true) {
905
+ const createSortResult = (a, b)=>ascending ? a - b : b - a;
906
+ if (a.major !== b.major) {
907
+ return createSortResult(a.major, b.major);
908
+ }
909
+ if (a.minor !== b.minor) {
910
+ return createSortResult(a.minor, b.minor);
911
+ }
912
+ if (a.patch !== b.patch) {
913
+ return createSortResult(a.patch, b.patch);
914
+ }
915
+ return createSortResult(a.preRelease ? a.preRelease.version : 0, b.preRelease ? b.preRelease.version : 0);
916
+ }
917
+ static toNumber(version) {
918
+ return ((version.major * 1000 + version.minor) * 1000 + version.patch) * 1000 + version.buildNumber;
919
+ }
920
+ constructor(major, minor, patch, preRelease, buildNumber){
921
+ this.major = major;
922
+ this.minor = minor;
923
+ this.patch = patch;
924
+ this.preRelease = preRelease;
925
+ this.buildNumber = buildNumber;
926
+ }
927
+ isPreRelease() {
928
+ return this.preRelease !== undefined;
929
+ }
930
+ clone() {
931
+ return new PackageVersion(this.major, this.minor, this.patch, this.preRelease ? {
932
+ ...this.preRelease
933
+ } : undefined, this.buildNumber);
934
+ }
935
+ incrementMajor() {
936
+ this.preRelease = undefined;
937
+ this.patch = 0;
938
+ this.minor = 0;
939
+ this.major++;
940
+ }
941
+ incrementMinor() {
942
+ this.preRelease = undefined;
943
+ this.patch = 0;
944
+ this.minor++;
945
+ }
946
+ incrementPatch() {
947
+ this.preRelease = undefined;
948
+ this.patch++;
949
+ }
950
+ createPreRelease(type) {
951
+ if (!this.preRelease) {
952
+ this.buildNumber = 1;
953
+ } else {
954
+ this.buildNumber++;
955
+ }
956
+ if (this.preRelease && type === this.preRelease.type) {
957
+ this.preRelease.version++;
958
+ return;
959
+ }
960
+ this.preRelease = {
961
+ version: 0,
962
+ type
963
+ };
964
+ }
965
+ createRelease() {
966
+ this.preRelease = undefined;
967
+ this.buildNumber = 100;
968
+ }
969
+ toVersionString({ buildNumber } = {}) {
970
+ let version = [
971
+ this.major,
972
+ this.minor,
973
+ this.patch
974
+ ].join(".");
975
+ if (buildNumber) {
976
+ version += "." + this.buildNumber;
977
+ }
978
+ if (this.preRelease) {
979
+ version += `-${this.preRelease.type}.${this.preRelease.version}`;
980
+ }
981
+ return version;
982
+ }
983
+ toDescriptionString(packageName) {
984
+ const base = [
985
+ this.major,
986
+ this.minor,
987
+ this.patch
988
+ ].join(".");
989
+ const parts = [
990
+ packageName,
991
+ base
992
+ ];
993
+ if (this.preRelease) {
994
+ parts.push(upperCaseFirst(this.preRelease.type));
995
+ parts.push(this.preRelease.version);
996
+ }
997
+ parts.push(`(${base}.${this.buildNumber})`);
998
+ return parts.join(" ");
999
+ }
1000
+ /**
1001
+ * Determines wether the version is lesser than the input version
1002
+ *
1003
+ * @param {PackageVersion} version
1004
+ * @returns
1005
+ */ isLesserThan(version) {
1006
+ return PackageVersion.toNumber(this) < PackageVersion.toNumber(version);
1007
+ }
1008
+ /**
1009
+ * Determines wether the version is greater than the input version
1010
+ *
1011
+ * @param {PackageVersion} version
1012
+ * @returns
1013
+ */ isGreaterThan(version) {
1014
+ return PackageVersion.toNumber(this) > PackageVersion.toNumber(version);
1015
+ }
1016
+ }
1017
+ const upperCaseFirst = (input)=>{
1018
+ return input.slice(0, 1).toUpperCase() + input.slice(1);
1019
+ };
1020
+
1021
+ async function buildFolders(options) {
872
1022
  if (options.outDir !== undefined && options.clean) {
873
1023
  await fs$1.rm(options.outDir, {
874
1024
  recursive: true
@@ -885,7 +1035,7 @@ const buildFolders = async (options)=>{
885
1035
  ]));
886
1036
  const maxNameLength = Array.from(manifests.values(), (manifest)=>manifest.Package.length).reduce((acc, length)=>Math.max(acc, length), 0);
887
1037
  for (const location of sortedPackages){
888
- await ensureTsConfig(location);
1038
+ const tsConfig = await ensureTsConfig(location);
889
1039
  const data = manifests.get(location);
890
1040
  const reporter = options.preparedReporter ?? createPackageScopedReporter(baseReporter, data.Package, index, folders.length, maxNameLength);
891
1041
  const outputDirectory = options.outDir || location.scriptsDir;
@@ -896,7 +1046,18 @@ const buildFolders = async (options)=>{
896
1046
  if (options.banner) {
897
1047
  manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
898
1048
  }
899
- manager.addParticipant("tsc", createTSCBuildParticipant(location, outputDirectory));
1049
+ const typescriptFiles = getPackageTypescriptFiles(location);
1050
+ if (!typescriptFiles.some((file)=>path.basename(file).toLowerCase() === "version.ts")) {
1051
+ manager.addParticipant("version", createVersionLogBuildParticipant(data));
1052
+ }
1053
+ if (typescriptFiles.length > 0) {
1054
+ if (isScriptPackageModules(tsConfig.options)) {
1055
+ const { createRollupBuildParticipant } = await import('./rollup-UR3DADp8.mjs');
1056
+ manager.addParticipant("rollup", createRollupBuildParticipant(location, data, outputDirectory));
1057
+ } else {
1058
+ manager.addParticipant("tsc", createTSCBuildParticipant(location, outputDirectory));
1059
+ }
1060
+ }
900
1061
  manager.addParticipant("animation", createAnimationBuildParticipant(location, data));
901
1062
  await new Promise((resolve, reject)=>{
902
1063
  manager.addListener("start", ()=>{
@@ -917,8 +1078,8 @@ const buildFolders = async (options)=>{
917
1078
  }
918
1079
  index++;
919
1080
  }
920
- };
921
- const buildFoldersWatch = async (options)=>{
1081
+ }
1082
+ async function buildFoldersWatch(options) {
922
1083
  if (options.outDir !== undefined && options.clean) {
923
1084
  await fs$1.rm(options.outDir, {
924
1085
  recursive: true
@@ -934,7 +1095,7 @@ const buildFoldersWatch = async (options)=>{
934
1095
  ]));
935
1096
  const maxNameLength = Array.from(manifests.values(), (manifest)=>manifest.Package.length).reduce((acc, length)=>Math.max(acc, length), 0);
936
1097
  for (const location of sortedPackages){
937
- await ensureTsConfig(location);
1098
+ const tsConfig = await ensureTsConfig(location);
938
1099
  const baseReporter = options.reporter ?? consoleReporter;
939
1100
  const data = manifests.get(location);
940
1101
  const reporter = createPackageScopedReporter(baseReporter, data.Package, index, folders.length, maxNameLength);
@@ -946,7 +1107,18 @@ const buildFoldersWatch = async (options)=>{
946
1107
  if (options.banner) {
947
1108
  manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
948
1109
  }
949
- manager.addParticipant("tsc", createTSCWatchBuildParticipant(location, outputDirectory));
1110
+ const typescriptFiles = getPackageTypescriptFiles(location);
1111
+ if (!typescriptFiles.some((file)=>path.basename(file).toLowerCase() === "version.ts")) {
1112
+ manager.addParticipant("version", createVersionLogBuildParticipant(data));
1113
+ }
1114
+ if (typescriptFiles.length > 0) {
1115
+ if (isScriptPackageModules(tsConfig.options)) {
1116
+ const { createRollupWatchBuildParticipant } = await import('./rollup-UR3DADp8.mjs');
1117
+ manager.addParticipant("rollup", createRollupWatchBuildParticipant(location, data, outputDirectory));
1118
+ } else {
1119
+ manager.addParticipant("tsc", createTSCWatchBuildParticipant(location, outputDirectory));
1120
+ }
1121
+ }
950
1122
  manager.addParticipant("animation", createAnimationWatchBuildParticipant(location, data));
951
1123
  await new Promise((resolve, reject)=>{
952
1124
  manager.addListener("start", ()=>{
@@ -965,8 +1137,8 @@ const buildFoldersWatch = async (options)=>{
965
1137
  index++;
966
1138
  }
967
1139
  await new Promise(()=>{});
968
- };
969
- const writeBuildResult = async (buildResult, manifest, location, workspace, outputDirectory, minimize, reporter)=>{
1140
+ }
1141
+ async function writeBuildResult(buildResult, manifest, location, workspace, outputDirectory, minimize, reporter) {
970
1142
  let js = buildResult.js;
971
1143
  if (buildResult.sourceMap) {
972
1144
  js += `\n//# sourceMappingURL=${manifest.Package}.js.map`;
@@ -974,8 +1146,8 @@ const writeBuildResult = async (buildResult, manifest, location, workspace, outp
974
1146
  await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.js`), js, {
975
1147
  encoding: "utf8"
976
1148
  });
977
- if (buildResult.definitions !== undefined) {
978
- await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.d.ts`), buildResult.definitions, {
1149
+ if (buildResult.declarations !== undefined) {
1150
+ await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.d.ts`), buildResult.declarations, {
979
1151
  encoding: "utf8"
980
1152
  });
981
1153
  }
@@ -1003,54 +1175,94 @@ const writeBuildResult = async (buildResult, manifest, location, workspace, outp
1003
1175
  });
1004
1176
  }
1005
1177
  }
1006
- if (location.path.includes("Basics") && buildResult.definitions !== undefined) {
1178
+ if (location.path.includes("Basics") && buildResult.declarations !== undefined) {
1007
1179
  await fs$1.mkdir(path.join(workspace.path, "lib"), {
1008
1180
  recursive: true
1009
1181
  });
1010
1182
  reporter.log("Copying basics definition file to the lib folder");
1011
- await fs$1.writeFile(path.join(workspace.path, "lib", `${manifest.Package}.d.ts`), buildResult.definitions, {
1183
+ await fs$1.writeFile(path.join(workspace.path, "lib", `${manifest.Package}.d.ts`), buildResult.declarations, {
1012
1184
  encoding: "utf8"
1013
1185
  });
1014
1186
  }
1015
- };
1016
- const createBannerCommentBuildParticipant = (options)=>(env)=>{
1187
+ }
1188
+ function createVersionLogBuildParticipant(manifest) {
1189
+ return (env)=>{
1190
+ env.onBuildStart();
1191
+ const parsedVersion = manifest.Version !== undefined ? PackageVersion.extractFromLine(manifest.Version) : undefined;
1192
+ let logText;
1193
+ if (parsedVersion !== undefined) {
1194
+ logText = parsedVersion.toDescriptionString(manifest.Package);
1195
+ } else {
1196
+ logText = manifest.Package;
1197
+ }
1198
+ logText += ".";
1199
+ if (manifest.Copyright !== undefined) {
1200
+ logText += " " + manifest.Copyright;
1201
+ }
1202
+ env.onBuildEnd({
1203
+ type: "success",
1204
+ artefacts: {
1205
+ js: `console.log(${JSON.stringify(logText)})`
1206
+ }
1207
+ });
1208
+ return {
1209
+ destroy: ()=>{}
1210
+ };
1211
+ };
1212
+ }
1213
+ function createBannerCommentBuildParticipant(options) {
1214
+ return (env)=>{
1017
1215
  env.onBuildStart();
1018
1216
  const banner = createBannerComment(options);
1019
1217
  env.onBuildEnd({
1020
1218
  type: "success",
1021
1219
  artefacts: {
1022
1220
  js: banner ?? "",
1023
- definitions: banner ?? ""
1221
+ declarations: banner ?? ""
1024
1222
  }
1025
1223
  });
1026
1224
  return {
1027
1225
  destroy: ()=>{}
1028
1226
  };
1029
1227
  };
1030
- const ensureTsConfig = async (location)=>{
1228
+ }
1229
+ async function ensureTsConfig(location) {
1031
1230
  const tsconfigPath = path.join(location.scriptsDir, "tsconfig.json");
1032
1231
  try {
1033
1232
  const content = JSON.parse(await fs$1.readFile(tsconfigPath, "utf8"));
1034
- applyTsConfigOption(content);
1233
+ applyTsConfigOptions(content);
1035
1234
  await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
1235
+ return ts.parseJsonConfigFileContent(content, ts.sys, location.scriptsDir);
1036
1236
  } catch (err) {
1037
1237
  if (!isErrorENOENT(err)) {
1038
1238
  throw err;
1039
1239
  }
1040
1240
  const content = {};
1041
- applyTsConfigOption(content);
1241
+ applyTsConfigOptions(content);
1042
1242
  await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
1243
+ return ts.parseJsonConfigFileContent(content, ts.sys, location.scriptsDir);
1043
1244
  }
1044
- };
1045
- const applyTsConfigOption = (data)=>{
1046
- data.compilerOptions = data.compilerOptions ?? {};
1047
- data.compilerOptions.target = "es5";
1048
- data.compilerOptions.lib = [
1049
- "es5",
1050
- "dom"
1051
- ];
1052
- };
1053
- const sortPackagesByBuildOrder = (folders)=>{
1245
+ }
1246
+ function applyTsConfigOptions(data) {
1247
+ if (data.compilerOptions?.module?.toLowerCase().startsWith("es")) {
1248
+ data.compilerOptions = data.compilerOptions ?? {};
1249
+ data.compilerOptions.target = "esnext";
1250
+ data.compilerOptions.lib = [
1251
+ "esnext",
1252
+ "dom"
1253
+ ];
1254
+ data.compilerOptions.module = "es2015";
1255
+ data.compilerOptions.moduleResolution = "node";
1256
+ } else {
1257
+ data.compilerOptions = data.compilerOptions ?? {};
1258
+ data.compilerOptions.target = "es5";
1259
+ data.compilerOptions.lib = [
1260
+ "es5",
1261
+ "dom"
1262
+ ];
1263
+ }
1264
+ }
1265
+ function sortPackagesByBuildOrder(folders) {
1054
1266
  const packages = Array.from(folders).reduce((acc, location)=>{
1055
1267
  const data = readPackageNpmManifest(location);
1056
1268
  if (data !== undefined) {
@@ -1090,8 +1302,8 @@ const sortPackagesByBuildOrder = (folders)=>{
1090
1302
  }
1091
1303
  }
1092
1304
  return result;
1093
- };
1094
- const createBannerComment = (banner)=>{
1305
+ }
1306
+ function createBannerComment(banner) {
1095
1307
  const bannerParts = [];
1096
1308
  if (banner.text) {
1097
1309
  bannerParts.push(" * " + banner.text);
@@ -1125,7 +1337,7 @@ ${bannerText}
1125
1337
  */`;
1126
1338
  }
1127
1339
  return undefined;
1128
- };
1340
+ }
1129
1341
 
1130
1342
  var index = /*#__PURE__*/Object.freeze({
1131
1343
  __proto__: null,
@@ -1133,5 +1345,5 @@ var index = /*#__PURE__*/Object.freeze({
1133
1345
  buildFoldersWatch: buildFoldersWatch
1134
1346
  });
1135
1347
 
1136
- export { consoleReporter as a, buildFolders as b, createPackageScopedReporter as c, index as i };
1137
- //# sourceMappingURL=index-a87a7800.mjs.map
1348
+ export { PackageVersion as P, consoleReporter as a, buildFolders as b, createPackageScopedReporter as c, index as i };
1349
+ //# sourceMappingURL=index-B2kXo6K7.mjs.map