hugo-bin-extended 0.124.0 → 0.125.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/README.md +20 -2
- package/lib/index.js +20 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ See the [Hugo Documentation](https://gohugo.io/) for more information.
|
|
|
69
69
|
|
|
70
70
|
## Installation options
|
|
71
71
|
|
|
72
|
-
hugo-bin-extended supports options to change the variation of Hugo binaries
|
|
72
|
+
hugo-bin-extended supports options to change the variation of Hugo binaries, to overwrite the download repository and the Hugo version.
|
|
73
73
|
|
|
74
74
|
Each option can be configured in one of the following ways:
|
|
75
75
|
|
|
@@ -80,7 +80,8 @@ Each option can be configured in one of the following ways:
|
|
|
80
80
|
"name": "your-package",
|
|
81
81
|
"version": "0.0.1",
|
|
82
82
|
"hugo-bin-extended": {
|
|
83
|
-
"downloadRepo": "https://some.example.com/artifactory/github-releases"
|
|
83
|
+
"downloadRepo": "https://some.example.com/artifactory/github-releases",
|
|
84
|
+
"version": "0.124.1"
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
```
|
|
@@ -89,12 +90,23 @@ Each option can be configured in one of the following ways:
|
|
|
89
90
|
|
|
90
91
|
```ini
|
|
91
92
|
hugo_bin_download_repo = "https://some.example.com/artifactory/github-releases"
|
|
93
|
+
hugo_bin_hugo_version = "0.124.1"
|
|
92
94
|
```
|
|
93
95
|
|
|
94
96
|
### As environment variables
|
|
95
97
|
|
|
98
|
+
On Linux/macOS:
|
|
99
|
+
|
|
96
100
|
```sh
|
|
97
101
|
export HUGO_BIN_DOWNLOAD_REPO="https://some.example.com/artifactory/github-releases"
|
|
102
|
+
export HUGO_BIN_HUGO_VERSION="0.124.1"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
On Windows:
|
|
106
|
+
|
|
107
|
+
```bat
|
|
108
|
+
set HUGO_BIN_DOWNLOAD_REPO=https://some.example.com/artifactory/github-releases
|
|
109
|
+
set HUGO_BIN_HUGO_VERSION=0.124.1
|
|
98
110
|
```
|
|
99
111
|
|
|
100
112
|
**Note that you have to run `npm install hugo-bin-extended` to re-install hugo-bin-extended itself, if you change any of these options.**
|
|
@@ -107,6 +119,12 @@ Default: `"https://github.com"`
|
|
|
107
119
|
|
|
108
120
|
Set it to your proxy URL to download the hugo binary from a different download repository.
|
|
109
121
|
|
|
122
|
+
#### hugoVersion
|
|
123
|
+
|
|
124
|
+
Default: the version specified in [package.json](package.json)
|
|
125
|
+
|
|
126
|
+
You can override the Hugo version here, but please note that if any of the URLs have changed upstream, you might not be able to use any version and you will probably need to update to a newer hugo-bin version which takes into consideration the new URLs.
|
|
127
|
+
|
|
110
128
|
## Super Inspired By
|
|
111
129
|
|
|
112
130
|
- [mastilver/apex-bin](https://github.com/mastilver/apex-bin)
|
package/lib/index.js
CHANGED
|
@@ -6,12 +6,16 @@ import BinWrapper from '@xhmikosr/bin-wrapper';
|
|
|
6
6
|
import { packageConfig } from 'pkg-conf';
|
|
7
7
|
|
|
8
8
|
const pkg = new URL('../package.json', import.meta.url);
|
|
9
|
-
const { hugoVersion } = JSON.parse(await fs.readFile(pkg, 'utf8'));
|
|
9
|
+
const { hugoVersion: HUGO_VERSION } = JSON.parse(await fs.readFile(pkg, 'utf8'));
|
|
10
10
|
|
|
11
11
|
const destDir = path.join(fileURLToPath(new URL('../vendor/', import.meta.url)));
|
|
12
12
|
const binName = process.platform === 'win32' ? 'hugo.exe' : 'hugo';
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @param {string} baseUrl
|
|
16
|
+
* @param {string} hugoVersion
|
|
17
|
+
*/
|
|
18
|
+
function extendedBin(baseUrl, hugoVersion) {
|
|
15
19
|
return new BinWrapper()
|
|
16
20
|
.src(`${baseUrl}hugo_extended_${hugoVersion}_darwin-universal.tar.gz`, 'darwin', 'arm64')
|
|
17
21
|
.src(`${baseUrl}hugo_extended_${hugoVersion}_darwin-universal.tar.gz`, 'darwin', 'x64')
|
|
@@ -30,16 +34,27 @@ function extendedBin(baseUrl) {
|
|
|
30
34
|
.use(binName);
|
|
31
35
|
}
|
|
32
36
|
|
|
37
|
+
/**
|
|
38
|
+
* @param {string} cwd
|
|
39
|
+
*/
|
|
33
40
|
async function main(cwd) {
|
|
34
41
|
const config = await packageConfig('hugo-bin-extended', { cwd });
|
|
42
|
+
const hugoVersion = [
|
|
43
|
+
process.env.HUGO_BIN_HUGO_VERSION,
|
|
44
|
+
process.env.npm_config_hugo_bin_hugo_version,
|
|
45
|
+
config.version
|
|
46
|
+
].find(Boolean) ?? HUGO_VERSION;
|
|
35
47
|
const downloadRepo = [
|
|
36
48
|
process.env.HUGO_BIN_DOWNLOAD_REPO,
|
|
37
49
|
process.env.npm_config_hugo_bin_download_repo,
|
|
38
50
|
config.downloadRepo
|
|
39
|
-
].find(Boolean)
|
|
40
|
-
const baseUrl = `${downloadRepo}/gohugoio/hugo/releases/download/v${hugoVersion}/`;
|
|
51
|
+
].find(Boolean) ?? 'https://github.com';
|
|
41
52
|
|
|
42
|
-
|
|
53
|
+
// Strip any leading `v` from hugoVersion because otherwise we'll end up with duplicate `v`s
|
|
54
|
+
const version = hugoVersion[0] === 'v' ? hugoVersion.slice(1) : hugoVersion;
|
|
55
|
+
const baseUrl = `${downloadRepo}/gohugoio/hugo/releases/download/v${version}/`;
|
|
56
|
+
|
|
57
|
+
return extendedBin(baseUrl, version);
|
|
43
58
|
}
|
|
44
59
|
|
|
45
60
|
export default main;
|