-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "version" string and parsed "versionInfo"
Fixes #1726
- Loading branch information
1 parent
4502ab9
commit a018871
Showing
7 changed files
with
152 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @noflow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const { version } = require('../package.json'); | ||
const { writeFile, parseSemver } = require('./utils'); | ||
|
||
const versionInfo = parseSemver(version); | ||
const body = `/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
*/ | ||
/** | ||
* Note: This file is autogenerated using "resources/gen-version.js" script and | ||
* automaticly updated by "yarn version" command. | ||
*/ | ||
/** | ||
* A string containing the version of the GraphQL.js library | ||
*/ | ||
export const version = '${version}'; | ||
/** | ||
* An object containing the components of the GraphQL.js version string | ||
*/ | ||
export const versionInfo = Object.freeze({ | ||
major: ${versionInfo.major}, | ||
minor: ${versionInfo.minor}, | ||
patch: ${versionInfo.patch}, | ||
preReleaseTag: ${JSON.stringify(versionInfo.preReleaseTag || null)}, | ||
}); | ||
`; | ||
|
||
if (require.main === module) { | ||
writeFile('./src/version.js', body); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
*/ | ||
|
||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { version, versionInfo } from '../version'; | ||
|
||
describe('Version', () => { | ||
it('version', () => { | ||
expect(version).to.be.a('string'); | ||
expect(version).to.match(/^\d+\.\d+\.\d(-rc.\d+)?$/); | ||
}); | ||
|
||
it('versionInfo', () => { | ||
expect(versionInfo).to.be.an('object'); | ||
expect(versionInfo).to.have.all.keys( | ||
'major', | ||
'minor', | ||
'patch', | ||
'preReleaseTag', | ||
); | ||
|
||
const { major, minor, patch, preReleaseTag } = versionInfo; | ||
|
||
expect(major).to.be.a('number'); | ||
expect(minor).to.be.a('number'); | ||
expect(patch).to.be.a('number'); | ||
if (preReleaseTag !== null) { | ||
expect(preReleaseTag).to.be.a('string'); | ||
} | ||
|
||
expect( | ||
`${major}.${minor}.${patch}` + | ||
(preReleaseTag !== null ? '-' + preReleaseTag : ''), | ||
).to.equal(version); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
*/ | ||
|
||
/** | ||
* Note: This file is autogenerated using "resources/gen-version.js" script and | ||
* automaticly updated by "yarn version" command. | ||
*/ | ||
|
||
/** | ||
* A string containing the version of the GraphQL.js library | ||
*/ | ||
export const version = '14.3.0'; | ||
|
||
/** | ||
* An object containing the components of the GraphQL.js version string | ||
*/ | ||
export const versionInfo = Object.freeze({ | ||
major: 14, | ||
minor: 3, | ||
patch: 0, | ||
preReleaseTag: null, | ||
}); |