@intelligentgraphics/ig.gfx.packager 3.0.0-beta.0 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.mjs +44 -338
- package/build/cli.mjs.map +1 -1
- package/build/commands/build/docs.mjs +34 -0
- package/build/commands/build/docs.mjs.map +1 -0
- package/build/commands/build/index.mjs +169 -0
- package/build/commands/build/index.mjs.map +1 -0
- package/build/commands/build/tsc.mjs +84 -0
- package/build/commands/build/tsc.mjs.map +1 -0
- package/build/commands/{generate.ts.mjs → generate.mjs} +3 -13
- package/build/commands/generate.mjs.map +1 -0
- package/build/commands/{postinstall.ts.mjs → postinstall.mjs} +4 -11
- package/build/commands/postinstall.mjs.map +1 -0
- package/build/commands/{publish.mjs → publish/index.mjs} +20 -288
- package/build/commands/publish/index.mjs.map +1 -0
- package/build/commands/publish/zip.mjs +168 -0
- package/build/commands/publish/zip.mjs.map +1 -0
- package/build/commands/{publishNpm.ts.mjs → publishNpm.mjs} +11 -19
- package/build/commands/publishNpm.mjs.map +1 -0
- package/build/index.mjs +1 -1
- package/build/index.mjs.map +1 -1
- package/build/lib/assetService.mjs +111 -0
- package/build/lib/assetService.mjs.map +1 -0
- package/build/lib/banner.mjs +20 -0
- package/build/lib/banner.mjs.map +1 -0
- package/build/{dependencies.mjs → lib/dependencies.mjs} +4 -64
- package/build/lib/dependencies.mjs.map +1 -0
- package/build/lib/error.mjs +15 -0
- package/build/lib/error.mjs.map +1 -0
- package/build/lib/fs.mjs +19 -0
- package/build/lib/fs.mjs.map +1 -0
- package/build/lib/git.mjs +37 -0
- package/build/lib/git.mjs.map +1 -0
- package/build/lib/localization.mjs +16 -0
- package/build/lib/localization.mjs.map +1 -0
- package/build/lib/log.mjs +9 -0
- package/build/lib/log.mjs.map +1 -0
- package/build/lib/npmPackage.mjs +19 -0
- package/build/lib/npmPackage.mjs.map +1 -0
- package/build/lib/package.mjs +129 -0
- package/build/lib/package.mjs.map +1 -0
- package/build/lib/packageVersion.mjs +174 -0
- package/build/lib/packageVersion.mjs.map +1 -0
- package/build/lib/parseVersion.mjs +54 -0
- package/build/lib/parseVersion.mjs.map +1 -0
- package/build/lib/prompter.mjs +31 -0
- package/build/lib/prompter.mjs.map +1 -0
- package/build/lib/publishedPackage.mjs +66 -0
- package/build/lib/publishedPackage.mjs.map +1 -0
- package/build/{scripts.mjs → lib/scripts.mjs} +1 -2
- package/build/lib/scripts.mjs.map +1 -0
- package/build/lib/stripUtf8Bom.mjs +11 -0
- package/build/lib/stripUtf8Bom.mjs.map +1 -0
- package/build/lib/toposort.mjs +26 -0
- package/build/lib/toposort.mjs.map +1 -0
- package/build/lib/versionFile.mjs +78 -0
- package/build/lib/versionFile.mjs.map +1 -0
- package/build/lib/workspace.mjs +51 -0
- package/build/lib/workspace.mjs.map +1 -0
- package/package.json +2 -2
- package/readme.md +9 -0
- package/build/commands/build.mjs +0 -326
- package/build/commands/build.mjs.map +0 -1
- package/build/commands/generate.ts.mjs.map +0 -1
- package/build/commands/postinstall.ts.mjs.map +0 -1
- package/build/commands/publish.mjs.map +0 -1
- package/build/commands/publishNpm.ts.mjs.map +0 -1
- package/build/dependencies.mjs.map +0 -1
- package/build/scripts.mjs.map +0 -1
- package/build/versionFile.mjs +0 -365
- package/build/versionFile.mjs.map +0 -1
|
@@ -1,288 +1,26 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
import * as path from 'path';
|
|
3
2
|
import * as fs from 'fs';
|
|
4
3
|
import { pipeline } from 'stream/promises';
|
|
5
4
|
import { execSync } from 'child_process';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import '
|
|
15
|
-
import '
|
|
16
|
-
import '
|
|
17
|
-
import '
|
|
18
|
-
import '
|
|
19
|
-
import '
|
|
20
|
-
import '
|
|
21
|
-
import 'y18n';
|
|
22
|
-
import 'write-pkg';
|
|
23
|
-
import 'inquirer';
|
|
24
|
-
import 'simple-git';
|
|
25
|
-
import 'resolve';
|
|
26
|
-
|
|
27
|
-
const PLUGIN_ID = "0feba3a0-b6d1-11e6-9598-0800200c9a66";
|
|
28
|
-
/**
|
|
29
|
-
* Starts an IG.Asset.Server session and returns the sessionId
|
|
30
|
-
*
|
|
31
|
-
* @param {SessionStartParams} params
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
const startSession = async ({
|
|
35
|
-
url,
|
|
36
|
-
authentication,
|
|
37
|
-
...params
|
|
38
|
-
}) => {
|
|
39
|
-
const payload = {
|
|
40
|
-
...params,
|
|
41
|
-
user: undefined,
|
|
42
|
-
password: undefined,
|
|
43
|
-
license: undefined,
|
|
44
|
-
plugin: PLUGIN_ID
|
|
45
|
-
};
|
|
46
|
-
if (authentication.type === "credentials") {
|
|
47
|
-
payload.user = authentication.username;
|
|
48
|
-
payload.password = authentication.password;
|
|
49
|
-
} else if (authentication.type === "license") {
|
|
50
|
-
payload.license = authentication.license;
|
|
51
|
-
}
|
|
52
|
-
const {
|
|
53
|
-
data: {
|
|
54
|
-
session: sessionId,
|
|
55
|
-
state
|
|
56
|
-
}
|
|
57
|
-
} = await axios.post(`Session/Start2`, JSON.stringify(payload), {
|
|
58
|
-
baseURL: url
|
|
59
|
-
});
|
|
60
|
-
if (state !== "SUCCESS") {
|
|
61
|
-
throw new Error(`Could not start session: IG.Asset.Server responded with ${state}`);
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
url,
|
|
65
|
-
sessionId,
|
|
66
|
-
domain: params.domain,
|
|
67
|
-
subDomain: params.subDomain
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
const closeSession = async session => {
|
|
71
|
-
await axios.get(`Session/Close/${session.sessionId}`, {
|
|
72
|
-
baseURL: session.url
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
const uploadPackage = async (session, {
|
|
76
|
-
name,
|
|
77
|
-
version
|
|
78
|
-
}, zipFilePath) => {
|
|
79
|
-
try {
|
|
80
|
-
await uploadPackageToUrl(session.url, `UploadPackage/${session.sessionId}/${name}_${version}`, zipFilePath);
|
|
81
|
-
} catch (err) {
|
|
82
|
-
await uploadPackageToUrl(session.url, `UploadPackage/${session.sessionId}/${name}_${version}/`, zipFilePath);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
const getExistingPackages = async session => axios.get(`Script/GetInformation/${session.sessionId}`, {
|
|
86
|
-
baseURL: session.url,
|
|
87
|
-
validateStatus: status => status === 404 || status === 200
|
|
88
|
-
}).then(({
|
|
89
|
-
data
|
|
90
|
-
}) => Array.isArray(data) ? data : undefined);
|
|
91
|
-
const uploadPackageToUrl = (url, path, zipFilePath) => axios.post(path, fs.createReadStream(zipFilePath), {
|
|
92
|
-
baseURL: url
|
|
93
|
-
}).then(({
|
|
94
|
-
data,
|
|
95
|
-
status
|
|
96
|
-
}) => {
|
|
97
|
-
let objectBody;
|
|
98
|
-
if (typeof data === "string") {
|
|
99
|
-
try {
|
|
100
|
-
objectBody = JSON.parse(data);
|
|
101
|
-
} catch (err) {}
|
|
102
|
-
} else if (typeof data === "object") {
|
|
103
|
-
objectBody = data;
|
|
104
|
-
}
|
|
105
|
-
if (objectBody !== undefined) {
|
|
106
|
-
if ("state" in objectBody && objectBody.state !== "SUCCESS") {
|
|
107
|
-
throw new Error(objectBody.response ?? objectBody.state);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (status >= 400) {
|
|
111
|
-
if (objectBody !== undefined) {
|
|
112
|
-
let text = "";
|
|
113
|
-
for (const key in objectBody) {
|
|
114
|
-
text += key + ": \n";
|
|
115
|
-
if (typeof objectBody[key] === "object") {
|
|
116
|
-
text += JSON.stringify(objectBody[key], undefined, 2);
|
|
117
|
-
} else {
|
|
118
|
-
text += objectBody[key];
|
|
119
|
-
}
|
|
120
|
-
text += "\n\n";
|
|
121
|
-
}
|
|
122
|
-
throw new Error(text);
|
|
123
|
-
}
|
|
124
|
-
throw new Error(data);
|
|
125
|
-
}
|
|
126
|
-
return data;
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
const buildArchiveFromPublishedPackage = (location, manifest, creatorPackage) => {
|
|
130
|
-
const archive = new JSZip();
|
|
131
|
-
archive.file(PACKAGE_FILE, JSON.stringify(creatorPackage, null, 2));
|
|
132
|
-
const index = readPublishedPackageCreatorIndex(location);
|
|
133
|
-
if (index !== undefined) {
|
|
134
|
-
archive.file(INDEX_FILE, JSON.stringify(index, null, 2));
|
|
135
|
-
}
|
|
136
|
-
archive.file(manifest.main, fs.createReadStream(path.join(location.path, manifest.main)));
|
|
137
|
-
return archive;
|
|
138
|
-
};
|
|
139
|
-
let validateSchema;
|
|
140
|
-
const runtimeScripts = ["Interactor", "Core", "Mixed"];
|
|
141
|
-
const notRuntimeScripts = ["Context", "Evaluator"];
|
|
142
|
-
const buildArchiveFromPackage = async (workspaceLocation, packageLocation, data) => {
|
|
143
|
-
const {
|
|
144
|
-
domain,
|
|
145
|
-
subdomain
|
|
146
|
-
} = parseCreatorPackageName(data);
|
|
147
|
-
const logStep = step => logPackageMessage(data.Package, step);
|
|
148
|
-
if (validateSchema === undefined) {
|
|
149
|
-
validateSchema = await axios.get("https://archive.intelligentgraphics.biz/schemas/gfx/animation.json").then(({
|
|
150
|
-
data
|
|
151
|
-
}) => new Ajv({
|
|
152
|
-
coerceTypes: true,
|
|
153
|
-
allErrors: true,
|
|
154
|
-
removeAdditional: true,
|
|
155
|
-
useDefaults: "empty",
|
|
156
|
-
validateSchema: "log"
|
|
157
|
-
}).compile(data));
|
|
158
|
-
}
|
|
159
|
-
const libFilePath = path.join(getWorkspaceOutputPath(workspaceLocation), `${data.Package}.min.js`);
|
|
160
|
-
const scriptDirectories = [packageLocation.path, packageLocation.scriptsDir];
|
|
161
|
-
if (subdomain === "GFX.Standard") {
|
|
162
|
-
logStep(`Including Images folder`);
|
|
163
|
-
scriptDirectories.push(path.join(packageLocation.path, "Images"));
|
|
164
|
-
}
|
|
165
|
-
const manifest = readPackageCreatorManifest(packageLocation);
|
|
166
|
-
if (manifest !== undefined) {
|
|
167
|
-
if (manifest.RunTime && notRuntimeScripts.includes(manifest.Type)) {
|
|
168
|
-
logStep("Setting script RunTime to false because of script type");
|
|
169
|
-
writePackageCreatorManifest(packageLocation, {
|
|
170
|
-
...manifest,
|
|
171
|
-
RunTime: false
|
|
172
|
-
});
|
|
173
|
-
} else if (!manifest.RunTime && runtimeScripts.includes(manifest.Type)) {
|
|
174
|
-
logStep("Setting script RunTime to true because of script type");
|
|
175
|
-
writePackageCreatorManifest(packageLocation, {
|
|
176
|
-
...manifest,
|
|
177
|
-
RunTime: true
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// if (index === undefined) {
|
|
183
|
-
// throw new Error(
|
|
184
|
-
// `Could not find an "${INDEX_FILE}" file in "${primaryScriptDir}"`,
|
|
185
|
-
// );
|
|
186
|
-
// }
|
|
187
|
-
|
|
188
|
-
const animations = new Map();
|
|
189
|
-
for (const scriptFilePath of readPackageAnimationList(packageLocation)) {
|
|
190
|
-
const content = fs.readFileSync(scriptFilePath, {
|
|
191
|
-
encoding: "utf8"
|
|
192
|
-
});
|
|
193
|
-
let data;
|
|
194
|
-
try {
|
|
195
|
-
data = JSON.parse(content);
|
|
196
|
-
} catch (err) {
|
|
197
|
-
const relativePath = path.relative(workspaceLocation.path, scriptFilePath);
|
|
198
|
-
if (err instanceof SyntaxError) {
|
|
199
|
-
throw new Error(`Encountered invalid syntax in file "${relativePath}": ${String(err)}`);
|
|
200
|
-
}
|
|
201
|
-
throw new Error(`Encountered an unexpected error while parsing animation json file at path "${relativePath}"`, {
|
|
202
|
-
cause: err
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
validateSchema(data);
|
|
206
|
-
animations.set(data.Id, JSON.stringify(data));
|
|
207
|
-
}
|
|
208
|
-
let libFile;
|
|
209
|
-
try {
|
|
210
|
-
libFile = fs.readFileSync(libFilePath, {
|
|
211
|
-
encoding: "utf8"
|
|
212
|
-
});
|
|
213
|
-
} catch (err) {
|
|
214
|
-
if (!isErrorENOENT(err)) {
|
|
215
|
-
throw err;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
if (libFile === undefined) {
|
|
219
|
-
if (animations.size === 0) {
|
|
220
|
-
throw new Error(`Could not find a javascript file at "${libFilePath}".
|
|
221
|
-
Packaging without a javascript file is only allowed when animation json files are available`);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
const archive = new JSZip();
|
|
225
|
-
let library = "";
|
|
226
|
-
if (libFile) {
|
|
227
|
-
library = libFile;
|
|
228
|
-
}
|
|
229
|
-
if (!library) {
|
|
230
|
-
const date = new Date(Date.now());
|
|
231
|
-
library = `/* This file is part of the ${domain} Data Packages.
|
|
232
|
-
* Copyright (C) ${date.getFullYear()} intelligentgraphics. All Rights Reserved. */`;
|
|
233
|
-
}
|
|
234
|
-
if (animations.size > 0) {
|
|
235
|
-
const scopeParts = data.Scope.split(".");
|
|
236
|
-
const scope = data.Scope;
|
|
237
|
-
library += createNamespace(scopeParts);
|
|
238
|
-
for (const [name, data] of animations) {
|
|
239
|
-
library += `${scope}.${name} = ` + data + ";";
|
|
240
|
-
logPackageMessage(manifest.Package, `Added animation ${scope}.${name}`);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
const minifyResult = await terser.minify(library, {
|
|
244
|
-
ecma: 5
|
|
245
|
-
});
|
|
246
|
-
archive.file(`${data.Package}.js`, minifyResult.code);
|
|
247
|
-
archive.file(PACKAGE_FILE, JSON.stringify(data, null, 2));
|
|
248
|
-
const creatorIndex = readPackageCreatorIndex(packageLocation);
|
|
249
|
-
if (creatorIndex !== undefined) {
|
|
250
|
-
archive.file(INDEX_FILE, JSON.stringify(creatorIndex, null, 2));
|
|
251
|
-
}
|
|
252
|
-
for (const directory of scriptDirectories) {
|
|
253
|
-
try {
|
|
254
|
-
for (const file of fs.readdirSync(directory)) {
|
|
255
|
-
const {
|
|
256
|
-
ext
|
|
257
|
-
} = path.parse(file);
|
|
258
|
-
switch (ext) {
|
|
259
|
-
case ".png":
|
|
260
|
-
case ".jpeg":
|
|
261
|
-
case ".jpg":
|
|
262
|
-
break;
|
|
263
|
-
default:
|
|
264
|
-
continue;
|
|
265
|
-
}
|
|
266
|
-
archive.file(file, fs.createReadStream(path.join(directory, file)));
|
|
267
|
-
}
|
|
268
|
-
} catch (err) {
|
|
269
|
-
console.error(`Script directory "${directory}" does not exist`);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return archive;
|
|
273
|
-
};
|
|
274
|
-
const createNamespace = parts => {
|
|
275
|
-
let code = `var ${parts[0]};`;
|
|
276
|
-
for (let index = 0; index < parts.length; index++) {
|
|
277
|
-
const path = parts.slice(0, index + 1).join(".");
|
|
278
|
-
code += `\n(${path} = ${path} || {});`;
|
|
279
|
-
}
|
|
280
|
-
return code;
|
|
281
|
-
};
|
|
5
|
+
import { logPackageMessage } from '../../lib/log.mjs';
|
|
6
|
+
import { translate } from '../../lib/localization.mjs';
|
|
7
|
+
import { readPackageCreatorManifest, parseCreatorPackageName, getPackageReleasesDirectory } from '../../lib/package.mjs';
|
|
8
|
+
import { readWorkspaceNpmManifest, getWorkspaceOutputPath } from '../../lib/workspace.mjs';
|
|
9
|
+
import { getVersionInformationFromGit } from '../../lib/git.mjs';
|
|
10
|
+
import { getWorkspaceBannerText } from '../../lib/banner.mjs';
|
|
11
|
+
import { parseVersionFromString, parseVersionFromNumericVersion } from '../../lib/parseVersion.mjs';
|
|
12
|
+
import { getVersionFileHandler } from '../../lib/versionFile.mjs';
|
|
13
|
+
import { uploadPackage, getExistingPackages, startSession, closeSession } from '../../lib/assetService.mjs';
|
|
14
|
+
import { isErrorENOENT } from '../../lib/error.mjs';
|
|
15
|
+
import { determineWorkspaceIGLibraries } from '../../lib/dependencies.mjs';
|
|
16
|
+
import { readPublishedPackageNpmManifest, readPublishedPackageCreatorManifest } from '../../lib/publishedPackage.mjs';
|
|
17
|
+
import { PackageVersion } from '../../lib/packageVersion.mjs';
|
|
18
|
+
import { buildFolders } from '../build/index.mjs';
|
|
19
|
+
import { buildArchiveFromPackage, buildArchiveFromPublishedPackage } from './zip.mjs';
|
|
282
20
|
|
|
283
21
|
const releaseFolder = async options => {
|
|
284
|
-
const workspace =
|
|
285
|
-
const location =
|
|
22
|
+
const workspace = options.workspace;
|
|
23
|
+
const location = options.directory;
|
|
286
24
|
const {
|
|
287
25
|
write: writeVersionFile,
|
|
288
26
|
reset: resetVersionFile
|
|
@@ -350,7 +88,7 @@ const releaseFolder = async options => {
|
|
|
350
88
|
const bannerText = sharedPackageJson !== undefined ? getWorkspaceBannerText(sharedPackageJson) : undefined;
|
|
351
89
|
await buildFolders({
|
|
352
90
|
...options,
|
|
353
|
-
|
|
91
|
+
packages: [location],
|
|
354
92
|
skipPackagesWithoutTsFiles: true,
|
|
355
93
|
banner: options.banner ? {
|
|
356
94
|
text: bannerText,
|
|
@@ -390,9 +128,7 @@ const releaseFolder = async options => {
|
|
|
390
128
|
authentication: options.authentication
|
|
391
129
|
});
|
|
392
130
|
try {
|
|
393
|
-
|
|
394
|
-
logPackageMessage(packageDescription.Package, "Failed to ensure required dependency versions: IG.Asset.Server does not yet support required apis for dependency check");
|
|
395
|
-
}
|
|
131
|
+
await ensureRequiredVersions(workspace, packageDescription, sessionManager, options.prompter);
|
|
396
132
|
logPackageMessage(packageDescription.Package, `Uploading package to ${publishDomain}.${publishSubdomain}`);
|
|
397
133
|
await uploadPackage(sessionManager.getTargetSession(), assetServerPackageDetails, zipFilePath);
|
|
398
134
|
} finally {
|
|
@@ -424,9 +160,6 @@ const ensureRequiredVersions = async (workspaceLocation, creatorPackage, session
|
|
|
424
160
|
}
|
|
425
161
|
const targetSession = sessionManager.getTargetSession();
|
|
426
162
|
const rawUploadedPackages = await getExistingPackages(targetSession);
|
|
427
|
-
if (rawUploadedPackages === undefined) {
|
|
428
|
-
return false;
|
|
429
|
-
}
|
|
430
163
|
const uploadedPackages = rawUploadedPackages.map(entry => {
|
|
431
164
|
let version;
|
|
432
165
|
try {
|
|
@@ -535,7 +268,6 @@ const ensureRequiredVersions = async (workspaceLocation, creatorPackage, session
|
|
|
535
268
|
version: newVersionString
|
|
536
269
|
}, zipFilePath);
|
|
537
270
|
}
|
|
538
|
-
return true;
|
|
539
271
|
};
|
|
540
272
|
const createSessionManager = async params => {
|
|
541
273
|
const targetSession = await startSession(params);
|
|
@@ -564,4 +296,4 @@ const createSessionManager = async params => {
|
|
|
564
296
|
};
|
|
565
297
|
|
|
566
298
|
export { releaseFolder };
|
|
567
|
-
//# sourceMappingURL=
|
|
299
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/commands/publish/index.ts"],"sourcesContent":["import * as path from \"path\";\nimport * as fs from \"fs\";\nimport { pipeline } from \"stream/promises\";\nimport { execSync } from \"child_process\";\n\nimport { logPackageMessage } from \"../../lib/log\";\nimport { translate } from \"../../lib/localization\";\nimport { Authentication } from \"../../lib/authentication\";\nimport {\n\tCreatorPackage,\n\tdetectPackage,\n\tgetPackageReleasesDirectory,\n\tPackageLocation,\n\tparseCreatorPackageName,\n\treadPackageCreatorManifest,\n} from \"../../lib/package\";\nimport {\n\tdetectWorkspace,\n\tgetWorkspaceOutputPath,\n\treadWorkspaceNpmManifest,\n\tWorkspaceLocation,\n} from \"../../lib/workspace\";\nimport { getVersionInformationFromGit } from \"../../lib/git\";\nimport { getWorkspaceBannerText } from \"../../lib/banner\";\nimport {\n\tparseVersionFromNumericVersion,\n\tparseVersionFromString,\n} from \"../../lib/parseVersion\";\nimport { getVersionFileHandler } from \"../../lib/versionFile\";\nimport * as AssetService from \"../../lib/assetService\";\nimport { isErrorENOENT } from \"../../lib/error\";\nimport { determineWorkspaceIGLibraries } from \"../../lib/dependencies\";\nimport {\n\treadPublishedPackageCreatorManifest,\n\treadPublishedPackageNpmManifest,\n} from \"../../lib/publishedPackage\";\nimport { Prompter } from \"../../lib/prompter\";\nimport { PackageVersion } from \"../../lib/packageVersion\";\n\nimport { BuildFoldersOptions, buildFolders } from \"../build\";\nimport {\n\tbuildArchiveFromPackage,\n\tbuildArchiveFromPublishedPackage,\n} from \"./zip\";\n\nexport interface ReleaseFolderOptions\n\textends Omit<\n\t\tBuildFoldersOptions,\n\t\t\"skipPackagesWithoutTsFiles\" | \"banner\" | \"packages\"\n\t> {\n\tdirectory: PackageLocation;\n\tnoUpload: boolean;\n\tnewVersion: string;\n\tdomain?: string;\n\tsubdomain?: string;\n\taddress?: string;\n\tservice: string;\n\tauthentication?: Authentication;\n\tpushOnly: boolean;\n\tbanner?: boolean;\n\tprompter: Prompter;\n}\n\nexport const releaseFolder = async (options: ReleaseFolderOptions) => {\n\tconst workspace = options.workspace;\n\tconst location = options.directory;\n\n\tconst { write: writeVersionFile, reset: resetVersionFile } =\n\t\tgetVersionFileHandler(location);\n\n\tconst packageDescription = readPackageCreatorManifest(location);\n\tconst fullPackageName = packageDescription.Package;\n\tconst { domain, subdomain } = parseCreatorPackageName(packageDescription);\n\n\tconst publishDomain = options.domain ?? domain;\n\tconst publishSubdomain = options.subdomain ?? subdomain;\n\n\tconst sharedPackageJson = readWorkspaceNpmManifest(workspace);\n\n\tlet newVersion: PackageVersion;\n\ttry {\n\t\tnewVersion = parseVersionFromString(options.newVersion);\n\t} catch (err) {\n\t\tthrow new Error(`Please enter a version in this format 1.0.0.100`);\n\t}\n\n\tif (newVersion.buildNumber < 100) {\n\t\tnewVersion.preRelease = {\n\t\t\ttype: \"beta\",\n\t\t\tversion: newVersion.buildNumber,\n\t\t};\n\t} else if (newVersion.buildNumber > 100) {\n\t\tnewVersion.preRelease = {\n\t\t\ttype: \"patch\",\n\t\t\tversion: newVersion.buildNumber - 100,\n\t\t};\n\t}\n\n\tif (sharedPackageJson !== undefined) {\n\t\tlogPackageMessage(\n\t\t\tpackageDescription.Package,\n\t\t\t`Running npm install to make sure all dependencies are up to date`,\n\t\t);\n\t\texecSync(`npm install`, { encoding: \"utf-8\", cwd: workspace.path });\n\t}\n\n\tconst binDir = getWorkspaceOutputPath(workspace);\n\tfs.mkdirSync(binDir, { recursive: true });\n\n\tlet assetServerPackageDetails: AssetService.UploadPackageDetails;\n\n\tlet packageNameWithVersion: string;\n\n\t{\n\t\tconst versionWithoutPrelease = newVersion.clone();\n\t\tversionWithoutPrelease.preRelease = undefined;\n\t\tconst newVersionString = versionWithoutPrelease.toVersionString({\n\t\t\tbuildNumber: true,\n\t\t});\n\t\tpackageNameWithVersion = `${packageDescription.Package}_${newVersionString}`;\n\n\t\tassetServerPackageDetails = {\n\t\t\tname: packageDescription.Package,\n\t\t\tversion: newVersionString,\n\t\t};\n\t}\n\n\tconst zipFilePath = path.join(binDir, packageNameWithVersion + \".zip\");\n\n\ttry {\n\t\tif (options.pushOnly) {\n\t\t\tif (!fs.existsSync(zipFilePath)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Expected a zip file to exist at path ${zipFilePath} since pushOnly is specified`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst gitVersionInformation = await getVersionInformationFromGit(\n\t\t\t\tworkspace,\n\t\t\t\tlocation,\n\t\t\t);\n\n\t\t\twriteVersionFile(fullPackageName, newVersion);\n\n\t\t\tconst bannerText =\n\t\t\t\tsharedPackageJson !== undefined\n\t\t\t\t\t? getWorkspaceBannerText(sharedPackageJson)\n\t\t\t\t\t: undefined;\n\n\t\t\tawait buildFolders({\n\t\t\t\t...options,\n\t\t\t\tpackages: [location],\n\t\t\t\tskipPackagesWithoutTsFiles: true,\n\t\t\t\tbanner: options.banner\n\t\t\t\t\t? {\n\t\t\t\t\t\t\ttext: bannerText,\n\t\t\t\t\t\t\tcommit: gitVersionInformation.commit,\n\t\t\t\t\t\t\tcommitDirty: gitVersionInformation.dirty,\n\t\t\t\t\t\t\tversion: newVersion.toVersionString({\n\t\t\t\t\t\t\t\tbuildNumber: true,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tdate: new Date(Date.now()),\n\t\t\t\t\t\t\t// gitVersionInformation.commitDate\n\t\t\t\t\t\t\t// \t? new Date(gitVersionInformation.commitDate)\n\t\t\t\t\t\t\t// \t: new Date(Date.now()),\n\t\t\t\t\t }\n\t\t\t\t\t: undefined,\n\t\t\t});\n\n\t\t\tnewVersion.preRelease = undefined;\n\n\t\t\ttry {\n\t\t\t\tfs.rmSync(zipFilePath);\n\t\t\t} catch (err) {\n\t\t\t\tif (!isErrorENOENT(err)) {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst archive = await buildArchiveFromPackage(\n\t\t\t\tworkspace,\n\t\t\t\tlocation,\n\t\t\t\tpackageDescription,\n\t\t\t);\n\n\t\t\tconst zipOutputStream = fs.createWriteStream(zipFilePath);\n\t\t\tawait pipeline(archive.generateNodeStream(), zipOutputStream);\n\t\t}\n\n\t\tif (!options.noUpload) {\n\t\t\tif (!options.authentication) {\n\t\t\t\tthrow new Error(`Expected authentication to be available`);\n\t\t\t}\n\n\t\t\tlogPackageMessage(\n\t\t\t\tpackageDescription.Package,\n\t\t\t\t`Opening connection to IG.Asset.Server`,\n\t\t\t);\n\n\t\t\tconst sessionManager = await createSessionManager({\n\t\t\t\turl: options.service,\n\t\t\t\taddress: options.address,\n\t\t\t\tdomain: publishDomain,\n\t\t\t\tsubDomain: publishSubdomain,\n\t\t\t\tauthentication: options.authentication,\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\tawait ensureRequiredVersions(\n\t\t\t\t\tworkspace,\n\t\t\t\t\tpackageDescription,\n\t\t\t\t\tsessionManager,\n\t\t\t\t\toptions.prompter,\n\t\t\t\t);\n\n\t\t\t\tlogPackageMessage(\n\t\t\t\t\tpackageDescription.Package,\n\t\t\t\t\t`Uploading package to ${publishDomain}.${publishSubdomain}`,\n\t\t\t\t);\n\n\t\t\t\tawait AssetService.uploadPackage(\n\t\t\t\t\tsessionManager.getTargetSession(),\n\t\t\t\t\tassetServerPackageDetails,\n\t\t\t\t\tzipFilePath,\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tawait sessionManager.destroy().catch((err) => {\n\t\t\t\t\tlogPackageMessage(\n\t\t\t\t\t\tpackageDescription.Package,\n\t\t\t\t\t\t`Failed to close IG.Asset.Server session(s): ${err}`,\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t} catch (err) {\n\t\tresetVersionFile();\n\t\tthrow err;\n\t}\n\n\tif (newVersion.buildNumber >= 100 && !options.pushOnly) {\n\t\tlogPackageMessage(\n\t\t\tfullPackageName,\n\t\t\ttranslate(\"messages.movingReleaseZip\"),\n\t\t);\n\n\t\tconst zipFileName = `${packageNameWithVersion}.zip`;\n\t\tconst releasesPath = getPackageReleasesDirectory(location);\n\n\t\tfs.mkdirSync(releasesPath, { recursive: true });\n\t\tfs.copyFileSync(zipFilePath, path.join(releasesPath, zipFileName));\n\t}\n};\n\nconst ensureRequiredVersions = async (\n\tworkspaceLocation: WorkspaceLocation,\n\tcreatorPackage: CreatorPackage,\n\tsessionManager: SessionManager,\n\tprompter: Prompter,\n) => {\n\tinterface UploadedPackage\n\t\textends Omit<AssetService.ExistingPackage, \"version\"> {\n\t\tversion: PackageVersion;\n\t}\n\n\tconst libraries = determineWorkspaceIGLibraries(workspaceLocation);\n\n\t// If there are no libraries, we don't need to check for required versions\n\tif (libraries.length === 0) {\n\t\treturn true;\n\t}\n\n\tconst targetSession = sessionManager.getTargetSession();\n\n\tconst rawUploadedPackages = await AssetService.getExistingPackages(\n\t\ttargetSession,\n\t);\n\n\tconst uploadedPackages = rawUploadedPackages.map(\n\t\t(entry): UploadedPackage => {\n\t\t\tlet version: PackageVersion;\n\n\t\t\ttry {\n\t\t\t\tversion = parseVersionFromNumericVersion(entry.numericVersion);\n\t\t\t} catch (err) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Encountered invalid format for version ${entry.numericVersion}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (version.buildNumber < 100) {\n\t\t\t\tversion.preRelease = {\n\t\t\t\t\ttype: \"beta\",\n\t\t\t\t\tversion: version.buildNumber,\n\t\t\t\t};\n\t\t\t} else if (version.buildNumber > 100) {\n\t\t\t\tversion.preRelease = {\n\t\t\t\t\ttype: \"patch\",\n\t\t\t\t\tversion: version.buildNumber - 100,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...entry,\n\t\t\t\tversion,\n\t\t\t};\n\t\t},\n\t);\n\n\tfor (const libraryLocation of libraries) {\n\t\tconst libraryManifest =\n\t\t\treadPublishedPackageNpmManifest(libraryLocation);\n\t\tconst libraryCreatorPackage =\n\t\t\treadPublishedPackageCreatorManifest(libraryLocation);\n\n\t\tif (\n\t\t\tlibraryCreatorPackage === undefined ||\n\t\t\tlibraryManifest.main === undefined ||\n\t\t\tlibraryCreatorPackage.Package === creatorPackage.Package\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst libraryVersion = PackageVersion.extractFromLine(\n\t\t\tlibraryManifest.version,\n\t\t);\n\n\t\tif (libraryVersion.preRelease) {\n\t\t\tlibraryVersion.buildNumber = libraryVersion.preRelease.version;\n\t\t\tlibraryVersion.preRelease = undefined;\n\t\t} else {\n\t\t\tlibraryVersion.buildNumber = 100;\n\t\t}\n\n\t\tlet uploadedPackageInBasics: UploadedPackage | undefined;\n\t\tlet uploadedPackageInTarget: UploadedPackage | undefined;\n\n\t\tfor (const uploadedPackage of uploadedPackages) {\n\t\t\tif (uploadedPackage.scope === libraryCreatorPackage.Package) {\n\t\t\t\tif (uploadedPackage.support) {\n\t\t\t\t\tuploadedPackageInBasics = uploadedPackage;\n\t\t\t\t} else {\n\t\t\t\t\tuploadedPackageInTarget = uploadedPackage;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst validInBasics =\n\t\t\tuploadedPackageInBasics !== undefined &&\n\t\t\t!uploadedPackageInBasics.version.isLesserThan(libraryVersion);\n\t\tconst validInTarget =\n\t\t\tuploadedPackageInTarget !== undefined &&\n\t\t\t!uploadedPackageInTarget.version.isLesserThan(libraryVersion);\n\n\t\tif (validInBasics || validInTarget) {\n\t\t\tif (\n\t\t\t\ttargetSession.subDomain !== \"Basics\" &&\n\t\t\t\t(uploadedPackageInBasics !== undefined ||\n\t\t\t\t\tuploadedPackageInTarget !== undefined)\n\t\t\t) {\n\t\t\t\tlogPackageMessage(\n\t\t\t\t\tcreatorPackage.Package,\n\t\t\t\t\t`Package ${libraryCreatorPackage.Package} is uploaded both for Basics and ${targetSession.subDomain}. The package within ${targetSession.subDomain} will be used.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tlogPackageMessage(\n\t\t\tcreatorPackage.Package,\n\t\t\t`Requested at least version ${libraryVersion.toVersionString({\n\t\t\t\tbuildNumber: true,\n\t\t\t})} for package ${libraryCreatorPackage.Package}`,\n\t\t);\n\n\t\tif (targetSession.subDomain !== \"Basics\" && uploadedPackageInTarget) {\n\t\t\tconst version = uploadedPackageInTarget.version.toVersionString({\n\t\t\t\tbuildNumber: true,\n\t\t\t});\n\n\t\t\tlogPackageMessage(\n\t\t\t\tcreatorPackage.Package,\n\t\t\t\t`Found invalid version ${version} for package ${libraryCreatorPackage.Package} in ${targetSession.subDomain}`,\n\t\t\t);\n\t\t}\n\t\tif (uploadedPackageInBasics) {\n\t\t\tconst version = uploadedPackageInBasics.version.toVersionString({\n\t\t\t\tbuildNumber: true,\n\t\t\t});\n\n\t\t\tlet message = `Found invalid version ${version} for package ${libraryCreatorPackage.Package} in Basics`;\n\n\t\t\tif (\n\t\t\t\ttargetSession.subDomain !== \"Basics\" &&\n\t\t\t\tuploadedPackageInTarget\n\t\t\t) {\n\t\t\t\tmessage += `. This version will not be used since the package also exists in ${targetSession.subDomain}`;\n\t\t\t}\n\n\t\t\tlogPackageMessage(creatorPackage.Package, message);\n\t\t}\n\n\t\tconst possibleTargets: string[] = [\"Basics\"];\n\n\t\tif (targetSession.subDomain !== \"Basics\") {\n\t\t\tpossibleTargets.push(targetSession.subDomain);\n\t\t}\n\n\t\tconst uploadTargetScope = await prompter.ask({\n\t\t\tmessage: `Select the scope to upload the required version of ${libraryCreatorPackage.Package} to or select \"skip\" to skip the upload.`,\n\t\t\toptions: [...possibleTargets, \"Skip\"],\n\t\t\tdefault: possibleTargets[0],\n\t\t});\n\n\t\tif (uploadTargetScope === \"Skip\") {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst archive = buildArchiveFromPublishedPackage(\n\t\t\tlibraryLocation,\n\t\t\tlibraryManifest,\n\t\t\tlibraryCreatorPackage,\n\t\t);\n\n\t\tconst newVersionString = libraryVersion.toVersionString({\n\t\t\tbuildNumber: true,\n\t\t});\n\t\tconst packageNameWithVersion = `${libraryCreatorPackage.Package}_${newVersionString}`;\n\n\t\tconst zipFilePath = path.join(\n\t\t\tgetWorkspaceOutputPath(workspaceLocation),\n\t\t\t`${packageNameWithVersion}.zip`,\n\t\t);\n\n\t\ttry {\n\t\t\tfs.rmSync(zipFilePath);\n\t\t} catch (err) {\n\t\t\tif (!isErrorENOENT(err)) {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\n\t\tconst zipOutputStream = fs.createWriteStream(zipFilePath);\n\t\tawait pipeline(archive.generateNodeStream(), zipOutputStream);\n\n\t\tconst session =\n\t\t\tuploadTargetScope === \"Basics\"\n\t\t\t\t? await sessionManager.getBasicsSession()\n\t\t\t\t: targetSession;\n\n\t\tlogPackageMessage(\n\t\t\tcreatorPackage.Package,\n\t\t\t`Uploading package ${libraryCreatorPackage.Package} with version ${newVersionString} to ${session.domain}.${session.subDomain}`,\n\t\t);\n\n\t\tawait AssetService.uploadPackage(\n\t\t\tsession,\n\t\t\t{\n\t\t\t\tname: libraryCreatorPackage.Package,\n\t\t\t\tversion: newVersionString,\n\t\t\t},\n\t\t\tzipFilePath,\n\t\t);\n\t}\n};\n\ninterface SessionManager {\n\tgetBasicsSession: () => Promise<AssetService.Session>;\n\tgetTargetSession: () => AssetService.Session;\n\tdestroy: () => Promise<void>;\n}\n\nconst createSessionManager = async (\n\tparams: AssetService.SessionStartParams,\n): Promise<SessionManager> => {\n\tconst targetSession = await AssetService.startSession(params);\n\tlet basicsSession: AssetService.Session | undefined;\n\n\treturn {\n\t\tgetBasicsSession: async () => {\n\t\t\tif (targetSession.subDomain === \"Basics\") {\n\t\t\t\treturn targetSession;\n\t\t\t}\n\n\t\t\tif (basicsSession === undefined) {\n\t\t\t\tbasicsSession = await AssetService.startSession({\n\t\t\t\t\t...params,\n\t\t\t\t\tsubDomain: \"Basics\",\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn basicsSession;\n\t\t},\n\n\t\tgetTargetSession: () => targetSession,\n\n\t\tdestroy: async () => {\n\t\t\tawait AssetService.closeSession(targetSession);\n\n\t\t\tif (basicsSession !== undefined) {\n\t\t\t\tawait AssetService.closeSession(basicsSession);\n\t\t\t}\n\t\t},\n\t};\n};\n"],"names":["releaseFolder","options","workspace","location","directory","write","writeVersionFile","reset","resetVersionFile","getVersionFileHandler","packageDescription","readPackageCreatorManifest","fullPackageName","Package","domain","subdomain","parseCreatorPackageName","publishDomain","publishSubdomain","sharedPackageJson","readWorkspaceNpmManifest","newVersion","parseVersionFromString","err","Error","buildNumber","preRelease","type","version","undefined","logPackageMessage","execSync","encoding","cwd","path","binDir","getWorkspaceOutputPath","fs","mkdirSync","recursive","assetServerPackageDetails","packageNameWithVersion","versionWithoutPrelease","clone","newVersionString","toVersionString","name","zipFilePath","join","pushOnly","existsSync","gitVersionInformation","getVersionInformationFromGit","bannerText","getWorkspaceBannerText","buildFolders","packages","skipPackagesWithoutTsFiles","banner","text","commit","commitDirty","dirty","date","Date","now","rmSync","isErrorENOENT","archive","buildArchiveFromPackage","zipOutputStream","createWriteStream","pipeline","generateNodeStream","noUpload","authentication","sessionManager","createSessionManager","url","service","address","subDomain","ensureRequiredVersions","prompter","AssetService","getTargetSession","destroy","catch","translate","zipFileName","releasesPath","getPackageReleasesDirectory","copyFileSync","workspaceLocation","creatorPackage","libraries","determineWorkspaceIGLibraries","length","targetSession","rawUploadedPackages","uploadedPackages","map","entry","parseVersionFromNumericVersion","numericVersion","libraryLocation","libraryManifest","readPublishedPackageNpmManifest","libraryCreatorPackage","readPublishedPackageCreatorManifest","main","libraryVersion","PackageVersion","extractFromLine","uploadedPackageInBasics","uploadedPackageInTarget","uploadedPackage","scope","support","validInBasics","isLesserThan","validInTarget","message","possibleTargets","push","uploadTargetScope","ask","default","buildArchiveFromPublishedPackage","session","getBasicsSession","params","basicsSession"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+DaA,MAAAA,aAAa,GAAG,MAAOC,OAA6B,IAAK;AACrE,EAAA,MAAMC,SAAS,GAAGD,OAAO,CAACC,SAAS,CAAA;AACnC,EAAA,MAAMC,QAAQ,GAAGF,OAAO,CAACG,SAAS,CAAA;EAElC,MAAM;AAAEC,IAAAA,KAAK,EAAEC,gBAAgB;AAAEC,IAAAA,KAAK,EAAEC,gBAAAA;AAAiB,GAAC,GACzDC,qBAAqB,CAACN,QAAQ,CAAC,CAAA;AAEhC,EAAA,MAAMO,kBAAkB,GAAGC,0BAA0B,CAACR,QAAQ,CAAC,CAAA;AAC/D,EAAA,MAAMS,eAAe,GAAGF,kBAAkB,CAACG,OAAO,CAAA;EAClD,MAAM;IAAEC,MAAM;AAAEC,IAAAA,SAAAA;AAAU,GAAC,GAAGC,uBAAuB,CAACN,kBAAkB,CAAC,CAAA;AAEzE,EAAA,MAAMO,aAAa,GAAGhB,OAAO,CAACa,MAAM,IAAIA,MAAM,CAAA;AAC9C,EAAA,MAAMI,gBAAgB,GAAGjB,OAAO,CAACc,SAAS,IAAIA,SAAS,CAAA;AAEvD,EAAA,MAAMI,iBAAiB,GAAGC,wBAAwB,CAAClB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X,CAAA;AACF,GAAA;AACD,CAAC,CAAA;AAQD,MAAM8B,oBAAoB,GAAG,MAC5BsD,MAAuC,IACV;EAC7B,MAAMjC,aAAa,GAAG,MAAMd,YAAyB,CAAC+C,MAAM,CAAC,CAAA;AAC7D,EAAA,IAAIC,aAA+C,CAAA;EAEnD,OAAO;AACNF,IAAAA,gBAAgB,EAAE,YAAY;AAC7B,MAAA,IAAIhC,aAAa,CAACjB,SAAS,KAAK,QAAQ,EAAE;AACzC,QAAA,OAAOiB,aAAa,CAAA;AACrB,OAAA;MAEA,IAAIkC,aAAa,KAAKvG,SAAS,EAAE;AAChCuG,QAAAA,aAAa,GAAG,MAAMhD,YAAyB,CAAC;AAC/C,UAAA,GAAG+C,MAAM;AACTlD,UAAAA,SAAS,EAAE,QAAA;AACZ,SAAC,CAAC,CAAA;AACH,OAAA;AAEA,MAAA,OAAOmD,aAAa,CAAA;KACpB;IAED/C,gBAAgB,EAAE,MAAMa,aAAa;AAErCZ,IAAAA,OAAO,EAAE,YAAY;AACpB,MAAA,MAAMF,YAAyB,CAACc,aAAa,CAAC,CAAA;MAE9C,IAAIkC,aAAa,KAAKvG,SAAS,EAAE;AAChC,QAAA,MAAMuD,YAAyB,CAACgD,aAAa,CAAC,CAAA;AAC/C,OAAA;AACD,KAAA;GACA,CAAA;AACF,CAAC;;;;"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import JSZip from 'jszip';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as terser from 'terser';
|
|
7
|
+
import { isErrorENOENT } from '../../lib/error.mjs';
|
|
8
|
+
import { logPackageMessage } from '../../lib/log.mjs';
|
|
9
|
+
import { PACKAGE_FILE, INDEX_FILE, parseCreatorPackageName, readPackageCreatorManifest, writePackageCreatorManifest, readPackageAnimationList, readPackageCreatorIndex } from '../../lib/package.mjs';
|
|
10
|
+
import { getWorkspaceOutputPath } from '../../lib/workspace.mjs';
|
|
11
|
+
import { readPublishedPackageCreatorIndex } from '../../lib/publishedPackage.mjs';
|
|
12
|
+
|
|
13
|
+
const buildArchiveFromPublishedPackage = (location, manifest, creatorPackage) => {
|
|
14
|
+
const archive = new JSZip();
|
|
15
|
+
archive.file(PACKAGE_FILE, JSON.stringify(creatorPackage, null, 2));
|
|
16
|
+
const index = readPublishedPackageCreatorIndex(location);
|
|
17
|
+
if (index !== undefined) {
|
|
18
|
+
archive.file(INDEX_FILE, JSON.stringify(index, null, 2));
|
|
19
|
+
}
|
|
20
|
+
archive.file(manifest.main, fs.createReadStream(path.join(location.path, manifest.main)));
|
|
21
|
+
return archive;
|
|
22
|
+
};
|
|
23
|
+
let validateSchema;
|
|
24
|
+
const runtimeScripts = ["Interactor", "Core", "Mixed"];
|
|
25
|
+
const notRuntimeScripts = ["Context", "Evaluator"];
|
|
26
|
+
const buildArchiveFromPackage = async (workspaceLocation, packageLocation, data) => {
|
|
27
|
+
const {
|
|
28
|
+
domain,
|
|
29
|
+
subdomain
|
|
30
|
+
} = parseCreatorPackageName(data);
|
|
31
|
+
const logStep = step => logPackageMessage(data.Package, step);
|
|
32
|
+
if (validateSchema === undefined) {
|
|
33
|
+
validateSchema = await axios.get("https://archive.intelligentgraphics.biz/schemas/gfx/animation.json").then(({
|
|
34
|
+
data
|
|
35
|
+
}) => new Ajv({
|
|
36
|
+
coerceTypes: true,
|
|
37
|
+
allErrors: true,
|
|
38
|
+
removeAdditional: true,
|
|
39
|
+
useDefaults: "empty",
|
|
40
|
+
validateSchema: "log"
|
|
41
|
+
}).compile(data));
|
|
42
|
+
}
|
|
43
|
+
const libFilePath = path.join(getWorkspaceOutputPath(workspaceLocation), `${data.Package}.min.js`);
|
|
44
|
+
const scriptDirectories = [packageLocation.path, packageLocation.scriptsDir];
|
|
45
|
+
if (subdomain === "GFX.Standard") {
|
|
46
|
+
logStep(`Including Images folder`);
|
|
47
|
+
scriptDirectories.push(path.join(packageLocation.path, "Images"));
|
|
48
|
+
}
|
|
49
|
+
const manifest = readPackageCreatorManifest(packageLocation);
|
|
50
|
+
if (manifest !== undefined) {
|
|
51
|
+
if (manifest.RunTime && notRuntimeScripts.includes(manifest.Type)) {
|
|
52
|
+
logStep("Setting script RunTime to false because of script type");
|
|
53
|
+
writePackageCreatorManifest(packageLocation, {
|
|
54
|
+
...manifest,
|
|
55
|
+
RunTime: false
|
|
56
|
+
});
|
|
57
|
+
} else if (!manifest.RunTime && runtimeScripts.includes(manifest.Type)) {
|
|
58
|
+
logStep("Setting script RunTime to true because of script type");
|
|
59
|
+
writePackageCreatorManifest(packageLocation, {
|
|
60
|
+
...manifest,
|
|
61
|
+
RunTime: true
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// if (index === undefined) {
|
|
67
|
+
// throw new Error(
|
|
68
|
+
// `Could not find an "${INDEX_FILE}" file in "${primaryScriptDir}"`,
|
|
69
|
+
// );
|
|
70
|
+
// }
|
|
71
|
+
|
|
72
|
+
const animations = new Map();
|
|
73
|
+
for (const scriptFilePath of readPackageAnimationList(packageLocation)) {
|
|
74
|
+
const content = fs.readFileSync(scriptFilePath, {
|
|
75
|
+
encoding: "utf8"
|
|
76
|
+
});
|
|
77
|
+
let data;
|
|
78
|
+
try {
|
|
79
|
+
data = JSON.parse(content);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
const relativePath = path.relative(workspaceLocation.path, scriptFilePath);
|
|
82
|
+
if (err instanceof SyntaxError) {
|
|
83
|
+
throw new Error(`Encountered invalid syntax in file "${relativePath}": ${String(err)}`);
|
|
84
|
+
}
|
|
85
|
+
throw new Error(`Encountered an unexpected error while parsing animation json file at path "${relativePath}"`, {
|
|
86
|
+
cause: err
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
validateSchema(data);
|
|
90
|
+
animations.set(data.Id, JSON.stringify(data));
|
|
91
|
+
}
|
|
92
|
+
let libFile;
|
|
93
|
+
try {
|
|
94
|
+
libFile = fs.readFileSync(libFilePath, {
|
|
95
|
+
encoding: "utf8"
|
|
96
|
+
});
|
|
97
|
+
} catch (err) {
|
|
98
|
+
if (!isErrorENOENT(err)) {
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (libFile === undefined) {
|
|
103
|
+
if (animations.size === 0) {
|
|
104
|
+
throw new Error(`Could not find a javascript file at "${libFilePath}".
|
|
105
|
+
Packaging without a javascript file is only allowed when animation json files are available`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const archive = new JSZip();
|
|
109
|
+
let library = "";
|
|
110
|
+
if (libFile) {
|
|
111
|
+
library = libFile;
|
|
112
|
+
}
|
|
113
|
+
if (!library) {
|
|
114
|
+
const date = new Date(Date.now());
|
|
115
|
+
library = `/* This file is part of the ${domain} Data Packages.
|
|
116
|
+
* Copyright (C) ${date.getFullYear()} intelligentgraphics. All Rights Reserved. */`;
|
|
117
|
+
}
|
|
118
|
+
if (animations.size > 0) {
|
|
119
|
+
const scopeParts = data.Scope.split(".");
|
|
120
|
+
const scope = data.Scope;
|
|
121
|
+
library += createNamespace(scopeParts);
|
|
122
|
+
for (const [name, data] of animations) {
|
|
123
|
+
library += `${scope}.${name} = ` + data + ";";
|
|
124
|
+
logPackageMessage(manifest.Package, `Added animation ${scope}.${name}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const minifyResult = await terser.minify(library, {
|
|
128
|
+
ecma: 5
|
|
129
|
+
});
|
|
130
|
+
archive.file(`${data.Package}.js`, minifyResult.code);
|
|
131
|
+
archive.file(PACKAGE_FILE, JSON.stringify(data, null, 2));
|
|
132
|
+
const creatorIndex = readPackageCreatorIndex(packageLocation);
|
|
133
|
+
if (creatorIndex !== undefined) {
|
|
134
|
+
archive.file(INDEX_FILE, JSON.stringify(creatorIndex, null, 2));
|
|
135
|
+
}
|
|
136
|
+
for (const directory of scriptDirectories) {
|
|
137
|
+
try {
|
|
138
|
+
for (const file of fs.readdirSync(directory)) {
|
|
139
|
+
const {
|
|
140
|
+
ext
|
|
141
|
+
} = path.parse(file);
|
|
142
|
+
switch (ext) {
|
|
143
|
+
case ".png":
|
|
144
|
+
case ".jpeg":
|
|
145
|
+
case ".jpg":
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
archive.file(file, fs.createReadStream(path.join(directory, file)));
|
|
151
|
+
}
|
|
152
|
+
} catch (err) {
|
|
153
|
+
console.error(`Script directory "${directory}" does not exist`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return archive;
|
|
157
|
+
};
|
|
158
|
+
const createNamespace = parts => {
|
|
159
|
+
let code = `var ${parts[0]};`;
|
|
160
|
+
for (let index = 0; index < parts.length; index++) {
|
|
161
|
+
const path = parts.slice(0, index + 1).join(".");
|
|
162
|
+
code += `\n(${path} = ${path} || {});`;
|
|
163
|
+
}
|
|
164
|
+
return code;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export { buildArchiveFromPackage, buildArchiveFromPublishedPackage };
|
|
168
|
+
//# sourceMappingURL=zip.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.mjs","sources":["../../../src/commands/publish/zip.ts"],"sourcesContent":["import Ajv, { ValidateFunction } from \"ajv\";\nimport axios from \"axios\";\nimport JSZip from \"jszip\";\nimport * as path from \"path\";\nimport * as fs from \"fs\";\nimport * as terser from \"terser\";\n\nimport { isErrorENOENT } from \"../../lib/error\";\nimport { logPackageMessage } from \"../../lib/log\";\nimport {\n\tCreatorPackage,\n\treadPackageCreatorManifest,\n\twritePackageCreatorManifest,\n\treadPackageAnimationList,\n\treadPackageCreatorIndex,\n\tparseCreatorPackageName,\n\tPackageLocation,\n\tPackageNpmManifest,\n\tINDEX_FILE,\n\tPACKAGE_FILE,\n} from \"../../lib/package\";\nimport { getWorkspaceOutputPath, WorkspaceLocation } from \"../../lib/workspace\";\nimport {\n\tPublishedPackageLocation,\n\treadPublishedPackageCreatorIndex,\n} from \"../../lib/publishedPackage\";\n\nexport const buildArchiveFromPublishedPackage = (\n\tlocation: PublishedPackageLocation,\n\tmanifest: PackageNpmManifest,\n\tcreatorPackage: CreatorPackage,\n) => {\n\tconst archive = new JSZip();\n\n\tarchive.file(PACKAGE_FILE, JSON.stringify(creatorPackage, null, 2));\n\n\tconst index = readPublishedPackageCreatorIndex(location);\n\n\tif (index !== undefined) {\n\t\tarchive.file(INDEX_FILE, JSON.stringify(index, null, 2));\n\t}\n\n\tarchive.file(\n\t\tmanifest.main,\n\t\tfs.createReadStream(path.join(location.path, manifest.main)),\n\t);\n\n\treturn archive;\n};\n\nlet validateSchema: ValidateFunction | undefined;\n\nconst runtimeScripts: CreatorPackage[\"Type\"][] = [\n\t\"Interactor\",\n\t\"Core\",\n\t\"Mixed\",\n];\n\nconst notRuntimeScripts: CreatorPackage[\"Type\"][] = [\"Context\", \"Evaluator\"];\n\nexport const buildArchiveFromPackage = async (\n\tworkspaceLocation: WorkspaceLocation,\n\tpackageLocation: PackageLocation,\n\tdata: CreatorPackage,\n) => {\n\tconst { domain, subdomain } = parseCreatorPackageName(data);\n\n\tconst logStep = (step: string) => logPackageMessage(data.Package, step);\n\n\tif (validateSchema === undefined) {\n\t\tvalidateSchema = await axios\n\t\t\t.get(\n\t\t\t\t\"https://archive.intelligentgraphics.biz/schemas/gfx/animation.json\",\n\t\t\t)\n\t\t\t.then(({ data }) =>\n\t\t\t\tnew Ajv({\n\t\t\t\t\tcoerceTypes: true,\n\t\t\t\t\tallErrors: true,\n\t\t\t\t\tremoveAdditional: true,\n\t\t\t\t\tuseDefaults: \"empty\",\n\t\t\t\t\tvalidateSchema: \"log\",\n\t\t\t\t}).compile(data),\n\t\t\t);\n\t}\n\n\tconst libFilePath = path.join(\n\t\tgetWorkspaceOutputPath(workspaceLocation),\n\t\t`${data.Package}.min.js`,\n\t);\n\n\tconst scriptDirectories: string[] = [\n\t\tpackageLocation.path,\n\t\tpackageLocation.scriptsDir,\n\t];\n\n\tif (subdomain === \"GFX.Standard\") {\n\t\tlogStep(`Including Images folder`);\n\t\tscriptDirectories.push(path.join(packageLocation.path, \"Images\"));\n\t}\n\n\tconst manifest = readPackageCreatorManifest(packageLocation);\n\n\tif (manifest !== undefined) {\n\t\tif (manifest.RunTime && notRuntimeScripts.includes(manifest.Type)) {\n\t\t\tlogStep(\"Setting script RunTime to false because of script type\");\n\t\t\twritePackageCreatorManifest(packageLocation, {\n\t\t\t\t...manifest,\n\t\t\t\tRunTime: false,\n\t\t\t});\n\t\t} else if (\n\t\t\t!manifest.RunTime &&\n\t\t\truntimeScripts.includes(manifest.Type)\n\t\t) {\n\t\t\tlogStep(\"Setting script RunTime to true because of script type\");\n\t\t\twritePackageCreatorManifest(packageLocation, {\n\t\t\t\t...manifest,\n\t\t\t\tRunTime: true,\n\t\t\t});\n\t\t}\n\t}\n\n\t// if (index === undefined) {\n\t// \tthrow new Error(\n\t// \t\t`Could not find an \"${INDEX_FILE}\" file in \"${primaryScriptDir}\"`,\n\t// \t);\n\t// }\n\n\tconst animations = new Map<string, string>();\n\n\tfor (const scriptFilePath of readPackageAnimationList(packageLocation)) {\n\t\tconst content = fs.readFileSync(scriptFilePath, { encoding: \"utf8\" })!;\n\n\t\tlet data: { Id: string };\n\n\t\ttry {\n\t\t\tdata = JSON.parse(content);\n\t\t} catch (err) {\n\t\t\tconst relativePath = path.relative(\n\t\t\t\tworkspaceLocation.path,\n\t\t\t\tscriptFilePath,\n\t\t\t);\n\n\t\t\tif (err instanceof SyntaxError) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Encountered invalid syntax in file \"${relativePath}\": ${String(\n\t\t\t\t\t\terr,\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new Error(\n\t\t\t\t`Encountered an unexpected error while parsing animation json file at path \"${relativePath}\"`,\n\t\t\t\t{\n\t\t\t\t\tcause: err,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tvalidateSchema!(data);\n\n\t\tanimations.set(data.Id, JSON.stringify(data));\n\t}\n\n\tlet libFile: string | undefined;\n\n\ttry {\n\t\tlibFile = fs.readFileSync(libFilePath, { encoding: \"utf8\" });\n\t} catch (err) {\n\t\tif (!isErrorENOENT(err)) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tif (libFile === undefined) {\n\t\tif (animations.size === 0) {\n\t\t\tthrow new Error(`Could not find a javascript file at \"${libFilePath}\".\nPackaging without a javascript file is only allowed when animation json files are available`);\n\t\t}\n\t}\n\n\tconst archive = new JSZip();\n\n\tlet library: string = \"\";\n\n\tif (libFile) {\n\t\tlibrary = libFile;\n\t}\n\n\tif (!library) {\n\t\tconst date = new Date(Date.now());\n\t\tlibrary = `/* This file is part of the ${domain} Data Packages.\n\t\t* Copyright (C) ${date.getFullYear()} intelligentgraphics. All Rights Reserved. */`;\n\t}\n\n\tif (animations.size > 0) {\n\t\tconst scopeParts = data.Scope.split(\".\");\n\t\tconst scope = data.Scope;\n\n\t\tlibrary += createNamespace(scopeParts);\n\n\t\tfor (const [name, data] of animations) {\n\t\t\tlibrary += `${scope}.${name} = ` + data + \";\";\n\t\t\tlogPackageMessage(\n\t\t\t\tmanifest.Package,\n\t\t\t\t`Added animation ${scope}.${name}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst minifyResult = await terser.minify(library, { ecma: 5 });\n\n\tarchive.file(`${data.Package}.js`, minifyResult.code!);\n\tarchive.file(PACKAGE_FILE, JSON.stringify(data, null, 2));\n\n\tconst creatorIndex = readPackageCreatorIndex(packageLocation);\n\n\tif (creatorIndex !== undefined) {\n\t\tarchive.file(INDEX_FILE, JSON.stringify(creatorIndex, null, 2));\n\t}\n\n\tfor (const directory of scriptDirectories) {\n\t\ttry {\n\t\t\tfor (const file of fs.readdirSync(directory)) {\n\t\t\t\tconst { ext } = path.parse(file);\n\n\t\t\t\tswitch (ext) {\n\t\t\t\t\tcase \".png\":\n\t\t\t\t\tcase \".jpeg\":\n\t\t\t\t\tcase \".jpg\":\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tarchive.file(\n\t\t\t\t\tfile,\n\t\t\t\t\tfs.createReadStream(path.join(directory, file)),\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconsole.error(`Script directory \"${directory}\" does not exist`);\n\t\t}\n\t}\n\n\treturn archive;\n};\n\nconst createNamespace = (parts: string[]) => {\n\tlet code = `var ${parts[0]};`;\n\n\tfor (let index = 0; index < parts.length; index++) {\n\t\tconst path = parts.slice(0, index + 1).join(\".\");\n\n\t\tcode += `\\n(${path} = ${path} || {});`;\n\t}\n\n\treturn code;\n};\n"],"names":["buildArchiveFromPublishedPackage","location","manifest","creatorPackage","archive","JSZip","file","PACKAGE_FILE","JSON","stringify","index","readPublishedPackageCreatorIndex","undefined","INDEX_FILE","main","fs","createReadStream","path","join","validateSchema","runtimeScripts","notRuntimeScripts","buildArchiveFromPackage","workspaceLocation","packageLocation","data","domain","subdomain","parseCreatorPackageName","logStep","step","logPackageMessage","Package","axios","get","then","Ajv","coerceTypes","allErrors","removeAdditional","useDefaults","compile","libFilePath","getWorkspaceOutputPath","scriptDirectories","scriptsDir","push","readPackageCreatorManifest","RunTime","includes","Type","writePackageCreatorManifest","animations","Map","scriptFilePath","readPackageAnimationList","content","readFileSync","encoding","parse","err","relativePath","relative","SyntaxError","Error","String","cause","set","Id","libFile","isErrorENOENT","size","library","date","Date","now","getFullYear","scopeParts","Scope","split","scope","createNamespace","name","minifyResult","terser","minify","ecma","code","creatorIndex","readPackageCreatorIndex","directory","readdirSync","ext","console","error","parts","length","slice"],"mappings":";;;;;;;;;;;;AA2BO,MAAMA,gCAAgC,GAAG,CAC/CC,QAAkC,EAClCC,QAA4B,EAC5BC,cAA8B,KAC1B;AACJ,EAAA,MAAMC,OA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