zarro 1.130.0 → 1.130.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.
@@ -78,6 +78,7 @@ async function build() {
78
78
  }
79
79
 
80
80
  function buildForNetCore(solutions) {
81
+ const { build } = requireModule("gulp-dotnet-cli");
81
82
  log.info(gutil.colors.yellow("Building with dotnet core"));
82
83
  const
83
84
  configuration = env.resolve("BUILD_CONFIGURATION"),
@@ -85,18 +86,26 @@ function buildForNetCore(solutions) {
85
86
  if (!env.resolveFlag("BUILD_MSBUILD_NODE_REUSE")) {
86
87
  msbuildArgs.push("/nodeReuse:false");
87
88
  }
89
+ /** @type DotNetBuildOptions */
90
+ const options = {
91
+ target: "[not set]",
92
+ verbosity: env.resolve("BUILD_VERBOSITY"),
93
+ configuration,
94
+ additionalArguments: msbuildArgs
95
+ };
88
96
  return promisifyStream(
89
97
  solutions
90
98
  .pipe(
91
- dotnetBuild({
92
- verbosity: env.resolve("BUILD_VERBOSITY"),
93
- configuration,
94
- // msbuild attempts to re-use nodes, which causes issues
95
- // if you're building unrelated projects on the same machine with,
96
- // eg, different versions of Microsoft.Net.Compilers
97
- msbuildArgs,
98
- echo: true
99
- })
99
+ // dotnetBuild({
100
+ // verbosity: env.resolve("BUILD_VERBOSITY"),
101
+ // configuration,
102
+ // // msbuild attempts to re-use nodes, which causes issues
103
+ // // if you're building unrelated projects on the same machine with,
104
+ // // eg, different versions of Microsoft.Net.Compilers
105
+ // msbuildArgs,
106
+ // echo: true
107
+ // })
108
+ build(options)
100
109
  )
101
110
  );
102
111
  }
@@ -1,26 +1,124 @@
1
1
  "use strict";
2
2
  (function () {
3
3
  const spawn = requireModule("spawn");
4
+ const q = requireModule("quote-if-required");
5
+ async function build(opts) {
6
+ validate(opts);
7
+ const args = [
8
+ "build",
9
+ q(opts.target)
10
+ ];
11
+ pushCommonBuildArgs(args, opts);
12
+ pushFlag(args, opts.disableBuildServers, "--disable-build-servers");
13
+ pushFlag(args, opts.noIncremental, "--no-incremental");
14
+ pushFlag(args, opts.noDependencies, "--no-dependencies");
15
+ pushFlag(args, opts.noRestore, "--no-restore");
16
+ pushFlag(args, opts.selfContained, "--self-contained");
17
+ pushVersionSuffix(args, opts);
18
+ pushProperties(args, opts);
19
+ pushAdditionalArgs(args, opts);
20
+ return runDotNetWith(args, opts);
21
+ }
4
22
  async function test(opts) {
5
23
  const args = [
6
24
  "test",
7
- opts.target
25
+ q(opts.target)
8
26
  ];
9
- pushIfSet(args, opts.verbosity, "-v");
10
- pushIfSet(args, opts.configuration, "-c");
11
- pushFlag(args, opts.noBuild, "--no-build");
12
- pushFlag(args, opts.noRestore, "--no-restore");
27
+ pushCommonBuildArgs(args, opts);
28
+ pushIfSet(args, opts.settingsFile, "--settings");
29
+ pushIfSet(args, opts.filter, "--filter");
30
+ pushIfSet(args, opts.diagnostics, "--diag");
31
+ pushNoBuild(args, opts);
32
+ pushNoRestore(args, opts);
13
33
  pushLoggers(args, opts.loggers);
34
+ pushProperties(args, opts);
35
+ pushEnvVars(args, opts.env);
36
+ pushAdditionalArgs(args, opts);
37
+ return runDotNetWith(args, opts);
38
+ }
39
+ async function pack(opts) {
40
+ const args = [
41
+ "pack",
42
+ q(opts.target)
43
+ ];
44
+ pushVerbosity(args, opts);
45
+ pushOutput(args, opts);
46
+ pushConfiguration(args, opts);
47
+ pushNoBuild(args, opts);
48
+ pushFlag(args, opts.includeSymbols, "--include-symbols");
49
+ pushFlag(args, opts.includeSource, "--include-source");
50
+ pushNoRestore(args, opts);
51
+ pushVersionSuffix(args, opts);
52
+ return runDotNetWith(args, opts);
53
+ }
54
+ function pushCommonBuildArgs(args, opts) {
55
+ pushVerbosity(args, opts);
56
+ pushConfiguration(args, opts);
57
+ pushIfSet(args, opts.framework, "--framework");
58
+ pushIfSet(args, opts.runtime, "--runtime");
59
+ pushIfSet(args, opts.arch, "--arch");
60
+ pushIfSet(args, opts.os, "--os");
61
+ pushOutput(args, opts);
62
+ }
63
+ function pushVersionSuffix(args, opts) {
64
+ pushIfSet(args, opts.versionSuffix, "--version-suffix");
65
+ }
66
+ function pushNoRestore(args, opts) {
67
+ pushFlag(args, opts.noRestore, "--no-restore");
68
+ }
69
+ function pushNoBuild(args, opts) {
70
+ pushFlag(args, opts.noBuild, "--no-build");
71
+ }
72
+ function validate(opts) {
73
+ if (!opts) {
74
+ throw new Error("no options provided");
75
+ }
76
+ if (!opts.target) {
77
+ throw new Error("target not set");
78
+ }
79
+ }
80
+ function pushOutput(args, opts) {
81
+ pushIfSet(args, opts.output, "--output");
82
+ }
83
+ function pushVerbosity(args, opts) {
84
+ pushIfSet(args, opts.verbosity, "--verbosity");
85
+ }
86
+ function pushConfiguration(args, opts) {
87
+ pushIfSet(args, opts.configuration, "--configuration");
88
+ }
89
+ function pushAdditionalArgs(args, opts) {
90
+ if (opts.additionalArguments) {
91
+ args.push.apply(args, opts.additionalArguments);
92
+ }
93
+ }
94
+ async function runDotNetWith(args, consumers) {
14
95
  try {
15
96
  return await spawn("dotnet", args, {
16
- stdout: opts.stdout,
17
- stderr: opts.stderr
97
+ stdout: consumers.stdout,
98
+ stderr: consumers.stderr
18
99
  });
19
100
  }
20
101
  catch (e) {
21
102
  return e;
22
103
  }
23
104
  }
105
+ function pushProperties(args, opts) {
106
+ if (!opts.msbuildProperties) {
107
+ return;
108
+ }
109
+ for (const key of Object.keys(opts.msbuildProperties)) {
110
+ args.push(`/p:${q(key)}=${q(opts.msbuildProperties[key])}`);
111
+ }
112
+ }
113
+ function pushEnvVars(args, env) {
114
+ if (!env) {
115
+ return;
116
+ }
117
+ for (const key of Object.keys(env)) {
118
+ args.push("-e");
119
+ args.push(`${q(key)}=${q(env[key])}`);
120
+ }
121
+ }
24
122
  function pushLoggers(args, loggers) {
25
123
  if (!loggers) {
26
124
  return;
@@ -37,7 +135,7 @@
37
135
  }
38
136
  function pushIfSet(args, value, cliSwitch) {
39
137
  if (value) {
40
- args.push(cliSwitch, value);
138
+ args.push(cliSwitch, q(value));
41
139
  }
42
140
  }
43
141
  function pushFlag(args, value, cliSwitch) {
@@ -46,6 +144,8 @@
46
144
  }
47
145
  }
48
146
  module.exports = {
49
- test
147
+ test,
148
+ build,
149
+ pack
50
150
  };
51
151
  })();
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ (function () {
3
+ const dotnetCli = requireModule("dotnet-cli");
4
+ const { streamify } = requireModule("streamify");
5
+ function wrap(fn) {
6
+ return async (opts) => {
7
+ const result = await fn(opts);
8
+ if (result instanceof Error) {
9
+ throw result;
10
+ }
11
+ // otherwise, discard the result
12
+ };
13
+ }
14
+ function pack(opts) {
15
+ return streamify(wrap(dotnetCli.pack), f => {
16
+ const copy = Object.assign({}, opts);
17
+ copy.target = f.path;
18
+ return copy;
19
+ }, "gulp-dotnet-cli-pack", "creating nuget package");
20
+ }
21
+ function build(opts) {
22
+ return streamify(wrap(dotnetCli.build), f => {
23
+ const copy = Object.assign({}, opts);
24
+ copy.target = f.path;
25
+ return copy;
26
+ }, "gulp-dotnet-cli-build", "building project or solution");
27
+ }
28
+ function test(opts) {
29
+ return streamify(wrap(dotnetCli.test), f => {
30
+ const copy = Object.assign({}, opts);
31
+ copy.target = f.path;
32
+ return copy;
33
+ }, "gulp-dotnet-cli-pack", "creating nuget package");
34
+ }
35
+ module.exports = {
36
+ build,
37
+ test,
38
+ pack
39
+ };
40
+ })();
@@ -46,7 +46,6 @@
46
46
  const errors = e.stderr.join("\n").trim(), isDuplicatePackageError = errors.match(/: 409 /);
47
47
  if (isDuplicatePackageError && options.suppressDuplicateError) {
48
48
  console.warn(`ignoring duplicate package error: ${errors}`);
49
- return e;
50
49
  }
51
50
  }
52
51
  throw e;
@@ -1,14 +1,15 @@
1
- function isAlreadyQuoted(str) {
2
- return str &&
3
- str[0] === "\"" &&
4
- str[str.length-1] === "\"";
5
- }
6
-
7
- module.exports = function quoteIfRequired(arg) {
8
- arg = arg || "";
9
- return (arg.indexOf(" ") > -1 || arg.indexOf(";") > -1) &&
10
- arg.match(/^".*"$/) == null
11
- ? isAlreadyQuoted(arg) ? arg : `"${arg}"`
12
- : arg;
13
- }
14
-
1
+ "use strict";
2
+ (function () {
3
+ function isAlreadyQuoted(str) {
4
+ return !!str &&
5
+ str[0] === "\"" &&
6
+ str[str.length - 1] === "\"";
7
+ }
8
+ module.exports = function quoteIfRequired(arg) {
9
+ arg = arg || "";
10
+ return (arg.indexOf(" ") > -1 || arg.indexOf(";") > -1) &&
11
+ arg.match(/^".*"$/) == null
12
+ ? isAlreadyQuoted(arg) ? arg : `"${arg}"`
13
+ : arg;
14
+ };
15
+ })();
@@ -429,7 +429,7 @@ module.exports = function _env(env) {
429
429
  env.register({
430
430
  name: "PACK_CONFIGURATION",
431
431
  help: "Build configuration for dotnet-core packing",
432
- default: "Release"
432
+ default: "Release",
433
433
  });
434
434
 
435
435
  env.register({
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ (function () {
4
+ const through = require("through2");
5
+ const PluginError = require("plugin-error");
6
+ function streamify(fn, optionsFactory, pluginName, operation) {
7
+ return through.obj(async function (file, enc, cb) {
8
+ try {
9
+ const options = await optionsFactory(file);
10
+ await fn(options);
11
+ cb(null, file);
12
+ }
13
+ catch (e) {
14
+ const pluginError = new PluginError(pluginName, `${operation} failed: ${e.message || e}`);
15
+ this.emit("error", pluginError);
16
+ cb(pluginError, file);
17
+ }
18
+ });
19
+ }
20
+ module.exports = {
21
+ streamify
22
+ };
23
+ })();
@@ -12,8 +12,7 @@ const getToolsFolder = requireModule("get-tools-folder"),
12
12
  { rewriteFile } = requireModule("rewrite-file"),
13
13
  del = require("del"),
14
14
  debug = require("debug")("pack"),
15
- gulp = requireModule("gulp"),
16
- { pack } = requireModule("gulp-nuget-pack");
15
+ gulp = requireModule("gulp");
17
16
 
18
17
  env.associate(
19
18
  [
@@ -53,6 +52,7 @@ function removeBadEntities(buffer) {
53
52
  }
54
53
 
55
54
  function packWithNuget(target, incrementVersion) {
55
+ const { pack } = requireModule("gulp-nuget-pack");
56
56
  const nuspecs = resolveMasks(
57
57
  "PACK_INCLUDE_NUSPEC",
58
58
  "PACK_EXCLUDE_NUSPEC",
@@ -72,6 +72,7 @@ function packWithNuget(target, incrementVersion) {
72
72
  }
73
73
 
74
74
  function packWithDotnetCore(target, incrementVersion) {
75
+ const { pack } = requireModule("gulp-dotnet-cli");
75
76
  const projects = resolveMasks("PACK_INCLUDE_CSPROJ", "PACK_EXCLUDE_CSPROJ", p => {
76
77
  return (p || "").match(/\.csproj$/) ? p : `${p}.csproj`;
77
78
  });
@@ -92,15 +93,17 @@ function packWithDotnetCore(target, incrementVersion) {
92
93
  .pipe(incrementPackageVersion())
93
94
  .pipe(rewriteFile(removeBadEntities));
94
95
  }
96
+ /** @type DotnetPackOptions */
95
97
  const packConfig = {
98
+ target: "[not set]",
96
99
  output: path.resolve(target),
97
100
  configuration
98
101
  };
99
102
  if (process.env["PACK_VERSION"] !== undefined) {
100
- packConfig.version = process.env["PACK_VERSION"]
103
+ packConfig.versionSuffix = process.env["PACK_VERSION"]
101
104
  }
102
105
  return stream.pipe(
103
- dotnetPack(packConfig)
106
+ pack(packConfig)
104
107
  );
105
108
  }
106
109
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zarro",
3
- "version": "1.130.0",
3
+ "version": "1.130.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"
@@ -14,7 +14,10 @@
14
14
  "clean-cache": "rimraf .jest-cache",
15
15
  "pretest": "run-s clean-cache build verify-submodules",
16
16
  "test": "jest",
17
- "autotest": "jest --watch",
17
+ "quick-test": "jest -o --no-cache",
18
+ "clear-console": "console-cls",
19
+ "autotest-once": "run-s clear-console build quick-test",
20
+ "autotest": "nodemon -w gulp-tasks -w tests -w types.d.ts -x \"npm run autotest-once || cd .\" -e ts",
18
21
  "autobuild": "nodemon -w gulp-tasks -w tests -x \"npm run build || cd .\" -e ts",
19
22
  "prestart": "run-s build",
20
23
  "start": "node index.js",
@@ -84,10 +87,12 @@
84
87
  "@types/jest": "^26.0.20",
85
88
  "@types/node": "^13.13.40",
86
89
  "@types/rimraf": "^3.0.0",
90
+ "@types/through2": "^2.0.38",
87
91
  "@types/xml2js": "^0.4.8",
88
92
  "@types/yargs": "^15.0.13",
93
+ "console-cls": "^1.2.2",
89
94
  "debugger-is-attached": "^1.2.0",
90
- "expect-even-more-jest": "^1.11.0",
95
+ "expect-even-more-jest": "^1.15.0",
91
96
  "filesystem-sandbox": "^1.20.0",
92
97
  "jest": "^26.6.3",
93
98
  "nodemon": "^2.0.19",
package/types.d.ts CHANGED
@@ -1,11 +1,14 @@
1
+ // noinspection JSUnusedGlobalSymbols
2
+
1
3
  import * as fs from "fs";
2
- import { Stream } from "stream";
4
+ import { Stream, Transform } from "stream";
3
5
  import { StyleFunction } from "ansi-colors";
4
6
  import { AlterPackageJsonVersionOptions } from "./gulp-tasks/modules/alter-package-json-version";
5
7
  import { RimrafOptions } from "./gulp-tasks/modules/rimraf";
6
8
  import { ExecFileOptionsWithBufferEncoding } from "child_process";
7
9
  import { IoConsumer, IoHandlers } from "./gulp-tasks/modules/exec";
8
10
  import { StatsBase } from "fs";
11
+ import * as vinyl from "vinyl";
9
12
 
10
13
  // copied out of @types/fancy-log because imports are being stupid
11
14
  interface Logger {
@@ -22,6 +25,8 @@ declare global {
22
25
  type VoidVoid = () => void;
23
26
  type AsyncVoidVoid = () => Promise<void>;
24
27
  type AsyncVoidFunc<T> = () => Promise<T>;
28
+ type AsyncTVoid<T> = (arg: T) => Promise<void>;
29
+ type OptionsFactory<T> = (file: vinyl.BufferFile) => T | Promise<T>;
25
30
  type ErrorReporter = (e: Error) => Promise<void> | void;
26
31
  type GulpCallback =
27
32
  (() => Promise<any> | NodeJS.EventEmitter) | ((done: VoidVoid) => Promise<any> | NodeJS.EventEmitter)
@@ -30,6 +35,10 @@ declare global {
30
35
  type ResolveNuget = (nugetPath: Optional<string>, errorOnMissing: boolean) => string;
31
36
  type FindLocalNuget = () => Promise<string>;
32
37
 
38
+ interface Streamify {
39
+ streamify<T>(fn: AsyncTVoid<T>, optionsFactory: OptionsFactory<T>, pluginName: string, operation: string): Transform;
40
+ }
41
+
33
42
  interface GulpWithHelp {
34
43
  task(name: string, callback: GulpCallback): void;
35
44
  task(name: string, help: string, callback: GulpCallback): void;
@@ -405,6 +414,7 @@ declare global {
405
414
 
406
415
  type GitTagFromCsProj = (options?: GitTagOptions) => Stream;
407
416
  type GitFetch = (all: boolean) => Promise<void>;
417
+ type NugetPush = (packageFile: string, sourceName?: string, options?: NugetPushOpts) => Promise<void>;
408
418
 
409
419
  interface Log {
410
420
  setThreshold(level: number): void;
@@ -469,6 +479,7 @@ declare global {
469
479
  type GitTag = (tag: string | GitTagOptions, comment?: string, where?: string) => Promise<void>;
470
480
  type GitPush = (dryRun?: boolean | GitPushOptions, quiet?: boolean, where?: string) => Promise<void>;
471
481
  type GitPushTags = (dryRun?: boolean | GitPushOptions, comment?: string, where?: string) => Promise<void>;
482
+ type QuoteIfRequired = (str?: string) => string;
472
483
 
473
484
  type StdioOptions = "pipe" | "ignore" | "inherit" |
474
485
  Array<("pipe" | "ipc" | "ignore" | "inherit" | any | number | null | undefined)>;
@@ -534,21 +545,64 @@ declare global {
534
545
 
535
546
  type DotNetTestLoggers = Dictionary<Dictionary<string>>;
536
547
 
537
- interface DotNetTestOptions {
538
- target: string;
548
+ interface DotNetBaseOptions {
549
+ msbuildProperties?: Dictionary<string>;
550
+ additionalArguments?: string[]
539
551
  verbosity?: DotNetVerbosity,
552
+ }
553
+
554
+ interface DotNetCommonBuildOptions extends DotNetBaseOptions {
555
+ target: string;
556
+ configuration?: string;
557
+ framework?: string;
558
+ runtime?: string;
559
+ output?: string;
560
+ arch?: string;
561
+ os?: string;
562
+ }
563
+
564
+ interface DotnetPackOptions extends DotNetBaseOptions, IoConsumers {
565
+ target: string;
566
+ output?: string;
540
567
  configuration?: string;
541
568
  noBuild?: boolean;
569
+ includeSymbols?: boolean;
570
+ includeSource?: boolean;
542
571
  noRestore?: boolean;
543
- loggers?: DotNetTestLoggers;
544
- stdout?: IoConsumer,
545
- stderr?: IoConsumer
572
+ versionSuffix?: string;
573
+ }
574
+
575
+ interface DotNetBuildOptions extends DotNetCommonBuildOptions, IoConsumers {
576
+ noIncremental?: boolean;
577
+ disableBuildServers?: boolean;
578
+ selfContained?: boolean;
579
+ noDependencies?: boolean;
580
+ noRestore?: boolean;
581
+ versionSuffix?: string;
582
+ }
583
+
584
+ interface IoConsumers {
585
+ stdout?: IoConsumer;
586
+ stderr?: IoConsumer;
546
587
  }
547
588
 
548
- type DotNetTestFunction = (opts: DotNetTestOptions) => Promise<void>;
589
+ interface DotNetTestOptions extends DotNetCommonBuildOptions, IoConsumers {
590
+ noBuild?: boolean;
591
+ noRestore?: boolean;
592
+ loggers?: DotNetTestLoggers;
593
+ settingsFile?: string;
594
+ env?: Dictionary<string>;
595
+ filter?: string;
596
+ diagnostics?: string;
597
+ }
549
598
 
599
+ type DotNetTestFunction = (opts: DotNetTestOptions) => Promise<SpawnResult | SpawnError>;
600
+ type DotNetBuildFunction = (opts: DotNetBuildOptions) => Promise<SpawnResult | SpawnError>;
601
+ type DotNetPackFunction = (opts: DotnetPackOptions) => Promise<SpawnResult | SpawnError>;
550
602
  interface DotNetCli {
551
- test: DotNetTestFunction
603
+ test: DotNetTestFunction;
604
+ build: DotNetBuildFunction;
605
+ pack: DotNetPackFunction;
552
606
  }
553
607
 
554
608
  // scraped from https://spdx.org/licenses/