build-strap 3.0.0-dev.45 → 4.0.0-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +3 -34
  3. package/ant.d.ts +19 -0
  4. package/ant.js +12 -37
  5. package/cert.d.ts +12 -0
  6. package/cert.js +89 -151
  7. package/clean.d.ts +4 -0
  8. package/clean.js +7 -16
  9. package/copy.d.ts +7 -0
  10. package/copy.js +49 -76
  11. package/cp.d.ts +17 -0
  12. package/cp.js +85 -170
  13. package/docker.container.d.ts +73 -0
  14. package/docker.container.js +219 -362
  15. package/docker.d.ts +68 -0
  16. package/docker.js +167 -347
  17. package/docker.network.d.ts +42 -0
  18. package/docker.network.js +69 -144
  19. package/docker.volume.d.ts +26 -0
  20. package/docker.volume.js +52 -126
  21. package/dockerCleanup.d.ts +38 -0
  22. package/dockerCleanup.js +66 -141
  23. package/dockerCompose.d.ts +154 -0
  24. package/dockerCompose.js +400 -727
  25. package/fs.d.ts +5 -0
  26. package/fs.js +38 -95
  27. package/git.d.ts +9 -0
  28. package/git.js +19 -30
  29. package/index.d.ts +20 -0
  30. package/index.js +20 -27
  31. package/maps.d.ts +33 -0
  32. package/maps.js +16 -87
  33. package/npm.d.ts +42 -0
  34. package/npm.js +104 -135
  35. package/package.json +23 -19
  36. package/pkg.d.ts +39 -0
  37. package/pkg.js +26 -74
  38. package/publish.d.ts +27 -0
  39. package/publish.js +52 -140
  40. package/run.d.ts +13 -0
  41. package/run.js +39 -85
  42. package/tgz.d.ts +13 -0
  43. package/tgz.js +61 -96
  44. package/version.d.ts +34 -0
  45. package/version.js +86 -127
  46. package/yarn.d.ts +44 -0
  47. package/yarn.js +156 -119
  48. package/ant.js.flow +0 -42
  49. package/artifactory.js +0 -617
  50. package/artifactory.js.flow +0 -616
  51. package/cert.conf +0 -20
  52. package/cert.js.flow +0 -152
  53. package/clean.js.flow +0 -19
  54. package/copy.js.flow +0 -79
  55. package/cp.js.flow +0 -172
  56. package/docker.container.js.flow +0 -389
  57. package/docker.js.flow +0 -367
  58. package/docker.network.js.flow +0 -159
  59. package/docker.volume.js.flow +0 -136
  60. package/dockerCleanup.js.flow +0 -151
  61. package/dockerCompose.js.flow +0 -765
  62. package/flow.js +0 -21
  63. package/flow.js.flow +0 -20
  64. package/fs.js.flow +0 -96
  65. package/git.js.flow +0 -34
  66. package/hg.js +0 -35
  67. package/hg.js.flow +0 -34
  68. package/index.js.flow +0 -26
  69. package/inline-resources.js +0 -158
  70. package/inline-resources.js.flow +0 -157
  71. package/maps.js.flow +0 -111
  72. package/npm.js.flow +0 -144
  73. package/pkg.js.flow +0 -80
  74. package/publish.js.flow +0 -144
  75. package/run.js.flow +0 -89
  76. package/src/ant.js +0 -42
  77. package/src/artifactory.js +0 -616
  78. package/src/cert.conf +0 -20
  79. package/src/cert.js +0 -152
  80. package/src/clean.js +0 -19
  81. package/src/copy.js +0 -79
  82. package/src/cp.js +0 -172
  83. package/src/docker.container.js +0 -389
  84. package/src/docker.js +0 -367
  85. package/src/docker.network.js +0 -159
  86. package/src/docker.volume.js +0 -136
  87. package/src/dockerCleanup.js +0 -151
  88. package/src/dockerCompose.js +0 -765
  89. package/src/flow.js +0 -20
  90. package/src/fs.js +0 -96
  91. package/src/git.js +0 -34
  92. package/src/hg.js +0 -34
  93. package/src/index.js +0 -26
  94. package/src/inline-resources.js +0 -157
  95. package/src/maps.js +0 -111
  96. package/src/npm.js +0 -144
  97. package/src/pkg.js +0 -80
  98. package/src/publish.js +0 -144
  99. package/src/run.js +0 -89
  100. package/src/test.js +0 -55
  101. package/src/tgz.js +0 -101
  102. package/src/version.js +0 -141
  103. package/src/yarn.js +0 -123
  104. package/test.js +0 -56
  105. package/test.js.flow +0 -55
  106. package/tgz.js.flow +0 -101
  107. package/version.js.flow +0 -141
  108. package/yarn.js.flow +0 -123
@@ -1,616 +0,0 @@
1
- // @flow
2
- import path from 'path';
3
- import fs from 'fs-extra';
4
- import rp from 'request-promise-native';
5
- import request from 'request';
6
- import moment from 'moment';
7
- import urlJoin from 'url-join';
8
- import { platform } from 'os';
9
- import { writeFile } from './fs';
10
- import { spawn } from './cp';
11
- import { getCfg, getPkgName, getPkgScope } from './pkg';
12
- import { getVersion, getReleaseBranch } from './version';
13
- import { buildLog } from './run';
14
- import { type ArtifactInfo } from './tgz';
15
-
16
- export type ArtifactoryCreds = {
17
- username: string,
18
- password: string,
19
- email: string,
20
- };
21
-
22
- export type RemoteArtifactInfo = {
23
- uri: string,
24
- lastModified: string,
25
- repo: string,
26
- path: string,
27
- children: RemoteArtifactInfo[],
28
- };
29
-
30
- export type ArtifactoryConfig = {
31
- root?: string,
32
- path?: string,
33
- 'version-folders'?: boolean,
34
- release?: string,
35
- 'release-branch'?: string,
36
- integration?: string,
37
- 'integration-branch-folders'?: boolean,
38
- 'integration-days-to-keep'?: number,
39
- 'integration-max-to-keep'?: number,
40
- npm?: string,
41
- 'npm-clean'?: string,
42
- };
43
-
44
- export function getArtifactoryConfig(): ArtifactoryConfig {
45
- return getCfg().artifactory || {};
46
- }
47
-
48
- const envArtifactoryCreds: ArtifactoryCreds = (process.env.ARTIFACTORY_CREDS &&
49
- JSON.parse(process.env.ARTIFACTORY_CREDS)) || {
50
- username: '',
51
- password: '',
52
- email: '',
53
- };
54
-
55
- // Properly insert credentials into request to artifactory api
56
- export async function artifactoryRequest(
57
- requestOptions: any,
58
- artifactoryCreds?: ArtifactoryCreds,
59
- ): Promise<any> {
60
- const creds = artifactoryCreds || envArtifactoryCreds;
61
- return rp(requestOptions).auth(creds.username, creds.password);
62
- }
63
-
64
- // Send a file to artifactory by doing a http PUT to the given url(s), with the given credentials
65
- // if artifactoryCreds are not provided, attempt to read from environment variable
66
- export async function artifactoryPut(
67
- artifact: string | stream$Readable,
68
- url: string | string[],
69
- artifactInfo: ArtifactInfo,
70
- artifactoryCreds?: ArtifactoryCreds,
71
- ): Promise<string[]> {
72
- const stream: stream$Readable =
73
- typeof artifact === 'string' ? fs.createReadStream(artifact) : artifact;
74
- const urls = typeof url === 'string' ? [url] : url;
75
-
76
- return Promise.all(
77
- urls.map((uri) =>
78
- artifactoryRequest(
79
- {
80
- method: 'PUT',
81
- uri,
82
- body: stream,
83
- headers: {
84
- 'content-type': artifactInfo.contentType || 'application/gzip',
85
- 'X-Checksum-Md5': artifactInfo.md5,
86
- 'X-Checksum-Sha1': artifactInfo.sha1,
87
- 'Content-Length': artifactInfo.size,
88
- },
89
- },
90
- artifactoryCreds,
91
- ).then(() => {
92
- buildLog(`Successful PUT to ${uri}`);
93
- return uri;
94
- }),
95
- ),
96
- );
97
- }
98
-
99
- export async function artifactoryDelete(
100
- url: string | string[],
101
- artifactoryCreds?: ArtifactoryCreds,
102
- dryRun: boolean = process.argv.includes('--dry-run'),
103
- ): Promise<?($SettledPromiseResult<string>[])> {
104
- const urls = typeof url === 'string' ? [url] : url;
105
- if (dryRun) {
106
- buildLog('Skipping delete due to --dry-run');
107
- return null;
108
- }
109
-
110
- return Promise.allSettled(
111
- urls.map((uri) =>
112
- artifactoryRequest(
113
- {
114
- method: 'DELETE',
115
- uri,
116
- },
117
- artifactoryCreds,
118
- ).then(
119
- () => {
120
- buildLog(`Successful DELETE of ${uri}`);
121
- return uri;
122
- },
123
- (err) => {
124
- buildLog(`Failed to DELETE ${uri}`);
125
- throw err;
126
- },
127
- ),
128
- ),
129
- );
130
- }
131
-
132
- // Invokes `npm publish` on the distDir, using the given credentials and artifactory config
133
- // artifactory config can be provided as arg, or in the package.json file
134
- export async function artifactoryNpm(
135
- distDir: string,
136
- artifactoryConfig?: ArtifactoryConfig,
137
- artifactoryCreds?: ArtifactoryCreds,
138
- npmPath?: string,
139
- tag?: string,
140
- skipExisting: boolean = false,
141
- ): Promise<boolean> {
142
- const creds = artifactoryCreds || envArtifactoryCreds;
143
- const { root: rt, npm } = artifactoryConfig || getArtifactoryConfig();
144
- if (!rt || !npm) {
145
- buildLog(
146
- 'npm artifactoryConfig info missing from package.json, skipping npm publish',
147
- );
148
- return false;
149
- }
150
- const existing = await getNpmArtifacts(false, artifactoryConfig, creds);
151
- const { isRelease, npm: npmVersion } = await getVersion();
152
- const regex = new RegExp(`${npmVersion}.tgz$`);
153
- const exists = !!existing.find((c) => c.path.match(regex));
154
- if (exists) {
155
- if (skipExisting) {
156
- buildLog(
157
- 'npm module with this same version already exists in artifactory. Skipping publish...',
158
- );
159
- return false;
160
- }
161
- throw new Error(
162
- 'Failed to publish npm module, this version already exists in artifactory!',
163
- );
164
- }
165
- // Write out .npmrc with credentials
166
- await writeFile(
167
- path.join(distDir, '.npmrc'),
168
- `registry=${rt}api/npm/${npm}
169
- _auth=${Buffer.from(`${creds.username}:${creds.password}`).toString('base64')}
170
- always-auth=true
171
- email=${creds.email}`,
172
- );
173
- await spawn(
174
- npmPath || (platform() === 'win32' ? 'npm.cmd' : 'npm'),
175
- ['publish', '--tag', tag || (isRelease ? 'latest' : 'next')],
176
- {
177
- stdio: 'inherit',
178
- cwd: distDir,
179
- },
180
- );
181
- return true;
182
- }
183
-
184
- async function standardUrl(
185
- fileName: string,
186
- artifactoryConfig?: ArtifactoryConfig,
187
- ) {
188
- const {
189
- root: rt,
190
- release,
191
- integration,
192
- path: aPath,
193
- 'version-folders': versionFolders,
194
- 'integration-branch-folders': intBrFolders,
195
- } = artifactoryConfig || getArtifactoryConfig();
196
- if (!rt || !release || !integration) {
197
- return false;
198
- }
199
- const version = await getVersion();
200
- const artPath = aPath || getPkgName();
201
- const versDir = versionFolders ? `/${version.info}` : '';
202
- if (version.isRelease) {
203
- return `${rt}${release}/${artPath}${versDir}/${fileName}`;
204
- }
205
- const branch = intBrFolders ? `/${version.branch}` : '';
206
- return `${rt}${integration}/${artPath}${branch}${versDir}/${fileName}`;
207
- }
208
-
209
- // Use the REST api to publish as a standard artifactory artifact
210
- export async function artifactoryStandard(
211
- artifact: string | stream$Readable,
212
- artifactInfo: ArtifactInfo,
213
- fileName: string,
214
- artifactoryConfig?: ArtifactoryConfig,
215
- artifactoryCreds?: ArtifactoryCreds,
216
- ): Promise<boolean> {
217
- const url = await standardUrl(fileName, artifactoryConfig);
218
- if (!url) {
219
- buildLog(
220
- 'release/integration artifactoryConfig info missing from package.json, skipping publish',
221
- );
222
- return false;
223
- }
224
- await artifactoryPut(artifact, url, artifactInfo, artifactoryCreds);
225
- return true;
226
- }
227
-
228
- const getRemoteArtifactInfo = async (
229
- rootUri: string,
230
- repo: string,
231
- subPath: string,
232
- artifactoryCreds?: ArtifactoryCreds,
233
- ): Promise<RemoteArtifactInfo> =>
234
- artifactoryRequest(
235
- {
236
- method: 'GET',
237
- uri: `${rootUri}/api/storage/${repo}/${subPath}`,
238
- json: true,
239
- },
240
- artifactoryCreds,
241
- );
242
-
243
- const getRemoteArtifactChildrenInfo = async (
244
- info: RemoteArtifactInfo,
245
- rootUri: string,
246
- repo: string,
247
- subPath: string,
248
- artifactoryCreds?: ArtifactoryCreds,
249
- ) =>
250
- Promise.all(
251
- info.children.map(async (c) =>
252
- getRemoteArtifactInfo(
253
- rootUri,
254
- repo,
255
- `${subPath}${c.uri}`,
256
- artifactoryCreds,
257
- ),
258
- ),
259
- );
260
-
261
- type CleanChildrenOptions = {|
262
- rootUri: string,
263
- repo: string,
264
- subPath: string,
265
- daysToKeep?: number,
266
- maxToKeep?: number,
267
- keepFilter?: ?(child: RemoteArtifactInfo) => boolean,
268
- artifactoryCreds?: ArtifactoryCreds,
269
- ignoreErrors?: boolean,
270
- |};
271
-
272
- async function cleanChildren({
273
- rootUri,
274
- repo,
275
- subPath,
276
- daysToKeep = 14,
277
- maxToKeep = 10,
278
- keepFilter,
279
- artifactoryCreds,
280
- ignoreErrors = true,
281
- }: CleanChildrenOptions = {}) {
282
- const info = await getRemoteArtifactInfo(
283
- rootUri,
284
- repo,
285
- subPath,
286
- artifactoryCreds,
287
- );
288
- const children = await getRemoteArtifactChildrenInfo(
289
- info,
290
- rootUri,
291
- repo,
292
- subPath,
293
- artifactoryCreds,
294
- );
295
- // Filter out children that we absolutely will not delete
296
- const integrationChildren = keepFilter
297
- ? children.filter((c) => !keepFilter(c))
298
- : children;
299
-
300
- // Determine which integration artifacts to keep (they are recent and not too numerous)
301
- const timeThreshold = daysToKeep
302
- ? moment().subtract(daysToKeep, 'days')
303
- : null;
304
- const filtered = timeThreshold
305
- ? integrationChildren.filter((c) =>
306
- moment(c.lastModified).isAfter(timeThreshold),
307
- )
308
- : integrationChildren;
309
- const limited = maxToKeep
310
- ? filtered
311
- .sort((a, b) => {
312
- const tA = moment(a.lastModified);
313
- const tB = moment(b.lastModified);
314
- if (tA.isBefore(tB)) {
315
- return -1;
316
- }
317
- if (tA.isAfter(tB)) {
318
- return 1;
319
- }
320
- return 0;
321
- })
322
- .slice(-maxToKeep)
323
- : filtered;
324
-
325
- // Delete any integration artifacts that didn't make the limited list
326
- const results = await Promise.allSettled(
327
- integrationChildren
328
- .filter((c) => limited.indexOf(c) < 0)
329
- .map(async (c) => {
330
- buildLog(`Deleting artifact: ${c.repo}${c.path}`);
331
- return artifactoryDelete(
332
- `${rootUri}/${c.repo}/${c.path}`,
333
- artifactoryCreds,
334
- );
335
- }),
336
- );
337
-
338
- if (!ignoreErrors && results.some((r) => r.status === 'rejected')) {
339
- throw new Error('Some artifacts were not deleted.');
340
- }
341
-
342
- return results;
343
- }
344
-
345
- type CleanBranchFoldersOptions = {
346
- rootUri: string,
347
- repo: string,
348
- subPath: string,
349
- daysToKeep?: number,
350
- maxToKeep?: number,
351
- keepFilter?: ?(child: RemoteArtifactInfo) => boolean,
352
- artifactoryCreds?: ArtifactoryCreds,
353
- ignoreErrors?: boolean,
354
- };
355
-
356
- async function cleanBranchFolders({
357
- rootUri,
358
- repo,
359
- subPath,
360
- daysToKeep,
361
- maxToKeep,
362
- keepFilter,
363
- artifactoryCreds,
364
- ignoreErrors = true,
365
- }: CleanBranchFoldersOptions = {}) {
366
- const info = await getRemoteArtifactInfo(
367
- rootUri,
368
- repo,
369
- subPath,
370
- artifactoryCreds,
371
- );
372
- const children = await getRemoteArtifactChildrenInfo(
373
- info,
374
- rootUri,
375
- repo,
376
- subPath,
377
- artifactoryCreds,
378
- );
379
- const results = await Promise.allSettled(
380
- children.map(async (c) => {
381
- const [branch] = c.path.split('/').slice(-1);
382
- if (branch === getReleaseBranch()) {
383
- buildLog(
384
- `Skipping cleanup of release branch: ${repo}/${subPath}/${branch}`,
385
- );
386
- return;
387
- }
388
- buildLog(`Cleaning integration branch: ${repo}/${subPath}/${branch}`);
389
- await cleanChildren({
390
- rootUri,
391
- repo: c.repo,
392
- subPath: c.path,
393
- daysToKeep,
394
- maxToKeep,
395
- keepFilter,
396
- artifactoryCreds,
397
- });
398
-
399
- // if branch folder is now empty, delete it
400
- const cInfo = await getRemoteArtifactInfo(
401
- rootUri,
402
- c.repo,
403
- c.path,
404
- artifactoryCreds,
405
- );
406
- if (cInfo.children.length === 0) {
407
- buildLog(`Deleting empty branch folder: ${c.repo}/${c.path}`);
408
- await artifactoryDelete(
409
- `${rootUri}/${c.repo}/${c.path}`,
410
- artifactoryCreds,
411
- );
412
- }
413
- }),
414
- );
415
-
416
- if (!ignoreErrors && results.some((r) => r.status === 'rejected')) {
417
- throw new Error('Some artifacts were not deleted.');
418
- }
419
- return results;
420
- }
421
-
422
- export async function artifactoryCleanup(
423
- daysToKeep?: number,
424
- maxToKeep?: number,
425
- artifactoryConfig?: ArtifactoryConfig,
426
- artifactoryCreds?: ArtifactoryCreds,
427
- ): Promise<boolean> {
428
- const {
429
- root: rt,
430
- 'integration-days-to-keep': intDaysKeep,
431
- 'integration-max-to-keep': intMaxKeep,
432
- integration,
433
- path: aPath,
434
- 'integration-branch-folders': intBranchFolders,
435
- 'npm-clean': npmClean,
436
- } = artifactoryConfig || getArtifactoryConfig();
437
- if (!rt) {
438
- buildLog(
439
- 'artifactory info missing from package.json, skipping artifactory cleanup',
440
- );
441
- return false;
442
- }
443
- const dToK = daysToKeep == null ? intDaysKeep : daysToKeep;
444
- const mToK = maxToKeep == null ? intMaxKeep : maxToKeep;
445
-
446
- if (integration) {
447
- // Clean up integration repo artifacts
448
- const artPath = aPath || getPkgName();
449
- if (intBranchFolders) {
450
- await cleanBranchFolders({
451
- rootUri: rt,
452
- repo: integration,
453
- subPath: artPath,
454
- daysToKeep: dToK,
455
- maxToKeep: mToK,
456
- artifactoryCreds,
457
- });
458
- } else {
459
- await cleanChildren({
460
- rootUri: rt,
461
- repo: integration,
462
- subPath: artPath,
463
- daysToKeep: dToK,
464
- maxToKeep: mToK,
465
- artifactoryCreds,
466
- });
467
- }
468
- }
469
-
470
- if (npmClean) {
471
- // Clean up npm integration artifacts
472
- const name = getPkgName(false);
473
- const scope = getPkgScope();
474
- const releaseRegex = new RegExp(`${name}-\\d+\\.\\d+\\.\\d+\\.tgz`, 'i');
475
- await cleanChildren({
476
- rootUri: rt,
477
- repo: npmClean,
478
- subPath: scope ? `${scope}/${name}/-/${scope}` : `${name}/-`,
479
- daysToKeep: dToK,
480
- maxToKeep: mToK,
481
- keepFilter: (c) => !!c.path.match(releaseRegex),
482
- artifactoryCreds,
483
- });
484
- }
485
- return true;
486
- }
487
-
488
- function uniqBy<T>(a: T[], key: (T) => string): T[] {
489
- const seen = new Set();
490
- return a.filter((item: T) => {
491
- const k = key(item);
492
- return seen.has(k) ? false : seen.add(k);
493
- });
494
- }
495
-
496
- export async function getNpmArtifacts(
497
- releasedOnly: boolean = false,
498
- artifactoryConfig?: ArtifactoryConfig,
499
- artifactoryCreds?: ArtifactoryCreds,
500
- ): Promise<RemoteArtifactInfo[]> {
501
- const { root: rt, npm } = artifactoryConfig || getArtifactoryConfig();
502
- if (!rt || !npm) {
503
- throw new Error('artifactoryConfig info missing from package.json');
504
- }
505
- const name = getPkgName(false);
506
- const scope = getPkgScope();
507
- const npmPath = scope ? `${scope}/${name}/-/${scope}` : `${name}/-`;
508
- const releaseRegex = new RegExp(`${name}-\\d+\\.\\d+\\.\\d+\\.tgz`, 'i');
509
- try {
510
- const info = await getRemoteArtifactInfo(
511
- rt,
512
- npm,
513
- npmPath,
514
- artifactoryCreds,
515
- );
516
- const children = uniqBy(
517
- await getRemoteArtifactChildrenInfo(
518
- info,
519
- rt,
520
- npm,
521
- npmPath,
522
- artifactoryCreds,
523
- ),
524
- (c) => c.uri,
525
- );
526
- return releasedOnly
527
- ? // $FlowFixMe
528
- children.filter((c) => !!c.path.match(releaseRegex))
529
- : children;
530
- } catch (err) {
531
- if (err.statusCode === 404) return [];
532
- throw err;
533
- }
534
- }
535
-
536
- export async function getLatestRepositoryVersion(
537
- repositoryPath: string,
538
- artifactoryCreds?: ArtifactoryCreds,
539
- ): Promise<string> {
540
- const { root: rt } = getArtifactoryConfig();
541
- if (!rt) {
542
- throw new Error('artifactoryConfig info missing from package.json');
543
- }
544
- // get latest version number for the key
545
- const lastModifiedFileInfo = await artifactoryRequest(
546
- {
547
- method: 'GET',
548
- uri: urlJoin(rt, `/api/storage/${repositoryPath}?lastModified`),
549
- },
550
- artifactoryCreds,
551
- );
552
- const { uri } = JSON.parse(lastModifiedFileInfo);
553
- const versionStartIndex = uri.indexOf(repositoryPath) + repositoryPath.length;
554
- const versionEndIndex = uri.indexOf('/', versionStartIndex + 1);
555
- const versionNumber = uri.substring(versionStartIndex + 1, versionEndIndex);
556
- return versionNumber;
557
- }
558
-
559
- export async function parseVersionedFilePath(
560
- repositoryPath: string,
561
- filePath: string,
562
- artifactoryCreds?: ArtifactoryCreds,
563
- ): Promise<string> {
564
- // eslint-disable-next-line
565
- if (filePath.indexOf('{{version}}') > -1) {
566
- const version = await getLatestRepositoryVersion(
567
- repositoryPath,
568
- artifactoryCreds,
569
- );
570
- return filePath.replace(/{{version}}/g, version);
571
- }
572
-
573
- return filePath;
574
- }
575
-
576
- /**
577
- * Download a given file from a repository hosted in Artifactory
578
- * @param {string} repositoryPath
579
- * The path to the repository root relative to the configured artifactory root
580
- * @param {string} filePath
581
- * The path to the file from the repository root. If the latest version of the
582
- * file is desired a tokenized string can be passed using {{version}} to indicate
583
- * segments to replaced by the latest version string.
584
- * ex: {{version}}/path/file-name-${{version}}.js
585
- * @param {string} saveAs
586
- * The local file path to save the downloaded file to.
587
- * @param {ArtifactoryCreds} artifactoryCreds
588
- */
589
- export async function downloadRepositoryFile(
590
- repositoryPath: string,
591
- filePath: string,
592
- saveAs: string,
593
- artifactoryCreds?: ArtifactoryCreds,
594
- ): Promise<Response> {
595
- const { root: rt } = getArtifactoryConfig();
596
- if (!rt) {
597
- throw new Error('artifactoryConfig info missing from package.json');
598
- }
599
- const fileUri = urlJoin(
600
- rt,
601
- repositoryPath,
602
- await parseVersionedFilePath(repositoryPath, filePath, artifactoryCreds),
603
- );
604
- buildLog(`Downloading file from Artifactory: ${fileUri}`);
605
- const fileStream = fs.createWriteStream(saveAs);
606
- return new Promise((resolve, reject) => {
607
- request(fileUri, (error, response) => {
608
- if (error) {
609
- buildLog(`Error downloading ${fileUri}: ${JSON.stringify(error)}`);
610
- reject(error);
611
- } else {
612
- resolve(response);
613
- }
614
- }).pipe(fileStream);
615
- });
616
- }
package/src/cert.conf DELETED
@@ -1,20 +0,0 @@
1
- [req]
2
- distinguished_name = req_distinguished_name
3
- req_extensions = v3_req
4
- x509_extensions = v3_req
5
-
6
- [req_distinguished_name]
7
- countryName = {{countryName}}
8
- stateOrProvinceName = {{stateOrProvinceName}}
9
- localityName = {{localityName}}
10
- organizationName = {{organizationName}}
11
- organizationalUnitName = {{organizationalUnitName}}
12
- commonName = {{commonName}}
13
- emailAddress = {{emailAddress}}
14
-
15
- [v3_req]
16
- # The extentions to add to a self-signed cert
17
- subjectKeyIdentifier = hash
18
- basicConstraints = critical,CA:false
19
- subjectAltName = DNS:localhost,IP:127.0.0.1{{SAN_IP}}{{SAN_DNS}}
20
- keyUsage = critical,digitalSignature,keyEncipherment