hugo-bin-extended 0.111.3 → 0.112.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
- Copyright (c) 2016 FennecLab
3
+ Copyright (c) 2020-present Marlon Luan
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,24 +1,27 @@
1
- # hugo-bin-extended [![npm version](https://img.shields.io/npm/v/hugo-bin-extended.svg)](https://www.npmjs.com/package/hugo-bin-extended) [![Build Status](https://img.shields.io/github/actions/workflow/status/MarlonLuan/hugo-bin-extended/ci.yml?branch=main&label=CI&logo=github)](https://github.com/MarlonLuan/hugo-bin-extended/actions?query=workflow%3ACI+branch%3Amain)
1
+ # hugo-bin-extended [![npm version](https://img.shields.io/npm/v/hugo-bin-extended?logo=npm&logoColor=fff)](https://www.npmjs.com/package/hugo-bin-extended) [![Build Status](https://img.shields.io/github/actions/workflow/status/MarlonLuan/hugo-bin-extended/ci.yml?branch=main&label=CI&logo=github)](https://github.com/MarlonLuan/hugo-bin-extended/actions?query=workflow%3ACI+branch%3Amain)
2
2
 
3
3
  > Binary wrapper for [Hugo](https://gohugo.io/)
4
4
 
5
+ - hugo-bin supports the [Extended Hugo version](https://github.com/gohugoio/hugo/releases/tag/v0.43)
6
+ - For usage within corporate networks or behind corporate proxies, the download repository can be overwritten
7
+
8
+ See [Installation options](#installation-options) for more details.
9
+
5
10
  ## Install
6
11
 
7
12
  ```sh
8
13
  npm install hugo-bin-extended --save-dev
9
14
  ```
10
15
 
11
- For usage within corporate networks or behind corporate proxies, the download repository can be overwritten, see [Installation options](#installation-options) for more details.
12
-
13
16
  ## Usage
14
17
 
15
18
  ### API
16
19
 
17
20
  ```js
18
21
  import { execFile } from 'node:child_process';
19
- import hugo from 'hugo-bin-extended';
22
+ import hugoPath from 'hugo-bin-extended';
20
23
 
21
- execFile(hugo, ['version'], (error, stdout) => {
24
+ execFile(hugoPath, ['version'], (error, stdout) => {
22
25
  if (error) {
23
26
  throw error;
24
27
  }
@@ -29,15 +32,23 @@ execFile(hugo, ['version'], (error, stdout) => {
29
32
 
30
33
  ### CLI
31
34
 
35
+ #### Unix
36
+
32
37
  ```sh
38
+ # older npm
33
39
  $(npm bin)/hugo --help
40
+ # newer npm (v9+)
41
+ npm exec hugo help
34
42
  npm run create -- post/my-new-post.md # see below 'npm run-script'
35
43
  ```
36
44
 
37
- or on Windows:
45
+ #### Windows
38
46
 
39
47
  ```bat
48
+ rem older npm
40
49
  for /f "delims=" %F in ('npm bin') do call "%F\hugo" help
50
+ rem newer npm (v9+)
51
+ npm exec hugo help
41
52
  rem see below 'npm run-script'
42
53
  npm run create -- post/my-new-post.md
43
54
  ```
@@ -60,25 +71,27 @@ See the [Hugo Documentation](https://gohugo.io/) for more information.
60
71
 
61
72
  hugo-bin-extended supports options to change the variation of Hugo binaries and to overwrite the download repository.
62
73
 
63
- Each option can be configured in the `hugo-bin-extended` section of your `package.json`:
74
+ Each option can be configured in one of the following ways:
75
+
76
+ ### The `hugo-bin-extended` section of your `package.json`
64
77
 
65
78
  ```json
66
79
  {
67
80
  "name": "your-package",
68
81
  "version": "0.0.1",
69
82
  "hugo-bin-extended": {
70
- "downloadRepo" : "https://some.example.com/artifactory/github-releases"
83
+ "downloadRepo": "https://some.example.com/artifactory/github-releases"
71
84
  }
72
85
  }
73
86
  ```
74
87
 
75
- Also as local or global [.npmrc](https://docs.npmjs.com/files/npmrc) configuration file:
88
+ ### As local or global [.npmrc](https://docs.npmjs.com/files/npmrc) configuration file
76
89
 
77
90
  ```ini
78
91
  hugo_bin_extended_download_repo = "https://some.example.com/artifactory/github-releases"
79
92
  ```
80
93
 
81
- Also as an environment variable:
94
+ ### As environment variables
82
95
 
83
96
  ```sh
84
97
  export HUGO_BIN_EXTENDED_DOWNLOAD_REPO="https://some.example.com/artifactory/github-releases"
@@ -92,7 +105,7 @@ export HUGO_BIN_EXTENDED_DOWNLOAD_REPO="https://some.example.com/artifactory/git
92
105
 
93
106
  Default: `"https://github.com"`
94
107
 
95
- Set it to your corporate proxy url to download the hugo binary from a different download repository.
108
+ Set it to your proxy URL to download the hugo binary from a different download repository.
96
109
 
97
110
  ## Super Inspired By
98
111
 
@@ -102,4 +115,4 @@ Set it to your corporate proxy url to download the hugo binary from a different
102
115
 
103
116
  ## License
104
117
 
105
- MIT © [Marlon Luan](https://www.MarlonLuan.com/)
118
+ [MIT](LICENSE) © [Marlon Luan](https://www.MarlonLuan.com/)
@@ -2,9 +2,9 @@
2
2
 
3
3
  import { spawn } from 'node:child_process';
4
4
  import process from 'node:process';
5
- import hugo from './index.js';
5
+ import hugoPath from '../index.js';
6
6
 
7
7
  const input = process.argv.slice(2);
8
8
 
9
- spawn(hugo, input, { stdio: 'inherit' })
9
+ spawn(hugoPath, input, { stdio: 'inherit' })
10
10
  .on('exit', process.exit);
package/index.js CHANGED
@@ -1,4 +1,7 @@
1
1
  import process from 'node:process';
2
- import lib from './lib/index.js';
2
+ import hugoBin from './lib/index.js';
3
3
 
4
- export default lib(process.cwd()).path();
4
+ const bin = await hugoBin(process.cwd());
5
+ const hugoPath = bin.path();
6
+
7
+ export default hugoPath;
package/lib/index.js CHANGED
@@ -1,38 +1,44 @@
1
- import fs from 'node:fs';
1
+ import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import process from 'node:process';
4
4
  import { fileURLToPath } from 'node:url';
5
- import BinWrapper from 'bin-wrapper';
6
- import { packageConfigSync } from 'pkg-conf';
5
+ import BinWrapper from '@xhmikosr/bin-wrapper';
6
+ import { packageConfig } from 'pkg-conf';
7
7
 
8
- const { hugoVersion } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)));
8
+ const pkg = new URL('../package.json', import.meta.url);
9
+ const { hugoVersion } = JSON.parse(await fs.readFile(pkg));
9
10
 
10
- const destDir = path.join(fileURLToPath(new URL('../vendor', import.meta.url)));
11
+ const destDir = path.join(fileURLToPath(new URL('../vendor/', import.meta.url)));
11
12
  const binName = process.platform === 'win32' ? 'hugo.exe' : 'hugo';
12
13
 
13
- const extendedBin = (baseDownloadUrl) => new BinWrapper()
14
- .src(`${baseDownloadUrl}hugo_extended_${hugoVersion}_darwin-universal.tar.gz`, 'darwin', 'arm64')
15
- .src(`${baseDownloadUrl}hugo_extended_${hugoVersion}_darwin-universal.tar.gz`, 'darwin', 'x64')
16
- .src(`${baseDownloadUrl}hugo_extended_${hugoVersion}_linux-amd64.tar.gz`, 'linux', 'x64')
17
- .src(`${baseDownloadUrl}hugo_extended_${hugoVersion}_linux-arm64.tar.gz`, 'linux', 'arm64')
18
- .src(`${baseDownloadUrl}hugo_extended_${hugoVersion}_windows-amd64.zip`, 'win32', 'x64')
19
- // Fall back to the normal version on unsupported platforms
20
- .src(`${baseDownloadUrl}hugo_${hugoVersion}_dragonfly-amd64.tar.gz`, 'dragonflybsd', 'x64')
21
- .src(`${baseDownloadUrl}hugo_${hugoVersion}_freebsd-amd64.tar.gz`, 'freebsd', 'x64')
22
- .src(`${baseDownloadUrl}hugo_${hugoVersion}_linux-arm.tar.gz`, 'linux', 'arm')
23
- .src(`${baseDownloadUrl}hugo_${hugoVersion}_netbsd-amd64.tar.gz`, 'netbsd', 'x64')
24
- .src(`${baseDownloadUrl}hugo_${hugoVersion}_openbsd-amd64.tar.gz`, 'openbsd', 'x64')
25
- .src(`${baseDownloadUrl}hugo_${hugoVersion}_windows-arm64.zip`, 'win32', 'arm64')
26
- .dest(destDir)
27
- .use(binName);
28
-
29
- function main(projectRoot) {
30
- const config = packageConfigSync('hugo-bin-extended', { cwd: projectRoot });
31
- const downloadRepo = (process.env.HUGO_BIN_EXTENDED_DOWNLOAD_REPO || process.env.npm_config_hugo_bin_extended_download_repo || config.downloadRepo || 'https://github.com');
14
+ function extendedBin(baseUrl) {
15
+ return new BinWrapper()
16
+ .src(`${baseUrl}hugo_extended_${hugoVersion}_darwin-universal.tar.gz`, 'darwin', 'arm64')
17
+ .src(`${baseUrl}hugo_extended_${hugoVersion}_darwin-universal.tar.gz`, 'darwin', 'x64')
18
+ .src(`${baseUrl}hugo_extended_${hugoVersion}_linux-amd64.tar.gz`, 'linux', 'x64')
19
+ .src(`${baseUrl}hugo_extended_${hugoVersion}_linux-arm64.tar.gz`, 'linux', 'arm64')
20
+ .src(`${baseUrl}hugo_extended_${hugoVersion}_windows-amd64.zip`, 'win32', 'x64')
21
+ // Fall back to the normal version on unsupported platforms
22
+ .src(`${baseUrl}hugo_${hugoVersion}_dragonfly-amd64.tar.gz`, 'dragonflybsd', 'x64')
23
+ .src(`${baseUrl}hugo_${hugoVersion}_freebsd-amd64.tar.gz`, 'freebsd', 'x64')
24
+ .src(`${baseUrl}hugo_${hugoVersion}_linux-arm.tar.gz`, 'linux', 'arm')
25
+ .src(`${baseUrl}hugo_${hugoVersion}_netbsd-amd64.tar.gz`, 'netbsd', 'x64')
26
+ .src(`${baseUrl}hugo_${hugoVersion}_openbsd-amd64.tar.gz`, 'openbsd', 'x64')
27
+ .src(`${baseUrl}hugo_${hugoVersion}_windows-arm64.zip`, 'win32', 'arm64')
28
+ .dest(destDir)
29
+ .use(binName);
30
+ }
32
31
 
33
- const baseDownloadUrl = `${downloadRepo}/gohugoio/hugo/releases/download/v${hugoVersion}/`;
32
+ async function main(cwd) {
33
+ const config = await packageConfig('hugo-bin-extended', { cwd });
34
+ const downloadRepo = [
35
+ process.env.HUGO_BIN_EXTENDED_DOWNLOAD_REPO,
36
+ process.env.npm_config_hugo_bin_extended_download_repo,
37
+ config.downloadRepo
38
+ ].find(Boolean) || 'https://github.com';
39
+ const baseUrl = `${downloadRepo}/gohugoio/hugo/releases/download/v${hugoVersion}/`;
34
40
 
35
- return extendedBin(baseDownloadUrl);
41
+ return extendedBin(baseUrl);
36
42
  }
37
43
 
38
44
  export default main;
package/lib/install.js CHANGED
@@ -1,7 +1,7 @@
1
+ import { rm } from 'node:fs/promises';
1
2
  import path from 'node:path';
2
3
  import process from 'node:process';
3
- import picocolors from 'picocolors';
4
- import bin from './index.js';
4
+ import hugoBin from './index.js';
5
5
 
6
6
  function getProjectRoot() {
7
7
  // `projectRoot` on postinstall could be INIT_CWD introduced in npm >= 5.4
@@ -23,10 +23,21 @@ function getProjectRoot() {
23
23
  return cwd;
24
24
  }
25
25
 
26
- bin(getProjectRoot()).run(['version'])
27
- .then(() => {
28
- console.log(picocolors.green('Hugo binary extended successfully installed!'));
26
+ async function main() {
27
+ const projectRoot = getProjectRoot();
28
+ const vendorDir = path.join(projectRoot, './vendor');
29
+
30
+ await rm(vendorDir, { force: true, recursive: true });
31
+
32
+ const bin = await hugoBin(projectRoot);
33
+
34
+ bin.run(['version']).then(() => {
35
+ console.log('Hugo binary extended successfully installed!');
29
36
  })
30
- .catch(error => {
31
- console.error(picocolors.red(`${error.message}\nHugo binary extended installation failed!`));
32
- });
37
+ .catch(error => {
38
+ console.error('Hugo binary extended installation failed!');
39
+ throw new Error(error);
40
+ });
41
+ }
42
+
43
+ main();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hugo-bin-extended",
3
- "version": "0.111.3",
4
- "hugoVersion": "0.111.3",
3
+ "version": "0.112.0",
4
+ "hugoVersion": "0.112.0",
5
5
  "description": "Binary wrapper for Hugo Extended",
6
6
  "repository": {
7
7
  "type": "git",
@@ -12,36 +12,76 @@
12
12
  },
13
13
  "homepage": "https://github.com/MarlonLuan/hugo-bin-extended#readme",
14
14
  "author": "MarlonLuan",
15
+ "contributors": [
16
+ "MarlonLuan"
17
+ ],
18
+ "funding": [
19
+ {
20
+ "type": "github",
21
+ "url": "https://github.com/sponsors/MarlonLuan"
22
+ }
23
+ ],
15
24
  "license": "MIT",
16
25
  "type": "module",
17
- "exports": "./index.js",
26
+ "exports": {
27
+ ".": "./index.js"
28
+ },
18
29
  "bin": {
19
- "hugo": "cli.js"
30
+ "hugo": "bin/cli.js"
20
31
  },
21
32
  "dependencies": {
22
- "bin-wrapper": "^4.1.0",
23
- "picocolors": "^1.0.0",
24
- "pkg-conf": "^4.0.0",
25
- "rimraf": "^3.0.2"
33
+ "@xhmikosr/bin-wrapper": "^5.0.1",
34
+ "pkg-conf": "^4.0.0"
26
35
  },
27
36
  "devDependencies": {
28
37
  "bin-check": "^4.1.0",
29
- "eslint": "^8.35.0",
30
- "uvu": "^0.5.6"
38
+ "uvu": "^0.5.6",
39
+ "xo": "^0.54.2"
31
40
  },
32
41
  "scripts": {
33
- "lint": "eslint .",
34
- "fix": "npm run lint -- --fix",
42
+ "lint": "xo",
43
+ "fix": "xo --fix",
35
44
  "uvu": "uvu test",
36
45
  "test": "npm run lint && npm run uvu",
37
- "postinstall": "rimraf vendor && node lib/install.js"
46
+ "postinstall": "node lib/install.js"
38
47
  },
39
48
  "files": [
49
+ "bin/cli.js",
40
50
  "lib/*.js",
41
- "cli.js",
42
51
  "index.js"
43
52
  ],
44
53
  "engines": {
45
- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
54
+ "node": "^14.14.0 || >=16.0.0"
55
+ },
56
+ "xo": {
57
+ "space": true,
58
+ "rules": {
59
+ "arrow-body-style": "off",
60
+ "camelcase": [
61
+ "error",
62
+ {
63
+ "properties": "never"
64
+ }
65
+ ],
66
+ "capitalized-comments": "off",
67
+ "comma-dangle": [
68
+ "error",
69
+ "never"
70
+ ],
71
+ "operator-linebreak": [
72
+ "error",
73
+ "after"
74
+ ],
75
+ "object-curly-spacing": [
76
+ "error",
77
+ "always"
78
+ ],
79
+ "space-before-function-paren": [
80
+ "error",
81
+ "never"
82
+ ],
83
+ "unicorn/prefer-top-level-await": "off",
84
+ "unicorn/prevent-abbreviations": "off"
85
+ }
46
86
  }
47
87
  }