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/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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
89
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.trim();
|
|
5
|
+
export async function gitBranch() {
|
|
6
|
+
return (await git(['symbolic-ref', '--short', 'HEAD']))
|
|
7
|
+
.replace(/[_+/]/g, '-')
|
|
8
|
+
.trim();
|
|
12
9
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './docker';
|
|
9
|
-
export * from './docker.
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './
|
|
17
|
-
export * from './
|
|
18
|
-
export * from './
|
|
19
|
-
export * from './
|
|
20
|
-
export * from './
|
|
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 =
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
69
|
-
|
|
70
|
-
|
|
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 =
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
)
|
|
93
|
-
|
|
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 =
|
|
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 {};
|