@intelligentgraphics/ig.gfx.packager 3.1.0-alpha.1 → 3.1.0-alpha.2
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-fec9c069.mjs → cli-CuiqZ39_.mjs} +87 -82
- package/build/cli-CuiqZ39_.mjs.map +1 -0
- package/build/{dependencies-d870016d.mjs → dependencies-BiYItaVS.mjs} +2 -2
- package/build/{dependencies-d870016d.mjs.map → dependencies-BiYItaVS.mjs.map} +1 -1
- package/build/{generateIndex-dd0b4563.mjs → generateIndex-hg6jRXQv.mjs} +96 -83
- package/build/generateIndex-hg6jRXQv.mjs.map +1 -0
- package/build/{generateParameterType-9a671e36.mjs → generateParameterType-CDjqLM4J.mjs} +3 -4
- package/build/{generateParameterType-9a671e36.mjs.map → generateParameterType-CDjqLM4J.mjs.map} +1 -1
- package/build/{index-0caf1a6e.mjs → index-B2kXo6K7.mjs} +343 -119
- package/build/index-B2kXo6K7.mjs.map +1 -0
- package/build/{index-7fa42d48.mjs → index-BoGrZubW.mjs} +201 -188
- package/build/index-BoGrZubW.mjs.map +1 -0
- package/build/{postinstall-81b6f0b0.mjs → postinstall-CbMUz2zy.mjs} +3 -4
- package/build/{postinstall-81b6f0b0.mjs.map → postinstall-CbMUz2zy.mjs.map} +1 -1
- package/build/{publishNpm-c985bd6e.mjs → publishNpm-CrnuTwss.mjs} +14 -11
- package/build/publishNpm-CrnuTwss.mjs.map +1 -0
- package/build/rollup-UR3DADp8.mjs +198 -0
- package/build/rollup-UR3DADp8.mjs.map +1 -0
- package/build/scripts-Bfojy_uD.mjs +48 -0
- package/build/scripts-Bfojy_uD.mjs.map +1 -0
- package/build/versionFile-DSqOw-XB.mjs +208 -0
- package/build/versionFile-DSqOw-XB.mjs.map +1 -0
- package/lib/lib.mjs +2649 -18
- package/package.json +20 -15
- package/readme.md +126 -13
- package/build/cli-fec9c069.mjs.map +0 -1
- package/build/generateIndex-dd0b4563.mjs.map +0 -1
- package/build/index-0caf1a6e.mjs.map +0 -1
- package/build/index-7fa42d48.mjs.map +0 -1
- package/build/publishNpm-c985bd6e.mjs.map +0 -1
- package/build/scripts-7ed8dff6.mjs +0 -10
- package/build/scripts-7ed8dff6.mjs.map +0 -1
- package/build/swc-9ed0f3ce.mjs +0 -60
- package/build/swc-9ed0f3ce.mjs.map +0 -1
- package/build/versionFile-cbfd3f4a.mjs +0 -380
- package/build/versionFile-cbfd3f4a.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postinstall-
|
|
1
|
+
{"version":3,"file":"postinstall-CbMUz2zy.mjs","sources":["../src/commands/postinstall.ts"],"sourcesContent":["import * as path from \"path\";\nimport * as fs from \"fs\";\nimport glob from \"glob\";\nimport * as os from \"os\";\n\nimport {\n\tgetWorkspaceLibPath,\n\treadWorkspaceNpmManifest,\n\tWorkspaceLocation,\n} from \"../lib/workspace\";\nimport { readPublishedPackageNpmManifest } from \"../lib/publishedPackage\";\nimport { determineWorkspaceIGLibraries } from \"../lib/dependencies\";\n\nconst DEFINITION_FILE_HINT =\n\t\"// This file is automatically managed by the ig.gfx.packager.\";\n\nexport const executePostInstall = (workspace: WorkspaceLocation) => {\n\tconst manifest = readWorkspaceNpmManifest(workspace);\n\n\tconst libPath = getWorkspaceLibPath(workspace);\n\n\tfs.mkdirSync(libPath, { recursive: true });\n\n\tconst existingDefinitions = glob.sync(\"**/*.d.ts\", {\n\t\tcwd: libPath,\n\t\tabsolute: true,\n\t});\n\n\t// delete all existing definition files that are managed by the packager.\n\t// we'll recreate all needed definitions in the next step.\n\tfor (const existingDefinitionPath of existingDefinitions) {\n\t\tconst content = fs.readFileSync(existingDefinitionPath, {\n\t\t\tencoding: \"utf-8\",\n\t\t});\n\n\t\tif (content.startsWith(DEFINITION_FILE_HINT)) {\n\t\t\tfs.rmSync(existingDefinitionPath);\n\t\t}\n\t}\n\n\tconst libraryLocations = determineWorkspaceIGLibraries(workspace);\n\n\tfor (const location of libraryLocations) {\n\t\tconst manifest = readPublishedPackageNpmManifest(location);\n\n\t\tfor (const existingDefinitionPath of existingDefinitions) {\n\t\t\tconst basename = path.basename(existingDefinitionPath);\n\n\t\t\tif (basename === manifest.types) {\n\t\t\t\tfs.rmSync(existingDefinitionPath, { force: true });\n\t\t\t}\n\t\t}\n\n\t\t// add a hint to the top of the file so we know it's managed by the packager.\n\n\t\tconst content = [\n\t\t\tDEFINITION_FILE_HINT,\n\t\t\t`// This is a reference to version ${manifest.version}.`,\n\t\t\t`// Run \"npm install\" to install the types if they are missing or not up to date.`,\n\t\t\t`/// <reference types=\"${manifest.name}\" />`,\n\t\t].join(os.EOL);\n\n\t\tfs.writeFileSync(\n\t\t\tpath.join(getWorkspaceLibPath(workspace), manifest.types),\n\t\t\tcontent,\n\t\t\t{\n\t\t\t\tencoding: \"utf8\",\n\t\t\t},\n\t\t);\n\t}\n};\n"],"names":["DEFINITION_FILE_HINT","executePostInstall","workspace","readWorkspaceNpmManifest","libPath","getWorkspaceLibPath","fs","mkdirSync","recursive","existingDefinitions","glob","sync","cwd","absolute","existingDefinitionPath","content","readFileSync","encoding","startsWith","rmSync","libraryLocations","determineWorkspaceIGLibraries","location","manifest","readPublishedPackageNpmManifest","basename","path","types","force","version","name","join","os","EOL","writeFileSync"],"mappings":";;;;;;;;;;;;;;;;;;;AAaA,MAAMA,oBAAAA,GACL,+DAAA;AAEM,MAAMC,qBAAqB,CAACC,SAAAA,GAAAA;AAClC,IAAiBC,wBAAAA,CAAyBD,SAAAA;AAE1C,IAAA,MAAME,UAAUC,mBAAAA,CAAoBH,SAAAA,CAAAA;IAEpCI,EAAAA,CAAGC,SAAS,CAACH,OAAAA,EAAS;QAAEI,SAAAA,EAAW;AAAK,KAAA,CAAA;AAExC,IAAA,MAAMC,mBAAAA,GAAsBC,IAAAA,CAAKC,IAAI,CAAC,WAAA,EAAa;QAClDC,GAAAA,EAAKR,OAAAA;QACLS,QAAAA,E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EF,IAAA;AACD;;;;"}
|
|
@@ -3,31 +3,31 @@ import * as fs from 'fs';
|
|
|
3
3
|
import { execSync } from 'child_process';
|
|
4
4
|
import 'resolve';
|
|
5
5
|
import 'write-pkg';
|
|
6
|
-
import { b as readWorkspaceNpmManifest,
|
|
7
|
-
import {
|
|
6
|
+
import { b as readWorkspaceNpmManifest, d as getWorkspaceOutputPath, r as readPackageCreatorManifest, q as readPackageNpmManifest, t as writePackageNpmManifest, w as writePackageCreatorManifest, P as PACKAGE_FILE, a as readPackageCreatorIndex, I as INDEX_FILE, v as iterateWorkspacePackages } from './cli-CuiqZ39_.mjs';
|
|
7
|
+
import { c as createPackageScopedReporter, a as consoleReporter, b as buildFolders } from './index-B2kXo6K7.mjs';
|
|
8
8
|
import 'glob';
|
|
9
9
|
import 'node:path';
|
|
10
10
|
import 'node:fs';
|
|
11
11
|
import 'axios';
|
|
12
|
-
import {
|
|
12
|
+
import { a as parseVersionFromString, g as getVersionFileHandler, b as getVersionInformationFromGit, c as getWorkspaceBannerText } from './versionFile-DSqOw-XB.mjs';
|
|
13
13
|
import 'update-notifier';
|
|
14
14
|
import 'yargs/yargs';
|
|
15
15
|
import 'url';
|
|
16
16
|
import 'assert';
|
|
17
17
|
import 'events';
|
|
18
|
-
import 'core-js/modules/es.typed-array.set.js';
|
|
19
18
|
import 'util';
|
|
20
19
|
import 'inquirer';
|
|
21
20
|
import 'fs/promises';
|
|
22
21
|
import 'terser';
|
|
22
|
+
import 'os';
|
|
23
23
|
import 'typescript';
|
|
24
|
-
import './scripts-
|
|
24
|
+
import './scripts-Bfojy_uD.mjs';
|
|
25
25
|
import 'typedoc';
|
|
26
26
|
import 'source-map-js';
|
|
27
27
|
import 'ajv';
|
|
28
28
|
import 'simple-git';
|
|
29
29
|
|
|
30
|
-
const publishToNpm = async ({ workspace, location, version: providedVersion, dryRun })=>{
|
|
30
|
+
const publishToNpm = async ({ workspace, location, version: providedVersion, dryRun, reporter: providedReporter })=>{
|
|
31
31
|
let newVersion;
|
|
32
32
|
try {
|
|
33
33
|
newVersion = parseVersionFromString(providedVersion);
|
|
@@ -47,6 +47,7 @@ const publishToNpm = async ({ workspace, location, version: providedVersion, dry
|
|
|
47
47
|
const workspaceManifest = readWorkspaceNpmManifest(workspace);
|
|
48
48
|
const workspaceOutputPath = getWorkspaceOutputPath(workspace);
|
|
49
49
|
const creatorPackage = readPackageCreatorManifest(location);
|
|
50
|
+
const reporter = providedReporter ?? createPackageScopedReporter(consoleReporter, creatorPackage.Package);
|
|
50
51
|
let packageJson = readPackageNpmManifest(location);
|
|
51
52
|
if (packageJson === undefined) {
|
|
52
53
|
packageJson = {
|
|
@@ -80,7 +81,10 @@ const publishToNpm = async ({ workspace, location, version: providedVersion, dry
|
|
|
80
81
|
buildNumber: true
|
|
81
82
|
});
|
|
82
83
|
writePackageCreatorManifest(location, creatorPackage);
|
|
83
|
-
getVersionFileHandler(location)
|
|
84
|
+
const versionFile = getVersionFileHandler(location);
|
|
85
|
+
if (versionFile.exists) {
|
|
86
|
+
versionFile.write(creatorPackage.Package, newVersion);
|
|
87
|
+
}
|
|
84
88
|
const gitVersionInformation = await getVersionInformationFromGit(workspace, location);
|
|
85
89
|
const bannerText = getWorkspaceBannerText(workspaceManifest);
|
|
86
90
|
await buildFolders({
|
|
@@ -124,7 +128,7 @@ const publishToNpm = async ({ workspace, location, version: providedVersion, dry
|
|
|
124
128
|
if (newVersion.preRelease) {
|
|
125
129
|
npmPublishArgs.push("--tag", "next");
|
|
126
130
|
}
|
|
127
|
-
|
|
131
|
+
reporter.log(`Publishing to npm with version ${packageJson.version} using tag ${newVersion.preRelease ? "next" : "latest"}`);
|
|
128
132
|
execSync([
|
|
129
133
|
"npm",
|
|
130
134
|
"publish",
|
|
@@ -135,9 +139,8 @@ const publishToNpm = async ({ workspace, location, version: providedVersion, dry
|
|
|
135
139
|
cwd: publishDir
|
|
136
140
|
});
|
|
137
141
|
for (const packageLocation of iterateWorkspacePackages(workspace)){
|
|
138
|
-
var _manifest_dependencies;
|
|
139
142
|
const manifest = readPackageNpmManifest(packageLocation);
|
|
140
|
-
if (
|
|
143
|
+
if (manifest?.dependencies?.[packageJson.name] !== undefined) {
|
|
141
144
|
manifest.dependencies[packageJson.name] = "^" + packageJson.version;
|
|
142
145
|
writePackageNpmManifest(packageLocation, manifest);
|
|
143
146
|
}
|
|
@@ -166,4 +169,4 @@ const copyImagesDirectory = (source, target)=>{
|
|
|
166
169
|
};
|
|
167
170
|
|
|
168
171
|
export { publishToNpm };
|
|
169
|
-
//# sourceMappingURL=publishNpm-
|
|
172
|
+
//# sourceMappingURL=publishNpm-CrnuTwss.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publishNpm-CrnuTwss.mjs","sources":["../src/commands/publishNpm.ts"],"sourcesContent":["import * as path from \"path\";\nimport * as fs from \"fs\";\nimport { execSync } from \"child_process\";\n\nimport {\n\tconsoleReporter,\n\tcreatePackageScopedReporter,\n\tReporter,\n} from \"@intelligentgraphics/ig.gfx.tools.core\";\n\nimport { PackageVersion } from \"../lib/packageVersion\";\nimport {\n\tINDEX_FILE,\n\tPackageLocation,\n\tPACKAGE_FILE,\n\treadPackageCreatorIndex,\n\treadPackageCreatorManifest,\n\treadPackageNpmManifest,\n\twritePackageNpmManifest,\n\twritePackageCreatorManifest,\n} from \"../lib/package\";\nimport {\n\tgetWorkspaceOutputPath,\n\titerateWorkspacePackages,\n\treadWorkspaceNpmManifest,\n\tWorkspaceLocation,\n} from \"../lib/workspace\";\nimport { getVersionInformationFromGit } from \"../lib/git\";\nimport { getWorkspaceBannerText } from \"../lib/banner\";\nimport { parseVersionFromString } from \"../lib/parseVersion\";\nimport { getVersionFileHandler } from \"../lib/versionFile\";\n\nimport { buildFolders } from \"./build\";\n\nexport interface PublishToNpmSettings {\n\tworkspace: WorkspaceLocation;\n\tlocation: PackageLocation;\n\tversion: string;\n\tdryRun?: boolean;\n\treporter?: Reporter;\n}\n\nexport const publishToNpm = async ({\n\tworkspace,\n\tlocation,\n\tversion: providedVersion,\n\tdryRun,\n\treporter: providedReporter,\n}: PublishToNpmSettings) => {\n\tlet newVersion: PackageVersion;\n\ttry {\n\t\tnewVersion = parseVersionFromString(providedVersion);\n\t} catch (err) {\n\t\tthrow new Error(`Please enter a version in this format 1.0.0.100`);\n\t}\n\n\tif (newVersion.buildNumber < 100) {\n\t\tnewVersion.preRelease = {\n\t\t\ttype: \"beta\",\n\t\t\tversion: newVersion.buildNumber,\n\t\t};\n\t} else if (newVersion.buildNumber === 100) {\n\t\tnewVersion.preRelease = undefined;\n\t} else {\n\t\tthrow new Error(\n\t\t\t`Refusing to publish a package with a build version larger than 100.`,\n\t\t);\n\t}\n\n\tconst workspaceManifest = readWorkspaceNpmManifest(workspace);\n\tconst workspaceOutputPath = getWorkspaceOutputPath(workspace);\n\tconst creatorPackage = readPackageCreatorManifest(location);\n\n\tconst reporter =\n\t\tprovidedReporter ??\n\t\tcreatePackageScopedReporter(consoleReporter, creatorPackage.Package);\n\n\tlet packageJson = readPackageNpmManifest(location);\n\n\tif (packageJson === undefined) {\n\t\tpackageJson = {\n\t\t\tname:\n\t\t\t\t\"@intelligentgraphics/3d\" +\n\t\t\t\tcreatorPackage.Package.toLowerCase(),\n\t\t\tversion: \"1.0.0\",\n\t\t\tdescription: creatorPackage.Package,\n\t\t};\n\t}\n\n\tpackageJson.version = newVersion.toVersionString({\n\t\tbuildNumber: false,\n\t});\n\tpackageJson.description = newVersion.toDescriptionString(\n\t\tcreatorPackage.Package,\n\t);\n\tpackageJson.main = `${creatorPackage.Package}.js`;\n\tpackageJson.types = `${creatorPackage.Package}.d.ts`;\n\tpackageJson.publishConfig ??= {};\n\tpackageJson.publishConfig.acccess = \"public\";\n\tpackageJson.ig = {\n\t\tscriptingLibrary: true,\n\t};\n\tpackageJson.files = undefined;\n\n\tconst publishDir = path.join(\n\t\tworkspaceOutputPath,\n\t\t\"publish\",\n\t\tcreatorPackage.Package,\n\t);\n\tfs.rmSync(publishDir, { recursive: true, force: true });\n\tfs.mkdirSync(publishDir, { recursive: true });\n\n\twritePackageNpmManifest(location, packageJson);\n\tcreatorPackage.Version = newVersion.toVersionString({ buildNumber: true });\n\twritePackageCreatorManifest(location, creatorPackage);\n\n\tconst versionFile = getVersionFileHandler(location);\n\tif (versionFile.exists) {\n\t\tversionFile.write(creatorPackage.Package, newVersion);\n\t}\n\n\tconst gitVersionInformation = await getVersionInformationFromGit(\n\t\tworkspace,\n\t\tlocation,\n\t);\n\n\tconst bannerText = getWorkspaceBannerText(workspaceManifest);\n\n\tawait buildFolders({\n\t\tworkspace,\n\t\tpackages: [location],\n\t\tminimize: true,\n\t\toutDir: getWorkspaceOutputPath(workspace),\n\t\tbanner: {\n\t\t\ttext: bannerText,\n\t\t\tcommit: gitVersionInformation.commit,\n\t\t\tcommitDirty: gitVersionInformation.dirty,\n\t\t\tversion: newVersion.toVersionString({\n\t\t\t\tbuildNumber: true,\n\t\t\t}),\n\t\t\tdate: new Date(Date.now()),\n\t\t},\n\t});\n\n\tfs.copyFileSync(\n\t\tpath.join(\n\t\t\tgetWorkspaceOutputPath(workspace),\n\t\t\t`${creatorPackage.Package}.d.ts`,\n\t\t),\n\t\tpath.join(publishDir, `${creatorPackage.Package}.d.ts`),\n\t);\n\tfs.copyFileSync(\n\t\tpath.join(\n\t\t\tgetWorkspaceOutputPath(workspace),\n\t\t\t`${creatorPackage.Package}.min.js`,\n\t\t),\n\t\tpath.join(publishDir, `${creatorPackage.Package}.js`),\n\t);\n\n\tfs.copyFileSync(\n\t\tpath.join(location.manifestDir, \"package.json\"),\n\t\tpath.join(publishDir, \"package.json\"),\n\t);\n\n\tfs.writeFileSync(\n\t\tpath.join(publishDir, PACKAGE_FILE),\n\t\tJSON.stringify(creatorPackage, null, 2),\n\t);\n\n\tconst index = readPackageCreatorIndex(location);\n\n\tif (index !== undefined) {\n\t\tfs.writeFileSync(\n\t\t\tpath.join(publishDir, INDEX_FILE),\n\t\t\tJSON.stringify(index),\n\t\t);\n\t}\n\n\tconst readmeName = fs\n\t\t.readdirSync(location.path)\n\t\t.find((name) => name.toLowerCase() === \"readme.md\");\n\n\tif (readmeName !== undefined) {\n\t\tfs.copyFileSync(\n\t\t\tpath.join(location.path, readmeName),\n\t\t\tpath.join(publishDir, readmeName),\n\t\t);\n\t}\n\n\tif (creatorPackage.Package === \"IG.GFX.Standard\") {\n\t\tconst source = path.join(location.path, \"Images\");\n\t\tconst target = path.join(publishDir, \"Images\");\n\t\tcopyImagesDirectory(source, target);\n\t}\n\n\tconst npmPublishArgs: string[] = [];\n\n\tif (dryRun) {\n\t\tnpmPublishArgs.push(\"--dry-run\");\n\t}\n\n\tif (newVersion.preRelease) {\n\t\tnpmPublishArgs.push(\"--tag\", \"next\");\n\t}\n\n\treporter.log(\n\t\t`Publishing to npm with version ${packageJson.version} using tag ${\n\t\t\tnewVersion.preRelease ? \"next\" : \"latest\"\n\t\t}`,\n\t);\n\n\texecSync([\"npm\", \"publish\", ...npmPublishArgs].join(\" \"), {\n\t\tstdio: \"inherit\",\n\t\tencoding: \"utf8\",\n\t\tcwd: publishDir,\n\t});\n\n\tfor (const packageLocation of iterateWorkspacePackages(workspace)) {\n\t\tconst manifest = readPackageNpmManifest(packageLocation);\n\n\t\tif (manifest?.dependencies?.[packageJson.name] !== undefined) {\n\t\t\tmanifest.dependencies[packageJson.name] = \"^\" + packageJson.version;\n\t\t\twritePackageNpmManifest(packageLocation, manifest);\n\t\t}\n\t}\n};\n\nconst copyImagesDirectory = (source: string, target: string) => {\n\tfs.mkdirSync(target, { recursive: true });\n\n\tfor (const name of fs.readdirSync(source)) {\n\t\tconst sourcePath = path.join(source, name);\n\t\tconst targetPath = path.join(target, name);\n\n\t\tif (fs.statSync(sourcePath).isDirectory()) {\n\t\t\tcopyImagesDirectory(sourcePath, targetPath);\n\t\t} else {\n\t\t\tif (\n\t\t\t\t[\".png\", \".jpg\", \".jpeg\", \".gif\"].includes(path.extname(name))\n\t\t\t) {\n\t\t\t\tfs.copyFileSync(sourcePath, targetPath);\n\t\t\t}\n\t\t}\n\t}\n};\n"],"names":["publishToNpm","workspace","location","version","providedVersion","dryRun","reporter","providedReporter","newVersion","parseVersionFromString","err","Error","buildNumber","preRelease","type","undefined","workspaceManifest","readWorkspaceNpmManifest","workspaceOutputPath","getWorkspaceOutputPath","creatorPackage","readPackageCreatorManifest","createPackageScopedReporter","consoleReporter","Package","packageJson","readPackageNpmManifest","name","toLowerCase","description","toVersionString","toDescriptionString","main","types","publishConfig","acccess","ig","scriptingLibrary","files","publishDir","path","join","fs","rmSync","recursive","force","mkdirSync","writePackageNpmManifest","Version","writePackageCreatorManifest","versionFile","getVersionFileHandler","exists","write","gitVersionInformation","getVersionInformationFromGit","bannerText","getWorkspaceBannerText","buildFolders","packages","minimize","outDir","banner","text","commit","commitDirty","dirty","date","Date","now","copyFileSync","manifestDir","writeFileSync","PACKAGE_FILE","JSON","stringify","index","readPackageCreatorIndex","INDEX_FILE","readmeName","readdirSync","find","source","target","copyImagesDirectory","npmPublishArgs","push","log","execSync","stdio","encoding","cwd","packageLocation","iterateWorkspacePackages","manifest","dependencies","sourcePath","targetPath","statSync","isDirectory","includes","extname"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CO,MAAMA,YAAAA,GAAe,OAAO,EAClCC,SAAS,EACTC,QAAQ,EACRC,OAAAA,EAASC,eAAe,EACxBC,MAAM,EACNC,QAAAA,EAAUC,gBAAgB,EACJ,GAAA;IACtB,IAAIC,UAAAA;IACJ,IAAI;AACHA,QAAAA,UAAAA,GAAaC,sBAAAA,CAAuBL,eAAAA,CAAAA;AACrC,IAAA,CAAA,CAAE,OAAOM,GAAAA,EAAK;AACb,QAAA,MAAM,IAAIC,KAAAA,CAAM,CAAC,+CAA+C,CAAC,CAAA;AAClE,IAAA;IAEA,IAAIH,UAAAA,CAAWI,WAAW,GAAG,GAAA,EAAK;AACjCJ,QAAAA,UAAAA,CAAWK,UAAU,GAAG;YACvBC,IAAA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C,IAAI,CAAC0C,MAAAA,EAAQxD,IAAAA,CAAAA;AAErC,QAAA,IAAIe,EAAAA,CAAGwD,QAAQ,CAACF,UAAAA,CAAAA,CAAYG,WAAW,EAAA,EAAI;AAC1Cf,YAAAA,mBAAAA,CAAoBY,UAAAA,EAAYC,UAAAA,CAAAA;QACjC,CAAA,MAAO;YACN,IACC;AAAC,gBAAA,MAAA;AAAQ,gBAAA,MAAA;AAAQ,gBAAA,OAAA;AAAS,gBAAA;AAAO,aAAA,CAACG,QAAQ,CAAC5D,IAAAA,CAAK6D,OAAO,CAAC1E,IAAAA,CAAAA,CAAAA,EACvD;gBACDe,EAAAA,CAAG4B,YAAY,CAAC0B,UAAAA,EAAYC,UAAAA,CAAAA;AAC7B,YAAA;AACD,QAAA;AACD,IAAA;AACD,CAAA;;;;"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
import * as os from 'os';
|
|
4
|
+
import resolve from 'resolve';
|
|
5
|
+
import { rollup, watch } from 'rollup';
|
|
6
|
+
import rollupPluginNodeResolve from '@rollup/plugin-node-resolve';
|
|
7
|
+
import rollupPluginTypescript from '@rollup/plugin-typescript';
|
|
8
|
+
import rollupPluginBabel from '@rollup/plugin-babel';
|
|
9
|
+
import rollupPluginCommonJs from '@rollup/plugin-commonjs';
|
|
10
|
+
import rollupPluginJson from '@rollup/plugin-json';
|
|
11
|
+
import { bundleFromEntryFile } from '@intelligentgraphics/declarationbundler';
|
|
12
|
+
import { a as resolveScriptPackageEntryModule } from './scripts-Bfojy_uD.mjs';
|
|
13
|
+
import 'glob';
|
|
14
|
+
import 'fs';
|
|
15
|
+
import 'write-pkg';
|
|
16
|
+
import 'node:path';
|
|
17
|
+
import 'node:fs';
|
|
18
|
+
import './cli-CuiqZ39_.mjs';
|
|
19
|
+
import 'update-notifier';
|
|
20
|
+
import 'yargs/yargs';
|
|
21
|
+
import 'url';
|
|
22
|
+
import 'assert';
|
|
23
|
+
import 'events';
|
|
24
|
+
import 'util';
|
|
25
|
+
import 'axios';
|
|
26
|
+
import 'inquirer';
|
|
27
|
+
|
|
28
|
+
function createRollupBuildParticipant(location, manifest, outDir) {
|
|
29
|
+
return (env)=>{
|
|
30
|
+
env.onBuildStart();
|
|
31
|
+
(async ()=>{
|
|
32
|
+
try {
|
|
33
|
+
const rollupConfig = getRollupConfig(location, manifest, outDir);
|
|
34
|
+
const build = await rollup(rollupConfig);
|
|
35
|
+
const output = await build.generate(rollupConfig.output);
|
|
36
|
+
env.onBuildEnd({
|
|
37
|
+
type: "success",
|
|
38
|
+
artefacts: processRollupOutput(output, location, manifest)
|
|
39
|
+
});
|
|
40
|
+
} catch (err) {
|
|
41
|
+
env.onBuildEnd({
|
|
42
|
+
type: "error",
|
|
43
|
+
error: String(err)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
})();
|
|
47
|
+
return {
|
|
48
|
+
destroy: ()=>{}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function createRollupWatchBuildParticipant(location, manifest, outDir) {
|
|
53
|
+
return (env)=>{
|
|
54
|
+
env.onBuildStart();
|
|
55
|
+
const rollupConfig = getRollupConfig(location, manifest, outDir);
|
|
56
|
+
const watcher = watch(rollupConfig);
|
|
57
|
+
watcher.on("event", async (event)=>{
|
|
58
|
+
switch(event.code){
|
|
59
|
+
case "BUNDLE_START":
|
|
60
|
+
env.onBuildStart();
|
|
61
|
+
break;
|
|
62
|
+
case "BUNDLE_END":
|
|
63
|
+
const output = await event.result.generate(rollupConfig.output);
|
|
64
|
+
env.onBuildEnd({
|
|
65
|
+
type: "success",
|
|
66
|
+
artefacts: processRollupOutput(output, location, manifest)
|
|
67
|
+
});
|
|
68
|
+
event.result.close();
|
|
69
|
+
break;
|
|
70
|
+
case "ERROR":
|
|
71
|
+
env.onBuildEnd({
|
|
72
|
+
type: "error",
|
|
73
|
+
error: event.error.message
|
|
74
|
+
});
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
destroy: ()=>watcher.close()
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function getRollupConfig(location, manifest, outDir) {
|
|
84
|
+
const entryModule = resolveScriptPackageEntryModule(location, manifest);
|
|
85
|
+
if (entryModule === undefined) {
|
|
86
|
+
throw new Error(`Could not find an entry module`);
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
input: entryModule,
|
|
90
|
+
plugins: [
|
|
91
|
+
rollupPluginNodeResolve(),
|
|
92
|
+
rollupPluginCommonJs(),
|
|
93
|
+
rollupPluginJson(),
|
|
94
|
+
rollupPluginTypescript({
|
|
95
|
+
compilerOptions: {
|
|
96
|
+
rootDir: location.scriptsDir,
|
|
97
|
+
declaration: true,
|
|
98
|
+
declarationDir: outDir,
|
|
99
|
+
module: "esnext",
|
|
100
|
+
target: "esnext"
|
|
101
|
+
},
|
|
102
|
+
tsconfig: path.join(location.scriptsDir, "tsconfig.json"),
|
|
103
|
+
removeComments: false
|
|
104
|
+
}),
|
|
105
|
+
rollupPluginBabel({
|
|
106
|
+
presets: [
|
|
107
|
+
[
|
|
108
|
+
resolve.sync("@babel/preset-env", {
|
|
109
|
+
basedir: import.meta.dirname
|
|
110
|
+
}),
|
|
111
|
+
{
|
|
112
|
+
corejs: "3",
|
|
113
|
+
useBuiltIns: "usage"
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
],
|
|
117
|
+
targets: {
|
|
118
|
+
ie: "11"
|
|
119
|
+
},
|
|
120
|
+
babelHelpers: "bundled",
|
|
121
|
+
extensions: [
|
|
122
|
+
".ts",
|
|
123
|
+
".js"
|
|
124
|
+
],
|
|
125
|
+
sourceMaps: true,
|
|
126
|
+
exclude: /core-js/
|
|
127
|
+
})
|
|
128
|
+
],
|
|
129
|
+
output: {
|
|
130
|
+
format: "iife",
|
|
131
|
+
name: manifest.Scope ?? manifest.Package,
|
|
132
|
+
dir: outDir,
|
|
133
|
+
sourcemap: "hidden"
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function processRollupOutput(output, location, manifest) {
|
|
138
|
+
const [primaryChunk, ...otherOutputs] = output.output;
|
|
139
|
+
const assets = otherOutputs.filter((chunk)=>chunk.type === "asset");
|
|
140
|
+
const sourceMap = assets.find((asset)=>asset.fileName.endsWith(".js.map"));
|
|
141
|
+
const declarationFileMap = new Map(assets.filter((asset)=>asset.fileName.endsWith(".d.ts")).map((asset)=>{
|
|
142
|
+
return [
|
|
143
|
+
path.resolve(location.scriptsDir, asset.fileName).replaceAll("\\", "/"),
|
|
144
|
+
asset.source
|
|
145
|
+
];
|
|
146
|
+
}));
|
|
147
|
+
const declarations = bundleTSDeclarations(declarationFileMap, declarationFileMap.keys().next().value, manifest.Scope ?? manifest.Package);
|
|
148
|
+
return {
|
|
149
|
+
js: primaryChunk.code,
|
|
150
|
+
declarations: declarations,
|
|
151
|
+
sourceMap: sourceMap?.source
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const referenceRegex = /(\/\/\/ ?<reference .+\/>$)/;
|
|
155
|
+
function bundleTSDeclarations(files, entryFileName, namespace) {
|
|
156
|
+
const references = [];
|
|
157
|
+
for (const [_fileName, content] of files){
|
|
158
|
+
if (content.indexOf("reference") === -1) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const lines = content.split(os.EOL);
|
|
162
|
+
for(let index = 0; index < lines.length; index++){
|
|
163
|
+
const line = lines[index];
|
|
164
|
+
const match = line.match(referenceRegex);
|
|
165
|
+
if (match === null) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (!references.includes(match[1])) {
|
|
169
|
+
references.push(match[1]);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const compilerOptions = {
|
|
174
|
+
removeComments: false
|
|
175
|
+
};
|
|
176
|
+
const host = ts.createCompilerHost(compilerOptions, true);
|
|
177
|
+
host.fileExists = (fileName)=>files.has(fileName);
|
|
178
|
+
host.readFile = (fileName)=>files.get(fileName);
|
|
179
|
+
const program = ts.createProgram({
|
|
180
|
+
host,
|
|
181
|
+
options: compilerOptions,
|
|
182
|
+
rootNames: [
|
|
183
|
+
entryFileName
|
|
184
|
+
]
|
|
185
|
+
});
|
|
186
|
+
const mainFile = program.getSourceFile(entryFileName);
|
|
187
|
+
if (mainFile === undefined) {
|
|
188
|
+
throw new Error(`Unexpected: Failed to find compiled declaration entry module`);
|
|
189
|
+
}
|
|
190
|
+
const result = bundleFromEntryFile(namespace, mainFile, program, host, compilerOptions);
|
|
191
|
+
return [
|
|
192
|
+
...references,
|
|
193
|
+
result
|
|
194
|
+
].join(os.EOL);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export { createRollupBuildParticipant, createRollupWatchBuildParticipant };
|
|
198
|
+
//# sourceMappingURL=rollup-UR3DADp8.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollup-UR3DADp8.mjs","sources":["../src/commands/build/rollup.ts"],"sourcesContent":["import * as path from \"path\";\nimport ts from \"typescript\";\nimport * as os from \"os\";\nimport resolve from \"resolve\";\nimport { rollup, watch, RollupOutput, 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\";\n\nimport { bundleFromEntryFile } from \"@intelligentgraphics/declarationbundler\";\n\nimport { CreatorPackage, PackageLocation } from \"../../lib/package\";\nimport { BuildArtefacts, BuilderEnvironment, BuildParticipant } from \"./types\";\nimport { resolveScriptPackageEntryModule } from \"../../lib/scripts\";\n\nexport function createRollupBuildParticipant(\n\tlocation: PackageLocation,\n\tmanifest: CreatorPackage,\n\toutDir: string,\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);\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(output, location, manifest),\n\t\t\t\t});\n\t\t\t} catch (err) {\n\t\t\t\tenv.onBuildEnd({ type: \"error\", error: String(err) });\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): BuildParticipant {\n\treturn (env: BuilderEnvironment) => {\n\t\tenv.onBuildStart();\n\n\t\tconst rollupConfig = getRollupConfig(location, manifest, outDir);\n\n\t\tconst watcher = watch(rollupConfig);\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\n\t\t\t\t\tenv.onBuildEnd({\n\t\t\t\t\t\ttype: \"success\",\n\t\t\t\t\t\tartefacts: processRollupOutput(\n\t\t\t\t\t\t\toutput,\n\t\t\t\t\t\t\tlocation,\n\t\t\t\t\t\t\tmanifest,\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: event.error.message,\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) {\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\trollupPluginTypescript({\n\t\t\t\tcompilerOptions: {\n\t\t\t\t\trootDir: location.scriptsDir,\n\t\t\t\t\tdeclaration: true,\n\t\t\t\t\tdeclarationDir: 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}),\n\t\t\trollupPluginBabel({\n\t\t\t\tpresets: [\n\t\t\t\t\t[\n\t\t\t\t\t\tresolve.sync(\"@babel/preset-env\", {\n\t\t\t\t\t\t\tbasedir: import.meta.dirname,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcorejs: \"3\",\n\t\t\t\t\t\t\tuseBuiltIns: \"usage\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t\ttargets: {\n\t\t\t\t\tie: \"11\",\n\t\t\t\t},\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},\n\t} satisfies RollupOptions;\n}\n\nfunction processRollupOutput(\n\toutput: RollupOutput,\n\tlocation: PackageLocation,\n\tmanifest: CreatorPackage,\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\tconst declarationFileMap = new Map(\n\t\tassets\n\t\t\t.filter((asset) => asset.fileName.endsWith(\".d.ts\"))\n\t\t\t.map((asset) => {\n\t\t\t\treturn [\n\t\t\t\t\tpath\n\t\t\t\t\t\t.resolve(location.scriptsDir, asset.fileName)\n\t\t\t\t\t\t.replaceAll(\"\\\\\", \"/\"),\n\t\t\t\t\tasset.source as string,\n\t\t\t\t];\n\t\t\t}),\n\t);\n\n\tconst declarations = bundleTSDeclarations(\n\t\tdeclarationFileMap,\n\t\tdeclarationFileMap.keys().next().value,\n\t\tmanifest.Scope ?? manifest.Package,\n\t);\n\n\treturn {\n\t\tjs: primaryChunk.code,\n\t\tdeclarations: declarations,\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\tcompilerOptions,\n\t);\n\treturn [...references, result].join(os.EOL);\n}\n"],"names":["createRollupBuildParticipant","location","manifest","outDir","env","onBuildStart","rollupConfig","getRollupConfig","build","rollup","output","generate","onBuildEnd","type","artefacts","processRollupOutput","err","error","String","destroy","createRollupWatchBuildParticipant","watcher","watch","on","event","code","result","close","message","entryModule","resolveScriptPackageEntryModule","undefined","Error","input","plugins","rollupPluginNodeResolve","rollupPluginCommonJs","rollupPluginJson","rollupPluginTypescript","compilerOptions","rootDir","scriptsDir","declaration","declarationDir","module","target","tsconfig","path","join","removeComments","rollupPluginBabel","presets","resolve","sync","basedir","dirname","corejs","useBuiltIns","targets","ie","babelHelpers","extensions","sourceMaps","exclude","format","name","Scope","Package","dir","sourcemap","primaryChunk","otherOutputs","assets","filter","chunk","sourceMap","find","asset","fileName","endsWith","declarationFileMap","Map","map","replaceAll","source","declarations","bundleTSDeclarations","keys","next","value","js","referenceRegex","files","entryFileName","namespace","references","_fileName","content","indexOf","lines","split","os","EOL","index","length","line","match","includes","push","host","ts","createCompilerHost","fileExists","has","readFile","get","program","createProgram","options","rootNames","mainFile","getSourceFile","bundleFromEntryFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBO,SAASA,4BAA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,eAAAA,CAAAA;IAED,OAAO;AAAIwD,QAAAA,GAAAA,UAAAA;AAAYrE,QAAAA;KAAO,CAACsB,IAAI,CAACqD,EAAAA,CAAGC,GAAG,CAAA;AAC3C;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import glob from 'glob';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import ts from 'typescript';
|
|
5
|
+
import 'resolve';
|
|
6
|
+
import 'write-pkg';
|
|
7
|
+
import 'node:path';
|
|
8
|
+
import 'node:fs';
|
|
9
|
+
import './cli-CuiqZ39_.mjs';
|
|
10
|
+
import 'axios';
|
|
11
|
+
|
|
12
|
+
const getPackageTypescriptFiles = (location)=>glob.sync("**/*.ts", {
|
|
13
|
+
absolute: true,
|
|
14
|
+
cwd: location.scriptsDir,
|
|
15
|
+
ignore: "node_modules/**/*"
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
function resolveScriptPackageEntryModule(location, manifest) {
|
|
19
|
+
let candidates = [
|
|
20
|
+
"index.ts"
|
|
21
|
+
];
|
|
22
|
+
if (manifest.Type === "Context") {
|
|
23
|
+
candidates.push("Context.ts");
|
|
24
|
+
}
|
|
25
|
+
for (const candidate of candidates){
|
|
26
|
+
const candidatePath = path.join(location.scriptsDir, candidate);
|
|
27
|
+
if (fs.existsSync(candidatePath)) {
|
|
28
|
+
return candidatePath;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function readScriptPackageTSConfig(location) {
|
|
33
|
+
const { config } = ts.readConfigFile(path.join(location.scriptsDir, "tsconfig.json"), (path)=>{
|
|
34
|
+
try {
|
|
35
|
+
return fs.readFileSync(path, "utf8");
|
|
36
|
+
} catch {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const parsedTsConfig = ts.parseJsonConfigFileContent(config, ts.sys, location.scriptsDir);
|
|
41
|
+
return parsedTsConfig;
|
|
42
|
+
}
|
|
43
|
+
function isScriptPackageModules(options) {
|
|
44
|
+
return options.module === ts.ModuleKind.ES2015;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { resolveScriptPackageEntryModule as a, getPackageTypescriptFiles as g, isScriptPackageModules as i, readScriptPackageTSConfig as r };
|
|
48
|
+
//# sourceMappingURL=scripts-Bfojy_uD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripts-Bfojy_uD.mjs","sources":["../../tools.core/build/scripts.mjs","../src/lib/scripts.ts"],"sourcesContent":["import glob from 'glob';\n\nconst getPackageTypescriptFiles = (location)=>glob.sync(\"**/*.ts\", {\n absolute: true,\n cwd: location.scriptsDir,\n ignore: \"node_modules/**/*\"\n });\n\nexport { getPackageTypescriptFiles };\n//# sourceMappingURL=scripts.mjs.map\n","import * as fs from \"fs\";\nimport * as path from \"path\";\nimport ts from \"typescript\";\n\nimport {\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"],"names":["getPackageTypescriptFiles","location","glob","sync","absolute","cwd","scriptsDir","ignore","resolveScriptPackageEntryModule","manifest","candidates","Type","push","candidate","candidatePath","path","join","fs","existsSync","readScriptPackageTSConfig","config","ts","readConfigFile","readFileSync","undefined","parsedTsConfig","parseJsonConfigFileContent","sys","isScriptPackageModules","options","module","ModuleKind","ES2015"],"mappings":";;;;;;;;;;;AAEA,MAAMA,4BAA4B,CAACC,QAAAA,GAAWC,IAAAA,CAAKC,IAAI,CAAC,SAAA,EAAW;QAC3DC,QAAAA,EAAU,IAAA;AACVC,QAAAA,GAAAA,EAAKJ,SAASK,UAAU;QACxBC,MAAAA,EAAQ;AACZ,KAAA;;ACKG,SAASC,+BAAAA,CACfP,QAAyB,EACzBQ,QAAwB,EAAA;AAExB,IAAA,IAAIC,UAAAA,GAAa;AAAC,QAAA;AAAW,KAAA;IAE7B,IAAID,QAAAA,CAASE,IAAI,KAAK,SAAA,EAAW;AAChCD,QAAAA,UAAAA,CAAWE,IAAI,CAAC,YAAA,CAAA;AACjB,IAAA;IAEA,KAAK,MAAMC,aAAaH,UAAAA,CAAY;AACnC,QAAA,MAAMI,gBAAgBC,IAAAA,CAAKC,IAAI,CAACf,QAAAA,CAASK,UAAU,EAAEO,SAAAA,CAAAA;QAErD,IAAII,EAAAA,CAAGC,UAAU,CAACJ,aAAAA,CAAAA,EAAgB;YACjC,OAAOA,aAAAA;AACR,QAAA;AACD,IAAA;AACD;AAEO,SAASK,0BAA0BlB,QAAyB,EAAA;AAClE,IAAA,MAAM,EAAEmB,MAAM,EAAE,GAAGC,GAAGC,cAAc,CACnCP,IAAAA,CAAKC,IAAI,CAACf,QAAAA,CAASK,UAAU,EAAE,kBAC/B,CAACS,IAAAA,GAAAA;QACA,IAAI;YACH,OAAOE,EAAAA,CAAGM,YAAY,CAACR,IAAAA,EAAM,MAAA,CAAA;AAC9B,QAAA,CAAA,CAAE,OAAM;YACP,OAAOS,SAAAA;AACR,QAAA;AACD,IAAA,CAAA,CAAA;IAGD,MAAMC,cAAAA,GAAiBJ,GAAGK,0BAA0B,CACnDN,QACAC,EAAAA,CAAGM,GAAG,EACN1B,QAAAA,CAASK,UAAU,CAAA;IAGpB,OAAOmB,cAAAA;AACR;AAEO,SAASG,uBAAuBC,OAA2B,EAAA;AACjE,IAAA,OAAOA,QAAQC,MAAM,KAAKT,EAAAA,CAAGU,UAAU,CAACC,MAAM;AAC/C;;;;"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import simpleGit from 'simple-git';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { P as PackageVersion } from './index-B2kXo6K7.mjs';
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import 'resolve';
|
|
6
|
+
import 'write-pkg';
|
|
7
|
+
import { i as isErrorENOENT } from './cli-CuiqZ39_.mjs';
|
|
8
|
+
import 'glob';
|
|
9
|
+
import 'node:path';
|
|
10
|
+
import 'node:fs';
|
|
11
|
+
import 'axios';
|
|
12
|
+
|
|
13
|
+
const readStringFromFile = (filePath)=>fs.readFileSync(filePath, {
|
|
14
|
+
encoding: "utf8"
|
|
15
|
+
});
|
|
16
|
+
const readStringFromFileOrUndefined = (filePath)=>{
|
|
17
|
+
try {
|
|
18
|
+
return readStringFromFile(filePath);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
if (!isErrorENOENT(err)) {
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getVersionInformationFromGit = async (workspaceLocation, packageLocation)=>{
|
|
28
|
+
try {
|
|
29
|
+
const git = simpleGit({
|
|
30
|
+
baseDir: workspaceLocation.path
|
|
31
|
+
});
|
|
32
|
+
// check wether the files for a folder are changed
|
|
33
|
+
// if so, mark as dirty
|
|
34
|
+
const diff = await git.diffSummary();
|
|
35
|
+
const dirty = diff.files.some((file)=>{
|
|
36
|
+
if (file.file.toLowerCase().includes("releases") || file.file.toLowerCase().endsWith("version.ts") || file.file.toLowerCase().endsWith("package.json")) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const fullPath = path.resolve(workspaceLocation.path, file.file);
|
|
40
|
+
const relativePath = path.relative(packageLocation.path, fullPath);
|
|
41
|
+
return !relativePath.startsWith("..");
|
|
42
|
+
});
|
|
43
|
+
const log = await git.log({
|
|
44
|
+
maxCount: 1
|
|
45
|
+
});
|
|
46
|
+
const commit = !log.latest?.hash ? undefined : log.latest.hash.substring(0, 7);
|
|
47
|
+
return {
|
|
48
|
+
commit,
|
|
49
|
+
dirty,
|
|
50
|
+
commitDate: log.latest?.date
|
|
51
|
+
};
|
|
52
|
+
} catch (err) {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const getWorkspaceBannerText = (manifest)=>{
|
|
58
|
+
let bannerText = manifest?.packager?.banner;
|
|
59
|
+
if (bannerText) {
|
|
60
|
+
const match = bannerText.match(/Copyright \(C\) (\d+)( ?- ?(\d+))?/);
|
|
61
|
+
if (match !== null) {
|
|
62
|
+
const startYear = parseInt(match[1]);
|
|
63
|
+
const endYear = new Date().getFullYear();
|
|
64
|
+
if (startYear !== endYear) {
|
|
65
|
+
bannerText = bannerText.replace(match[0], `Copyright (C) ${startYear} - ${endYear}`);
|
|
66
|
+
} else {
|
|
67
|
+
bannerText = bannerText.replace(match[0], `Copyright (C) ${startYear}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return bannerText;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const parseVersionFromString = (input)=>{
|
|
75
|
+
if (input === undefined) {
|
|
76
|
+
throw new Error(`Can not parse version from undefined`);
|
|
77
|
+
}
|
|
78
|
+
let match;
|
|
79
|
+
let major;
|
|
80
|
+
let minor;
|
|
81
|
+
let patch;
|
|
82
|
+
let build;
|
|
83
|
+
let preReleaseType;
|
|
84
|
+
let preReleaseNumber;
|
|
85
|
+
if (// first try to find a full match with build number
|
|
86
|
+
(match = input.match(/(\d+)\.(\d+)\.(\d+)\.(\d+)(-([^\.]+)\.(\d+))?/)) !== null) {
|
|
87
|
+
[, major, minor, patch, build, preReleaseType, preReleaseNumber] = match;
|
|
88
|
+
} else if ((match = input.match(/(\d+)\.(\d+)\.(\d+)(-([^\.]+)\.(\d+))?/)) !== null) {
|
|
89
|
+
[, major, minor, patch, , preReleaseType, preReleaseNumber] = match;
|
|
90
|
+
}
|
|
91
|
+
if (match === null) {
|
|
92
|
+
throw new Error(`Could not parse version from input: ${input}`);
|
|
93
|
+
}
|
|
94
|
+
let preRelease = undefined;
|
|
95
|
+
let buildNumber = 100;
|
|
96
|
+
if (preReleaseType && preReleaseNumber) {
|
|
97
|
+
preRelease = {
|
|
98
|
+
type: preReleaseType,
|
|
99
|
+
version: parseInt(preReleaseNumber)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (build) {
|
|
103
|
+
buildNumber = Number(build);
|
|
104
|
+
} else if (input) {
|
|
105
|
+
const descriptionMatch = input.match(/(\d+)\)$/);
|
|
106
|
+
if (descriptionMatch) {
|
|
107
|
+
buildNumber = parseInt(descriptionMatch[1]);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return new PackageVersion(parseInt(major), parseInt(minor), parseInt(patch), preRelease, buildNumber);
|
|
111
|
+
};
|
|
112
|
+
// 1000001001 -> 1.0.1.1
|
|
113
|
+
// 1002017001 -> 1.2.17.1
|
|
114
|
+
const parseVersionFromNumericVersion = (version)=>{
|
|
115
|
+
const major = Math.floor(version / 1000000000);
|
|
116
|
+
const minor = Math.floor(version % 1000000000 / 1000000);
|
|
117
|
+
const patch = Math.floor(version % 1000000 / 1000);
|
|
118
|
+
const buildNumber = version % 1000;
|
|
119
|
+
return new PackageVersion(major, minor, patch, undefined, buildNumber);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// https://regex101.com/r/LtGAu5/1
|
|
123
|
+
const logRegex = /console\.log\(\s*"([\w\s\.\(\)]+)\ *Copyright[\w\s\(\)\.]+(\d{4}|\d{4} - \d{4})([\w\s\(\)\.]+)?",?\s*\)/i;
|
|
124
|
+
const currentYear = new Date(Date.now()).getFullYear();
|
|
125
|
+
function getVersionFileHandler(location) {
|
|
126
|
+
const filePath = path.join(location.scriptsDir, "Version.ts");
|
|
127
|
+
function invalidVersionFile(versionFile, exists) {
|
|
128
|
+
return {
|
|
129
|
+
exists,
|
|
130
|
+
write: (name, newVersion)=>{
|
|
131
|
+
const scriptsContent = fs.readdirSync(location.scriptsDir);
|
|
132
|
+
const tsFiles = scriptsContent.filter((file)=>file.endsWith(".ts"));
|
|
133
|
+
if (tsFiles.length > 0) {
|
|
134
|
+
return createVersionFileWriter([
|
|
135
|
+
currentYear
|
|
136
|
+
], "")(name, newVersion);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
reset: ()=>{
|
|
140
|
+
if (versionFile !== undefined) {
|
|
141
|
+
fs.writeFileSync(filePath, versionFile, {
|
|
142
|
+
encoding: "utf8"
|
|
143
|
+
});
|
|
144
|
+
} else {
|
|
145
|
+
try {
|
|
146
|
+
fs.rmSync(filePath);
|
|
147
|
+
} catch (err) {
|
|
148
|
+
if (!isErrorENOENT(err)) {
|
|
149
|
+
throw err;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function createVersionFileWriter(copyright = [
|
|
157
|
+
currentYear
|
|
158
|
+
], copyrightStuff = "") {
|
|
159
|
+
return (name, newVersion)=>{
|
|
160
|
+
const descriptionText = newVersion.toDescriptionString(name);
|
|
161
|
+
const copyrightText = createYearString(copyright);
|
|
162
|
+
const result = `console.log("${descriptionText}. Copyright (C) ${copyrightText}${copyrightStuff}");`;
|
|
163
|
+
fs.writeFileSync(filePath, result, {
|
|
164
|
+
encoding: "utf-8"
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
let rawVersionFile = readStringFromFileOrUndefined(filePath);
|
|
169
|
+
if (rawVersionFile === undefined) {
|
|
170
|
+
return invalidVersionFile(rawVersionFile, false);
|
|
171
|
+
}
|
|
172
|
+
const versionFile = rawVersionFile.replace(/\n/g, "");
|
|
173
|
+
const match = versionFile.match(logRegex);
|
|
174
|
+
if (!match) {
|
|
175
|
+
return invalidVersionFile(versionFile, true);
|
|
176
|
+
}
|
|
177
|
+
const [_full, _description, copyright, copyrightStuff] = match;
|
|
178
|
+
const copyrightYears = copyright.match(/^(\d+)( ?- ?(\d+))?$/);
|
|
179
|
+
let years;
|
|
180
|
+
if (copyrightYears === null) {
|
|
181
|
+
years = [
|
|
182
|
+
currentYear
|
|
183
|
+
];
|
|
184
|
+
} else {
|
|
185
|
+
years = [
|
|
186
|
+
Number(copyrightYears[1]),
|
|
187
|
+
currentYear
|
|
188
|
+
];
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
exists: true,
|
|
192
|
+
write: createVersionFileWriter(years, copyrightStuff),
|
|
193
|
+
reset: ()=>{
|
|
194
|
+
fs.writeFileSync(filePath, versionFile, {
|
|
195
|
+
encoding: "utf8"
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
const createYearString = (years)=>{
|
|
201
|
+
if (years[1] === undefined || years[0] === years[1]) {
|
|
202
|
+
return years[0].toString();
|
|
203
|
+
}
|
|
204
|
+
return `${years[0]} - ${years[1]}`;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export { parseVersionFromString as a, getVersionInformationFromGit as b, getWorkspaceBannerText as c, getVersionFileHandler as g, parseVersionFromNumericVersion as p };
|
|
208
|
+
//# sourceMappingURL=versionFile-DSqOw-XB.mjs.map
|