hugo-bin-extended 0.151.0 → 0.152.2
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 +2 -0
- package/index.js +2 -2
- package/lib/index.js +86 -31
- package/lib/install.js +4 -4
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
> Binary wrapper for [Hugo](https://github.com/gohugoio/hugo)
|
|
4
4
|
|
|
5
5
|
- hugo-bin-extended supports the [Extended Hugo version](https://github.com/gohugoio/hugo/releases/tag/v0.43)
|
|
6
|
+
- hugo-bin-extended supports the [withdeploy Hugo version](https://github.com/gohugoio/hugo/releases/tag/v0.137.0)
|
|
6
7
|
- For usage within corporate networks or behind corporate proxies, the download repository can be overwritten
|
|
7
8
|
|
|
8
9
|
See [Installation options](#installation-options) for more details.
|
|
@@ -114,6 +115,7 @@ set HUGO_BIN_HUGO_VERSION=0.124.1
|
|
|
114
115
|
- Default: `""`
|
|
115
116
|
|
|
116
117
|
Set `buildTags` to `extended` to download the [extended version](https://github.com/gohugoio/hugo/releases/tag/v0.43) binary.
|
|
118
|
+
Set `buildTags` to `extended,withdeploy` to download the [withdeploy version](https://github.com/gohugoio/hugo/releases/tag/v0.137.0) binary.
|
|
117
119
|
|
|
118
120
|
If this is set to `extended` but it's not available for the user's platform, then the normal version will be downloaded instead.
|
|
119
121
|
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
|
-
import
|
|
2
|
+
import hugoBin from './lib/index.js';
|
|
3
3
|
|
|
4
|
-
const bin = await
|
|
4
|
+
const bin = await hugoBin(process.cwd());
|
|
5
5
|
const hugoPath = bin.path();
|
|
6
6
|
|
|
7
7
|
export default hugoPath;
|
package/lib/index.js
CHANGED
|
@@ -13,77 +13,132 @@ const { hugoVersion: HUGO_VERSION } = JSON.parse(await fs.readFile(pkg, 'utf8'))
|
|
|
13
13
|
const destDir = path.join(fileURLToPath(new URL('../vendor/', import.meta.url)));
|
|
14
14
|
const binName = process.platform === 'win32' ? 'hugo.exe' : 'hugo';
|
|
15
15
|
|
|
16
|
+
const targets = [
|
|
17
|
+
// macOS
|
|
18
|
+
{ os: 'darwin', arch: 'arm64', suffix: '_darwin-universal.tar.gz' },
|
|
19
|
+
{ os: 'darwin', arch: 'x64', suffix: '_darwin-universal.tar.gz' },
|
|
20
|
+
|
|
21
|
+
// Linux
|
|
22
|
+
{ os: 'linux', arch: 'x64', suffix: '_linux-amd64.tar.gz' },
|
|
23
|
+
{ os: 'linux', arch: 'arm64', suffix: '_linux-arm64.tar.gz' },
|
|
24
|
+
{ os: 'linux', arch: 'arm', suffix: '_linux-arm.tar.gz' },
|
|
25
|
+
|
|
26
|
+
// Windows
|
|
27
|
+
{ os: 'win32', arch: 'x64', suffix: '_windows-amd64.zip' },
|
|
28
|
+
{ os: 'win32', arch: 'arm64', suffix: '_windows-arm64.zip' },
|
|
29
|
+
|
|
30
|
+
/* eslint-disable @stylistic/object-curly-newline */
|
|
31
|
+
// Fallbacks
|
|
32
|
+
{ os: 'dragonflybsd', arch: 'x64', suffix: '_dragonfly-amd64.tar.gz', fallback: true },
|
|
33
|
+
{ os: 'freebsd', arch: 'x64', suffix: '_freebsd-amd64.tar.gz', fallback: true },
|
|
34
|
+
{ os: 'netbsd', arch: 'x64', suffix: '_netbsd-amd64.tar.gz', fallback: true },
|
|
35
|
+
{ os: 'openbsd', arch: 'x64', suffix: '_openbsd-amd64.tar.gz', fallback: true },
|
|
36
|
+
{ os: 'solaris', arch: 'x64', suffix: '_solaris-amd64.tar.gz', fallback: true }
|
|
37
|
+
/* eslint-enable @stylistic/object-curly-newline */
|
|
38
|
+
];
|
|
39
|
+
|
|
16
40
|
debug('[global] HUGO_VERSION:', HUGO_VERSION);
|
|
17
41
|
debug('[global] destDir:', destDir);
|
|
18
42
|
debug('[global] binName:', binName);
|
|
19
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @typedef {Object} BinOptions
|
|
46
|
+
* @property {boolean} [extended]
|
|
47
|
+
* @property {boolean} [withDeploy]
|
|
48
|
+
*/
|
|
49
|
+
|
|
20
50
|
/**
|
|
21
51
|
* @param {string} baseUrl
|
|
22
52
|
* @param {string} hugoVersion
|
|
53
|
+
* @param {BinOptions} options
|
|
54
|
+
* @returns {BinWrapper}
|
|
23
55
|
*/
|
|
24
|
-
function
|
|
25
|
-
debug('[
|
|
26
|
-
|
|
56
|
+
function createBin(baseUrl, hugoVersion, { extended = false, withDeploy = false } = {}) {
|
|
57
|
+
debug('[createBin] %o', {
|
|
58
|
+
baseUrl,
|
|
59
|
+
hugoVersion,
|
|
60
|
+
extended,
|
|
61
|
+
withDeploy
|
|
62
|
+
});
|
|
27
63
|
|
|
28
64
|
const baseName = `hugo_${hugoVersion}`;
|
|
29
|
-
const baseNameExtended =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.src(`${baseUrl}${
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
.src(`${baseUrl}${baseName}_openbsd-amd64.tar.gz`, 'openbsd', 'x64')
|
|
43
|
-
.src(`${baseUrl}${baseName}_solaris-amd64.tar.gz`, 'openbsd', 'x64')
|
|
44
|
-
.src(`${baseUrl}${baseName}_windows-arm64.zip`, 'win32', 'arm64')
|
|
45
|
-
.dest(destDir)
|
|
46
|
-
.use(binName);
|
|
65
|
+
const baseNameExtended = withDeploy ?
|
|
66
|
+
`hugo_extended_withdeploy_${hugoVersion}` :
|
|
67
|
+
`hugo_extended_${hugoVersion}`;
|
|
68
|
+
const chosenBase = extended ? baseNameExtended : baseName;
|
|
69
|
+
|
|
70
|
+
let bin = new BinWrapper();
|
|
71
|
+
|
|
72
|
+
for (const { os, arch, suffix, fallback } of targets) {
|
|
73
|
+
const name = fallback ? baseName : chosenBase;
|
|
74
|
+
bin = bin.src(`${baseUrl}${name}${suffix}`, os, arch);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return bin.dest(destDir).version(hugoVersion).use(binName);
|
|
47
78
|
}
|
|
48
79
|
|
|
49
80
|
/**
|
|
50
|
-
* @param {import('
|
|
81
|
+
* @param {import('package-config').Config} config
|
|
82
|
+
* @returns {{hugoVersion: string, downloadRepo: string, extended: boolean, withDeploy: boolean}}
|
|
51
83
|
*/
|
|
52
84
|
function getOptions(config) {
|
|
53
|
-
const
|
|
85
|
+
const hugoVersionRaw = [
|
|
54
86
|
process.env.HUGO_BIN_HUGO_VERSION,
|
|
55
87
|
process.env.npm_config_hugo_bin_hugo_version,
|
|
56
88
|
config.version
|
|
57
89
|
].find(Boolean) ?? HUGO_VERSION;
|
|
90
|
+
|
|
58
91
|
const downloadRepo = [
|
|
59
92
|
process.env.HUGO_BIN_DOWNLOAD_REPO,
|
|
60
93
|
process.env.npm_config_hugo_bin_download_repo,
|
|
61
94
|
config.downloadRepo
|
|
62
95
|
].find(Boolean) ?? 'https://github.com';
|
|
63
96
|
|
|
64
|
-
|
|
65
|
-
|
|
97
|
+
const buildTags = new Set([
|
|
98
|
+
process.env.HUGO_BIN_BUILD_TAGS,
|
|
99
|
+
process.env.npm_config_hugo_bin_build_tags,
|
|
100
|
+
config.buildTags
|
|
101
|
+
]
|
|
102
|
+
.filter(Boolean)
|
|
103
|
+
.join(',')
|
|
104
|
+
.split(',')
|
|
105
|
+
.map(s => s.trim().toLowerCase())
|
|
106
|
+
.filter(Boolean));
|
|
107
|
+
|
|
108
|
+
// const extended = buildTags.has('extended');
|
|
109
|
+
const extended = true;
|
|
110
|
+
const withDeploy = buildTags.has('withdeploy');
|
|
111
|
+
|
|
112
|
+
// Strip any leading `v` from hugoVersionRaw because otherwise we'll end up with duplicate `v`s
|
|
113
|
+
const hugoVersion = hugoVersionRaw[0] === 'v' ? hugoVersionRaw.slice(1) : hugoVersionRaw;
|
|
66
114
|
|
|
67
|
-
debug('[getOptions]
|
|
68
|
-
|
|
115
|
+
debug('[getOptions] %o', {
|
|
116
|
+
hugoVersion,
|
|
117
|
+
downloadRepo,
|
|
118
|
+
extended,
|
|
119
|
+
withDeploy
|
|
120
|
+
});
|
|
69
121
|
|
|
70
122
|
return {
|
|
71
|
-
hugoVersion
|
|
72
|
-
downloadRepo
|
|
123
|
+
hugoVersion,
|
|
124
|
+
downloadRepo,
|
|
125
|
+
extended,
|
|
126
|
+
withDeploy
|
|
73
127
|
};
|
|
74
128
|
}
|
|
75
129
|
|
|
76
130
|
/**
|
|
77
131
|
* @param {string} cwd
|
|
132
|
+
* @returns {Promise<BinWrapper>}
|
|
78
133
|
*/
|
|
79
134
|
async function main(cwd) {
|
|
80
135
|
const config = await packageConfig('hugo-bin-extended', { cwd });
|
|
81
|
-
const { hugoVersion, downloadRepo } = getOptions(config);
|
|
136
|
+
const { hugoVersion, downloadRepo, extended, withDeploy } = getOptions(config);
|
|
82
137
|
const baseUrl = `${downloadRepo}/gohugoio/hugo/releases/download/v${hugoVersion}/`;
|
|
83
138
|
|
|
84
139
|
debug('[main] baseUrl:', baseUrl);
|
|
85
140
|
|
|
86
|
-
return
|
|
141
|
+
return createBin(baseUrl, hugoVersion, { extended, withDeploy });
|
|
87
142
|
}
|
|
88
143
|
|
|
89
144
|
export default main;
|
package/lib/install.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rm } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import process from 'node:process';
|
|
4
|
-
import
|
|
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
|
|
@@ -15,7 +15,7 @@ function getProjectRoot() {
|
|
|
15
15
|
const cwd = process.cwd();
|
|
16
16
|
const paths = cwd.split(path.sep);
|
|
17
17
|
// If `process.cwd` ends with 'node_modules/*' then get the dependent root directory,
|
|
18
|
-
// otherwise return the `cwd` (ordinary it will be the postinstall process of hugo-bin
|
|
18
|
+
// otherwise return the `cwd` (ordinary it will be the postinstall process of hugo-bin itself).
|
|
19
19
|
if (paths.length > 1 && paths.at(-2) === 'node_modules') {
|
|
20
20
|
return path.resolve('../../', cwd);
|
|
21
21
|
}
|
|
@@ -29,14 +29,14 @@ async function main() {
|
|
|
29
29
|
|
|
30
30
|
await rm(vendorDir, { force: true, recursive: true });
|
|
31
31
|
|
|
32
|
-
const bin = await
|
|
32
|
+
const bin = await hugoBin(projectRoot);
|
|
33
33
|
|
|
34
34
|
try {
|
|
35
35
|
await bin.run(['version']);
|
|
36
36
|
console.log('Hugo binary successfully installed!');
|
|
37
37
|
} catch (error) {
|
|
38
38
|
console.error('Hugo binary installation failed!');
|
|
39
|
-
throw new Error(error);
|
|
39
|
+
throw new Error(error instanceof Error ? error.message : String(error));
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hugo-bin-extended",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"hugoVersion": "0.
|
|
3
|
+
"version": "0.152.2",
|
|
4
|
+
"hugoVersion": "0.152.2",
|
|
5
5
|
"description": "Binary wrapper for Hugo",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@xhmikosr/bin-check": "^7.1.0",
|
|
54
54
|
"c8": "^10.1.3",
|
|
55
55
|
"uvu": "^0.5.6",
|
|
56
|
-
"xo": "^1.2.
|
|
56
|
+
"xo": "^1.2.3"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"lint": "xo",
|
|
@@ -74,6 +74,10 @@
|
|
|
74
74
|
"error",
|
|
75
75
|
"always"
|
|
76
76
|
],
|
|
77
|
+
"@stylistic/operator-linebreak": [
|
|
78
|
+
"error",
|
|
79
|
+
"after"
|
|
80
|
+
],
|
|
77
81
|
"@stylistic/space-before-function-paren": [
|
|
78
82
|
"error",
|
|
79
83
|
"never"
|
|
@@ -86,10 +90,6 @@
|
|
|
86
90
|
}
|
|
87
91
|
],
|
|
88
92
|
"capitalized-comments": "off",
|
|
89
|
-
"operator-linebreak": [
|
|
90
|
-
"error",
|
|
91
|
-
"after"
|
|
92
|
-
],
|
|
93
93
|
"unicorn/prefer-top-level-await": "off",
|
|
94
94
|
"unicorn/prevent-abbreviations": "off"
|
|
95
95
|
}
|