@@ -9,8 +9,6 @@ import * as semver from 'semver';
9
9
10
10
const repoRoot = path . join ( __dirname , '..' ) ;
11
11
const packageJsonPath = path . join ( repoRoot , 'package.json' ) ;
12
- const typesRoot = path . join ( repoRoot , 'types' ) ;
13
- const typesPackageJsonPath = path . join ( typesRoot , 'package.json' ) ;
14
12
const nuspecPath = path . join ( repoRoot , 'Worker.nuspec' ) ;
15
13
const nuspecVersionRegex = / < v e r s i o n > ( .* ) \$ p r e r e l e a s e S u f f i x \$ < \/ v e r s i o n > / i;
16
14
const constantsPath = path . join ( repoRoot , 'src' , 'constants.ts' ) ;
@@ -24,9 +22,6 @@ if (args.validate) {
24
22
} else {
25
23
console . log ( `This script can be used to either update the version of the worker or validate that the repo is in a valid state with regards to versioning.
26
24
27
- NOTE: For the types package, only the major & minor version need to match the worker. We follow the same pattern as DefinitelyTyped as described here:
28
- https://github.com/DefinitelyTyped/DefinitelyTyped#how-do-definitely-typed-package-versions-relate-to-versions-of-the-corresponding-library
29
-
30
25
Example usage:
31
26
32
27
npm run updateVersion -- --version 3.3.0
@@ -39,35 +34,21 @@ function validateVersion() {
39
34
const packageJson = readJSONSync ( packageJsonPath ) ;
40
35
const packageJsonVersion = packageJson . version ;
41
36
42
- const typesPackageJson = readJSONSync ( typesPackageJsonPath ) ;
43
- const typesPackageJsonVersion = typesPackageJson . version ;
44
-
45
37
const nuspecVersion = getVersion ( nuspecPath , nuspecVersionRegex ) ;
46
38
47
39
const constantsVersion = getVersion ( constantsPath , constantsVersionRegex ) ;
48
40
49
41
console . log ( 'Found the following versions:' ) ;
50
42
console . log ( `- package.json: ${ packageJsonVersion } ` ) ;
51
- console . log ( `- types/package.json: ${ typesPackageJsonVersion } ` ) ;
52
43
console . log ( `- Worker.nuspec: ${ nuspecVersion } ` ) ;
53
44
console . log ( `- src/constants.ts: ${ constantsVersion } ` ) ;
54
45
55
46
const parsedVersion = semver . parse ( packageJsonVersion ) ;
56
- const parsedTypesVersion = semver . parse ( typesPackageJsonVersion ) ;
57
-
58
- if (
59
- ! packageJsonVersion ||
60
- ! nuspecVersion ||
61
- ! constantsVersion ||
62
- ! typesPackageJsonVersion ||
63
- ! parsedVersion ||
64
- ! parsedTypesVersion
65
- ) {
47
+
48
+ if ( ! packageJsonVersion || ! nuspecVersion || ! constantsVersion || ! parsedVersion ) {
66
49
throw new Error ( 'Failed to detect valid versions in all expected files' ) ;
67
50
} else if ( nuspecVersion !== packageJsonVersion || constantsVersion !== packageJsonVersion ) {
68
51
throw new Error ( `Worker versions do not match.` ) ;
69
- } else if ( parsedVersion . major !== parsedTypesVersion . major || parsedVersion . minor !== parsedTypesVersion . minor ) {
70
- throw new Error ( `Types package does not match the major/minor version of the worker.` ) ;
71
52
} else {
72
53
console . log ( 'Versions match! 🎉' ) ;
73
54
}
@@ -84,15 +65,7 @@ function getVersion(filePath: string, regex: RegExp): string {
84
65
85
66
function updateVersion ( newVersion : string ) {
86
67
updatePackageJsonVersion ( repoRoot , newVersion ) ;
87
-
88
- if ( newVersion . endsWith ( '.0' ) ) {
89
- updatePackageJsonVersion ( typesRoot , newVersion ) ;
90
- } else {
91
- console . log ( `Skipping types/package.json because this is a patch version.` ) ;
92
- }
93
-
94
68
updateVersionByRegex ( nuspecPath , nuspecVersionRegex , newVersion ) ;
95
-
96
69
updateVersionByRegex ( constantsPath , constantsVersionRegex , newVersion ) ;
97
70
}
98
71
0 commit comments