zarro 1.178.0 → 1.179.2

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.
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  (function () {
3
+ const debug = requireModule("debug")(__filename);
3
4
  const system = requireModule("system");
4
5
  const { types } = require("util");
5
6
  const { isRegExp } = types;
6
7
  const ZarroError = requireModule("zarro-error");
8
+ const sleep = requireModule("sleep");
7
9
  const path = require("path");
8
10
  const { fileExists, readTextFile, ls, FsEntities } = require("yafs");
9
11
  const { yellow } = requireModule("ansi-colors");
@@ -250,10 +252,14 @@
250
252
  pushIfSet(args, opts.configFile, "--configfile");
251
253
  args.push(opts.url);
252
254
  const systemArgs = ["nuget", "add", "source"].concat(args);
253
- await runDotNetWith(systemArgs, { suppressOutput: true });
255
+ let result = await runDotNetWith(systemArgs, { suppressOutput: true });
256
+ if (SystemError.isError(result)) {
257
+ return result;
258
+ }
254
259
  if (opts.enabled === false) {
255
- await disableNugetSource(opts.name);
260
+ result = await disableNugetSource(opts.name);
256
261
  }
262
+ return result;
257
263
  }
258
264
  async function removeNugetSource(source) {
259
265
  if (!source) {
@@ -270,7 +276,7 @@
270
276
  if (!toEnable) {
271
277
  throw new ZarroError(`unable to find source matching: ${JSON.stringify(source)}`);
272
278
  }
273
- await runDotNetWith(["dotnet", "nuget", "enable", "source", toEnable.name], {
279
+ return await runDotNetWith(["dotnet", "nuget", "enable", "source", toEnable.name], {
274
280
  suppressOutput: true
275
281
  });
276
282
  }
@@ -279,7 +285,7 @@
279
285
  if (!toDisable) {
280
286
  throw new ZarroError(`unable to find source matching: ${JSON.stringify(source)}`);
281
287
  }
282
- await runDotNetWith(["dotnet", "nuget", "disable", "source", toDisable.name], {
288
+ return runDotNetWith(["dotnet", "nuget", "disable", "source", toDisable.name], {
283
289
  suppressOutput: true
284
290
  });
285
291
  }
@@ -416,7 +422,7 @@ WARNING: 'dotnet pack' ignores --version-suffix when a nuspec file is provided.
416
422
  }
417
423
  pushMsbuildProperties(args, copy);
418
424
  pushAdditionalArgs(args, copy);
419
- return await runDotNetWith(args, copy);
425
+ return runDotNetWith(args, copy);
420
426
  }
421
427
  catch (e) {
422
428
  throw e;
@@ -792,7 +798,7 @@ WARNING: 'dotnet pack' ignores --version-suffix when a nuspec file is provided.
792
798
  ? { search: options }
793
799
  : options;
794
800
  if (opts.skipCache) {
795
- return await searchPackages(opts);
801
+ return await searchPackagesUncached(opts);
796
802
  }
797
803
  return await cache.through(JSON.stringify(opts), async () => await searchPackagesUncached(opts), 60 // cache for a minute
798
804
  );
@@ -829,6 +835,11 @@ WARNING: 'dotnet pack' ignores --version-suffix when a nuspec file is provided.
829
835
  throw wrapSearchError(systemError);
830
836
  }
831
837
  const parsed = parsePackageSearchResult(stdout);
838
+ debug({
839
+ label: "searchPackagesUncached: response from package repository",
840
+ rawResult,
841
+ parsed
842
+ });
832
843
  const finalResult = [];
833
844
  for (const sourceResult of parsed.searchResult) {
834
845
  for (const pkg of sourceResult.packages) {
@@ -878,7 +889,7 @@ WARNING: 'dotnet pack' ignores --version-suffix when a nuspec file is provided.
878
889
  if (opts.suppressOutput === undefined) {
879
890
  opts.suppressOutput = true;
880
891
  }
881
- await runDotNetWith(args, opts);
892
+ return await runDotNetWith(args, opts);
882
893
  }
883
894
  const defaultCreateOptions = {
884
895
  skipTemplateUpdateCheck: true
@@ -1082,7 +1093,22 @@ WARNING: 'dotnet pack' ignores --version-suffix when a nuspec file is provided.
1082
1093
  })(DotNetCache || (DotNetCache = {}));
1083
1094
  async function clearCaches(cacheType) {
1084
1095
  const args = ["nuget", "locals", `${cacheType}`, "--clear"];
1085
- await runDotNetWith(args);
1096
+ let lastError = null;
1097
+ for (let i = 0; i < 10; i++) {
1098
+ try {
1099
+ await runDotNetWith(args);
1100
+ return;
1101
+ }
1102
+ catch (e) {
1103
+ lastError = e;
1104
+ const allLogs = (lastError.stdout || []).concat(lastError.stderr || []);
1105
+ const lockError = !!allLogs.find(s => s.includes("another process"));
1106
+ if (lockError) {
1107
+ await sleep(500);
1108
+ }
1109
+ }
1110
+ }
1111
+ console.warn(`unable to clear caches:\n${lastError}`);
1086
1112
  }
1087
1113
  clearCaches.all = DotNetCache.all;
1088
1114
  clearCaches.httpCache = DotNetCache.httpCache;
@@ -28,7 +28,8 @@
28
28
  resolveFlag,
29
29
  resolveWithFallback,
30
30
  resolveMap,
31
- resolveRequired
31
+ resolveRequired,
32
+ toBool
32
33
  };
33
34
  const positives = new Set(["1", "yes", "true"]);
34
35
  if (process.env.POSITIVE_FLAG) {
@@ -285,7 +286,7 @@
285
286
  // a file name or a path to something
286
287
  return undefined;
287
288
  }
288
- const key = "ZARRO_ALLOW_FILE_RESOLUTIONS", raw = process.env[key], fileResolutionsAreEnabled = resolveAsBoolean(name, raw, true);
289
+ const key = "ZARRO_ALLOW_FILE_RESOLUTIONS", raw = process.env[key], fileResolutionsAreEnabled = toBool(name, raw, true);
289
290
  if (!fileResolutionsAreEnabled) {
290
291
  return;
291
292
  }
@@ -389,9 +390,9 @@
389
390
  const resolved = resolveInternal(name), value = resolved === undefined || resolved === ""
390
391
  ? undefined
391
392
  : resolved.toLowerCase();
392
- return resolveAsBoolean(name, value, fallback);
393
+ return toBool(name, value, fallback);
393
394
  }
394
- function resolveAsBoolean(name, value, fallback) {
395
+ function toBool(name, value, fallback) {
395
396
  if (value === undefined && fallback !== undefined) {
396
397
  return fallback;
397
398
  }
package/index.js CHANGED
@@ -329,7 +329,72 @@ async function transpileTasksUnder_(folder) {
329
329
  }
330
330
  }
331
331
 
332
+ const timestampMatcher = /\[\d\d:\d\d:\d\d]/;
333
+
334
+ function patchConsoleOutputToSuppressIntermediateTasks() {
335
+ patchConsoleFunction("log");
336
+ patchConsoleFunction("error");
337
+ // don't need to patch console.warn right now...
338
+ // patchConsoleFunction("warn");
339
+
340
+ const original = process.stdout.write.bind(process.stdout);
341
+ let last = "";
342
+ process.stdout.write = (...args) => {
343
+ const main = plainText(`${ args[0] }`);
344
+ if (main.match(timestampMatcher) && last.match(timestampMatcher)) {
345
+ // suppress duplicated timestamps
346
+ last = main;
347
+ return;
348
+ }
349
+ last = main;
350
+ original.apply(process.stdout, args);
351
+ };
352
+ }
353
+
354
+ // https://stackoverflow.com/a/29497680/1697008
355
+ function plainText(str) {
356
+ return str.replace(
357
+ /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ''
358
+ );
359
+ }
360
+
361
+ let eatNewLines = {};
362
+
363
+ function patchConsoleFunction(fn) {
364
+ const original = console[fn].bind(console);
365
+ console[fn] = (...args) => {
366
+ const main = `${ args[0] }`;
367
+ if (shouldSuppressLog(main)) {
368
+ eatNewLines[fn] = true;
369
+ return;
370
+ }
371
+ if (!main.trim() && eatNewLines[fn]) {
372
+ return;
373
+ }
374
+ eatNewLines[fn] = false;
375
+ original.apply(console, args);
376
+ };
377
+ }
378
+
379
+ function shouldSuppressLog(str) {
380
+ return str.includes("::: [suppress] :::") ||
381
+ looksLikeAnonymousTaskMessage(str);
382
+ }
383
+
384
+ function looksLikeAnonymousTaskMessage(str) {
385
+ if (!str) {
386
+ return false;
387
+ }
388
+ const firstQuotePos = str.indexOf("'");
389
+ if (firstQuotePos === -1) {
390
+ return false;
391
+ }
392
+ const anonymousPos = str.indexOf("<anonymous>", firstQuotePos);
393
+ return anonymousPos > -1;
394
+ }
395
+
332
396
  (async function () {
397
+ patchConsoleOutputToSuppressIntermediateTasks();
333
398
  try {
334
399
  const rawArgs = await gatherArgs([ path.join(path.dirname(__dirname), ".bin", "zarro"), __filename ]);
335
400
  const args = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zarro",
3
- "version": "1.178.0",
3
+ "version": "1.179.2",
4
4
  "description": "Some glue to make gulp easier, perhaps even zero- or close-to-zero-conf",
5
5
  "bin": {
6
6
  "zarro": "index.js"
@@ -125,7 +125,7 @@
125
125
  "console-cls": "^1.2.2",
126
126
  "debug": "^4.3.4",
127
127
  "debugger-is-attached": "^1.2.0",
128
- "expect-even-more-jest": "^1.15.0",
128
+ "expect-even-more-jest": "^1.19.0",
129
129
  "filesystem-sandbox": "^1.20.0",
130
130
  "ioredis": "^5.3.2",
131
131
  "jest": "^29.6.2",