Skip to content

build: resolve latest MDC version through yarn #23220

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

Merged
merged 1 commit into from
Jul 23, 2021
Merged
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
19 changes: 16 additions & 3 deletions scripts/circleci/setup-mdc-canary.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
const {join} = require('path');
const {spawn} = require('child_process');
const {spawn, spawnSync} = require('child_process');
const packageJson = require(join(__dirname, '../../package.json'));
const versionsProcess = spawnSync('yarn', [
'info', 'material-components-web', 'dist-tags.canary', '--json'
], {shell: true});
let latestCanaryVersion = null;

try {
latestCanaryVersion = JSON.parse(versionsProcess.stdout.toString()).data;
} catch (e) {
console.error('Failed to retrieve latest MDC version');
throw e;
}

const pattern = /^material-components-web$|^@material\//;
const params = Object.keys(packageJson.devDependencies)
.filter(dependency => pattern.test(dependency))
.reduce((mdcDependencies, dependency) => [...mdcDependencies, `${dependency}@canary`], []);
.reduce((mdcDependencies, dependency) =>
[...mdcDependencies, `${dependency}@${latestCanaryVersion}`], []);

if (!params.length) {
throw Error(`Could not find MDC dependencies in package.json`);
}

console.log('Updating all MDC dependencies to latest canary version');
console.log(`Updating all MDC dependencies to version ${latestCanaryVersion}`);
const childProcess = spawn('yarn', ['add', ...params, '-D'], {shell: true});
childProcess.stdout.on('data', data => console.log(data + ''));
childProcess.stderr.on('data', data => console.error(data + ''));
Expand Down