@intelligentgraphics/ig.gfx.packager 3.0.9 → 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/build/cli-cb85e4b5.js +1393 -0
  2. package/build/cli-cb85e4b5.js.map +1 -0
  3. package/build/dependencies-2565d80c.js +133 -0
  4. package/build/dependencies-2565d80c.js.map +1 -0
  5. package/build/generateIndex-f386d332.js +257 -0
  6. package/build/generateIndex-f386d332.js.map +1 -0
  7. package/build/generateParameterType-151ab313.js +75 -0
  8. package/build/generateParameterType-151ab313.js.map +1 -0
  9. package/build/index-67a112b8.js +312 -0
  10. package/build/index-67a112b8.js.map +1 -0
  11. package/build/index-7a955335.js +479 -0
  12. package/build/{index-a48c5d0a.js.map → index-7a955335.js.map} +1 -1
  13. package/build/index.mjs +1 -1
  14. package/build/index.mjs.map +1 -1
  15. package/build/postinstall-962af586.js +67 -0
  16. package/build/{postinstall-9990fb31.js.map → postinstall-962af586.js.map} +1 -1
  17. package/build/publishNpm-1838e45c.js +134 -0
  18. package/build/{publishNpm-74a96626.js.map → publishNpm-1838e45c.js.map} +1 -1
  19. package/build/versionFile-cf6657c8.js +384 -0
  20. package/build/versionFile-cf6657c8.js.map +1 -0
  21. package/package.json +4 -6
  22. package/readme.md +81 -2
  23. package/build/cli-17d957b0.js +0 -2531
  24. package/build/cli-17d957b0.js.map +0 -1
  25. package/build/dependencies-51916db0.js +0 -149
  26. package/build/dependencies-51916db0.js.map +0 -1
  27. package/build/generateIndex-59993f0f.js +0 -266
  28. package/build/generateIndex-59993f0f.js.map +0 -1
  29. package/build/generateParameterType-d3ab08fd.js +0 -74
  30. package/build/generateParameterType-d3ab08fd.js.map +0 -1
  31. package/build/index-a48c5d0a.js +0 -480
  32. package/build/index-ac2cd050.js +0 -308
  33. package/build/index-ac2cd050.js.map +0 -1
  34. package/build/postinstall-9990fb31.js +0 -64
  35. package/build/publishNpm-74a96626.js +0 -133
  36. package/build/versionFile-68e35b54.js +0 -370
  37. package/build/versionFile-68e35b54.js.map +0 -1
@@ -1,480 +0,0 @@
1
- import * as path from 'path';
2
- import * as fs from 'fs';
3
- import { pipeline } from 'stream/promises';
4
- import { execSync } from 'child_process';
5
- import { r as readPublishedPackageCreatorIndex, d as determineWorkspaceIGLibraries, a as readPublishedPackageNpmManifest, b as readPublishedPackageCreatorManifest } from './dependencies-51916db0.js';
6
- import { P as PACKAGE_FILE, I as INDEX_FILE, p as parseCreatorPackageName, g as getWorkspaceOutputPath, r as readPackageCreatorManifest, w as writePackageCreatorManifest, a as readPackageAnimationList, i as isErrorENOENT, b as readPackageCreatorIndex, c as readWorkspaceNpmManifest, u as uploadPackage, d as getPackageReleasesDirectory, e as getExistingPackages, s as startSession, f as closeSession } from './cli-17d957b0.js';
7
- import { l as logPackageMessage, b as buildFolders } from './index-ac2cd050.js';
8
- import 'write-pkg';
9
- import 'glob';
10
- import 'node:path';
11
- import 'node:fs';
12
- import axios from 'axios';
13
- import { g as getVersionFileHandler, p as parseVersionFromString, a as getVersionInformationFromGit, b as getWorkspaceBannerText, c as parseVersionFromNumericVersion, P as PackageVersion } from './versionFile-68e35b54.js';
14
- import Ajv from 'ajv';
15
- import JSZip from 'jszip';
16
- import * as terser from 'terser';
17
- import 'resolve';
18
- import 'update-notifier';
19
- import 'yargs/yargs';
20
- import 'url';
21
- import 'assert';
22
- import 'events';
23
- import 'util';
24
- import 'inquirer';
25
- import 'typescript';
26
- import 'typedoc';
27
- import 'simple-git';
28
-
29
- const buildArchiveFromPublishedPackage = (location, manifest, creatorPackage) => {
30
- const archive = new JSZip();
31
- archive.file(PACKAGE_FILE, JSON.stringify(creatorPackage, null, 2));
32
- const index = readPublishedPackageCreatorIndex(location);
33
- if (index !== undefined) {
34
- archive.file(INDEX_FILE, JSON.stringify(index, null, 2));
35
- }
36
- archive.file(manifest.main, fs.createReadStream(path.join(location.path, manifest.main)));
37
- return archive;
38
- };
39
- let validateSchema;
40
- const runtimeScripts = ["Interactor", "Core", "Mixed"];
41
- const notRuntimeScripts = ["Context", "Evaluator"];
42
- const buildArchiveFromPackage = async (workspaceLocation, packageLocation, data) => {
43
- const {
44
- domain,
45
- subdomain
46
- } = parseCreatorPackageName(data);
47
- const logStep = step => logPackageMessage(data.Package, step);
48
- if (validateSchema === undefined) {
49
- validateSchema = await axios.get("https://archive.intelligentgraphics.biz/schemas/gfx/animation.json").then(({
50
- data
51
- }) => new Ajv({
52
- coerceTypes: true,
53
- allErrors: true,
54
- removeAdditional: true,
55
- useDefaults: "empty",
56
- validateSchema: "log"
57
- }).compile(data));
58
- }
59
- const libFilePath = path.join(getWorkspaceOutputPath(workspaceLocation), `${data.Package}.min.js`);
60
- const scriptDirectories = [packageLocation.path, packageLocation.scriptsDir];
61
- if (subdomain === "GFX.Standard") {
62
- logStep(`Including Images folder`);
63
- scriptDirectories.push(path.join(packageLocation.path, "Images"));
64
- }
65
- const manifest = readPackageCreatorManifest(packageLocation);
66
- if (manifest !== undefined) {
67
- if (manifest.RunTime && notRuntimeScripts.includes(manifest.Type)) {
68
- logStep("Setting script RunTime to false because of script type");
69
- writePackageCreatorManifest(packageLocation, {
70
- ...manifest,
71
- RunTime: false
72
- });
73
- } else if (!manifest.RunTime && runtimeScripts.includes(manifest.Type)) {
74
- logStep("Setting script RunTime to true because of script type");
75
- writePackageCreatorManifest(packageLocation, {
76
- ...manifest,
77
- RunTime: true
78
- });
79
- }
80
- }
81
-
82
- // if (index === undefined) {
83
- // throw new Error(
84
- // `Could not find an "${INDEX_FILE}" file in "${primaryScriptDir}"`,
85
- // );
86
- // }
87
-
88
- const animations = new Map();
89
- for (const scriptFilePath of readPackageAnimationList(packageLocation)) {
90
- const content = fs.readFileSync(scriptFilePath, {
91
- encoding: "utf8"
92
- });
93
- let data;
94
- try {
95
- data = JSON.parse(content);
96
- } catch (err) {
97
- const relativePath = path.relative(workspaceLocation.path, scriptFilePath);
98
- if (err instanceof SyntaxError) {
99
- throw new Error(`Encountered invalid syntax in file "${relativePath}": ${String(err)}`);
100
- }
101
- throw new Error(`Encountered an unexpected error while parsing animation json file at path "${relativePath}"`, {
102
- cause: err
103
- });
104
- }
105
- validateSchema(data);
106
- animations.set(data.Id, JSON.stringify(data));
107
- }
108
- let libFile;
109
- try {
110
- libFile = fs.readFileSync(libFilePath, {
111
- encoding: "utf8"
112
- });
113
- } catch (err) {
114
- if (!isErrorENOENT(err)) {
115
- throw err;
116
- }
117
- }
118
- if (libFile === undefined) {
119
- if (animations.size === 0) {
120
- throw new Error(`Could not find a javascript file at "${libFilePath}".
121
- Packaging without a javascript file is only allowed when animation json files are available`);
122
- }
123
- }
124
- const archive = new JSZip();
125
- let library = "";
126
- if (libFile) {
127
- library = libFile;
128
- }
129
- if (!library) {
130
- const date = new Date(Date.now());
131
- library = `/* This file is part of the ${domain} Data Packages.
132
- * Copyright (C) ${date.getFullYear()} intelligentgraphics. All Rights Reserved. */`;
133
- }
134
- if (animations.size > 0) {
135
- const scopeParts = data.Scope.split(".");
136
- const scope = data.Scope;
137
- library += createNamespace(scopeParts);
138
- for (const [name, data] of animations) {
139
- library += `${scope}.${name} = ` + data + ";";
140
- logPackageMessage(manifest.Package, `Added animation ${scope}.${name}`);
141
- }
142
- }
143
- const minifyResult = await terser.minify(library, {
144
- ecma: 5
145
- });
146
- archive.file(`${data.Package}.js`, minifyResult.code);
147
- archive.file(PACKAGE_FILE, JSON.stringify(data, null, 2));
148
- const creatorIndex = readPackageCreatorIndex(packageLocation);
149
- if (creatorIndex !== undefined) {
150
- archive.file(INDEX_FILE, JSON.stringify(creatorIndex, null, 2));
151
- }
152
- for (const directory of scriptDirectories) {
153
- try {
154
- for (const file of fs.readdirSync(directory)) {
155
- const {
156
- ext
157
- } = path.parse(file);
158
- switch (ext) {
159
- case ".png":
160
- case ".jpeg":
161
- case ".jpg":
162
- break;
163
- default:
164
- continue;
165
- }
166
- archive.file(file, fs.createReadStream(path.join(directory, file)));
167
- }
168
- } catch (err) {
169
- console.error(`Script directory "${directory}" does not exist`);
170
- }
171
- }
172
- return archive;
173
- };
174
- const createNamespace = parts => {
175
- let code = `var ${parts[0]};`;
176
- for (let index = 0; index < parts.length; index++) {
177
- const path = parts.slice(0, index + 1).join(".");
178
- code += `\n(${path} = ${path} || {});`;
179
- }
180
- return code;
181
- };
182
-
183
- const releaseFolder = async options => {
184
- const workspace = options.workspace;
185
- const location = options.directory;
186
- const {
187
- write: writeVersionFile,
188
- reset: resetVersionFile
189
- } = getVersionFileHandler(location);
190
- const packageDescription = readPackageCreatorManifest(location);
191
- const fullPackageName = packageDescription.Package;
192
- const {
193
- domain,
194
- subdomain
195
- } = parseCreatorPackageName(packageDescription);
196
- const publishDomain = options.domain ?? domain;
197
- const publishSubdomain = options.subdomain ?? subdomain;
198
- const sharedPackageJson = readWorkspaceNpmManifest(workspace);
199
- let newVersion;
200
- try {
201
- newVersion = parseVersionFromString(options.newVersion);
202
- } catch (err) {
203
- throw new Error(`Please enter a version in this format 1.0.0.100`);
204
- }
205
- if (newVersion.buildNumber < 100) {
206
- newVersion.preRelease = {
207
- type: "beta",
208
- version: newVersion.buildNumber
209
- };
210
- } else if (newVersion.buildNumber > 100) {
211
- newVersion.preRelease = {
212
- type: "patch",
213
- version: newVersion.buildNumber - 100
214
- };
215
- }
216
- if (sharedPackageJson !== undefined) {
217
- logPackageMessage(packageDescription.Package, `Running npm install to make sure all dependencies are up to date`);
218
- execSync(`npm install`, {
219
- encoding: "utf-8",
220
- cwd: workspace.path
221
- });
222
- }
223
- const binDir = getWorkspaceOutputPath(workspace);
224
- fs.mkdirSync(binDir, {
225
- recursive: true
226
- });
227
- let assetServerPackageDetails;
228
- let packageNameWithVersion;
229
- {
230
- const versionWithoutPrelease = newVersion.clone();
231
- versionWithoutPrelease.preRelease = undefined;
232
- const newVersionString = versionWithoutPrelease.toVersionString({
233
- buildNumber: true
234
- });
235
- packageNameWithVersion = `${packageDescription.Package}_${newVersionString}`;
236
- assetServerPackageDetails = {
237
- name: packageDescription.Package,
238
- version: newVersionString
239
- };
240
- }
241
- const zipFilePath = path.join(binDir, packageNameWithVersion + ".zip");
242
- try {
243
- if (options.pushOnly) {
244
- if (!fs.existsSync(zipFilePath)) {
245
- throw new Error(`Expected a zip file to exist at path ${zipFilePath} since pushOnly is specified`);
246
- }
247
- } else {
248
- const gitVersionInformation = await getVersionInformationFromGit(workspace, location);
249
- writeVersionFile(fullPackageName, newVersion);
250
- const bannerText = sharedPackageJson !== undefined ? getWorkspaceBannerText(sharedPackageJson) : undefined;
251
- await buildFolders({
252
- ...options,
253
- packages: [location],
254
- skipPackagesWithoutTsFiles: true,
255
- banner: options.banner ? {
256
- text: bannerText,
257
- commit: gitVersionInformation.commit,
258
- commitDirty: gitVersionInformation.dirty,
259
- version: newVersion.toVersionString({
260
- buildNumber: true
261
- }),
262
- date: new Date(Date.now())
263
- // gitVersionInformation.commitDate
264
- // ? new Date(gitVersionInformation.commitDate)
265
- // : new Date(Date.now()),
266
- } : undefined
267
- });
268
- newVersion.preRelease = undefined;
269
- try {
270
- fs.rmSync(zipFilePath);
271
- } catch (err) {
272
- if (!isErrorENOENT(err)) {
273
- throw err;
274
- }
275
- }
276
- if (readPackageAnimationList(location).length > 0) {
277
- var _workspaceManifest$de;
278
- const workspaceManifest = readWorkspaceNpmManifest(workspace);
279
- if (!((_workspaceManifest$de = workspaceManifest.dependencies) !== null && _workspaceManifest$de !== void 0 && _workspaceManifest$de["@intelligentgraphics/3d.ig.gfx.standard"])) {
280
- const install = await options.prompter.confirm(`Animation.json files require the library 'IG.GFX.Standard' to be available, but it is not registered as a dependency. Do you want to install it now?`);
281
- if (install) {
282
- execSync(`npm install @intelligentgraphics/3d.ig.gfx.standard`, {
283
- encoding: "utf-8",
284
- cwd: workspace.path,
285
- stdio: "inherit"
286
- });
287
- execSync(`npm run postinstall`, {
288
- cwd: workspace.path
289
- });
290
- }
291
- }
292
- }
293
- const archive = await buildArchiveFromPackage(workspace, location, packageDescription);
294
- const zipOutputStream = fs.createWriteStream(zipFilePath);
295
- await pipeline(archive.generateNodeStream(), zipOutputStream);
296
- }
297
- if (!options.noUpload) {
298
- if (!options.authentication) {
299
- throw new Error(`Expected authentication to be available`);
300
- }
301
- logPackageMessage(packageDescription.Package, `Opening connection to IG.Asset.Server`);
302
- const sessionManager = await createSessionManager({
303
- url: options.service,
304
- address: options.address,
305
- domain: publishDomain,
306
- subDomain: publishSubdomain,
307
- authentication: options.authentication
308
- });
309
- try {
310
- if (!options.skipDependencies) {
311
- await ensureRequiredVersions(workspace, packageDescription, sessionManager, options.prompter);
312
- }
313
- logPackageMessage(packageDescription.Package, `Uploading package to ${publishDomain}.${publishSubdomain}`);
314
- await uploadPackage(sessionManager.getTargetSession(), assetServerPackageDetails, zipFilePath);
315
- } finally {
316
- await sessionManager.destroy().catch(err => {
317
- logPackageMessage(packageDescription.Package, `Failed to close IG.Asset.Server session(s): ${err}`);
318
- });
319
- }
320
- }
321
- } catch (err) {
322
- resetVersionFile();
323
- throw err;
324
- }
325
- if (newVersion.buildNumber >= 100 && !options.pushOnly) {
326
- logPackageMessage(fullPackageName, "Copying zip to releases folder");
327
- const zipFileName = `${packageNameWithVersion}.zip`;
328
- const releasesPath = getPackageReleasesDirectory(location);
329
- fs.mkdirSync(releasesPath, {
330
- recursive: true
331
- });
332
- fs.copyFileSync(zipFilePath, path.join(releasesPath, zipFileName));
333
- }
334
- };
335
- const ensureRequiredVersions = async (workspaceLocation, creatorPackage, sessionManager, prompter) => {
336
- const libraries = determineWorkspaceIGLibraries(workspaceLocation);
337
-
338
- // If there are no libraries, we don't need to check for required versions
339
- if (libraries.length === 0) {
340
- return true;
341
- }
342
- const targetSession = sessionManager.getTargetSession();
343
- const rawUploadedPackages = await getExistingPackages(targetSession);
344
- const uploadedPackages = rawUploadedPackages.map(entry => {
345
- let version;
346
- try {
347
- version = parseVersionFromNumericVersion(entry.numericVersion);
348
- } catch (err) {
349
- throw new Error(`Encountered invalid format for version ${entry.numericVersion}`);
350
- }
351
- if (version.buildNumber < 100) {
352
- version.preRelease = {
353
- type: "beta",
354
- version: version.buildNumber
355
- };
356
- } else if (version.buildNumber > 100) {
357
- version.preRelease = {
358
- type: "patch",
359
- version: version.buildNumber - 100
360
- };
361
- }
362
- return {
363
- ...entry,
364
- version
365
- };
366
- });
367
- for (const libraryLocation of libraries) {
368
- const libraryManifest = readPublishedPackageNpmManifest(libraryLocation);
369
- const libraryCreatorPackage = readPublishedPackageCreatorManifest(libraryLocation);
370
- if (libraryCreatorPackage === undefined || libraryManifest.main === undefined || libraryCreatorPackage.Package === creatorPackage.Package) {
371
- continue;
372
- }
373
- const libraryVersion = PackageVersion.extractFromLine(libraryManifest.version);
374
- if (libraryVersion.preRelease) {
375
- libraryVersion.buildNumber = libraryVersion.preRelease.version;
376
- libraryVersion.preRelease = undefined;
377
- } else {
378
- libraryVersion.buildNumber = 100;
379
- }
380
- let uploadedPackageInBasics;
381
- let uploadedPackageInTarget;
382
- for (const uploadedPackage of uploadedPackages) {
383
- if (uploadedPackage.scope === libraryCreatorPackage.Package) {
384
- if (uploadedPackage.support) {
385
- uploadedPackageInBasics = uploadedPackage;
386
- } else {
387
- uploadedPackageInTarget = uploadedPackage;
388
- }
389
- }
390
- }
391
- const validInBasics = uploadedPackageInBasics !== undefined && !uploadedPackageInBasics.version.isLesserThan(libraryVersion);
392
- const validInTarget = uploadedPackageInTarget !== undefined && !uploadedPackageInTarget.version.isLesserThan(libraryVersion);
393
- if (validInBasics || validInTarget) {
394
- if (targetSession.subDomain !== "Basics" && uploadedPackageInBasics !== undefined && uploadedPackageInTarget !== undefined) {
395
- logPackageMessage(creatorPackage.Package, `Package ${libraryCreatorPackage.Package} is uploaded both for Basics and ${targetSession.subDomain}. The package within ${targetSession.subDomain} will be used.`);
396
- }
397
- continue;
398
- }
399
- logPackageMessage(creatorPackage.Package, `Requested at least version ${libraryVersion.toVersionString({
400
- buildNumber: true
401
- })} for package ${libraryCreatorPackage.Package}`);
402
- if (targetSession.subDomain !== "Basics" && uploadedPackageInTarget) {
403
- const version = uploadedPackageInTarget.version.toVersionString({
404
- buildNumber: true
405
- });
406
- logPackageMessage(creatorPackage.Package, `Found invalid version ${version} for package ${libraryCreatorPackage.Package} in ${targetSession.subDomain}`);
407
- }
408
- if (uploadedPackageInBasics) {
409
- const version = uploadedPackageInBasics.version.toVersionString({
410
- buildNumber: true
411
- });
412
- let message = `Found invalid version ${version} for package ${libraryCreatorPackage.Package} in Basics`;
413
- if (targetSession.subDomain !== "Basics" && uploadedPackageInTarget) {
414
- message += `. This version will not be used since the package also exists in ${targetSession.subDomain}`;
415
- }
416
- logPackageMessage(creatorPackage.Package, message);
417
- }
418
- const possibleTargets = ["Basics"];
419
- if (targetSession.subDomain !== "Basics") {
420
- possibleTargets.push(targetSession.subDomain);
421
- }
422
- const uploadTargetScope = await prompter.ask({
423
- message: `Select the scope to upload the required version of ${libraryCreatorPackage.Package} to or select "skip" to skip the upload.`,
424
- options: [...possibleTargets, "Skip"],
425
- default: possibleTargets[0]
426
- });
427
- if (uploadTargetScope === "Skip") {
428
- continue;
429
- }
430
- const archive = buildArchiveFromPublishedPackage(libraryLocation, libraryManifest, libraryCreatorPackage);
431
- const newVersionString = libraryVersion.toVersionString({
432
- buildNumber: true
433
- });
434
- const packageNameWithVersion = `${libraryCreatorPackage.Package}_${newVersionString}`;
435
- const zipFilePath = path.join(getWorkspaceOutputPath(workspaceLocation), `${packageNameWithVersion}.zip`);
436
- try {
437
- fs.rmSync(zipFilePath);
438
- } catch (err) {
439
- if (!isErrorENOENT(err)) {
440
- throw err;
441
- }
442
- }
443
- const zipOutputStream = fs.createWriteStream(zipFilePath);
444
- await pipeline(archive.generateNodeStream(), zipOutputStream);
445
- const session = uploadTargetScope === "Basics" ? await sessionManager.getBasicsSession() : targetSession;
446
- logPackageMessage(creatorPackage.Package, `Uploading package ${libraryCreatorPackage.Package} with version ${newVersionString} to ${session.domain}.${session.subDomain}`);
447
- await uploadPackage(session, {
448
- name: libraryCreatorPackage.Package,
449
- version: newVersionString
450
- }, zipFilePath);
451
- }
452
- };
453
- const createSessionManager = async params => {
454
- const targetSession = await startSession(params);
455
- let basicsSession;
456
- return {
457
- getBasicsSession: async () => {
458
- if (targetSession.subDomain === "Basics") {
459
- return targetSession;
460
- }
461
- if (basicsSession === undefined) {
462
- basicsSession = await startSession({
463
- ...params,
464
- subDomain: "Basics"
465
- });
466
- }
467
- return basicsSession;
468
- },
469
- getTargetSession: () => targetSession,
470
- destroy: async () => {
471
- await closeSession(targetSession);
472
- if (basicsSession !== undefined) {
473
- await closeSession(basicsSession);
474
- }
475
- }
476
- };
477
- };
478
-
479
- export { releaseFolder };
480
- //# sourceMappingURL=index-a48c5d0a.js.map