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/fs.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import glob from 'glob';
2
+ export declare const readDir: (pattern: string, options?: glob.IOptions | undefined) => Promise<string[]>;
3
+ export declare const moveDir: (source: string, target: string) => Promise<void>;
4
+ export declare const copyDir: (source: string, target: string, fileGlob?: string, globOptions?: null | glob.IOptions, renameFn?: (name: string) => string) => Promise<void>;
5
+ export declare const cleanDir: (pattern: string, globOptions?: false | glob.IOptions | undefined) => Promise<void>;
package/src/fs.js CHANGED
@@ -1,96 +1,38 @@
1
- // @flow
2
1
  import fs from 'fs-extra';
2
+ import glob from 'glob';
3
3
  import path from 'path';
4
- import glob, { type Options as GlobOptions } from 'glob';
5
4
  import rimraf from 'rimraf';
6
-
7
- export const readFile = async (
8
- file: string,
9
- options:
10
- | string
11
- | {
12
- encoding: string,
13
- flag?: string,
14
- ...
15
- } = 'utf8',
16
- ): Promise<string> => fs.readFile(file, options);
17
-
18
- export const writeFile = async (
19
- file: string,
20
- data: string | Buffer,
21
- options?: string | Object,
22
- ): Promise<void> => fs.writeFile(file, data, options);
23
-
24
- export const renameFile = async (
25
- source: string,
26
- target: string,
27
- ): Promise<void> => fs.rename(source, target);
28
-
29
- export const copyFile = async (source: string, target: string): Promise<void> =>
30
- fs.copyFile(source, target);
31
-
32
- export const readDir = async (
33
- pattern: string,
34
- options?: Object,
35
- ): Promise<string[]> =>
36
- new Promise((resolve, reject) =>
37
- glob(pattern, options || {}, (err, result) =>
38
- err ? reject(err) : resolve(result),
39
- ),
40
- );
41
-
42
- export const makeDir = async (name: string): Promise<void> =>
43
- fs.ensureDir(name);
44
-
45
- export const moveDir = async (
46
- source: string,
47
- target: string,
48
- ): Promise<void> => {
49
- const dirs = await readDir('**/*.*', {
50
- cwd: source,
51
- nosort: true,
52
- dot: true,
53
- });
54
- await Promise.all(
55
- dirs.map(async (dir) => {
56
- const from = path.resolve(source, dir);
57
- const to = path.resolve(target, dir);
58
- await makeDir(path.dirname(to));
59
- await renameFile(from, to);
60
- }),
61
- );
5
+ export const readDir = async (pattern, options) => new Promise((resolve, reject) => {
6
+ glob(pattern, options || {}, (err, result) => err ? reject(err) : resolve(result));
7
+ });
8
+ export const moveDir = async (source, target) => {
9
+ const dirs = await readDir('**/*.*', {
10
+ cwd: source,
11
+ dot: true,
12
+ nosort: true,
13
+ });
14
+ await Promise.all(dirs.map(async (dir) => {
15
+ const from = path.resolve(source, dir);
16
+ const to = path.resolve(target, dir);
17
+ await fs.ensureDir(path.dirname(to));
18
+ await fs.rename(from, to);
19
+ }));
62
20
  };
63
-
64
- export const copyDir = async (
65
- source: string,
66
- target: string,
67
- fileGlob: string = '**/*.*',
68
- globOptions?: ?Object = null,
69
- renameFn: (name: string) => string = (n) => n,
70
- ): Promise<void> => {
71
- const paths = await readDir(fileGlob, {
72
- cwd: source,
73
- nosort: true,
74
- nodir: true,
75
- dot: true,
76
- ...globOptions,
77
- });
78
- await Promise.all(
79
- paths.map(async (p) => {
80
- const from = path.resolve(source, p);
81
- const to = path.resolve(target, renameFn(p));
82
- await makeDir(path.dirname(to));
83
- await copyFile(from, to);
84
- }),
85
- );
21
+ export const copyDir = async (source, target, fileGlob = '**/*.*', globOptions = null, renameFn = (n) => n) => {
22
+ const paths = await readDir(fileGlob, {
23
+ cwd: source,
24
+ dot: true,
25
+ nodir: true,
26
+ nosort: true,
27
+ ...globOptions,
28
+ });
29
+ await Promise.all(paths.map(async (p) => {
30
+ const from = path.resolve(source, p);
31
+ const to = path.resolve(target, renameFn(p));
32
+ await fs.ensureDir(path.dirname(to));
33
+ await fs.copyFile(from, to);
34
+ }));
86
35
  };
87
-
88
- export const cleanDir = async (
89
- pattern: string,
90
- globOptions?: GlobOptions | boolean,
91
- ): Promise<void> =>
92
- new Promise((resolve, reject) =>
93
- rimraf(pattern, { glob: globOptions }, (err) =>
94
- err ? reject(err) : resolve(),
95
- ),
96
- );
36
+ export const cleanDir = async (pattern, globOptions) => new Promise((resolve, reject) => {
37
+ rimraf(pattern, { glob: globOptions }, (err) => err ? reject(err) : resolve());
38
+ });
package/src/git.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export declare function git(args: string[]): Promise<string>;
2
+ export declare function gitBranch(): Promise<string>;
3
+ export declare function gitRevId(): Promise<string>;
4
+ declare type GitInfo = {
5
+ branch: string;
6
+ revision: string;
7
+ };
8
+ export declare function gitInfo(noCache?: boolean): Promise<GitInfo>;
9
+ export {};
package/src/git.js CHANGED
@@ -1,34 +1,24 @@
1
- // @flow
2
- import { exec } from './cp';
3
-
4
- export async function git(args: string[]): Promise<string> {
5
- return (await exec(`git ${args.join(' ')}`)).stdout.toString();
1
+ import { exec } from './cp.js';
2
+ export async function git(args) {
3
+ return (await exec(`git ${args.join(' ')}`)).stdout.toString();
6
4
  }
7
-
8
- export async function gitBranch(): Promise<string> {
9
- return (await git(['symbolic-ref', '--short', 'HEAD']))
10
- .replace(/[_+/]/g, '-')
11
- .trim();
5
+ export async function gitBranch() {
6
+ return (await git(['symbolic-ref', '--short', 'HEAD']))
7
+ .replace(/[_+/]/g, '-')
8
+ .trim();
12
9
  }
13
-
14
- export async function gitRevId(): Promise<string> {
15
- return (await git(['rev-parse', '--short=12', 'HEAD']))
16
- .replace(/[+]/g, '')
17
- .trim();
10
+ export async function gitRevId() {
11
+ return (await git(['rev-parse', '--short=12', 'HEAD']))
12
+ .replace(/[+]/g, '')
13
+ .trim();
18
14
  }
19
-
20
- type GitInfo = {
21
- branch: string,
22
- revision: string,
23
- };
24
-
25
15
  let info = null;
26
- export async function gitInfo(noCache: boolean = false): Promise<GitInfo> {
27
- if (!info || noCache) {
28
- info = {
29
- branch: await gitBranch(),
30
- revision: await gitRevId(),
31
- };
32
- }
33
- return info;
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;
34
24
  }
package/src/index.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ export * from './ant.js';
2
+ export * from './cert.js';
3
+ export * from './clean.js';
4
+ export * from './copy.js';
5
+ export * from './cp.js';
6
+ export * from './docker.js';
7
+ export * from './docker.container.js';
8
+ export * from './docker.network.js';
9
+ export * from './docker.volume.js';
10
+ export * from './dockerCleanup.js';
11
+ export * from './dockerCompose.js';
12
+ export * from './fs.js';
13
+ export * from './git.js';
14
+ export * from './npm.js';
15
+ export * from './pkg.js';
16
+ export * from './publish.js';
17
+ export * from './run.js';
18
+ export * from './tgz.js';
19
+ export * from './version.js';
20
+ export * from './yarn.js';
package/src/index.js CHANGED
@@ -1,26 +1,20 @@
1
- // @flow
2
- export * from './ant';
3
- export * from './artifactory';
4
- export * from './cert';
5
- export * from './clean';
6
- export * from './copy';
7
- export * from './cp';
8
- export * from './docker';
9
- export * from './docker.container';
10
- export * from './docker.network';
11
- export * from './docker.volume';
12
- export * from './dockerCleanup';
13
- export * from './dockerCompose';
14
- export * from './flow';
15
- export * from './fs';
16
- export * from './git';
17
- export * from './hg';
18
- export * from './inline-resources';
19
- export * from './npm';
20
- export * from './pkg';
21
- export * from './publish';
22
- export * from './run';
23
- export * from './test';
24
- export * from './tgz';
25
- export * from './version';
26
- export * from './yarn';
1
+ export * from './ant.js';
2
+ export * from './cert.js';
3
+ export * from './clean.js';
4
+ export * from './copy.js';
5
+ export * from './cp.js';
6
+ export * from './docker.js';
7
+ export * from './docker.container.js';
8
+ export * from './docker.network.js';
9
+ export * from './docker.volume.js';
10
+ export * from './dockerCleanup.js';
11
+ export * from './dockerCompose.js';
12
+ export * from './fs.js';
13
+ export * from './git.js';
14
+ export * from './npm.js';
15
+ export * from './pkg.js';
16
+ export * from './publish.js';
17
+ export * from './run.js';
18
+ export * from './tgz.js';
19
+ export * from './version.js';
20
+ export * from './yarn.js';
package/src/maps.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Given a `ObjMap`, iterate over each entry and run it through the given `map` function.
3
+ * @param {ObjMap} obj the input object
4
+ * @param {Function} map the mapping operation
5
+ * @returns {ObjMap} a new object
6
+ */
7
+ export declare const mapValues: <K extends string, V, R>(obj: Record<K, V> | null | undefined, map: (value: V, key: K, map: Record<K, V>) => R) => Record<K, R>;
8
+ /**
9
+ * Given a `ObjMap`, iterate over each entry and run it through the given async `map` function.
10
+ * The promise returned by the `map` is awaited, such that the resulting `ObjMap` values are
11
+ * the result of the resolved promise.
12
+ * @param {ObjMap} obj the input object
13
+ * @param {Function} map the async mapping operation
14
+ * @returns {Promise} a promise for a new object
15
+ */
16
+ export declare const mapValuesAsync: <K extends string, V, R>(obj: Record<K, V> | null | undefined, map: (value: V, key: K, objMap: Record<K, V>) => Promise<R>) => Promise<Record<K, R>>;
17
+ /**
18
+ * Given a `ObjMap`, iterate over each entry and run it through the given `filter` function.
19
+ * Any entry for which the `filter` returns `false` is removed from the resulting `ObjMap`.
20
+ * All other entries are left as-is. The resulting output is a subset of the input.
21
+ * If no `filter` is specified, default to filtering out nullish values.
22
+ * @param {ObjMap} obj the input object
23
+ * @param {Function} filter the filter operation
24
+ * @returns {ObjMap} a new object, a subset of the input
25
+ */
26
+ export declare const filterKeys: <V, K extends string = string>(obj: Record<K, V> | null | undefined, filter?: (value: V, key: K, objMap: Record<K, V>) => boolean) => Partial<Record<K, V>>;
27
+ /**
28
+ * Given an object, removes any top level keys with a nullish value.
29
+ * The type system should preserve the incoming object type, with all such keys typed as `empty`.
30
+ * @param {Object} obj the input object
31
+ * @returns {Object} a new object, a subset of the input
32
+ */
33
+ export declare const filterNullish: <T>(obj: Record<string, T>) => Record<string, Exclude<T, null | undefined>>;
package/src/maps.js CHANGED
@@ -1,62 +1,12 @@
1
- // @flow
2
- // Util functions for using objects as maps and preserving type information
3
-
4
- /**
5
- * An object with arbitrary keys, where every key's value is of the same type.
6
- */
7
- export type ObjMap<V, K: string = string> = {
8
- +[K]: V,
9
- };
10
- // Alias for above, generics in opposite order (for backwards compat)
11
- export type MapObj<K, V> = ObjMap<V, K>;
12
-
13
- /**
14
- * Given an input object, return an array of the keys.
15
- * This is a wrapper around the standard `Object.keys` that preserves type information.
16
- * @param {ObjMap} obj the input object
17
- * @returns {Array} an array of keys. These will always be strings, but flow may assign
18
- * a more specific type when possible
19
- */
20
- export const keys = <V, K: string = string>(obj?: ?ObjMap<V, K>): K[] =>
21
- (Object.keys(obj || {}): any);
22
-
23
- /**
24
- * Given an input object, return an array of the values.
25
- * This is a wrapper around the standard `Object.values` that preserves type information.
26
- * @param {ObjMap} obj the input object
27
- * @returns {Array} an array of values
28
- */
29
- export const values = <V, K: string = string>(obj?: ?ObjMap<V, K>): V[] =>
30
- (Object.values(obj || {}): any);
31
-
32
- /**
33
- * Given a `ObjMap`, return an array of the entries.
34
- * This is a wrapper around the standard `Object.entries` that preserves type information.
35
- * It assumes an object with homogenous values.
36
- * @param {ObjMap} obj the input object
37
- * @returns {Array} an array of entry [key, value] tuples
38
- */
39
- export const entries = <V, K: string = string>(obj?: ?ObjMap<V, K>): [K, V][] =>
40
- (Object.entries(obj || {}): any);
41
-
42
1
  /**
43
2
  * Given a `ObjMap`, iterate over each entry and run it through the given `map` function.
44
3
  * @param {ObjMap} obj the input object
45
4
  * @param {Function} map the mapping operation
46
5
  * @returns {ObjMap} a new object
47
6
  */
48
- export const mapValues = <V, K: string, R>(
49
- obj?: ?ObjMap<V, K>,
50
- map: (V, K, ObjMap<V, K>) => R,
51
- ): ObjMap<R, K> =>
52
- entries(obj).reduce(
53
- (acc, [k, v]) =>
54
- Object.assign(acc, {
55
- [k]: map(v, k, obj || {}),
56
- }),
57
- {},
58
- );
59
-
7
+ export const mapValues = (obj, map) => Object.entries(obj ?? {}).reduce((acc, [k, v]) => Object.assign(acc, {
8
+ [k]: map(v, k, (obj ?? {})),
9
+ }), {});
60
10
  /**
61
11
  * Given a `ObjMap`, iterate over each entry and run it through the given async `map` function.
62
12
  * The promise returned by the `map` is awaited, such that the resulting `ObjMap` values are
@@ -65,18 +15,9 @@ export const mapValues = <V, K: string, R>(
65
15
  * @param {Function} map the async mapping operation
66
16
  * @returns {Promise} a promise for a new object
67
17
  */
68
- export const mapValuesAsync = async <V, K: string, R>(
69
- obj?: ?ObjMap<V, K>,
70
- map: (V, K, ObjMap<V, K>) => Promise<R>,
71
- ): Promise<ObjMap<R, K>> =>
72
- entries(obj).reduce(
73
- async (acc, [k, v]) =>
74
- Object.assign(await acc, {
75
- [k]: await map(v, k, obj || {}),
76
- }),
77
- {},
78
- );
79
-
18
+ export const mapValuesAsync = async (obj, map) => Object.entries(obj ?? {}).reduce(async (acc, [k, v]) => Object.assign(await acc, {
19
+ [k]: await map(v, k, (obj ?? {})),
20
+ }), Promise.resolve({}));
80
21
  /**
81
22
  * Given a `ObjMap`, iterate over each entry and run it through the given `filter` function.
82
23
  * Any entry for which the `filter` returns `false` is removed from the resulting `ObjMap`.
@@ -86,26 +27,15 @@ export const mapValuesAsync = async <V, K: string, R>(
86
27
  * @param {Function} filter the filter operation
87
28
  * @returns {ObjMap} a new object, a subset of the input
88
29
  */
89
- export const filterKeys = <V, K: string = string>(
90
- obj?: ?ObjMap<V, K>,
91
- filter?: (V, K, ObjMap<V, K>) => boolean = (v) => v != null,
92
- ): ObjMap<V, K> =>
93
- entries(obj).reduce(
94
- (acc, [k, v]) =>
95
- filter(v, k, obj || {})
96
- ? Object.assign(acc, {
97
- [k]: v,
98
- })
99
- : acc,
100
- {},
101
- );
102
-
30
+ export const filterKeys = (obj, filter = (v) => v != null) => Object.entries(obj ?? {}).reduce((acc, [k, v]) => filter(v, k, (obj ?? {}))
31
+ ? Object.assign(acc, {
32
+ [k]: v,
33
+ })
34
+ : acc, {});
103
35
  /**
104
36
  * Given an object, removes any top level keys with a nullish value.
105
37
  * The type system should preserve the incoming object type, with all such keys typed as `empty`.
106
38
  * @param {Object} obj the input object
107
39
  * @returns {Object} a new object, a subset of the input
108
40
  */
109
- export const filterNullish = <T: { ... }>(
110
- obj: T,
111
- ): $ObjMap<T, <V>(V) => $NonMaybeType<V>> => filterKeys(obj);
41
+ export const filterNullish = (obj) => filterKeys(obj);
package/src/npm.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ import { SpawnOptions, SpawnResult } from './cp.js';
2
+ export declare type NpmCreds = {
3
+ email?: string;
4
+ password?: string;
5
+ username?: string;
6
+ };
7
+ export declare type NpmConfig = {
8
+ access?: 'public' | 'restricted';
9
+ dryRun?: boolean;
10
+ name?: string;
11
+ publish?: boolean;
12
+ registry?: string;
13
+ };
14
+ export declare function getNpmConfig(): NpmConfig;
15
+ export declare const envNpmCreds: null | NpmCreds;
16
+ export interface NpmOptions {
17
+ args?: string[];
18
+ npmPath?: string;
19
+ spawnOptions?: SpawnOptions;
20
+ }
21
+ export declare function npm({ args, spawnOptions, npmPath, }?: NpmOptions): Promise<SpawnResult>;
22
+ export declare function npmGetVersions(packageName: string, npmPath?: string): Promise<string[]>;
23
+ interface NpmWriteRcOptions {
24
+ authToken?: string;
25
+ creds?: NpmCreds | null;
26
+ outPath: string;
27
+ registry?: string;
28
+ }
29
+ export declare function npmWriteRc({ authToken, creds, outPath, registry, }: NpmWriteRcOptions): Promise<void>;
30
+ export interface NpmPublishOptions {
31
+ npmAuthToken?: string;
32
+ npmConfig?: NpmConfig;
33
+ npmCreds?: NpmCreds;
34
+ npmPath?: string;
35
+ publishPath?: string;
36
+ skipExisting?: boolean;
37
+ tag?: string;
38
+ workDir?: string;
39
+ }
40
+ export declare function npmPublish({ npmAuthToken, npmConfig, npmCreds, npmPath, publishPath, skipExisting, tag, workDir: passedWorkDir, }?: NpmPublishOptions): Promise<boolean>;
41
+ interface NpmPackOptions {
42
+ destination?: string;
43
+ npmConfig?: NpmConfig;
44
+ npmPath?: string;
45
+ workDir?: string;
46
+ }
47
+ export declare function npmPack({ destination, npmConfig, npmPath, workDir, }: NpmPackOptions): Promise<string>;
48
+ export {};