feat: alternate nexe base binary remotes (--remote option) (#760)
This commit is contained in:
+4
-2
@@ -111,8 +111,10 @@ export class NexeCompiler {
|
||||
if (options.asset && options.asset.startsWith('http')) {
|
||||
this.remoteAsset = options.asset
|
||||
} else {
|
||||
this.remoteAsset =
|
||||
'https://github.com/nexe/nexe/releases/download/v3.0.0/' + this.target.toString()
|
||||
if (!options.remote.startsWith('http')) {
|
||||
throw new NexeError(`Invalid remote URL (must be HTTP/HTTPS): ${options.remote}`)
|
||||
}
|
||||
this.remoteAsset = options.remote + this.target.toString()
|
||||
}
|
||||
this.src = join(this.options.temp, this.target.version)
|
||||
this.configureScript = configure + (semverGt(this.target.version, '10.10.0') ? '.py' : '')
|
||||
|
||||
@@ -39,6 +39,7 @@ export interface NexeOptions {
|
||||
native: any
|
||||
mangle: boolean
|
||||
ghToken: string
|
||||
remote: string
|
||||
sourceUrl?: string
|
||||
enableStdIn?: boolean
|
||||
python?: string
|
||||
@@ -71,6 +72,7 @@ const defaults = {
|
||||
bundle: true,
|
||||
patches: [],
|
||||
plugins: [],
|
||||
remote: 'https://github.com/nexe/nexe/releases/download/v3.0.0/',
|
||||
}
|
||||
const alias = {
|
||||
i: 'input',
|
||||
@@ -87,6 +89,7 @@ const alias = {
|
||||
m: 'make',
|
||||
h: 'help',
|
||||
l: 'loglevel',
|
||||
e: 'remote',
|
||||
'fake-argv': 'fakeArgv',
|
||||
'gh-token': 'ghToken',
|
||||
}
|
||||
@@ -103,6 +106,7 @@ ${c.bold('nexe <entry-file> [options]')}
|
||||
-r --resource -- *embed files (glob) within the binary
|
||||
-a --asset -- alternate asset path, file or url pointing to a base (nexe) binary
|
||||
--plugin -- extend nexe runtime behavior
|
||||
-e --remote -- third-party remote location (URL) to download pre-built releases from
|
||||
|
||||
${c.underline.bold('Building from source:')}
|
||||
|
||||
@@ -249,6 +253,10 @@ function normalizeOptions(input?: Partial<NexeOptions>): NexeOptions {
|
||||
options.configure = flatten(options.configure)
|
||||
options.resources = flatten(opts.resource, options.resources)
|
||||
|
||||
if (!options.remote.endsWith('/')) {
|
||||
options.remote += '/'
|
||||
}
|
||||
|
||||
options.downloadOptions = options.downloadOptions || {}
|
||||
options.downloadOptions.headers = options.downloadOptions.headers || {}
|
||||
options.downloadOptions.headers['User-Agent'] = 'nexe (https://www.npmjs.com/package/nexe)'
|
||||
|
||||
@@ -39,6 +39,26 @@ describe('options', () => {
|
||||
expect(options.output).to.equal(path.resolve(cwd, `abc${ext}`))
|
||||
})
|
||||
})
|
||||
|
||||
describe('remote', () => {
|
||||
it('should use default remote', () => {
|
||||
const options = normalizeOptions({})
|
||||
expect(options.remote).to.equal('https://github.com/nexe/nexe/releases/download/v3.0.0/')
|
||||
})
|
||||
it('should append trailing slash to third-party remote if necessary', () => {
|
||||
const options = normalizeOptions({
|
||||
remote: 'https://sitejs.org/nexe'
|
||||
})
|
||||
expect(options.remote).to.equal('https://sitejs.org/nexe/')
|
||||
})
|
||||
it('should not append trailing slash to third-party remote that already has one', () => {
|
||||
const options = normalizeOptions({
|
||||
remote: 'https://sitejs.org/nexe/'
|
||||
})
|
||||
expect(options.remote).to.equal('https://sitejs.org/nexe/')
|
||||
})
|
||||
})
|
||||
|
||||
describe('output', () => {
|
||||
it('should work', () => {
|
||||
const options = normalizeOptions({
|
||||
|
||||
Reference in New Issue
Block a user