build-strap 4.0.0-dev.46 → 4.0.0-dev.5

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 (107) hide show
  1. package/README.md +3 -34
  2. package/ant.d.ts +19 -0
  3. package/ant.js +12 -37
  4. package/cert.d.ts +12 -0
  5. package/cert.js +89 -151
  6. package/clean.d.ts +4 -0
  7. package/clean.js +7 -16
  8. package/copy.d.ts +7 -0
  9. package/copy.js +49 -76
  10. package/cp.d.ts +17 -0
  11. package/cp.js +85 -170
  12. package/docker.container.d.ts +73 -0
  13. package/docker.container.js +219 -362
  14. package/docker.d.ts +68 -0
  15. package/docker.js +167 -344
  16. package/docker.network.d.ts +42 -0
  17. package/docker.network.js +69 -144
  18. package/docker.volume.d.ts +26 -0
  19. package/docker.volume.js +52 -126
  20. package/dockerCleanup.d.ts +38 -0
  21. package/dockerCleanup.js +66 -141
  22. package/dockerCompose.d.ts +154 -0
  23. package/dockerCompose.js +400 -727
  24. package/fs.d.ts +5 -0
  25. package/fs.js +38 -95
  26. package/git.d.ts +9 -0
  27. package/git.js +19 -30
  28. package/index.d.ts +20 -0
  29. package/index.js +20 -27
  30. package/maps.d.ts +33 -0
  31. package/maps.js +16 -87
  32. package/npm.d.ts +48 -0
  33. package/npm.js +131 -135
  34. package/package.json +23 -19
  35. package/pkg.d.ts +39 -0
  36. package/pkg.js +26 -74
  37. package/publish.d.ts +27 -0
  38. package/publish.js +52 -140
  39. package/run.d.ts +13 -0
  40. package/run.js +39 -85
  41. package/tgz.d.ts +13 -0
  42. package/tgz.js +61 -96
  43. package/version.d.ts +34 -0
  44. package/version.js +86 -128
  45. package/yarn.d.ts +44 -0
  46. package/yarn.js +150 -119
  47. package/ant.js.flow +0 -42
  48. package/artifactory.js +0 -617
  49. package/artifactory.js.flow +0 -616
  50. package/cert.conf +0 -20
  51. package/cert.js.flow +0 -152
  52. package/clean.js.flow +0 -19
  53. package/copy.js.flow +0 -79
  54. package/cp.js.flow +0 -172
  55. package/docker.container.js.flow +0 -389
  56. package/docker.js.flow +0 -364
  57. package/docker.network.js.flow +0 -159
  58. package/docker.volume.js.flow +0 -136
  59. package/dockerCleanup.js.flow +0 -151
  60. package/dockerCompose.js.flow +0 -765
  61. package/flow.js +0 -21
  62. package/flow.js.flow +0 -20
  63. package/fs.js.flow +0 -96
  64. package/git.js.flow +0 -34
  65. package/hg.js +0 -35
  66. package/hg.js.flow +0 -34
  67. package/index.js.flow +0 -26
  68. package/inline-resources.js +0 -158
  69. package/inline-resources.js.flow +0 -157
  70. package/maps.js.flow +0 -111
  71. package/npm.js.flow +0 -144
  72. package/pkg.js.flow +0 -80
  73. package/publish.js.flow +0 -144
  74. package/run.js.flow +0 -89
  75. package/src/ant.js +0 -42
  76. package/src/artifactory.js +0 -616
  77. package/src/cert.conf +0 -20
  78. package/src/cert.js +0 -152
  79. package/src/clean.js +0 -19
  80. package/src/copy.js +0 -79
  81. package/src/cp.js +0 -172
  82. package/src/docker.container.js +0 -389
  83. package/src/docker.js +0 -364
  84. package/src/docker.network.js +0 -159
  85. package/src/docker.volume.js +0 -136
  86. package/src/dockerCleanup.js +0 -151
  87. package/src/dockerCompose.js +0 -765
  88. package/src/flow.js +0 -20
  89. package/src/fs.js +0 -96
  90. package/src/git.js +0 -34
  91. package/src/hg.js +0 -34
  92. package/src/index.js +0 -26
  93. package/src/inline-resources.js +0 -157
  94. package/src/maps.js +0 -111
  95. package/src/npm.js +0 -144
  96. package/src/pkg.js +0 -80
  97. package/src/publish.js +0 -144
  98. package/src/run.js +0 -89
  99. package/src/test.js +0 -55
  100. package/src/tgz.js +0 -101
  101. package/src/version.js +0 -142
  102. package/src/yarn.js +0 -123
  103. package/test.js +0 -56
  104. package/test.js.flow +0 -55
  105. package/tgz.js.flow +0 -101
  106. package/version.js.flow +0 -142
  107. package/yarn.js.flow +0 -123
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy90ZXN0LmpzIl0sIm5hbWVzIjpbImthcm1hVGVzdCIsImthcm1hIiwia2FybWFDb25maWciLCJwcmVUZXN0Rm4iLCJ3YXRjaCIsInByb2Nlc3MiLCJhcmd2IiwiaW5jbHVkZXMiLCJTZXJ2ZXIiLCJydW5uZXIiLCJzdG9wcGVyIiwiY29uZmlnIiwidGVzdENvbmZpZyIsInBhcnNlQ29uZmlnIiwiYXV0b1dhdGNoIiwic2luZ2xlUnVuIiwic2VydmVyIiwiZXhpdENvZGUiLC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XhpdENvZGUpID0+IHtcbiAgICAgICAgICBidWlsZExvZyhgS2FybWEgcnVuIGNvbXBsZXRlZCB3aXRoIGV4aXQgY29kZSAke2V4aXRDb2RlfWApO1xuICAgICAgICAgIGlmIChleGl0Q29kZSA9PT0gMCB8fCB3YXRjaCkge1xuICAgICAgICAgICAgcmVzb2x2ZShleGl0Q29kZSk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJlamVjdChleGl0Q29kZSk7XG4gICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgIH0pO1xuICAgIH1cbiAgfVxuXG4gIGlmICh0eXBlb2YgcHJlVGVzdEZuID09PSAnZnVuY3Rpb24nKSB7XG4gICAgLy8gcHJlVGVzdEZuIGlzIGV4cGVjdGVkIHRvIGNhbGxiYWNrIGFuZCBydW4gZG9UZXN0XG4gICAgYXdhaXQgcnVuKHByZVRlc3RGbiwgZG9UZXN0KTtcbiAgfSBlbHNlIHtcbiAgICBhd2FpdCBkb1Rlc3QoKTtcbiAgfVxufVxuIl19
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.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
- }
package/version.js.flow DELETED
@@ -1,142 +0,0 @@
1
- // @flow
2
- import fs from 'fs';
3
- import { gitInfo } from './git';
4
- import { hgInfo } from './hg';
5
- import { getCfg, getPkg } from './pkg';
6
- import { buildLog } from './run';
7
-
8
- export function getBuild(): string {
9
- const arg = process.argv.find((el) => /^--buildNum=\d+$/.test(el));
10
- return (arg && arg.substr(11)) || process.env.BUILD_NUMBER || '0';
11
- }
12
-
13
- export function getReleaseBranch(): string {
14
- const { releaseBranch } = getCfg();
15
- return releaseBranch || 'master';
16
- }
17
-
18
- type RepoType = 'git' | 'hg' | 'unknown';
19
- export async function getRepoType(): Promise<RepoType> {
20
- const { repoType } = getCfg();
21
-
22
- return (
23
- repoType ||
24
- (fs.existsSync('./.hg')
25
- ? 'hg'
26
- : fs.existsSync('./.git')
27
- ? 'git'
28
- : 'unknown')
29
- );
30
- }
31
-
32
- type RepoInfo = {
33
- branch: string,
34
- revision: string,
35
- };
36
-
37
- export async function getRepoInfo(): Promise<RepoInfo> {
38
- const repoType = await getRepoType();
39
- const { branch, revision } =
40
- repoType === 'git'
41
- ? await gitInfo()
42
- : repoType === 'hg'
43
- ? await hgInfo()
44
- : {};
45
- if (!branch || !revision) {
46
- throw new Error('Failed to parse branch and revision from source repo.');
47
- }
48
- return { branch, revision };
49
- }
50
-
51
- export async function getDevBranch(): Promise<string> {
52
- const { devBranch } = getCfg();
53
- return devBranch || (await getRepoType()) === 'hg' ? 'default' : 'dev';
54
- }
55
-
56
- export async function getIsRelease(
57
- passedBranch?: ?string = null,
58
- releaseOverride?: ?boolean = null,
59
- ): Promise<boolean> {
60
- const branch = passedBranch || (await getRepoInfo()).branch;
61
- return releaseOverride != null
62
- ? releaseOverride
63
- : process.argv.includes('--force-release-version')
64
- ? true
65
- : branch === getReleaseBranch();
66
- }
67
-
68
- let cacheVersion = true;
69
- export function useVersionCache(useCache: boolean = true): void {
70
- cacheVersion = useCache;
71
- }
72
-
73
- export type Version = {|
74
- branch: string,
75
- build: string,
76
- info: string,
77
- isRelease: boolean,
78
- major: string,
79
- minor: string,
80
- name: string,
81
- npm: string,
82
- patch: string,
83
- revision: string,
84
- short: string,
85
- |};
86
-
87
- let version = null;
88
- export async function getVersion(
89
- logIt: boolean = true,
90
- release: ?boolean = null,
91
- ): Promise<Version> {
92
- if (!cacheVersion || version == null) {
93
- const { version: pkgVers, name } = getPkg();
94
- const { branch, revision } = await getRepoInfo();
95
- const [, major, minor, patch] =
96
- pkgVers.match(/^(\d+)\.(\d+)\.(\d+)$/) || [];
97
- if (!major || !minor || !patch) {
98
- throw new Error('Invalid version format in package.json');
99
- }
100
- const build = getBuild();
101
- const isRelease = await getIsRelease(branch, release);
102
- const short = `${major}.${minor}.${patch}`;
103
- const npm = `${short}${isRelease ? '' : `-${branch}.${build}`}`;
104
- const info = `${short}${
105
- isRelease ? `+${build}.` : `-${branch}.${build}+`
106
- }${revision}`;
107
- version = {
108
- name,
109
- branch,
110
- revision,
111
- major,
112
- minor,
113
- patch,
114
- build,
115
- short,
116
- isRelease,
117
- npm,
118
- info,
119
- };
120
- if (logIt) {
121
- buildLog(`Building version ${info}`);
122
- }
123
- }
124
- return version;
125
- }
126
-
127
- export async function getBanner(): Promise<string> {
128
- const { copyright = '' } = getCfg();
129
- const { info, name } = await getVersion();
130
- const today = new Date();
131
- return `${name} v${info} | (c) ${today.getFullYear()} ${copyright} | built on ${today.toISOString()}`;
132
- }
133
-
134
- export async function getVersionCode(): Promise<string> {
135
- return `// This file is auto-generated
136
- export const version = ${JSON.stringify(await getVersion(), null, 2)}`;
137
- }
138
-
139
- export async function getUniqueBuildTag(): Promise<string> {
140
- const { branch, revision, build } = await getVersion();
141
- return `${branch}-${revision}-${build}`;
142
- }
package/yarn.js.flow DELETED
@@ -1,123 +0,0 @@
1
- // @flow
2
- import md5File from 'md5-file';
3
- import fs from 'fs-extra';
4
- import path from 'path';
5
- import { spawnAdv } from './cp';
6
- import type { SpawnOptions, SpawnResult } from './cp';
7
- import { buildLog } from './run';
8
- import { readDir } from './fs';
9
- import { getPkg } from './pkg';
10
-
11
- export type YarnOptions = {|
12
- args?: string[],
13
- spawnOptions?: ?SpawnOptions,
14
- |};
15
-
16
- export async function yarnAdv(opts?: YarnOptions): Promise<SpawnResult> {
17
- const { args = [], spawnOptions } = opts || {};
18
- const localYarn = path.join(
19
- path.dirname(process.execPath),
20
- '/node_modules/yarn/bin/yarn.js',
21
- );
22
-
23
- const spawnOpts = {
24
- stdio: 'inherit',
25
- shell: true,
26
- env: process.env,
27
- ...spawnOptions,
28
- };
29
-
30
- return (await fs.exists(localYarn))
31
- ? // prefer to use local copy of yarn
32
- spawnAdv(process.execPath, [localYarn, ...args], spawnOpts)
33
- : // fall back to globally installed yarn
34
- spawnAdv('yarn', args, spawnOpts);
35
- }
36
-
37
- export async function yarn(opts?: YarnOptions): Promise<string> {
38
- const { args = [], spawnOptions } = opts || {};
39
- return yarnAdv({
40
- args,
41
- spawnOptions: { rejectOnErrorCode: true, ...spawnOptions },
42
- }).then((r) => r.output);
43
- }
44
-
45
- export const yarnFiles = ['./package.json', './yarn.lock'];
46
-
47
- export type YarnInstallOptions = {|
48
- nodeModulesPath?: string,
49
- hashFilePath?: string,
50
- force?: boolean,
51
- |};
52
-
53
- // Smart yarn invocation, only if package changed
54
- export async function yarnInstall(opts?: YarnInstallOptions) {
55
- const {
56
- nodeModulesPath = './node_modules',
57
- hashFilePath = './download/buildHash_yarn.md5',
58
- force = false,
59
- } = opts || {};
60
- await fs.ensureDir(nodeModulesPath);
61
- const currentHash = (
62
- await Promise.all(yarnFiles.map(async (f) => md5File(f)))
63
- ).join('|');
64
- await fs.ensureFile(hashFilePath);
65
- const prevHash = await fs.readFile(hashFilePath, 'utf8');
66
- if (currentHash !== prevHash) {
67
- buildLog(
68
- 'node package definition changed since last build, invoking yarn.',
69
- );
70
- } else if (!(await readDir(`${nodeModulesPath}/**/*.js`)).length) {
71
- buildLog('node packages missing, invoking yarn.');
72
- } else if (force) {
73
- buildLog('node packages unchanged, but yarn forced on command line...');
74
- } else {
75
- buildLog('node packages unchanged since last build, skipping yarn.');
76
- return;
77
- }
78
- await yarn();
79
- await fs.writeFile(hashFilePath, currentHash);
80
- }
81
-
82
- export type YarnUpgradeOptions = {|
83
- /**
84
- * Use `yarn outdated` to find packages that should be upgraded
85
- * May include breaking changes (major version changes)
86
- */
87
- outdated?: boolean,
88
- /**
89
- * `false` by default
90
- * we assume any package with an explicit version shouldn't be touched
91
- */
92
- all?: boolean,
93
- |};
94
-
95
- export async function yarnUpgrade(opts?: YarnUpgradeOptions) {
96
- const { outdated = false, all = false } = opts || {};
97
- if (outdated) {
98
- const { code, stdout } = await yarnAdv({
99
- args: ['outdated'],
100
- spawnOptions: { stdio: 'pipe', captureOutput: true },
101
- });
102
- if (code === 0) {
103
- buildLog('No outdated packages.');
104
- } else {
105
- const { dependencies = {}, devDependencies = {} } = getPkg();
106
- const packages = stdout
107
- .split('\n')
108
- .slice(5, -1)
109
- .map((l) => l.split(/\s+/)[0])
110
- .filter(
111
- (p) =>
112
- all || !/^\d/.test(dependencies[p] || devDependencies[p] || ''),
113
- );
114
- if (packages.length) {
115
- await yarn({ args: ['add', ...packages] });
116
- buildLog(`Upgraded: ${packages.join(', ')}`);
117
- } else {
118
- buildLog('No eligible outdated packages');
119
- }
120
- }
121
- }
122
- await yarn({ args: ['upgrade'] });
123
- }