mirror of
https://github.com/jakejarvis/hugo-extended.git
synced 2025-04-25 16:45:23 -04:00
use @jakejarvis/eslint-config, switch to yarn
This commit is contained in:
parent
09b503609b
commit
0f315eadc4
4
.github/workflows/publish.yml
vendored
4
.github/workflows/publish.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
with:
|
||||
node-version: 14
|
||||
registry-url: https://registry.npmjs.org/
|
||||
- run: npm ci
|
||||
- run: npm publish --access public
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
@ -28,11 +28,11 @@ jobs:
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
- name: npm install and test
|
||||
- name: yarn install and test
|
||||
run: |
|
||||
npm ci
|
||||
npm audit
|
||||
npm test
|
||||
yarn install --frozen-lockfile
|
||||
yarn audit
|
||||
yarn test
|
||||
- name: Checkout gohugoio/hugoBasicExample
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
node_modules/
|
||||
vendor/
|
||||
npm-debug.log
|
||||
package-lock.json
|
||||
|
8
cli.js
8
cli.js
@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
const execa = require('execa');
|
||||
const hugo = require('.');
|
||||
const execa = require("execa");
|
||||
const hugo = require(".");
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
execa(hugo, args, { stdio: 'inherit' });
|
||||
execa(hugo, args, { stdio: "inherit" });
|
||||
|
8
index.js
8
index.js
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
module.exports = require('path').join(
|
||||
module.exports = require("path").join(
|
||||
__dirname,
|
||||
'vendor',
|
||||
process.platform === 'win32' ? 'hugo.exe' : 'hugo'
|
||||
"vendor",
|
||||
process.platform === "win32" ? "hugo.exe" : "hugo",
|
||||
);
|
||||
|
106
install.js
106
install.js
@ -1,47 +1,49 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
const fs = require('fs');
|
||||
const stream = require('stream');
|
||||
const { promisify } = require('util');
|
||||
const path = require('path');
|
||||
const execa = require('execa');
|
||||
const chalk = require('chalk');
|
||||
const got = require('got');
|
||||
const decompress = require('decompress');
|
||||
const sumchecker = require('sumchecker');
|
||||
const fs = require("fs");
|
||||
const stream = require("stream");
|
||||
const { promisify } = require("util");
|
||||
const path = require("path");
|
||||
const execa = require("execa");
|
||||
const chalk = require("chalk");
|
||||
const got = require("got");
|
||||
const decompress = require("decompress");
|
||||
const sumchecker = require("sumchecker");
|
||||
|
||||
installHugo()
|
||||
.then((bin) => {
|
||||
// print output of `hugo version` to console
|
||||
const { stdout } = execa.sync(bin, ['version']);
|
||||
const { stdout } = execa.sync(bin, ["version"]);
|
||||
return stdout;
|
||||
})
|
||||
.then((version) => {
|
||||
console.log(chalk.green('✔ Hugo installed successfully!'));
|
||||
console.log(chalk.green("✔ Hugo installed successfully!"));
|
||||
console.log(version);
|
||||
})
|
||||
.catch((error) => {
|
||||
// pass whatever error occured along the way along to console
|
||||
console.error(chalk.red('✖ Hugo installation failed. :('));
|
||||
console.error(chalk.red("✖ Hugo installation failed. :("));
|
||||
throw error;
|
||||
});
|
||||
|
||||
async function installHugo() {
|
||||
// this package's version number (should) always match the Hugo release we want
|
||||
const { version } = require('./package.json');
|
||||
const { version } = require("./package.json");
|
||||
const downloadBaseUrl = `https://github.com/gohugoio/hugo/releases/download/v${version}/`;
|
||||
const releaseFile = getArchiveFilename(version, process.platform, process.arch);
|
||||
const checksumFile = `hugo_${version}_checksums.txt`;
|
||||
|
||||
// stop here if there's nothing we can download
|
||||
if (!releaseFile) throw 'Are you sure this platform is supported?';
|
||||
if (!releaseFile) {
|
||||
throw "Are you sure this platform is supported?";
|
||||
}
|
||||
|
||||
const releaseUrl = downloadBaseUrl + releaseFile;
|
||||
const checksumUrl = downloadBaseUrl + checksumFile;
|
||||
const vendorDir = path.join(__dirname, 'vendor');
|
||||
const vendorDir = path.join(__dirname, "vendor");
|
||||
const archivePath = path.join(vendorDir, releaseFile);
|
||||
const checksumPath = path.join(vendorDir, checksumFile);
|
||||
const binName = process.platform === 'win32' ? 'hugo.exe' : 'hugo';
|
||||
const binName = process.platform === "win32" ? "hugo.exe" : "hugo";
|
||||
const binPath = path.join(vendorDir, binName);
|
||||
|
||||
try {
|
||||
@ -77,7 +79,7 @@ async function downloadFile(url, dest) {
|
||||
const pipeline = promisify(stream.pipeline);
|
||||
return await pipeline(
|
||||
got.stream(url, { followRedirect: true }), // GitHub releases redirect to unpredictable URLs
|
||||
fs.createWriteStream(dest)
|
||||
fs.createWriteStream(dest),
|
||||
);
|
||||
}
|
||||
|
||||
@ -90,9 +92,9 @@ async function deleteFile(path) {
|
||||
}
|
||||
|
||||
async function checkChecksum(baseDir, checksumFile, binFile) {
|
||||
const checker = new sumchecker.ChecksumValidator('sha256', checksumFile, {
|
||||
const checker = new sumchecker.ChecksumValidator("sha256", checksumFile, {
|
||||
// returns a completely different hash without this for some reason
|
||||
defaultTextEncoding: 'binary'
|
||||
defaultTextEncoding: "binary",
|
||||
});
|
||||
|
||||
return await checker.validate(baseDir, binFile);
|
||||
@ -104,46 +106,46 @@ async function checkChecksum(baseDir, checksumFile, binFile) {
|
||||
function getArchiveFilename(version, os, arch) {
|
||||
const filename =
|
||||
// macOS
|
||||
os === 'darwin' && arch === 'x64'
|
||||
? `hugo_extended_${version}_macOS-64bit.tar.gz` :
|
||||
os === 'darwin' && arch === 'arm64'
|
||||
? `hugo_extended_${version}_macOS-ARM64.tar.gz` :
|
||||
os === "darwin" && arch === "x64" ?
|
||||
`hugo_extended_${version}_macOS-64bit.tar.gz` :
|
||||
os === "darwin" && arch === "arm64" ?
|
||||
`hugo_extended_${version}_macOS-ARM64.tar.gz` :
|
||||
|
||||
// Windows
|
||||
os === 'win32' && arch === 'x64'
|
||||
? `hugo_extended_${version}_Windows-64bit.zip` :
|
||||
os === 'win32' && arch.endsWith('32')
|
||||
? `hugo_${version}_Windows-32bit.zip` :
|
||||
os === "win32" && arch === "x64" ?
|
||||
`hugo_extended_${version}_Windows-64bit.zip` :
|
||||
os === "win32" && arch.endsWith("32") ?
|
||||
`hugo_${version}_Windows-32bit.zip` :
|
||||
|
||||
// Linux
|
||||
os === 'linux' && arch === 'x64'
|
||||
? `hugo_extended_${version}_Linux-64bit.tar.gz` :
|
||||
os === 'linux' && arch.endsWith('32')
|
||||
? `hugo_${version}_Linux-32bit.tar.gz` :
|
||||
os === 'linux' && arch === 'arm'
|
||||
? `hugo_${version}_Linux-ARM.tar.gz` :
|
||||
os === 'linux' && arch === 'arm64'
|
||||
? `hugo_${version}_Linux-ARM64.tar.gz` :
|
||||
os === "linux" && arch === "x64" ?
|
||||
`hugo_extended_${version}_Linux-64bit.tar.gz` :
|
||||
os === "linux" && arch.endsWith("32") ?
|
||||
`hugo_${version}_Linux-32bit.tar.gz` :
|
||||
os === "linux" && arch === "arm" ?
|
||||
`hugo_${version}_Linux-ARM.tar.gz` :
|
||||
os === "linux" && arch === "arm64" ?
|
||||
`hugo_${version}_Linux-ARM64.tar.gz` :
|
||||
|
||||
// FreeBSD
|
||||
os === 'freebsd' && arch === 'x64'
|
||||
? `hugo_${version}_FreeBSD-64bit.tar.gz` :
|
||||
os === 'freebsd' && arch.endsWith('32')
|
||||
? `hugo_${version}_FreeBSD-32bit.tar.gz` :
|
||||
os === 'freebsd' && arch === 'arm'
|
||||
? `hugo_${version}_FreeBSD-ARM.tar.gz` :
|
||||
os === 'freebsd' && arch === 'arm64'
|
||||
? `hugo_${version}_FreeBSD-ARM64.tar.gz` :
|
||||
os === "freebsd" && arch === "x64" ?
|
||||
`hugo_${version}_FreeBSD-64bit.tar.gz` :
|
||||
os === "freebsd" && arch.endsWith("32") ?
|
||||
`hugo_${version}_FreeBSD-32bit.tar.gz` :
|
||||
os === "freebsd" && arch === "arm" ?
|
||||
`hugo_${version}_FreeBSD-ARM.tar.gz` :
|
||||
os === "freebsd" && arch === "arm64" ?
|
||||
`hugo_${version}_FreeBSD-ARM64.tar.gz` :
|
||||
|
||||
// OpenBSD
|
||||
os === 'openbsd' && arch === 'x64'
|
||||
? `hugo_${version}_OpenBSD-64bit.tar.gz` :
|
||||
os === 'openbsd' && arch.endsWith('32')
|
||||
? `hugo_${version}_OpenBSD-32bit.tar.gz` :
|
||||
os === 'openbsd' && arch === 'arm'
|
||||
? `hugo_${version}_OpenBSD-ARM.tar.gz` :
|
||||
os === 'openbsd' && arch === 'arm64'
|
||||
? `hugo_${version}_OpenBSD-ARM64.tar.gz` :
|
||||
os === "openbsd" && arch === "x64" ?
|
||||
`hugo_${version}_OpenBSD-64bit.tar.gz` :
|
||||
os === "openbsd" && arch.endsWith("32") ?
|
||||
`hugo_${version}_OpenBSD-32bit.tar.gz` :
|
||||
os === "openbsd" && arch === "arm" ?
|
||||
`hugo_${version}_OpenBSD-ARM.tar.gz` :
|
||||
os === "openbsd" && arch === "arm64" ?
|
||||
`hugo_${version}_OpenBSD-ARM64.tar.gz` :
|
||||
|
||||
// not gonna work :(
|
||||
null;
|
||||
|
4719
package-lock.json
generated
4719
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@ -30,8 +30,9 @@
|
||||
"sumchecker": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jakejarvis/eslint-config": "*",
|
||||
"eslint": "^7.32.0",
|
||||
"mocha": "^9.1.0"
|
||||
"mocha": "^9.1.1"
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "node install.js",
|
||||
@ -60,14 +61,19 @@
|
||||
"golang"
|
||||
],
|
||||
"eslintConfig": {
|
||||
"extends": "eslint:recommended",
|
||||
"extends": [
|
||||
"@jakejarvis/eslint-config"
|
||||
],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 8,
|
||||
"ecmaVersion": 2018,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true
|
||||
},
|
||||
"rules": {
|
||||
"compat/compat": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,16 @@
|
||||
/* eslint-env node, mocha */
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
const { execFile } = require('child_process');
|
||||
const assert = require('assert');
|
||||
const hugo = require('..');
|
||||
const { execFile } = require("child_process");
|
||||
const assert = require("assert");
|
||||
const hugo = require("..");
|
||||
|
||||
it('Hugo exists and runs?', async () => {
|
||||
assert(execFile(hugo, ['env'], (error, stdout) => {
|
||||
if (error) throw error;
|
||||
it("Hugo exists and runs?", async () => {
|
||||
assert(execFile(hugo, ["env"], (error, stdout) => {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
console.log(stdout);
|
||||
}));
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user