Skip to content

Commit

Permalink
Merge pull request #20 from CloudCannon/feat/bump-versions
Browse files Browse the repository at this point in the history
Update available versions
  • Loading branch information
rycoll authored Jul 5, 2024
2 parents 946c842 + 79d459d commit 47cd350
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 35 deletions.
44 changes: 22 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudcannon/command-builder",
"version": "1.1.7",
"version": "1.1.8",
"description": "A script that builds the script that builds your site",
"main": "src/index.js",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ module.exports = class Compiler {
static getVersionCommands(buildConfig) {
return Object.entries(versionOptions).flatMap(([name, options]) => {
if (buildConfig[name] && buildConfig[name] !== options.default) {
const command = options.getVersionCommand(buildConfig[name]);
const { version, message } = options.migrateVersion(buildConfig[name]);
const command = options.getVersionCommand(version);
if (!command) {
return [];
}

return [
...message,
`echo "$ ${command}"`,
command
];
Expand Down
28 changes: 17 additions & 11 deletions src/options/version-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ const versionOptions = {
hugoVersion: {
name: 'Hugo version',
type: 'string',
default: '0.122.0',
default: '0.128.1',
checkCommand:
"$((hugo version 2> /dev/null || echo 'unknown') | sed 's/[][]//g' | sed 's/^hugo v//' | cut -d ' ' -f 1 | cut -d '-' -f 1)",
getVersionCommand: (version) => `install-hugo ${version}`
getVersionCommand: (version) => `install-hugo ${version}`,
migrateVersion: (version) => ({ version, message: [] })
},
rubyVersion: {
name: 'Ruby version',
Expand All @@ -14,6 +15,7 @@ const versionOptions = {
checkCommand:
'$((ruby -v 2> /dev/null || echo \'unknown\') | sed "s/[][]//g" | sed "s/^ruby //g" | cut -d " " -f 1 | cut -d "p" -f 1)',
getVersionCommand: (version) => (version !== 'file' ? `rbenv local ${version}` : null),
migrateVersion: (version) => ({ version, message: [] }),
options: [
{
value: '2.6.7'
Expand Down Expand Up @@ -45,19 +47,22 @@ const versionOptions = {
getVersionCommand: (version) => (version !== 'file'
? `nvm use ${version}`
: '[ -f .nvmrc ] && nvm install'),
migrateVersion: (version) => {
if (version === '10' || version === '12') {
return {
version: '14',
message: [
`echo "$ nvm use ${version}"`,
`echo 'Node version ${version} is no longer supported. Falling back to Node version 14.'`
]
};
}
return { version, message: [] };
},
options: [
{
value: '10'
},
{
value: '12'
},
{
value: '14'
},
{
value: '15'
},
{
value: '16'
},
Expand All @@ -82,6 +87,7 @@ const versionOptions = {
getVersionCommand: (version) => (version !== 'file'
? `dvm use ${version}`
: '[ -f .dvmrc ] && dvm install'),
migrateVersion: (version) => ({ version, message: [] }),
options: [
{
value: '1.40.2'
Expand Down

0 comments on commit 47cd350

Please sign in to comment.