build-strap 5.0.7-dev.116 → 5.1.0-dev.118

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "build-strap",
3
- "version": "5.0.7-dev.116",
3
+ "version": "5.1.0-dev.118",
4
4
  "description": "Node scripts for building things",
5
5
  "license": "MIT",
6
6
  "authors": [
@@ -14,22 +14,22 @@
14
14
  "main": "./src/index.js",
15
15
  "types": "./src/index.d.ts",
16
16
  "engines": {
17
- "node": ">=16"
17
+ "node": ">=20"
18
18
  },
19
19
  "dependencies": {
20
20
  "bytes": "^3.1.1",
21
- "chokidar": "^3.5.2",
21
+ "chokidar": "^3.6.0",
22
22
  "cross-spawn": "^7.0.3",
23
- "fs-extra": "^11.1.0",
24
- "get-port": "^6.0.0",
25
- "glob": "^8.0.1",
23
+ "fs-extra": "^11.2.0",
24
+ "get-port": "^7.1.0",
25
+ "glob": "^10.3.14",
26
26
  "is-reachable": "^5.1.1",
27
27
  "js-yaml": "^4.1.0",
28
28
  "lodash-es": "^4.17.21",
29
- "moment": "^2.29.1",
30
- "node-fetch": "^3.1.0",
31
- "rimraf": "^3.0.2",
29
+ "moment": "^2.30.1",
30
+ "node-fetch": "^3.3.2",
31
+ "rimraf": "^5.0.5",
32
32
  "stream-counter": "1",
33
- "tar": "^6.1.11"
33
+ "tar": "^7.1.0"
34
34
  }
35
35
  }
package/src/ant.js CHANGED
@@ -5,7 +5,7 @@ import { spawn } from './cp.js';
5
5
  * @param {AntSpawnOptions} options
6
6
  */
7
7
  export async function ant(target, opts) {
8
- const { properties = [], args = [], spawnOptions } = opts || {};
8
+ const { args = [], properties = [], spawnOptions } = opts || {};
9
9
  await spawn('ant', [
10
10
  target,
11
11
  ...args,
package/src/clean.js CHANGED
@@ -6,6 +6,5 @@ export async function clean(globs = ['dist/*', 'out/*', 'build/*']) {
6
6
  await Promise.all(globs.map((glob) => cleanDir(glob, {
7
7
  dot: true,
8
8
  ignore: ['.git', '.hg'],
9
- nosort: true,
10
9
  })));
11
10
  }
package/src/copy.d.ts CHANGED
@@ -4,4 +4,4 @@ export interface CopySrcOptions {
4
4
  to: string;
5
5
  watch?: boolean;
6
6
  }
7
- export declare function copySrc({ from, to, watch, cbFn, }: CopySrcOptions): Promise<void>;
7
+ export declare function copySrc({ cbFn, from, to, watch, }: CopySrcOptions): Promise<void>;
package/src/copy.js CHANGED
@@ -18,7 +18,7 @@ async function throttledCallback(cbFn) {
18
18
  cbFn();
19
19
  }, 200);
20
20
  }
21
- export async function copySrc({ from, to, watch = process.argv.includes('--watch'), cbFn, }) {
21
+ export async function copySrc({ cbFn, from, to, watch = process.argv.includes('--watch'), }) {
22
22
  await copyDir(from, to);
23
23
  if (cbFn)
24
24
  await cbFn();
@@ -38,7 +38,7 @@ export async function copySrc({ from, to, watch = process.argv.includes('--watch
38
38
  break;
39
39
  case 'unlink':
40
40
  case 'unlinkDir':
41
- cleanDir(dest, { dot: true, nosort: true });
41
+ cleanDir(dest, { dot: true });
42
42
  break;
43
43
  default:
44
44
  return;
@@ -59,8 +59,8 @@ interface DockerContainerRunDaemonArgs {
59
59
  interface DockerContainerRunArgs extends DockerContainerRunDaemonArgs {
60
60
  spawnOptions?: SpawnOptions | null;
61
61
  }
62
- export declare function dockerContainerRun({ image, runArgs, cmd, spawnOptions, }: DockerContainerRunArgs): Promise<string>;
63
- export declare function dockerContainerRunDaemon({ image, runArgs, cmd, waitAttempts, waitDuration, }: DockerContainerRunDaemonArgs): Promise<DockerContainer>;
62
+ export declare function dockerContainerRun({ cmd, image, runArgs, spawnOptions, }: DockerContainerRunArgs): Promise<string>;
63
+ export declare function dockerContainerRunDaemon({ cmd, image, runArgs, waitAttempts, waitDuration, }: DockerContainerRunDaemonArgs): Promise<DockerContainer>;
64
64
  /**
65
65
  * Waits for the given container to be fully started. Checks that the container is
66
66
  * running, and test with the provided testFn every second until it returns true.
@@ -170,14 +170,14 @@ export async function unthrottledDockerContainerInspect(id) {
170
170
  export const dockerContainerInspect = throttle(unthrottledDockerContainerInspect, 500, {
171
171
  trailing: false,
172
172
  });
173
- export async function dockerContainerRun({ image, runArgs = [], cmd = [], spawnOptions, }) {
173
+ export async function dockerContainerRun({ cmd = [], image, runArgs = [], spawnOptions, }) {
174
174
  return (await spawn('docker', ['container', 'run', ...runArgs, image, ...cmd], {
175
175
  pipeOutput: true,
176
176
  stdio: 'inherit',
177
177
  ...spawnOptions,
178
178
  })).output;
179
179
  }
180
- export async function dockerContainerRunDaemon({ image, runArgs = [], cmd = [], waitAttempts = 10, waitDuration = 501, }) {
180
+ export async function dockerContainerRunDaemon({ cmd = [], image, runArgs = [], waitAttempts = 10, waitDuration = 501, }) {
181
181
  const id = (await dockerContainerRun({
182
182
  cmd,
183
183
  image,
package/src/docker.js CHANGED
@@ -140,7 +140,7 @@ export function getDockerRepo() {
140
140
  return `${registry ? `${registry}/` : ''}${repository}/${name}`;
141
141
  }
142
142
  export async function dockerPullAndRunContainer(options) {
143
- const { image, runArgs = [], cmd = [], network, alias, offline = process.argv.includes('--offline'), testUrl, } = options;
143
+ const { alias, cmd = [], image, network, offline = process.argv.includes('--offline'), runArgs = [], testUrl, } = options;
144
144
  try {
145
145
  await dockerPull({ image, offline, testUrl });
146
146
  }
@@ -27,7 +27,7 @@ export interface DockerNetworkCreateOptions {
27
27
  labels?: string[];
28
28
  subnets?: string[];
29
29
  }
30
- export declare function dockerNetworkCreate(networkName: string, { driver, driverOpts, ipRange, gateways, subnets, auxAddresses, ingress, internal, ipv6, labels, }?: DockerNetworkCreateOptions): Promise<DockerNetwork | null>;
30
+ export declare function dockerNetworkCreate(networkName: string, { auxAddresses, driver, driverOpts, gateways, ingress, internal, ipRange, ipv6, labels, subnets, }?: DockerNetworkCreateOptions): Promise<DockerNetwork | null>;
31
31
  /**
32
32
  * Removes a network by id
33
33
  * @param {string} id The id of the network
@@ -31,7 +31,7 @@ export const dockerNetworkLs = throttle(unthrottledDockerNetworkLs, 500, {
31
31
  export async function dockerNetworkFind(networkName, options) {
32
32
  return ((await dockerNetworkLs(options))?.find((n) => n.name === networkName || n.id === networkName) || null);
33
33
  }
34
- export async function dockerNetworkCreate(networkName, { driver, driverOpts = {}, ipRange, gateways = [], subnets = [], auxAddresses = [], ingress, internal, ipv6, labels = [], } = {}) {
34
+ export async function dockerNetworkCreate(networkName, { auxAddresses = [], driver, driverOpts = {}, gateways = [], ingress, internal, ipRange, ipv6, labels = [], subnets = [], } = {}) {
35
35
  const existing = await dockerNetworkFind(networkName);
36
36
  if (existing)
37
37
  return existing;
@@ -19,7 +19,7 @@ export interface DockerVolumeCreateOptions {
19
19
  driverOpts?: Record<string, string>;
20
20
  labels?: string[];
21
21
  }
22
- export declare function dockerVolumeCreate(name: string, { labels, driver, driverOpts }?: DockerVolumeCreateOptions): Promise<null | DockerVolume>;
22
+ export declare function dockerVolumeCreate(name: string, { driver, driverOpts, labels }?: DockerVolumeCreateOptions): Promise<null | DockerVolume>;
23
23
  export declare function dockerVolumeRm(id: string | string[], ignoreErrors?: boolean): Promise<void>;
24
24
  export declare function unthrottledDockerVolumeInspect(id: string | string[]): Promise<DockerVolumeInspectOutput[]>;
25
25
  export declare const dockerVolumeInspect: (id: string | string[]) => undefined | Promise<DockerVolumeInspectOutput[]>;
@@ -28,7 +28,7 @@ export const dockerVolumeLs = throttle(unthrottledDockerVolumeLs, 500, {
28
28
  export async function dockerVolumeFind(search, options) {
29
29
  return ((await dockerVolumeLs(options))?.find((v) => v.name === search || v.name.startsWith(search)) ?? null);
30
30
  }
31
- export async function dockerVolumeCreate(name, { labels = [], driver, driverOpts = {} } = {}) {
31
+ export async function dockerVolumeCreate(name, { driver, driverOpts = {}, labels = [] } = {}) {
32
32
  const existing = await dockerVolumeFind(name);
33
33
  if (existing)
34
34
  return existing;
@@ -28,7 +28,7 @@ interface DockerImageCleanupOptions extends CommonDockerCleanupOptions {
28
28
  /**
29
29
  * Purge docker images created during build process
30
30
  */
31
- export declare const dockerImageCleanup: ({ repos, buildImageIds, images, purgeAll, purgeOld, dryRun, }?: DockerImageCleanupOptions) => Promise<void>;
31
+ export declare const dockerImageCleanup: ({ buildImageIds, dryRun, images, purgeAll, purgeOld, repos, }?: DockerImageCleanupOptions) => Promise<void>;
32
32
  interface DockerCleanupOptions extends DockerImageCleanupOptions, CommonDockerCleanupOptions {
33
33
  }
34
34
  /**
@@ -38,7 +38,7 @@ export const dockerContainerCleanup = async ({ dryRun = process.argv.includes('-
38
38
  /**
39
39
  * Purge docker images created during build process
40
40
  */
41
- export const dockerImageCleanup = async ({ repos = [getDockerRepo()], buildImageIds = [], images = [], purgeAll = process.argv.includes('--purge-all'), purgeOld = !process.argv.includes('--keep-old'), dryRun = process.argv.includes('--dry-run'), } = {}) => {
41
+ export const dockerImageCleanup = async ({ buildImageIds = [], dryRun = process.argv.includes('--dry-run'), images = [], purgeAll = process.argv.includes('--purge-all'), purgeOld = !process.argv.includes('--keep-old'), repos = [getDockerRepo()], } = {}) => {
42
42
  // only match images without a :latest tag
43
43
  const filterLatest = (m) => purgeAll || !m.tag.match(/^latest(-\w+)?$/);
44
44
  // only match images more than an hour old, AND without a :latest* tag
@@ -124,7 +124,7 @@ export declare class DockerComposeService {
124
124
  getBaseRunArgs(): Promise<string[]>;
125
125
  assembleRunArgs(containerName?: string, aliases?: string[], additionalArgs?: null | string[]): Promise<string[]>;
126
126
  getRunArgs(avoidConflicts?: boolean, mapLocalPorts?: boolean): Promise<string[]>;
127
- up({ healthCheck, avoidConflicts, mapVolumes, mapPorts, cmd, tracker, }?: UpOptions): Promise<UpResult>;
127
+ up({ avoidConflicts, cmd, healthCheck, mapPorts, mapVolumes, tracker, }?: UpOptions): Promise<UpResult>;
128
128
  down({ includeDefaults, includeNetworks, includeVolumes, }?: {
129
129
  includeDefaults?: boolean;
130
130
  includeNetworks?: boolean;
@@ -134,7 +134,7 @@ export declare class DockerComposeService {
134
134
  static getUrls(ports: PortMap[], alias: string): UrlMap[];
135
135
  }
136
136
  export declare function dockerComposeGetAllServices(dockerCompose?: null | (string | DockerCompose)): Promise<Record<string, null | DockerComposeService>>;
137
- export declare function dockerComposeTeardown({ includeDefaults, includeVolumes, includeNetworks, dockerCompose, tracker, }?: {
137
+ export declare function dockerComposeTeardown({ dockerCompose, includeDefaults, includeNetworks, includeVolumes, tracker, }?: {
138
138
  dockerCompose?: null | (string | DockerCompose);
139
139
  includeDefaults?: boolean;
140
140
  includeNetworks?: boolean;
@@ -1,15 +1,3 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _DockerComposeService_name, _DockerComposeService_svcDef, _DockerComposeService_dockerCompose, _DockerComposeService_tracker, _DockerComposeService_parsedPorts, _DockerComposeService_parsedNetworks, _DockerComposeService_parsedVolumes, _DockerComposeService_baseRunArgs;
13
1
  import fs from 'fs-extra';
14
2
  import getPort from 'get-port';
15
3
  import yaml from 'js-yaml';
@@ -127,37 +115,37 @@ export const dockerComposeCreateVolumes = async (names, dockerCompose, tracker =
127
115
  }));
128
116
  };
129
117
  export class DockerComposeService {
118
+ #name;
119
+ #svcDef;
120
+ #dockerCompose;
121
+ #tracker = dockerComposeCreateResourceTracker();
122
+ // lazily computed
123
+ #parsedPorts = null;
124
+ #parsedNetworks = null;
125
+ #parsedVolumes = null;
126
+ #baseRunArgs = null;
130
127
  constructor(name, serviceDef, dockerCompose) {
131
- _DockerComposeService_name.set(this, void 0);
132
- _DockerComposeService_svcDef.set(this, void 0);
133
- _DockerComposeService_dockerCompose.set(this, void 0);
134
- _DockerComposeService_tracker.set(this, dockerComposeCreateResourceTracker());
135
- // lazily computed
136
- _DockerComposeService_parsedPorts.set(this, null);
137
- _DockerComposeService_parsedNetworks.set(this, null);
138
- _DockerComposeService_parsedVolumes.set(this, null);
139
- _DockerComposeService_baseRunArgs.set(this, null);
140
- __classPrivateFieldSet(this, _DockerComposeService_name, name, "f");
141
- __classPrivateFieldSet(this, _DockerComposeService_svcDef, serviceDef, "f");
142
- __classPrivateFieldSet(this, _DockerComposeService_dockerCompose, dockerCompose || null, "f");
128
+ this.#name = name;
129
+ this.#svcDef = serviceDef;
130
+ this.#dockerCompose = dockerCompose || null;
143
131
  }
144
132
  get name() {
145
- return __classPrivateFieldGet(this, _DockerComposeService_name, "f");
133
+ return this.#name;
146
134
  }
147
135
  get serviceDef() {
148
- return __classPrivateFieldGet(this, _DockerComposeService_svcDef, "f");
136
+ return this.#svcDef;
149
137
  }
150
138
  get image() {
151
- return __classPrivateFieldGet(this, _DockerComposeService_svcDef, "f").image || null;
139
+ return this.#svcDef.image || null;
152
140
  }
153
141
  get defaultContainerName() {
154
- return __classPrivateFieldGet(this, _DockerComposeService_svcDef, "f").container_name || __classPrivateFieldGet(this, _DockerComposeService_name, "f");
142
+ return this.#svcDef.container_name || this.#name;
155
143
  }
156
144
  get cmd() {
157
- return __classPrivateFieldGet(this, _DockerComposeService_svcDef, "f").command || [];
145
+ return this.#svcDef.command || [];
158
146
  }
159
147
  get envArgs() {
160
- return parseEnv(__classPrivateFieldGet(this, _DockerComposeService_svcDef, "f").environment);
148
+ return parseEnv(this.#svcDef.environment);
161
149
  }
162
150
  /**
163
151
  * Find (available) container name and alias(es)
@@ -183,13 +171,13 @@ export class DockerComposeService {
183
171
  }
184
172
  // Get (available) port mappings
185
173
  async getPorts(avoidConflicts = false, mapLocal = true) {
186
- return parsePorts(__classPrivateFieldGet(this, _DockerComposeService_svcDef, "f").ports, avoidConflicts, mapLocal);
174
+ return parsePorts(this.#svcDef.ports, avoidConflicts, mapLocal);
187
175
  }
188
176
  async getDefaultPortInfo() {
189
- if (!__classPrivateFieldGet(this, _DockerComposeService_parsedPorts, "f")) {
190
- __classPrivateFieldSet(this, _DockerComposeService_parsedPorts, await this.getPorts(), "f");
177
+ if (!this.#parsedPorts) {
178
+ this.#parsedPorts = await this.getPorts();
191
179
  }
192
- return __classPrivateFieldGet(this, _DockerComposeService_parsedPorts, "f");
180
+ return this.#parsedPorts;
193
181
  }
194
182
  async getDefaultPorts() {
195
183
  const { ports } = await this.getDefaultPortInfo();
@@ -203,10 +191,10 @@ export class DockerComposeService {
203
191
  return DockerComposeService.getUrls(await this.getDefaultPorts(), this.defaultContainerName);
204
192
  }
205
193
  async getDefaultNetworkInfo() {
206
- if (!__classPrivateFieldGet(this, _DockerComposeService_parsedNetworks, "f")) {
207
- __classPrivateFieldSet(this, _DockerComposeService_parsedNetworks, await parseNetworks(__classPrivateFieldGet(this, _DockerComposeService_svcDef, "f").networks), "f");
194
+ if (!this.#parsedNetworks) {
195
+ this.#parsedNetworks = await parseNetworks(this.#svcDef.networks);
208
196
  }
209
- return __classPrivateFieldGet(this, _DockerComposeService_parsedNetworks, "f");
197
+ return this.#parsedNetworks;
210
198
  }
211
199
  async getDefaultNetworks() {
212
200
  const { networks } = await this.getDefaultNetworkInfo();
@@ -217,10 +205,10 @@ export class DockerComposeService {
217
205
  return runArgs;
218
206
  }
219
207
  async getDefaultVolumeInfo() {
220
- if (!__classPrivateFieldGet(this, _DockerComposeService_parsedVolumes, "f")) {
221
- __classPrivateFieldSet(this, _DockerComposeService_parsedVolumes, await parseVolumes(__classPrivateFieldGet(this, _DockerComposeService_svcDef, "f").networks), "f");
208
+ if (!this.#parsedVolumes) {
209
+ this.#parsedVolumes = await parseVolumes(this.#svcDef.networks);
222
210
  }
223
- return __classPrivateFieldGet(this, _DockerComposeService_parsedVolumes, "f");
211
+ return this.#parsedVolumes;
224
212
  }
225
213
  async getDefaultVolumes() {
226
214
  const { volumes } = await this.getDefaultVolumeInfo();
@@ -237,13 +225,13 @@ export class DockerComposeService {
237
225
  await dockerPull({ image: this.image });
238
226
  }
239
227
  async getBaseRunArgs() {
240
- if (!__classPrivateFieldGet(this, _DockerComposeService_baseRunArgs, "f")) {
241
- const envArgs = parseEnv(__classPrivateFieldGet(this, _DockerComposeService_svcDef, "f").environment);
242
- const ulArgs = parseULimits(__classPrivateFieldGet(this, _DockerComposeService_svcDef, "f").ulimits);
228
+ if (!this.#baseRunArgs) {
229
+ const envArgs = parseEnv(this.#svcDef.environment);
230
+ const ulArgs = parseULimits(this.#svcDef.ulimits);
243
231
  const netArgs = await this.getDefaultNetworkArgs();
244
- __classPrivateFieldSet(this, _DockerComposeService_baseRunArgs, ['--rm', ...envArgs, ...netArgs, ...ulArgs], "f");
232
+ this.#baseRunArgs = ['--rm', ...envArgs, ...netArgs, ...ulArgs];
245
233
  }
246
- return __classPrivateFieldGet(this, _DockerComposeService_baseRunArgs, "f");
234
+ return this.#baseRunArgs;
247
235
  }
248
236
  async assembleRunArgs(containerName = this.defaultContainerName, aliases = [this.name], additionalArgs = null) {
249
237
  const additional = additionalArgs || [
@@ -260,21 +248,21 @@ export class DockerComposeService {
260
248
  async getRunArgs(avoidConflicts = false, mapLocalPorts = true) {
261
249
  const { aliases, name: cName, suffix, } = await this.getNames(avoidConflicts);
262
250
  const { runArgs: pArgs } = await this.getPorts(avoidConflicts, mapLocalPorts);
263
- const { runArgs: vArgs } = await parseVolumes(__classPrivateFieldGet(this, _DockerComposeService_svcDef, "f").volumes, suffix);
251
+ const { runArgs: vArgs } = await parseVolumes(this.#svcDef.volumes, suffix);
264
252
  return this.assembleRunArgs(cName, aliases, [...pArgs, ...vArgs]);
265
253
  }
266
- async up({ healthCheck, avoidConflicts = false, mapVolumes = true, mapPorts = true, cmd = this.cmd, tracker = defaultTracker, } = {}) {
254
+ async up({ avoidConflicts = false, cmd = this.cmd, healthCheck, mapPorts = true, mapVolumes = true, tracker = defaultTracker, } = {}) {
267
255
  const { image } = this;
268
256
  if (!image) {
269
257
  throw new Error(`Cannot bring up service '${this.name}', no image defined.`);
270
258
  }
271
- if (__classPrivateFieldGet(this, _DockerComposeService_tracker, "f").containers.size) {
259
+ if (this.#tracker.containers.size) {
272
260
  buildLog(`Warning: up called on service '${this.name}' with already running container`);
273
261
  }
274
262
  const { aliases, name: containerName, suffix, } = await this.getNames(avoidConflicts);
275
263
  const { ports, runArgs: pArgs } = await this.getPorts(avoidConflicts, mapPorts);
276
264
  const { runArgs: vArgs, volumes } = mapVolumes
277
- ? await parseVolumes(__classPrivateFieldGet(this, _DockerComposeService_svcDef, "f").volumes, suffix)
265
+ ? await parseVolumes(this.#svcDef.volumes, suffix)
278
266
  : { runArgs: [], volumes: [] };
279
267
  let container = await dockerContainerFind(containerName, { all: true });
280
268
  if (container && !(await container.isRunning())) {
@@ -282,8 +270,8 @@ export class DockerComposeService {
282
270
  }
283
271
  if (!container) {
284
272
  await this.pull();
285
- await dockerComposeCreateNetworks(await this.getDefaultNetworks(), __classPrivateFieldGet(this, _DockerComposeService_dockerCompose, "f"), __classPrivateFieldGet(this, _DockerComposeService_tracker, "f"));
286
- await dockerComposeCreateVolumes(volumes, __classPrivateFieldGet(this, _DockerComposeService_dockerCompose, "f"), __classPrivateFieldGet(this, _DockerComposeService_tracker, "f"));
273
+ await dockerComposeCreateNetworks(await this.getDefaultNetworks(), this.#dockerCompose, this.#tracker);
274
+ await dockerComposeCreateVolumes(volumes, this.#dockerCompose, this.#tracker);
287
275
  const runArgs = await this.assembleRunArgs(containerName, aliases, [
288
276
  ...pArgs,
289
277
  ...vArgs,
@@ -298,7 +286,7 @@ export class DockerComposeService {
298
286
  buildLog(`Reusing existing container for '${this.name}' service.`);
299
287
  }
300
288
  // This service tracks the things it created
301
- __classPrivateFieldGet(this, _DockerComposeService_tracker, "f").containers.set(containerName, container);
289
+ this.#tracker.containers.set(containerName, container);
302
290
  // The passed tracker needs to track this service
303
291
  tracker.services.set(this.name, this);
304
292
  const idAlias = container.id.slice(0, 12);
@@ -321,7 +309,7 @@ export class DockerComposeService {
321
309
  await dockerComposeTeardown({
322
310
  includeNetworks,
323
311
  includeVolumes,
324
- tracker: __classPrivateFieldGet(this, _DockerComposeService_tracker, "f"),
312
+ tracker: this.#tracker,
325
313
  });
326
314
  if (includeDefaults) {
327
315
  const container = await dockerContainerFind(this.defaultContainerName);
@@ -341,12 +329,11 @@ export class DockerComposeService {
341
329
  }));
342
330
  }
343
331
  }
344
- _DockerComposeService_name = new WeakMap(), _DockerComposeService_svcDef = new WeakMap(), _DockerComposeService_dockerCompose = new WeakMap(), _DockerComposeService_tracker = new WeakMap(), _DockerComposeService_parsedPorts = new WeakMap(), _DockerComposeService_parsedNetworks = new WeakMap(), _DockerComposeService_parsedVolumes = new WeakMap(), _DockerComposeService_baseRunArgs = new WeakMap();
345
332
  export async function dockerComposeGetAllServices(dockerCompose) {
346
333
  const { services } = await dockerComposeResolve(dockerCompose);
347
334
  return mapValuesAsync(services, (s, name) => DockerComposeService.parse(name));
348
335
  }
349
- export async function dockerComposeTeardown({ includeDefaults = false, includeVolumes = false, includeNetworks = false, dockerCompose, tracker = defaultTracker, } = {}) {
336
+ export async function dockerComposeTeardown({ dockerCompose, includeDefaults = false, includeNetworks = false, includeVolumes = false, tracker = defaultTracker, } = {}) {
350
337
  if (!tracker.cleaning) {
351
338
  // eslint-disable-next-line no-param-reassign
352
339
  tracker.cleaning = (async () => {
@@ -426,7 +413,7 @@ export async function dockerComposeRunService(key, upOptions = {}, dockerCompose
426
413
  }
427
414
  buildLog(`Starting <${service.name}> service...`);
428
415
  const upResult = await service.up(upOptions);
429
- const { container, urls, urls: [{ docker: dockerUrl, local: url }], ports: [{ docker: dockerPort, local: port }], } = upResult;
416
+ const { container, ports: [{ docker: dockerPort, local: port }], urls, urls: [{ docker: dockerUrl, local: url }], } = upResult;
430
417
  const { id, image, name } = container;
431
418
  urls.forEach(({ local }) => local && buildLog(`<${service.name}> accessible at ${local}`));
432
419
  return {
package/src/env.d.ts CHANGED
@@ -12,9 +12,9 @@ export declare const cmdExists: (cmd: string) => Promise<boolean>;
12
12
  interface ReadShellEnvVarOptions {
13
13
  envFile?: string | null;
14
14
  refreshEnv?: boolean;
15
- shell?: string;
15
+ shell?: string | null;
16
16
  }
17
- export declare const readShellEnvVar: (name: string, { refreshEnv, envFile, shell, }?: ReadShellEnvVarOptions) => Promise<string | null>;
17
+ export declare const readShellEnvVar: (name: string, { envFile, refreshEnv, shell, }?: ReadShellEnvVarOptions) => Promise<string | null>;
18
18
  export interface AppendToEnvOptions {
19
19
  envFile?: string | null;
20
20
  testContent?: string | StringGenFn;
package/src/env.js CHANGED
@@ -25,7 +25,7 @@ const cacheString = (key, fn) => {
25
25
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
26
26
  return stringCache.get(key);
27
27
  };
28
- export const shellType = () => cacheString('shellType', () => os.userInfo().shell.split('/').pop() || null);
28
+ export const shellType = () => cacheString('shellType', () => os.userInfo().shell?.split('/').pop() || null);
29
29
  export const shellEnvFile = () => cacheString('shellEnvFile', () => {
30
30
  switch (shellType()) {
31
31
  case 'zsh':
@@ -61,10 +61,13 @@ export const whichCmd = async (cmd) => {
61
61
  return binPath;
62
62
  };
63
63
  export const cmdExists = async (cmd) => !!(await whichCmd(cmd));
64
- export const readShellEnvVar = async (name, { refreshEnv = true, envFile = shellEnvFile(), shell = os.userInfo().shell, } = {}) => {
64
+ export const readShellEnvVar = async (name, { envFile = shellEnvFile(), refreshEnv = true, shell = os.userInfo().shell, } = {}) => {
65
65
  if (refreshEnv && (!envFile || !(await fs.pathExists(envFile)))) {
66
66
  throw new Error(`Could not find shell env file: ${envFile}`);
67
67
  }
68
+ if (!shell) {
69
+ throw new Error('Could not determine shell');
70
+ }
68
71
  try {
69
72
  return (await spawn(shell, [
70
73
  '-c',
package/src/fs.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import glob from 'glob';
2
- export declare const readDir: (pattern: string, options?: glob.IOptions) => Promise<string[]>;
1
+ import { GlobOptions, GlobOptionsWithFileTypesUnset } from 'glob';
2
+ export declare const readDir: (pattern: string, options?: GlobOptionsWithFileTypesUnset) => Promise<string[]>;
3
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?: glob.IOptions | false) => Promise<void>;
4
+ export declare const copyDir: (source: string, target: string, fileGlob?: string, globOptions?: null | GlobOptionsWithFileTypesUnset, renameFn?: (name: string) => string) => Promise<void>;
5
+ export declare const cleanDir: (pattern: string, globOptions?: GlobOptions | false) => Promise<boolean>;
6
6
  export declare const producedPathExists: (producer: () => Promise<string>) => Promise<boolean>;
7
7
  export declare const copyIfMissing: (src: string, dest: string) => Promise<void>;
8
8
  export type StringGenFn = () => string | Promise<string>;
package/src/fs.js CHANGED
@@ -1,17 +1,14 @@
1
1
  import fs from 'fs-extra';
2
- import glob from 'glob';
2
+ import { glob } from 'glob';
3
3
  import path from 'path';
4
- import rimraf from 'rimraf';
4
+ import { rimraf } from 'rimraf';
5
5
  import { resolveOnce } from './promise.js';
6
6
  import { buildLog } from './run.js';
7
- export const readDir = async (pattern, options) => new Promise((resolve, reject) => {
8
- glob(pattern, options || {}, (err, result) => err ? reject(err) : resolve(result));
9
- });
7
+ export const readDir = async (pattern, options) => glob(pattern, options);
10
8
  export const moveDir = async (source, target) => {
11
9
  const dirs = await readDir('**/*.*', {
12
10
  cwd: source,
13
11
  dot: true,
14
- nosort: true,
15
12
  });
16
13
  await Promise.all(dirs.map(async (dir) => {
17
14
  const from = path.resolve(source, dir);
@@ -25,7 +22,6 @@ export const copyDir = async (source, target, fileGlob = '**/*.*', globOptions =
25
22
  cwd: source,
26
23
  dot: true,
27
24
  nodir: true,
28
- nosort: true,
29
25
  ...globOptions,
30
26
  });
31
27
  await Promise.all(paths.map(async (p) => {
@@ -35,9 +31,7 @@ export const copyDir = async (source, target, fileGlob = '**/*.*', globOptions =
35
31
  await fs.copyFile(from, to);
36
32
  }));
37
33
  };
38
- export const cleanDir = async (pattern, globOptions) => new Promise((resolve, reject) => {
39
- rimraf(pattern, { glob: globOptions }, (err) => err ? reject(err) : resolve());
40
- });
34
+ export const cleanDir = async (pattern, globOptions) => rimraf(pattern, { glob: globOptions });
41
35
  export const producedPathExists = async (producer) => {
42
36
  try {
43
37
  const result = (await producer()).trim();
package/src/gh.d.ts CHANGED
@@ -2,17 +2,17 @@ import { SpawnOptions } from './cp.js';
2
2
  export declare const gh: (args: string[], options?: SpawnOptions) => Promise<import("./cp.js").SpawnResult>;
3
3
  export declare const ghRepoClone: (repo: string, repoDir: string) => Promise<void>;
4
4
  export declare const ensureGhRepo: (repo: string, { rootDir, targetDir, targetName, }?: {
5
- rootDir?: string | undefined;
6
- targetDir?: string | undefined;
7
- targetName?: string | undefined;
5
+ rootDir?: string;
6
+ targetDir?: string;
7
+ targetName?: string;
8
8
  }) => Promise<void>;
9
9
  export declare const ensureGhAuthLogin: ({ host, scopes, }?: {
10
- host?: string | undefined;
11
- scopes?: string | undefined;
10
+ host?: string;
11
+ scopes?: string;
12
12
  }) => Promise<void>;
13
13
  export declare const ensureGhSshKeyAdded: ({ keyTitle, privateKeyPath, }?: {
14
- keyTitle?: string | undefined;
15
- privateKeyPath?: string | undefined;
14
+ keyTitle?: string;
15
+ privateKeyPath?: string;
16
16
  }) => Promise<void>;
17
17
  export declare const ensureGhConfig: (key: string, value: string, host?: string) => Promise<void>;
18
18
  export declare const ensureGhConfigSshGitProtocol: (host?: string) => Promise<void>;
package/src/maps.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * @param {Function} map the mapping operation
5
5
  * @returns {ObjMap} a new object
6
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>;
7
+ export declare const mapValues: <K extends string, V, R>(obj: null | undefined | Record<K, V>, map: (value: V, key: K, map: Record<K, V>) => R) => Record<K, R>;
8
8
  /**
9
9
  * Given a `ObjMap`, iterate over each entry and run it through the given async `map` function.
10
10
  * The promise returned by the `map` is awaited, such that the resulting `ObjMap` values are
@@ -13,7 +13,7 @@ export declare const mapValues: <K extends string, V, R>(obj: Record<K, V> | nul
13
13
  * @param {Function} map the async mapping operation
14
14
  * @returns {Promise} a promise for a new object
15
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>>;
16
+ export declare const mapValuesAsync: <K extends string, V, R>(obj: null | undefined | Record<K, V>, map: (value: V, key: K, objMap: Record<K, V>) => Promise<R>) => Promise<Record<K, R>>;
17
17
  /**
18
18
  * Given a `ObjMap`, iterate over each entry and run it through the given `filter` function.
19
19
  * Any entry for which the `filter` returns `false` is removed from the resulting `ObjMap`.
@@ -23,7 +23,7 @@ export declare const mapValuesAsync: <K extends string, V, R>(obj: Record<K, V>
23
23
  * @param {Function} filter the filter operation
24
24
  * @returns {ObjMap} a new object, a subset of the input
25
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>>;
26
+ export declare const filterKeys: <V, K extends string = string>(obj: null | undefined | Record<K, V>, filter?: (value: V, key: K, objMap: Record<K, V>) => boolean) => Partial<Record<K, V>>;
27
27
  /**
28
28
  * Given an object, removes any top level keys with a nullish value.
29
29
  * The type system should preserve the incoming object type, with all such keys typed as `empty`.
package/src/npm.d.ts CHANGED
@@ -18,7 +18,7 @@ export interface NpmOptions {
18
18
  npmPath?: string;
19
19
  spawnOptions?: SpawnOptions;
20
20
  }
21
- export declare function npm({ args, spawnOptions, npmPath, }?: NpmOptions): Promise<SpawnResult>;
21
+ export declare function npm({ args, npmPath, spawnOptions, }?: NpmOptions): Promise<SpawnResult>;
22
22
  export declare function npmGetVersions(packageName: string, npmPath?: string): Promise<string[]>;
23
23
  interface NpmWriteRcOptions {
24
24
  authToken?: string;
package/src/npm.js CHANGED
@@ -10,7 +10,7 @@ export function getNpmConfig() {
10
10
  }
11
11
  export const envNpmCreds = (process.env.NPM_CREDS && JSON.parse(process.env.NPM_CREDS)) || null;
12
12
  const npmExe = (npmPath) => npmPath || (platform() === 'win32' ? 'npm.cmd' : 'npm');
13
- export async function npm({ args = [], spawnOptions, npmPath, } = {}) {
13
+ export async function npm({ args = [], npmPath, spawnOptions, } = {}) {
14
14
  const localNpm = path.join(path.dirname(process.execPath), 'lib/node_modules/npm/bin/npm-cli.js');
15
15
  const spawnOpts = {
16
16
  env: process.env,
package/src/promise.d.ts CHANGED
@@ -4,4 +4,4 @@
4
4
  * @param producer a function that produces a promise, will be invoked at most once
5
5
  * @returns a function that returns a promise
6
6
  */
7
- export declare const resolveOnce: <T>(producer: () => Promise<T>) => () => Promise<T>;
7
+ export declare const resolveOnce: <T>(producer: () => Promise<T>) => (() => Promise<T>);
package/src/run.d.ts CHANGED
@@ -10,4 +10,4 @@ export interface RunCliOptions<Args extends string[], Result> {
10
10
  passthroughArgv?: Args | boolean;
11
11
  resolveFn?: (path: string) => Promise<RunnableModule<Args, Result>> | RunnableModule<Args, Result>;
12
12
  }
13
- export declare function runCli<Args extends string[], Result>({ resolveFn, defaultAction, argv, passthroughArgv, }?: RunCliOptions<Args, Result>): Promise<Result>;
13
+ export declare function runCli<Args extends string[], Result>({ argv, defaultAction, passthroughArgv, resolveFn, }?: RunCliOptions<Args, Result>): Promise<Result>;
package/src/run.js CHANGED
@@ -24,7 +24,7 @@ export async function run(fn, ...options) {
24
24
  buildLog(`Finished '${task.name}' after ${time} ms`, end);
25
25
  return result;
26
26
  }
27
- export async function runCli({ resolveFn = async (path) => import(`./${path}.js`), defaultAction = 'build', argv = process.argv, passthroughArgv = false, } = {}) {
27
+ export async function runCli({ argv = process.argv, defaultAction = 'build', passthroughArgv = false, resolveFn = async (path) => import(`./${path}.js`), } = {}) {
28
28
  const module = argv.length > 2
29
29
  ? await resolveFn(argv[2])
30
30
  : typeof defaultAction === 'string'
package/src/tgz.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { Readable } from 'stream';
3
- import tar from 'tar';
3
+ import { TarOptionsWithAliases } from 'tar/dist/commonjs/options.js';
4
4
  export type ArtifactInfo = {
5
5
  contentType?: string;
6
6
  md5: string;
@@ -9,5 +9,5 @@ export type ArtifactInfo = {
9
9
  size: number;
10
10
  };
11
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>;
12
+ export declare function getArtifactInfo(artifact: string | Pick<Readable, 'pipe'>): Promise<ArtifactInfo>;
13
+ export declare function tgzDir(srcDir: string, outPath: string, options?: TarOptionsWithAliases): Promise<ArtifactInfo>;
package/src/tgz.js CHANGED
@@ -2,7 +2,7 @@ import crypto from 'crypto';
2
2
  import fs from 'fs-extra';
3
3
  import path from 'path';
4
4
  import StreamCounter from 'stream-counter';
5
- import tar from 'tar';
5
+ import { create } from 'tar';
6
6
  import { buildLog } from './run.js';
7
7
  const generateHash = async (stream, type) => new Promise((resolve, reject) => {
8
8
  stream
@@ -49,7 +49,7 @@ export async function getArtifactInfo(artifact) {
49
49
  // Creates a gzipped tarball of a directory, returns sha1 + md5 hash and size of resulting file
50
50
  export async function tgzDir(srcDir, outPath, options) {
51
51
  await fs.ensureDir(path.dirname(outPath));
52
- const tgzStream = tar.c({
52
+ const tgzStream = create({
53
53
  cwd: srcDir,
54
54
  gzip: true,
55
55
  portable: true,