@milaboratories/pl-deployments 1.1.6 → 1.1.7
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/dist/common/pl_binary.d.ts +2 -0
- package/dist/common/pl_binary.d.ts.map +1 -1
- package/dist/common/pl_binary_download.d.ts +2 -4
- package/dist/common/pl_binary_download.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +141 -138
- package/dist/index.mjs.map +1 -1
- package/dist/local/pl.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/common/pl_binary.ts +11 -2
- package/src/common/pl_binary_download.ts +26 -55
- package/src/local/pl.ts +3 -1
- package/src/ssh/__tests__/pl-docker.test.ts +5 -5
|
@@ -11,13 +11,19 @@ import decompress from 'decompress';
|
|
|
11
11
|
import type { ArchType, OSType } from './os_and_arch';
|
|
12
12
|
import { newOs, newArch } from './os_and_arch';
|
|
13
13
|
|
|
14
|
+
const cdn = 'https://cdn.platforma.bio/software';
|
|
15
|
+
// We'll download things from Global Access if downloading from CDN has failed
|
|
16
|
+
// (it might be that it's blocked from the company's network.)
|
|
17
|
+
const gaCdn = 'https://cdn-ga.pl-open.science/software';
|
|
18
|
+
|
|
14
19
|
export type DownloadBinaryResult = {
|
|
15
20
|
archiveUrl: string;
|
|
21
|
+
alternativeArchiveGAUrl: string;
|
|
22
|
+
wasDownloadedFrom?: string;
|
|
16
23
|
archivePath: string;
|
|
17
24
|
archiveType: ArchiveType;
|
|
18
25
|
targetFolder: string;
|
|
19
26
|
baseName: string;
|
|
20
|
-
binaryPath?: string;
|
|
21
27
|
};
|
|
22
28
|
|
|
23
29
|
export async function downloadBinaryNoExtract(
|
|
@@ -29,9 +35,15 @@ export async function downloadBinaryNoExtract(
|
|
|
29
35
|
platform: string,
|
|
30
36
|
): Promise<DownloadBinaryResult> {
|
|
31
37
|
const opts = getPathsForDownload(softwareName, tgzName, baseDir, newArch(arch), newOs(platform));
|
|
32
|
-
const { archiveUrl, archivePath } = opts;
|
|
38
|
+
const { archiveUrl, alternativeArchiveGAUrl, archivePath } = opts;
|
|
33
39
|
|
|
34
|
-
|
|
40
|
+
try {
|
|
41
|
+
await downloadArchive(logger, archiveUrl, archivePath);
|
|
42
|
+
opts.wasDownloadedFrom = archiveUrl;
|
|
43
|
+
} catch (e: unknown) {
|
|
44
|
+
await downloadArchive(logger, alternativeArchiveGAUrl, archivePath);
|
|
45
|
+
opts.wasDownloadedFrom = alternativeArchiveGAUrl;
|
|
46
|
+
}
|
|
35
47
|
|
|
36
48
|
return opts;
|
|
37
49
|
}
|
|
@@ -45,25 +57,16 @@ export async function downloadBinary(
|
|
|
45
57
|
platform: string,
|
|
46
58
|
): Promise<DownloadBinaryResult> {
|
|
47
59
|
const opts = getPathsForDownload(softwareName, archiveName, baseDir, newArch(arch), newOs(platform));
|
|
48
|
-
const { archiveUrl, archivePath, archiveType, targetFolder, baseName } = opts;
|
|
49
|
-
|
|
50
|
-
await downloadArchive(logger, archiveUrl, archivePath);
|
|
51
|
-
await extractArchive(logger, archivePath, archiveType, targetFolder);
|
|
60
|
+
const { archiveUrl, alternativeArchiveGAUrl, archivePath, archiveType, targetFolder, baseName } = opts;
|
|
52
61
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
arch: string,
|
|
61
|
-
platform: string,
|
|
62
|
-
): Promise<DownloadBinaryResult> {
|
|
63
|
-
const opts = localDownloadPlOptions(plVersion, baseDir, newArch(arch), newOs(platform));
|
|
64
|
-
const { archiveUrl, archivePath, archiveType, targetFolder, binaryPath } = opts;
|
|
62
|
+
try {
|
|
63
|
+
await downloadArchive(logger, archiveUrl, archivePath);
|
|
64
|
+
opts.wasDownloadedFrom = archiveUrl;
|
|
65
|
+
} catch (e: unknown) {
|
|
66
|
+
await downloadArchive(logger, alternativeArchiveGAUrl, archivePath);
|
|
67
|
+
opts.wasDownloadedFrom = alternativeArchiveGAUrl;
|
|
68
|
+
}
|
|
65
69
|
|
|
66
|
-
await downloadArchive(logger, archiveUrl, archivePath);
|
|
67
70
|
await extractArchive(logger, archivePath, archiveType, targetFolder);
|
|
68
71
|
|
|
69
72
|
return opts;
|
|
@@ -80,13 +83,15 @@ function getPathsForDownload(
|
|
|
80
83
|
const archiveType = osToArchiveType[os];
|
|
81
84
|
|
|
82
85
|
const archiveFileName = `${baseName}.${archiveType}`;
|
|
83
|
-
const archiveUrl =
|
|
86
|
+
const archiveUrl = `${cdn}/${softwareName}/${os}/${archiveFileName}`;
|
|
87
|
+
const alternativeArchiveGAUrl = `${gaCdn}/${softwareName}/${os}/${archiveFileName}`;
|
|
84
88
|
const archivePath = upath.join(baseDir, archiveFileName);
|
|
85
89
|
// folder where binary distribution of pl will be unpacked
|
|
86
90
|
const targetFolder = upath.join(baseDir, baseName);
|
|
87
91
|
|
|
88
92
|
return {
|
|
89
93
|
archiveUrl,
|
|
94
|
+
alternativeArchiveGAUrl,
|
|
90
95
|
archivePath,
|
|
91
96
|
archiveType,
|
|
92
97
|
targetFolder,
|
|
@@ -94,34 +99,6 @@ function getPathsForDownload(
|
|
|
94
99
|
};
|
|
95
100
|
}
|
|
96
101
|
|
|
97
|
-
export function localDownloadPlOptions(
|
|
98
|
-
plVersion: string,
|
|
99
|
-
baseDir: string,
|
|
100
|
-
arch: ArchType,
|
|
101
|
-
os: OSType,
|
|
102
|
-
): DownloadBinaryResult {
|
|
103
|
-
const baseName = `pl-${plVersion}-${arch}`;
|
|
104
|
-
const archiveType = osToArchiveType[os];
|
|
105
|
-
|
|
106
|
-
const archiveFileName = `${baseName}.${archiveType}`;
|
|
107
|
-
const archiveUrl = `https://cdn.platforma.bio/software/pl/${os}/${archiveFileName}`;
|
|
108
|
-
const archivePath = upath.join(baseDir, archiveFileName);
|
|
109
|
-
|
|
110
|
-
// folder where binary distribution of pl will be unpacked
|
|
111
|
-
const targetFolder = upath.join(baseDir, baseName);
|
|
112
|
-
|
|
113
|
-
const binaryPath = upath.join(baseName, 'binaries', osToBinaryName[os]);
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
archiveUrl,
|
|
117
|
-
archivePath,
|
|
118
|
-
archiveType,
|
|
119
|
-
targetFolder,
|
|
120
|
-
binaryPath,
|
|
121
|
-
baseName,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
102
|
export type DownloadInfo = {
|
|
126
103
|
dstArchive?: string;
|
|
127
104
|
fileExisted?: boolean;
|
|
@@ -250,9 +227,3 @@ const osToArchiveType: Record<OSType, ArchiveType> = {
|
|
|
250
227
|
macos: 'tgz',
|
|
251
228
|
windows: 'zip',
|
|
252
229
|
};
|
|
253
|
-
|
|
254
|
-
const osToBinaryName: Record<OSType, string> = {
|
|
255
|
-
linux: 'platforma',
|
|
256
|
-
macos: 'platforma',
|
|
257
|
-
windows: 'platforma.exe',
|
|
258
|
-
};
|
package/src/local/pl.ts
CHANGED
|
@@ -162,7 +162,9 @@ export async function localPlatformaInit(logger: MiLogger, _ops: LocalPlOptions)
|
|
|
162
162
|
logger.info(`writing configuration '${configPath}'...`);
|
|
163
163
|
await fsp.writeFile(configPath, ops.config);
|
|
164
164
|
|
|
165
|
-
const
|
|
165
|
+
const plBinPath = upath.join(workDir, 'binaries');
|
|
166
|
+
const baseBinaryPath = await resolveLocalPlBinaryPath(logger, plBinPath, ops.plBinary);
|
|
167
|
+
|
|
166
168
|
const binaryPath = trace('binaryPath', upath.join('binaries', baseBinaryPath));
|
|
167
169
|
|
|
168
170
|
const processOpts: ProcessOptions = {
|
|
@@ -5,7 +5,7 @@ import upath from 'upath';
|
|
|
5
5
|
import { getDefaultPlVersion } from '../../common/pl_version';
|
|
6
6
|
import { existsSync, unlinkSync, rmSync } from 'fs';
|
|
7
7
|
import { newArch } from '../../common/os_and_arch';
|
|
8
|
-
import { downloadBinary
|
|
8
|
+
import { downloadBinary } from '../../common/pl_binary_download';
|
|
9
9
|
import { ConsoleLoggerAdapter } from '@milaboratories/ts-helpers';
|
|
10
10
|
import * as plpath from '../pl_paths';
|
|
11
11
|
|
|
@@ -84,10 +84,10 @@ describe('SshPl', async () => {
|
|
|
84
84
|
it('Transfer Platforma to server', async () => {
|
|
85
85
|
const arch = await sshPl.getArch();
|
|
86
86
|
|
|
87
|
-
const plPath = await
|
|
87
|
+
const plPath = await downloadBinary(
|
|
88
88
|
new ConsoleLoggerAdapter(),
|
|
89
89
|
downloadDestination,
|
|
90
|
-
getDefaultPlVersion()
|
|
90
|
+
'pl', `pl-${getDefaultPlVersion()}`,
|
|
91
91
|
arch.arch,
|
|
92
92
|
arch.platform,
|
|
93
93
|
);
|
|
@@ -154,10 +154,10 @@ describe('SshPl download binaries', async () => {
|
|
|
154
154
|
it('Download pl. We have archive and extracted data', async () => {
|
|
155
155
|
const arch = await sshPl.getArch();
|
|
156
156
|
|
|
157
|
-
const result = await
|
|
157
|
+
const result = await downloadBinary(
|
|
158
158
|
new ConsoleLoggerAdapter(),
|
|
159
159
|
downloadDestination,
|
|
160
|
-
getDefaultPlVersion()
|
|
160
|
+
'pl', `pl-${getDefaultPlVersion()}`,
|
|
161
161
|
arch.arch,
|
|
162
162
|
arch.platform,
|
|
163
163
|
);
|