Compare commits

..

1 commit

Author SHA1 Message Date
a9f3e107bb chore(deps): update node.js to v20.18.1
All checks were successful
Check Transpiled JavaScript / Check dist/ (pull_request) Successful in 45s
Continuous Integration / GitHub Actions Test (pull_request) Successful in 9s
Continuous Integration / TypeScript Tests (pull_request) Successful in 56s
2024-11-27 19:01:34 +00:00
8 changed files with 27 additions and 118 deletions

View file

@ -43,8 +43,6 @@ jobs:
- name: Test
id: npm-ci-test
run: npm run ci-test
env:
GITHUB_TOKEN: ${{ secrets.RENOVATE_GITHUB_TOKEN }}
test-action:
name: GitHub Actions Test
@ -61,8 +59,6 @@ jobs:
with:
extended: true
dart-sass: true
with-deploy: true
github-token: ${{ secrets.RENOVATE_GITHUB_TOKEN }}
- name: Test installed tools
id: test-tools

View file

@ -1 +1 @@
20.6.0
20.18.1

View file

@ -18,9 +18,7 @@ afterEach(() => {
describe('Install Hugo', () => {
test('Download latest Hugo', async () => {
const releaseLookup = new OctokitReleaseLookup(
process.env.GITHUB_TOKEN || undefined
)
const releaseLookup = new OctokitReleaseLookup()
const platformMock = new Platform('linux', undefined, { HOME: tmpDir })
const hugo = new HugoInstaller(releaseLookup, platformMock)
@ -31,36 +29,4 @@ describe('Install Hugo', () => {
})
).not.toThrow()
}, 30_000)
test('Download latest Hugo - extended', async () => {
const releaseLookup = new OctokitReleaseLookup(
process.env.GITHUB_TOKEN || undefined
)
const platformMock = new Platform('linux', undefined, { HOME: tmpDir })
const hugo = new HugoInstaller(releaseLookup, platformMock)
expect(
async () =>
await hugo.install({
version: 'latest',
extended: true
})
).not.toThrow()
}, 30_000)
test('Download latest Hugo - with deploy', async () => {
const releaseLookup = new OctokitReleaseLookup(
process.env.GITHUB_TOKEN || undefined
)
const platformMock = new Platform('linux', undefined, { HOME: tmpDir })
const hugo = new HugoInstaller(releaseLookup, platformMock)
expect(
async () =>
await hugo.install({
version: 'latest',
withDeploy: true
})
).not.toThrow()
}, 30_000)
})

View file

@ -15,12 +15,6 @@ inputs:
description: 'Download (if necessary) dart-sass'
required: false
default: 'false'
with-deploy:
description:
'Fetch a Hugo build that includes the deploy command - if true, will
override the extended option'
required: false
default: 'false'
dart-sass-version:
description:
'The dart-sass version to download.ts (if necessary) and use. Example:

40
dist/index.js vendored
View file

@ -50809,21 +50809,13 @@ class HugoInstaller {
}
async install(cmd) {
const release = await this.releaseLookup.getRelease(Hugo.Org, Hugo.Repo, cmd.version, HugoReleaseTransformer);
core.debug(`Hugo extended: ${cmd.extended ?? false}`);
core.debug(`Hugo with deploy: ${cmd.withDeploy ?? false}`);
core.debug(`Hugo extended: ${cmd.extended}`);
core.debug(`Operating System: ${this.platform.os}`);
core.debug(`Processor Architecture: ${this.platform.arch}`);
const hugoBinName = this.platform.binaryName(Hugo.CmdName);
const tmpDir = external_node_os_namespaceObject.tmpdir();
let versionSpec = release.tag_name;
if (cmd.extended) {
versionSpec = `${release.tag_name}+extended`;
}
else if (cmd.withDeploy) {
versionSpec = `${release.tag_name}+extended+withdeploy`;
}
try {
const cachedTool = tool_cache.find(Hugo.Name, versionSpec, this.platform.arch);
const cachedTool = tool_cache.find(Hugo.Name, release.tag_name, this.platform.arch);
if (cachedTool) {
core.addPath(cachedTool);
return;
@ -50832,7 +50824,7 @@ class HugoInstaller {
catch (e) {
core.warning(`Failed to lookup tool in cache: ${errorMsg(e)}`);
}
const toolUrl = release.assetUrl(this.platform, cmd.extended, cmd.withDeploy);
const toolUrl = release.assetUrl(this.platform, cmd.extended);
if (!toolUrl) {
throw new Error('No matching URL detected for given platform');
}
@ -50847,7 +50839,7 @@ class HugoInstaller {
}
await (0,io.rmRF)(destPath);
try {
const cachedHugoPath = await tool_cache.cacheFile(external_path_default().join(tmpDir, hugoBinName), hugoBinName, Hugo.Name, versionSpec, this.platform.arch);
const cachedHugoPath = await tool_cache.cacheFile(external_path_default().join(tmpDir, hugoBinName), hugoBinName, Hugo.Name, release.tag_name, this.platform.arch);
core.addPath(cachedHugoPath);
}
catch (e) {
@ -50865,21 +50857,16 @@ const HugoReleaseTransformer = {
}
};
class HugoRelease {
static keyReplacementRegex = new RegExp('hugo_(extended_)*(withdeploy_)*(\\d+.\\d+.\\d+)_');
static keyReplacementRegex = new RegExp('hugo_(extended_)*(\\d+.\\d+.\\d+)_');
tag_name;
defaultAssets;
extendedAssets;
withDeployAssets;
constructor(tag_name, assets) {
this.tag_name = tag_name;
this.defaultAssets = new Map();
this.extendedAssets = new Map();
this.withDeployAssets = new Map();
for (const asset of assets) {
if (asset.name.includes('extended_withdeploy')) {
this.withDeployAssets.set(asset.name.replace(HugoRelease.keyReplacementRegex, ''), asset.browser_download_url);
}
else if (asset.name.includes('extended')) {
if (asset.name.includes('extended')) {
this.extendedAssets.set(asset.name.replace(HugoRelease.keyReplacementRegex, ''), asset.browser_download_url);
}
else {
@ -50887,17 +50874,11 @@ class HugoRelease {
}
}
}
assetUrl(platform, extended, withDeploy) {
let assets = this.defaultAssets;
if (extended) {
assets = this.extendedAssets;
}
else if (withDeploy) {
assets = this.withDeployAssets;
}
assetUrl(platform, extended) {
const src = extended ? this.extendedAssets : this.defaultAssets;
const arch = platform.os === 'darwin' ? 'universal' : platform.arch;
const key = `${platform.os}-${arch}${platform.archiveExtension()}`;
return assets.get(key);
return src.get(key);
}
}
@ -51025,8 +51006,7 @@ async function run() {
const hugoInstaller = new HugoInstaller(releaseLookup);
await hugoInstaller.install({
version: core.getInput('hugo-version'),
extended: core.getBooleanInput('extended'),
withDeploy: core.getBooleanInput('with-deploy')
extended: core.getBooleanInput('extended')
});
if (!core.getBooleanInput('dart-sass'))
return;

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -13,7 +13,6 @@ import { errorMsg } from './utils/error'
export interface IHugoInstallCommand {
version?: string
extended?: boolean
withDeploy?: boolean
}
export class HugoInstaller {
@ -33,23 +32,19 @@ export class HugoInstaller {
HugoReleaseTransformer
)
core.debug(`Hugo extended: ${cmd.extended ?? false}`)
core.debug(`Hugo with deploy: ${cmd.withDeploy ?? false}`)
core.debug(`Hugo extended: ${cmd.extended}`)
core.debug(`Operating System: ${this.platform.os}`)
core.debug(`Processor Architecture: ${this.platform.arch}`)
const hugoBinName = this.platform.binaryName(Hugo.CmdName)
const tmpDir = os.tmpdir()
let versionSpec = release.tag_name
if (cmd.extended) {
versionSpec = `${release.tag_name}+extended`
} else if (cmd.withDeploy) {
versionSpec = `${release.tag_name}+extended+withdeploy`
}
try {
const cachedTool = tc.find(Hugo.Name, versionSpec, this.platform.arch)
const cachedTool = tc.find(
Hugo.Name,
release.tag_name,
this.platform.arch
)
if (cachedTool) {
core.addPath(cachedTool)
return
@ -58,11 +53,7 @@ export class HugoInstaller {
core.warning(`Failed to lookup tool in cache: ${errorMsg(e)}`)
}
const toolUrl = release.assetUrl(
this.platform,
cmd.extended,
cmd.withDeploy
)
const toolUrl = release.assetUrl(this.platform, cmd.extended)
if (!toolUrl) {
throw new Error('No matching URL detected for given platform')
@ -88,7 +79,7 @@ export class HugoInstaller {
path.join(tmpDir, hugoBinName),
hugoBinName,
Hugo.Name,
versionSpec,
release.tag_name,
this.platform.arch
)
@ -112,14 +103,13 @@ export const HugoReleaseTransformer = {
export class HugoRelease implements IGithubRelease {
private static readonly keyReplacementRegex = new RegExp(
'hugo_(extended_)*(withdeploy_)*(\\d+.\\d+.\\d+)_'
'hugo_(extended_)*(\\d+.\\d+.\\d+)_'
)
readonly tag_name: string
private readonly defaultAssets: Map<string, string>
private readonly extendedAssets: Map<string, string>
private readonly withDeployAssets: Map<string, string>
constructor(
tag_name: string,
@ -128,15 +118,9 @@ export class HugoRelease implements IGithubRelease {
this.tag_name = tag_name
this.defaultAssets = new Map<string, string>()
this.extendedAssets = new Map<string, string>()
this.withDeployAssets = new Map<string, string>()
for (const asset of assets) {
if (asset.name.includes('extended_withdeploy')) {
this.withDeployAssets.set(
asset.name.replace(HugoRelease.keyReplacementRegex, ''),
asset.browser_download_url
)
} else if (asset.name.includes('extended')) {
if (asset.name.includes('extended')) {
this.extendedAssets.set(
asset.name.replace(HugoRelease.keyReplacementRegex, ''),
asset.browser_download_url
@ -150,21 +134,11 @@ export class HugoRelease implements IGithubRelease {
}
}
assetUrl(
platform: Platform,
extended?: boolean,
withDeploy?: boolean
): string | undefined {
let assets = this.defaultAssets
if (extended) {
assets = this.extendedAssets
} else if (withDeploy) {
assets = this.withDeployAssets
}
assetUrl(platform: Platform, extended?: boolean): string | undefined {
const src = extended ? this.extendedAssets : this.defaultAssets
const arch = platform.os === 'darwin' ? 'universal' : platform.arch
const key = `${platform.os}-${arch}${platform.archiveExtension()}`
return assets.get(key)
return src.get(key)
}
}

View file

@ -11,8 +11,7 @@ export async function run(): Promise<void> {
await hugoInstaller.install({
version: core.getInput('hugo-version'),
extended: core.getBooleanInput('extended'),
withDeploy: core.getBooleanInput('with-deploy')
extended: core.getBooleanInput('extended')
})
if (!core.getBooleanInput('dart-sass')) return