Skip to content

Commit 421a026

Browse files
committed
Merge branch 'master' into ianc/fixing-gcb-package-json
2 parents 8ebdfb3 + 103b6f0 commit 421a026

File tree

16 files changed

+328
-80
lines changed

16 files changed

+328
-80
lines changed

apps/rush-lib/CHANGELOG.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
{
22
"name": "@microsoft/rush-lib",
33
"entries": [
4+
{
5+
"version": "3.0.11",
6+
"tag": "@microsoft/rush-lib_v3.0.11",
7+
"date": "Mon, Jul 3, 2017 10:53:12 PM",
8+
"comments": {
9+
"patch": [
10+
{
11+
"comment": "Rush 3.0.11 was released."
12+
}
13+
]
14+
}
15+
},
416
{
517
"version": "3.0.10",
618
"tag": "@microsoft/rush-lib_v3.0.10",

apps/rush-lib/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log - @microsoft/rush-lib
22

3-
This log was last generated on Tue, 27 Jun 2017 21:49:51 GMT and should not be manually modified.
3+
This log was last generated on Mon, 03 Jul 2017 22:58:11 GMT and should not be manually modified.
4+
5+
## 3.0.11
6+
Mon, Jul 3, 2017 10:53:12 PM
7+
8+
### Patches
9+
10+
- Rush 3.0.11 was released.
411

512
## 3.0.10
613
Tue, 27 Jun 2017 21:44:50 GMT

apps/rush-lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microsoft/rush-lib",
3-
"version": "3.0.10",
3+
"version": "3.0.11",
44
"description": "A library for writing scripts that interact with the Rush tool",
55
"repository": {
66
"type": "git",

apps/rush/CHANGELOG.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
{
22
"name": "@microsoft/rush",
33
"entries": [
4+
{
5+
"version": "3.0.11",
6+
"tag": "@microsoft/rush_v3.0.11",
7+
"date": "Mon, Jul 3, 2017 10:53:12 PM",
8+
"comments": {
9+
"patch": [
10+
{
11+
"comment": "Add support for non-SemVer dependency specifiers in package.json; for example, \"github:gulpjs/gulp#4.0\" or \"git://github.com/user/project.git#commit-ish\""
12+
}
13+
]
14+
}
15+
},
416
{
517
"version": "3.0.10",
618
"tag": "@microsoft/rush_v3.0.10",

apps/rush/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log - @microsoft/rush
22

3-
This log was last generated on Tue, 27 Jun 2017 21:49:51 GMT and should not be manually modified.
3+
This log was last generated on Mon, 03 Jul 2017 22:58:11 GMT and should not be manually modified.
4+
5+
## 3.0.11
6+
Mon, Jul 3, 2017 10:53:12 PM
7+
8+
### Patches
9+
10+
- Add support for non-SemVer dependency specifiers in package.json; for example, "github:gulpjs/gulp#4.0" or "git://github.com/user/project.git#commit-ish"
411

512
## 3.0.10
613
Tue, 27 Jun 2017 21:44:50 GMT

apps/rush/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microsoft/rush",
3-
"version": "3.0.10",
3+
"version": "3.0.11",
44
"description": "The professional solution for consolidating all your JavaScript projects in one Git repo",
55
"keywords": [
66
"install",
@@ -29,7 +29,7 @@
2929
"license": "MIT",
3030
"dependencies": {
3131
"@microsoft/package-deps-hash": "~2.0.5",
32-
"@microsoft/rush-lib": "3.0.10",
32+
"@microsoft/rush-lib": "3.0.11",
3333
"@microsoft/stream-collator": "~2.0.2",
3434
"@microsoft/ts-command-line": "~2.0.2",
3535
"builtins": "~1.0.3",
@@ -41,6 +41,7 @@
4141
"inquirer": "~1.2.1",
4242
"lodash": "~4.15.0",
4343
"minimatch": "~3.0.2",
44+
"npm-package-arg": "~5.1.2",
4445
"read-package-tree": "~5.1.5",
4546
"semver": "~5.3.0",
4647
"wordwrap": "~1.0.0"

apps/rush/src/utilities/ShrinkwrapFile.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4+
import * as colors from 'colors';
45
import * as fsx from 'fs-extra';
56
import * as os from 'os';
67
import * as semver from 'semver';
8+
import npmPackageArg = require('npm-package-arg');
9+
710
import { Utilities, RushConstants } from '@microsoft/rush-lib';
811

912
interface IShrinkwrapDependencyJson {
@@ -24,6 +27,7 @@ interface IShrinkwrapJson {
2427
*/
2528
export default class ShrinkwrapFile {
2629
private _shrinkwrapJson: IShrinkwrapJson;
30+
private _alreadyWarnedSpecs: Set<string> = new Set<string>();
2731

2832
public static loadFromFile(shrinkwrapJsonFilename: string): ShrinkwrapFile | undefined {
2933
let data: string = undefined;
@@ -107,8 +111,20 @@ export default class ShrinkwrapFile {
107111
return false;
108112
}
109113

110-
// If we found it, the version must be compatible
111-
return semver.satisfies(dependencyJson.version, versionRange);
114+
const result: npmPackageArg.IResult = npmPackageArg.resolve(dependencyName, versionRange);
115+
switch (result.type) {
116+
case 'version':
117+
case 'range':
118+
// If it's a SemVer pattern, then require that the shrinkwrapped version must be compatible
119+
return semver.satisfies(dependencyJson.version, versionRange);
120+
default:
121+
// Only warn once for each spec
122+
if (!this._alreadyWarnedSpecs.has(result.rawSpec)) {
123+
this._alreadyWarnedSpecs.add(result.rawSpec);
124+
console.log(colors.yellow(`WARNING: Not validating ${result.type}-based specifier: "${result.rawSpec}"`));
125+
}
126+
return true;
127+
}
112128
}
113129

114130
private constructor(shrinkwrapJson: IShrinkwrapJson) {
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// Type definitions for npm-package-arg 5.1.2
2+
// Project: https://github.com/npm/npm-package-arg
3+
// Definitions by: pgonzal
4+
5+
declare module 'npm-package-arg' {
6+
namespace npmPackageArg {
7+
interface IResult {
8+
/**
9+
* Indicates the type of dependency reference. For example 'version' indicates
10+
* a normal SemVer pattern. See the package README.md for full docs.
11+
*
12+
* git - a git repository
13+
* tag - a tagged version, e.g. "example@latest"
14+
* version - A specific version number, e.g. "example@1.2.3"
15+
* range - A version range, e.g. "example@2.x"
16+
* file - A local .tar.gz, .tar or .tgz file
17+
* directory - A local directory
18+
* remote - An HTTP url to a .tar.gz, .tar or .tgz file
19+
*/
20+
type: 'git' | 'tag' | 'version' | 'range' | 'file' | 'directory' | 'remote';
21+
22+
/**
23+
* True for tag, version and range types.
24+
*/
25+
registry: boolean | undefined;
26+
27+
/**
28+
* If known, the "name" field expected in the package.
29+
*/
30+
name: string | null;
31+
32+
/**
33+
* For scoped NPM packages, the scope name; otherwise the value will be null.
34+
*/
35+
scope: string | null | undefined;
36+
37+
/**
38+
* An escaped name for use when making requests to the NPM registry.
39+
*/
40+
escapedName: string | null;
41+
42+
/**
43+
* The original specifier passed to npmPackageArg.resolve(), or the specifier part of the
44+
* argument for npmPackageArg().
45+
*/
46+
rawSpec: string;
47+
48+
/**
49+
* The specifier, as normalized by NPM for saving in a package.json file.
50+
*/
51+
saveSpec: string | null;
52+
53+
/**
54+
* The specifier, as normalized by NPM for fetching a resource. For example, a "directory"
55+
* type dependency, this will be the folder path.
56+
*/
57+
fetchSpec: string | null;
58+
59+
/**
60+
* For Git dependencies, if the committish includes a "semver:" prefix, then this is
61+
* the range part.
62+
* Example: For "mochajs/mocha#semver:1.2.3", the value would be "1.2.3"
63+
*/
64+
gitRange: string | null | undefined;
65+
66+
/**
67+
* For Git dependencies, the committish part of the specifier, or "master" if omitted.
68+
* Example: For "mochajs/mocha#4727d357ea", the value would be "4727d357ea"
69+
*/
70+
gitCommittish: string | null | undefined;
71+
72+
/**
73+
* The original input that was provided. For npmPackageArg.resolve(), the name and
74+
* spec parameters will be combined, e.g. "example" and "1.2" will be combined as "example@1.2".
75+
*/
76+
raw: string;
77+
}
78+
79+
/**
80+
* Parses a package dependency, based on a package name and version specifier as might appear
81+
* in a package.json file. An Error object will be thrown if the input is invalid.
82+
*
83+
* @param name - The name of an NPM package, possibly including a scope
84+
* @param spec - A version specifier, e.g. "^1.2.3", "git://github.com/user/project.git#commit-ish", etc.
85+
* @param where - a path that file paths will be resolved relative to; otherwise, process.cwd()
86+
* is used
87+
* @returns an object containing parsed information.
88+
*
89+
* @see {@link https://docs.npmjs.com/files/package.json#dependencies} for full syntax.
90+
*/
91+
function resolve(name: string, spec: string, where?: string): npmPackageArg.IResult;
92+
}
93+
94+
/**
95+
* Parses a package dependency, based on a combined package name and version specifier
96+
* as might be passed to "npm install". An Error object will be thrown if the input is invalid.
97+
*
98+
* @param arg - a string such as "example@1.2", "bitbucket:user/example", "file:../example", etc.
99+
* @param where - a path that file paths will be resolved relative to; otherwise, process.cwd()
100+
* is used
101+
* @returns an object containing parsed information.
102+
*
103+
* @see {@link https://docs.npmjs.com/files/package.json#dependencies} for full syntax.
104+
*/
105+
function npmPackageArg(arg: string, where?: string): npmPackageArg.IResult;
106+
107+
export = npmPackageArg;
108+
}

apps/rush/typings/read-package-tree/read-package-tree.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Type definitions for read-package-tree 5.1.2
22
// Project: https://github.com/npm/read-package-tree
3-
// Definitions by: Pete Gonzalez
3+
// Definitions by: pgonzal
44

55
declare module 'read-package-tree' {
66
namespace readPackageTree {

apps/rush/typings/tsd.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/// <reference path="colors/colors.d.ts" />
66
/// <reference path="git-repo-info/git-repo-info.d.ts" />
77
/// <reference path="glob-escape/glob-escape.d.ts" />
8+
/// <reference path="inquirer/inquirer.d.ts" />
9+
/// <reference path="npm-package-arg/npm-package-arg.d.ts" />
810
/// <reference path="read-package-tree/read-package-tree.d.ts" />
911
/// <reference path="wordwrap/wordwrap.d.ts" />
10-
/// <reference path="inquirer/inquirer.d.ts" />

0 commit comments

Comments
 (0)