zarro 1.126.0 → 1.126.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,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  (function () {
4
- const PLUGIN_NAME = __filename.replace(/\.js$/, ""), gutil = requireModule("gulp-util"), loadXmlFile = requireModule("load-xml-file"), es = require("event-stream"), gitTag = requireModule("git-tag"), gitPushTags = requireModule("git-push-tags"), gitPush = requireModule("git-push"), { ZarroError } = requireModule("zarro-error"), defaultOptions = {
4
+ const PLUGIN_NAME = __filename.replace(/\.js$/, ""), gutil = requireModule("gulp-util"), loadXmlFile = requireModule("load-xml-file"), es = require("event-stream"), gitTag = requireModule("git-tag"), gitPushTags = requireModule("git-push-tags"), gitPush = requireModule("git-push"), { ZarroError } = requireModule("zarro-error"), { parseNugetVersion } = requireModule("parse-nuget-version"), defaultOptions = {
5
5
  push: true,
6
- dryRun: false
6
+ dryRun: false,
7
+ ignorePreRelease: true
7
8
  };
8
9
  module.exports = function gitTagFromCsProj(options) {
9
10
  const opts = Object.assign({}, defaultOptions, options);
@@ -18,11 +19,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
19
  if (csprojFiles.length > 1) {
19
20
  throw new ZarroError(`too many csproj files! specify the one to use for creating a versioned tag!\n${csprojFiles.join("\n- ")}`);
20
21
  }
21
- const xml = await loadXmlFile(csprojFiles[0]), version = findPackageVersion(xml, csprojFiles[0]);
22
+ const xml = await loadXmlFile(csprojFiles[0]), version = findPackageVersion(xml, csprojFiles[0]), versionInfo = parseNugetVersion(version);
22
23
  if (opts.dryRun) {
23
24
  console.log(`Dry run: would have tagged at ${version}`);
24
25
  return this.emit("end");
25
26
  }
27
+ if (versionInfo.isPreRelease && opts.ignorePreRelease) {
28
+ console.log(`Not tagging: this is a pre-release. Set ignorePreRelease: false on options to tag pre-releases.`);
29
+ return this.emit("end");
30
+ }
26
31
  try {
27
32
  await gitTag({
28
33
  tag: `v${version}`,
@@ -1,55 +1,45 @@
1
- const
2
- PLUGIN_NAME = __filename.replace(/\.js$/, ""),
3
- gutil = requireModule("gulp-util"),
4
- loadXmlFile = requireModule("load-xml-file"),
5
- es = require("event-stream"),
6
- gitTag = requireModule("git-tag"),
7
- gitPushTags = requireModule("git-push-tags"),
8
- gitPush = requireModule("git-push"),
9
- { ZarroError } = requireModule("zarro-error"),
10
- defaultOptions = {
11
- push: true,
12
- dryRun: false
13
- };
14
-
15
- module.exports = function gitTagFromPackageNuspec(options) {
16
- options = Object.assign({}, defaultOptions, options);
17
- const nuspecs = [];
18
- return es.through(
19
- async function write(file) {
20
- nuspecs.push(file.path);
21
- this.emit("data", file);
22
- },
23
- async function end() {
24
- if (nuspecs.length == 0) {
25
- throw new ZarroError("no nuspecs found to tag from?");
26
- }
27
- if (nuspecs.length > 1) {
28
- throw new ZarroError(
29
- `too many nuspecs! specify the one to use for creating a versioned tag!\n${nuspecs.join(
30
- "\n- "
31
- )}`
32
- );
33
- }
34
- const xml = await loadXmlFile(nuspecs[0]),
35
- version = xml.package.metadata[0].version[0].trim();
36
-
37
- if (options.dryRun) {
38
- console.log(`Dry run: would have tagged at ${version}`);
39
- return this.emit("end");
40
- }
41
-
42
- try {
43
- await gitTag(`v${version}`, `:bookmark: ${version}`);
44
- if (options.push) {
45
- await gitPushTags();
46
- await gitPush();
47
- gutil.log(gutil.colors.green("-> all commits and tags pushed!"));
48
- }
49
- this.emit("end");
50
- } catch (e) {
51
- this.emit("error", new gutil.PluginError(PLUGIN_NAME, e));
52
- }
53
- }
54
- );
55
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ (function () {
4
+ const PLUGIN_NAME = __filename.replace(/\.js$/, ""), gutil = requireModule("gulp-util"), loadXmlFile = requireModule("load-xml-file"), es = require("event-stream"), gitTag = requireModule("git-tag"), gitPushTags = requireModule("git-push-tags"), gitPush = requireModule("git-push"), { parseNugetVersion } = requireModule("parse-nuget-version"), { ZarroError } = requireModule("zarro-error"), defaultOptions = {
5
+ push: true,
6
+ dryRun: false,
7
+ ignorePreRelease: true
8
+ };
9
+ module.exports = function gitTagFromPackageNuspec(options) {
10
+ options = Object.assign({}, defaultOptions, options);
11
+ const nuspecs = [];
12
+ return es.through(async function write(file) {
13
+ nuspecs.push(file.path);
14
+ this.emit("data", file);
15
+ }, async function end() {
16
+ if (nuspecs.length == 0) {
17
+ throw new ZarroError("no nuspecs found to tag from?");
18
+ }
19
+ if (nuspecs.length > 1) {
20
+ throw new ZarroError(`too many nuspecs! specify the one to use for creating a versioned tag!\n${nuspecs.join("\n- ")}`);
21
+ }
22
+ const xml = await loadXmlFile(nuspecs[0]), version = xml.package.metadata[0].version[0].trim(), versionInfo = parseNugetVersion(version);
23
+ if (options.dryRun) {
24
+ console.log(`Dry run: would have tagged at ${version}`);
25
+ return this.emit("end");
26
+ }
27
+ if (versionInfo.isPreRelease && options.ignorePreRelease) {
28
+ console.log(`Not tagging: this is a pre-release. Set ignorePreRelease: false on options to tag pre-releases.`);
29
+ return this.emit("end");
30
+ }
31
+ try {
32
+ await gitTag(`v${version}`, `:bookmark: ${version}`);
33
+ if (options.push) {
34
+ await gitPushTags();
35
+ await gitPush();
36
+ gutil.log(gutil.colors.green("-> all commits and tags pushed!"));
37
+ }
38
+ this.emit("end");
39
+ }
40
+ catch (e) {
41
+ this.emit("error", new gutil.PluginError(PLUGIN_NAME, e));
42
+ }
43
+ });
44
+ };
45
+ })();
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ (function () {
3
+ class VersionInfo {
4
+ constructor(major, minor, patch, tag) {
5
+ this.major = major;
6
+ this.minor = minor;
7
+ this.patch = patch;
8
+ this.tag = tag;
9
+ }
10
+ get isPreRelease() {
11
+ return !!this.tag;
12
+ }
13
+ toString() {
14
+ const version = `${this.major}.${this.minor}.${this.patch}`;
15
+ return this.tag
16
+ ? `${version}-${this.tag}`
17
+ : version;
18
+ }
19
+ }
20
+ function parseNugetVersion(versionStringOrFileName) {
21
+ const withoutExtension = versionStringOrFileName.replace(/\.nupkg$/, ""), packageWithVersionAndTag = withoutExtension.split("-"), packageWithVersionParts = packageWithVersionAndTag[0].split("."), idAndVersion = collect(packageWithVersionParts);
22
+ return new PackageVersionInfo(idAndVersion.id, new VersionInfo(idAndVersion.version[0] || 0, idAndVersion.version[1] || 0, idAndVersion.version[2] || 0, packageWithVersionAndTag[1] || ""));
23
+ }
24
+ class PackageVersionInfo {
25
+ constructor(id, version) {
26
+ this.id = id;
27
+ this.version = version;
28
+ }
29
+ get isPreRelease() {
30
+ var _a, _b;
31
+ return (_b = (_a = this.version) === null || _a === void 0 ? void 0 : _a.isPreRelease) !== null && _b !== void 0 ? _b : true;
32
+ }
33
+ }
34
+ function collect(stringParts) {
35
+ // moving in from the right, any pure number becomes part of the version, then the
36
+ // rest is package identifier parts
37
+ const idParts = [], versionParts = [];
38
+ stringParts.reverse();
39
+ let inVersion = true;
40
+ for (const part of stringParts) {
41
+ if (inVersion) {
42
+ const asNum = parseInt(part);
43
+ if (isNaN(asNum)) {
44
+ idParts.push(part);
45
+ inVersion = false;
46
+ }
47
+ else {
48
+ versionParts.push(asNum);
49
+ }
50
+ }
51
+ else {
52
+ idParts.push(part);
53
+ }
54
+ }
55
+ idParts.reverse();
56
+ versionParts.reverse();
57
+ return {
58
+ id: idParts.join("."),
59
+ version: versionParts
60
+ };
61
+ }
62
+ module.exports = {
63
+ parseNugetVersion
64
+ };
65
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zarro",
3
- "version": "1.126.0",
3
+ "version": "1.126.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"