@intelligentgraphics/ig.gfx.packager 3.0.2 → 3.0.4

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 (68) hide show
  1. package/build/cli-5332deff.js +2486 -0
  2. package/build/cli-5332deff.js.map +1 -0
  3. package/build/{lib/dependencies.mjs → dependencies-227aca50.js} +62 -7
  4. package/build/dependencies-227aca50.js.map +1 -0
  5. package/build/{commands/generate.mjs → generate-a3a16031.js} +17 -3
  6. package/build/generate-a3a16031.js.map +1 -0
  7. package/build/{commands/publish/index.mjs → index-5d595f56.js} +199 -17
  8. package/build/index-5d595f56.js.map +1 -0
  9. package/build/{commands/build/index.mjs → index-92b6ba5c.js} +151 -8
  10. package/build/index-92b6ba5c.js.map +1 -0
  11. package/build/index.mjs +1 -1
  12. package/build/index.mjs.map +1 -1
  13. package/build/{commands/postinstall.mjs → postinstall-7e50da37.js} +19 -12
  14. package/build/postinstall-7e50da37.js.map +1 -0
  15. package/build/{commands/publishNpm.mjs → publishNpm-e2c8347f.js} +22 -10
  16. package/build/publishNpm-e2c8347f.js.map +1 -0
  17. package/build/versionFile-b3a65dc8.js +370 -0
  18. package/build/versionFile-b3a65dc8.js.map +1 -0
  19. package/package.json +8 -7
  20. package/readme.md +23 -3
  21. package/build/cli.mjs +0 -316
  22. package/build/cli.mjs.map +0 -1
  23. package/build/commands/build/docs.mjs +0 -34
  24. package/build/commands/build/docs.mjs.map +0 -1
  25. package/build/commands/build/index.mjs.map +0 -1
  26. package/build/commands/build/tsc.mjs +0 -84
  27. package/build/commands/build/tsc.mjs.map +0 -1
  28. package/build/commands/generate.mjs.map +0 -1
  29. package/build/commands/postinstall.mjs.map +0 -1
  30. package/build/commands/publish/index.mjs.map +0 -1
  31. package/build/commands/publish/zip.mjs +0 -168
  32. package/build/commands/publish/zip.mjs.map +0 -1
  33. package/build/commands/publishNpm.mjs.map +0 -1
  34. package/build/lib/assetService.mjs +0 -111
  35. package/build/lib/assetService.mjs.map +0 -1
  36. package/build/lib/banner.mjs +0 -20
  37. package/build/lib/banner.mjs.map +0 -1
  38. package/build/lib/dependencies.mjs.map +0 -1
  39. package/build/lib/error.mjs +0 -15
  40. package/build/lib/error.mjs.map +0 -1
  41. package/build/lib/fs.mjs +0 -19
  42. package/build/lib/fs.mjs.map +0 -1
  43. package/build/lib/git.mjs +0 -37
  44. package/build/lib/git.mjs.map +0 -1
  45. package/build/lib/log.mjs +0 -9
  46. package/build/lib/log.mjs.map +0 -1
  47. package/build/lib/npmPackage.mjs +0 -19
  48. package/build/lib/npmPackage.mjs.map +0 -1
  49. package/build/lib/package.mjs +0 -129
  50. package/build/lib/package.mjs.map +0 -1
  51. package/build/lib/packageVersion.mjs +0 -174
  52. package/build/lib/packageVersion.mjs.map +0 -1
  53. package/build/lib/parseVersion.mjs +0 -54
  54. package/build/lib/parseVersion.mjs.map +0 -1
  55. package/build/lib/prompter.mjs +0 -31
  56. package/build/lib/prompter.mjs.map +0 -1
  57. package/build/lib/publishedPackage.mjs +0 -66
  58. package/build/lib/publishedPackage.mjs.map +0 -1
  59. package/build/lib/scripts.mjs +0 -10
  60. package/build/lib/scripts.mjs.map +0 -1
  61. package/build/lib/stripUtf8Bom.mjs +0 -11
  62. package/build/lib/stripUtf8Bom.mjs.map +0 -1
  63. package/build/lib/toposort.mjs +0 -26
  64. package/build/lib/toposort.mjs.map +0 -1
  65. package/build/lib/versionFile.mjs +0 -78
  66. package/build/lib/versionFile.mjs.map +0 -1
  67. package/build/lib/workspace.mjs +0 -51
  68. package/build/lib/workspace.mjs.map +0 -1
@@ -1,66 +0,0 @@
1
- import * as path from 'path';
2
- import * as fs from 'fs';
3
- import resolve from 'resolve';
4
- import { readNpmManifest } from './npmPackage.mjs';
5
- import { PACKAGE_FILE, INDEX_FILE } from './package.mjs';
6
- import { isErrorENOENT } from './error.mjs';
7
- import { stripUtf8Bom } from './stripUtf8Bom.mjs';
8
-
9
- /**
10
- * Describes the location of a single published package.
11
- *
12
- * I.e. node_modules/@intelligentgraphics/3d.ig.gfx.core
13
- *
14
- * @export
15
- * @interface PublishedPackageLocation
16
- */
17
-
18
- const detectPublishedPackageFromPath = (resolveBasePath, name) => {
19
- const manifestPath = resolve.sync(name + "/package.json", {
20
- basedir: resolveBasePath
21
- });
22
- const dir = path.dirname(manifestPath);
23
- return {
24
- _kind: "PublishedPackageLocation",
25
- path: dir
26
- };
27
- };
28
- const readPublishedPackageNpmManifest = location => {
29
- return readNpmManifest(location.path);
30
- };
31
- const readPublishedPackageCreatorManifest = location => {
32
- try {
33
- const packageJsonPath = path.join(location.path, PACKAGE_FILE);
34
- const packageJson = stripUtf8Bom(fs.readFileSync(packageJsonPath, {
35
- encoding: "utf8"
36
- }));
37
- const result = JSON.parse(packageJson);
38
- return {
39
- ...result,
40
- Scope: result.Scope || result.Package
41
- };
42
- } catch (err) {
43
- if (isErrorENOENT(err)) {
44
- return undefined;
45
- }
46
- throw err;
47
- }
48
- };
49
- const readPublishedPackageCreatorIndex = location => {
50
- try {
51
- const packageJsonPath = path.join(location.path, INDEX_FILE);
52
- const packageJson = stripUtf8Bom(fs.readFileSync(packageJsonPath, {
53
- encoding: "utf8"
54
- }));
55
- const result = JSON.parse(packageJson);
56
- return result;
57
- } catch (err) {
58
- if (isErrorENOENT(err)) {
59
- return undefined;
60
- }
61
- throw err;
62
- }
63
- };
64
-
65
- export { detectPublishedPackageFromPath, readPublishedPackageCreatorIndex, readPublishedPackageCreatorManifest, readPublishedPackageNpmManifest };
66
- //# sourceMappingURL=publishedPackage.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"publishedPackage.mjs","sources":["../../src/lib/publishedPackage.ts"],"sourcesContent":["import * as path from \"path\";\nimport * as fs from \"fs\";\nimport resolve from \"resolve\";\n\nimport { readNpmManifest } from \"./npmPackage\";\nimport {\n\tCreatorPackage,\n\tINDEX_FILE,\n\tPackageNpmManifest,\n\tPACKAGE_FILE,\n} from \"./package\";\nimport { isErrorENOENT } from \"./error\";\nimport { stripUtf8Bom } from \"./stripUtf8Bom\";\n\n/**\n * Describes the location of a single published package.\n *\n * I.e. node_modules/@intelligentgraphics/3d.ig.gfx.core\n *\n * @export\n * @interface PublishedPackageLocation\n */\nexport interface PublishedPackageLocation {\n\t_kind: \"PublishedPackageLocation\";\n\tpath: string;\n}\n\nexport const detectPublishedPackageFromPath = (\n\tresolveBasePath: string,\n\tname: string,\n): PublishedPackageLocation => {\n\tconst manifestPath = resolve.sync(name + \"/package.json\", {\n\t\tbasedir: resolveBasePath,\n\t});\n\tconst dir = path.dirname(manifestPath);\n\treturn {\n\t\t_kind: \"PublishedPackageLocation\",\n\t\tpath: dir,\n\t};\n};\n\nexport const readPublishedPackageNpmManifest = (\n\tlocation: PublishedPackageLocation,\n): PackageNpmManifest => {\n\treturn readNpmManifest<PackageNpmManifest>(location.path);\n};\n\nexport const readPublishedPackageCreatorManifest = (\n\tlocation: PublishedPackageLocation,\n): CreatorPackage | undefined => {\n\ttry {\n\t\tconst packageJsonPath = path.join(location.path, PACKAGE_FILE);\n\t\tconst packageJson = stripUtf8Bom(\n\t\t\tfs.readFileSync(packageJsonPath, {\n\t\t\t\tencoding: \"utf8\",\n\t\t\t}),\n\t\t);\n\t\tconst result: Omit<CreatorPackage, \"Scope\"> & { Scope?: string } =\n\t\t\tJSON.parse(packageJson);\n\t\treturn {\n\t\t\t...result,\n\t\t\tScope: result.Scope || result.Package,\n\t\t};\n\t} catch (err) {\n\t\tif (isErrorENOENT(err)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tthrow err;\n\t}\n};\n\nexport const readPublishedPackageCreatorIndex = (\n\tlocation: PublishedPackageLocation,\n) => {\n\ttry {\n\t\tconst packageJsonPath = path.join(location.path, INDEX_FILE);\n\t\tconst packageJson = stripUtf8Bom(\n\t\t\tfs.readFileSync(packageJsonPath, {\n\t\t\t\tencoding: \"utf8\",\n\t\t\t}),\n\t\t);\n\t\tconst result: object = JSON.parse(packageJson);\n\t\treturn result;\n\t} catch (err) {\n\t\tif (isErrorENOENT(err)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tthrow err;\n\t}\n};\n"],"names":["detectPublishedPackageFromPath","resolveBasePath","name","manifestPath","resolve","sync","basedir","dir","path","dirname","_kind","readPublishedPackageNpmManifest","location","readNpmManifest","readPublishedPackageCreatorManifest","packageJsonPath","join","PACKAGE_FILE","packageJson","stripUtf8Bom","fs","readFileSync","encoding","result","JSON","parse","Scope","Package","err","isErrorENOENT","undefined","readPublishedPackageCreatorIndex","INDEX_FILE"],"mappings":";;;;;;;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;MAMaA,8BAA8B,GAAG,CAC7CC,eAAuB,EACvBC,IAAY,KACkB;EAC9B,MAAMC,YAAY,GAAGC,OAAO,CAACC,IAAI,CAACH,IAAI,GAAG,eAAe,EAAE;AACzDI,IAAAA,OAAO,EAAEL,eAAAA;AACV,GAAC,CAAC,CAAA;AACF,EAAA,MAAMM,GAAG,GAAGC,IAAI,CAACC,OAAO,CAACN,YAAY,CAAC,CAAA;EACtC,OAAO;AACNO,IAAAA,KAAK,EAAE,0BAA0B;AACjCF,IAAAA,IAAI,EAAED,GAAAA;GACN,CAAA;AACF,EAAC;AAEYI,MAAAA,+BAA+B,GAC3CC,QAAkC,IACV;AACxB,EAAA,OAAOC,eAAe,CAAqBD,QAAQ,CAACJ,IAAI,CAAC,CAAA;AAC1D,EAAC;AAEYM,MAAAA,mCAAmC,GAC/CF,QAAkC,IACF;EAChC,IAAI;IACH,MAAMG,eAAe,GAAGP,IAAI,CAACQ,IAAI,CAACJ,QAAQ,CAACJ,IAAI,EAAES,YAAY,CAAC,CAAA;IAC9D,MAAMC,WAAW,GAAGC,YAAY,CAC/BC,EAAE,CAACC,YAAY,CAACN,eAAe,EAAE;AAChCO,MAAAA,QAAQ,EAAE,MAAA;AACX,KAAC,CAAC,CACF,CAAA;AACD,IAAA,MAAMC,MAA0D,GAC/DC,IAAI,CAACC,KAAK,CAACP,WAAW,CAAC,CAAA;IACxB,OAAO;AACN,MAAA,GAAGK,MAAM;AACTG,MAAAA,KAAK,EAAEH,MAAM,CAACG,KAAK,IAAIH,MAAM,CAACI,OAAAA;KAC9B,CAAA;GACD,CAAC,OAAOC,GAAG,EAAE;AACb,IAAA,IAAIC,aAAa,CAACD,GAAG,CAAC,EAAE;AACvB,MAAA,OAAOE,SAAS,CAAA;AACjB,KAAA;AAEA,IAAA,MAAMF,GAAG,CAAA;AACV,GAAA;AACD,EAAC;AAEYG,MAAAA,gCAAgC,GAC5CnB,QAAkC,IAC9B;EACJ,IAAI;IACH,MAAMG,eAAe,GAAGP,IAAI,CAACQ,IAAI,CAACJ,QAAQ,CAACJ,IAAI,EAAEwB,UAAU,CAAC,CAAA;IAC5D,MAAMd,WAAW,GAAGC,YAAY,CAC/BC,EAAE,CAACC,YAAY,CAACN,eAAe,EAAE;AAChCO,MAAAA,QAAQ,EAAE,MAAA;AACX,KAAC,CAAC,CACF,CAAA;AACD,IAAA,MAAMC,MAAc,GAAGC,IAAI,CAACC,KAAK,CAACP,WAAW,CAAC,CAAA;AAC9C,IAAA,OAAOK,MAAM,CAAA;GACb,CAAC,OAAOK,GAAG,EAAE;AACb,IAAA,IAAIC,aAAa,CAACD,GAAG,CAAC,EAAE;AACvB,MAAA,OAAOE,SAAS,CAAA;AACjB,KAAA;AAEA,IAAA,MAAMF,GAAG,CAAA;AACV,GAAA;AACD;;;;"}
@@ -1,10 +0,0 @@
1
- import glob from 'glob';
2
-
3
- const getPackageTypescriptFiles = location => glob.sync("**/*.ts", {
4
- absolute: true,
5
- cwd: location.scriptsDir,
6
- ignore: "node_modules/**/*"
7
- });
8
-
9
- export { getPackageTypescriptFiles };
10
- //# sourceMappingURL=scripts.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scripts.mjs","sources":["../../src/lib/scripts.ts"],"sourcesContent":["import glob from \"glob\";\n\nimport { PackageLocation } from \"./package\";\n\nexport const getPackageTypescriptFiles = (location: PackageLocation) =>\n\tglob.sync(\"**/*.ts\", {\n\t\tabsolute: true,\n\t\tcwd: location.scriptsDir,\n\t\tignore: \"node_modules/**/*\",\n\t});\n"],"names":["getPackageTypescriptFiles","location","glob","sync","absolute","cwd","scriptsDir","ignore"],"mappings":";;AAIO,MAAMA,yBAAyB,GAAIC,QAAyB,IAClEC,IAAI,CAACC,IAAI,CAAC,SAAS,EAAE;AACpBC,EAAAA,QAAQ,EAAE,IAAI;EACdC,GAAG,EAAEJ,QAAQ,CAACK,UAAU;AACxBC,EAAAA,MAAM,EAAE,mBAAA;AACT,CAAC;;;;"}
@@ -1,11 +0,0 @@
1
- const stripUtf8Bom = text => {
2
- // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
3
- // conversion translates it to FEFF (UTF-16 BOM).
4
- if (text.charCodeAt(0) === 0xfeff) {
5
- return text.slice(1);
6
- }
7
- return text;
8
- };
9
-
10
- export { stripUtf8Bom };
11
- //# sourceMappingURL=stripUtf8Bom.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stripUtf8Bom.mjs","sources":["../../src/lib/stripUtf8Bom.ts"],"sourcesContent":["export const stripUtf8Bom = (text: string) => {\n\t// Catches EFBBBF (UTF-8 BOM) because the buffer-to-string\n\t// conversion translates it to FEFF (UTF-16 BOM).\n\tif (text.charCodeAt(0) === 0xfeff) {\n\t\treturn text.slice(1);\n\t}\n\n\treturn text;\n};\n"],"names":["stripUtf8Bom","text","charCodeAt","slice"],"mappings":"AAAaA,MAAAA,YAAY,GAAIC,IAAY,IAAK;AAC7C;AACA;EACA,IAAIA,IAAI,CAACC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE;AAClC,IAAA,OAAOD,IAAI,CAACE,KAAK,CAAC,CAAC,CAAC,CAAA;AACrB,GAAA;AAEA,EAAA,OAAOF,IAAI,CAAA;AACZ;;;;"}
@@ -1,26 +0,0 @@
1
- // Stolen from ig.tools.core
2
-
3
- const toposort = packages => {
4
- const queue = Object.getOwnPropertyNames(packages);
5
- const result = [];
6
- let index = 0;
7
- while (queue.length > 0) {
8
- if (index >= queue.length) {
9
- throw new Error("Packages can not have cyclic dependencies");
10
- }
11
- const queueEntry = queue[index];
12
- const dependencies = packages[queueEntry];
13
- const dependencyQueued = dependencies.some(dependency => queue.includes(dependency));
14
- if (dependencyQueued) {
15
- index++;
16
- continue;
17
- }
18
- queue.splice(index, 1);
19
- index = 0;
20
- result.push(queueEntry);
21
- }
22
- return result;
23
- };
24
-
25
- export { toposort };
26
- //# sourceMappingURL=toposort.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toposort.mjs","sources":["../../src/lib/toposort.ts"],"sourcesContent":["// Stolen from ig.tools.core\n\nexport const toposort = (packages: Record<string, string[]>) => {\n\tconst queue = Object.getOwnPropertyNames(packages);\n\tconst result: string[] = [];\n\n\tlet index = 0;\n\n\twhile (queue.length > 0) {\n\t\tif (index >= queue.length) {\n\t\t\tthrow new Error(\"Packages can not have cyclic dependencies\");\n\t\t}\n\n\t\tconst queueEntry = queue[index];\n\n\t\tconst dependencies = packages[queueEntry];\n\t\tconst dependencyQueued = dependencies.some((dependency) =>\n\t\t\tqueue.includes(dependency),\n\t\t);\n\n\t\tif (dependencyQueued) {\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tqueue.splice(index, 1);\n\t\tindex = 0;\n\t\tresult.push(queueEntry);\n\t}\n\n\treturn result;\n};\n"],"names":["toposort","packages","queue","Object","getOwnPropertyNames","result","index","length","Error","queueEntry","dependencies","dependencyQueued","some","dependency","includes","splice","push"],"mappings":"AAAA;;AAEaA,MAAAA,QAAQ,GAAIC,QAAkC,IAAK;AAC/D,EAAA,MAAMC,KAAK,GAAGC,MAAM,CAACC,mBAAmB,CAACH,QAAQ,CAAC,CAAA;EAClD,MAAMI,MAAgB,GAAG,EAAE,CAAA;EAE3B,IAAIC,KAAK,GAAG,CAAC,CAAA;AAEb,EAAA,OAAOJ,KAAK,CAACK,MAAM,GAAG,CAAC,EAAE;AACxB,IAAA,IAAID,KAAK,IAAIJ,KAAK,CAACK,MAAM,EAAE;AAC1B,MAAA,MAAM,IAAIC,KAAK,CAAC,2CAA2C,CAAC,CAAA;AAC7D,KAAA;AAEA,IAAA,MAAMC,UAAU,GAAGP,KAAK,CAACI,KAAK,CAAC,CAAA;AAE/B,IAAA,MAAMI,YAAY,GAAGT,QAAQ,CAACQ,UAAU,CAAC,CAAA;AACzC,IAAA,MAAME,gBAAgB,GAAGD,YAAY,CAACE,IAAI,CAAEC,UAAU,IACrDX,KAAK,CAACY,QAAQ,CAACD,UAAU,CAAC,CAC1B,CAAA;AAED,IAAA,IAAIF,gBAAgB,EAAE;AACrBL,MAAAA,KAAK,EAAE,CAAA;AACP,MAAA,SAAA;AACD,KAAA;AAEAJ,IAAAA,KAAK,CAACa,MAAM,CAACT,KAAK,EAAE,CAAC,CAAC,CAAA;AACtBA,IAAAA,KAAK,GAAG,CAAC,CAAA;AACTD,IAAAA,MAAM,CAACW,IAAI,CAACP,UAAU,CAAC,CAAA;AACxB,GAAA;AAEA,EAAA,OAAOJ,MAAM,CAAA;AACd;;;;"}
@@ -1,78 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { isErrorENOENT } from './error.mjs';
4
- import { readStringFromFileOrUndefined } from './fs.mjs';
5
-
6
- // https://regex101.com/r/LtGAu5/1
7
- const logRegex = /console\.log\(\s*"([\w\s\.\(\)]+)\ *Copyright[\w\s\(\)\.]+(\d{4}|\d{4} - \d{4})([\w\s\(\)\.]+)?",?\s*\)/i;
8
- const currentYear = new Date(Date.now()).getFullYear();
9
- const getVersionFileHandler = location => {
10
- const filePath = path.join(location.scriptsDir, "Version.ts");
11
- const invalidVersionFile = versionFile => ({
12
- version: undefined,
13
- write: (name, newVersion) => {
14
- const scriptsContent = fs.readdirSync(location.scriptsDir);
15
- const tsFiles = scriptsContent.filter(file => file.endsWith(".ts"));
16
- if (tsFiles.length > 0) {
17
- return createVersionFileWriter([currentYear], "")(name, newVersion);
18
- }
19
- },
20
- reset: () => {
21
- if (versionFile !== undefined) {
22
- fs.writeFileSync(filePath, versionFile, {
23
- encoding: "utf8"
24
- });
25
- } else {
26
- try {
27
- fs.rmSync(filePath);
28
- } catch (err) {
29
- if (!isErrorENOENT(err)) {
30
- throw err;
31
- }
32
- }
33
- }
34
- }
35
- });
36
- const createVersionFileWriter = (copyright = [currentYear], copyrightStuff = "") => (name, newVersion) => {
37
- const descriptionText = newVersion.toDescriptionString(name);
38
- const copyrightText = createYearString(copyright);
39
- const result = `console.log("${descriptionText}. Copyright (C) ${copyrightText}${copyrightStuff}");`;
40
- fs.writeFileSync(filePath, result, {
41
- encoding: "utf-8"
42
- });
43
- };
44
- let rawVersionFile = readStringFromFileOrUndefined(filePath);
45
- if (rawVersionFile === undefined) {
46
- return invalidVersionFile(rawVersionFile);
47
- }
48
- const versionFile = rawVersionFile.replace(/\n/g, "");
49
- const match = versionFile.match(logRegex);
50
- if (!match) {
51
- return invalidVersionFile(versionFile);
52
- }
53
- const [_full, _description, copyright, copyrightStuff] = match;
54
- const copyrightYears = copyright.match(/^(\d+)( ?- ?(\d+))?$/);
55
- let years;
56
- if (copyrightYears === null) {
57
- years = [currentYear];
58
- } else {
59
- years = [Number(copyrightYears[1]), currentYear];
60
- }
61
- return {
62
- write: createVersionFileWriter(years, copyrightStuff),
63
- reset: () => {
64
- fs.writeFileSync(filePath, versionFile, {
65
- encoding: "utf8"
66
- });
67
- }
68
- };
69
- };
70
- const createYearString = years => {
71
- if (years[1] === undefined || years[0] === years[1]) {
72
- return years[0].toString();
73
- }
74
- return `${years[0]} - ${years[1]}`;
75
- };
76
-
77
- export { getVersionFileHandler };
78
- //# sourceMappingURL=versionFile.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"versionFile.mjs","sources":["../../src/lib/versionFile.ts"],"sourcesContent":["import * as fs from \"fs\";\nimport * as path from \"path\";\n\nimport { isErrorENOENT } from \"./error\";\nimport { readStringFromFileOrUndefined } from \"./fs\";\nimport { PackageLocation } from \"./package\";\nimport { PackageVersion } from \"./packageVersion\";\n\n// https://regex101.com/r/LtGAu5/1\nconst logRegex =\n\t/console\\.log\\(\\s*\"([\\w\\s\\.\\(\\)]+)\\ *Copyright[\\w\\s\\(\\)\\.]+(\\d{4}|\\d{4} - \\d{4})([\\w\\s\\(\\)\\.]+)?\",?\\s*\\)/i;\nconst currentYear = new Date(Date.now()).getFullYear();\n\nexport const getVersionFileHandler = (location: PackageLocation) => {\n\tconst filePath = path.join(location.scriptsDir, \"Version.ts\");\n\n\tconst invalidVersionFile = (versionFile: string | undefined) => ({\n\t\tversion: undefined,\n\t\twrite: (name: string, newVersion: PackageVersion) => {\n\t\t\tconst scriptsContent = fs.readdirSync(location.scriptsDir);\n\t\t\tconst tsFiles = scriptsContent.filter((file) =>\n\t\t\t\tfile.endsWith(\".ts\"),\n\t\t\t);\n\n\t\t\tif (tsFiles.length > 0) {\n\t\t\t\treturn createVersionFileWriter([currentYear], \"\")(\n\t\t\t\t\tname,\n\t\t\t\t\tnewVersion,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\treset: () => {\n\t\t\tif (versionFile !== undefined) {\n\t\t\t\tfs.writeFileSync(filePath, versionFile, { encoding: \"utf8\" });\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tfs.rmSync(filePath);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tif (!isErrorENOENT(err)) {\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t});\n\n\ttype CopyrightRange = [number, number?];\n\n\tconst createVersionFileWriter =\n\t\t(\n\t\t\tcopyright: CopyrightRange = [currentYear],\n\t\t\tcopyrightStuff: string = \"\",\n\t\t) =>\n\t\t(name: string, newVersion: PackageVersion) => {\n\t\t\tconst descriptionText = newVersion.toDescriptionString(name);\n\t\t\tconst copyrightText = createYearString(copyright);\n\n\t\t\tconst result = `console.log(\"${descriptionText}. Copyright (C) ${copyrightText}${copyrightStuff}\");`;\n\n\t\t\tfs.writeFileSync(filePath, result, { encoding: \"utf-8\" });\n\t\t};\n\n\tlet rawVersionFile = readStringFromFileOrUndefined(filePath);\n\n\tif (rawVersionFile === undefined) {\n\t\treturn invalidVersionFile(rawVersionFile);\n\t}\n\n\tconst versionFile = rawVersionFile.replace(/\\n/g, \"\");\n\n\tconst match = versionFile.match(logRegex);\n\n\tif (!match) {\n\t\treturn invalidVersionFile(versionFile);\n\t}\n\n\tconst [_full, _description, copyright, copyrightStuff] = match as [\n\t\tstring,\n\t\tstring,\n\t\tstring,\n\t\tstring?,\n\t];\n\n\tconst copyrightYears = copyright.match(/^(\\d+)( ?- ?(\\d+))?$/);\n\n\tlet years: [number, number?];\n\n\tif (copyrightYears === null) {\n\t\tyears = [currentYear];\n\t} else {\n\t\tyears = [Number(copyrightYears[1]), currentYear];\n\t}\n\n\treturn {\n\t\twrite: createVersionFileWriter(years, copyrightStuff),\n\t\treset: () => {\n\t\t\tfs.writeFileSync(filePath, versionFile, { encoding: \"utf8\" });\n\t\t},\n\t};\n};\n\nconst createYearString = (years: [number, number?]) => {\n\tif (years[1] === undefined || years[0] === years[1]) {\n\t\treturn years[0].toString();\n\t}\n\n\treturn `${years[0]} - ${years[1]}`;\n};\n"],"names":["logRegex","currentYear","Date","now","getFullYear","getVersionFileHandler","location","filePath","path","join","scriptsDir","invalidVersionFile","versionFile","version","undefined","write","name","newVersion","scriptsContent","fs","readdirSync","tsFiles","filter","file","endsWith","length","createVersionFileWriter","reset","writeFileSync","encoding","rmSync","err","isErrorENOENT","copyright","copyrightStuff","descriptionText","toDescriptionString","copyrightText","createYearString","result","rawVersionFile","readStringFromFileOrUndefined","replace","match","_full","_description","copyrightYears","years","Number","toString"],"mappings":";;;;;AAQA;AACA,MAAMA,QAAQ,GACb,0GAA0G,CAAA;AAC3G,MAAMC,WAAW,GAAG,IAAIC,IAAI,CAACA,IAAI,CAACC,GAAG,EAAE,CAAC,CAACC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AAC,CAAC,CAAC,CAAC,EAAE7C,WAAW,CAAC,CAAA;AACjD,GAAA;EAEA,OAAO;AACNc,IAAAA,KAAK,EAAEW,uBAAuB,CAACqB,KAAK,EAAEb,cAAc,CAAC;AACrDP,IAAAA,KAAK,EAAE,MAAM;AACZR,MAAAA,EAAE,CAACS,aAAa,CAACrB,QAAQ,EAAEK,WAAW,EAAE;AAAEiB,QAAAA,QAAQ,EAAE,MAAA;AAAO,OAAC,CAAC,CAAA;AAC9D,KAAA;GACA,CAAA;AACF,EAAC;AAED,MAAMS,gBAAgB,GAAIS,KAAwB,IAAK;AACtD,EAAA,IAAIA,KAAK,CAAC,CAAC,CAAC,KAAKjC,SAAS,IAAIiC,KAAK,CAAC,CAAC,CAAC,KAAKA,KAAK,CAAC,CAAC,CAAC,EAAE;AACpD,IAAA,OAAOA,KAAK,CAAC,CAAC,CAAC,CAACE,QAAQ,EAAE,CAAA;AAC3B,GAAA;EAEA,OAAQ,CAAA,EAAEF,KAAK,CAAC,CAAC,CAAE,MAAKA,KAAK,CAAC,CAAC,CAAE,CAAC,CAAA,CAAA;AACnC,CAAC;;;;"}
@@ -1,51 +0,0 @@
1
- import * as path from 'path';
2
- import * as fs from 'fs';
3
- import { isErrorENOENT } from './error.mjs';
4
- import { readNpmManifest, writeNpmManifest } from './npmPackage.mjs';
5
- import { detectPackage } from './package.mjs';
6
-
7
- // Functionality related to working with a workspace consisting of multiple packages.
8
-
9
- /**
10
- * Describe the location of a workspace constining of n packages.
11
- *
12
- * @export
13
- * @interface WorkspaceLocation
14
- */
15
-
16
- const detectWorkspace = directory => {
17
- directory = path.resolve(process.cwd(), directory);
18
- return {
19
- _kind: "WorkspaceLocation",
20
- path: directory
21
- };
22
- };
23
- const readWorkspaceNpmManifest = workspace => {
24
- try {
25
- return readNpmManifest(workspace.path);
26
- } catch (err) {
27
- if (isErrorENOENT(err)) {
28
- return undefined;
29
- }
30
- throw err;
31
- }
32
- };
33
- const writeWorkspaceNpmManifest = (workspace, packageJson) => writeNpmManifest(workspace.path, packageJson);
34
- const getWorkspaceOutputPath = workspace => path.join(workspace.path, "bin");
35
- const getWorkspaceLibPath = workspace => path.join(workspace.path, "lib");
36
- function* iterateWorkspacePackages(workspace) {
37
- const entries = fs.readdirSync(workspace.path, {
38
- withFileTypes: true
39
- });
40
- for (const entry of entries) {
41
- if (!entry.isDirectory()) {
42
- continue;
43
- }
44
- try {
45
- yield detectPackage(workspace, entry.name);
46
- } catch {}
47
- }
48
- }
49
-
50
- export { detectWorkspace, getWorkspaceLibPath, getWorkspaceOutputPath, iterateWorkspacePackages, readWorkspaceNpmManifest, writeWorkspaceNpmManifest };
51
- //# sourceMappingURL=workspace.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workspace.mjs","sources":["../../src/lib/workspace.ts"],"sourcesContent":["// Functionality related to working with a workspace consisting of multiple packages.\n\nimport * as path from \"path\";\nimport * as fs from \"fs\";\n\nimport { PackageJSON } from \"./packageJSON\";\nimport { isErrorENOENT } from \"./error\";\nimport { readNpmManifest, writeNpmManifest } from \"./npmPackage\";\nimport { detectPackage } from \"./package\";\n\n/**\n * Describe the location of a workspace constining of n packages.\n *\n * @export\n * @interface WorkspaceLocation\n */\nexport interface WorkspaceLocation {\n\t_kind: \"WorkspaceLocation\";\n\tpath: string;\n}\n\nexport interface WorkspacePackageJSON extends PackageJSON {\n\tpackager?: { banner?: string };\n}\n\nexport const detectWorkspace = (directory: string): WorkspaceLocation => {\n\tdirectory = path.resolve(process.cwd(), directory);\n\treturn {\n\t\t_kind: \"WorkspaceLocation\",\n\t\tpath: directory,\n\t};\n};\n\nexport const readWorkspaceNpmManifest = (\n\tworkspace: WorkspaceLocation,\n): WorkspacePackageJSON | undefined => {\n\ttry {\n\t\treturn readNpmManifest<WorkspacePackageJSON>(workspace.path);\n\t} catch (err) {\n\t\tif (isErrorENOENT(err)) {\n\t\t\treturn undefined;\n\t\t}\n\t\tthrow err;\n\t}\n};\n\nexport const writeWorkspaceNpmManifest = <T extends WorkspacePackageJSON>(\n\tworkspace: WorkspaceLocation,\n\tpackageJson: T,\n) => writeNpmManifest(workspace.path, packageJson);\n\nexport const getWorkspaceOutputPath = (workspace: WorkspaceLocation) =>\n\tpath.join(workspace.path, \"bin\");\n\nexport const getWorkspaceLibPath = (workspace: WorkspaceLocation) =>\n\tpath.join(workspace.path, \"lib\");\n\nexport function* iterateWorkspacePackages(workspace: WorkspaceLocation) {\n\tconst entries = fs.readdirSync(workspace.path, { withFileTypes: true });\n\n\tfor (const entry of entries) {\n\t\tif (!entry.isDirectory()) {\n\t\t\tcontinue;\n\t\t}\n\n\t\ttry {\n\t\t\tyield detectPackage(workspace, entry.name);\n\t\t} catch {}\n\t}\n}\n"],"names":["detectWorkspace","directory","path","resolve","process","cwd","_kind","readWorkspaceNpmManifest","workspace","readNpmManifest","err","isErrorENOENT","undefined","writeWorkspaceNpmManifest","packageJson","writeNpmManifest","getWorkspaceOutputPath","join","getWorkspaceLibPath","iterateWorkspacePackages","entries","fs","readdirSync","withFileTypes","entry","isDirectory","detectPackage","name"],"mappings":";;;;;;AAAA;;AAUA;AACA;AACA;AACA;AACA;AACA;;AAUaA,MAAAA,eAAe,GAAIC,SAAiB,IAAwB;EACxEA,SAAS,GAAGC,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,GAAG,EAAE,EAAEJ,SAAS,CAAC,CAAA;EAClD,OAAO;AACNK,IAAAA,KAAK,EAAE,mBAAmB;AAC1BJ,IAAAA,IAAI,EAAED,SAAAA;GACN,CAAA;AACF,EAAC;AAEYM,MAAAA,wBAAwB,GACpCC,SAA4B,IACU;EACtC,IAAI;AACH,IAAA,OAAOC,eAAe,CAAuBD,SAAS,CAACN,IAAI,CAAC,CAAA;GAC5D,CAAC,OAAOQ,GAAG,EAAE;AACb,IAAA,IAAIC,aAAa,CAACD,GAAG,CAAC,EAAE;AACvB,MAAA,OAAOE,SAAS,CAAA;AACjB,KAAA;AACA,IAAA,MAAMF,GAAG,CAAA;AACV,G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