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

Add node fixer #793

Merged
merged 3 commits into from
Apr 4, 2022
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
31 changes: 31 additions & 0 deletions .autofix/fixers/update-lang-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const os = require('os');
const util = require('util');
const exec = util.promisify(require('child_process').exec);

exports.register = async (fixers) => {
const { stdout, stderr } = await exec('bash -lc ". ~/.nvm/nvm.sh && nvm ls-remote --no-colors"');
if (stderr) {
throw stderr;
}

const minorVersionReplacements = {};
for (const line of stdout.split('\n')) {
const match = line.trim().match(/^[->]*\s*([a-z1-9\.]+-)?v(\d+\.)(\d+\.\d+)\s*.*$/);
if (!match || match[2] === '0.') {
// Unsupported format, or unsupported version (e.g. Node.js v0).
continue;
}

const prefix = match[1] ? match[1] + 'v' : '';
const pattern = (prefix + match[2]).replace(/\./g, '\\.') + '[0-9][0-9]*\\.[0-9][0-9]*';
minorVersionReplacements[pattern] = prefix + match[2] + match[3];
}

fixers[0].push({
id: 'upgrade-lang-node',
cmd: Object.keys(minorVersionReplacements).map(pattern => {
return `sed ${os.type() === 'Darwin' ? '-i "" -E' : '-i -e'} "s/\\(NODE_VERSION.*\\)${pattern}/\\1${minorVersionReplacements[pattern]}/g" chunks/lang-node/chunk.yaml`;
}).join('\n'),
description: 'update lang-node',
});
}
2 changes: 1 addition & 1 deletion .autofix/fixers/update-lang-python.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ exports.register = async (fixers) => {
cmd: Object.keys(patchVersionReplacements).map(pattern => {
return `sed ${os.type() === 'Darwin' ? '-i "" -E' : '-i -e'} "s/\\(PYTHON_VERSION.*\\)${pattern}/\\1${patchVersionReplacements[pattern]}/g" chunks/lang-python/chunk.yaml`;
}).join('\n'),
description: 'Update Python variants',
description: 'update lang python',
});
};
8 changes: 4 additions & 4 deletions chunks/lang-node/chunk.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
variants:
- name: "16.13.2"
- name: "16"
args:
NODE_VERSION: 16.13.2
- name: "17.4.0"
NODE_VERSION: 16.14.2
- name: "17"
args:
NODE_VERSION: 17.4.0
NODE_VERSION: 17.8.0
6 changes: 3 additions & 3 deletions dazzle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ combiner:
- lang-clojure
- lang-go:1.18.0
- lang-java:11
- lang-node:16.13.2
- lang-node:16
- lang-python:3.8
- lang-ruby:2.7
- lang-rust
Expand All @@ -49,13 +49,13 @@ combiner:
ref:
- base
chunks:
- lang-node:17.4.0
- lang-node:17
- tool-chrome
- name: node-lts
ref:
- base
chunks:
- lang-node:16.13.2
- lang-node:16
- tool-chrome
- name: python
ref:
Expand Down
4 changes: 2 additions & 2 deletions tests/lang-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
entrypoint: [bash, -i, -c]
assert:
- status == 0
- stdout.indexOf("v16.13.2") != -1 ||
stdout.indexOf("v17.4.0") != -1
- stdout.indexOf("v16") != -1 ||
stdout.indexOf("v17") != -1
- desc: it should have yarn
command: [yarn --version]
entrypoint: [bash, -i, -c]
Expand Down