zarro 1.177.0 → 1.179.1

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.
@@ -9,13 +9,13 @@
9
9
  await writeTextFile(target, template.replace("%TASK_NAME%", taskName));
10
10
  log.info(`generated new task file at: ${target}`);
11
11
  });
12
- const template = `
13
- /// <reference path="../node_modules/zarro/types.d.ts" />
14
- const
15
- gulp = requireModule<Gulp>("gulp");
16
-
17
- gulp.task(\`%TASK_NAME%\`, async () => {
18
-
19
- });
12
+ const template = `
13
+ /// <reference path="../node_modules/zarro/types.d.ts" />
14
+ const
15
+ gulp = requireModule<Gulp>("gulp");
16
+
17
+ gulp.task(\`%TASK_NAME%\`, async () => {
18
+
19
+ });
20
20
  `.trim();
21
21
  })();
@@ -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");
@@ -792,7 +794,7 @@ WARNING: 'dotnet pack' ignores --version-suffix when a nuspec file is provided.
792
794
  ? { search: options }
793
795
  : options;
794
796
  if (opts.skipCache) {
795
- return await searchPackages(opts);
797
+ return await searchPackagesUncached(opts);
796
798
  }
797
799
  return await cache.through(JSON.stringify(opts), async () => await searchPackagesUncached(opts), 60 // cache for a minute
798
800
  );
@@ -829,6 +831,11 @@ WARNING: 'dotnet pack' ignores --version-suffix when a nuspec file is provided.
829
831
  throw wrapSearchError(systemError);
830
832
  }
831
833
  const parsed = parsePackageSearchResult(stdout);
834
+ debug({
835
+ label: "searchPackagesUncached: response from package repository",
836
+ rawResult,
837
+ parsed
838
+ });
832
839
  const finalResult = [];
833
840
  for (const sourceResult of parsed.searchResult) {
834
841
  for (const pkg of sourceResult.packages) {
@@ -1082,7 +1089,22 @@ WARNING: 'dotnet pack' ignores --version-suffix when a nuspec file is provided.
1082
1089
  })(DotNetCache || (DotNetCache = {}));
1083
1090
  async function clearCaches(cacheType) {
1084
1091
  const args = ["nuget", "locals", `${cacheType}`, "--clear"];
1085
- await runDotNetWith(args);
1092
+ let lastError = null;
1093
+ for (let i = 0; i < 10; i++) {
1094
+ try {
1095
+ await runDotNetWith(args);
1096
+ return;
1097
+ }
1098
+ catch (e) {
1099
+ lastError = e;
1100
+ const allLogs = (lastError.stdout || []).concat(lastError.stderr || []);
1101
+ const lockError = !!allLogs.find(s => s.includes("another process"));
1102
+ if (lockError) {
1103
+ await sleep(500);
1104
+ }
1105
+ }
1106
+ }
1107
+ console.warn(`unable to clear caches:\n${lastError}`);
1086
1108
  }
1087
1109
  clearCaches.all = DotNetCache.all;
1088
1110
  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
  }
@@ -99,7 +99,7 @@
99
99
  throw new ZarroError("MONO is required to run nuget restore on this platform");
100
100
  }
101
101
  const baseFolder = findNpmBase();
102
- const script = `#!/bin/sh
102
+ const script = `#!/bin/sh
103
103
  mono ${path.resolve(nugetPath)} $@`;
104
104
  const scriptPath = path.join(baseFolder, "node_modules", ".bin", "mono-nuget");
105
105
  writeFileSync(scriptPath, script, { encoding: "utf-8" });
@@ -18,8 +18,8 @@
18
18
  if (fileExistsSync(shim)) {
19
19
  return shim;
20
20
  }
21
- writeTextFileSync(shim, `#!/bin/sh
22
- mono $(dirname $0)/nuget.exe $*
21
+ writeTextFileSync(shim, `#!/bin/sh
22
+ mono $(dirname $0)/nuget.exe $*
23
23
  `);
24
24
  chmodSync(shim, "777");
25
25
  return shim;
@@ -55,10 +55,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
55
55
  this.emit("end");
56
56
  }
57
57
  catch (err) {
58
- console.error(chalk.redBright(`
59
- ==================================================
60
- | WARNING: Unable to update zarro, error(s) follow |
61
- ==================================================
58
+ console.error(chalk.redBright(`
59
+ ==================================================
60
+ | WARNING: Unable to update zarro, error(s) follow |
61
+ ==================================================
62
62
  `));
63
63
  this.emit("error", err);
64
64
  }
@@ -43,9 +43,9 @@
43
43
  const e = ex;
44
44
  const msg = e.message || e;
45
45
  if (msg === "operation timed out") {
46
- log.error(chalk.redBright(`fetch operation timed out:
47
- - check that the current account can fetch from all remotes
48
- - optionally disable fetch with SKIP_FETCH_ON_VERIFY=1
46
+ log.error(chalk.redBright(`fetch operation timed out:
47
+ - check that the current account can fetch from all remotes
48
+ - optionally disable fetch with SKIP_FETCH_ON_VERIFY=1
49
49
  - optionally increase GIT_FETCH_TIMEOUT from current value: ${timeout}`));
50
50
  }
51
51
  }
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.177.0",
3
+ "version": "1.179.1",
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"
@@ -63,7 +63,7 @@
63
63
  "event-stream": "^4.0.1",
64
64
  "exec-step": "^0.14.0",
65
65
  "fancy-log": "^1.3.3",
66
- "gulp": "^4.0.0",
66
+ "gulp": "^5.0.0",
67
67
  "gulp-debug": "^4.0.0",
68
68
  "gulp-dotnet-cli": "^1.1.0",
69
69
  "gulp-edit-xml": "^3.1.1",
@@ -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",