diff --git a/package-lock.json b/package-lock.json index 06b2841..c66b189 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cloudcannon/command-builder", - "version": "1.1.7", + "version": "1.1.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@cloudcannon/command-builder", - "version": "1.1.7", + "version": "1.1.8", "license": "ISC", "devDependencies": { "eslint": "^7.27.0", @@ -1704,12 +1704,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -2824,9 +2824,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" @@ -5982,9 +5982,9 @@ } }, "node_modules/ws": { - "version": "7.5.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.3.tgz", - "integrity": "sha512-kQ/dHIzuLrS6Je9+uv81ueZomEwH0qVYstcAQ4/Z93K8zeko9gtAbttJWzoC5ukqXY1PpoouV3+VSOqEAFt5wg==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "dev": true, "engines": { "node": ">=8.3.0" @@ -7364,12 +7364,12 @@ } }, "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "requires": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" } }, "browser-process-hrtime": { @@ -8274,9 +8274,9 @@ } }, "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "requires": { "to-regex-range": "^5.0.1" @@ -10746,9 +10746,9 @@ } }, "ws": { - "version": "7.5.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.3.tgz", - "integrity": "sha512-kQ/dHIzuLrS6Je9+uv81ueZomEwH0qVYstcAQ4/Z93K8zeko9gtAbttJWzoC5ukqXY1PpoouV3+VSOqEAFt5wg==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "dev": true, "requires": {} }, diff --git a/package.json b/package.json index 7bce8e4..03d3a3b 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/lib/compiler.js b/src/lib/compiler.js index 69c951c..7313b2a 100644 --- a/src/lib/compiler.js +++ b/src/lib/compiler.js @@ -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 ]; diff --git a/src/options/version-options.js b/src/options/version-options.js index 0b70c2e..de264fb 100644 --- a/src/options/version-options.js +++ b/src/options/version-options.js @@ -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', @@ -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' @@ -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' }, @@ -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'