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