@intelligentgraphics/ig.gfx.packager 3.0.0-alpha.9 → 3.0.0-beta.1
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/cli.mjs +48 -336
- package/build/cli.mjs.map +1 -1
- package/build/commands/build/docs.mjs +34 -0
- package/build/commands/build/docs.mjs.map +1 -0
- package/build/commands/build/index.mjs +169 -0
- package/build/commands/build/index.mjs.map +1 -0
- package/build/commands/build/tsc.mjs +84 -0
- package/build/commands/build/tsc.mjs.map +1 -0
- package/build/{generate.mjs → commands/generate.mjs} +6 -16
- package/build/commands/generate.mjs.map +1 -0
- package/build/{postinstall.mjs → commands/postinstall.mjs} +3 -10
- package/build/commands/postinstall.mjs.map +1 -0
- package/build/{index3.mjs → commands/publish/index.mjs} +20 -288
- package/build/commands/publish/index.mjs.map +1 -0
- package/build/commands/publish/zip.mjs +168 -0
- package/build/commands/publish/zip.mjs.map +1 -0
- package/build/{publishNpm.mjs → commands/publishNpm.mjs} +10 -18
- package/build/commands/publishNpm.mjs.map +1 -0
- package/build/index.mjs +1 -1
- package/build/index.mjs.map +1 -1
- package/build/lib/assetService.mjs +111 -0
- package/build/lib/assetService.mjs.map +1 -0
- package/build/lib/banner.mjs +20 -0
- package/build/lib/banner.mjs.map +1 -0
- package/build/{dependencies.mjs → lib/dependencies.mjs} +9 -60
- package/build/lib/dependencies.mjs.map +1 -0
- package/build/lib/error.mjs +15 -0
- package/build/lib/error.mjs.map +1 -0
- package/build/lib/fs.mjs +19 -0
- package/build/lib/fs.mjs.map +1 -0
- package/build/lib/git.mjs +37 -0
- package/build/lib/git.mjs.map +1 -0
- package/build/lib/localization.mjs +16 -0
- package/build/lib/localization.mjs.map +1 -0
- package/build/lib/log.mjs +9 -0
- package/build/lib/log.mjs.map +1 -0
- package/build/lib/npmPackage.mjs +19 -0
- package/build/lib/npmPackage.mjs.map +1 -0
- package/build/lib/package.mjs +129 -0
- package/build/lib/package.mjs.map +1 -0
- package/build/lib/packageVersion.mjs +174 -0
- package/build/lib/packageVersion.mjs.map +1 -0
- package/build/lib/parseVersion.mjs +54 -0
- package/build/lib/parseVersion.mjs.map +1 -0
- package/build/lib/prompter.mjs +31 -0
- package/build/lib/prompter.mjs.map +1 -0
- package/build/lib/publishedPackage.mjs +66 -0
- package/build/lib/publishedPackage.mjs.map +1 -0
- package/build/{scripts.mjs → lib/scripts.mjs} +1 -2
- package/build/lib/scripts.mjs.map +1 -0
- package/build/lib/stripUtf8Bom.mjs +11 -0
- package/build/lib/stripUtf8Bom.mjs.map +1 -0
- package/build/lib/toposort.mjs +26 -0
- package/build/lib/toposort.mjs.map +1 -0
- package/build/lib/versionFile.mjs +78 -0
- package/build/lib/versionFile.mjs.map +1 -0
- package/build/lib/workspace.mjs +51 -0
- package/build/lib/workspace.mjs.map +1 -0
- package/locales/de.json +18 -18
- package/locales/en.json +37 -37
- package/package.json +2 -2
- package/readme.md +29 -2
- package/scripts/postinstall.js +22 -22
- package/build/dependencies.mjs.map +0 -1
- package/build/generate.mjs.map +0 -1
- package/build/index2.mjs +0 -326
- package/build/index2.mjs.map +0 -1
- package/build/index3.mjs.map +0 -1
- package/build/postinstall.mjs.map +0 -1
- package/build/publishNpm.mjs.map +0 -1
- package/build/scripts.mjs.map +0 -1
- package/build/versionFile.mjs +0 -365
- package/build/versionFile.mjs.map +0 -1
package/locales/de.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
{
|
|
2
|
-
"options.banner": "Text, der als Kommentar über dem kompilierten Code eingefügt wird",
|
|
3
|
-
"options.outDir": "Ziel-Verzeichnis für den kompilierten Code",
|
|
4
|
-
"options.minimize": "Minifiziere den kompilierten Code mit Terser",
|
|
5
|
-
"options.cwd": "Ausführungs-Verzeichnis",
|
|
6
|
-
"options.clean": "Ziel-Ordner vor dem Kompilieren leeren",
|
|
7
|
-
"messages.skipEmpty": "Es wurden keine Ordner beim Ausführen des Programms angegeben. Kompilation wird übersprungen",
|
|
8
|
-
"messages.building": "Kompiliere",
|
|
9
|
-
"messages.built": "Kompilation fertiggestellt",
|
|
10
|
-
"messages.invalidPackageFolder": "Konnte keine _Package.json Datei in \"%s\" finden",
|
|
11
|
-
"messages.movingReleaseZip": "Release-Zip wird in den Release-Ordner bewegt",
|
|
12
|
-
"messages.error": "Ausführung wurde wegen folgendem Fehler gestoppt: %s",
|
|
13
|
-
"release.newVersionQuestion": "Bitte gib die neue Versions-Nummer für %s an (Aktuell: %s)",
|
|
14
|
-
"release.publishConfirmQuestion": "Möchtest du %s mit der Version %s veröffentlichen?",
|
|
15
|
-
"release.domainQuestion": "Welche Domain soll verwendet werden?",
|
|
16
|
-
"release.subdomainQuestion": "Welche Sub-Domain soll verwendet werden?",
|
|
17
|
-
"release.noVersion": "Keine"
|
|
18
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"options.banner": "Text, der als Kommentar über dem kompilierten Code eingefügt wird",
|
|
3
|
+
"options.outDir": "Ziel-Verzeichnis für den kompilierten Code",
|
|
4
|
+
"options.minimize": "Minifiziere den kompilierten Code mit Terser",
|
|
5
|
+
"options.cwd": "Ausführungs-Verzeichnis",
|
|
6
|
+
"options.clean": "Ziel-Ordner vor dem Kompilieren leeren",
|
|
7
|
+
"messages.skipEmpty": "Es wurden keine Ordner beim Ausführen des Programms angegeben. Kompilation wird übersprungen",
|
|
8
|
+
"messages.building": "Kompiliere",
|
|
9
|
+
"messages.built": "Kompilation fertiggestellt",
|
|
10
|
+
"messages.invalidPackageFolder": "Konnte keine _Package.json Datei in \"%s\" finden",
|
|
11
|
+
"messages.movingReleaseZip": "Release-Zip wird in den Release-Ordner bewegt",
|
|
12
|
+
"messages.error": "Ausführung wurde wegen folgendem Fehler gestoppt: %s",
|
|
13
|
+
"release.newVersionQuestion": "Bitte gib die neue Versions-Nummer für %s an (Aktuell: %s)",
|
|
14
|
+
"release.publishConfirmQuestion": "Möchtest du %s mit der Version %s veröffentlichen?",
|
|
15
|
+
"release.domainQuestion": "Welche Domain soll verwendet werden?",
|
|
16
|
+
"release.subdomainQuestion": "Welche Sub-Domain soll verwendet werden?",
|
|
17
|
+
"release.noVersion": "Keine"
|
|
18
|
+
}
|
package/locales/en.json
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"options.banner.description": "Specify a banner which will be inserted as a comment above the code",
|
|
3
|
-
"options.outDir.description": "Output directory",
|
|
4
|
-
"options.minimize.description": "Minify output",
|
|
5
|
-
"options.cwd.description": "Working directory",
|
|
6
|
-
"options.clean.description": "Empty output dir before compiling",
|
|
7
|
-
"options.noUpload.description": "Only zip built files",
|
|
8
|
-
"options.newVersion.description": "Predefine the target version",
|
|
9
|
-
"options.domain.description": "Overwrite the publish domain",
|
|
10
|
-
"options.subdomain.description": "Overwrite the publish subdomain",
|
|
11
|
-
"options.address.description": "Address",
|
|
12
|
-
"options.service.description": "IG.Asset.Server url",
|
|
13
|
-
"options.service.demands": "The IG.Asset.Server url has to either be provided using the option --service or through the \"%s\" environment variable",
|
|
14
|
-
"options.user.description": "User",
|
|
15
|
-
"options.user.demands": "The username has to either be provided using the option --user or through the \"%s\" environment variable",
|
|
16
|
-
"options.password.description": "Password",
|
|
17
|
-
"options.password.demands": "The user password has to either be provided using the option --password or through the \"%s\" environment variable",
|
|
18
|
-
"options.pushOnly.description": "Try to upload an existing zip file without building and validating the version number",
|
|
19
|
-
"options.noValidate.description": "Skip validation of wether newVersion is higher than the current version for releases",
|
|
20
|
-
"options.docs.description": "Generates typedoc",
|
|
21
|
-
"options.ignore.description": "Files to ignore while generating index",
|
|
22
|
-
"options.license.description": "Path to a license file",
|
|
23
|
-
"messages.buildSkipEmpty": "No build targets found. Please check wether a folder with the provided name exists and wether it has _Package.json.",
|
|
24
|
-
"messages.releaseSkipEmpty": "No release targets found. Please check wether a folder with the provided name exists and wether it has _Package.json.",
|
|
25
|
-
"messages.building": "Creating javascript files",
|
|
26
|
-
"messages.invalidPackageFolder": "Could not find a _Package.json file in \"%s\"",
|
|
27
|
-
"messages.movingReleaseZip": "Copying zip to releases folder",
|
|
28
|
-
"messages.error": "Stopped execution because of the following error: %s",
|
|
29
|
-
"messages.missingUploadArgs": "Can not upload the package because of the following issues:",
|
|
30
|
-
"messages.basicsCopy": "Copying basics to lib folder",
|
|
31
|
-
"messages.docsGeneration": "Generating typedoc",
|
|
32
|
-
"release.newVersionQuestion": "Please input a new version number for %s (Current: %s)",
|
|
33
|
-
"release.publishConfirmQuestion": "Do you want to publish %s ",
|
|
34
|
-
"release.domainQuestion": "Which domain should be used?",
|
|
35
|
-
"release.subdomainQuestion": "Which sub domain should be used?",
|
|
36
|
-
"release.noVersion": "None"
|
|
37
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"options.banner.description": "Specify a banner which will be inserted as a comment above the code",
|
|
3
|
+
"options.outDir.description": "Output directory",
|
|
4
|
+
"options.minimize.description": "Minify output",
|
|
5
|
+
"options.cwd.description": "Working directory",
|
|
6
|
+
"options.clean.description": "Empty output dir before compiling",
|
|
7
|
+
"options.noUpload.description": "Only zip built files",
|
|
8
|
+
"options.newVersion.description": "Predefine the target version",
|
|
9
|
+
"options.domain.description": "Overwrite the publish domain",
|
|
10
|
+
"options.subdomain.description": "Overwrite the publish subdomain",
|
|
11
|
+
"options.address.description": "Address",
|
|
12
|
+
"options.service.description": "IG.Asset.Server url",
|
|
13
|
+
"options.service.demands": "The IG.Asset.Server url has to either be provided using the option --service or through the \"%s\" environment variable",
|
|
14
|
+
"options.user.description": "User",
|
|
15
|
+
"options.user.demands": "The username has to either be provided using the option --user or through the \"%s\" environment variable",
|
|
16
|
+
"options.password.description": "Password",
|
|
17
|
+
"options.password.demands": "The user password has to either be provided using the option --password or through the \"%s\" environment variable",
|
|
18
|
+
"options.pushOnly.description": "Try to upload an existing zip file without building and validating the version number",
|
|
19
|
+
"options.noValidate.description": "Skip validation of wether newVersion is higher than the current version for releases",
|
|
20
|
+
"options.docs.description": "Generates typedoc",
|
|
21
|
+
"options.ignore.description": "Files to ignore while generating index",
|
|
22
|
+
"options.license.description": "Path to a license file",
|
|
23
|
+
"messages.buildSkipEmpty": "No build targets found. Please check wether a folder with the provided name exists and wether it has _Package.json.",
|
|
24
|
+
"messages.releaseSkipEmpty": "No release targets found. Please check wether a folder with the provided name exists and wether it has _Package.json.",
|
|
25
|
+
"messages.building": "Creating javascript files",
|
|
26
|
+
"messages.invalidPackageFolder": "Could not find a _Package.json file in \"%s\"",
|
|
27
|
+
"messages.movingReleaseZip": "Copying zip to releases folder",
|
|
28
|
+
"messages.error": "Stopped execution because of the following error: %s",
|
|
29
|
+
"messages.missingUploadArgs": "Can not upload the package because of the following issues:",
|
|
30
|
+
"messages.basicsCopy": "Copying basics to lib folder",
|
|
31
|
+
"messages.docsGeneration": "Generating typedoc",
|
|
32
|
+
"release.newVersionQuestion": "Please input a new version number for %s (Current: %s)",
|
|
33
|
+
"release.publishConfirmQuestion": "Do you want to publish %s ",
|
|
34
|
+
"release.domainQuestion": "Which domain should be used?",
|
|
35
|
+
"release.subdomainQuestion": "Which sub domain should be used?",
|
|
36
|
+
"release.noVersion": "None"
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intelligentgraphics/ig.gfx.packager",
|
|
3
|
-
"version": "3.0.0-
|
|
4
|
-
"description": "IG.GFX.Packager 3.0.0
|
|
3
|
+
"version": "3.0.0-beta.1",
|
|
4
|
+
"description": "IG.GFX.Packager 3.0.0 Beta 1 (3.0.0.12)",
|
|
5
5
|
"author": "Michael Beier <mb@intelligentgraphics.biz>",
|
|
6
6
|
"main": "build/index.mjs",
|
|
7
7
|
"private": false,
|
package/readme.md
CHANGED
|
@@ -61,7 +61,7 @@ npm install -g @intelligentgraphics/ig.gfx.packager@latest
|
|
|
61
61
|
|
|
62
62
|
## Update
|
|
63
63
|
|
|
64
|
-
You can update the installed
|
|
64
|
+
You can update the installed packager by running `npm install -g @intelligentgraphics/ig.gfx.packager@latest` again.
|
|
65
65
|
|
|
66
66
|
## Environment configuration
|
|
67
67
|
|
|
@@ -170,7 +170,17 @@ You can add a reference by including the following comment at the top of the fil
|
|
|
170
170
|
/// <reference types="@intelligentgraphics/3d.ig.gfx.standard" />
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
-
The packager also replaces the content of the legacy definition files within the lib folder with a reference to the installed definition file
|
|
173
|
+
The packager also replaces the content of the legacy definition files within the lib folder with a reference to the installed definition file. The files are created when executing `npm install` or `npm run postinstall`.
|
|
174
|
+
Old packages do not need to be updated to use these new dependencies.
|
|
175
|
+
|
|
176
|
+
### Migrating to ig.gfx.packager 3.0
|
|
177
|
+
|
|
178
|
+
The preferred installation method of the ig.gfx.packager has changed with version 3.0. The packager should now be installed as a global dependency once rather than a local dependency for every single workspace.
|
|
179
|
+
|
|
180
|
+
The following steps are required to migrate to the new packager:
|
|
181
|
+
|
|
182
|
+
1. Install the packager globally by executing `npm install -g @intelligentgraphics/ig.gfx.packager`
|
|
183
|
+
2. Uninstall the packager by executing `npm uninstall @intelligentgraphics/ig.gfx.packager` in every workspace.
|
|
174
184
|
|
|
175
185
|
### Migrating the build.txt
|
|
176
186
|
|
|
@@ -309,6 +319,23 @@ The ts files have to adhere to a certain form to be processed.
|
|
|
309
319
|
|
|
310
320
|
## History
|
|
311
321
|
|
|
322
|
+
**IG.GFX.Packager 3.0.0-beta.1**
|
|
323
|
+
|
|
324
|
+
- restructure to fix release on windows
|
|
325
|
+
- preserve original module structure for output
|
|
326
|
+
|
|
327
|
+
**IG.GFX.Packager 3.0.0**
|
|
328
|
+
|
|
329
|
+
- change packager to be installed globally (see [Migrating to ig.gfx.packager 3.0](#Migrating-to-ig.gfx.packager-3.0))
|
|
330
|
+
- offer to upload dependencies, that are defined in the workspace package json, to a creator sub domain if they are not available or outdated (see [Declaring dependencies on ig libraries](#declaring-dependencies-on-ig-libraries))
|
|
331
|
+
|
|
332
|
+
**IG.GFX.Packager 3.0.0-beta.0**
|
|
333
|
+
|
|
334
|
+
- update readme
|
|
335
|
+
- ignore utf8 bom
|
|
336
|
+
- improve readme
|
|
337
|
+
- fix chunk file names handling to also work on windows
|
|
338
|
+
|
|
312
339
|
**IG.GFX.Packager 3.0.0-alpha.9**
|
|
313
340
|
|
|
314
341
|
- change packager to be installed globally
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
const fs = require("fs");
|
|
3
|
-
|
|
4
|
-
try {
|
|
5
|
-
const filePath = path.join(process.cwd(), "package.json");
|
|
6
|
-
const manifest = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
7
|
-
|
|
8
|
-
if (manifest.name !== "@intelligentgraphics/ig.gfx.packager") {
|
|
9
|
-
if (manifest.scripts === undefined) {
|
|
10
|
-
manifest.scripts = {};
|
|
11
|
-
} else {
|
|
12
|
-
if (manifest.scripts.release === "packager release") {
|
|
13
|
-
delete manifest.scripts.release;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
manifest.scripts.build = "packager build";
|
|
18
|
-
manifest.scripts.upload = "packager upload";
|
|
19
|
-
|
|
20
|
-
fs.writeFileSync(filePath, JSON.stringify(manifest, undefined, 2));
|
|
21
|
-
}
|
|
22
|
-
} catch {}
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
|
|
4
|
+
try {
|
|
5
|
+
const filePath = path.join(process.cwd(), "package.json");
|
|
6
|
+
const manifest = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
7
|
+
|
|
8
|
+
if (manifest.name !== "@intelligentgraphics/ig.gfx.packager") {
|
|
9
|
+
if (manifest.scripts === undefined) {
|
|
10
|
+
manifest.scripts = {};
|
|
11
|
+
} else {
|
|
12
|
+
if (manifest.scripts.release === "packager release") {
|
|
13
|
+
delete manifest.scripts.release;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
manifest.scripts.build = "packager build";
|
|
18
|
+
manifest.scripts.upload = "packager upload";
|
|
19
|
+
|
|
20
|
+
fs.writeFileSync(filePath, JSON.stringify(manifest, undefined, 2));
|
|
21
|
+
}
|
|
22
|
+
} catch {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.mjs","sources":["../src/lib/publishedPackage.ts","../src/lib/dependencies.ts"],"sourcesContent":["import * as path from \"path\";\r\nimport * as fs from \"fs\";\r\nimport resolve from \"resolve\";\r\n\r\nimport { readNpmManifest } from \"./npmPackage\";\r\nimport {\r\n\tCreatorPackage,\r\n\tINDEX_FILE,\r\n\tPackageNpmManifest,\r\n\tPACKAGE_FILE,\r\n} from \"./package\";\r\nimport { isErrorENOENT } from \"./error\";\r\nimport { WorkspaceLocation } from \"./workspace\";\r\n\r\n/**\r\n * Describes the location of a single published package.\r\n *\r\n * I.e. node_modules/@intelligentgraphics/3d.ig.gfx.core\r\n *\r\n * @export\r\n * @interface PublishedPackageLocation\r\n */\r\nexport interface PublishedPackageLocation {\r\n\t_kind: \"PublishedPackageLocation\";\r\n\tpath: string;\r\n}\r\n\r\nexport const detectPublishedPackageByModuleName = (\r\n\tworkspace: WorkspaceLocation,\r\n\tname: string,\r\n) => {\r\n\tconst manifestPath = resolve.sync(name + \"/package.json\", {\r\n\t\tbasedir: workspace.path,\r\n\t});\r\n\tconst dir = path.dirname(manifestPath);\r\n\treturn detectPublishedPackage(dir);\r\n};\r\n\r\nexport const detectPublishedPackage = (\r\n\tpath: string,\r\n): PublishedPackageLocation => ({\r\n\t_kind: \"PublishedPackageLocation\",\r\n\tpath,\r\n});\r\n\r\nexport const readPublishedPackageNpmManifest = (\r\n\tlocation: PublishedPackageLocation,\r\n): PackageNpmManifest => {\r\n\treturn readNpmManifest<PackageNpmManifest>(location.path);\r\n};\r\n\r\nexport const readPublishedPackageCreatorManifest = (\r\n\tlocation: PublishedPackageLocation,\r\n): CreatorPackage | undefined => {\r\n\ttry {\r\n\t\tconst packageJsonPath = path.join(location.path, PACKAGE_FILE);\r\n\t\tconst packageJson = fs.readFileSync(packageJsonPath, {\r\n\t\t\tencoding: \"utf8\",\r\n\t\t});\r\n\t\tconst result: Omit<CreatorPackage, \"Scope\"> & { Scope?: string } =\r\n\t\t\tJSON.parse(packageJson);\r\n\t\treturn {\r\n\t\t\t...result,\r\n\t\t\tScope: result.Scope || result.Package,\r\n\t\t};\r\n\t} catch (err) {\r\n\t\tif (isErrorENOENT(err)) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\r\n\t\tthrow err;\r\n\t}\r\n};\r\n\r\nexport const readPublishedPackageCreatorIndex = (\r\n\tlocation: PublishedPackageLocation,\r\n) => {\r\n\ttry {\r\n\t\tconst packageJsonPath = path.join(location.path, INDEX_FILE);\r\n\t\tconst packageJson = fs.readFileSync(packageJsonPath, {\r\n\t\t\tencoding: \"utf8\",\r\n\t\t});\r\n\t\tconst result: object = JSON.parse(packageJson);\r\n\t\treturn result;\r\n\t} catch (err) {\r\n\t\tif (isErrorENOENT(err)) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\r\n\t\tthrow err;\r\n\t}\r\n};\r\n","import { CreatorPackage } from \"./package\";\r\nimport { PackageJSON } from \"./packageJSON\";\r\nimport {\r\n\tdetectPublishedPackageByModuleName,\r\n\tPublishedPackageLocation,\r\n\treadPublishedPackageCreatorManifest,\r\n\treadPublishedPackageNpmManifest,\r\n} from \"./publishedPackage\";\r\nimport { readWorkspaceNpmManifest, WorkspaceLocation } from \"./workspace\";\r\n\r\n// /**\r\n// * Determines the implicit dependencies of a an actual data workspace package.\r\n// *\r\n// * An implicit dependency is a dependency that is installed for the workspace and has the same runtime environment (evaluator, interactor) as the package.\r\n// *\r\n// * @param {WorkspaceLocation} workspace\r\n// * @param {CreatorPackage} creatorPackage\r\n// * @returns {PublishedPackageLocation[]}\r\n// */\r\n// export const determinePackageImplicitDependencies = (\r\n// \tworkspace: WorkspaceLocation,\r\n// \tcreatorPackage: CreatorPackage,\r\n// ): PublishedPackageLocation[] => {\r\n// \tconst libraries = determineWorkspaceIGLibraries(workspace);\r\n\r\n// \tconst results: PublishedPackageLocation[] = [];\r\n// \tfor (const librarylocation of libraries) {\r\n// \t\tconst libraryManifest =\r\n// \t\t\treadPublishedPackageCreatorManifest(librarylocation);\r\n\r\n// \t\tif (\r\n// \t\t\tlibraryManifest !== undefined &&\r\n// \t\t\t(libraryManifest.Type === \"Mixed\" ||\r\n// \t\t\t\tlibraryManifest.RunTime === creatorPackage.RunTime)\r\n// \t\t) {\r\n// \t\t\tresults.push(librarylocation);\r\n// \t\t}\r\n// \t}\r\n\r\n// \treturn results;\r\n// };\r\n\r\n/**\r\n * Recursively determines all installed ig libraries for a workspace.\r\n *\r\n * @param {WorkspaceLocation} workspace\r\n * @returns {PublishedPackageLocation[]}\r\n */\r\nexport const determineWorkspaceIGLibraries = (\r\n\tworkspace: WorkspaceLocation,\r\n): PublishedPackageLocation[] => {\r\n\tconst manifest = readWorkspaceNpmManifest(workspace);\r\n\r\n\tif (manifest === undefined) {\r\n\t\treturn [];\r\n\t}\r\n\r\n\tconst libraries = collectIGLibraries(workspace, manifest);\r\n\tconst results = new Map<string, PublishedPackageLocation>();\r\n\r\n\tfor (const location of libraries) {\r\n\t\tconst manifest = readPublishedPackageNpmManifest(location);\r\n\t\tif (!results.has(manifest.name)) {\r\n\t\t\tresults.set(manifest.name, location);\r\n\t\t}\r\n\t}\r\n\r\n\treturn Array.from(results.values());\r\n};\r\n\r\nconst collectIGLibraries = (\r\n\tworkspace: WorkspaceLocation,\r\n\tmanifest: PackageJSON,\r\n): PublishedPackageLocation[] => {\r\n\tif (!manifest.dependencies) {\r\n\t\treturn [];\r\n\t}\r\n\r\n\tconst runtimeDependencies = Object.getOwnPropertyNames(\r\n\t\tmanifest.dependencies,\r\n\t);\r\n\r\n\tconst result: PublishedPackageLocation[] = [];\r\n\r\n\tfor (const runtimeDependency of runtimeDependencies) {\r\n\t\tconst location = detectPublishedPackageByModuleName(\r\n\t\t\tworkspace,\r\n\t\t\truntimeDependency,\r\n\t\t);\r\n\r\n\t\tconst runtimeManifest = readPublishedPackageNpmManifest(location);\r\n\r\n\t\t// packages need to explicitly be marked as ig scriptingLibraries\r\n\t\tif (runtimeManifest.ig?.scriptingLibrary) {\r\n\t\t\tresult.push(location);\r\n\t\t\tresult.push(...collectIGLibraries(workspace, runtimeManifest));\r\n\t\t}\r\n\t}\r\n\r\n\treturn result;\r\n};\r\n"],"names":["detectPublishedPackageByModuleName","workspace","name","manifestPath","resolve","sync","basedir","path","dir","dirname","detectPublishedPackage","_kind","readPublishedPackageNpmManifest","location","readNpmManifest","readPublishedPackageCreatorManifest","packageJsonPath","join","PACKAGE_FILE","packageJson","fs","readFileSync","encoding","result","JSON","parse","Scope","Package","err","isErrorENOENT","undefined","readPublishedPackageCreatorIndex","INDEX_FILE","determineWorkspaceIGLibraries","manifest","readWorkspaceNpmManifest","libraries","collectIGLibraries","results","Map","has","set","Array","from","values","dependencies","runtimeDependencies","Object","getOwnPropertyNames","runtimeDependency","runtimeManifest","ig","scriptingLibrary","push"],"mappings":";;;;;;AA2BO,MAAMA,kCAAkC,GAAG,CACjDC,SAA4B,EAC5BC,IAAY,KACR;EACJ,MAAMC,YAAY,GAAGC,OAAO,CAACC,IAAI,CAACH,IAAI,GAAG,eAAe,EAAE;IACzDI,OAAO,EAAEL,SAAS,CAACM,IAAAA;AACpB,GAAC,CAAC,CAAA;AACF,EAAA,MAAMC,GAAG,GAAGD,IAAI,CAACE,OAAO,CAACN,YAAY,CAAC,CAAA;EACtC,OAAOO,sBAAsB,CAACF,GAAG,CAAC,CAAA;AACnC,CAAC,CAAA;AAEM,MAAME,sBAAsB,GAClCH,IAAY,KACmB;AAC/BI,EAAAA,KAAK,EAAE,0BAA0B;AACjCJ,EAAAA,IAAAA;AACD,CAAC,CAAC,CAAA;AAEWK,MAAAA,+BAA+B,GAC3CC,QAAkC,IACV;AACxB,EAAA,OAAOC,eAAe,CAAqBD,QAAQ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IAAIH,mBAAmB,EAAE;AAAA,IAAA,IAAA,mBAAA,CAAA;AACpD,IAAA,MAAMjC,QAAQ,GAAGb,kCAAkC,CAClDC,SAAS,EACTgD,iBAAiB,CACjB,CAAA;AAED,IAAA,MAAMC,eAAe,GAAGtC,+BAA+B,CAACC,QAAQ,CAAC,CAAA;;AAEjE;AACA,IAAA,IAAA,CAAA,mBAAA,GAAIqC,eAAe,CAACC,EAAE,MAAlB,IAAA,IAAA,mBAAA,KAAA,KAAA,CAAA,IAAA,mBAAA,CAAoBC,gBAAgB,EAAE;AACzC7B,MAAAA,MAAM,CAAC8B,IAAI,CAACxC,QAAQ,CAAC,CAAA;MACrBU,MAAM,CAAC8B,IAAI,CAAC,GAAGhB,kBAAkB,CAACpC,SAAS,EAAEiD,eAAe,CAAC,CAAC,CAAA;AAC/D,KAAA;AACD,GAAA;AAEA,EAAA,OAAO3B,MAAM,CAAA;AACd,CAAC;;;;"}
|
package/build/generate.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.mjs","sources":["../src/commands/generate.ts"],"sourcesContent":["import ts from \"typescript\";\r\n\r\nimport {\r\n\tPackageLocation,\r\n\twritePackageCreatorIndex,\r\n\treadPackageCreatorIndex,\r\n} from \"../lib/package\";\r\nimport { getPackageTypescriptFiles } from \"../lib/scripts\";\r\nimport {\r\n\tCreatorIndexEntry,\r\n\tCreatorIndexParameter,\r\n\tCreatorIndexParameterType,\r\n} from \"../lib/package\";\r\n\r\nfunction findTsNode<T extends ts.Node>(\r\n\tnode: ts.Node,\r\n\tcallback: (node: ts.Node) => node is T,\r\n): T | undefined;\r\nfunction findTsNode(\r\n\tnode: ts.Node,\r\n\tcallback: (node: ts.Node) => boolean,\r\n): ts.Node | undefined;\r\nfunction findTsNode(\r\n\tnode: ts.Node,\r\n\tcallback: (node: ts.Node) => boolean,\r\n): ts.Node | undefined {\r\n\tlet result: ts.Node | undefined;\r\n\r\n\tts.forEachChild(node, (child) => {\r\n\t\tif (callback(child)) {\r\n\t\t\tresult = child;\r\n\t\t\treturn true;\r\n\t\t}\r\n\t});\r\n\r\n\treturn result;\r\n}\r\n\r\nfunction capitalizeFirstLetter(string) {\r\n\treturn string?.charAt(0).toUpperCase() + string?.slice(1);\r\n}\r\n\r\nfunction parseDefault(value: string, type: string) {\r\n\tconst uType: CreatorIndexParameterType = capitalizeFirstLetter(type);\r\n\tif (value === \"null\") return null;\r\n\tswitch (uType) {\r\n\t\tcase \"LengthM\":\r\n\t\tcase \"ArcDEG\":\r\n\t\tcase \"Float\":\r\n\t\t\treturn parseFloat(value);\r\n\t\tcase \"Integer\":\r\n\t\tcase \"Int\":\r\n\t\t\treturn parseInt(value);\r\n\t\tcase \"Boolean\":\r\n\t\tcase \"Bool\":\r\n\t\t\treturn value === \"true\";\r\n\t\tcase \"Material\":\r\n\t\tcase \"String\":\r\n\t\tdefault:\r\n\t\t\treturn value.replace(/^\"/, \"\").replace(/\"$/, \"\");\r\n\t}\r\n}\r\n\r\nfunction findEvaluatorNode(node: ts.Node): ts.ClassDeclaration | undefined {\r\n\tif (\r\n\t\tts.isModuleDeclaration(node) &&\r\n\t\tnode.body &&\r\n\t\tts.isModuleDeclaration(node.body) &&\r\n\t\tnode.body.body\r\n\t) {\r\n\t\tconst classDeclaration = findTsNode(\r\n\t\t\tnode.body.body,\r\n\t\t\t(child): child is ts.ClassDeclaration => {\r\n\t\t\t\tif (!ts.isClassDeclaration(child)) {\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tconst isEvaluator = child.heritageClauses?.some((clause) => {\r\n\t\t\t\t\tif (clause.token !== ts.SyntaxKind.ExtendsKeyword) {\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn clause.types.some((type) =>\r\n\t\t\t\t\t\ttype.getText().includes(\"Evaluator\"),\r\n\t\t\t\t\t);\r\n\t\t\t\t});\r\n\r\n\t\t\t\treturn isEvaluator ?? false;\r\n\t\t\t},\r\n\t\t);\r\n\r\n\t\treturn classDeclaration;\r\n\t}\r\n}\r\n\r\nfunction getParameter(evaluatorNode: ts.ClassDeclaration) {\r\n\tlet memb = evaluatorNode.members?.find(\r\n\t\t(member) => member?.name?.getText().toLowerCase() == \"create\",\r\n\t);\r\n\tif (ts.isMethodDeclaration(memb!)) {\r\n\t\treturn memb.parameters.find(\r\n\t\t\t(para) => para.name.getText().toLowerCase() == \"parameters\",\r\n\t\t);\r\n\t}\r\n}\r\n\r\nfunction findParametersInterface(\r\n\tnode: ts.Node,\r\n\tinterfaceName: string,\r\n): ts.InterfaceDeclaration | undefined {\r\n\tif (\r\n\t\tts.isModuleDeclaration(node) &&\r\n\t\tnode.body &&\r\n\t\tts.isModuleDeclaration(node.body) &&\r\n\t\tnode.body.body\r\n\t) {\r\n\t\tconst interfaceDeclaration = findTsNode(\r\n\t\t\tnode.body.body,\r\n\t\t\t(child): child is ts.InterfaceDeclaration =>\r\n\t\t\t\tts.isInterfaceDeclaration(child) &&\r\n\t\t\t\tchild.name.getText() == interfaceName,\r\n\t\t);\r\n\r\n\t\treturn interfaceDeclaration;\r\n\t}\r\n\r\n\treturn undefined;\r\n}\r\n\r\nfunction getModuleName(sourceFile: ts.Node): string {\r\n\tlet fullName = \"\";\r\n\tif (ts.isModuleDeclaration(sourceFile)) {\r\n\t\tfullName += sourceFile.name.getText();\r\n\r\n\t\tlet packageB = sourceFile.body!;\r\n\t\tif (ts.isModuleDeclaration(packageB)) {\r\n\t\t\tfullName += \".\" + packageB.name.getText();\r\n\t\t}\r\n\t}\r\n\treturn fullName;\r\n}\r\n\r\nfunction genParameters(\r\n\tinterfac: ts.InterfaceDeclaration,\r\n): CreatorIndexParameter[] {\r\n\treturn interfac.members.map((member, i) => {\r\n\t\tlet para = {} as CreatorIndexParameter;\r\n\r\n\t\tpara.Name = member.name!.getText();\r\n\t\tif (para.Name.length > 45)\r\n\t\t\tthrow new Error(`Parameter name length >45 '${para.Name}'`);\r\n\r\n\t\tlet rawDocTags = ts.getJSDocTags(member);\r\n\t\tif (rawDocTags.length) {\r\n\t\t\tlet dict = getTagDict(rawDocTags);\r\n\t\t\tif (dict.summary) para.Description = dict.summary;\r\n\t\t\tif (dict.creatorType)\r\n\t\t\t\tpara.Type = dict.creatorType as CreatorIndexParameterType;\r\n\t\t\tif (dict.default && dict.creatorType)\r\n\t\t\t\tpara.Default = parseDefault(dict.default, dict.creatorType);\r\n\t\t\tpara.DisplayIndex = i + 1;\r\n\t\t}\r\n\t\treturn para;\r\n\t});\r\n}\r\n\r\ninterface IDocTags {\r\n\tdefault?: string;\r\n\tcreatorType?: string;\r\n\tsummary?: string;\r\n}\r\n\r\nfunction getTagDict(tags: any): IDocTags {\r\n\tlet dict = {};\r\n\ttags.forEach((tag) => {\r\n\t\tdict[tag.tagName.text] = tag.comment;\r\n\t});\r\n\treturn dict;\r\n}\r\n\r\nfunction findParametersInterfaceInFiles(\r\n\tprogram: ts.Program,\r\n\tfileList: string[],\r\n\tname: string,\r\n): ts.InterfaceDeclaration | undefined {\r\n\tfor (const file of fileList) {\r\n\t\tconst sourceFile = program.getSourceFile(file);\r\n\r\n\t\tif (sourceFile === undefined) {\r\n\t\t\tthrow new Error(\r\n\t\t\t\t`Expected a source file to exist for file name \"${file}\"`,\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tlet interfaceDeclaration: ts.InterfaceDeclaration | undefined;\r\n\r\n\t\tts.forEachChild(sourceFile, (node) => {\r\n\t\t\tinterfaceDeclaration = findParametersInterface(node, name);\r\n\r\n\t\t\treturn interfaceDeclaration !== undefined;\r\n\t\t});\r\n\r\n\t\tif (interfaceDeclaration !== undefined) {\r\n\t\t\treturn interfaceDeclaration;\r\n\t\t}\r\n\t}\r\n\r\n\treturn undefined;\r\n}\r\n\r\n/**\r\n * Extracts and returns script array for _Index.json from a src folder\r\n *\r\n * @param folderPath path to a src folder\r\n */\r\nexport function extract(location: PackageLocation, ignore: string[] = []) {\r\n\tconst files = getPackageTypescriptFiles(location);\r\n\tconst filtered = files.filter((path) => {\r\n\t\treturn !ignore.some((suffix) => path.endsWith(suffix));\r\n\t});\r\n\tlet arr = new Array<CreatorIndexEntry>();\r\n\r\n\tlet program = ts.createProgram(filtered, { allowJs: true });\r\n\tprogram.getTypeChecker();\r\n\tfiltered.forEach((file) => {\r\n\t\t// Create a Program to represent the project, then pull out the\r\n\t\t// source file to parse its AST.\r\n\t\tconst sourceFile = program.getSourceFile(file);\r\n\r\n\t\t// Loop through the root AST nodes of the file\r\n\t\tts.forEachChild(sourceFile!, (node) => {\r\n\t\t\tconst evalNode = findEvaluatorNode(node);\r\n\r\n\t\t\tif (evalNode === undefined) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tlet moduleName = getModuleName(node);\r\n\r\n\t\t\tif (evalNode.name === undefined) {\r\n\t\t\t\tthrow new Error(`Expected evaluator class to have a name`);\r\n\t\t\t}\r\n\r\n\t\t\tconst name = moduleName + \".\" + evalNode.name.getText();\r\n\r\n\t\t\tif (name.length > 45)\r\n\t\t\t\tthrow new Error(`Package name length >45 '${name}'`);\r\n\r\n\t\t\tlet para = getParameter(evalNode);\r\n\t\t\tlet paraName = (para?.type as any).typeName.getText();\r\n\t\t\tlet interfac = findParametersInterfaceInFiles(\r\n\t\t\t\tprogram,\r\n\t\t\t\tfiltered,\r\n\t\t\t\tparaName,\r\n\t\t\t);\r\n\r\n\t\t\tif (interfac === undefined) {\r\n\t\t\t\tthrow new Error(\r\n\t\t\t\t\t`Failed to find parameters type declaration for evaluator ${evalNode.name.getText()}`,\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\tconst obj: CreatorIndexEntry = {\r\n\t\t\t\tName: name,\r\n\t\t\t\tParameters: [],\r\n\t\t\t\tType: \"Evaluator\",\r\n\t\t\t};\r\n\r\n\t\t\tlet rawDocTags = ts.getJSDocTags(evalNode);\r\n\t\t\tif (rawDocTags.length) {\r\n\t\t\t\tlet dict = getTagDict(rawDocTags);\r\n\t\t\t\tif (dict.summary) obj.Description = dict.summary;\r\n\t\t\t\tif (dict.creatorType)\r\n\t\t\t\t\tobj.Type = dict.creatorType as \"Interactor\" | \"Evaluator\";\r\n\t\t\t}\r\n\r\n\t\t\tobj.Parameters = genParameters(interfac);\r\n\r\n\t\t\tarr.push(obj);\r\n\t\t});\r\n\t});\r\n\r\n\twritePackageCreatorIndex(location, arr);\r\n}\r\n"],"names":["findTsNode","node","callback","result","ts","forEachChild","child","capitalizeFirstLetter","string","charAt","toUpperCase","slice","parseDefault","value","type","uType","parseFloat","parseInt","replace","findEvaluatorNode","isModuleDeclaration","body","classDeclaration","isClassDeclaration","isEvaluator","heritageClauses","some","clause","token","SyntaxKind","ExtendsKeyword","types","getText","includes","getParameter","evaluatorNode","memb","members","find","member","name","toLowerCase","isMethodDeclaration","parameters","para","findParametersInterface","interfaceName","interfaceDeclaration","isInterfaceDeclaration","undefined","getModuleName","sourceFile","fullName","packageB","genParameters","interfac","map","i","Name","length","Error","rawDocTags","getJSDocTags","dict","getTagDict","summary","Description","creatorType","Type","default","Default","DisplayIndex","tags","forEach","tag","tagName","text","comment","findParametersInterfaceInFiles","program","fileList","file","getSourceFile","extract","location","ignore","files","getPackageTypescriptFiles","filtered","filter","path","suffix","endsWith","arr","Array","createProgram","allowJs","getTypeChecker","evalNode","moduleName","paraName","typeName","obj","Parameters","push","writePackageCreatorIndex"],"mappings":";;;;;;;;;;;;;;AAsBA,SAASA,UAAU,CAClBC,IAAa,EACbC,QAAoC,EACd;AACtB,EAAA,IAAIC,MAA2B,CAAA;AAE/BC,EAAAA,EAAE,CAACC,YAAY,CAACJ,IAAI,EAAGK,KAAK,IAAK;AAChC,IAAA,IAAIJ,QAAQ,CAACI,KAAK,CAAC,EAAE;AACpBH,MAAAA,MAAM,GAAGG,KAAK,CAAA;AACd,MAAA,OAAO,IAAI,CAAA;AACZ,KAAA;AACD,GAAC,CAAC,CAAA;AAEF,EAAA,OAAOH,MAAM,CA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 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import * as fs from 'fs';
|
|
4
|
-
import glob from 'glob';
|
|
5
|
-
import * as terser from 'terser';
|
|
6
|
-
import { d as detectWorkspace, t as translate, r as readPackageCreatorManifest, a as detectPackage, b as readPackageNpmManifest } from './cli.mjs';
|
|
7
|
-
import ts from 'typescript';
|
|
8
|
-
import { g as getPackageTypescriptFiles } from './scripts.mjs';
|
|
9
|
-
import typedoc from 'typedoc';
|
|
10
|
-
|
|
11
|
-
const logPackageMessage = (name, step, index, total) => {
|
|
12
|
-
const numLength = total === undefined ? undefined : total.toString().length;
|
|
13
|
-
const indexString = total === undefined || total < 2 ? "" : `${index.toString().padStart(numLength, "0")}/${total} `;
|
|
14
|
-
const identifierString = `${indexString}${name.padEnd(15)}`;
|
|
15
|
-
console.log(`${identifierString} >> ${step}`);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const tryReadTsConfig = location => {
|
|
19
|
-
const {
|
|
20
|
-
config
|
|
21
|
-
} = ts.readConfigFile(path.join(location.scriptsDir, "tsconfig.json"), path => {
|
|
22
|
-
try {
|
|
23
|
-
return fs.readFileSync(path, "utf8");
|
|
24
|
-
} catch {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
return config;
|
|
29
|
-
};
|
|
30
|
-
const build = async (location, outputDir) => {
|
|
31
|
-
const config = tryReadTsConfig(location);
|
|
32
|
-
config.compilerOptions.lib = ["es5", "dom"];
|
|
33
|
-
const result = ts.convertCompilerOptionsFromJson(config.compilerOptions, location.scriptsDir);
|
|
34
|
-
const compilerOptions = {
|
|
35
|
-
...result.options,
|
|
36
|
-
removeComments: false,
|
|
37
|
-
declaration: true,
|
|
38
|
-
sourceMap: false,
|
|
39
|
-
// We don't use tsc to actually emit the files, but we still need to set the correct
|
|
40
|
-
// output directory so the compiler can rewrite the `reference path` directives.
|
|
41
|
-
outFile: path.join(outputDir, "out.js"),
|
|
42
|
-
target: ts.ScriptTarget.ES5,
|
|
43
|
-
noEmitOnError: true
|
|
44
|
-
};
|
|
45
|
-
const host = ts.createCompilerHost(compilerOptions);
|
|
46
|
-
host.getCurrentDirectory = () => location.scriptsDir;
|
|
47
|
-
let js;
|
|
48
|
-
let definitions;
|
|
49
|
-
host.writeFile = (fileName, data, writeByteOrderMark) => {
|
|
50
|
-
if (fileName.endsWith(".js")) {
|
|
51
|
-
js = data;
|
|
52
|
-
} else if (fileName.endsWith(".d.ts")) {
|
|
53
|
-
definitions = data;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const files = getPackageTypescriptFiles(location);
|
|
57
|
-
if (files.length === 0) {
|
|
58
|
-
throw new Error(`Expected typescript files to exist when building a package. Packages only consisting of animation jsons do not need to be built.`);
|
|
59
|
-
}
|
|
60
|
-
const programOptions = {
|
|
61
|
-
rootNames: files,
|
|
62
|
-
options: compilerOptions,
|
|
63
|
-
host
|
|
64
|
-
};
|
|
65
|
-
const program = ts.createProgram(programOptions);
|
|
66
|
-
const emitResult = program.emit();
|
|
67
|
-
const allDiagnostics = ts.getPreEmitDiagnostics(program);
|
|
68
|
-
if (!emitResult.emitSkipped) {
|
|
69
|
-
if (allDiagnostics.length > 0) {
|
|
70
|
-
console.log(allDiagnostics.map(createErrorMessage).join("\n"));
|
|
71
|
-
}
|
|
72
|
-
if (js === undefined || definitions === undefined) {
|
|
73
|
-
throw new Error(`Unexpected: no js or definitions were created`);
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
js,
|
|
77
|
-
definitions
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const error = allDiagnostics.map(createErrorMessage).join("\n");
|
|
81
|
-
throw new Error(error);
|
|
82
|
-
};
|
|
83
|
-
const createErrorMessage = diagnostic => {
|
|
84
|
-
if (!diagnostic.file) {
|
|
85
|
-
return `${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`;
|
|
86
|
-
}
|
|
87
|
-
const {
|
|
88
|
-
line,
|
|
89
|
-
character
|
|
90
|
-
} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
91
|
-
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
92
|
-
return `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const generateDocs = async (location, declarationFile, outFolder, name) => {
|
|
96
|
-
const app = new typedoc.Application();
|
|
97
|
-
const mediaDir = path.join(location.manifestDir, "Media");
|
|
98
|
-
app.bootstrap({
|
|
99
|
-
entryPoints: [declarationFile],
|
|
100
|
-
media: mediaDir,
|
|
101
|
-
out: outFolder,
|
|
102
|
-
tsconfig: path.join(location.scriptsDir, "tsconfig.json"),
|
|
103
|
-
skipErrorChecking: true
|
|
104
|
-
});
|
|
105
|
-
app.options.setCompilerOptions([declarationFile], {
|
|
106
|
-
target: ts.ScriptTarget.ES5
|
|
107
|
-
}, undefined);
|
|
108
|
-
app.options.setValue("name", name);
|
|
109
|
-
const [readmePath] = glob.sync("**/readme.md", {
|
|
110
|
-
absolute: true,
|
|
111
|
-
cwd: location.manifestDir
|
|
112
|
-
});
|
|
113
|
-
if (readmePath) {
|
|
114
|
-
app.options.setValue("readme", readmePath);
|
|
115
|
-
}
|
|
116
|
-
const project = app.convert();
|
|
117
|
-
if (project) {
|
|
118
|
-
await app.generateDocs(project, outFolder);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
// Stolen from ig.tools.core
|
|
123
|
-
|
|
124
|
-
const toposort = packages => {
|
|
125
|
-
const queue = Object.getOwnPropertyNames(packages);
|
|
126
|
-
const result = [];
|
|
127
|
-
let index = 0;
|
|
128
|
-
while (queue.length > 0) {
|
|
129
|
-
if (index >= queue.length) {
|
|
130
|
-
throw new Error("Packages can not have cyclic dependencies");
|
|
131
|
-
}
|
|
132
|
-
const queueEntry = queue[index];
|
|
133
|
-
const dependencies = packages[queueEntry];
|
|
134
|
-
const dependencyQueued = dependencies.some(dependency => queue.includes(dependency));
|
|
135
|
-
if (dependencyQueued) {
|
|
136
|
-
index++;
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
queue.splice(index, 1);
|
|
140
|
-
index = 0;
|
|
141
|
-
result.push(queueEntry);
|
|
142
|
-
}
|
|
143
|
-
return result;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const buildFolders = async options => {
|
|
147
|
-
if (options.outDir !== undefined && options.clean) {
|
|
148
|
-
fs.rmSync(options.outDir, {
|
|
149
|
-
recursive: true
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
const workspace = detectWorkspace(options.cwd);
|
|
153
|
-
const folders = resolvePackagesFromArgs(options.directories, workspace);
|
|
154
|
-
if (folders.length === 0) {
|
|
155
|
-
return console.log(translate("messages.buildSkipEmpty"));
|
|
156
|
-
}
|
|
157
|
-
const sortedPackages = sortPackagesByBuildOrder(folders);
|
|
158
|
-
let index = 1;
|
|
159
|
-
for (const location of sortedPackages) {
|
|
160
|
-
if (options.skipPackagesWithoutTsFiles && getPackageTypescriptFiles(location).length === 0) {
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
ensureTsConfig(location);
|
|
164
|
-
const data = readPackageCreatorManifest(location);
|
|
165
|
-
const logStep = step => logPackageMessage(data.Package, step, index, folders.length);
|
|
166
|
-
logStep(translate("messages.building"));
|
|
167
|
-
const outputDirectory = options.outDir || location.scriptsDir;
|
|
168
|
-
fs.mkdirSync(outputDirectory, {
|
|
169
|
-
recursive: true
|
|
170
|
-
});
|
|
171
|
-
const buildResult = await build(location, outputDirectory);
|
|
172
|
-
const banner = options.banner ? createBannerComment(options.banner) : undefined;
|
|
173
|
-
if (banner) {
|
|
174
|
-
buildResult.js = banner + "\n" + buildResult.js;
|
|
175
|
-
buildResult.definitions = banner + "\n" + buildResult.definitions;
|
|
176
|
-
}
|
|
177
|
-
fs.writeFileSync(path.join(outputDirectory, `${data.Package}.js`), buildResult.js, {
|
|
178
|
-
encoding: "utf8"
|
|
179
|
-
});
|
|
180
|
-
fs.writeFileSync(path.join(outputDirectory, `${data.Package}.d.ts`), buildResult.definitions, {
|
|
181
|
-
encoding: "utf8"
|
|
182
|
-
});
|
|
183
|
-
if (options.minimize) {
|
|
184
|
-
const minifyResult = await terser.minify(buildResult.js, {
|
|
185
|
-
ecma: 5
|
|
186
|
-
});
|
|
187
|
-
const minifiedPath = path.join(outputDirectory, `${data.Package}.min.js`);
|
|
188
|
-
fs.writeFileSync(minifiedPath, minifyResult.code, {
|
|
189
|
-
encoding: "utf8"
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
if (location.path.includes("Basics")) {
|
|
193
|
-
fs.mkdirSync(path.join(options.cwd, "lib"), {
|
|
194
|
-
recursive: true
|
|
195
|
-
});
|
|
196
|
-
logStep(translate("messages.basicsCopy"));
|
|
197
|
-
fs.writeFileSync(path.join(options.cwd, "lib", `${data.Package}.d.ts`), buildResult.definitions, {
|
|
198
|
-
encoding: "utf8"
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
if (options.docs) {
|
|
202
|
-
logStep(translate("messages.docsGeneration"));
|
|
203
|
-
await generateDocs(location, path.join(outputDirectory, `${data.Package}.d.ts`), path.join(options.cwd, "docs", data.Package), data.Package);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// logStep(translate("messages.built"));
|
|
207
|
-
|
|
208
|
-
index++;
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
const resolvePackagesFromArgs = (args = [], workspace) => {
|
|
212
|
-
const folders = new Map();
|
|
213
|
-
for (const arg of args) {
|
|
214
|
-
glob.sync(arg, {
|
|
215
|
-
cwd: workspace.path,
|
|
216
|
-
absolute: true
|
|
217
|
-
}).forEach(folder => {
|
|
218
|
-
try {
|
|
219
|
-
const location = detectPackage(workspace, folder);
|
|
220
|
-
folders.set(folder, location);
|
|
221
|
-
} catch (err) {}
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
return Array.from(folders.values());
|
|
225
|
-
};
|
|
226
|
-
const ensureTsConfig = location => {
|
|
227
|
-
const tsconfigPath = path.join(location.scriptsDir, "tsconfig.json");
|
|
228
|
-
if (!fs.existsSync(tsconfigPath)) {
|
|
229
|
-
const content = {};
|
|
230
|
-
applyTsConfigOption(content);
|
|
231
|
-
fs.writeFileSync(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
|
|
232
|
-
} else {
|
|
233
|
-
const content = JSON.parse(fs.readFileSync(tsconfigPath, "utf8"));
|
|
234
|
-
applyTsConfigOption(content);
|
|
235
|
-
fs.writeFileSync(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
const applyTsConfigOption = data => {
|
|
239
|
-
data.compilerOptions = data.compilerOptions ?? {};
|
|
240
|
-
data.compilerOptions.target = "es5";
|
|
241
|
-
data.compilerOptions.lib = ["es5", "dom"];
|
|
242
|
-
};
|
|
243
|
-
const sortPackagesByBuildOrder = folders => {
|
|
244
|
-
const packages = Array.from(folders).reduce((acc, location) => {
|
|
245
|
-
const data = readPackageNpmManifest(location);
|
|
246
|
-
if (data !== undefined) {
|
|
247
|
-
acc[data.name] = {
|
|
248
|
-
data,
|
|
249
|
-
location
|
|
250
|
-
};
|
|
251
|
-
} else {
|
|
252
|
-
acc[location.path] = {
|
|
253
|
-
data: undefined,
|
|
254
|
-
location
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
return acc;
|
|
258
|
-
}, {});
|
|
259
|
-
const packageDependencies = Object.getOwnPropertyNames(packages).reduce((acc, packageName) => {
|
|
260
|
-
const packageData = packages[packageName];
|
|
261
|
-
if (packageData.data === undefined) {
|
|
262
|
-
acc[packageName] = [];
|
|
263
|
-
} else {
|
|
264
|
-
acc[packageName] = Object.getOwnPropertyNames({
|
|
265
|
-
...packageData.data.devDependencies,
|
|
266
|
-
...packageData.data.dependencies,
|
|
267
|
-
...packageData.data.peerDependencies
|
|
268
|
-
}).filter(packageName => packages[packageName] !== undefined);
|
|
269
|
-
}
|
|
270
|
-
return acc;
|
|
271
|
-
}, {});
|
|
272
|
-
const sortedPackages = toposort(packageDependencies);
|
|
273
|
-
const result = [];
|
|
274
|
-
for (const packageName of sortedPackages) {
|
|
275
|
-
const location = packages[packageName].location;
|
|
276
|
-
if (readPackageCreatorManifest(location).Package.endsWith(".Basics")) {
|
|
277
|
-
result.unshift(location);
|
|
278
|
-
} else {
|
|
279
|
-
result.push(location);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
return result;
|
|
283
|
-
};
|
|
284
|
-
const createBannerComment = banner => {
|
|
285
|
-
const bannerParts = [];
|
|
286
|
-
if (banner.text) {
|
|
287
|
-
bannerParts.push(" * " + banner.text);
|
|
288
|
-
}
|
|
289
|
-
{
|
|
290
|
-
const details = [];
|
|
291
|
-
if (banner.version) {
|
|
292
|
-
details.push(`Version: ${banner.version}`);
|
|
293
|
-
}
|
|
294
|
-
if (banner.commit) {
|
|
295
|
-
if (banner.commitDirty) {
|
|
296
|
-
details.push(`Commit: ${banner.commit} (dirty)`);
|
|
297
|
-
} else {
|
|
298
|
-
details.push(`Commit: ${banner.commit}`);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
if (banner.date) {
|
|
302
|
-
details.push(`Date: ${banner.date.toISOString()}`);
|
|
303
|
-
}
|
|
304
|
-
const detailsText = details.map(line => ` * ${line}`).join("\n");
|
|
305
|
-
if (detailsText) {
|
|
306
|
-
bannerParts.push(detailsText);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
const bannerText = bannerParts.join("\n\n");
|
|
310
|
-
if (bannerText) {
|
|
311
|
-
return `/*
|
|
312
|
-
${bannerText}
|
|
313
|
-
*
|
|
314
|
-
* @preserve
|
|
315
|
-
*/`;
|
|
316
|
-
}
|
|
317
|
-
return undefined;
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
321
|
-
__proto__: null,
|
|
322
|
-
buildFolders: buildFolders
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
export { buildFolders as b, index as i, logPackageMessage as l };
|
|
326
|
-
//# sourceMappingURL=index2.mjs.map
|