Skip to content

Commit 5a742c2

Browse files
authored
Merge pull request #191 from Polymer/fixswap
Fix git checkout bug and improve dependency swapping
2 parents 0030606 + f284801 commit 5a742c2

File tree

6 files changed

+197
-124
lines changed

6 files changed

+197
-124
lines changed

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,22 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this
66
project adheres to [Semantic Versioning](http://semver.org/).
77

8-
<!-- ## Unreleased -->
8+
## Unreleased
9+
10+
- Fix `git checkout` errors when using advanced git-based dependency swapping.
11+
12+
- When using dependency swapping, a fresh install will now be performed whenever
13+
any dependency version has changed (either in the original `package.json`, or
14+
in the dependency-swap configuration). The `label` field is no longer
15+
significant in this respect.
16+
17+
- When using advanced git-based dependency swapping `{kind: 'git', ...}`, a
18+
query will now always be made to the remote git repo to determine if the
19+
configured `ref` is still up to date. If it is stale, a fresh install will be
20+
performed.
21+
22+
- When using dependency swapping, temp directories will be deleted when there is
23+
an installation failure, so that they are not re-used in a broken state.
924

1025
## [0.5.2] 2020-09-08
1126

config.schema.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
"additionalProperties": false,
167167
"properties": {
168168
"dependencies": {
169-
"$ref": "#/definitions/PackageDependencyMap",
169+
"$ref": "#/definitions/ExtendedPackageDependencyMap",
170170
"description": "Map from NPM package to version. Any version syntax supported by NPM is\nsupported here."
171171
},
172172
"label": {
@@ -226,6 +226,20 @@
226226
],
227227
"type": "object"
228228
},
229+
"ExtendedPackageDependencyMap": {
230+
"additionalProperties": {
231+
"anyOf": [
232+
{
233+
"$ref": "#/definitions/GitDependency"
234+
},
235+
{
236+
"type": "string"
237+
}
238+
]
239+
},
240+
"description": "Tachometer's extensions to the NPM \"dependencies\" field, which allows for\nmore advanced configurations.",
241+
"type": "object"
242+
},
229243
"FirefoxConfig": {
230244
"additionalProperties": false,
231245
"properties": {
@@ -333,20 +347,6 @@
333347
],
334348
"type": "object"
335349
},
336-
"PackageDependencyMap": {
337-
"additionalProperties": {
338-
"anyOf": [
339-
{
340-
"$ref": "#/definitions/GitDependency"
341-
},
342-
{
343-
"type": "string"
344-
}
345-
]
346-
},
347-
"description": "A mapping from NPM package name to version specifier, as used in a\npackage.json's \"dependencies\" and \"devDependencies\".",
348-
"type": "object"
349-
},
350350
"PerformanceEntryMeasurement": {
351351
"additionalProperties": false,
352352
"properties": {

src/configfile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import * as jsonschema from 'jsonschema';
1515
import {BrowserConfig, BrowserName, parseBrowserConfigString, validateBrowserConfig} from './browser';
1616
import {Config, parseHorizons, urlFromLocalPath} from './config';
1717
import * as defaults from './defaults';
18-
import {BenchmarkSpec, Measurement, measurements, PackageDependencyMap} from './types';
18+
import {BenchmarkSpec, ExtendedPackageDependencyMap, Measurement, measurements} from './types';
1919
import {isHttpUrl} from './util';
2020

2121
/**
@@ -266,7 +266,7 @@ interface ConfigFilePackageVersion {
266266
* Map from NPM package to version. Any version syntax supported by NPM is
267267
* supported here.
268268
*/
269-
dependencies: PackageDependencyMap;
269+
dependencies: ExtendedPackageDependencyMap;
270270
}
271271

272272
/**

src/test/versions_test.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import * as path from 'path';
1515

1616
import * as defaults from '../defaults';
1717
import {BenchmarkSpec} from '../types';
18-
import {hashStrings, makeServerPlans, ServerPlan} from '../versions';
18+
import {hashStrings, makeServerPlans, ServerPlan, tachometerVersion} from '../versions';
1919
import {testData} from './test_helpers';
2020

2121
const defaultBrowser = {
@@ -119,8 +119,14 @@ suite('versions', () => {
119119
const {plans: actualPlans, gitInstalls: actualGitInstalls} =
120120
await makeServerPlans(testData, tempDir, specs);
121121

122-
const v1Hash = hashStrings(path.join(testData, 'mylib'), 'v1');
123-
const v2Hash = hashStrings(path.join(testData, 'mylib'), 'v2');
122+
const v1Hash = hashStrings(
123+
tachometerVersion,
124+
path.join(testData, 'mylib', 'package.json'),
125+
JSON.stringify([['mylib', '1.0.0'], ['otherlib', '0.0.0']]));
126+
const v2Hash = hashStrings(
127+
tachometerVersion,
128+
path.join(testData, 'mylib', 'package.json'),
129+
JSON.stringify([['mylib', '2.0.0'], ['otherlib', '0.0.0']]));
124130

125131
const expectedPlans: ServerPlan[] = [
126132
{
@@ -217,7 +223,10 @@ suite('versions', () => {
217223
const {plans: actualPlans, gitInstalls: actualGitInstalls} =
218224
await makeServerPlans(path.join(testData, 'mylib'), tempDir, specs);
219225

220-
const v1Hash = hashStrings(path.join(testData, 'mylib'), 'v1');
226+
const v1Hash = hashStrings(
227+
tachometerVersion,
228+
path.join(testData, 'mylib', 'package.json'),
229+
JSON.stringify([['mylib', '1.0.0'], ['otherlib', '0.0.0']]));
221230
const expectedPlans: ServerPlan[] = [
222231
{
223232
specs: [specs[0]],

src/types.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ export class Deferred<T> {
2929
* package.json's "dependencies" and "devDependencies".
3030
*/
3131
export interface PackageDependencyMap {
32+
[pkg: string]: string;
33+
}
34+
35+
/**
36+
* Tachometer's extensions to the NPM "dependencies" field, which allows for
37+
* more advanced configurations.
38+
*/
39+
export interface ExtendedPackageDependencyMap {
3240
[pkg: string]: string|GitDependency;
3341
}
3442

@@ -58,7 +66,7 @@ export interface GitDependency {
5866
*/
5967
export interface PackageVersion {
6068
label: string;
61-
dependencyOverrides: PackageDependencyMap;
69+
dependencyOverrides: ExtendedPackageDependencyMap;
6270
}
6371

6472
/** The subset of the format of an NPM package.json file we care about. */

0 commit comments

Comments
 (0)