From e7c68c1a5c842f6431e34f799b2870f6039fd72a Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Thu, 21 Jun 2018 14:29:25 +0100 Subject: [PATCH] Support emulated and nocache options for remote builds Change-type: minor Closes: #901 Signed-off-by: Cameron Diver --- doc/cli.markdown | 8 ++++++++ lib/actions/push.ts | 19 +++++++++++++++++++ lib/utils/remote-build.ts | 21 +++++++++++++++++++-- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/doc/cli.markdown b/doc/cli.markdown index 62806088..3343e4ca 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -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 diff --git a/lib/actions/push.ts b/lib/actions/push.ts index 5f7fac11..b43a52b2 100644 --- a/lib/actions/push.ts +++ b/lib/actions/push.ts @@ -79,6 +79,8 @@ export const push: CommandDefinition< }, { source: string; + emulated: boolean; + nocache: boolean; } > = { signature: 'push ', @@ -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); diff --git a/lib/utils/remote-build.ts b/lib/utils/remote-build.ts index 0d4624ab..a03a97be 100644 --- a/lib/utils/remote-build.ts +++ b/lib/utils/remote-build.ts @@ -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 { 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 { 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, },