zarro 1.170.14 → 1.170.18

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.
@@ -805,6 +805,25 @@ WARNING: 'dotnet pack' ignores --version-suffix when a nuspec file is provided.
805
805
  }
806
806
  return finalResult;
807
807
  }
808
+ async function installPackage(opts) {
809
+ if (!opts) {
810
+ throw new Error(`no options passed to 'installPackage' - target project and package name not specified`);
811
+ }
812
+ if (!`${opts.projectFile}`.trim()) {
813
+ throw new Error(`projectFile not specified`);
814
+ }
815
+ if (!`${opts.id}`.trim()) {
816
+ throw new Error(`package id not specified`);
817
+ }
818
+ const args = ["add", "package", opts.projectFile, opts.id];
819
+ pushIfSet(args, opts.version, "--version");
820
+ pushIfSet(args, opts.framework, "--framework");
821
+ pushFlag(args, opts.noRestore, "--no-restore");
822
+ pushIfSet(args, opts.source, "--source");
823
+ pushIfSet(args, opts.packageDirectory, "--package-directory");
824
+ pushFlag(args, opts.preRelease, "--prerelease");
825
+ await runDotNetWith(args, opts);
826
+ }
808
827
  module.exports = {
809
828
  test,
810
829
  build,
@@ -821,6 +840,7 @@ WARNING: 'dotnet pack' ignores --version-suffix when a nuspec file is provided.
821
840
  enableNugetSource,
822
841
  tryFindConfiguredNugetSource,
823
842
  incrementTempDbPortHintIfFound,
824
- searchPackages
843
+ searchPackages,
844
+ installPackage
825
845
  };
826
846
  })();
@@ -67,7 +67,7 @@
67
67
  const ver = other instanceof Version
68
68
  ? other
69
69
  : new Version(other);
70
- return compareVersionArrays(this.version, ver.version);
70
+ return compareVersions(this.version, this.tag, ver.version, ver.tag);
71
71
  }
72
72
  toString() {
73
73
  const ver = this.version.join(".");
@@ -76,7 +76,7 @@
76
76
  : ver;
77
77
  }
78
78
  }
79
- function compareVersionArrays(x, y) {
79
+ function compareVersions(x, xTag, y, yTag) {
80
80
  const shortest = Math.min(x.length, y.length), compare = [];
81
81
  for (let i = 0; i < shortest; i++) {
82
82
  if (x[i] > y[i]) {
@@ -90,11 +90,11 @@
90
90
  }
91
91
  }
92
92
  if (compare.length === 0) {
93
- return 0;
93
+ return compareTags(xTag, yTag);
94
94
  }
95
95
  const allZero = compare.reduce((acc, cur) => acc && (cur === "0"), true);
96
96
  if (allZero) {
97
- return 0;
97
+ return compareTags(xTag, yTag);
98
98
  }
99
99
  for (const s of compare) {
100
100
  if (s === ">") {
@@ -104,7 +104,29 @@
104
104
  return -1;
105
105
  }
106
106
  }
107
+ return compareTags(xTag, yTag);
108
+ }
109
+ function compareTags(xTag, yTag) {
110
+ if (xTag && yTag) {
111
+ return compareStrings(xTag, yTag);
112
+ }
113
+ if (xTag) {
114
+ // assume x is the beta for y
115
+ return -1;
116
+ }
117
+ if (yTag) {
118
+ // assume y is the beta for x
119
+ return 1;
120
+ }
107
121
  return 0;
108
122
  }
123
+ function compareStrings(s1, s2) {
124
+ if (s1 === s2) {
125
+ return 0;
126
+ }
127
+ return s1 < s2
128
+ ? -1
129
+ : 1;
130
+ }
109
131
  module.exports = Version;
110
132
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zarro",
3
- "version": "1.170.14",
3
+ "version": "1.170.18",
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"
package/types.d.ts CHANGED
@@ -1510,6 +1510,18 @@ declare global {
1510
1510
  exactMatch?: boolean;
1511
1511
  preRelease?: boolean;
1512
1512
  configFile?: string;
1513
+ latestOnly?: boolean;
1514
+ }
1515
+
1516
+ interface DotNetInstallNugetPackageOption extends DotNetBaseOptions {
1517
+ id: string;
1518
+ projectFile: string;
1519
+ version?: string;
1520
+ framework?: string;
1521
+ noRestore?: boolean;
1522
+ source?: string;
1523
+ packageDirectory?: string;
1524
+ preRelease?: boolean;
1513
1525
  }
1514
1526
 
1515
1527
  interface IoConsumers {
@@ -1573,6 +1585,7 @@ declare global {
1573
1585
  type DotNetDisableNugetSourceFunction = (source: string | NugetSource) => Promise<void>;
1574
1586
  type DotNetTryMatchNugetSourceFunction = (nameOrUrlOrHostOrSpec: string | Partial<NugetSource> | RegExp) => Promise<Optional<NugetSource>>;
1575
1587
  type DotNetSearchNugetPackagesFunction = (opts: DotNetSearchPackagesOptions | string) => Promise<PackageInfo[]>;
1588
+ type DotNetInstallNugetPackageFunction = (opts: DotNetInstallNugetPackageOption | string) => Promise<void>;
1576
1589
 
1577
1590
  interface DotNetCli {
1578
1591
  clean: DotNetCleanFunction;
@@ -1591,6 +1604,7 @@ declare global {
1591
1604
  tryFindConfiguredNugetSource: DotNetTryMatchNugetSourceFunction;
1592
1605
  incrementTempDbPortHintIfFound: (env: Dictionary<string>) => void;
1593
1606
  searchPackages: DotNetSearchNugetPackagesFunction;
1607
+ installPackage: DotNetInstallNugetPackageFunction;
1594
1608
  }
1595
1609
 
1596
1610
  type ReadCsProjNode = (csproj: string) => Promise<string>;