build-strap 4.0.0 → 4.1.0-dev.60

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 (66) hide show
  1. package/package.json +7 -57
  2. package/{dist/src → src}/ant.d.ts +0 -0
  3. package/{dist/src → src}/ant.js +0 -0
  4. package/src/brew.d.ts +6 -0
  5. package/src/brew.js +74 -0
  6. package/{dist/src → src}/cert.d.ts +0 -0
  7. package/{dist/src → src}/cert.js +0 -0
  8. package/{dist/src → src}/clean.d.ts +0 -0
  9. package/{dist/src → src}/clean.js +0 -0
  10. package/{dist/src → src}/copy.d.ts +0 -0
  11. package/{dist/src → src}/copy.js +0 -0
  12. package/{dist/src → src}/cp.d.ts +0 -0
  13. package/{dist/src → src}/cp.js +1 -0
  14. package/{dist/src → src}/docker.container.d.ts +0 -0
  15. package/{dist/src → src}/docker.container.js +0 -0
  16. package/{dist/src → src}/docker.d.ts +4 -1
  17. package/{dist/src → src}/docker.js +78 -1
  18. package/{dist/src → src}/docker.network.d.ts +0 -0
  19. package/{dist/src → src}/docker.network.js +0 -0
  20. package/{dist/src → src}/docker.volume.d.ts +0 -0
  21. package/{dist/src → src}/docker.volume.js +0 -0
  22. package/{dist/src → src}/dockerCleanup.d.ts +0 -0
  23. package/{dist/src → src}/dockerCleanup.js +0 -0
  24. package/{dist/src → src}/dockerCompose.d.ts +1 -0
  25. package/{dist/src → src}/dockerCompose.js +9 -1
  26. package/src/env.d.ts +19 -0
  27. package/src/env.js +80 -0
  28. package/src/fetch.d.ts +1 -0
  29. package/src/fetch.js +20 -0
  30. package/{dist/src → src}/fs.d.ts +6 -0
  31. package/src/fs.js +76 -0
  32. package/src/gh.d.ts +7 -0
  33. package/src/gh.js +51 -0
  34. package/src/git.d.ts +14 -0
  35. package/src/git.js +44 -0
  36. package/{dist/src → src}/index.d.ts +4 -0
  37. package/{dist/src → src}/index.js +4 -0
  38. package/src/macos.d.ts +3 -0
  39. package/src/macos.js +36 -0
  40. package/{dist/src → src}/maps.d.ts +0 -0
  41. package/{dist/src → src}/maps.js +0 -0
  42. package/{dist/src → src}/npm.d.ts +16 -3
  43. package/src/npm.js +143 -0
  44. package/{dist/src → src}/pkg.d.ts +6 -1
  45. package/{dist/src → src}/pkg.js +0 -0
  46. package/src/promise.d.ts +7 -0
  47. package/src/promise.js +15 -0
  48. package/src/prompt.d.ts +2 -0
  49. package/src/prompt.js +19 -0
  50. package/{dist/src → src}/publish.d.ts +0 -0
  51. package/{dist/src → src}/publish.js +0 -0
  52. package/{dist/src → src}/run.d.ts +0 -0
  53. package/{dist/src → src}/run.js +0 -0
  54. package/src/ssh.d.ts +1 -0
  55. package/src/ssh.js +13 -0
  56. package/{dist/src → src}/tgz.d.ts +0 -0
  57. package/{dist/src → src}/tgz.js +0 -0
  58. package/{dist/src → src}/version.d.ts +0 -0
  59. package/{dist/src → src}/version.js +1 -1
  60. package/{dist/src → src}/yarn.d.ts +18 -0
  61. package/src/yarn.js +155 -0
  62. package/dist/src/fs.js +0 -38
  63. package/dist/src/git.d.ts +0 -9
  64. package/dist/src/git.js +0 -24
  65. package/dist/src/npm.js +0 -104
  66. package/dist/src/yarn.js +0 -75
package/dist/src/git.js DELETED
@@ -1,24 +0,0 @@
1
- import { exec } from './cp.js';
2
- export async function git(args) {
3
- return (await exec(`git ${args.join(' ')}`)).stdout.toString();
4
- }
5
- export async function gitBranch() {
6
- return (await git(['symbolic-ref', '--short', 'HEAD']))
7
- .replace(/[_+/]/g, '-')
8
- .trim();
9
- }
10
- export async function gitRevId() {
11
- return (await git(['rev-parse', '--short=12', 'HEAD']))
12
- .replace(/[+]/g, '')
13
- .trim();
14
- }
15
- let info = null;
16
- export async function gitInfo(noCache = false) {
17
- if (!info || noCache) {
18
- info = {
19
- branch: await gitBranch(),
20
- revision: await gitRevId(),
21
- };
22
- }
23
- return info;
24
- }
package/dist/src/npm.js DELETED
@@ -1,104 +0,0 @@
1
- import fs from 'fs-extra';
2
- import { platform } from 'os';
3
- import path from 'path';
4
- import { exec, spawn } from './cp.js';
5
- import { getCfg, getPkgName } from './pkg.js';
6
- import { buildLog } from './run.js';
7
- import { getDevBranch, getVersion } from './version.js';
8
- export function getNpmConfig() {
9
- return getCfg().npm || {};
10
- }
11
- const envNpmCreds = (process.env.NPM_CREDS && JSON.parse(process.env.NPM_CREDS)) || null;
12
- const npmExe = (npmPath) => npmPath || (platform() === 'win32' ? 'npm.cmd' : 'npm');
13
- export async function npmExec(args, npmPath) {
14
- return (await exec(`${npmExe(npmPath)} ${args.join(' ')}`)).stdout.toString();
15
- }
16
- export async function npmGetVersions(packageName, npmPath) {
17
- try {
18
- return JSON.parse(await npmExec(['show', packageName, 'versions'], npmPath));
19
- }
20
- catch (err) {
21
- buildLog(`warning: failed to find existing package for ${packageName} in npm registry: ${err.message}`);
22
- return [];
23
- }
24
- }
25
- export async function npmPublish({ npmAuthToken, npmConfig, npmCreds, npmPath, publishPath = '.', skipExisting = false, tag, workDir: passedWorkDir, writeNpmrc = false, } = {}) {
26
- const creds = npmCreds || envNpmCreds;
27
- const authToken = npmAuthToken || process.env.NPM_TOKEN;
28
- const name = getPkgName();
29
- const { access, dryRun, publish, registry } = npmConfig || getNpmConfig();
30
- if (!publish) {
31
- buildLog('npm publish info missing from package.json, skipping npm publish');
32
- return false;
33
- }
34
- const resolvedPath = path.resolve(publishPath);
35
- const workDir = passedWorkDir ||
36
- ((await fs.stat(resolvedPath)).isDirectory()
37
- ? resolvedPath
38
- : path.dirname(resolvedPath));
39
- if (!(await fs.pathExists(path.join(workDir, 'package.json')))) {
40
- buildLog(`warning: no package.json found in ${workDir}, skipping npm publish`);
41
- return false;
42
- }
43
- if (writeNpmrc && (creds || registry || authToken)) {
44
- // Write out .npmrc with credentials
45
- const theRegistry = registry || 'https://registry.npmjs.org/';
46
- const [, host] = /^(?:http(?:s)?:\/\/)?(.+)$/.exec(theRegistry) || [];
47
- await fs.mkdirp(workDir);
48
- await fs.writeFile(path.join(workDir, '.npmrc'), `registry=${theRegistry}
49
- ${authToken ? `//${host}:_authToken=${authToken}` : ''}
50
- ${creds
51
- ? `_auth=${Buffer.from(`${creds.username}:${creds.password}`).toString('base64')}
52
- always-auth=true
53
- email=${creds.email}`
54
- : ''}`);
55
- }
56
- const existing = await npmGetVersions(name, npmPath);
57
- const { branch, isRelease, npm: npmVersion } = await getVersion();
58
- if (existing.includes(npmVersion)) {
59
- if (skipExisting) {
60
- buildLog('npm package with this same version already exists. Skipping publish...');
61
- return false;
62
- }
63
- throw new Error('Failed to publish npm package, this version already exists!');
64
- }
65
- await spawn(npmExe(npmPath), [
66
- 'publish',
67
- resolvedPath,
68
- '--tag',
69
- tag ||
70
- (isRelease
71
- ? 'latest'
72
- : branch === (await getDevBranch())
73
- ? 'next'
74
- : 'branch'),
75
- ...(access ? ['--access', access] : []),
76
- ...(dryRun ? ['--dry-run'] : []),
77
- '--color=always',
78
- ], {
79
- cwd: workDir,
80
- env: {
81
- ...process.env,
82
- NPM_TOKEN: authToken,
83
- },
84
- stdio: 'inherit',
85
- });
86
- return true;
87
- }
88
- export async function npmPack({ destination, npmConfig, npmPath, workDir = '.', }) {
89
- const { dryRun } = npmConfig || getNpmConfig();
90
- if (destination) {
91
- await fs.ensureDir(destination);
92
- }
93
- const { stdout } = await spawn(npmExe(npmPath), [
94
- 'pack',
95
- ...(dryRun ? ['--dry-run'] : []),
96
- ...(destination ? ['--pack-destination', destination] : []),
97
- '--color=always',
98
- ], {
99
- captureOutput: true,
100
- cwd: workDir,
101
- pipeOutput: true,
102
- });
103
- return path.resolve(destination || '.', stdout.trim());
104
- }
package/dist/src/yarn.js DELETED
@@ -1,75 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- import { spawn } from './cp.js';
4
- import { readDir } from './fs.js';
5
- import { getPkg } from './pkg.js';
6
- import { buildLog } from './run.js';
7
- import { generateFileHash } from './tgz.js';
8
- export async function yarn({ args = [], spawnOptions, } = {}) {
9
- const localYarn = path.join(path.dirname(process.execPath), '/node_modules/yarn/bin/yarn.js');
10
- const spawnOpts = {
11
- env: process.env,
12
- shell: true,
13
- stdio: 'inherit',
14
- ...spawnOptions,
15
- };
16
- return (await fs.pathExists(localYarn))
17
- ? // prefer to use local copy of yarn
18
- spawn(process.execPath, [localYarn, ...args], spawnOpts)
19
- : // fall back to globally installed yarn
20
- spawn('yarn', args, spawnOpts);
21
- }
22
- export const yarnFiles = ['./package.json', './yarn.lock'];
23
- // Smart yarn invocation, only if package changed
24
- export async function yarnInstall({ force = false, hashFilePath = './download/buildHash_yarn.md5', nodeModulesPath = './node_modules', } = {}) {
25
- await fs.ensureDir(nodeModulesPath);
26
- const currentHash = (await Promise.all(yarnFiles.map(async (f) => generateFileHash(f, 'md5')))).join('|');
27
- await fs.ensureFile(hashFilePath);
28
- const prevHash = await fs.readFile(hashFilePath, 'utf8');
29
- if (currentHash !== prevHash) {
30
- buildLog('node package definition changed since last build, invoking yarn.');
31
- }
32
- else if (!(await readDir(`${nodeModulesPath}/**/*.js`)).length) {
33
- buildLog('node packages missing, invoking yarn.');
34
- }
35
- else if (force) {
36
- buildLog('node packages unchanged, but yarn forced on command line...');
37
- }
38
- else {
39
- buildLog('node packages unchanged since last build, skipping yarn.');
40
- return;
41
- }
42
- await yarn();
43
- await fs.writeFile(hashFilePath, currentHash);
44
- }
45
- export async function yarnUpgrade({ all = false, outdated = false, } = {}) {
46
- if (outdated) {
47
- const { code, stdout } = await yarn({
48
- args: ['outdated'],
49
- spawnOptions: {
50
- captureOutput: true,
51
- rejectOnErrorCode: false,
52
- stdio: 'pipe',
53
- },
54
- });
55
- if (code === 0) {
56
- buildLog('No outdated packages.');
57
- }
58
- else {
59
- const { dependencies = {}, devDependencies = {} } = getPkg();
60
- const packages = stdout
61
- .split('\n')
62
- .slice(5, -1)
63
- .map((l) => l.split(/\s+/)[0])
64
- .filter((p) => all || !/^\d/.test(dependencies[p] || devDependencies[p] || ''));
65
- if (packages.length) {
66
- await yarn({ args: ['add', ...packages] });
67
- buildLog(`Upgraded: ${packages.join(', ')}`);
68
- }
69
- else {
70
- buildLog('No eligible outdated packages');
71
- }
72
- }
73
- }
74
- await yarn({ args: ['upgrade'] });
75
- }