Auto-merge for PR #903 via VersionBot

Support emulated and nocache options for remote builds
This commit is contained in:
resin-io-versionbot[bot] 2018-08-09 14:52:03 +00:00 committed by GitHub
commit 53c7bc622c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 3 deletions

View File

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/).
## v7.9.0 - 2018-08-09
* Support emulated and nocache options for remote builds #903 [Cameron Diver]
## v7.8.6 - 2018-08-09
* Fix bug where the sudo helper failed in os initialize #939 [Tim Perry]

View File

@ -1274,6 +1274,14 @@ Examples:
The source that should be sent to the resin builder to be built (defaults to the current directory)
#### --emulated, -e
Force an emulated build to occur on the remote builder
#### --nocache, -c
Don't use cache when building this project
# Settings
## settings

View File

@ -79,6 +79,8 @@ export const push: CommandDefinition<
},
{
source: string;
emulated: boolean;
nocache: boolean;
}
> = {
signature: 'push <application>',
@ -104,6 +106,18 @@ export const push: CommandDefinition<
'The source that should be sent to the resin builder to be built (defaults to the current directory)',
parameter: 'source',
},
{
signature: 'emulated',
alias: 'e',
description: 'Force an emulated build to occur on the remote builder',
boolean: true,
},
{
signature: 'nocache',
alias: 'c',
description: "Don't use cache when building this project",
boolean: true,
},
],
async action(params, options, done) {
const sdk = (await import('resin-sdk')).fromSharedOptions();
@ -126,6 +140,10 @@ export const push: CommandDefinition<
sdk.settings.get('resinUrl'),
getAppOwner(sdk, app),
(token, baseUrl, owner) => {
const opts = {
emulated: options.emulated,
nocache: options.nocache,
};
const args = {
app,
owner,
@ -133,6 +151,7 @@ export const push: CommandDefinition<
auth: token,
baseUrl,
sdk,
opts,
};
return remote.startRemoteBuild(args);

View File

@ -26,12 +26,18 @@ const DEBUG_MODE = !!process.env.DEBUG;
const CURSOR_METADATA_REGEX = /([a-z]+)([0-9]+)?/;
const TRIM_REGEX = /\n+$/;
export interface BuildOpts {
emulated: boolean;
nocache: boolean;
}
export interface RemoteBuild {
app: string;
owner: string;
source: string;
auth: string;
baseUrl: string;
opts: BuildOpts;
sdk: ResinSDK;
@ -52,9 +58,15 @@ async function getBuilderEndpoint(
baseUrl: string,
owner: string,
app: string,
opts: BuildOpts,
): Promise<string> {
const querystring = await import('querystring');
const args = querystring.stringify({ owner, app });
const args = querystring.stringify({
owner,
app,
emulated: opts.emulated,
nocache: opts.nocache,
});
return `https://builder.${baseUrl}/v3/build?${args}`;
}
@ -196,7 +208,12 @@ async function getRequestStream(build: RemoteBuild): Promise<Stream.Duplex> {
console.log('[debug] Opening builder connection');
}
const post = request.post({
url: await getBuilderEndpoint(build.baseUrl, build.owner, build.app),
url: await getBuilderEndpoint(
build.baseUrl,
build.owner,
build.app,
build.opts,
),
auth: {
bearer: build.auth,
},

View File

@ -1,6 +1,6 @@
{
"name": "resin-cli",
"version": "7.8.6",
"version": "7.9.0",
"description": "The official resin.io CLI tool",
"main": "./build/actions/index.js",
"homepage": "https://github.com/resin-io/resin-cli",