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/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# build-strap
|
|
2
|
-
A suite of functions to help with writing build scripts using javascript code (which run on node).
|
|
2
|
+
A suite of functions to help with writing build scripts using TypeScript (or javascript) code (which run on node).
|
|
3
3
|
|
|
4
|
-
This project builds itself, so take a look in the `
|
|
4
|
+
This project builds itself, so take a look in the `targets/` folder for an example. Run `./bs` to build.
|
|
5
5
|
|
|
6
6
|
[](https://github.com/murrayju/build-strap/actions?query=workflow%3A%22CI+Build%22)
|
|
7
7
|
[](https://github.com/murrayju/build-strap/releases/latest)
|
|
@@ -41,39 +41,14 @@ By default, the build tools read project-specific configuration from your `packa
|
|
|
41
41
|
"npm": {
|
|
42
42
|
"publish": true,
|
|
43
43
|
},
|
|
44
|
-
"artifactory": {
|
|
45
|
-
"root": "https://artifactory.your-company.com/artifactory/",
|
|
46
|
-
"path": "com/your-company/your-project-name",
|
|
47
|
-
"version-folders": false,
|
|
48
|
-
"integration": "integration-repo",
|
|
49
|
-
"integration-branch-folders": true,
|
|
50
|
-
"integration-days-to-keep": 14,
|
|
51
|
-
"integration-max-to-keep": 10,
|
|
52
|
-
"release": "releases-repo",
|
|
53
|
-
"release-branch": "master",
|
|
54
|
-
"npm": "npm-repo",
|
|
55
|
-
"npm-clean": "internal-npm-repo"
|
|
56
|
-
},
|
|
57
44
|
"docker": {
|
|
58
|
-
"registry": "
|
|
45
|
+
"registry": "ghcr.io",
|
|
59
46
|
"repository": "your-company",
|
|
60
47
|
"name": "your-project-name"
|
|
61
48
|
}
|
|
62
49
|
}
|
|
63
50
|
}
|
|
64
51
|
```
|
|
65
|
-
### artifactory
|
|
66
|
-
* **root**: base URL for the artifactory server
|
|
67
|
-
* **path**: path to project root in the artifactory tree.
|
|
68
|
-
* **version-folders**: if `true`, artifacts will be organized into subfolders for each version number
|
|
69
|
-
* **integration**: name of the artifactory repo in which to place integration (not official release) artifacts.
|
|
70
|
-
* **integration-branch-folders**: if `true`, artifacts will be organized into subfolders for each branch.
|
|
71
|
-
* **integration-days-to-keep**: for artifact cleanup, specifies the max age in days before an artifact will be deleted.
|
|
72
|
-
* **integration-max-to-keep**: for artifact cleanup, specifies the maximum number of artifacts to keep, regardless of age. Only the newest N artifacts will be kept.
|
|
73
|
-
* **release**: name of the artifactory repo in which to place release artifacts.
|
|
74
|
-
* **release-branch**: name of the mercurial branch from which official releases are built/published. Defaults to `master`.
|
|
75
|
-
* **npm**: name of the artifactory repo in which to publish npm artifacts.
|
|
76
|
-
* **npm-clean**: for artifact cleanup, the name of the artifactory repo used to find and delete old npm artifacts.
|
|
77
52
|
|
|
78
53
|
### docker
|
|
79
54
|
* **registry**: base URL for the docker registry, as needed by `docker push`.
|
|
@@ -135,9 +110,3 @@ In order to publish to NPM, proper credentials must be provided to the script. B
|
|
|
135
110
|
```
|
|
136
111
|
{ "email": "builder@your-company.com", "username":"builder", "password":"abc123" }
|
|
137
112
|
```
|
|
138
|
-
|
|
139
|
-
## Artifactory Credentials
|
|
140
|
-
In order to publish and/or delete things from Artifactory, proper credentials must be provided to the script. By default, these are read from the `ARTIFACTORY_CREDS` environment variable, but it is also possible to pass them as an argument to most functions. This is expected to be a JSON encoded string in the following format:
|
|
141
|
-
```
|
|
142
|
-
{ "email": "builder@your-company.com", "username":"builder", "password":"abc123" }
|
|
143
|
-
```
|
package/package.json
CHANGED
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "build-strap",
|
|
3
|
-
"version": "4.0.0-dev.
|
|
4
|
-
"
|
|
3
|
+
"version": "4.0.0-dev.54",
|
|
4
|
+
"description": "Node scripts for building things",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"authors": [
|
|
7
|
+
"Justin Murray <justin@murrayju.com>"
|
|
8
|
+
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/murrayju/build-strap"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./src/index.js",
|
|
15
|
+
"types": "./src/index.d.ts",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=16"
|
|
18
|
+
},
|
|
5
19
|
"dependencies": {
|
|
6
|
-
"bytes": "3",
|
|
20
|
+
"bytes": "^3.1.1",
|
|
7
21
|
"chokidar": "^3.5.2",
|
|
8
22
|
"cross-spawn": "^7.0.3",
|
|
9
23
|
"fs-extra": "^10.0.0",
|
|
10
|
-
"get-port": "^
|
|
11
|
-
"glob": "^7.
|
|
12
|
-
"is-reachable": "^5.
|
|
24
|
+
"get-port": "^6.0.0",
|
|
25
|
+
"glob": "^7.2.0",
|
|
26
|
+
"is-reachable": "^5.1.1",
|
|
13
27
|
"js-yaml": "^4.1.0",
|
|
14
|
-
"lodash": "^4.17.21",
|
|
15
|
-
"md5-file": "^5.0.0",
|
|
28
|
+
"lodash-es": "^4.17.21",
|
|
16
29
|
"moment": "^2.29.1",
|
|
17
|
-
"
|
|
18
|
-
"request-promise-native": "^1.0.9",
|
|
19
|
-
"rimraf": "^3.0.2",
|
|
20
|
-
"set-value": "^4.0.1",
|
|
21
|
-
"source-map-support": "^0.5.16",
|
|
30
|
+
"node-fetch": "^3.1.0",
|
|
22
31
|
"stream-counter": "1",
|
|
23
|
-
"tar": "^6.1.
|
|
32
|
+
"tar": "^6.1.11",
|
|
24
33
|
"url-join": "^4.0.1"
|
|
25
|
-
},
|
|
26
|
-
"peerDependencies": {},
|
|
27
|
-
"engines": {
|
|
28
|
-
"node": ">=7",
|
|
29
|
-
"npm": ">=4"
|
|
30
34
|
}
|
|
31
35
|
}
|
package/src/ant.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SpawnOptions } from './cp.js';
|
|
2
|
+
/**
|
|
3
|
+
* Named value pair to use when configuring an Ant build property
|
|
4
|
+
*/
|
|
5
|
+
export interface AntPropertyConfiguration {
|
|
6
|
+
name: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AntSpawnOptions {
|
|
10
|
+
args?: string[];
|
|
11
|
+
properties?: AntPropertyConfiguration[];
|
|
12
|
+
spawnOptions?: SpawnOptions;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Executes the given ant command
|
|
16
|
+
* @param {string} target the ant target to invoke
|
|
17
|
+
* @param {AntSpawnOptions} options
|
|
18
|
+
*/
|
|
19
|
+
export declare function ant(target: string, opts?: AntSpawnOptions): Promise<void>;
|
package/src/ant.js
CHANGED
|
@@ -1,42 +1,18 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
1
|
+
import { spawn } from './cp.js';
|
|
19
2
|
/**
|
|
20
3
|
* Executes the given ant command
|
|
21
4
|
* @param {string} target the ant target to invoke
|
|
22
5
|
* @param {AntSpawnOptions} options
|
|
23
6
|
*/
|
|
24
|
-
export async function ant(target
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
[
|
|
36
|
-
target,
|
|
37
|
-
...args,
|
|
38
|
-
...properties.map(({ name, value }) => `-D${name}=${value}`),
|
|
39
|
-
],
|
|
40
|
-
execOptions,
|
|
41
|
-
);
|
|
7
|
+
export async function ant(target, opts) {
|
|
8
|
+
const { properties = [], args = [], spawnOptions } = opts || {};
|
|
9
|
+
await spawn('ant', [
|
|
10
|
+
target,
|
|
11
|
+
...args,
|
|
12
|
+
...properties.map(({ name, value }) => `-D${name}=${value}`),
|
|
13
|
+
], {
|
|
14
|
+
pipeOutput: true,
|
|
15
|
+
stdio: 'inherit',
|
|
16
|
+
...spawnOptions,
|
|
17
|
+
});
|
|
42
18
|
}
|
package/src/cert.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface CertConfig {
|
|
2
|
+
commonName?: string;
|
|
3
|
+
countryName?: string;
|
|
4
|
+
emailAddress?: string;
|
|
5
|
+
localityName?: string;
|
|
6
|
+
organizationName?: string;
|
|
7
|
+
organizationalUnitName?: string;
|
|
8
|
+
stateOrProvinceName?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const getCertConfig: () => CertConfig;
|
|
11
|
+
export declare const getIpAddresses: () => string[];
|
|
12
|
+
export declare function generateCert(targetDir: string, force?: boolean): Promise<void>;
|
package/src/cert.js
CHANGED
|
@@ -1,152 +1,91 @@
|
|
|
1
|
-
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import fetch from 'node-fetch';
|
|
2
3
|
import os from 'os';
|
|
3
|
-
import rp from 'request-promise-native';
|
|
4
4
|
import path from 'path';
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export type CertConfig = {
|
|
12
|
-
countryName?: string,
|
|
13
|
-
stateOrProvinceName?: string,
|
|
14
|
-
localityName?: string,
|
|
15
|
-
organizationName?: string,
|
|
16
|
-
organizationalUnitName?: string,
|
|
17
|
-
commonName?: string,
|
|
18
|
-
emailAddress?: string,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export function getCertConfig(): CertConfig {
|
|
22
|
-
return getCfg().cert || {};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function getIpAddresses(): string[] {
|
|
26
|
-
const iFaces = os.networkInterfaces();
|
|
27
|
-
return Object.keys(iFaces).reduce(
|
|
28
|
-
(prev, ifName) => [
|
|
29
|
-
...prev,
|
|
30
|
-
...iFaces[ifName].map((iFace) => iFace.address),
|
|
31
|
-
],
|
|
32
|
-
[],
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
5
|
+
import { spawn } from './cp.js';
|
|
6
|
+
import { readDir } from './fs.js';
|
|
7
|
+
import { getCfg } from './pkg.js';
|
|
8
|
+
import { buildLog } from './run.js';
|
|
9
|
+
export const getCertConfig = () => getCfg().cert ?? {};
|
|
10
|
+
export const getIpAddresses = () => Object.values(os.networkInterfaces()).flatMap((iFaces) => iFaces?.map((iFace) => iFace.address) ?? []);
|
|
36
11
|
// Generate a self-signed certificate (if it doesn't exist)
|
|
37
|
-
export async function generateCert(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
buildLog(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
'openssl',
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
'req',
|
|
117
|
-
'-new',
|
|
118
|
-
'-key',
|
|
119
|
-
keyFile,
|
|
120
|
-
'-out',
|
|
121
|
-
csrFile,
|
|
122
|
-
'-subj',
|
|
123
|
-
`/C=${countryName}/ST=${stateOrProvinceName}/L=${localityName}/O=${organizationName}/OU=${organizationalUnitName}/CN=${commonName}/CN=${externalIp4}/CN=${hostname}/CN=${dnsName}${ipAddresses.reduce(
|
|
124
|
-
(acc, next) => `${acc}/CN=${next}`,
|
|
125
|
-
)}/CN=localhost`,
|
|
126
|
-
'-config',
|
|
127
|
-
confFile,
|
|
128
|
-
],
|
|
129
|
-
{ pipeOutput: true },
|
|
130
|
-
);
|
|
131
|
-
buildLog('generating cert...');
|
|
132
|
-
await spawn(
|
|
133
|
-
'openssl',
|
|
134
|
-
[
|
|
135
|
-
'x509',
|
|
136
|
-
'-req',
|
|
137
|
-
'-days',
|
|
138
|
-
'365',
|
|
139
|
-
'-in',
|
|
140
|
-
csrFile,
|
|
141
|
-
'-signkey',
|
|
142
|
-
keyFile,
|
|
143
|
-
'-out',
|
|
144
|
-
crtFile,
|
|
145
|
-
'-extfile',
|
|
146
|
-
confFile,
|
|
147
|
-
'-extensions',
|
|
148
|
-
'v3_req',
|
|
149
|
-
],
|
|
150
|
-
{ pipeOutput: true },
|
|
151
|
-
);
|
|
12
|
+
export async function generateCert(targetDir, force = process.argv.includes('--force-generateCert')) {
|
|
13
|
+
if (process.argv.includes('--no-generateCert')) {
|
|
14
|
+
buildLog('Skipping due to --no-generateCert');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
buildLog(`scanning ${targetDir} for certificates...`);
|
|
18
|
+
if (!force &&
|
|
19
|
+
(await readDir(`${targetDir}/server.@(crt|key)`)).length === 2) {
|
|
20
|
+
buildLog('Skipping certificate generation: certificate already exists');
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
buildLog('Generating self-signed certificate...');
|
|
24
|
+
const { commonName = 'app.company.com', countryName = 'US', emailAddress = 'contact@company.com', localityName = 'SomeCity', organizationName = 'Company', organizationalUnitName = 'Product', stateOrProvinceName = 'Pennsylvania', } = getCertConfig();
|
|
25
|
+
const hostname = os.hostname();
|
|
26
|
+
buildLog(`hostname: ${hostname}`);
|
|
27
|
+
const ipAddresses = getIpAddresses();
|
|
28
|
+
buildLog(`ip addresses: ${JSON.stringify(ipAddresses)}`);
|
|
29
|
+
const ifconfig = await fetch('https://ifconfig.co').then((r) => r.json());
|
|
30
|
+
const externalIp4 = ifconfig.ip;
|
|
31
|
+
buildLog(`external ipv4: ${externalIp4}`);
|
|
32
|
+
const dnsName = ifconfig.hostname;
|
|
33
|
+
buildLog(`dnsName: ${dnsName}`);
|
|
34
|
+
await fs.ensureDir(targetDir);
|
|
35
|
+
const keyFile = path.resolve(targetDir, 'server.key');
|
|
36
|
+
const csrFile = path.resolve(targetDir, 'server.csr');
|
|
37
|
+
const crtFile = path.resolve(targetDir, 'server.crt');
|
|
38
|
+
const confTemplateFile = path.resolve(__dirname, 'cert.conf');
|
|
39
|
+
const confFile = path.resolve(targetDir, 'cert.conf.generated');
|
|
40
|
+
const confTemplate = await fs.readFile(confTemplateFile, 'utf8');
|
|
41
|
+
await fs.writeFile(confFile, confTemplate
|
|
42
|
+
.replace('{{countryName}}', countryName)
|
|
43
|
+
.replace('{{stateOrProvinceName}}', stateOrProvinceName)
|
|
44
|
+
.replace('{{localityName}}', localityName)
|
|
45
|
+
.replace('{{organizationName}}', organizationName)
|
|
46
|
+
.replace('{{organizationalUnitName}}', organizationalUnitName)
|
|
47
|
+
.replace('{{commonName}}', commonName)
|
|
48
|
+
.replace('{{emailAddress}}', emailAddress)
|
|
49
|
+
.replace('{{SAN_IP}}', ipAddresses.reduce((acc, next) => `${acc},IP:${next}`, ''))
|
|
50
|
+
.replace('{{SAN_DNS}}', `,DNS:${hostname},DNS:${dnsName}`), 'utf8');
|
|
51
|
+
buildLog('generating key file...');
|
|
52
|
+
await spawn('openssl', [
|
|
53
|
+
'genpkey',
|
|
54
|
+
'-algorithm',
|
|
55
|
+
'RSA',
|
|
56
|
+
'-pkeyopt',
|
|
57
|
+
'rsa_keygen_bits:2048',
|
|
58
|
+
'-out',
|
|
59
|
+
keyFile,
|
|
60
|
+
], { pipeOutput: true });
|
|
61
|
+
buildLog('generating csr file...');
|
|
62
|
+
await spawn('openssl', [
|
|
63
|
+
'req',
|
|
64
|
+
'-new',
|
|
65
|
+
'-key',
|
|
66
|
+
keyFile,
|
|
67
|
+
'-out',
|
|
68
|
+
csrFile,
|
|
69
|
+
'-subj',
|
|
70
|
+
`/C=${countryName}/ST=${stateOrProvinceName}/L=${localityName}/O=${organizationName}/OU=${organizationalUnitName}/CN=${commonName}/CN=${externalIp4}/CN=${hostname}/CN=${dnsName}${ipAddresses.reduce((acc, next) => `${acc}/CN=${next}`)}/CN=localhost`,
|
|
71
|
+
'-config',
|
|
72
|
+
confFile,
|
|
73
|
+
], { pipeOutput: true });
|
|
74
|
+
buildLog('generating cert...');
|
|
75
|
+
await spawn('openssl', [
|
|
76
|
+
'x509',
|
|
77
|
+
'-req',
|
|
78
|
+
'-days',
|
|
79
|
+
'365',
|
|
80
|
+
'-in',
|
|
81
|
+
csrFile,
|
|
82
|
+
'-signkey',
|
|
83
|
+
keyFile,
|
|
84
|
+
'-out',
|
|
85
|
+
crtFile,
|
|
86
|
+
'-extfile',
|
|
87
|
+
confFile,
|
|
88
|
+
'-extensions',
|
|
89
|
+
'v3_req',
|
|
90
|
+
], { pipeOutput: true });
|
|
152
91
|
}
|
package/src/clean.d.ts
ADDED
package/src/clean.js
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { cleanDir } from './fs';
|
|
3
|
-
|
|
1
|
+
import { cleanDir } from './fs.js';
|
|
4
2
|
/**
|
|
5
3
|
* Cleans up the build output directories.
|
|
6
4
|
*/
|
|
7
|
-
export async function clean(
|
|
8
|
-
|
|
9
|
-
): Promise<void> {
|
|
10
|
-
await Promise.all(
|
|
11
|
-
globs.map((glob) =>
|
|
12
|
-
cleanDir(glob, {
|
|
13
|
-
nosort: true,
|
|
5
|
+
export async function clean(globs = ['dist/*', 'out/*', 'build/*']) {
|
|
6
|
+
await Promise.all(globs.map((glob) => cleanDir(glob, {
|
|
14
7
|
dot: true,
|
|
15
8
|
ignore: ['.git', '.hg'],
|
|
16
|
-
|
|
17
|
-
)
|
|
18
|
-
);
|
|
9
|
+
nosort: true,
|
|
10
|
+
})));
|
|
19
11
|
}
|
package/src/copy.d.ts
ADDED
package/src/copy.js
CHANGED
|
@@ -1,79 +1,53 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import path from 'path';
|
|
3
1
|
import chokidar from 'chokidar';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { onKillSignal } from './cp.js';
|
|
5
|
+
import { cleanDir, copyDir } from './fs.js';
|
|
6
|
+
import { buildLog } from './run.js';
|
|
9
7
|
let timer = null;
|
|
10
8
|
async function throttledCallback(cbFn) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
if (!cbFn || typeof cbFn !== 'function') {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (timer) {
|
|
13
|
+
clearTimeout(timer);
|
|
14
|
+
timer = null;
|
|
15
|
+
}
|
|
16
|
+
timer = setTimeout(() => {
|
|
17
|
+
timer = null;
|
|
18
|
+
cbFn();
|
|
19
|
+
}, 200);
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
case 'unlinkDir':
|
|
56
|
-
cleanDir(dest, { nosort: true, dot: true });
|
|
57
|
-
break;
|
|
58
|
-
default:
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
// Check dependencies
|
|
62
|
-
if (dependencies[dest]) {
|
|
63
|
-
await Promise.all(
|
|
64
|
-
dependencies[dest].map(async (dep) => {
|
|
65
|
-
const toCopy = path.join(from, path.relative(to, dep));
|
|
66
|
-
await copyFile(toCopy, dep);
|
|
67
|
-
buildLog(`copied '${dep}' due to changed dependency`);
|
|
68
|
-
}),
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
const end = new Date();
|
|
72
|
-
const time = end.getTime() - start.getTime();
|
|
73
|
-
buildLog(`${event} '${dest}' after ${time} ms`, end);
|
|
74
|
-
throttledCallback(cbFn);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
onKillSignal(() => watcher.close());
|
|
78
|
-
}
|
|
21
|
+
export async function copySrc({ from, to, watch = process.argv.includes('--watch'), cbFn, }) {
|
|
22
|
+
await copyDir(from, to);
|
|
23
|
+
if (cbFn)
|
|
24
|
+
await cbFn();
|
|
25
|
+
if (watch) {
|
|
26
|
+
const watcher = chokidar.watch([path.join(from, '/**/*')], {
|
|
27
|
+
ignoreInitial: true,
|
|
28
|
+
});
|
|
29
|
+
watcher.on('all', async (event, filePath) => {
|
|
30
|
+
const start = new Date();
|
|
31
|
+
const src = path.relative(from, filePath);
|
|
32
|
+
const dest = path.join(to, src);
|
|
33
|
+
switch (event) {
|
|
34
|
+
case 'add':
|
|
35
|
+
case 'change':
|
|
36
|
+
await fs.ensureDir(path.dirname(dest));
|
|
37
|
+
await fs.copyFile(filePath, dest);
|
|
38
|
+
break;
|
|
39
|
+
case 'unlink':
|
|
40
|
+
case 'unlinkDir':
|
|
41
|
+
cleanDir(dest, { dot: true, nosort: true });
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const end = new Date();
|
|
47
|
+
const time = end.getTime() - start.getTime();
|
|
48
|
+
buildLog(`${event} '${dest}' after ${time} ms`, end);
|
|
49
|
+
throttledCallback(cbFn);
|
|
50
|
+
});
|
|
51
|
+
onKillSignal(() => watcher.close());
|
|
52
|
+
}
|
|
79
53
|
}
|
package/src/cp.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import cp from 'child_process';
|
|
3
|
+
export interface SpawnOptions extends cp.SpawnOptions {
|
|
4
|
+
captureOutput?: boolean;
|
|
5
|
+
pipeOutput?: boolean;
|
|
6
|
+
rejectOnErrorCode?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SpawnResult {
|
|
9
|
+
code: number;
|
|
10
|
+
output: string;
|
|
11
|
+
signal: string;
|
|
12
|
+
stderr: string;
|
|
13
|
+
stdout: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function spawn(command: string, args?: string[], opts?: SpawnOptions | null): Promise<SpawnResult>;
|
|
16
|
+
export declare const exec: typeof cp.exec.__promisify__;
|
|
17
|
+
export declare const onKillSignal: (cbFn: () => void) => void;
|