build-strap 4.0.0-dev.46 → 4.0.0-dev.54
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/README.md +3 -34
- package/package.json +23 -19
- package/src/ant.d.ts +19 -0
- package/src/ant.js +12 -36
- package/src/cert.d.ts +12 -0
- package/src/cert.js +87 -148
- package/src/clean.d.ts +4 -0
- package/src/clean.js +5 -13
- package/src/copy.d.ts +7 -0
- package/src/copy.js +48 -74
- package/src/cp.d.ts +17 -0
- package/src/cp.js +81 -165
- package/src/docker.container.d.ts +73 -0
- package/src/docker.container.js +208 -350
- package/src/docker.d.ts +68 -0
- package/src/docker.js +163 -339
- package/src/docker.network.d.ts +42 -0
- package/src/docker.network.js +67 -141
- package/src/docker.volume.d.ts +26 -0
- package/src/docker.volume.js +50 -124
- package/src/dockerCleanup.d.ts +38 -0
- package/src/dockerCleanup.js +62 -136
- package/src/dockerCompose.d.ts +154 -0
- package/src/dockerCompose.js +390 -716
- package/src/fs.d.ts +5 -0
- package/src/fs.js +33 -91
- package/src/git.d.ts +9 -0
- package/src/git.js +19 -29
- package/src/index.d.ts +20 -0
- package/src/index.js +20 -26
- package/src/maps.d.ts +33 -0
- package/src/maps.js +12 -82
- package/src/npm.d.ts +48 -0
- package/src/npm.js +128 -131
- package/src/pkg.d.ts +38 -0
- package/src/pkg.js +27 -74
- package/src/publish.d.ts +27 -0
- package/src/publish.js +51 -138
- package/src/run.d.ts +13 -0
- package/src/run.js +39 -84
- package/src/tgz.d.ts +13 -0
- package/src/tgz.js +54 -88
- package/src/version.d.ts +34 -0
- package/src/version.js +85 -126
- package/src/yarn.d.ts +44 -0
- package/src/yarn.js +147 -115
- package/ant.js +0 -43
- package/ant.js.flow +0 -42
- package/artifactory.js +0 -617
- package/artifactory.js.flow +0 -616
- package/cert.conf +0 -20
- package/cert.js +0 -153
- package/cert.js.flow +0 -152
- package/clean.js +0 -20
- package/clean.js.flow +0 -19
- package/copy.js +0 -80
- package/copy.js.flow +0 -79
- package/cp.js +0 -173
- package/cp.js.flow +0 -172
- package/docker.container.js +0 -390
- package/docker.container.js.flow +0 -389
- package/docker.js +0 -365
- package/docker.js.flow +0 -364
- package/docker.network.js +0 -160
- package/docker.network.js.flow +0 -159
- package/docker.volume.js +0 -136
- package/docker.volume.js.flow +0 -136
- package/dockerCleanup.js +0 -152
- package/dockerCleanup.js.flow +0 -151
- package/dockerCompose.js +0 -766
- package/dockerCompose.js.flow +0 -765
- package/flow.js +0 -21
- package/flow.js.flow +0 -20
- package/fs.js +0 -95
- package/fs.js.flow +0 -96
- package/git.js +0 -35
- package/git.js.flow +0 -34
- package/hg.js +0 -35
- package/hg.js.flow +0 -34
- package/index.js +0 -27
- package/index.js.flow +0 -26
- package/inline-resources.js +0 -158
- package/inline-resources.js.flow +0 -157
- package/maps.js +0 -112
- package/maps.js.flow +0 -111
- package/npm.js +0 -145
- package/npm.js.flow +0 -144
- package/pkg.js +0 -81
- package/pkg.js.flow +0 -80
- package/publish.js +0 -145
- package/publish.js.flow +0 -144
- package/run.js +0 -90
- package/run.js.flow +0 -89
- package/src/artifactory.js +0 -616
- package/src/cert.conf +0 -20
- package/src/flow.js +0 -20
- package/src/hg.js +0 -34
- package/src/inline-resources.js +0 -157
- package/src/test.js +0 -55
- package/test.js +0 -56
- package/test.js.flow +0 -55
- package/tgz.js +0 -102
- package/tgz.js.flow +0 -101
- package/version.js +0 -143
- package/version.js.flow +0 -142
- package/yarn.js +0 -124
- package/yarn.js.flow +0 -123
package/src/inline-resources.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import glob from 'glob';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import { readFile, writeFile } from './fs';
|
|
6
|
-
|
|
7
|
-
type DependencyMap = {
|
|
8
|
-
[string]: string[],
|
|
9
|
-
};
|
|
10
|
-
// So we know to copy extra files when a dependency is modified
|
|
11
|
-
export const dependencies: DependencyMap = {};
|
|
12
|
-
|
|
13
|
-
function recordDependency(parent, child): void {
|
|
14
|
-
dependencies[child] = dependencies[child] || [];
|
|
15
|
-
if (!dependencies[child].includes(parent)) {
|
|
16
|
-
dependencies[child].push(parent);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Inline resources in a tsc/ngc compilation.
|
|
22
|
-
* @param projectPath {string} Path to the project.
|
|
23
|
-
*/
|
|
24
|
-
export async function inlineResources(projectPath: string): Promise<void> {
|
|
25
|
-
// Match only TypeScript files in projectPath.
|
|
26
|
-
const files = glob.sync('**/*.ts', { cwd: projectPath });
|
|
27
|
-
|
|
28
|
-
// For each file, inline the templates and styles under it and write the new file.
|
|
29
|
-
await Promise.all(
|
|
30
|
-
files.map(async (filePath) => {
|
|
31
|
-
const fullFilePath = path.join(projectPath, filePath);
|
|
32
|
-
const content = await readFile(fullFilePath, 'utf-8');
|
|
33
|
-
const inlined = inlineResourcesFromString(content, (url) => {
|
|
34
|
-
// Resolve the template url.
|
|
35
|
-
const templatePath = path.join(path.dirname(fullFilePath), url);
|
|
36
|
-
recordDependency(fullFilePath, templatePath);
|
|
37
|
-
return templatePath;
|
|
38
|
-
});
|
|
39
|
-
await writeFile(fullFilePath, inlined);
|
|
40
|
-
}),
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function requireResourcesLoader(content: string): string {
|
|
45
|
-
return [requireTemplate, requireStyle, removeModuleId].reduce(
|
|
46
|
-
(c, fn) => fn(c, '!raw-loader!'),
|
|
47
|
-
content,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// This is a webpack loader
|
|
52
|
-
export function webpackInlineResourceLoader(content: string): string {
|
|
53
|
-
this.cacheable(true);
|
|
54
|
-
const dir = this.context;
|
|
55
|
-
const that = this;
|
|
56
|
-
return inlineResourcesFromString(content, (url) => {
|
|
57
|
-
// Resolve the template url.
|
|
58
|
-
const fullPath = path.join(dir, url);
|
|
59
|
-
// Make sure this file gets watched
|
|
60
|
-
that.addDependency(fullPath);
|
|
61
|
-
return fullPath;
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export type UrlResolver = (url: string) => string;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Inline resources from a string content.
|
|
69
|
-
* @param content {string} The source file's content.
|
|
70
|
-
* @param urlResolver {Function} A resolver that takes a URL and return a path.
|
|
71
|
-
* @returns {string} The content with resources inlined.
|
|
72
|
-
*/
|
|
73
|
-
export function inlineResourcesFromString(
|
|
74
|
-
content: string,
|
|
75
|
-
urlResolver: UrlResolver,
|
|
76
|
-
): string {
|
|
77
|
-
// Curry through the inlining functions.
|
|
78
|
-
return [inlineTemplate, inlineStyle, removeModuleId].reduce(
|
|
79
|
-
(c, fn) => fn(c, urlResolver),
|
|
80
|
-
content,
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// The cbFn is given the template url, and should return the string to replace it
|
|
85
|
-
function processTemplate(content: string, cbFn: UrlResolver) {
|
|
86
|
-
return content.replace(
|
|
87
|
-
/templateUrl:\s*'([^']+?\.html)'/g,
|
|
88
|
-
(m, templateUrl) => `template: ${cbFn(templateUrl)}`,
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Inline the templates for a source file. Simply search for instances of `templateUrl: ...` and
|
|
94
|
-
* replace with `template: ...` (with the content of the file included).
|
|
95
|
-
* @param content {string} The source file's content.
|
|
96
|
-
* @param urlResolver {Function} A resolver that takes a URL and return a path.
|
|
97
|
-
* @return {string} The content with all templates inlined.
|
|
98
|
-
*/
|
|
99
|
-
function inlineTemplate(content: string, urlResolver: UrlResolver): string {
|
|
100
|
-
return processTemplate(
|
|
101
|
-
content,
|
|
102
|
-
(templateUrl) =>
|
|
103
|
-
`\`${fs
|
|
104
|
-
.readFileSync(urlResolver(templateUrl), 'utf-8')
|
|
105
|
-
.replace(/([\n\r]\s*)+/gm, ' ')}\``,
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function requireTemplate(content: string, loader: string = ''): string {
|
|
110
|
-
return processTemplate(content, (url) => `require('${loader}${url}')`);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// The cbFn is given the url of a single css file, and should return the string to replace it
|
|
114
|
-
function processStyle(content: string, cbFn: UrlResolver): string {
|
|
115
|
-
return content.replace(
|
|
116
|
-
/styleUrls:\s*(\[[\s\S]*?\])/gm,
|
|
117
|
-
(m, styleUrls) =>
|
|
118
|
-
// eslint-disable-next-line no-eval
|
|
119
|
-
`styles: [${eval(styleUrls)
|
|
120
|
-
.map((styleUrl) => cbFn(styleUrl))
|
|
121
|
-
.join(',\n')}]`,
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Inline the styles for a source file. Simply search for instances of `styleUrls: [...]` and
|
|
127
|
-
* replace with `styles: [...]` (with the content of the file included).
|
|
128
|
-
* @param urlResolver {Function} A resolver that takes a URL and return a path.
|
|
129
|
-
* @param content {string} The source file's content.
|
|
130
|
-
* @return {string} The content with all styles inlined.
|
|
131
|
-
*/
|
|
132
|
-
function inlineStyle(content: string, urlResolver: UrlResolver): string {
|
|
133
|
-
return processStyle(
|
|
134
|
-
content,
|
|
135
|
-
(styleUrl) =>
|
|
136
|
-
`\`${fs
|
|
137
|
-
.readFileSync(urlResolver(styleUrl), 'utf-8')
|
|
138
|
-
.replace(/([\n\r]\s*)+/gm, ' ')}\``,
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function requireStyle(content: string, loader: string = ''): string {
|
|
143
|
-
return processStyle(content, (url) => `require('${loader}${url}')`);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Remove every mention of `moduleId: module.id`.
|
|
148
|
-
* @param content {string} The source file's content.
|
|
149
|
-
* @returns {string} The content with all moduleId: mentions removed.
|
|
150
|
-
*/
|
|
151
|
-
function removeModuleId(
|
|
152
|
-
content: string,
|
|
153
|
-
// eslint-disable-next-line no-unused-vars
|
|
154
|
-
urlResolver?: UrlResolver | string,
|
|
155
|
-
): string {
|
|
156
|
-
return content.replace(/\s*moduleId:\s*module\.id\s*,?\s*/gm, '');
|
|
157
|
-
}
|
package/src/test.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import { run, buildLog } from './run';
|
|
3
|
-
import { onKillSignal } from './cp';
|
|
4
|
-
|
|
5
|
-
export async function karmaTest(
|
|
6
|
-
karma: Object,
|
|
7
|
-
karmaConfig: any,
|
|
8
|
-
preTestFn?: () => any,
|
|
9
|
-
watch: boolean = process.argv.includes('--watch'),
|
|
10
|
-
) {
|
|
11
|
-
// Lazy require karma
|
|
12
|
-
const { Server, runner, stopper, config } = karma;
|
|
13
|
-
|
|
14
|
-
const testConfig = config.parseConfig(karmaConfig, {
|
|
15
|
-
autoWatch: false,
|
|
16
|
-
singleRun: !watch,
|
|
17
|
-
});
|
|
18
|
-
const server = new Server(testConfig, (exitCode) => {
|
|
19
|
-
buildLog(`Karma has exited with code ${exitCode}`);
|
|
20
|
-
});
|
|
21
|
-
onKillSignal(() => stopper.stop(testConfig));
|
|
22
|
-
|
|
23
|
-
let started = false;
|
|
24
|
-
async function doTest() {
|
|
25
|
-
if (!started) {
|
|
26
|
-
await Promise.all([
|
|
27
|
-
new Promise((resolve) => {
|
|
28
|
-
server.on('browsers_ready', resolve);
|
|
29
|
-
}),
|
|
30
|
-
server.start(),
|
|
31
|
-
]);
|
|
32
|
-
started = true;
|
|
33
|
-
}
|
|
34
|
-
if (watch) {
|
|
35
|
-
// await server.refreshFiles();
|
|
36
|
-
await new Promise((resolve, reject) => {
|
|
37
|
-
runner.run(testConfig, (exitCode) => {
|
|
38
|
-
buildLog(`Karma run completed with exit code ${exitCode}`);
|
|
39
|
-
if (exitCode === 0 || watch) {
|
|
40
|
-
resolve(exitCode);
|
|
41
|
-
} else {
|
|
42
|
-
reject(exitCode);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (typeof preTestFn === 'function') {
|
|
50
|
-
// preTestFn is expected to callback and run doTest
|
|
51
|
-
await run(preTestFn, doTest);
|
|
52
|
-
} else {
|
|
53
|
-
await doTest();
|
|
54
|
-
}
|
|
55
|
-
}
|
package/test.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.karmaTest = karmaTest;
|
|
2
|
-
var _run = require("./run");
|
|
3
|
-
var _cp = require("./cp");
|
|
4
|
-
|
|
5
|
-
async function karmaTest(
|
|
6
|
-
karma,
|
|
7
|
-
karmaConfig,
|
|
8
|
-
preTestFn,
|
|
9
|
-
watch = process.argv.includes('--watch'))
|
|
10
|
-
{
|
|
11
|
-
// Lazy require karma
|
|
12
|
-
const { Server, runner, stopper, config } = karma;
|
|
13
|
-
|
|
14
|
-
const testConfig = config.parseConfig(karmaConfig, {
|
|
15
|
-
autoWatch: false,
|
|
16
|
-
singleRun: !watch });
|
|
17
|
-
|
|
18
|
-
const server = new Server(testConfig, (exitCode) => {
|
|
19
|
-
(0, _run.buildLog)(`Karma has exited with code ${exitCode}`);
|
|
20
|
-
});
|
|
21
|
-
(0, _cp.onKillSignal)(() => stopper.stop(testConfig));
|
|
22
|
-
|
|
23
|
-
let started = false;
|
|
24
|
-
async function doTest() {
|
|
25
|
-
if (!started) {
|
|
26
|
-
await Promise.all([
|
|
27
|
-
new Promise((resolve) => {
|
|
28
|
-
server.on('browsers_ready', resolve);
|
|
29
|
-
}),
|
|
30
|
-
server.start()]);
|
|
31
|
-
|
|
32
|
-
started = true;
|
|
33
|
-
}
|
|
34
|
-
if (watch) {
|
|
35
|
-
// await server.refreshFiles();
|
|
36
|
-
await new Promise((resolve, reject) => {
|
|
37
|
-
runner.run(testConfig, (exitCode) => {
|
|
38
|
-
(0, _run.buildLog)(`Karma run completed with exit code ${exitCode}`);
|
|
39
|
-
if (exitCode === 0 || watch) {
|
|
40
|
-
resolve(exitCode);
|
|
41
|
-
} else {
|
|
42
|
-
reject(exitCode);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (typeof preTestFn === 'function') {
|
|
50
|
-
// preTestFn is expected to callback and run doTest
|
|
51
|
-
await (0, _run.run)(preTestFn, doTest);
|
|
52
|
-
} else {
|
|
53
|
-
await doTest();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy90ZXN0LmpzIl0sIm5hbWVzIjpbImthcm1hVGVzdCIsImthcm1hIiwia2FybWFDb25maWciLCJwcmVUZXN0Rm4iLCJ3YXRjaCIsInByb2Nlc3MiLCJhcmd2IiwiaW5jbHVkZXMiLCJTZXJ2ZXIiLCJydW5uZXIiLCJzdG9wcGVyIiwiY29uZmlnIiwidGVzdENvbmZpZyIsInBhcnNlQ29uZmlnIiwiYXV0b1dhdGNoIiwic2luZ2xlUnVuIiwic2VydmVyIiwiZXhpdENvZGUiLCJzdG9wIiwic3RhcnRlZCIsImRvVGVzdCIsIlByb21pc2UiLCJhbGwiLCJyZXNvbHZlIiwib24iLCJzdGFydCIsInJlamVjdCIsInJ1biJdLCJtYXBwaW5ncyI6IjtBQUNBO0FBQ0E7O0FBRU8sZUFBZUEsU0FBZjtBQUNMQyxLQURLO0FBRUxDLFdBRks7QUFHTEMsU0FISztBQUlMQyxLQUFjLEdBQUdDLE9BQU8sQ0FBQ0MsSUFBUixDQUFhQyxRQUFiLENBQXNCLFNBQXRCLENBSlo7QUFLTDtBQUNBO0FBQ0EsUUFBTS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cbiAgfVxuXG4gIGlmICh0eXBlb2YgcHJlVGVzdEZuID09PSAnZnVuY3Rpb24nKSB7XG4gICAgLy8gcHJlVGVzdEZuIGlzIGV4cGVjdGVkIHRvIGNhbGxiYWNrIGFuZCBydW4gZG9UZXN0XG4gICAgYXdhaXQgcnVuKHByZVRlc3RGbiwgZG9UZXN0KTtcbiAgfSBlbHNlIHtcbiAgICBhd2FpdCBkb1Rlc3QoKTtcbiAgfVxufVxuIl19
|
package/test.js.flow
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import { run, buildLog } from './run';
|
|
3
|
-
import { onKillSignal } from './cp';
|
|
4
|
-
|
|
5
|
-
export async function karmaTest(
|
|
6
|
-
karma: Object,
|
|
7
|
-
karmaConfig: any,
|
|
8
|
-
preTestFn?: () => any,
|
|
9
|
-
watch: boolean = process.argv.includes('--watch'),
|
|
10
|
-
) {
|
|
11
|
-
// Lazy require karma
|
|
12
|
-
const { Server, runner, stopper, config } = karma;
|
|
13
|
-
|
|
14
|
-
const testConfig = config.parseConfig(karmaConfig, {
|
|
15
|
-
autoWatch: false,
|
|
16
|
-
singleRun: !watch,
|
|
17
|
-
});
|
|
18
|
-
const server = new Server(testConfig, (exitCode) => {
|
|
19
|
-
buildLog(`Karma has exited with code ${exitCode}`);
|
|
20
|
-
});
|
|
21
|
-
onKillSignal(() => stopper.stop(testConfig));
|
|
22
|
-
|
|
23
|
-
let started = false;
|
|
24
|
-
async function doTest() {
|
|
25
|
-
if (!started) {
|
|
26
|
-
await Promise.all([
|
|
27
|
-
new Promise((resolve) => {
|
|
28
|
-
server.on('browsers_ready', resolve);
|
|
29
|
-
}),
|
|
30
|
-
server.start(),
|
|
31
|
-
]);
|
|
32
|
-
started = true;
|
|
33
|
-
}
|
|
34
|
-
if (watch) {
|
|
35
|
-
// await server.refreshFiles();
|
|
36
|
-
await new Promise((resolve, reject) => {
|
|
37
|
-
runner.run(testConfig, (exitCode) => {
|
|
38
|
-
buildLog(`Karma run completed with exit code ${exitCode}`);
|
|
39
|
-
if (exitCode === 0 || watch) {
|
|
40
|
-
resolve(exitCode);
|
|
41
|
-
} else {
|
|
42
|
-
reject(exitCode);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (typeof preTestFn === 'function') {
|
|
50
|
-
// preTestFn is expected to callback and run doTest
|
|
51
|
-
await run(preTestFn, doTest);
|
|
52
|
-
} else {
|
|
53
|
-
await doTest();
|
|
54
|
-
}
|
|
55
|
-
}
|
package/tgz.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.getArtifactInfo = getArtifactInfo;exports.tgzDir = tgzDir;
|
|
2
|
-
var _path = _interopRequireDefault(require("path"));
|
|
3
|
-
var _tar = _interopRequireDefault(require("tar"));
|
|
4
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
5
|
-
var _crypto = _interopRequireDefault(require("crypto"));
|
|
6
|
-
var _streamCounter = _interopRequireDefault(require("stream-counter"));
|
|
7
|
-
var _fs2 = require("./fs");
|
|
8
|
-
var _run = require("./run");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const generateHash = async (
|
|
19
|
-
stream,
|
|
20
|
-
type) =>
|
|
21
|
-
|
|
22
|
-
new Promise((resolve, reject) => {
|
|
23
|
-
stream.
|
|
24
|
-
pipe(_crypto.default.createHash(type).setEncoding('hex')).
|
|
25
|
-
on('finish', function () {
|
|
26
|
-
resolve(this.read());
|
|
27
|
-
}).
|
|
28
|
-
on('end', function () {
|
|
29
|
-
resolve(this.read());
|
|
30
|
-
}).
|
|
31
|
-
on('error', (err) => reject(err));
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const countBytes = async (stream) =>
|
|
35
|
-
new Promise((resolve, reject) => {
|
|
36
|
-
const counter = new _streamCounter.default();
|
|
37
|
-
stream.
|
|
38
|
-
pipe(counter).
|
|
39
|
-
on('finish', () => resolve(counter.bytes)).
|
|
40
|
-
on('end', () => resolve(counter.bytes)).
|
|
41
|
-
on('error', (err) => reject(err));
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const writeStreamToFile = async (stream, filePath) =>
|
|
45
|
-
new Promise((resolve, reject) => {
|
|
46
|
-
stream.
|
|
47
|
-
pipe(_fs.default.createWriteStream(filePath)).
|
|
48
|
-
on('finish', () => {
|
|
49
|
-
(0, _run.buildLog)(`Successfully wrote file: ${filePath}`);
|
|
50
|
-
resolve();
|
|
51
|
-
}).
|
|
52
|
-
on('error', (err) => reject(err));
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Take the given file (path or stream) and compute the info that artifactory needs.
|
|
56
|
-
// md5 + sha1 hash, and size in bytes
|
|
57
|
-
async function getArtifactInfo(
|
|
58
|
-
artifact)
|
|
59
|
-
{
|
|
60
|
-
// make it into a stream
|
|
61
|
-
const stream =
|
|
62
|
-
typeof artifact === 'string' ? _fs.default.createReadStream(artifact) : artifact;
|
|
63
|
-
|
|
64
|
-
const [md5, sha1, sha512, size] = await Promise.all([
|
|
65
|
-
generateHash(stream, 'md5'),
|
|
66
|
-
generateHash(stream, 'sha1'),
|
|
67
|
-
generateHash(stream, 'sha512'),
|
|
68
|
-
countBytes(stream)]);
|
|
69
|
-
|
|
70
|
-
return { md5, sha1, sha512, size };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Creates a gzipped tarball of a directory, returns sha1 + md5 hash and size of resulting file
|
|
74
|
-
async function tgzDir(
|
|
75
|
-
srcDir,
|
|
76
|
-
outPath,
|
|
77
|
-
options)
|
|
78
|
-
{
|
|
79
|
-
await (0, _fs2.makeDir)(_path.default.dirname(outPath));
|
|
80
|
-
const tgzStream = _tar.default.c(
|
|
81
|
-
// $FlowFixMe
|
|
82
|
-
{
|
|
83
|
-
gzip: true,
|
|
84
|
-
cwd: srcDir,
|
|
85
|
-
portable: true,
|
|
86
|
-
// $FlowFixMe
|
|
87
|
-
...options },
|
|
88
|
-
|
|
89
|
-
['.']);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// write the file to disk (outPath)
|
|
93
|
-
const [info] = await Promise.all([
|
|
94
|
-
getArtifactInfo(tgzStream),
|
|
95
|
-
writeStreamToFile(tgzStream, `${outPath}`)]);
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
...info,
|
|
99
|
-
contentType: 'application/gzip' };
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy90Z3ouanMiXSwibmFtZXMiOlsiZ2VuZXJhdGVIYXNoIiwic3RyZWFtIiwidHlwZSIsIlByb21pc2UiLCJyZXNvbHZlIiwicmVqZWN0IiwicGlwZSIsImNyeXB0byIsImNyZWF0ZUhhc2giLCJzZXRFbmNvZGluZyIsIm9uIiwicmVhZCIsImVyciIsImNvdW50Qnl0ZXMiLCJjb3VudGVyIiwiU3RyZWFtQ291bnRlciIsImJ5dGVzIiwid3JpdGVTdHJlYW1Ub0ZpbGUiLCJmaWxlUGF0aCIsImZzIiwiY3JlYXRlV3JpdGVTdHJlYW0iLCJnZXRBcnRpZmFjdEluZm8iLCJhcnRpZmFjdCIsImNyZWF0ZVJlYWRTdHJlYW0iLCJtZDUiLCJzaGExIiwic2hhNTEyIiwic2l6ZSIsImFsbCIsInRnekRpciIsInNyY0RpciIsIm91dFBhdGgiLCJvcHRpb25zIiwicGF0aCIsImRpcm5hbWUiLCJ0Z3pTdHJlYW0iLCJ0YXIiLCJjIiwiZ3ppcCIsImN3ZCIsInBvcnRhYmxlIiwiaW5mbyIsImNvbnRlbnRUeXBlIl0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gICAuLi5vcHRpb25zLFxuICAgIH0sXG4gICAgWycuJ10sXG4gICk7XG5cbiAgLy8gd3JpdGUgdGhlIGZpbGUgdG8gZGlzayAob3V0UGF0aClcbiAgY29uc3QgW2luZm9dID0gYXdhaXQgUHJvbWlzZS5hbGwoW1xuICAgIGdldEFydGlmYWN0SW5mbyh0Z3pTdHJlYW0pLFxuICAgIHdyaXRlU3RyZWFtVG9GaWxlKHRnelN0cmVhbSwgYCR7b3V0UGF0aH1gKSxcbiAgXSk7XG4gIHJldHVybiB7XG4gICAgLi4uaW5mbyxcbiAgICBjb250ZW50VHlwZTogJ2FwcGxpY2F0aW9uL2d6aXAnLFxuICB9O1xufVxuIl19
|
package/tgz.js.flow
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import tar from 'tar';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import crypto from 'crypto';
|
|
6
|
-
import StreamCounter from 'stream-counter';
|
|
7
|
-
import { makeDir } from './fs';
|
|
8
|
-
import { buildLog } from './run';
|
|
9
|
-
|
|
10
|
-
export type ArtifactInfo = {
|
|
11
|
-
md5: string,
|
|
12
|
-
sha1: string,
|
|
13
|
-
sha512: string,
|
|
14
|
-
size: number,
|
|
15
|
-
contentType?: string,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const generateHash = async (
|
|
19
|
-
stream: stream$Readable,
|
|
20
|
-
type: 'md5' | 'sha1' | 'sha512',
|
|
21
|
-
): Promise<string> =>
|
|
22
|
-
new Promise((resolve, reject) => {
|
|
23
|
-
stream
|
|
24
|
-
.pipe(crypto.createHash(type).setEncoding('hex'))
|
|
25
|
-
.on('finish', function () {
|
|
26
|
-
resolve(this.read());
|
|
27
|
-
})
|
|
28
|
-
.on('end', function () {
|
|
29
|
-
resolve(this.read());
|
|
30
|
-
})
|
|
31
|
-
.on('error', (err) => reject(err));
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const countBytes = async (stream: stream$Readable): Promise<number> =>
|
|
35
|
-
new Promise((resolve, reject) => {
|
|
36
|
-
const counter = new StreamCounter();
|
|
37
|
-
stream
|
|
38
|
-
.pipe(counter)
|
|
39
|
-
.on('finish', () => resolve(counter.bytes))
|
|
40
|
-
.on('end', () => resolve(counter.bytes))
|
|
41
|
-
.on('error', (err) => reject(err));
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const writeStreamToFile = async (stream: stream$Readable, filePath: string) =>
|
|
45
|
-
new Promise((resolve, reject) => {
|
|
46
|
-
stream
|
|
47
|
-
.pipe(fs.createWriteStream(filePath))
|
|
48
|
-
.on('finish', () => {
|
|
49
|
-
buildLog(`Successfully wrote file: ${filePath}`);
|
|
50
|
-
resolve();
|
|
51
|
-
})
|
|
52
|
-
.on('error', (err) => reject(err));
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Take the given file (path or stream) and compute the info that artifactory needs.
|
|
56
|
-
// md5 + sha1 hash, and size in bytes
|
|
57
|
-
export async function getArtifactInfo(
|
|
58
|
-
artifact: string | stream$Readable,
|
|
59
|
-
): Promise<ArtifactInfo> {
|
|
60
|
-
// make it into a stream
|
|
61
|
-
const stream: stream$Readable =
|
|
62
|
-
typeof artifact === 'string' ? fs.createReadStream(artifact) : artifact;
|
|
63
|
-
|
|
64
|
-
const [md5, sha1, sha512, size] = await Promise.all([
|
|
65
|
-
generateHash(stream, 'md5'),
|
|
66
|
-
generateHash(stream, 'sha1'),
|
|
67
|
-
generateHash(stream, 'sha512'),
|
|
68
|
-
countBytes(stream),
|
|
69
|
-
]);
|
|
70
|
-
return { md5, sha1, sha512, size };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Creates a gzipped tarball of a directory, returns sha1 + md5 hash and size of resulting file
|
|
74
|
-
export async function tgzDir(
|
|
75
|
-
srcDir: string,
|
|
76
|
-
outPath: string,
|
|
77
|
-
options?: ?{ [string]: any },
|
|
78
|
-
): Promise<ArtifactInfo> {
|
|
79
|
-
await makeDir(path.dirname(outPath));
|
|
80
|
-
const tgzStream = tar.c(
|
|
81
|
-
// $FlowFixMe
|
|
82
|
-
{
|
|
83
|
-
gzip: true,
|
|
84
|
-
cwd: srcDir,
|
|
85
|
-
portable: true,
|
|
86
|
-
// $FlowFixMe
|
|
87
|
-
...options,
|
|
88
|
-
},
|
|
89
|
-
['.'],
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
// write the file to disk (outPath)
|
|
93
|
-
const [info] = await Promise.all([
|
|
94
|
-
getArtifactInfo(tgzStream),
|
|
95
|
-
writeStreamToFile(tgzStream, `${outPath}`),
|
|
96
|
-
]);
|
|
97
|
-
return {
|
|
98
|
-
...info,
|
|
99
|
-
contentType: 'application/gzip',
|
|
100
|
-
};
|
|
101
|
-
}
|