@intelligentgraphics/ig.gfx.packager 3.1.4 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/build/bin.js +7 -0
  2. package/build/bin.js.map +1 -0
  3. package/build/build-CMbCj7x-.js +945 -0
  4. package/build/build-CMbCj7x-.js.map +1 -0
  5. package/build/build-kkMVBBJL.js +408 -0
  6. package/build/build-kkMVBBJL.js.map +1 -0
  7. package/build/cli-Co1DhAmx.js +405 -0
  8. package/build/cli-Co1DhAmx.js.map +1 -0
  9. package/build/docs-BkGeoYY2.js +30 -0
  10. package/build/docs-BkGeoYY2.js.map +1 -0
  11. package/build/generateIndex-C_DxQ2R4.js +209 -0
  12. package/build/generateIndex-C_DxQ2R4.js.map +1 -0
  13. package/build/generateParameterType-CdCi5BWM.js +46 -0
  14. package/build/generateParameterType-CdCi5BWM.js.map +1 -0
  15. package/build/package-DHx2bvVO.js +1 -0
  16. package/build/postinstall-DHTlEmNr.js +35 -0
  17. package/build/postinstall-DHTlEmNr.js.map +1 -0
  18. package/build/prompter-DONgUlzS.js +20 -0
  19. package/build/prompter-DONgUlzS.js.map +1 -0
  20. package/build/publish-E5zcQAo0.js +348 -0
  21. package/build/publish-E5zcQAo0.js.map +1 -0
  22. package/build/publishNpm-CBT1819u.js +115 -0
  23. package/build/publishNpm-CBT1819u.js.map +1 -0
  24. package/build/publishedPackage-D-KiU0FG.js +1 -0
  25. package/build/rollup-Csyght27.js +179 -0
  26. package/build/rollup-Csyght27.js.map +1 -0
  27. package/build/scripts-CBblHIL1.js +29 -0
  28. package/build/scripts-CBblHIL1.js.map +1 -0
  29. package/build/versionFile-DViDwgCa.js +123 -0
  30. package/build/versionFile-DViDwgCa.js.map +1 -0
  31. package/build/workspace-D0XY2EMu.js +1 -0
  32. package/lib/lib.js +1595 -0
  33. package/package.json +30 -30
  34. package/readme.md +5 -0
  35. package/build/bin.mjs +0 -5
  36. package/build/bin.mjs.map +0 -1
  37. package/build/cli-CTqQeYIu.mjs +0 -768
  38. package/build/cli-CTqQeYIu.mjs.map +0 -1
  39. package/build/dependencies-CCIr5dgH.mjs +0 -129
  40. package/build/dependencies-CCIr5dgH.mjs.map +0 -1
  41. package/build/docs-DvFV9WXA.mjs +0 -37
  42. package/build/docs-DvFV9WXA.mjs.map +0 -1
  43. package/build/generateIndex-COnAgsMM.mjs +0 -306
  44. package/build/generateIndex-COnAgsMM.mjs.map +0 -1
  45. package/build/generateParameterType-BFVUv72F.mjs +0 -71
  46. package/build/generateParameterType-BFVUv72F.mjs.map +0 -1
  47. package/build/index-Ck4_b8Wk.mjs +0 -1400
  48. package/build/index-Ck4_b8Wk.mjs.map +0 -1
  49. package/build/index-DHSUlJia.mjs +0 -477
  50. package/build/index-DHSUlJia.mjs.map +0 -1
  51. package/build/postinstall-BTuIhY_F.mjs +0 -61
  52. package/build/postinstall-BTuIhY_F.mjs.map +0 -1
  53. package/build/publishNpm-A02qW1UY.mjs +0 -167
  54. package/build/publishNpm-A02qW1UY.mjs.map +0 -1
  55. package/build/rollup-BeQ0dM8U.mjs +0 -221
  56. package/build/rollup-BeQ0dM8U.mjs.map +0 -1
  57. package/build/scripts-B3noxiX3.mjs +0 -45
  58. package/build/scripts-B3noxiX3.mjs.map +0 -1
  59. package/build/versionFile-B9z_qwQL.mjs +0 -206
  60. package/build/versionFile-B9z_qwQL.mjs.map +0 -1
  61. package/lib/lib.mjs +0 -2706
@@ -1,768 +0,0 @@
1
- import updateNotifier from 'update-notifier';
2
- import * as fs from 'fs';
3
- import * as path from 'path';
4
- import yargs from 'yargs/yargs';
5
- import { fileURLToPath } from 'url';
6
- import * as glob from 'glob';
7
- import 'resolve';
8
- import { writePackageSync } from 'write-package';
9
- import axios, { AxiosError } from 'axios';
10
- import { select, confirm } from '@inquirer/prompts';
11
-
12
- const stripUtf8Bom = (text)=>{
13
- // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
14
- // conversion translates it to FEFF (UTF-16 BOM).
15
- if (text.charCodeAt(0) === 0xfeff) {
16
- return text.slice(1);
17
- }
18
- return text;
19
- };
20
-
21
- const readNpmManifest = (directory)=>{
22
- const packageJsonPath = path.join(directory, "package.json");
23
- const packageJson = stripUtf8Bom(fs.readFileSync(packageJsonPath, {
24
- encoding: "utf8"
25
- }));
26
- return JSON.parse(packageJson);
27
- };
28
- const writeNpmManifest = (directory, packageJson)=>{
29
- const packageJsonPath = path.join(directory, "package.json");
30
- writePackageSync(packageJsonPath, packageJson);
31
- };
32
-
33
- const getNodeErrorCode = (error)=>{
34
- if (error !== null && typeof error === "object" && error.code !== undefined) {
35
- return error.code;
36
- }
37
- };
38
- /**
39
- * Permission denied: An attempt was made to access a file in a way forbidden by its file access permissions.
40
- *
41
- * @param {unknown} error
42
- */ const isErrorEACCES = (error)=>getNodeErrorCode(error) === "EACCES";
43
- /**
44
- * No such file or directory: Commonly raised by fs operations to indicate that a component of the specified pathname does not exist. No entity (file or directory) could be found by the given path.
45
- *
46
- * @param {unknown} error
47
- */ const isErrorENOENT = (error)=>getNodeErrorCode(error) === "ENOENT";
48
- const isErrorEPERM = (error)=>getNodeErrorCode(error) === "EPERM";
49
-
50
- // Functionality related to working with a single package.
51
- const PACKAGE_FILE = "_Package.json";
52
- const INDEX_FILE = "_Index.json";
53
- const ANIMATION_FILE_SUFFIX = ".animation.json";
54
- const getCreatorIndexParameterPrimaryJSType = (type)=>{
55
- switch(type){
56
- case "LengthM":
57
- case "ArcDEG":
58
- case "Integer":
59
- case "Int":
60
- case "Float":
61
- return "number";
62
- case "Boolean":
63
- case "Bool":
64
- return "boolean";
65
- case "String":
66
- case "Material":
67
- case "Geometry":
68
- case "Animation":
69
- case "Interactor":
70
- case "Evaluator":
71
- default:
72
- return "string";
73
- }
74
- };
75
- function parseCreatorPackageName(manifest) {
76
- const [domain, subdomain] = manifest.Package.split(".");
77
- if (subdomain === undefined) {
78
- throw new Error(`Expected "Package" field of the _Package.json file to contain a value in the form of Domain.SubDomain`);
79
- }
80
- return {
81
- domain,
82
- subdomain
83
- };
84
- }
85
- /**
86
- * Detects the package at the given directory.
87
- *
88
- * @param {string} directory
89
- * @returns {PackageLocation}
90
- */ const detectPackage = (workspace, directory)=>{
91
- directory = path.resolve(workspace.path, directory);
92
- const scriptsPath = path.join(directory, "Scripts");
93
- const tsPath = path.join(directory, "ts");
94
- let location;
95
- if (fs.existsSync(scriptsPath)) {
96
- location = {
97
- _kind: "PackageLocation",
98
- path: directory,
99
- scriptsDir: scriptsPath,
100
- manifestDir: scriptsPath
101
- };
102
- } else if (fs.existsSync(tsPath)) {
103
- location = {
104
- _kind: "PackageLocation",
105
- path: directory,
106
- scriptsDir: tsPath,
107
- manifestDir: directory
108
- };
109
- } else {
110
- location = {
111
- _kind: "PackageLocation",
112
- path: directory,
113
- scriptsDir: directory,
114
- manifestDir: directory
115
- };
116
- }
117
- try {
118
- readPackageCreatorManifest(location);
119
- } catch (err) {
120
- if (isErrorENOENT(err)) {
121
- throw new Error(`No _Package.json found in ${location.manifestDir}`);
122
- }
123
- throw err;
124
- }
125
- return location;
126
- };
127
- const readPackageCreatorManifest = (location)=>{
128
- const packageJsonPath = path.join(location.manifestDir, PACKAGE_FILE);
129
- const packageJson = stripUtf8Bom(fs.readFileSync(packageJsonPath, {
130
- encoding: "utf8"
131
- }));
132
- return JSON.parse(packageJson);
133
- };
134
- const writePackageCreatorManifest = (location, creatorPackage)=>{
135
- const packageJsonPath = path.join(location.manifestDir, PACKAGE_FILE);
136
- fs.writeFileSync(packageJsonPath, JSON.stringify(creatorPackage, null, "\t") + "\n");
137
- };
138
- const getPackageCreatorIndexPath = (location)=>path.join(location.manifestDir, INDEX_FILE);
139
- const readPackageCreatorIndex = (location)=>{
140
- try {
141
- const indexPath = getPackageCreatorIndexPath(location);
142
- const index = stripUtf8Bom(fs.readFileSync(indexPath, {
143
- encoding: "utf8"
144
- }));
145
- return JSON.parse(index);
146
- } catch (err) {
147
- if (isErrorENOENT(err)) {
148
- return undefined;
149
- }
150
- throw err;
151
- }
152
- };
153
- const writePackageCreatorIndex = (location, index)=>{
154
- const indexPath = getPackageCreatorIndexPath(location);
155
- fs.writeFileSync(indexPath, JSON.stringify(index, null, "\t") + "\n");
156
- };
157
- const readPackageNpmManifest = (location)=>{
158
- try {
159
- return readNpmManifest(location.manifestDir);
160
- } catch (err) {
161
- if (isErrorENOENT(err)) {
162
- return undefined;
163
- }
164
- throw err;
165
- }
166
- };
167
- const writePackageNpmManifest = (location, packageJson)=>{
168
- writeNpmManifest(location.manifestDir, packageJson);
169
- };
170
- const readPackageAnimationList = (location)=>{
171
- const directoryContent = fs.readdirSync(location.manifestDir);
172
- const animationPathList = [];
173
- for (const entry of directoryContent){
174
- if (entry.endsWith(ANIMATION_FILE_SUFFIX)) {
175
- const animationPath = path.join(location.manifestDir, entry);
176
- animationPathList.push(animationPath);
177
- }
178
- }
179
- return animationPathList;
180
- };
181
- const getPackageReleasesDirectory = (location)=>path.join(location.path, "Releases");
182
-
183
- // Functionality related to working with a workspace consisting of multiple packages.
184
- const detectWorkspace = (directory)=>{
185
- directory = path.resolve(process.cwd(), directory);
186
- return {
187
- _kind: "WorkspaceLocation",
188
- path: directory
189
- };
190
- };
191
- const readWorkspaceNpmManifest = (workspace)=>{
192
- try {
193
- return readNpmManifest(workspace.path);
194
- } catch (err) {
195
- if (isErrorENOENT(err)) {
196
- throw new Error(`Expected a package.json file to exist in ${workspace.path}. See packager readme for instructions on how to create the package.json.`);
197
- }
198
- throw err;
199
- }
200
- };
201
- const writeWorkspaceNpmManifest = (workspace, packageJson)=>writeNpmManifest(workspace.path, packageJson);
202
- const getWorkspaceOutputPath = (workspace)=>path.join(workspace.path, "bin");
203
- const getWorkspaceLibPath = (workspace)=>path.join(workspace.path, "lib");
204
- function* iterateWorkspacePackages(workspace) {
205
- const entries = fs.readdirSync(workspace.path, {
206
- withFileTypes: true
207
- });
208
- for (const entry of entries){
209
- if (!entry.isDirectory()) {
210
- continue;
211
- }
212
- try {
213
- yield detectPackage(workspace, entry.name);
214
- } catch {}
215
- }
216
- }
217
-
218
- const PLUGIN_ID = "0feba3a0-b6d1-11e6-9598-0800200c9a66";
219
- /**
220
- * Starts an IG.Asset.Server session and returns the sessionId
221
- *
222
- * @param {SessionStartParams} params
223
- * @returns
224
- */ const startSession = async ({ url, authentication, ...params })=>{
225
- const payload = {
226
- ...params,
227
- user: undefined,
228
- password: undefined,
229
- license: undefined,
230
- plugin: PLUGIN_ID
231
- };
232
- if (authentication.type === "credentials") {
233
- payload.user = authentication.username;
234
- payload.password = authentication.password;
235
- } else if (authentication.type === "license") {
236
- payload.license = authentication.license;
237
- }
238
- const { data: { session: sessionId, state, response } } = await axios.post(`Session/Start2`, JSON.stringify(payload), {
239
- baseURL: url
240
- });
241
- if (state !== "SUCCESS") {
242
- let message = `Could not start session. IG.Asset.Server responded with ${state}`;
243
- if (response) {
244
- message += `: ${response}`;
245
- }
246
- throw new Error(message);
247
- }
248
- return {
249
- _kind: "AssetService",
250
- url,
251
- sessionId,
252
- domain: params.domain,
253
- subDomain: params.subDomain
254
- };
255
- };
256
- const closeSession = async (session)=>{
257
- await axios.get(`Session/Close/${session.sessionId}`, {
258
- baseURL: session.url
259
- });
260
- };
261
- const uploadPackageFromBuffer = async (session, { name, version }, buffer)=>{
262
- try {
263
- await uploadPackageToUrl(session.url, `UploadPackage/${session.sessionId}/${name}_${version}`, buffer);
264
- } catch (err) {
265
- if (err instanceof AxiosError) {
266
- var _err_response;
267
- if (((_err_response = err.response) == null ? void 0 : _err_response.status) === 404) {
268
- await uploadPackageToUrl(session.url, `UploadPackage/${session.sessionId}/${name}_${version}/`, buffer);
269
- return;
270
- }
271
- throw new Error(`Failed to upload package: ${err.message}`);
272
- }
273
- throw err;
274
- }
275
- };
276
- const uploadPackageToUrl = async (url, path, buffer)=>{
277
- const { data, status } = await axios.post(path, buffer, {
278
- baseURL: url
279
- });
280
- let objectBody;
281
- if (typeof data === "string") {
282
- try {
283
- objectBody = JSON.parse(data);
284
- } catch (err) {}
285
- } else if (typeof data === "object") {
286
- objectBody = data;
287
- }
288
- if (objectBody !== undefined) {
289
- if ("state" in objectBody && objectBody.state !== "SUCCESS") {
290
- throw new Error(objectBody.response ?? objectBody.state);
291
- }
292
- }
293
- if (status >= 400) {
294
- if (objectBody !== undefined) {
295
- let text_1 = "";
296
- for(const key in objectBody){
297
- text_1 += key + ": \n";
298
- if (typeof objectBody[key] === "object") {
299
- text_1 += JSON.stringify(objectBody[key], undefined, 2);
300
- } else {
301
- text_1 += objectBody[key];
302
- }
303
- text_1 += "\n\n";
304
- }
305
- throw new Error(text_1);
306
- }
307
- throw new Error(data);
308
- }
309
- return data;
310
- };
311
- const getExistingPackages = async (session)=>{
312
- const { data } = await axios.get(`Script/GetInformation/${session.sessionId}`, {
313
- baseURL: session.url,
314
- validateStatus: (status)=>status === 404 || status === 200
315
- }).catch((err)=>{
316
- throw new Error(`Failed to get existing packages: ${err.message}`);
317
- });
318
- return data;
319
- };
320
-
321
- const createDefaultPrompter = ()=>{
322
- return {
323
- confirm: async (message)=>{
324
- const result = await confirm({
325
- message
326
- });
327
- return result;
328
- },
329
- ask: async (question)=>{
330
- const answer = await select({
331
- message: question.message,
332
- choices: question.options,
333
- default: question.default
334
- });
335
- return answer;
336
- }
337
- };
338
- };
339
-
340
- const docsHandler = async (location, declarationFile, outFolder, name)=>{
341
- const { generateDocs } = await import('./docs-DvFV9WXA.mjs');
342
- return await generateDocs(location, declarationFile, outFolder, name);
343
- };
344
- const __filename$1 = fileURLToPath(import.meta.url);
345
- const __dirname$1 = path.dirname(__filename$1);
346
- const pjson = JSON.parse(fs.readFileSync(path.join(__dirname$1, "..", "package.json"), "utf8"));
347
- const captureError = (err)=>{
348
- console.log("");
349
- if (process.env.NODE_ENV !== "production") {
350
- console.error(err);
351
- } else {
352
- console.error("Stopped execution because of the following error: " + err.message);
353
- }
354
- process.exit(1);
355
- };
356
- const buildOptions = {
357
- outDir: {
358
- description: "Output directory",
359
- type: "string",
360
- default: "bin",
361
- coerce: (input)=>input === undefined || input === null ? undefined : path.resolve(process.cwd(), input)
362
- },
363
- minimize: {
364
- description: "Minify output",
365
- type: "boolean",
366
- default: true
367
- },
368
- cwd: {
369
- description: "Working directory",
370
- type: "string",
371
- default: process.cwd()
372
- },
373
- clean: {
374
- description: "Empty output dir before compiling",
375
- type: "boolean",
376
- default: false
377
- },
378
- docs: {
379
- type: "boolean",
380
- default: false
381
- }
382
- };
383
- const preCommandCheck = async (workspaceLocation)=>{
384
- const executedLocalPackager = __filename$1.startsWith(workspaceLocation.path);
385
- const repositoryPackage = readWorkspaceNpmManifest(workspaceLocation);
386
- if (repositoryPackage?.dependencies?.["@intelligentgraphics/ig.gfx.packager"] || repositoryPackage?.devDependencies?.["@intelligentgraphics/ig.gfx.packager"]) {
387
- const parts = [
388
- "Detected locally installed ig.gfx.packager."
389
- ];
390
- if (executedLocalPackager) {
391
- parts.push('Run "npm install -g @intelligentgraphics/ig.gfx.packager@latest" to install the global version, if it is not yet installed.');
392
- }
393
- parts.push('Run "npm uninstall @intelligentgraphics/ig.gfx.packager" to remove the local version.');
394
- console.error(parts.join("\n"));
395
- process.exit(1);
396
- }
397
- if (executedLocalPackager) {
398
- console.error(`Detected locally installed ig.gfx.packager.
399
- Run "npm install -g @intelligentgraphics/ig.gfx.packager@latest" to install the global version, if it is not yet installed.
400
- Run "npm install" to get rid of the local packager version.`);
401
- process.exit(1);
402
- }
403
- const notifier = updateNotifier({
404
- pkg: pjson,
405
- shouldNotifyInNpmScript: true,
406
- updateCheckInterval: 1000 * 60
407
- });
408
- notifier.notify({
409
- isGlobal: true,
410
- defer: true
411
- });
412
- if (repositoryPackage === undefined) {
413
- throw new Error("Could not load package.json file in current directory");
414
- }
415
- repositoryPackage.scripts ??= {};
416
- repositoryPackage.scripts.postinstall = "packager postinstall";
417
- writeWorkspaceNpmManifest(workspaceLocation, repositoryPackage);
418
- };
419
- const yargsInstance = yargs(process.argv.slice(2));
420
- const resolvePackagesFromMaybePatterns = (args = [], workspace)=>{
421
- const folders = new Map();
422
- for (const arg of args){
423
- glob.sync(arg, {
424
- cwd: workspace.path,
425
- absolute: true
426
- }).forEach((folder)=>{
427
- try {
428
- const location = detectPackage(workspace, folder);
429
- folders.set(folder, location);
430
- } catch (err) {}
431
- });
432
- }
433
- return Array.from(folders.values());
434
- };
435
- yargsInstance.command("build [directories...]", "Builds the specified directories", (argv)=>argv.options({
436
- ...buildOptions,
437
- watch: {
438
- type: "boolean",
439
- default: false
440
- }
441
- }), async ({ directories = [], watch, ...options })=>{
442
- const workspace = detectWorkspace(options.cwd);
443
- const folders = resolvePackagesFromMaybePatterns(directories, workspace);
444
- await preCommandCheck(workspace);
445
- if (folders.length === 0) {
446
- return console.log("No build targets found. Please check wether a folder with the provided name exists and wether it has _Package.json.");
447
- }
448
- const { buildFolders, buildFoldersWatch } = await import('./index-Ck4_b8Wk.mjs').then(function (n) { return n.i; });
449
- if (watch) {
450
- await buildFoldersWatch({
451
- ...options,
452
- packages: folders,
453
- workspace,
454
- docsHandler
455
- }).catch(captureError);
456
- return;
457
- }
458
- await buildFolders({
459
- ...options,
460
- packages: folders,
461
- workspace,
462
- docsHandler
463
- }).catch(captureError);
464
- });
465
- yargsInstance.command("publish [directory]", "Publishes the specified directory", (argv)=>argv.options({
466
- ...buildOptions,
467
- noUpload: {
468
- type: "boolean",
469
- default: false,
470
- description: "Only zip built files and do not upload them"
471
- },
472
- domain: {
473
- type: "string",
474
- description: "Overwrite the publish domain. Defaults to the one in the _Package.json"
475
- },
476
- subdomain: {
477
- type: "string",
478
- description: "Overwrite the publish subdomain. Defaults to the one in the _Package.json"
479
- },
480
- newVersion: {
481
- type: "string",
482
- description: "The name of the new version",
483
- default: process.env.VERSION,
484
- required: true
485
- },
486
- address: {
487
- type: "string",
488
- description: "Address",
489
- default: "localhost"
490
- },
491
- service: {
492
- type: "string",
493
- description: "IG.Asset.Server url",
494
- default: process.env.IG_GFX_ASSET_SERVICE,
495
- required: true
496
- },
497
- user: {
498
- type: "string",
499
- description: "User",
500
- default: process.env.IG_GFX_USER
501
- },
502
- password: {
503
- type: "string",
504
- description: "Password",
505
- default: process.env.IG_GFX_PWD
506
- },
507
- docs: {
508
- type: "boolean",
509
- default: false,
510
- description: "Generate typedoc documentation"
511
- },
512
- pushOnly: {
513
- type: "boolean",
514
- default: false,
515
- description: "Try to upload an existing zip file without building and validating the version number"
516
- },
517
- license: {
518
- type: "string",
519
- description: "Path to a license file",
520
- default: process.env.IG_GFX_LICENSE
521
- },
522
- skipDependencies: {
523
- type: "boolean",
524
- default: false,
525
- description: "Skip dependency checks"
526
- }
527
- }), async ({ directory, user, password, service, license, ...options })=>{
528
- const workspace = detectWorkspace(options.cwd);
529
- const folder = detectPackage(workspace, directory);
530
- await preCommandCheck(workspace);
531
- if (!options.noUpload) {
532
- if (!service) {
533
- captureError(new Error('The IG.Asset.Server url has to either be provided using the option --service or through the "IG_GFX_ASSET_SERVICE" environment variable'));
534
- return;
535
- }
536
- if (!license && (!user || !password)) {
537
- captureError(new Error(`Expected authentication to be provided through either of the following methods:
538
- - as a path to a license file using the --license option or the IG_GFX_LICENSE environment variable
539
- - as a username and password using the --user and --password options, or the IG_GFX_USER and IG_GFX_PWD environment variables`));
540
- return;
541
- }
542
- if (license && !license.endsWith(".iglic")) {
543
- captureError(new Error(`Expected the license path to end with the extension .iglic. Received the path "${license}". You may need to reload your environment variables by restarting the program you're using to execute the packager.`));
544
- return;
545
- }
546
- }
547
- let authentication;
548
- if (license) {
549
- const fullLicensePath = path.resolve(process.cwd(), license);
550
- try {
551
- const content = fs.readFileSync(fullLicensePath);
552
- authentication = {
553
- type: "license",
554
- license: content.toString("base64")
555
- };
556
- } catch (err) {
557
- if (err?.code === "ENOENT") {
558
- captureError(new Error(`Expected to find a license file at path: ${fullLicensePath}`));
559
- return;
560
- }
561
- captureError(new Error(`Failed to read license file at path: ${fullLicensePath}`));
562
- return;
563
- }
564
- } else if (user && password) {
565
- console.log(`Detected usage of username and password authentication. Please migrate to the new license file based authentication.`);
566
- authentication = {
567
- type: "credentials",
568
- username: user,
569
- password
570
- };
571
- }
572
- const { releaseFolder } = await import('./index-DHSUlJia.mjs');
573
- const prompter = createDefaultPrompter();
574
- const fullOptions = {
575
- ...options,
576
- authentication,
577
- service: service,
578
- directory: folder,
579
- banner: true,
580
- prompter,
581
- newVersion: options.newVersion,
582
- workspace,
583
- docsHandler
584
- };
585
- await releaseFolder(fullOptions).catch(captureError);
586
- });
587
- yargsInstance.command("testConnection [directory]", "Tests connection to asset service", (argv)=>argv.options({
588
- domain: {
589
- type: "string",
590
- description: "Overwrite the publish domain. Defaults to the one in the _Package.json"
591
- },
592
- subdomain: {
593
- type: "string",
594
- description: "Overwrite the publish subdomain. Defaults to the one in the _Package.json"
595
- },
596
- address: {
597
- type: "string",
598
- description: "Address",
599
- default: "localhost"
600
- },
601
- service: {
602
- type: "string",
603
- description: "IG.Asset.Server url",
604
- default: process.env.IG_GFX_ASSET_SERVICE,
605
- required: true
606
- },
607
- user: {
608
- type: "string",
609
- description: "User",
610
- default: process.env.IG_GFX_USER
611
- },
612
- password: {
613
- type: "string",
614
- description: "Password",
615
- default: process.env.IG_GFX_PWD
616
- },
617
- license: {
618
- type: "string",
619
- description: "Path to a license file",
620
- default: process.env.IG_GFX_LICENSE
621
- }
622
- }), async ({ user, password, service, license, subdomain, domain, address, directory })=>{
623
- if (!service) {
624
- captureError(new Error('The IG.Asset.Server url has to either be provided using the option --service or through the "IG_GFX_ASSET_SERVICE" environment variable'));
625
- return;
626
- }
627
- if (!license && (!user || !password)) {
628
- captureError(new Error(`Expected authentication to be provided through either of the following methods:
629
- - as a path to a license file using the --license option or the IG_GFX_LICENSE environment variable
630
- - as a username and password using the --user and --password options, or the IG_GFX_USER and IG_GFX_PWD environment variables`));
631
- return;
632
- }
633
- if (license && !license.endsWith(".iglic")) {
634
- captureError(new Error(`Expected the license path to end with the extension .iglic. Received the path "${license}". You may need to reload your environment variables by restarting the program you're using to execute the packager.`));
635
- return;
636
- }
637
- let authentication;
638
- if (license) {
639
- const fullLicensePath = path.resolve(process.cwd(), license);
640
- try {
641
- const content = fs.readFileSync(fullLicensePath);
642
- authentication = {
643
- type: "license",
644
- license: content.toString("base64")
645
- };
646
- } catch (err) {
647
- if (err?.code === "ENOENT") {
648
- captureError(new Error(`Expected to find a license file at path: ${fullLicensePath}`));
649
- return;
650
- }
651
- captureError(new Error(`Failed to read license file at path: ${fullLicensePath}`));
652
- return;
653
- }
654
- } else if (user && password) {
655
- console.log(`Detected usage of username and password authentication. Please migrate to the new license file based authentication.`);
656
- authentication = {
657
- type: "credentials",
658
- username: user,
659
- password
660
- };
661
- }
662
- if (authentication === undefined) {
663
- throw new Error(`Expected authentication to be available`);
664
- }
665
- if (typeof directory === "string") {
666
- const workspace = detectWorkspace(process.cwd());
667
- const folder = detectPackage(workspace, directory);
668
- const manifest = readPackageCreatorManifest(folder);
669
- const parsedName = parseCreatorPackageName(manifest);
670
- if (domain === undefined) {
671
- domain = parsedName.domain;
672
- }
673
- if (subdomain === undefined) {
674
- subdomain = parsedName.subdomain;
675
- }
676
- }
677
- if (domain === undefined || subdomain === undefined) {
678
- throw new Error(`Expected either domain and subdomain to be provided through options or to be executed for a specific package directory`);
679
- }
680
- const session = await startSession({
681
- url: service,
682
- address,
683
- domain,
684
- subDomain: subdomain,
685
- authentication
686
- });
687
- await closeSession(session);
688
- console.log(`Asset service session successfully started and closed`);
689
- });
690
- yargsInstance.command({
691
- command: "generateIndex [directory]",
692
- builder: (argv)=>argv.option("ignore", {
693
- type: "array",
694
- default: [],
695
- description: "Files to ignore while generating index"
696
- }).option("strictOptional", {
697
- type: "boolean",
698
- description: "Marks non optional parameter object properties as required"
699
- }),
700
- handler: async ({ directory, ignore, strictOptional })=>{
701
- const workspace = detectWorkspace(process.cwd());
702
- await preCommandCheck(workspace);
703
- const { generateIndex } = await import('./generateIndex-COnAgsMM.mjs');
704
- const location = detectPackage(workspace, directory);
705
- generateIndex({
706
- location,
707
- ignore: ignore,
708
- strictOptional
709
- });
710
- },
711
- describe: "Generates an index file for a package based on typescript types"
712
- });
713
- yargsInstance.command({
714
- command: "generateParameterType [directory] [name]",
715
- handler: async ({ directory, name })=>{
716
- const workspace = detectWorkspace(process.cwd());
717
- await preCommandCheck(workspace);
718
- const { generateParameterType } = await import('./generateParameterType-BFVUv72F.mjs');
719
- const location = detectPackage(workspace, directory);
720
- generateParameterType({
721
- location,
722
- name
723
- });
724
- },
725
- describe: "Generates a parameter type for an interactor or evaluator"
726
- });
727
- yargsInstance.command({
728
- command: "postinstall",
729
- builder: (argv)=>argv,
730
- handler: async ()=>{
731
- const { executePostInstall } = await import('./postinstall-BTuIhY_F.mjs');
732
- executePostInstall(detectWorkspace(process.cwd()));
733
- },
734
- describe: "Runs postinstall tasks"
735
- });
736
- yargsInstance.command({
737
- command: "publishNpm [directory]",
738
- builder: (argv)=>argv.options({
739
- newVersion: {
740
- type: "string",
741
- description: "Name of the new version",
742
- default: process.env.VERSION,
743
- required: true
744
- },
745
- dryRun: {
746
- type: "boolean"
747
- }
748
- }),
749
- handler: async ({ directory, newVersion, dryRun })=>{
750
- const workspace = detectWorkspace(process.cwd());
751
- const { publishToNpm } = await import('./publishNpm-A02qW1UY.mjs');
752
- await publishToNpm({
753
- workspace,
754
- location: detectPackage(workspace, directory),
755
- version: newVersion,
756
- dryRun
757
- }).catch(captureError);
758
- },
759
- describe: "Publishes the package to npm"
760
- });
761
- yargsInstance.demandCommand().pkgConf("packager").showHelpOnFail(false).version(pjson.version).argv;
762
-
763
- var cli = /*#__PURE__*/Object.freeze({
764
- __proto__: null
765
- });
766
-
767
- export { INDEX_FILE as I, PACKAGE_FILE as P, readPackageCreatorIndex as a, readWorkspaceNpmManifest as b, closeSession as c, getWorkspaceOutputPath as d, readPackageAnimationList as e, isErrorEACCES as f, getExistingPackages as g, isErrorEPERM as h, isErrorENOENT as i, getPackageReleasesDirectory as j, writePackageCreatorIndex as k, getCreatorIndexParameterPrimaryJSType as l, getWorkspaceLibPath as m, readNpmManifest as n, stripUtf8Bom as o, parseCreatorPackageName as p, readPackageNpmManifest as q, readPackageCreatorManifest as r, startSession as s, writePackageNpmManifest as t, uploadPackageFromBuffer as u, iterateWorkspacePackages as v, writePackageCreatorManifest as w, cli as x };
768
- //# sourceMappingURL=cli-CTqQeYIu.mjs.map