@intelligentgraphics/ig.gfx.packager 3.1.4 → 3.2.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 (61) hide show
  1. package/build/bin.js +7 -0
  2. package/build/bin.js.map +1 -0
  3. package/build/build-CMbCj7x-.js +945 -0
  4. package/build/build-CMbCj7x-.js.map +1 -0
  5. package/build/build-kkMVBBJL.js +408 -0
  6. package/build/build-kkMVBBJL.js.map +1 -0
  7. package/build/cli-Co1DhAmx.js +405 -0
  8. package/build/cli-Co1DhAmx.js.map +1 -0
  9. package/build/docs-BkGeoYY2.js +30 -0
  10. package/build/docs-BkGeoYY2.js.map +1 -0
  11. package/build/generateIndex-C_DxQ2R4.js +209 -0
  12. package/build/generateIndex-C_DxQ2R4.js.map +1 -0
  13. package/build/generateParameterType-CdCi5BWM.js +46 -0
  14. package/build/generateParameterType-CdCi5BWM.js.map +1 -0
  15. package/build/package-DHx2bvVO.js +1 -0
  16. package/build/postinstall-DHTlEmNr.js +35 -0
  17. package/build/postinstall-DHTlEmNr.js.map +1 -0
  18. package/build/prompter-DONgUlzS.js +20 -0
  19. package/build/prompter-DONgUlzS.js.map +1 -0
  20. package/build/publish-E5zcQAo0.js +348 -0
  21. package/build/publish-E5zcQAo0.js.map +1 -0
  22. package/build/publishNpm-CBT1819u.js +115 -0
  23. package/build/publishNpm-CBT1819u.js.map +1 -0
  24. package/build/publishedPackage-D-KiU0FG.js +1 -0
  25. package/build/rollup-Csyght27.js +179 -0
  26. package/build/rollup-Csyght27.js.map +1 -0
  27. package/build/scripts-CBblHIL1.js +29 -0
  28. package/build/scripts-CBblHIL1.js.map +1 -0
  29. package/build/versionFile-DViDwgCa.js +123 -0
  30. package/build/versionFile-DViDwgCa.js.map +1 -0
  31. package/build/workspace-D0XY2EMu.js +1 -0
  32. package/lib/lib.js +1595 -0
  33. package/package.json +30 -30
  34. package/readme.md +5 -0
  35. package/build/bin.mjs +0 -5
  36. package/build/bin.mjs.map +0 -1
  37. package/build/cli-CTqQeYIu.mjs +0 -768
  38. package/build/cli-CTqQeYIu.mjs.map +0 -1
  39. package/build/dependencies-CCIr5dgH.mjs +0 -129
  40. package/build/dependencies-CCIr5dgH.mjs.map +0 -1
  41. package/build/docs-DvFV9WXA.mjs +0 -37
  42. package/build/docs-DvFV9WXA.mjs.map +0 -1
  43. package/build/generateIndex-COnAgsMM.mjs +0 -306
  44. package/build/generateIndex-COnAgsMM.mjs.map +0 -1
  45. package/build/generateParameterType-BFVUv72F.mjs +0 -71
  46. package/build/generateParameterType-BFVUv72F.mjs.map +0 -1
  47. package/build/index-Ck4_b8Wk.mjs +0 -1400
  48. package/build/index-Ck4_b8Wk.mjs.map +0 -1
  49. package/build/index-DHSUlJia.mjs +0 -477
  50. package/build/index-DHSUlJia.mjs.map +0 -1
  51. package/build/postinstall-BTuIhY_F.mjs +0 -61
  52. package/build/postinstall-BTuIhY_F.mjs.map +0 -1
  53. package/build/publishNpm-A02qW1UY.mjs +0 -167
  54. package/build/publishNpm-A02qW1UY.mjs.map +0 -1
  55. package/build/rollup-BeQ0dM8U.mjs +0 -221
  56. package/build/rollup-BeQ0dM8U.mjs.map +0 -1
  57. package/build/scripts-B3noxiX3.mjs +0 -45
  58. package/build/scripts-B3noxiX3.mjs.map +0 -1
  59. package/build/versionFile-B9z_qwQL.mjs +0 -206
  60. package/build/versionFile-B9z_qwQL.mjs.map +0 -1
  61. package/lib/lib.mjs +0 -2706
@@ -0,0 +1,179 @@
1
+ import "./build-kkMVBBJL.js";
2
+ import { r as resolveScriptPackageEntryModule } from "./scripts-CBblHIL1.js";
3
+ import * as path from "node:path";
4
+ import resolve from "resolve";
5
+ import * as os from "node:os";
6
+ import ts from "typescript";
7
+ import { rollup, watch } from "rollup";
8
+ import rollupPluginNodeResolve from "@rollup/plugin-node-resolve";
9
+ import rollupPluginTypescript from "@rollup/plugin-typescript";
10
+ import rollupPluginBabel from "@rollup/plugin-babel";
11
+ import rollupPluginCommonJs from "@rollup/plugin-commonjs";
12
+ import rollupPluginJson from "@rollup/plugin-json";
13
+ import rollupPluginAlias from "@rollup/plugin-alias";
14
+ import babelPresetEnv from "@babel/preset-env";
15
+ import { bundleFromEntryFile } from "@intelligentgraphics/declarationbundler";
16
+ //#region src/commands/build/rollup.ts
17
+ function createRollupBuildParticipant(location, manifest, outDir, skipDeclarations) {
18
+ return (env) => {
19
+ env.onBuildStart();
20
+ (async () => {
21
+ try {
22
+ const rollupConfig = getRollupConfig(location, manifest, outDir, skipDeclarations, env);
23
+ const output = await (await rollup(rollupConfig)).generate(rollupConfig.output);
24
+ env.onBuildEnd({
25
+ type: "success",
26
+ artefacts: processRollupOutput(output, location, manifest, rollupConfig.input, skipDeclarations)
27
+ });
28
+ } catch (err) {
29
+ env.onBuildEnd({
30
+ type: "error",
31
+ error: err instanceof Error ? err : new Error(String(err))
32
+ });
33
+ }
34
+ })();
35
+ return { destroy: () => {} };
36
+ };
37
+ }
38
+ function createRollupWatchBuildParticipant(location, manifest, outDir, skipDeclarations) {
39
+ return (env) => {
40
+ env.onBuildStart();
41
+ const rollupConfig = getRollupConfig(location, manifest, outDir, skipDeclarations, env);
42
+ const watcher = watch({
43
+ ...rollupConfig,
44
+ watch: { skipWrite: true }
45
+ });
46
+ watcher.on("event", async (event) => {
47
+ switch (event.code) {
48
+ case "BUNDLE_START":
49
+ env.onBuildStart();
50
+ break;
51
+ case "BUNDLE_END":
52
+ const output = await event.result.generate(rollupConfig.output);
53
+ try {
54
+ env.onBuildEnd({
55
+ type: "success",
56
+ artefacts: processRollupOutput(output, location, manifest, rollupConfig.input, skipDeclarations)
57
+ });
58
+ } catch (err) {
59
+ env.onBuildEnd({
60
+ type: "error",
61
+ error: err instanceof Error ? err : new Error(String(err))
62
+ });
63
+ }
64
+ event.result.close();
65
+ break;
66
+ case "ERROR":
67
+ env.onBuildEnd({
68
+ type: "error",
69
+ error: Object.assign(new Error(event.error.message), event.error)
70
+ });
71
+ break;
72
+ }
73
+ });
74
+ return { destroy: () => watcher.close() };
75
+ };
76
+ }
77
+ function getRollupConfig(location, manifest, outDir, skipDeclarations, env) {
78
+ const entryModule = resolveScriptPackageEntryModule(location, manifest);
79
+ if (entryModule === void 0) throw new Error(`Could not find an entry module`);
80
+ return {
81
+ input: entryModule,
82
+ plugins: [
83
+ rollupPluginNodeResolve(),
84
+ rollupPluginCommonJs(),
85
+ rollupPluginJson(),
86
+ rollupPluginAlias({ entries: [{
87
+ find: /^core-js(.*)/,
88
+ replacement: path.join(path.dirname(resolve.sync("core-js", { basedir: import.meta.dirname })), "/$1")
89
+ }] }),
90
+ rollupPluginTypescript({
91
+ compilerOptions: {
92
+ rootDir: skipDeclarations ? void 0 : location.scriptsDir,
93
+ declaration: !skipDeclarations,
94
+ declarationDir: skipDeclarations ? void 0 : outDir,
95
+ module: "esnext",
96
+ target: "esnext"
97
+ },
98
+ tsconfig: path.join(location.scriptsDir, "tsconfig.json"),
99
+ removeComments: false,
100
+ filterRoot: skipDeclarations ? false : void 0,
101
+ incremental: false,
102
+ noEmitOnError: false
103
+ }),
104
+ rollupPluginBabel({
105
+ presets: [[babelPresetEnv, {
106
+ corejs: "3",
107
+ include: [
108
+ "transform-classes",
109
+ "transform-class-properties",
110
+ "transform-private-methods",
111
+ "transform-class-static-block"
112
+ ]
113
+ }]],
114
+ targets: ["defaults", "not IE 11"],
115
+ babelHelpers: "bundled",
116
+ extensions: [".ts", ".js"],
117
+ sourceMaps: true,
118
+ exclude: /core-js/
119
+ })
120
+ ],
121
+ output: {
122
+ format: "iife",
123
+ name: manifest.Scope ?? manifest.Package,
124
+ dir: outDir,
125
+ sourcemap: "hidden",
126
+ extend: true
127
+ },
128
+ onLog: createLogger(env)
129
+ };
130
+ }
131
+ function createLogger(env) {
132
+ return (level, log, _handler) => {
133
+ env.log(log.message);
134
+ };
135
+ }
136
+ function processRollupOutput(output, location, manifest, entryModulePath, skipDeclarations) {
137
+ const [primaryChunk, ...otherOutputs] = output.output;
138
+ const assets = otherOutputs.filter((chunk) => chunk.type === "asset");
139
+ const sourceMap = assets.find((asset) => asset.fileName.endsWith(".js.map"));
140
+ let declarations;
141
+ if (!skipDeclarations) declarations = bundleTSDeclarations(new Map(assets.filter((asset) => asset.fileName.endsWith(".d.ts")).map((asset) => {
142
+ return [path.resolve(location.scriptsDir, asset.fileName).replaceAll("\\", "/"), asset.source];
143
+ })), path.join(path.dirname(entryModulePath), path.basename(entryModulePath, path.extname(entryModulePath)) + ".d.ts"), manifest.Scope ?? manifest.Package);
144
+ return {
145
+ js: primaryChunk.code,
146
+ declarations,
147
+ sourceMap: sourceMap?.source
148
+ };
149
+ }
150
+ const referenceRegex = /(\/\/\/ ?<reference .+\/>$)/;
151
+ function bundleTSDeclarations(files, entryFileName, namespace) {
152
+ const references = [];
153
+ for (const [_fileName, content] of files) {
154
+ if (content.indexOf("reference") === -1) continue;
155
+ const lines = content.split(os.EOL);
156
+ for (let index = 0; index < lines.length; index++) {
157
+ const match = lines[index].match(referenceRegex);
158
+ if (match === null) continue;
159
+ if (!references.includes(match[1])) references.push(match[1]);
160
+ }
161
+ }
162
+ const compilerOptions = { removeComments: false };
163
+ const host = ts.createCompilerHost(compilerOptions, true);
164
+ host.fileExists = (fileName) => files.has(fileName);
165
+ host.readFile = (fileName) => files.get(fileName);
166
+ const program = ts.createProgram({
167
+ host,
168
+ options: compilerOptions,
169
+ rootNames: [entryFileName]
170
+ });
171
+ const mainFile = program.getSourceFile(entryFileName);
172
+ if (mainFile === void 0) throw new Error(`Unexpected: Failed to find compiled declaration entry module`);
173
+ const result = bundleFromEntryFile(namespace, mainFile, program, host, program.getTypeChecker(), compilerOptions);
174
+ return [...references, result].join(os.EOL);
175
+ }
176
+ //#endregion
177
+ export { createRollupBuildParticipant, createRollupWatchBuildParticipant };
178
+
179
+ //# sourceMappingURL=rollup-Csyght27.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup-Csyght27.js","names":[],"sources":["../src/commands/build/rollup.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport ts from \"typescript\";\nimport * as os from \"node:os\";\nimport resolve from \"resolve\";\nimport { rollup, watch, type RollupOutput, type RollupOptions } from \"rollup\";\nimport rollupPluginNodeResolve from \"@rollup/plugin-node-resolve\";\nimport rollupPluginTypescript from \"@rollup/plugin-typescript\";\nimport rollupPluginBabel from \"@rollup/plugin-babel\";\nimport rollupPluginCommonJs from \"@rollup/plugin-commonjs\";\nimport rollupPluginJson from \"@rollup/plugin-json\";\nimport rollupPluginAlias from \"@rollup/plugin-alias\";\nimport babelPresetEnv, {\n\ttype Options as PresetEnvOptions,\n} from \"@babel/preset-env\";\n\nimport { bundleFromEntryFile } from \"@intelligentgraphics/declarationbundler\";\n\nimport type { CreatorPackage, PackageLocation } from \"../../lib/package\";\nimport type {\n\tBuildArtefacts,\n\tBuilderEnvironment,\n\tBuildParticipant,\n} from \"./types\";\nimport { resolveScriptPackageEntryModule } from \"../../lib/scripts\";\n\nexport function createRollupBuildParticipant(\n\tlocation: PackageLocation,\n\tmanifest: CreatorPackage,\n\toutDir: string,\n\tskipDeclarations: boolean,\n): BuildParticipant {\n\treturn (env: BuilderEnvironment) => {\n\t\tenv.onBuildStart();\n\n\t\t(async () => {\n\t\t\ttry {\n\t\t\t\tconst rollupConfig = getRollupConfig(\n\t\t\t\t\tlocation,\n\t\t\t\t\tmanifest,\n\t\t\t\t\toutDir,\n\t\t\t\t\tskipDeclarations,\n\t\t\t\t\tenv,\n\t\t\t\t);\n\n\t\t\t\tconst build = await rollup(rollupConfig);\n\n\t\t\t\tconst output = await build.generate(rollupConfig.output);\n\n\t\t\t\tenv.onBuildEnd({\n\t\t\t\t\ttype: \"success\",\n\t\t\t\t\tartefacts: processRollupOutput(\n\t\t\t\t\t\toutput,\n\t\t\t\t\t\tlocation,\n\t\t\t\t\t\tmanifest,\n\t\t\t\t\t\trollupConfig.input,\n\t\t\t\t\t\tskipDeclarations,\n\t\t\t\t\t),\n\t\t\t\t});\n\t\t\t} catch (err) {\n\t\t\t\tenv.onBuildEnd({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\terror: err instanceof Error ? err : new Error(String(err)),\n\t\t\t\t});\n\t\t\t}\n\t\t})();\n\n\t\treturn {\n\t\t\tdestroy: () => {},\n\t\t};\n\t};\n}\n\nexport function createRollupWatchBuildParticipant(\n\tlocation: PackageLocation,\n\tmanifest: CreatorPackage,\n\toutDir: string,\n\tskipDeclarations: boolean,\n): BuildParticipant {\n\treturn (env: BuilderEnvironment) => {\n\t\tenv.onBuildStart();\n\n\t\tconst rollupConfig = getRollupConfig(\n\t\t\tlocation,\n\t\t\tmanifest,\n\t\t\toutDir,\n\t\t\tskipDeclarations,\n\t\t\tenv,\n\t\t);\n\n\t\tconst watcher = watch({\n\t\t\t...rollupConfig,\n\t\t\twatch: {\n\t\t\t\tskipWrite: true,\n\t\t\t},\n\t\t});\n\n\t\twatcher.on(\"event\", async (event) => {\n\t\t\tswitch (event.code) {\n\t\t\t\tcase \"BUNDLE_START\":\n\t\t\t\t\tenv.onBuildStart();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"BUNDLE_END\":\n\t\t\t\t\tconst output = await event.result.generate(\n\t\t\t\t\t\trollupConfig.output!,\n\t\t\t\t\t);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tenv.onBuildEnd({\n\t\t\t\t\t\t\ttype: \"success\",\n\t\t\t\t\t\t\tartefacts: processRollupOutput(\n\t\t\t\t\t\t\t\toutput,\n\t\t\t\t\t\t\t\tlocation,\n\t\t\t\t\t\t\t\tmanifest,\n\t\t\t\t\t\t\t\trollupConfig.input,\n\t\t\t\t\t\t\t\tskipDeclarations,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tenv.onBuildEnd({\n\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\terr instanceof Error\n\t\t\t\t\t\t\t\t\t? err\n\t\t\t\t\t\t\t\t\t: new Error(String(err)),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tevent.result.close();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"ERROR\":\n\t\t\t\t\tenv.onBuildEnd({\n\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\terror: Object.assign(\n\t\t\t\t\t\t\tnew Error(event.error.message),\n\t\t\t\t\t\t\tevent.error,\n\t\t\t\t\t\t),\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t});\n\n\t\treturn {\n\t\t\tdestroy: () => watcher.close(),\n\t\t};\n\t};\n}\n\nfunction getRollupConfig(\n\tlocation: PackageLocation,\n\tmanifest: CreatorPackage,\n\toutDir: string,\n\tskipDeclarations: boolean,\n\tenv: BuilderEnvironment,\n) {\n\tconst entryModule = resolveScriptPackageEntryModule(location, manifest);\n\n\tif (entryModule === undefined) {\n\t\tthrow new Error(`Could not find an entry module`);\n\t}\n\n\treturn {\n\t\tinput: entryModule,\n\t\tplugins: [\n\t\t\trollupPluginNodeResolve(),\n\t\t\trollupPluginCommonJs(),\n\t\t\trollupPluginJson(),\n\t\t\trollupPluginAlias({\n\t\t\t\tentries: [\n\t\t\t\t\t{\n\t\t\t\t\t\tfind: /^core-js(.*)/,\n\t\t\t\t\t\treplacement: path.join(\n\t\t\t\t\t\t\tpath.dirname(\n\t\t\t\t\t\t\t\tresolve.sync(\"core-js\", {\n\t\t\t\t\t\t\t\t\tbasedir: import.meta.dirname,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\"/$1\",\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}),\n\t\t\trollupPluginTypescript({\n\t\t\t\tcompilerOptions: {\n\t\t\t\t\trootDir: skipDeclarations ? undefined : location.scriptsDir,\n\t\t\t\t\tdeclaration: !skipDeclarations,\n\t\t\t\t\tdeclarationDir: skipDeclarations ? undefined : outDir,\n\t\t\t\t\tmodule: \"esnext\",\n\t\t\t\t\ttarget: \"esnext\",\n\t\t\t\t},\n\t\t\t\ttsconfig: path.join(location.scriptsDir, \"tsconfig.json\"),\n\t\t\t\tremoveComments: false,\n\t\t\t\tfilterRoot: skipDeclarations ? false : undefined,\n\t\t\t\tincremental: false,\n\t\t\t\tnoEmitOnError: false,\n\t\t\t}),\n\t\t\trollupPluginBabel({\n\t\t\t\tpresets: [\n\t\t\t\t\t[\n\t\t\t\t\t\tbabelPresetEnv,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcorejs: \"3\",\n\t\t\t\t\t\t\tinclude: [\n\t\t\t\t\t\t\t\t\"transform-classes\",\n\t\t\t\t\t\t\t\t\"transform-class-properties\",\n\t\t\t\t\t\t\t\t\"transform-private-methods\",\n\t\t\t\t\t\t\t\t\"transform-class-static-block\",\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t} satisfies PresetEnvOptions,\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t\ttargets: [\"defaults\", \"not IE 11\"],\n\t\t\t\tbabelHelpers: \"bundled\",\n\t\t\t\textensions: [\".ts\", \".js\"],\n\t\t\t\tsourceMaps: true,\n\t\t\t\texclude: /core-js/,\n\t\t\t}),\n\t\t],\n\t\toutput: {\n\t\t\tformat: \"iife\",\n\t\t\tname: manifest.Scope ?? manifest.Package,\n\t\t\tdir: outDir,\n\t\t\tsourcemap: \"hidden\",\n\t\t\textend: true,\n\t\t},\n\t\tonLog: createLogger(env),\n\t} satisfies RollupOptions;\n}\n\nfunction createLogger(env: BuilderEnvironment): RollupOptions[\"onLog\"] {\n\treturn (level, log, _handler) => {\n\t\tenv.log(log.message);\n\t};\n}\n\nfunction processRollupOutput(\n\toutput: RollupOutput,\n\tlocation: PackageLocation,\n\tmanifest: CreatorPackage,\n\tentryModulePath: string,\n\tskipDeclarations: boolean,\n): BuildArtefacts {\n\tconst [primaryChunk, ...otherOutputs] = output.output;\n\n\tconst assets = otherOutputs.filter((chunk) => chunk.type === \"asset\");\n\n\tconst sourceMap = assets.find((asset) =>\n\t\tasset.fileName.endsWith(\".js.map\"),\n\t);\n\n\tlet declarations: string | undefined;\n\n\tif (!skipDeclarations) {\n\t\tconst declarationFileMap = new Map(\n\t\t\tassets\n\t\t\t\t.filter((asset) => asset.fileName.endsWith(\".d.ts\"))\n\t\t\t\t.map((asset) => {\n\t\t\t\t\treturn [\n\t\t\t\t\t\tpath\n\t\t\t\t\t\t\t.resolve(location.scriptsDir, asset.fileName)\n\t\t\t\t\t\t\t.replaceAll(\"\\\\\", \"/\"),\n\t\t\t\t\t\tasset.source as string,\n\t\t\t\t\t];\n\t\t\t\t}),\n\t\t);\n\n\t\tconst entryModulePathWithDts = path.join(\n\t\t\tpath.dirname(entryModulePath),\n\t\t\tpath.basename(entryModulePath, path.extname(entryModulePath)) +\n\t\t\t\t\".d.ts\",\n\t\t);\n\n\t\tdeclarations = bundleTSDeclarations(\n\t\t\tdeclarationFileMap,\n\t\t\tentryModulePathWithDts,\n\t\t\tmanifest.Scope ?? manifest.Package,\n\t\t);\n\t}\n\n\treturn {\n\t\tjs: primaryChunk.code,\n\t\tdeclarations,\n\t\tsourceMap: sourceMap?.source as string,\n\t};\n}\n\nconst referenceRegex = /(\\/\\/\\/ ?<reference .+\\/>$)/;\n\nfunction bundleTSDeclarations(\n\tfiles: Map<string, string>,\n\tentryFileName: string,\n\tnamespace: string,\n) {\n\tconst references: string[] = [];\n\n\tfor (const [_fileName, content] of files) {\n\t\tif (content.indexOf(\"reference\") === -1) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst lines = content.split(os.EOL);\n\n\t\tfor (let index = 0; index < lines.length; index++) {\n\t\t\tconst line = lines[index];\n\t\t\tconst match = line.match(referenceRegex);\n\n\t\t\tif (match === null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!references.includes(match[1])) {\n\t\t\t\treferences.push(match[1]);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst compilerOptions: ts.CompilerOptions = {\n\t\tremoveComments: false,\n\t};\n\n\tconst host = ts.createCompilerHost(compilerOptions, true);\n\thost.fileExists = (fileName) => files.has(fileName);\n\thost.readFile = (fileName) => files.get(fileName);\n\n\tconst program = ts.createProgram({\n\t\thost,\n\t\toptions: compilerOptions,\n\t\trootNames: [entryFileName],\n\t});\n\n\tconst mainFile = program.getSourceFile(entryFileName);\n\n\tif (mainFile === undefined) {\n\t\tthrow new Error(\n\t\t\t`Unexpected: Failed to find compiled declaration entry module`,\n\t\t);\n\t}\n\n\tconst result = bundleFromEntryFile(\n\t\tnamespace,\n\t\tmainFile,\n\t\tprogram,\n\t\thost,\n\t\tprogram.getTypeChecker(),\n\t\tcompilerOptions,\n\t);\n\treturn [...references, result].join(os.EOL);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyBA,SAAgB,6BACf,UACA,UACA,QACA,kBACmB;AACnB,SAAQ,QAA4B;AACnC,MAAI,cAAc;AAElB,GAAC,YAAY;AACZ,OAAI;IACH,MAAM,eAAe,gBACpB,UACA,UACA,QACA,kBACA,IACA;IAID,MAAM,SAAS,OAFD,MAAM,OAAO,aAAa,EAEb,SAAS,aAAa,OAAO;AAExD,QAAI,WAAW;KACd,MAAM;KACN,WAAW,oBACV,QACA,UACA,UACA,aAAa,OACb,iBACA;KACD,CAAC;YACM,KAAK;AACb,QAAI,WAAW;KACd,MAAM;KACN,OAAO,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,IAAI,CAAC;KAC1D,CAAC;;MAEA;AAEJ,SAAO,EACN,eAAe,IACf;;;AAIH,SAAgB,kCACf,UACA,UACA,QACA,kBACmB;AACnB,SAAQ,QAA4B;AACnC,MAAI,cAAc;EAElB,MAAM,eAAe,gBACpB,UACA,UACA,QACA,kBACA,IACA;EAED,MAAM,UAAU,MAAM;GACrB,GAAG;GACH,OAAO,EACN,WAAW,MACX;GACD,CAAC;AAEF,UAAQ,GAAG,SAAS,OAAO,UAAU;AACpC,WAAQ,MA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G,IAAI;AAEnC,OAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;GAElD,MAAM,QADO,MAAM,OACA,MAAM,eAAe;AAExC,OAAI,UAAU,KACb;AAGD,OAAI,CAAC,WAAW,SAAS,MAAM,GAAG,CACjC,YAAW,KAAK,MAAM,GAAG;;;CAK5B,MAAM,kBAAsC,EAC3C,gBAAgB,OAChB;CAED,MAAM,OAAO,GAAG,mBAAmB,iBAAiB,KAAK;AACzD,MAAK,cAAc,aAAa,MAAM,IAAI,SAAS;AACnD,MAAK,YAAY,aAAa,MAAM,IAAI,SAAS;CAEjD,MAAM,UAAU,GAAG,cAAc;EAChC;EACA,SAAS;EACT,WAAW,CAAC,cAAc;EAC1B,CAAC;CAEF,MAAM,WAAW,QAAQ,cAAc,cAAc;AAErD,KAAI,aAAa,KAAA,EAChB,OAAM,IAAI,MACT,+DACA;CAGF,MAAM,SAAS,oBACd,WACA,UACA,SACA,MACA,QAAQ,gBAAgB,EACxB,gBACA;AACD,QAAO,CAAC,GAAG,YAAY,OAAO,CAAC,KAAK,GAAG,IAAI"}
@@ -0,0 +1,29 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import ts from "typescript";
4
+ //#region src/lib/scripts.ts
5
+ function resolveScriptPackageEntryModule(location, manifest) {
6
+ let candidates = ["index.ts"];
7
+ if (manifest.Type === "Context") candidates.push("Context.ts");
8
+ for (const candidate of candidates) {
9
+ const candidatePath = path.join(location.scriptsDir, candidate);
10
+ if (fs.existsSync(candidatePath)) return candidatePath;
11
+ }
12
+ }
13
+ function readScriptPackageTSConfig(location) {
14
+ const { config } = ts.readConfigFile(path.join(location.scriptsDir, "tsconfig.json"), (path) => {
15
+ try {
16
+ return fs.readFileSync(path, "utf8");
17
+ } catch {
18
+ return;
19
+ }
20
+ });
21
+ return ts.parseJsonConfigFileContent(config, ts.sys, location.scriptsDir);
22
+ }
23
+ function isScriptPackageModules(options) {
24
+ return options.module === ts.ModuleKind.ES2015;
25
+ }
26
+ //#endregion
27
+ export { readScriptPackageTSConfig as n, resolveScriptPackageEntryModule as r, isScriptPackageModules as t };
28
+
29
+ //# sourceMappingURL=scripts-CBblHIL1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scripts-CBblHIL1.js","names":[],"sources":["../src/lib/scripts.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport ts from \"typescript\";\n\nimport type {\n\tCreatorPackage,\n\tPackageLocation,\n} from \"@intelligentgraphics/ig.gfx.tools.core\";\n\nexport { getPackageTypescriptFiles } from \"@intelligentgraphics/ig.gfx.tools.core\";\n\nexport function resolveScriptPackageEntryModule(\n\tlocation: PackageLocation,\n\tmanifest: CreatorPackage,\n) {\n\tlet candidates = [\"index.ts\"];\n\n\tif (manifest.Type === \"Context\") {\n\t\tcandidates.push(\"Context.ts\");\n\t}\n\n\tfor (const candidate of candidates) {\n\t\tconst candidatePath = path.join(location.scriptsDir, candidate);\n\n\t\tif (fs.existsSync(candidatePath)) {\n\t\t\treturn candidatePath;\n\t\t}\n\t}\n}\n\nexport function readScriptPackageTSConfig(location: PackageLocation) {\n\tconst { config } = ts.readConfigFile(\n\t\tpath.join(location.scriptsDir, \"tsconfig.json\"),\n\t\t(path) => {\n\t\t\ttry {\n\t\t\t\treturn fs.readFileSync(path, \"utf8\");\n\t\t\t} catch {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t},\n\t);\n\n\tconst parsedTsConfig = ts.parseJsonConfigFileContent(\n\t\tconfig,\n\t\tts.sys,\n\t\tlocation.scriptsDir,\n\t);\n\n\treturn parsedTsConfig;\n}\n\nexport function isScriptPackageModules(options: ts.CompilerOptions) {\n\treturn options.module === ts.ModuleKind.ES2015;\n}\n"],"mappings":";;;;AAWA,SAAgB,gCACf,UACA,UACC;CACD,IAAI,aAAa,CAAC,WAAW;AAE7B,KAAI,SAAS,SAAS,UACrB,YAAW,KAAK,aAAa;AAG9B,MAAK,MAAM,aAAa,YAAY;EACnC,MAAM,gBAAgB,KAAK,KAAK,SAAS,YAAY,UAAU;AAE/D,MAAI,GAAG,WAAW,cAAc,CAC/B,QAAO;;;AAKV,SAAgB,0BAA0B,UAA2B;CACpE,MAAM,EAAE,WAAW,GAAG,eACrB,KAAK,KAAK,SAAS,YAAY,gBAAgB,GAC9C,SAAS;AACT,MAAI;AACH,UAAO,GAAG,aAAa,MAAM,OAAO;UAC7B;AACP;;GAGF;AAQD,QANuB,GAAG,2BACzB,QACA,GAAG,KACH,SAAS,WACT;;AAKF,SAAgB,uBAAuB,SAA6B;AACnE,QAAO,QAAQ,WAAW,GAAG,WAAW"}
@@ -0,0 +1,123 @@
1
+ import { A as isErrorENOENT, a as readStringFromFileOrUndefined } from "./build-kkMVBBJL.js";
2
+ import { t as PackageVersion } from "./build-CMbCj7x-.js";
3
+ import * as fs from "node:fs";
4
+ import * as path from "node:path";
5
+ import simpleGit from "simple-git";
6
+ //#region src/lib/git.ts
7
+ const getVersionInformationFromGit = async (workspaceLocation, packageLocation) => {
8
+ try {
9
+ const git = simpleGit({ baseDir: workspaceLocation.path });
10
+ const dirty = (await git.diffSummary()).files.some((file) => {
11
+ if (file.file.toLowerCase().includes("releases") || file.file.toLowerCase().endsWith("version.ts") || file.file.toLowerCase().endsWith("package.json")) return false;
12
+ const fullPath = path.resolve(workspaceLocation.path, file.file);
13
+ return !path.relative(packageLocation.path, fullPath).startsWith("..");
14
+ });
15
+ const log = await git.log({ maxCount: 1 });
16
+ return {
17
+ commit: !log.latest?.hash ? void 0 : log.latest.hash.substring(0, 7),
18
+ dirty,
19
+ commitDate: log.latest?.date
20
+ };
21
+ } catch (err) {
22
+ return {};
23
+ }
24
+ };
25
+ //#endregion
26
+ //#region src/lib/banner.ts
27
+ const getWorkspaceBannerText = (manifest) => {
28
+ let bannerText = manifest?.packager?.banner;
29
+ if (bannerText) {
30
+ const match = bannerText.match(/Copyright \(C\) (\d+)( ?- ?(\d+))?/);
31
+ if (match !== null) {
32
+ const startYear = parseInt(match[1]);
33
+ const endYear = (/* @__PURE__ */ new Date()).getFullYear();
34
+ if (startYear !== endYear) bannerText = bannerText.replace(match[0], `Copyright (C) ${startYear} - ${endYear}`);
35
+ else bannerText = bannerText.replace(match[0], `Copyright (C) ${startYear}`);
36
+ }
37
+ }
38
+ return bannerText;
39
+ };
40
+ //#endregion
41
+ //#region src/lib/parseVersion.ts
42
+ const parseVersionFromString = (input) => {
43
+ if (input === void 0) throw new Error(`Can not parse version from undefined`);
44
+ let match;
45
+ let major;
46
+ let minor;
47
+ let patch;
48
+ let build;
49
+ let preReleaseType;
50
+ let preReleaseNumber;
51
+ if ((match = input.match(/(\d+)\.(\d+)\.(\d+)\.(\d+)(-([^\.]+)\.(\d+))?/)) !== null) [, major, minor, patch, build, preReleaseType, preReleaseNumber] = match;
52
+ else if ((match = input.match(/(\d+)\.(\d+)\.(\d+)(-([^\.]+)\.(\d+))?/)) !== null) [, major, minor, patch, , preReleaseType, preReleaseNumber] = match;
53
+ if (match === null) throw new Error(`Could not parse version from input: ${input}`);
54
+ let preRelease = void 0;
55
+ let buildNumber = 100;
56
+ if (preReleaseType && preReleaseNumber) preRelease = {
57
+ type: preReleaseType,
58
+ version: parseInt(preReleaseNumber)
59
+ };
60
+ if (build) buildNumber = Number(build);
61
+ else if (input) {
62
+ const descriptionMatch = input.match(/(\d+)\)$/);
63
+ if (descriptionMatch) buildNumber = parseInt(descriptionMatch[1]);
64
+ }
65
+ return new PackageVersion(parseInt(major), parseInt(minor), parseInt(patch), preRelease, buildNumber);
66
+ };
67
+ const parseVersionFromNumericVersion = (version) => {
68
+ return new PackageVersion(Math.floor(version / 1e9), Math.floor(version % 1e9 / 1e6), Math.floor(version % 1e6 / 1e3), void 0, version % 1e3);
69
+ };
70
+ //#endregion
71
+ //#region src/lib/versionFile.ts
72
+ const logRegex = /console\.log\(\s*"([\w\s\.\(\)]+)\ *Copyright[\w\s\(\)\.]+(\d{4}|\d{4} - \d{4})([\w\s\(\)\.]+)?",?\s*\)/i;
73
+ const currentYear = new Date(Date.now()).getFullYear();
74
+ function getVersionFileHandler(location) {
75
+ const filePath = path.join(location.scriptsDir, "Version.ts");
76
+ function invalidVersionFile(versionFile, exists) {
77
+ return {
78
+ exists,
79
+ write: (name, newVersion) => {
80
+ if (fs.readdirSync(location.scriptsDir).filter((file) => file.endsWith(".ts")).length > 0) return createVersionFileWriter([currentYear], "")(name, newVersion);
81
+ },
82
+ reset: () => {
83
+ if (versionFile !== void 0) fs.writeFileSync(filePath, versionFile, { encoding: "utf8" });
84
+ else try {
85
+ fs.rmSync(filePath);
86
+ } catch (err) {
87
+ if (!isErrorENOENT(err)) throw err;
88
+ }
89
+ }
90
+ };
91
+ }
92
+ function createVersionFileWriter(copyright = [currentYear], copyrightStuff = "") {
93
+ return (name, newVersion) => {
94
+ const result = `console.log("${newVersion.toDescriptionString(name)}. Copyright (C) ${createYearString(copyright)}${copyrightStuff}");`;
95
+ fs.writeFileSync(filePath, result, { encoding: "utf-8" });
96
+ };
97
+ }
98
+ let rawVersionFile = readStringFromFileOrUndefined(filePath);
99
+ if (rawVersionFile === void 0) return invalidVersionFile(rawVersionFile, false);
100
+ const versionFile = rawVersionFile.replace(/\n/g, "");
101
+ const match = versionFile.match(logRegex);
102
+ if (!match) return invalidVersionFile(versionFile, true);
103
+ const [_full, _description, copyright, copyrightStuff] = match;
104
+ const copyrightYears = copyright.match(/^(\d+)( ?- ?(\d+))?$/);
105
+ let years;
106
+ if (copyrightYears === null) years = [currentYear];
107
+ else years = [Number(copyrightYears[1]), currentYear];
108
+ return {
109
+ exists: true,
110
+ write: createVersionFileWriter(years, copyrightStuff),
111
+ reset: () => {
112
+ fs.writeFileSync(filePath, versionFile, { encoding: "utf8" });
113
+ }
114
+ };
115
+ }
116
+ const createYearString = (years) => {
117
+ if (years[1] === void 0 || years[0] === years[1]) return years[0].toString();
118
+ return `${years[0]} - ${years[1]}`;
119
+ };
120
+ //#endregion
121
+ export { getVersionInformationFromGit as a, getWorkspaceBannerText as i, parseVersionFromNumericVersion as n, parseVersionFromString as r, getVersionFileHandler as t };
122
+
123
+ //# sourceMappingURL=versionFile-DViDwgCa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versionFile-DViDwgCa.js","names":[],"sources":["../src/lib/git.ts","../src/lib/banner.ts","../src/lib/parseVersion.ts","../src/lib/versionFile.ts"],"sourcesContent":["import simpleGit from \"simple-git\";\nimport * as path from \"node:path\";\n\nimport type { WorkspaceLocation } from \"./workspace\";\nimport type { PackageLocation } from \"./package\";\n\nexport const getVersionInformationFromGit = async (\n\tworkspaceLocation: WorkspaceLocation,\n\tpackageLocation: PackageLocation,\n) => {\n\ttry {\n\t\tconst git = simpleGit({\n\t\t\tbaseDir: workspaceLocation.path,\n\t\t});\n\n\t\t// check wether the files for a folder are changed\n\t\t// if so, mark as dirty\n\t\tconst diff = await git.diffSummary();\n\n\t\tconst dirty = diff.files.some((file) => {\n\t\t\tif (\n\t\t\t\tfile.file.toLowerCase().includes(\"releases\") ||\n\t\t\t\tfile.file.toLowerCase().endsWith(\"version.ts\") ||\n\t\t\t\tfile.file.toLowerCase().endsWith(\"package.json\")\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst fullPath = path.resolve(workspaceLocation.path, file.file);\n\t\t\tconst relativePath = path.relative(packageLocation.path, fullPath);\n\n\t\t\treturn !relativePath.startsWith(\"..\");\n\t\t});\n\n\t\tconst log = await git.log({ maxCount: 1 });\n\t\tconst commit = !log.latest?.hash\n\t\t\t? undefined\n\t\t\t: log.latest.hash.substring(0, 7);\n\n\t\treturn {\n\t\t\tcommit,\n\t\t\tdirty,\n\t\t\tcommitDate: log.latest?.date,\n\t\t};\n\t} catch (err) {\n\t\treturn {};\n\t}\n};\n","import type{ WorkspacePackageJSON } from \"./workspace\";\n\nexport const getWorkspaceBannerText = (manifest: WorkspacePackageJSON) => {\n\tlet bannerText = manifest?.packager?.banner;\n\n\tif (bannerText) {\n\t\tconst match = bannerText.match(/Copyright \\(C\\) (\\d+)( ?- ?(\\d+))?/);\n\n\t\tif (match !== null) {\n\t\t\tconst startYear = parseInt(match[1]);\n\t\t\tconst endYear = new Date().getFullYear();\n\n\t\t\tif (startYear !== endYear) {\n\t\t\t\tbannerText = bannerText.replace(\n\t\t\t\t\tmatch[0],\n\t\t\t\t\t`Copyright (C) ${startYear} - ${endYear}`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tbannerText = bannerText.replace(\n\t\t\t\t\tmatch[0],\n\t\t\t\t\t`Copyright (C) ${startYear}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn bannerText;\n};\n","import { PackageVersion } from \"./packageVersion\";\n\nexport const parseVersionFromString = (input: string) => {\n\tif (input === undefined) {\n\t\tthrow new Error(`Can not parse version from undefined`);\n\t}\n\n\tlet match: RegExpMatchArray | null;\n\n\tlet major!: string;\n\tlet minor!: string;\n\tlet patch!: string;\n\tlet build: string | undefined;\n\tlet preReleaseType: string | undefined;\n\tlet preReleaseNumber: string | undefined;\n\n\tif (\n\t\t// first try to find a full match with build number\n\t\t(match = input.match(\n\t\t\t/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)(-([^\\.]+)\\.(\\d+))?/,\n\t\t)) !== null\n\t) {\n\t\t[, major, minor, patch, build, preReleaseType, preReleaseNumber] =\n\t\t\tmatch;\n\t} else if (\n\t\t(match = input.match(/(\\d+)\\.(\\d+)\\.(\\d+)(-([^\\.]+)\\.(\\d+))?/)) !== null\n\t) {\n\t\t[, major, minor, patch, , preReleaseType, preReleaseNumber] = match;\n\t}\n\n\tif (match === null) {\n\t\tthrow new Error(`Could not parse version from input: ${input}`);\n\t}\n\n\tlet preRelease: PackageVersion[\"preRelease\"] = undefined;\n\tlet buildNumber = 100;\n\n\tif (preReleaseType && preReleaseNumber) {\n\t\tpreRelease = {\n\t\t\ttype: preReleaseType,\n\t\t\tversion: parseInt(preReleaseNumber),\n\t\t};\n\t}\n\n\tif (build) {\n\t\tbuildNumber = Number(build);\n\t} else if (input) {\n\t\tconst descriptionMatch = input.match(/(\\d+)\\)$/);\n\n\t\tif (descriptionMatch) {\n\t\t\tbuildNumber = parseInt(descriptionMatch[1]);\n\t\t}\n\t}\n\n\treturn new PackageVersion(\n\t\tparseInt(major),\n\t\tparseInt(minor),\n\t\tparseInt(patch),\n\t\tpreRelease,\n\t\tbuildNumber,\n\t);\n};\n\n// 1000001001 -> 1.0.1.1\n// 1002017001 -> 1.2.17.1\nexport const parseVersionFromNumericVersion = (\n\tversion: number,\n): PackageVersion => {\n\tconst major = Math.floor(version / 1000000000);\n\tconst minor = Math.floor((version % 1000000000) / 1000000);\n\tconst patch = Math.floor((version % 1000000) / 1000);\n\tconst buildNumber = version % 1000;\n\n\treturn new PackageVersion(major, minor, patch, undefined, buildNumber);\n};\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { isErrorENOENT } from \"./error\";\nimport { readStringFromFileOrUndefined } from \"./fs\";\nimport type { 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 function getVersionFileHandler(location: PackageLocation) {\n\tconst filePath = path.join(location.scriptsDir, \"Version.ts\");\n\n\tfunction invalidVersionFile(\n\t\tversionFile: string | undefined,\n\t\texists: boolean,\n\t) {\n\t\treturn {\n\t\t\texists,\n\t\t\twrite: (name: string, newVersion: PackageVersion) => {\n\t\t\t\tconst scriptsContent = fs.readdirSync(location.scriptsDir);\n\t\t\t\tconst tsFiles = scriptsContent.filter((file) =>\n\t\t\t\t\tfile.endsWith(\".ts\"),\n\t\t\t\t);\n\n\t\t\t\tif (tsFiles.length > 0) {\n\t\t\t\t\treturn createVersionFileWriter([currentYear], \"\")(\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tnewVersion,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t\treset: () => {\n\t\t\t\tif (versionFile !== undefined) {\n\t\t\t\t\tfs.writeFileSync(filePath, versionFile, {\n\t\t\t\t\t\tencoding: \"utf8\",\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfs.rmSync(filePath);\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tif (!isErrorENOENT(err)) {\n\t\t\t\t\t\t\tthrow err;\n\t\t\t\t\t\t}\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\tfunction createVersionFileWriter(\n\t\tcopyright: CopyrightRange = [currentYear],\n\t\tcopyrightStuff: string = \"\",\n\t) {\n\t\treturn (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\t}\n\n\tlet rawVersionFile = readStringFromFileOrUndefined(filePath);\n\n\tif (rawVersionFile === undefined) {\n\t\treturn invalidVersionFile(rawVersionFile, false);\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, true);\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\texists: true,\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"],"mappings":";;;;;;AAMA,MAAa,+BAA+B,OAC3C,mBACA,oBACI;AACJ,KAAI;EACH,MAAM,MAAM,UAAU,EACrB,SAAS,kBAAkB,MAC3B,CAAC;EAMF,MAAM,SAFO,MAAM,IAAI,aAAa,EAEjB,MAAM,MAAM,SAAS;AACvC,OACC,KAAK,KAAK,aAAa,CAAC,SAAS,WAAW,IAC5C,KAAK,KAAK,aAAa,CAAC,SAAS,aAAa,IAC9C,KAAK,KAAK,aAAa,CAAC,SAAS,eAAe,CAEhD,QAAO;GAGR,MAAM,WAAW,KAAK,QAAQ,kBAAkB,MAAM,KAAK,KAAK;AAGhE,UAAO,CAFc,KAAK,SAAS,gBAAgB,MAAM,SAAS,CAE7C,WAAW,KAAK;IACpC;EAEF,MAAM,MAAM,MAAM,IAAI,IAAI,EAAE,UAAU,GAAG,CAAC;AAK1C,SAAO;GACN,QALc,CAAC,IAAI,QAAQ,OACzB,KAAA,IACA,IAAI,OAAO,KAAK,UAAU,GAAG,EAAE;GAIjC;GACA,YAAY,IAAI,QAAQ;GACxB;UACO,KAAK;AACb,SAAO,EAAE;;;;;AC3CX,MAAa,0BAA0B,aAAmC;CACzE,IAAI,aAAa,UAAU,UAAU;AAErC,KAAI,YAAY;EACf,MAAM,QAAQ,WAAW,MAAM,qCAAqC;AAEpE,MAAI,UAAU,MAAM;GACnB,MAAM,YAAY,SAAS,MAAM,GAAG;GACpC,MAAM,2BAAU,IAAI,MAAM,EAAC,aAAa;AAExC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