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.
Files changed (107) hide show
  1. package/README.md +3 -34
  2. package/package.json +23 -19
  3. package/src/ant.d.ts +19 -0
  4. package/src/ant.js +12 -36
  5. package/src/cert.d.ts +12 -0
  6. package/src/cert.js +87 -148
  7. package/src/clean.d.ts +4 -0
  8. package/src/clean.js +5 -13
  9. package/src/copy.d.ts +7 -0
  10. package/src/copy.js +48 -74
  11. package/src/cp.d.ts +17 -0
  12. package/src/cp.js +81 -165
  13. package/src/docker.container.d.ts +73 -0
  14. package/src/docker.container.js +208 -350
  15. package/src/docker.d.ts +68 -0
  16. package/src/docker.js +163 -339
  17. package/src/docker.network.d.ts +42 -0
  18. package/src/docker.network.js +67 -141
  19. package/src/docker.volume.d.ts +26 -0
  20. package/src/docker.volume.js +50 -124
  21. package/src/dockerCleanup.d.ts +38 -0
  22. package/src/dockerCleanup.js +62 -136
  23. package/src/dockerCompose.d.ts +154 -0
  24. package/src/dockerCompose.js +390 -716
  25. package/src/fs.d.ts +5 -0
  26. package/src/fs.js +33 -91
  27. package/src/git.d.ts +9 -0
  28. package/src/git.js +19 -29
  29. package/src/index.d.ts +20 -0
  30. package/src/index.js +20 -26
  31. package/src/maps.d.ts +33 -0
  32. package/src/maps.js +12 -82
  33. package/src/npm.d.ts +48 -0
  34. package/src/npm.js +128 -131
  35. package/src/pkg.d.ts +38 -0
  36. package/src/pkg.js +27 -74
  37. package/src/publish.d.ts +27 -0
  38. package/src/publish.js +51 -138
  39. package/src/run.d.ts +13 -0
  40. package/src/run.js +39 -84
  41. package/src/tgz.d.ts +13 -0
  42. package/src/tgz.js +54 -88
  43. package/src/version.d.ts +34 -0
  44. package/src/version.js +85 -126
  45. package/src/yarn.d.ts +44 -0
  46. package/src/yarn.js +147 -115
  47. package/ant.js +0 -43
  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 +0 -153
  53. package/cert.js.flow +0 -152
  54. package/clean.js +0 -20
  55. package/clean.js.flow +0 -19
  56. package/copy.js +0 -80
  57. package/copy.js.flow +0 -79
  58. package/cp.js +0 -173
  59. package/cp.js.flow +0 -172
  60. package/docker.container.js +0 -390
  61. package/docker.container.js.flow +0 -389
  62. package/docker.js +0 -365
  63. package/docker.js.flow +0 -364
  64. package/docker.network.js +0 -160
  65. package/docker.network.js.flow +0 -159
  66. package/docker.volume.js +0 -136
  67. package/docker.volume.js.flow +0 -136
  68. package/dockerCleanup.js +0 -152
  69. package/dockerCleanup.js.flow +0 -151
  70. package/dockerCompose.js +0 -766
  71. package/dockerCompose.js.flow +0 -765
  72. package/flow.js +0 -21
  73. package/flow.js.flow +0 -20
  74. package/fs.js +0 -95
  75. package/fs.js.flow +0 -96
  76. package/git.js +0 -35
  77. package/git.js.flow +0 -34
  78. package/hg.js +0 -35
  79. package/hg.js.flow +0 -34
  80. package/index.js +0 -27
  81. package/index.js.flow +0 -26
  82. package/inline-resources.js +0 -158
  83. package/inline-resources.js.flow +0 -157
  84. package/maps.js +0 -112
  85. package/maps.js.flow +0 -111
  86. package/npm.js +0 -145
  87. package/npm.js.flow +0 -144
  88. package/pkg.js +0 -81
  89. package/pkg.js.flow +0 -80
  90. package/publish.js +0 -145
  91. package/publish.js.flow +0 -144
  92. package/run.js +0 -90
  93. package/run.js.flow +0 -89
  94. package/src/artifactory.js +0 -616
  95. package/src/cert.conf +0 -20
  96. package/src/flow.js +0 -20
  97. package/src/hg.js +0 -34
  98. package/src/inline-resources.js +0 -157
  99. package/src/test.js +0 -55
  100. package/test.js +0 -56
  101. package/test.js.flow +0 -55
  102. package/tgz.js +0 -102
  103. package/tgz.js.flow +0 -101
  104. package/version.js +0 -143
  105. package/version.js.flow +0 -142
  106. package/yarn.js +0 -124
  107. package/yarn.js.flow +0 -123
package/src/yarn.js CHANGED
@@ -1,123 +1,155 @@
1
- // @flow
2
- import md5File from 'md5-file';
3
1
  import fs from 'fs-extra';
4
2
  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);
3
+ import { spawn } from './cp.js';
4
+ import { readDir } from './fs.js';
5
+ import { envNpmCreds, getNpmConfig, npmGetVersions, npmWriteRc, } from './npm.js';
6
+ import { getPkg, getPkgName } from './pkg.js';
7
+ import { buildLog } from './run.js';
8
+ import { generateFileHash } from './tgz.js';
9
+ import { getDevBranch, getVersion } from './version.js';
10
+ export async function yarn({ args = [], spawnOptions, } = {}) {
11
+ const localYarn = path.join(path.dirname(process.execPath), '/node_modules/yarn/bin/yarn.js');
12
+ const spawnOpts = {
13
+ env: process.env,
14
+ shell: true,
15
+ stdio: 'inherit',
16
+ ...spawnOptions,
17
+ };
18
+ return (await fs.pathExists(localYarn))
19
+ ? // prefer to use local copy of yarn
20
+ spawn(process.execPath, [localYarn, ...args], spawnOpts)
21
+ : // fall back to globally installed yarn
22
+ spawn('yarn', args, spawnOpts);
35
23
  }
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
24
  export const yarnFiles = ['./package.json', './yarn.lock'];
46
-
47
- export type YarnInstallOptions = {|
48
- nodeModulesPath?: string,
49
- hashFilePath?: string,
50
- force?: boolean,
51
- |};
52
-
53
25
  // 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);
26
+ export async function yarnInstall({ force = false, hashFilePath = './download/buildHash_yarn.md5', nodeModulesPath = './node_modules', } = {}) {
27
+ await fs.ensureDir(nodeModulesPath);
28
+ const currentHash = (await Promise.all(yarnFiles.map(async (f) => generateFileHash(f, 'md5')))).join('|');
29
+ await fs.ensureFile(hashFilePath);
30
+ const prevHash = await fs.readFile(hashFilePath, 'utf8');
31
+ if (currentHash !== prevHash) {
32
+ buildLog('node package definition changed since last build, invoking yarn.');
33
+ }
34
+ else if (!(await readDir(`${nodeModulesPath}/**/*.js`)).length) {
35
+ buildLog('node packages missing, invoking yarn.');
36
+ }
37
+ else if (force) {
38
+ buildLog('node packages unchanged, but yarn forced on command line...');
39
+ }
40
+ else {
41
+ buildLog('node packages unchanged since last build, skipping yarn.');
42
+ return;
43
+ }
44
+ await yarn();
45
+ await fs.writeFile(hashFilePath, currentHash);
80
46
  }
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
- }
47
+ export async function yarnUpgrade({ all = false, outdated = false, } = {}) {
48
+ if (outdated) {
49
+ const { code, stdout } = await yarn({
50
+ args: ['outdated'],
51
+ spawnOptions: {
52
+ captureOutput: true,
53
+ rejectOnErrorCode: false,
54
+ stdio: 'pipe',
55
+ },
56
+ });
57
+ if (code === 0) {
58
+ buildLog('No outdated packages.');
59
+ }
60
+ else {
61
+ const { dependencies = {}, devDependencies = {} } = getPkg();
62
+ const packages = stdout
63
+ .split('\n')
64
+ .slice(5, -1)
65
+ .map((l) => l.split(/\s+/)[0])
66
+ .filter((p) => all || !/^\d/.test(dependencies[p] || devDependencies[p] || ''));
67
+ if (packages.length) {
68
+ await yarn({ args: ['add', ...packages] });
69
+ buildLog(`Upgraded: ${packages.join(', ')}`);
70
+ }
71
+ else {
72
+ buildLog('No eligible outdated packages');
73
+ }
74
+ }
75
+ }
76
+ await yarn({ args: ['upgrade'] });
77
+ }
78
+ export async function yarnPublish({ npmAuthToken, npmConfig, npmCreds, npmPath, publishPath = '.', skipExisting = false, tag, workDir: passedWorkDir, } = {}) {
79
+ const creds = npmCreds || envNpmCreds;
80
+ const authToken = npmAuthToken || process.env.NPM_TOKEN;
81
+ const name = getPkgName();
82
+ const { access, publish, registry } = npmConfig || getNpmConfig();
83
+ if (!publish) {
84
+ buildLog('npm publish info missing from package.json, skipping npm publish');
85
+ return false;
86
+ }
87
+ const resolvedPath = path.resolve(publishPath);
88
+ const workDir = passedWorkDir ||
89
+ ((await fs.stat(resolvedPath)).isDirectory()
90
+ ? resolvedPath
91
+ : path.dirname(resolvedPath));
92
+ if (!(await fs.pathExists(path.join(workDir, 'package.json')))) {
93
+ buildLog(`warning: no package.json found in ${workDir}, skipping npm publish`);
94
+ return false;
95
+ }
96
+ if (creds || registry || authToken) {
97
+ // Write out .npmrc with credentials
98
+ await npmWriteRc({
99
+ authToken: authToken ? `\${NPM_TOKEN}` : undefined,
100
+ creds,
101
+ outPath: path.join(workDir, '.npmrc'),
102
+ registry,
103
+ });
104
+ }
105
+ const existing = await npmGetVersions(name, npmPath);
106
+ const { branch, isRelease, npm: npmVersion } = await getVersion();
107
+ if (existing.includes(npmVersion)) {
108
+ if (skipExisting) {
109
+ buildLog('npm package with this same version already exists. Skipping publish...');
110
+ return false;
111
+ }
112
+ throw new Error('Failed to publish npm package, this version already exists!');
120
113
  }
121
- }
122
- await yarn({ args: ['upgrade'] });
114
+ await yarn({
115
+ args: [
116
+ 'publish',
117
+ resolvedPath,
118
+ '--new-version',
119
+ npmVersion,
120
+ '--tag',
121
+ tag ||
122
+ (isRelease
123
+ ? 'latest'
124
+ : branch === (await getDevBranch())
125
+ ? 'next'
126
+ : 'branch'),
127
+ ...(access ? ['--access', access] : []),
128
+ ],
129
+ spawnOptions: {
130
+ cwd: workDir,
131
+ env: {
132
+ ...process.env,
133
+ FORCE_COLOR: 'true',
134
+ NPM_TOKEN: authToken,
135
+ },
136
+ shell: true,
137
+ stdio: 'inherit',
138
+ },
139
+ });
140
+ return true;
141
+ }
142
+ export async function yarnPack({ destination, workDir = '.', }) {
143
+ await fs.ensureDir(destination);
144
+ const version = await getVersion();
145
+ const name = getPkgName();
146
+ const filename = path.resolve(destination, `${name}-${version.npm}.tgz`);
147
+ await yarn({
148
+ args: ['pack', ...(destination ? ['--filename', filename] : [])],
149
+ spawnOptions: {
150
+ cwd: path.resolve(workDir),
151
+ pipeOutput: true,
152
+ },
153
+ });
154
+ return filename;
123
155
  }
package/ant.js DELETED
@@ -1,43 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.ant = ant;
2
- var _cp = require("./cp");
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
- /**
20
- * Executes the given ant command
21
- * @param {string} target the ant target to invoke
22
- * @param {AntSpawnOptions} options
23
- */
24
- async function ant(target, opts) {
25
- const { properties = [], args = [], spawnOptions } = opts || {};
26
-
27
- const execOptions = {
28
- stdio: 'inherit',
29
- pipeOutput: true,
30
- ...spawnOptions };
31
-
32
-
33
- await (0, _cp.spawn)(
34
- 'ant',
35
- [
36
- target,
37
- ...args,
38
- ...properties.map(({ name, value }) => `-D${name}=${value}`)],
39
-
40
- execOptions);
41
-
42
- }
43
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9hbnQuanMiXSwibmFtZXMiOlsiYW50IiwidGFyZ2V0Iiwib3B0cyIsInByb3BlcnRpZXMiLCJhcmdzIiwic3Bhd25PcHRpb25zIiwiZXhlY09wdGlvbnMiLCJzdGRpbyIsInBpcGVPdXRwdXQiLCJtYXAiLCJuYW1lIiwidmFsdW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ucyxcbiAgKTtcbn1cbiJdfQ==
package/ant.js.flow DELETED
@@ -1,42 +0,0 @@
1
- // @flow
2
- import { spawn } from './cp';
3
- import type { SpawnOptions } from './cp';
4
-
5
- /**
6
- * Named value pair to use when configuring an Ant build property
7
- */
8
- export type AntPropertyConfiguration = {|
9
- name: string,
10
- value: string,
11
- |};
12
-
13
- export type AntSpawnOptions = {|
14
- properties?: AntPropertyConfiguration[], // Ant property values to configure
15
- args?: string[], // Any additional command line arguments to pass
16
- spawnOptions?: SpawnOptions, // Optional spawn configuration. Defaults to run the project root directory
17
- |};
18
-
19
- /**
20
- * Executes the given ant command
21
- * @param {string} target the ant target to invoke
22
- * @param {AntSpawnOptions} options
23
- */
24
- export async function ant(target: string, opts?: AntSpawnOptions) {
25
- const { properties = [], args = [], spawnOptions } = opts || {};
26
-
27
- const execOptions = {
28
- stdio: 'inherit',
29
- pipeOutput: true,
30
- ...spawnOptions,
31
- };
32
-
33
- await spawn(
34
- 'ant',
35
- [
36
- target,
37
- ...args,
38
- ...properties.map(({ name, value }) => `-D${name}=${value}`),
39
- ],
40
- execOptions,
41
- );
42
- }