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/run.js
CHANGED
|
@@ -1,89 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return time.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, '$1');
|
|
1
|
+
export function format(time = new Date()) {
|
|
2
|
+
return time.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, '$1');
|
|
4
3
|
}
|
|
5
|
-
|
|
6
4
|
const silenceLogs = process.argv.includes('--silence-buildLog');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
console.info(`[${format(time || new Date())}] ${msg}`);
|
|
5
|
+
export function buildLog(msg, time) {
|
|
6
|
+
if (silenceLogs) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
console.info(`[${format(time || new Date())}] ${msg}`);
|
|
13
10
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
'First argument to run must be a function or module with default function.',
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
const start = new Date();
|
|
33
|
-
buildLog(`Starting '${task.name}'...`, start);
|
|
34
|
-
const result = await task(...options);
|
|
35
|
-
const end = new Date();
|
|
36
|
-
const time = end.getTime() - start.getTime();
|
|
37
|
-
buildLog(`Finished '${task.name}' after ${time} ms`, end);
|
|
38
|
-
return result;
|
|
11
|
+
export async function run(fn, ...options) {
|
|
12
|
+
if (fn == null) {
|
|
13
|
+
throw new Error(`Invalid argument passed to run(${fn})`);
|
|
14
|
+
}
|
|
15
|
+
const task = typeof fn === 'function' ? fn : fn.default;
|
|
16
|
+
if (typeof task !== 'function') {
|
|
17
|
+
throw new Error('First argument to run must be a function or module with default function.');
|
|
18
|
+
}
|
|
19
|
+
const start = new Date();
|
|
20
|
+
buildLog(`Starting '${task.name}'...`, start);
|
|
21
|
+
const result = await task(...options);
|
|
22
|
+
const end = new Date();
|
|
23
|
+
const time = end.getTime() - start.getTime();
|
|
24
|
+
buildLog(`Finished '${task.name}' after ${time} ms`, end);
|
|
25
|
+
return result;
|
|
39
26
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
argv.length > 2
|
|
58
|
-
? resolveFn(argv[2])
|
|
59
|
-
: typeof defaultAction === 'string'
|
|
60
|
-
? resolveFn(defaultAction)
|
|
61
|
-
: defaultAction;
|
|
62
|
-
const args = Array.isArray(passthroughArgv)
|
|
63
|
-
? passthroughArgv.includes(argv[2] || defaultAction)
|
|
64
|
-
? argv.slice(3)
|
|
65
|
-
: []
|
|
66
|
-
: passthroughArgv
|
|
67
|
-
? argv.slice(3)
|
|
68
|
-
: [];
|
|
69
|
-
return run(module, ...args).catch((err) => {
|
|
70
|
-
console.error((err && err.stack) || err);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
throw err;
|
|
73
|
-
});
|
|
27
|
+
export async function runCli({ resolveFn = async (path) => import(`./${path}.js`), defaultAction = 'build', argv = process.argv, passthroughArgv = false, } = {}) {
|
|
28
|
+
const module = argv.length > 2
|
|
29
|
+
? await resolveFn(argv[2])
|
|
30
|
+
: typeof defaultAction === 'string'
|
|
31
|
+
? await resolveFn(defaultAction)
|
|
32
|
+
: defaultAction;
|
|
33
|
+
const args = Array.isArray(passthroughArgv)
|
|
34
|
+
? passthroughArgv.includes(argv[2] || defaultAction)
|
|
35
|
+
? argv.slice(3)
|
|
36
|
+
: []
|
|
37
|
+
: passthroughArgv
|
|
38
|
+
? argv.slice(3)
|
|
39
|
+
: [];
|
|
40
|
+
return run(module, ...args).catch((err) => {
|
|
41
|
+
console.error((err && err.stack) || err);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
});
|
|
74
44
|
}
|
|
75
|
-
|
|
76
|
-
export function handleEntryPoint<T>(
|
|
77
|
-
mainModule: typeof module,
|
|
78
|
-
mainModuleFilename: string,
|
|
79
|
-
cliOptions?: RunCliOptions<T>,
|
|
80
|
-
) {
|
|
81
|
-
if (require.main === mainModule) {
|
|
82
|
-
delete require.cache[mainModuleFilename]; // eslint-disable-line no-underscore-dangle
|
|
83
|
-
runCli(cliOptions);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
handleEntryPoint(module, __filename);
|
|
88
|
-
|
|
89
|
-
export default run;
|
package/src/tgz.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Readable } from 'stream';
|
|
3
|
+
import tar from 'tar';
|
|
4
|
+
export declare type ArtifactInfo = {
|
|
5
|
+
contentType?: string;
|
|
6
|
+
md5: string;
|
|
7
|
+
sha1: string;
|
|
8
|
+
sha512: string;
|
|
9
|
+
size: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const generateFileHash: (filePath: string, type: 'md5' | 'sha1' | 'sha512') => Promise<string>;
|
|
12
|
+
export declare function getArtifactInfo(artifact: string | Readable): Promise<ArtifactInfo>;
|
|
13
|
+
export declare function tgzDir(srcDir: string, outPath: string, options?: tar.CreateOptions): Promise<ArtifactInfo>;
|
package/src/tgz.js
CHANGED
|
@@ -1,101 +1,67 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import tar from 'tar';
|
|
4
|
-
import fs from 'fs';
|
|
5
1
|
import crypto from 'crypto';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
6
4
|
import StreamCounter from 'stream-counter';
|
|
7
|
-
import
|
|
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) => {
|
|
5
|
+
import tar from 'tar';
|
|
6
|
+
import { buildLog } from './run.js';
|
|
7
|
+
const generateHash = async (stream, type) => new Promise((resolve, reject) => {
|
|
23
8
|
stream
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
.pipe(crypto.createHash(type).setEncoding('hex'))
|
|
10
|
+
.on('finish', function onFinish() {
|
|
26
11
|
resolve(this.read());
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
})
|
|
13
|
+
.on('end', function onEnd() {
|
|
29
14
|
resolve(this.read());
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const countBytes = async (stream
|
|
35
|
-
new Promise((resolve, reject) => {
|
|
15
|
+
})
|
|
16
|
+
.on('error', (err) => reject(err));
|
|
17
|
+
});
|
|
18
|
+
export const generateFileHash = async (filePath, type) => generateHash(fs.createReadStream(filePath), type);
|
|
19
|
+
const countBytes = async (stream) => new Promise((resolve, reject) => {
|
|
36
20
|
const counter = new StreamCounter();
|
|
37
21
|
stream
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const writeStreamToFile = async (stream: stream$Readable, filePath: string) =>
|
|
45
|
-
new Promise((resolve, reject) => {
|
|
22
|
+
.pipe(counter)
|
|
23
|
+
.on('finish', () => resolve(counter.bytes))
|
|
24
|
+
.on('end', () => resolve(counter.bytes))
|
|
25
|
+
.on('error', (err) => reject(err));
|
|
26
|
+
});
|
|
27
|
+
const writeStreamToFile = async (stream, filePath) => new Promise((resolve, reject) => {
|
|
46
28
|
stream
|
|
47
|
-
|
|
48
|
-
|
|
29
|
+
.pipe(fs.createWriteStream(filePath))
|
|
30
|
+
.on('finish', () => {
|
|
49
31
|
buildLog(`Successfully wrote file: ${filePath}`);
|
|
50
32
|
resolve();
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
generateHash(stream, 'sha1'),
|
|
67
|
-
generateHash(stream, 'sha512'),
|
|
68
|
-
countBytes(stream),
|
|
69
|
-
]);
|
|
70
|
-
return { md5, sha1, sha512, size };
|
|
33
|
+
})
|
|
34
|
+
.on('error', (err) => reject(err));
|
|
35
|
+
});
|
|
36
|
+
// Take the given file (path or stream) and compute metadata for it.
|
|
37
|
+
// md5 + sha hashes, and size in bytes
|
|
38
|
+
export async function getArtifactInfo(artifact) {
|
|
39
|
+
// make it into a stream
|
|
40
|
+
const stream = typeof artifact === 'string' ? fs.createReadStream(artifact) : artifact;
|
|
41
|
+
const [md5, sha1, sha512, size] = await Promise.all([
|
|
42
|
+
generateHash(stream, 'md5'),
|
|
43
|
+
generateHash(stream, 'sha1'),
|
|
44
|
+
generateHash(stream, 'sha512'),
|
|
45
|
+
countBytes(stream),
|
|
46
|
+
]);
|
|
47
|
+
return { md5, sha1, sha512, size };
|
|
71
48
|
}
|
|
72
|
-
|
|
73
49
|
// Creates a gzipped tarball of a directory, returns sha1 + md5 hash and size of resulting file
|
|
74
|
-
export async function tgzDir(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
};
|
|
50
|
+
export async function tgzDir(srcDir, outPath, options) {
|
|
51
|
+
await fs.ensureDir(path.dirname(outPath));
|
|
52
|
+
const tgzStream = tar.c({
|
|
53
|
+
cwd: srcDir,
|
|
54
|
+
gzip: true,
|
|
55
|
+
portable: true,
|
|
56
|
+
...options,
|
|
57
|
+
}, ['.']);
|
|
58
|
+
// write the file to disk (outPath)
|
|
59
|
+
const [info] = await Promise.all([
|
|
60
|
+
getArtifactInfo(tgzStream),
|
|
61
|
+
writeStreamToFile(tgzStream, `${outPath}`),
|
|
62
|
+
]);
|
|
63
|
+
return {
|
|
64
|
+
...info,
|
|
65
|
+
contentType: 'application/gzip',
|
|
66
|
+
};
|
|
101
67
|
}
|
package/src/version.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare function getBuild(): string;
|
|
2
|
+
export declare function getReleaseBranch(): string;
|
|
3
|
+
declare enum RepoType {
|
|
4
|
+
git = "git",
|
|
5
|
+
hg = "hg",
|
|
6
|
+
unknown = "unknown"
|
|
7
|
+
}
|
|
8
|
+
export declare function getRepoType(): Promise<RepoType>;
|
|
9
|
+
declare type RepoInfo = {
|
|
10
|
+
branch: string;
|
|
11
|
+
revision: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function getRepoInfo(): Promise<RepoInfo>;
|
|
14
|
+
export declare function getDevBranch(): Promise<string>;
|
|
15
|
+
export declare function getIsRelease(passedBranch?: null | string, releaseOverride?: null | boolean): Promise<boolean>;
|
|
16
|
+
export declare function useVersionCache(useCache?: boolean): void;
|
|
17
|
+
export interface Version {
|
|
18
|
+
branch: string;
|
|
19
|
+
build: string;
|
|
20
|
+
info: string;
|
|
21
|
+
isRelease: boolean;
|
|
22
|
+
major: string;
|
|
23
|
+
minor: string;
|
|
24
|
+
name: string;
|
|
25
|
+
npm: string;
|
|
26
|
+
patch: string;
|
|
27
|
+
revision: string;
|
|
28
|
+
short: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function getVersion(logIt?: boolean, release?: null | boolean): Promise<Version>;
|
|
31
|
+
export declare function getBanner(): Promise<string>;
|
|
32
|
+
export declare function getVersionCode(): Promise<string>;
|
|
33
|
+
export declare function getUniqueBuildTag(): Promise<string>;
|
|
34
|
+
export {};
|
package/src/version.js
CHANGED
|
@@ -1,142 +1,101 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import fs from 'fs';
|
|
3
|
-
import { gitInfo } from './git';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const arg = process.argv.find((el) => /^--buildNum=\d+$/.test(el));
|
|
10
|
-
return (arg && arg.substr(11)) || process.env.BUILD_NUMBER || '0';
|
|
2
|
+
import { gitInfo } from './git.js';
|
|
3
|
+
import { getCfg, getPkg } from './pkg.js';
|
|
4
|
+
import { buildLog } from './run.js';
|
|
5
|
+
export function getBuild() {
|
|
6
|
+
const arg = process.argv.find((el) => /^--buildNum=\d+$/.test(el));
|
|
7
|
+
return (arg && arg.substring(11)) || process.env.BUILD_NUMBER || '0';
|
|
11
8
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return releaseBranch || 'master';
|
|
9
|
+
export function getReleaseBranch() {
|
|
10
|
+
const { releaseBranch } = getCfg();
|
|
11
|
+
return releaseBranch || 'master';
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
var RepoType;
|
|
14
|
+
(function (RepoType) {
|
|
15
|
+
RepoType["git"] = "git";
|
|
16
|
+
RepoType["hg"] = "hg";
|
|
17
|
+
RepoType["unknown"] = "unknown";
|
|
18
|
+
})(RepoType || (RepoType = {}));
|
|
19
|
+
export async function getRepoType() {
|
|
20
|
+
const { repoType } = getCfg();
|
|
21
|
+
return (repoType ||
|
|
22
|
+
(fs.existsSync('./.git')
|
|
23
|
+
? RepoType.git
|
|
24
|
+
: fs.existsSync('./.hg')
|
|
25
|
+
? RepoType.hg
|
|
26
|
+
: RepoType.unknown));
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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 };
|
|
28
|
+
export async function getRepoInfo() {
|
|
29
|
+
const repoType = await getRepoType();
|
|
30
|
+
if (repoType !== RepoType.git) {
|
|
31
|
+
throw new Error(`Unsupported repo type: ${repoType}`);
|
|
32
|
+
}
|
|
33
|
+
const { branch, revision } = await gitInfo();
|
|
34
|
+
if (!branch || !revision) {
|
|
35
|
+
throw new Error('Failed to parse branch and revision from source repo.');
|
|
36
|
+
}
|
|
37
|
+
return { branch, revision };
|
|
49
38
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return devBranch || (await getRepoType()) === 'hg' ? 'default' : 'dev';
|
|
39
|
+
export async function getDevBranch() {
|
|
40
|
+
const { devBranch } = getCfg();
|
|
41
|
+
return devBranch || ((await getRepoType()) === 'hg' ? 'default' : 'dev');
|
|
54
42
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
? releaseOverride
|
|
63
|
-
: process.argv.includes('--force-release-version')
|
|
64
|
-
? true
|
|
65
|
-
: branch === getReleaseBranch();
|
|
43
|
+
export async function getIsRelease(passedBranch = null, releaseOverride = null) {
|
|
44
|
+
const branch = passedBranch || (await getRepoInfo()).branch;
|
|
45
|
+
return releaseOverride != null
|
|
46
|
+
? releaseOverride
|
|
47
|
+
: process.argv.includes('--force-release-version')
|
|
48
|
+
? true
|
|
49
|
+
: branch === getReleaseBranch();
|
|
66
50
|
}
|
|
67
|
-
|
|
68
51
|
let cacheVersion = true;
|
|
69
|
-
export function useVersionCache(useCache
|
|
70
|
-
|
|
52
|
+
export function useVersionCache(useCache = true) {
|
|
53
|
+
cacheVersion = useCache;
|
|
71
54
|
}
|
|
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
55
|
let version = null;
|
|
88
|
-
export async function getVersion(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
npm,
|
|
118
|
-
info,
|
|
119
|
-
};
|
|
120
|
-
if (logIt) {
|
|
121
|
-
buildLog(`Building version ${info}`);
|
|
56
|
+
export async function getVersion(logIt = true, release = null) {
|
|
57
|
+
if (!cacheVersion || version == null) {
|
|
58
|
+
const { name, version: pkgVers } = getPkg();
|
|
59
|
+
const { branch, revision } = await getRepoInfo();
|
|
60
|
+
const [, major, minor, patch] = pkgVers.match(/^(\d+)\.(\d+)\.(\d+)$/) || [];
|
|
61
|
+
if (!major || !minor || !patch) {
|
|
62
|
+
throw new Error('Invalid version format in package.json');
|
|
63
|
+
}
|
|
64
|
+
const build = getBuild();
|
|
65
|
+
const isRelease = await getIsRelease(branch, release);
|
|
66
|
+
const short = `${major}.${minor}.${patch}`;
|
|
67
|
+
const npm = `${short}${isRelease ? '' : `-${branch}.${build}`}`;
|
|
68
|
+
const info = `${short}${isRelease ? `+${build}.` : `-${branch}.${build}+`}${revision}`;
|
|
69
|
+
version = {
|
|
70
|
+
branch,
|
|
71
|
+
build,
|
|
72
|
+
info,
|
|
73
|
+
isRelease,
|
|
74
|
+
major,
|
|
75
|
+
minor,
|
|
76
|
+
name,
|
|
77
|
+
npm,
|
|
78
|
+
patch,
|
|
79
|
+
revision,
|
|
80
|
+
short,
|
|
81
|
+
};
|
|
82
|
+
if (logIt) {
|
|
83
|
+
buildLog(`Building version ${info}`);
|
|
84
|
+
}
|
|
122
85
|
}
|
|
123
|
-
|
|
124
|
-
return version;
|
|
86
|
+
return version;
|
|
125
87
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return `${name} v${info} | (c) ${today.getFullYear()} ${copyright} | built on ${today.toISOString()}`;
|
|
88
|
+
export async function getBanner() {
|
|
89
|
+
const { copyright = '' } = getCfg();
|
|
90
|
+
const { info, name } = await getVersion();
|
|
91
|
+
const today = new Date();
|
|
92
|
+
return `${name} v${info} | (c) ${today.getFullYear()} ${copyright} | built on ${today.toISOString()}`;
|
|
132
93
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return `// This file is auto-generated
|
|
94
|
+
export async function getVersionCode() {
|
|
95
|
+
return `// This file is auto-generated
|
|
136
96
|
export const version = ${JSON.stringify(await getVersion(), null, 2)}`;
|
|
137
97
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return `${branch}-${revision}-${build}`;
|
|
98
|
+
export async function getUniqueBuildTag() {
|
|
99
|
+
const { branch, build, revision } = await getVersion();
|
|
100
|
+
return `${branch}-${revision}-${build}`;
|
|
142
101
|
}
|
package/src/yarn.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SpawnOptions, SpawnResult } from './cp.js';
|
|
2
|
+
import { NpmConfig, NpmCreds } from './npm.js';
|
|
3
|
+
export interface YarnOptions {
|
|
4
|
+
args?: string[];
|
|
5
|
+
spawnOptions?: SpawnOptions;
|
|
6
|
+
}
|
|
7
|
+
export declare function yarn({ args, spawnOptions, }?: YarnOptions): Promise<SpawnResult>;
|
|
8
|
+
export declare const yarnFiles: string[];
|
|
9
|
+
export interface YarnInstallOptions {
|
|
10
|
+
force?: boolean;
|
|
11
|
+
hashFilePath?: string;
|
|
12
|
+
nodeModulesPath?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function yarnInstall({ force, hashFilePath, nodeModulesPath, }?: YarnInstallOptions): Promise<void>;
|
|
15
|
+
export interface YarnUpgradeOptions {
|
|
16
|
+
/**
|
|
17
|
+
* `false` by default
|
|
18
|
+
* we assume any package with an explicit version shouldn't be touched
|
|
19
|
+
*/
|
|
20
|
+
all?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Use `yarn outdated` to find packages that should be upgraded
|
|
23
|
+
* May include breaking changes (major version changes)
|
|
24
|
+
*/
|
|
25
|
+
outdated?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function yarnUpgrade({ all, outdated, }?: YarnUpgradeOptions): Promise<void>;
|
|
28
|
+
export interface YarnPublishOptions {
|
|
29
|
+
npmAuthToken?: string;
|
|
30
|
+
npmConfig?: NpmConfig;
|
|
31
|
+
npmCreds?: NpmCreds;
|
|
32
|
+
npmPath?: string;
|
|
33
|
+
publishPath?: string;
|
|
34
|
+
skipExisting?: boolean;
|
|
35
|
+
tag?: string;
|
|
36
|
+
workDir?: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function yarnPublish({ npmAuthToken, npmConfig, npmCreds, npmPath, publishPath, skipExisting, tag, workDir: passedWorkDir, }?: YarnPublishOptions): Promise<boolean>;
|
|
39
|
+
interface YarnPackOptions {
|
|
40
|
+
destination: string;
|
|
41
|
+
workDir?: string;
|
|
42
|
+
}
|
|
43
|
+
export declare function yarnPack({ destination, workDir, }: YarnPackOptions): Promise<string>;
|
|
44
|
+
export {};
|