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