Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Add TypeScript version validation #21208

Merged
merged 2 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bin/packages/lint-staged-typecheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ const path = require( 'path' );
const fs = require( 'fs' );
const execa = require( 'execa' );

/**
* Internal dependencies
*/
require( './validate-typescript-version' );

/* eslint-disable no-console */

const repoRoot = path.join( __dirname, '..', '..' );
Expand Down
28 changes: 28 additions & 0 deletions bin/packages/validate-typescript-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* External dependencies
*/
const tscDetectedVersion = require( 'typescript' ).version;

/**
* Internal dependencies
*/
const tscDependencyVersion = require( '../../package.json' ).devDependencies
.typescript;

/* eslint-disable no-console */

if ( tscDependencyVersion !== tscDetectedVersion ) {
console.error(
[
'TypeScript dependency out of date.',
'\tDetected: %o',
'\tRequired: %o',
aduth marked this conversation as resolved.
Show resolved Hide resolved
'Please ensure dependencies are up to date.',
].join( require( 'os' ).EOL ),
tscDetectedVersion,
tscDependencyVersion
);
process.exit( 1 );
}

/* eslint-enable no-console */
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
"clean:package-types": "tsc --build --clean",
"prebuild:packages": "npm run clean:packages && lerna run build",
"build:packages": "npm run build:package-types && node ./bin/packages/build.js",
"build:package-types": "tsc --build",
"build:package-types": "node ./bin/packages/validate-typescript-version.js && tsc --build",
"build": "npm run build:packages && wp-scripts build",
"check-engines": "wp-scripts check-engines",
"check-licenses": "concurrently \"wp-scripts check-licenses --prod --gpl2\" \"wp-scripts check-licenses --dev\"",
Expand Down