@intelligentgraphics/ig.gfx.packager 2.3.4 → 3.0.0-alpha.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.
- package/build/cli.js +8315 -0
- package/build/cli.js.map +1 -0
- package/build/commands/build.js +325 -0
- package/build/commands/build.js.map +1 -0
- package/build/commands/generate.js +215 -0
- package/build/commands/generate.js.map +1 -0
- package/build/commands/postinstall.js +77 -0
- package/build/commands/postinstall.js.map +1 -0
- package/build/commands/publishNpm.js +156 -0
- package/build/commands/publishNpm.js.map +1 -0
- package/build/commands/release.js +576 -0
- package/build/commands/release.js.map +1 -0
- package/build/dependencies.js +164 -0
- package/build/dependencies.js.map +1 -0
- package/build/index.js +5 -8762
- package/build/index.js.map +1 -1
- package/build/scripts.js +31 -0
- package/build/scripts.js.map +1 -0
- package/build/versionFile.js +181 -0
- package/build/versionFile.js.map +1 -0
- package/package.json +13 -16
- package/readme.md +47 -10
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('path');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var promises = require('stream/promises');
|
|
6
|
+
var require$$1 = require('child_process');
|
|
7
|
+
var cli = require('../cli.js');
|
|
8
|
+
var index = require('./build.js');
|
|
9
|
+
var versionFile = require('../versionFile.js');
|
|
10
|
+
var axios = require('axios');
|
|
11
|
+
var Ajv = require('ajv');
|
|
12
|
+
var JSZip = require('jszip');
|
|
13
|
+
var terser = require('terser');
|
|
14
|
+
var dependencies = require('../dependencies.js');
|
|
15
|
+
require('update-notifier');
|
|
16
|
+
require('yargs');
|
|
17
|
+
require('tslib');
|
|
18
|
+
require('os');
|
|
19
|
+
require('assert');
|
|
20
|
+
require('events');
|
|
21
|
+
require('buffer');
|
|
22
|
+
require('stream');
|
|
23
|
+
require('util');
|
|
24
|
+
require('constants');
|
|
25
|
+
require('write-pkg');
|
|
26
|
+
require('inquirer');
|
|
27
|
+
require('glob');
|
|
28
|
+
require('typescript');
|
|
29
|
+
require('../scripts.js');
|
|
30
|
+
require('typedoc');
|
|
31
|
+
require('simple-git');
|
|
32
|
+
require('resolve');
|
|
33
|
+
|
|
34
|
+
function _interopNamespaceDefault(e) {
|
|
35
|
+
var n = Object.create(null);
|
|
36
|
+
if (e) {
|
|
37
|
+
Object.keys(e).forEach(function (k) {
|
|
38
|
+
if (k !== 'default') {
|
|
39
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
40
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function () { return e[k]; }
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
n.default = e;
|
|
48
|
+
return Object.freeze(n);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
52
|
+
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
53
|
+
var terser__namespace = /*#__PURE__*/_interopNamespaceDefault(terser);
|
|
54
|
+
|
|
55
|
+
const PLUGIN_ID = "0feba3a0-b6d1-11e6-9598-0800200c9a66";
|
|
56
|
+
/**
|
|
57
|
+
* Starts an asset service session and returns the sessionId
|
|
58
|
+
*
|
|
59
|
+
* @param {SessionStartParams} params
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
const startSession = async ({
|
|
63
|
+
url,
|
|
64
|
+
authentication,
|
|
65
|
+
...params
|
|
66
|
+
}) => {
|
|
67
|
+
const payload = {
|
|
68
|
+
...params,
|
|
69
|
+
user: undefined,
|
|
70
|
+
password: undefined,
|
|
71
|
+
license: undefined,
|
|
72
|
+
plugin: PLUGIN_ID
|
|
73
|
+
};
|
|
74
|
+
if (authentication.type === "credentials") {
|
|
75
|
+
payload.user = authentication.username;
|
|
76
|
+
payload.password = authentication.password;
|
|
77
|
+
} else if (authentication.type === "license") {
|
|
78
|
+
payload.license = authentication.license;
|
|
79
|
+
}
|
|
80
|
+
const {
|
|
81
|
+
data: {
|
|
82
|
+
session: sessionId,
|
|
83
|
+
state
|
|
84
|
+
}
|
|
85
|
+
} = await axios.post(`Session/Start2`, JSON.stringify(payload), {
|
|
86
|
+
baseURL: url
|
|
87
|
+
});
|
|
88
|
+
if (state !== "SUCCESS") {
|
|
89
|
+
throw new Error(`Could not start session: Asset server responded with ${state}`);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
url,
|
|
93
|
+
sessionId,
|
|
94
|
+
domain: params.domain,
|
|
95
|
+
subDomain: params.subDomain
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
const closeSession = async session => {
|
|
99
|
+
await axios.get(`Session/Close/${session.sessionId}`, {
|
|
100
|
+
baseURL: session.url
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
const uploadPackage = async (session, {
|
|
104
|
+
name,
|
|
105
|
+
version
|
|
106
|
+
}, zipFilePath) => {
|
|
107
|
+
try {
|
|
108
|
+
await uploadPackageToUrl(session.url, `UploadPackage/${session.sessionId}/${name}_${version}`, zipFilePath);
|
|
109
|
+
} catch (err) {
|
|
110
|
+
await uploadPackageToUrl(session.url, `UploadPackage/${session.sessionId}/${name}_${version}/`, zipFilePath);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const getExistingPackages = async session => axios.get(`Script/GetInformation/${session.sessionId}`, {
|
|
114
|
+
baseURL: session.url,
|
|
115
|
+
validateStatus: status => status === 404 || status === 200
|
|
116
|
+
}).then(({
|
|
117
|
+
data
|
|
118
|
+
}) => Array.isArray(data) ? data : undefined);
|
|
119
|
+
const uploadPackageToUrl = (url, path, zipFilePath) => axios.post(path, fs__namespace.createReadStream(zipFilePath), {
|
|
120
|
+
baseURL: url
|
|
121
|
+
}).then(({
|
|
122
|
+
data,
|
|
123
|
+
status
|
|
124
|
+
}) => {
|
|
125
|
+
let objectBody;
|
|
126
|
+
if (typeof data === "string") {
|
|
127
|
+
try {
|
|
128
|
+
objectBody = JSON.parse(data);
|
|
129
|
+
} catch (err) {}
|
|
130
|
+
} else if (typeof data === "object") {
|
|
131
|
+
objectBody = data;
|
|
132
|
+
}
|
|
133
|
+
if (objectBody !== undefined) {
|
|
134
|
+
if ("state" in objectBody && objectBody.state !== "SUCCESS") {
|
|
135
|
+
throw new Error(objectBody.response ?? objectBody.state);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (status >= 400) {
|
|
139
|
+
if (objectBody !== undefined) {
|
|
140
|
+
let text = "";
|
|
141
|
+
for (const key in objectBody) {
|
|
142
|
+
text += key + ": \n";
|
|
143
|
+
if (typeof objectBody[key] === "object") {
|
|
144
|
+
text += JSON.stringify(objectBody[key], undefined, 2);
|
|
145
|
+
} else {
|
|
146
|
+
text += objectBody[key];
|
|
147
|
+
}
|
|
148
|
+
text += "\n\n";
|
|
149
|
+
}
|
|
150
|
+
throw new Error(text);
|
|
151
|
+
}
|
|
152
|
+
throw new Error(data);
|
|
153
|
+
}
|
|
154
|
+
return data;
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const buildArchiveFromPublishedPackage = (location, manifest, creatorPackage) => {
|
|
158
|
+
const archive = new JSZip();
|
|
159
|
+
archive.file("_Package.json", JSON.stringify(creatorPackage, null, 2));
|
|
160
|
+
const index = dependencies.readPublishedPackageCreatorIndex(location);
|
|
161
|
+
if (index !== undefined) {
|
|
162
|
+
archive.file("_Index.json", JSON.stringify(index, null, 2));
|
|
163
|
+
}
|
|
164
|
+
archive.file(manifest.main, fs__namespace.createReadStream(path__namespace.join(location.path, manifest.main)));
|
|
165
|
+
return archive;
|
|
166
|
+
};
|
|
167
|
+
let validateSchema;
|
|
168
|
+
const runtimeScripts = ["Interactor", "Core", "Mixed"];
|
|
169
|
+
const notRuntimeScripts = ["Context", "Evaluator"];
|
|
170
|
+
const buildArchiveFromPackage = async (workspaceLocation, packageLocation, data) => {
|
|
171
|
+
const {
|
|
172
|
+
domain,
|
|
173
|
+
subdomain
|
|
174
|
+
} = cli.parseCreatorPackageName(data);
|
|
175
|
+
const logStep = step => index.logPackageMessage(data.Package, step);
|
|
176
|
+
if (validateSchema === undefined) {
|
|
177
|
+
validateSchema = await axios.get("https://archive.intelligentgraphics.biz/schemas/gfx/animation.json").then(({
|
|
178
|
+
data
|
|
179
|
+
}) => new Ajv({
|
|
180
|
+
coerceTypes: true,
|
|
181
|
+
allErrors: true,
|
|
182
|
+
removeAdditional: true,
|
|
183
|
+
useDefaults: "empty",
|
|
184
|
+
validateSchema: "log"
|
|
185
|
+
}).compile(data));
|
|
186
|
+
}
|
|
187
|
+
const libFilePath = path__namespace.join(cli.getWorkspaceOutputPath(workspaceLocation), `${data.Package}.min.js`);
|
|
188
|
+
const scriptDirectories = [packageLocation.path, packageLocation.scriptsDir];
|
|
189
|
+
if (subdomain === "GFX.Standard") {
|
|
190
|
+
logStep(`Including Images folder`);
|
|
191
|
+
scriptDirectories.push(path__namespace.join(packageLocation.path, "Images"));
|
|
192
|
+
}
|
|
193
|
+
const manifest = cli.readPackageCreatorManifest(packageLocation);
|
|
194
|
+
if (manifest !== undefined) {
|
|
195
|
+
if (manifest.RunTime && notRuntimeScripts.includes(manifest.Type)) {
|
|
196
|
+
logStep("Setting script RunTime to false because of script type");
|
|
197
|
+
cli.writePackageCreatorManifest(packageLocation, {
|
|
198
|
+
...manifest,
|
|
199
|
+
RunTime: false
|
|
200
|
+
});
|
|
201
|
+
} else if (!manifest.RunTime && runtimeScripts.includes(manifest.Type)) {
|
|
202
|
+
logStep("Setting script RunTime to true because of script type");
|
|
203
|
+
cli.writePackageCreatorManifest(packageLocation, {
|
|
204
|
+
...manifest,
|
|
205
|
+
RunTime: true
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// if (index === undefined) {
|
|
211
|
+
// throw new Error(
|
|
212
|
+
// `Could not find an "${INDEX_FILE}" file in "${primaryScriptDir}"`,
|
|
213
|
+
// );
|
|
214
|
+
// }
|
|
215
|
+
|
|
216
|
+
const animations = new Map();
|
|
217
|
+
for (const scriptFilePath of cli.readPackageAnimationList(packageLocation)) {
|
|
218
|
+
const content = fs__namespace.readFileSync(scriptFilePath, {
|
|
219
|
+
encoding: "utf8"
|
|
220
|
+
});
|
|
221
|
+
let data;
|
|
222
|
+
try {
|
|
223
|
+
data = JSON.parse(content);
|
|
224
|
+
} catch (err) {
|
|
225
|
+
const relativePath = path__namespace.relative(workspaceLocation.path, scriptFilePath);
|
|
226
|
+
if (err instanceof SyntaxError) {
|
|
227
|
+
throw new Error(`Encountered invalid syntax in file "${relativePath}": ${String(err)}`);
|
|
228
|
+
}
|
|
229
|
+
throw new Error(`Encountered an unexpected error while parsing animation json file at path "${relativePath}"`, {
|
|
230
|
+
cause: err
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
validateSchema(data);
|
|
234
|
+
animations.set(data.Id, JSON.stringify(data));
|
|
235
|
+
}
|
|
236
|
+
let libFile;
|
|
237
|
+
try {
|
|
238
|
+
libFile = fs__namespace.readFileSync(libFilePath, {
|
|
239
|
+
encoding: "utf8"
|
|
240
|
+
});
|
|
241
|
+
} catch (err) {
|
|
242
|
+
if (!cli.isErrorENOENT(err)) {
|
|
243
|
+
throw err;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (libFile === undefined) {
|
|
247
|
+
if (animations.size === 0) {
|
|
248
|
+
throw new Error(`Could not find a javascript file at "${libFilePath}".
|
|
249
|
+
Packaging without a javascript file is only allowed when animation json files are available`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const archive = new JSZip();
|
|
253
|
+
let library = "";
|
|
254
|
+
if (libFile) {
|
|
255
|
+
library = libFile;
|
|
256
|
+
}
|
|
257
|
+
if (!library) {
|
|
258
|
+
const date = new Date(Date.now());
|
|
259
|
+
library = `/* This file is part of the ${domain} Data Packages.
|
|
260
|
+
* Copyright (C) ${date.getFullYear()} intelligentgraphics. All Rights Reserved. */`;
|
|
261
|
+
}
|
|
262
|
+
if (animations.size > 0) {
|
|
263
|
+
const scopeParts = data.Scope.split(".");
|
|
264
|
+
const scope = data.Scope;
|
|
265
|
+
library += createNamespace(scopeParts);
|
|
266
|
+
for (const [name, data] of animations) {
|
|
267
|
+
library += `${scope}.${name} = ` + data + ";";
|
|
268
|
+
console.log(`${name}: Added animation ${scope}.${name}`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
const minifyResult = terser__namespace.minify(library, {
|
|
272
|
+
ecma: 5
|
|
273
|
+
});
|
|
274
|
+
archive.file(`${data.Package}.js`, minifyResult.code);
|
|
275
|
+
archive.file(`_Package.json`, JSON.stringify(data, null, 2));
|
|
276
|
+
const creatorIndex = cli.readPackageCreatorIndex(packageLocation);
|
|
277
|
+
if (creatorIndex !== undefined) {
|
|
278
|
+
archive.file(`_Index.json`, JSON.stringify(creatorIndex, null, 2));
|
|
279
|
+
}
|
|
280
|
+
for (const directory of scriptDirectories) {
|
|
281
|
+
try {
|
|
282
|
+
for (const file of fs__namespace.readdirSync(directory)) {
|
|
283
|
+
const {
|
|
284
|
+
ext
|
|
285
|
+
} = path__namespace.parse(file);
|
|
286
|
+
switch (ext) {
|
|
287
|
+
case ".png":
|
|
288
|
+
case ".jpeg":
|
|
289
|
+
case ".jpg":
|
|
290
|
+
break;
|
|
291
|
+
default:
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
archive.file(file, fs__namespace.createReadStream(path__namespace.join(directory, file)));
|
|
295
|
+
}
|
|
296
|
+
} catch (err) {
|
|
297
|
+
console.error(`Script directory "${directory}" does not exist`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return archive;
|
|
301
|
+
};
|
|
302
|
+
const createNamespace = parts => {
|
|
303
|
+
let code = `var ${parts[0]};`;
|
|
304
|
+
for (let index = 0; index < parts.length; index++) {
|
|
305
|
+
const path = parts.slice(0, index + 1).join(".");
|
|
306
|
+
code += `\n(${path} = ${path} || {});`;
|
|
307
|
+
}
|
|
308
|
+
return code;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
const releaseFolder = async options => {
|
|
312
|
+
const workspace = cli.detectWorkspace(options.cwd);
|
|
313
|
+
const location = cli.detectPackage(workspace, options.directory);
|
|
314
|
+
const {
|
|
315
|
+
write: writeVersionFile,
|
|
316
|
+
reset: resetVersionFile
|
|
317
|
+
} = versionFile.getVersionFileHandler(location);
|
|
318
|
+
const packageDescription = cli.readPackageCreatorManifest(location);
|
|
319
|
+
const fullPackageName = packageDescription.Package;
|
|
320
|
+
const {
|
|
321
|
+
domain,
|
|
322
|
+
subdomain
|
|
323
|
+
} = cli.parseCreatorPackageName(packageDescription);
|
|
324
|
+
const publishDomain = options.domain ?? domain;
|
|
325
|
+
const publishSubdomain = options.subdomain ?? subdomain;
|
|
326
|
+
const sharedPackageJson = cli.readWorkspaceNpmManifest(workspace);
|
|
327
|
+
let newVersion;
|
|
328
|
+
try {
|
|
329
|
+
newVersion = versionFile.parseVersionFromString(options.newVersion);
|
|
330
|
+
} catch (err) {
|
|
331
|
+
throw new Error(`Please enter a version in this format 1.0.0.100`);
|
|
332
|
+
}
|
|
333
|
+
if (newVersion.buildNumber < 100) {
|
|
334
|
+
newVersion.preRelease = {
|
|
335
|
+
type: "beta",
|
|
336
|
+
version: newVersion.buildNumber
|
|
337
|
+
};
|
|
338
|
+
} else if (newVersion.buildNumber > 100) {
|
|
339
|
+
newVersion.preRelease = {
|
|
340
|
+
type: "patch",
|
|
341
|
+
version: newVersion.buildNumber - 100
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
if (sharedPackageJson !== undefined) {
|
|
345
|
+
index.logPackageMessage(packageDescription.Package, `Running npm install to make sure all dependencies are up to date`);
|
|
346
|
+
require$$1.execSync(`npm install`, {
|
|
347
|
+
encoding: "utf-8",
|
|
348
|
+
cwd: workspace.path
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
const binDir = cli.getWorkspaceOutputPath(workspace);
|
|
352
|
+
fs__namespace.mkdirSync(binDir, {
|
|
353
|
+
recursive: true
|
|
354
|
+
});
|
|
355
|
+
let assetServerPackageDetails;
|
|
356
|
+
let packageNameWithVersion;
|
|
357
|
+
{
|
|
358
|
+
const versionWithoutPrelease = newVersion.clone();
|
|
359
|
+
versionWithoutPrelease.preRelease = undefined;
|
|
360
|
+
const newVersionString = versionWithoutPrelease.toVersionString({
|
|
361
|
+
buildNumber: true
|
|
362
|
+
});
|
|
363
|
+
packageNameWithVersion = `${packageDescription.Package}_${newVersionString}`;
|
|
364
|
+
assetServerPackageDetails = {
|
|
365
|
+
name: packageDescription.Package,
|
|
366
|
+
version: newVersionString
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
const zipFilePath = path__namespace.join(binDir, packageNameWithVersion + ".zip");
|
|
370
|
+
try {
|
|
371
|
+
if (options.pushOnly) {
|
|
372
|
+
if (!fs__namespace.existsSync(zipFilePath)) {
|
|
373
|
+
throw new Error(`Expected a zip file to exist at path ${zipFilePath} since pushOnly is specified`);
|
|
374
|
+
}
|
|
375
|
+
} else {
|
|
376
|
+
const gitVersionInformation = await versionFile.getVersionInformationFromGit(workspace, location);
|
|
377
|
+
writeVersionFile(fullPackageName, newVersion);
|
|
378
|
+
const bannerText = sharedPackageJson !== undefined ? versionFile.getWorkspaceBannerText(sharedPackageJson) : undefined;
|
|
379
|
+
await index.buildFolders({
|
|
380
|
+
...options,
|
|
381
|
+
directories: [location.path],
|
|
382
|
+
skipPackagesWithoutTsFiles: true,
|
|
383
|
+
banner: options.banner ? {
|
|
384
|
+
text: bannerText,
|
|
385
|
+
commit: gitVersionInformation.commit,
|
|
386
|
+
commitDirty: gitVersionInformation.dirty,
|
|
387
|
+
version: newVersion.toVersionString({
|
|
388
|
+
buildNumber: true
|
|
389
|
+
}),
|
|
390
|
+
date: new Date(Date.now())
|
|
391
|
+
// gitVersionInformation.commitDate
|
|
392
|
+
// ? new Date(gitVersionInformation.commitDate)
|
|
393
|
+
// : new Date(Date.now()),
|
|
394
|
+
} : undefined
|
|
395
|
+
});
|
|
396
|
+
newVersion.preRelease = undefined;
|
|
397
|
+
try {
|
|
398
|
+
fs__namespace.rmSync(zipFilePath);
|
|
399
|
+
} catch (err) {
|
|
400
|
+
if (!cli.isErrorENOENT(err)) {
|
|
401
|
+
throw err;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
const archive = await buildArchiveFromPackage(workspace, location, packageDescription);
|
|
405
|
+
const zipOutputStream = fs__namespace.createWriteStream(zipFilePath);
|
|
406
|
+
await promises.pipeline(archive.generateNodeStream(), zipOutputStream);
|
|
407
|
+
}
|
|
408
|
+
if (!options.noUpload) {
|
|
409
|
+
if (!options.authentication) {
|
|
410
|
+
throw new Error(`Expected authentication to be available`);
|
|
411
|
+
}
|
|
412
|
+
index.logPackageMessage(packageDescription.Package, `Opening connection to asset server`);
|
|
413
|
+
const sessionManager = await createSessionManager({
|
|
414
|
+
url: options.service,
|
|
415
|
+
address: options.address,
|
|
416
|
+
domain: publishDomain,
|
|
417
|
+
subDomain: publishSubdomain,
|
|
418
|
+
authentication: options.authentication
|
|
419
|
+
});
|
|
420
|
+
index.logPackageMessage(packageDescription.Package, `Making sure all dependencies are available with an acceptable version`);
|
|
421
|
+
if (!(await ensureRequiredVersions(workspace, packageDescription, sessionManager, options.prompter))) {
|
|
422
|
+
index.logPackageMessage(packageDescription.Package, "AssetService does not yet support required apis for dependency check");
|
|
423
|
+
}
|
|
424
|
+
index.logPackageMessage(packageDescription.Package, `Uploading package to ${publishDomain}.${publishSubdomain}`);
|
|
425
|
+
await uploadPackage(sessionManager.getTargetSession(), assetServerPackageDetails, zipFilePath);
|
|
426
|
+
await sessionManager.destroy().catch(err => {
|
|
427
|
+
index.logPackageMessage(packageDescription.Package, `Failed to close asset service session(s): ${err}`);
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
} catch (err) {
|
|
431
|
+
resetVersionFile();
|
|
432
|
+
throw err;
|
|
433
|
+
}
|
|
434
|
+
if (newVersion.buildNumber >= 100 && !options.pushOnly) {
|
|
435
|
+
index.logPackageMessage(fullPackageName, cli.translate("messages.movingReleaseZip"));
|
|
436
|
+
const zipFileName = `${packageNameWithVersion}.zip`;
|
|
437
|
+
const releasesPath = cli.getPackageReleasesDirectory(location);
|
|
438
|
+
fs__namespace.mkdirSync(releasesPath, {
|
|
439
|
+
recursive: true
|
|
440
|
+
});
|
|
441
|
+
fs__namespace.copyFileSync(zipFilePath, path__namespace.join(releasesPath, zipFileName));
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
const ensureRequiredVersions = async (workspaceLocation, creatorPackage, sessionManager, prompter) => {
|
|
445
|
+
const targetSession = sessionManager.getTargetSession();
|
|
446
|
+
const rawUploadedPackages = await getExistingPackages(targetSession);
|
|
447
|
+
if (rawUploadedPackages === undefined) {
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
450
|
+
const uploadedPackages = rawUploadedPackages.map(entry => {
|
|
451
|
+
let version;
|
|
452
|
+
try {
|
|
453
|
+
version = versionFile.parseVersionFromString(entry.informalVersion);
|
|
454
|
+
} catch (err) {
|
|
455
|
+
throw new Error(`Encountered invalid format for version ${entry.informalVersion}`);
|
|
456
|
+
}
|
|
457
|
+
if (version.buildNumber < 100) {
|
|
458
|
+
version.preRelease = {
|
|
459
|
+
type: "beta",
|
|
460
|
+
version: version.buildNumber
|
|
461
|
+
};
|
|
462
|
+
} else if (version.buildNumber > 100) {
|
|
463
|
+
version.preRelease = {
|
|
464
|
+
type: "patch",
|
|
465
|
+
version: version.buildNumber - 100
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
return {
|
|
469
|
+
...entry,
|
|
470
|
+
version
|
|
471
|
+
};
|
|
472
|
+
});
|
|
473
|
+
const libraries = dependencies.determineWorkspaceIGLibraries(workspaceLocation);
|
|
474
|
+
for (const libraryLocation of libraries) {
|
|
475
|
+
const libraryManifest = dependencies.readPublishedPackageNpmManifest(libraryLocation);
|
|
476
|
+
const libraryCreatorPackage = dependencies.readPublishedPackageCreatorManifest(libraryLocation);
|
|
477
|
+
if (libraryCreatorPackage === undefined || libraryManifest.main === undefined || libraryCreatorPackage.Package === creatorPackage.Package) {
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
const libraryVersion = cli.build.PackageVersion.extractFromLine(libraryManifest.version);
|
|
481
|
+
if (libraryVersion.preRelease) {
|
|
482
|
+
libraryVersion.buildNumber = libraryVersion.preRelease.version;
|
|
483
|
+
libraryVersion.preRelease = undefined;
|
|
484
|
+
} else {
|
|
485
|
+
libraryVersion.buildNumber = 100;
|
|
486
|
+
}
|
|
487
|
+
let uploadedPackageInBasics;
|
|
488
|
+
let uploadedPackageInTarget;
|
|
489
|
+
for (const uploadedPackage of uploadedPackages) {
|
|
490
|
+
if (uploadedPackage.scope === libraryCreatorPackage.Package) {
|
|
491
|
+
if (uploadedPackage.support) {
|
|
492
|
+
uploadedPackageInBasics = uploadedPackage;
|
|
493
|
+
} else {
|
|
494
|
+
uploadedPackageInTarget = uploadedPackage;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
if (targetSession.subDomain !== "Basics" && (uploadedPackageInBasics !== undefined || uploadedPackageInTarget !== undefined)) {
|
|
499
|
+
index.logPackageMessage(creatorPackage.Package, `Package ${libraryCreatorPackage.Package} is uploaded both for Basics and ${targetSession.subDomain}. The package within ${targetSession.subDomain} will be used.`);
|
|
500
|
+
}
|
|
501
|
+
const validInBasics = uploadedPackageInBasics !== undefined && !uploadedPackageInBasics.version.isLesserThan(libraryVersion);
|
|
502
|
+
const validInTarget = uploadedPackageInTarget !== undefined && !uploadedPackageInTarget.version.isLesserThan(libraryVersion);
|
|
503
|
+
if (validInBasics || validInTarget) {
|
|
504
|
+
index.logPackageMessage(creatorPackage.Package, `Skipping upload for package ${libraryCreatorPackage.Package} as it is already uploaded and up to date.`);
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
if (uploadedPackageInBasics) {
|
|
508
|
+
index.logPackageMessage(creatorPackage.Package, `Found invalid version for package ${libraryCreatorPackage.Package} in Basics.`);
|
|
509
|
+
}
|
|
510
|
+
if (targetSession.subDomain !== "Basics" && uploadedPackageInTarget) {
|
|
511
|
+
index.logPackageMessage(creatorPackage.Package, `Found invalid version for package ${libraryCreatorPackage.Package} in ${targetSession.subDomain}.`);
|
|
512
|
+
}
|
|
513
|
+
const possibleTargets = ["Basics"];
|
|
514
|
+
if (targetSession.subDomain !== "Basics") {
|
|
515
|
+
possibleTargets.push(targetSession.subDomain);
|
|
516
|
+
}
|
|
517
|
+
const uploadTargetScope = await prompter.ask({
|
|
518
|
+
message: `${libraryCreatorPackage.Package} is not available at all or has an invalid version. Select the scope to upload it to`,
|
|
519
|
+
options: [...possibleTargets, "Skip"],
|
|
520
|
+
default: possibleTargets[0]
|
|
521
|
+
});
|
|
522
|
+
if (uploadTargetScope === "Skip") {
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
const archive = buildArchiveFromPublishedPackage(libraryLocation, libraryManifest, libraryCreatorPackage);
|
|
526
|
+
const newVersionString = libraryVersion.toVersionString({
|
|
527
|
+
buildNumber: true
|
|
528
|
+
});
|
|
529
|
+
const packageNameWithVersion = `${libraryCreatorPackage.Package}_${newVersionString}`;
|
|
530
|
+
const zipFilePath = path__namespace.join(cli.getWorkspaceOutputPath(workspaceLocation), `${packageNameWithVersion}.zip`);
|
|
531
|
+
try {
|
|
532
|
+
fs__namespace.rmSync(zipFilePath);
|
|
533
|
+
} catch (err) {
|
|
534
|
+
if (!cli.isErrorENOENT(err)) {
|
|
535
|
+
throw err;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
const zipOutputStream = fs__namespace.createWriteStream(zipFilePath);
|
|
539
|
+
await promises.pipeline(archive.generateNodeStream(), zipOutputStream);
|
|
540
|
+
const session = uploadTargetScope === "Basics" ? await sessionManager.getBasicsSession() : targetSession;
|
|
541
|
+
index.logPackageMessage(creatorPackage.Package, `Uploading package ${libraryCreatorPackage.Package} with version ${newVersionString} to ${session.domain}.${session.subDomain}`);
|
|
542
|
+
await uploadPackage(session, {
|
|
543
|
+
name: libraryCreatorPackage.Package,
|
|
544
|
+
version: newVersionString
|
|
545
|
+
}, zipFilePath);
|
|
546
|
+
}
|
|
547
|
+
return true;
|
|
548
|
+
};
|
|
549
|
+
const createSessionManager = async params => {
|
|
550
|
+
const targetSession = await startSession(params);
|
|
551
|
+
let basicsSession;
|
|
552
|
+
return {
|
|
553
|
+
getBasicsSession: async () => {
|
|
554
|
+
if (targetSession.subDomain === "Basics") {
|
|
555
|
+
return targetSession;
|
|
556
|
+
}
|
|
557
|
+
if (basicsSession === undefined) {
|
|
558
|
+
basicsSession = await startSession({
|
|
559
|
+
...params,
|
|
560
|
+
subDomain: "Basics"
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
return basicsSession;
|
|
564
|
+
},
|
|
565
|
+
getTargetSession: () => targetSession,
|
|
566
|
+
destroy: async () => {
|
|
567
|
+
await closeSession(targetSession);
|
|
568
|
+
if (basicsSession !== undefined) {
|
|
569
|
+
await closeSession(basicsSession);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
exports.releaseFolder = releaseFolder;
|
|
576
|
+
//# sourceMappingURL=release.js.map
|