You've already forked hugo-extended
mirror of
https://github.com/jakejarvis/hugo-extended.git
synced 2025-09-13 04:05:31 -04:00
feat(hugo): upgrade Hugo to v0.17 (#9)
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
const path = require('path');
|
||||
const BinWrapper = require('bin-wrapper');
|
||||
const getBinalyName = require('./getBinalyName');
|
||||
const pkg = require('../package');
|
||||
|
||||
const hugoVersion = pkg.hugoVersion;
|
||||
const baseUrl = `https://github.com/spf13/hugo/releases/download/v${hugoVersion}/`;
|
||||
|
||||
const binalyNames = getBinalyName(hugoVersion, process.platform, process.arch);
|
||||
|
||||
module.exports = new BinWrapper()
|
||||
.src(`${baseUrl}${binalyNames.comp}`)
|
||||
.dest(path.join(__dirname, '../vendor'))
|
||||
.use(`${binalyNames.exe}`);
|
@@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const spawn = require('child_process').spawn;
|
||||
const input = process.argv.slice(2);
|
||||
const bin = require('./');
|
||||
|
||||
spawn(bin, input, {stdio: 'inherit'})
|
||||
.on('exit', process.exit);
|
@@ -1,74 +0,0 @@
|
||||
const semver = require('semver');
|
||||
// see: https://github.com/spf13/hugo/releases
|
||||
|
||||
const packageMap = version => ({
|
||||
darwin: {
|
||||
arm: `hugo_${version}_darwin-arm32.tgz`,
|
||||
ia32: `hugo_${version}_osx-32bit.tgz`,
|
||||
x64: `hugo_${version}_osx-64bit.tgz`
|
||||
},
|
||||
freebsd: {
|
||||
arm: `hugo_${version}_freebsd-arm32.tgz`,
|
||||
ia32: `hugo_${version}_freebsd-32bit.tgz`,
|
||||
x64: `hugo_${version}_freebsd-64bit.tgz`
|
||||
},
|
||||
linux: {
|
||||
arm: `hugo_${version}_linux-arm64.tgz`,
|
||||
ia32: `hugo_${version}_linux-32bit.tgz`,
|
||||
x64: `hugo_${version}_linux-64bit.tgz`
|
||||
},
|
||||
sunos: {
|
||||
x64: `hugo_${version}_solaris-64bit.tgz`
|
||||
},
|
||||
win32: {
|
||||
ia32: `hugo_${version}_windows-32bit.zip`,
|
||||
x64: `hugo_${version}_windows-64bit.zip`
|
||||
}
|
||||
});
|
||||
|
||||
const legacyPackageMap = version => ({
|
||||
darwin: {
|
||||
ia32: `hugo_${version}_darwin_386.zip`,
|
||||
x64: `hugo_${version}_darwin_amd64.zip`
|
||||
},
|
||||
freebsd: {
|
||||
arm: `hugo_${version}_freebsd_arm.zip`,
|
||||
ia32: `hugo_${version}_freebsd_386.zip`,
|
||||
x64: `hugo_${version}_freebsd_amd64.zip`
|
||||
},
|
||||
linux: {
|
||||
arm: `hugo_${version}_linux_arm.tar.gz`,
|
||||
ia32: `hugo_${version}_linux_386.tar.gz`,
|
||||
x64: `hugo_${version}_linux_amd64.tar.gz`
|
||||
},
|
||||
sunos: {}, // not supported
|
||||
win32: {
|
||||
ia32: `hugo_${version}_windows_386.zip`,
|
||||
x64: `hugo_${version}_windows_amd64.zip`
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = (version, plat, arch) => {
|
||||
const validSemverVersion = `${version}.0`;
|
||||
if (semver.lt(validSemverVersion, '0.10.0')) {
|
||||
throw new Error(`hugoVersion<0.10 is not supported: ${version}`);
|
||||
}
|
||||
// exceptionally when...
|
||||
if (version === '0.15' && plat === 'win32' && arch === 'ia32') {
|
||||
return {
|
||||
comp: 'hugo_0.15_windows_386_32-bit-only.zip',
|
||||
exe: 'hugo_0.15_windows_386.exe'
|
||||
}
|
||||
}
|
||||
const isLegacy = semver.lte(validSemverVersion, '0.15.0');
|
||||
const comp = isLegacy ? legacyPackageMap(version)[plat][arch] : packageMap(version)[plat][arch];
|
||||
if (!comp) {
|
||||
throw new Error(`Can't detect binaly name. Check your platform: ${plat}, arch: ${arch}, version: ${version}.
|
||||
For more info: https://github.com/fenneclab/hugo-bin/blob/master/test/getBinalyName.js`);
|
||||
}
|
||||
const exe = (isLegacy ? `${comp.replace(/\.zip|\.tar\.gz/, '')}` : 'hugo') + (plat === 'win32' ? '.exe' : '');
|
||||
return {
|
||||
comp,
|
||||
exe
|
||||
};
|
||||
}
|
42
lib/index.js
42
lib/index.js
@@ -1,3 +1,41 @@
|
||||
const bin = require('./binary');
|
||||
const path = require('path');
|
||||
const BinWrapper = require('bin-wrapper');
|
||||
const pkg = require('../package');
|
||||
|
||||
module.exports = bin.path();
|
||||
const hugoVersion = pkg.hugoVersion;
|
||||
const baseUrl = `https://github.com/spf13/hugo/releases/download/v${hugoVersion}/`;
|
||||
const binNameMap = {
|
||||
darwin: {
|
||||
ia32: `hugo_${hugoVersion}_darwin_386`,
|
||||
x64: `hugo_${hugoVersion}_darwin_amd64`
|
||||
},
|
||||
freebsd: {
|
||||
arm: `hugo_${hugoVersion}_freebsd_arm`,
|
||||
ia32: `hugo_${hugoVersion}_freebsd_386`,
|
||||
x64: `hugo_${hugoVersion}_freebsd_amd64`
|
||||
},
|
||||
linux: {
|
||||
arm: `hugo_${hugoVersion}_linux_arm`,
|
||||
ia32: `hugo_${hugoVersion}_linux_386`,
|
||||
x64: `hugo_${hugoVersion}_linux_amd64`
|
||||
},
|
||||
win32: {
|
||||
ia32: `hugo_${hugoVersion}_windows_386.exe`,
|
||||
x64: `hugo_${hugoVersion}_windows_amd64.exe`
|
||||
}
|
||||
};
|
||||
const binName = (binNameMap[process.platform] && binNameMap[process.platform][process.arch]) || '';
|
||||
|
||||
module.exports = new BinWrapper()
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_FreeBSD-32bit.zip`, 'freebsd', 'x86')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_FreeBSD-64bit.zip`, 'freebsd', 'x64')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_freebsd_arm.zip`, 'freebsd', 'arm')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_Linux-32bit.tar.gz`, 'linux', 'x86')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_Linux-64bit.tar.gz`, 'linux', 'x64')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_linux_arm.tar.gz`, 'linux', 'arm')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_MacOS-32bit.zip`, 'darwin', 'x86')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_MacOS-64bit.zip`, 'darwin', 'x64')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_Windows-32bit.zip`, 'win32', 'x86')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_Windows-64bit.zip`, 'win32', 'x64')
|
||||
.dest(path.join(__dirname, '../vendor'))
|
||||
.use(binName);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
const bin = require('./binary');
|
||||
const bin = require('./');
|
||||
const log = require('logalot');
|
||||
|
||||
bin.run(['version'], err => {
|
||||
|
Reference in New Issue
Block a user