mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-02 09:18:01 +00:00
Switch to object spreading in favor of _.assign
Change-type: patch
This commit is contained in:
parent
62e4930e5b
commit
235c13bea9
4
lib/actions-oclif/env/add.ts
vendored
4
lib/actions-oclif/env/add.ts
vendored
@ -92,8 +92,8 @@ export default class EnvAddCmd extends Command {
|
||||
'env add ' + new CommandHelp({ args: EnvAddCmd.args }).defaultUsage();
|
||||
|
||||
public static flags: flags.Input<FlagsDef> = {
|
||||
application: _.assign({ exclusive: ['device'] }, cf.application),
|
||||
device: _.assign({ exclusive: ['application'] }, cf.device),
|
||||
application: { exclusive: ['device'], ...cf.application },
|
||||
device: { exclusive: ['application'], ...cf.device },
|
||||
help: cf.help,
|
||||
quiet: cf.quiet,
|
||||
service: cf.service,
|
||||
|
@ -114,20 +114,20 @@ export default class EnvsCmd extends Command {
|
||||
include app-wide, device-wide variables that apply to the selected device or service.
|
||||
Variables are still filtered out by type with the --config option.`,
|
||||
}),
|
||||
application: _.assign({ exclusive: ['device'] }, cf.application),
|
||||
application: { exclusive: ['device'], ...cf.application },
|
||||
config: flags.boolean({
|
||||
char: 'c',
|
||||
description: 'show configuration variables only',
|
||||
exclusive: ['service'],
|
||||
}),
|
||||
device: _.assign({ exclusive: ['application'] }, cf.device),
|
||||
device: { exclusive: ['application'], ...cf.device },
|
||||
help: cf.help,
|
||||
json: flags.boolean({
|
||||
char: 'j',
|
||||
description: 'produce JSON output instead of tabular output',
|
||||
}),
|
||||
verbose: cf.verbose,
|
||||
service: _.assign({ exclusive: ['config'] }, cf.service),
|
||||
service: { exclusive: ['config'], ...cf.service },
|
||||
};
|
||||
|
||||
public async run() {
|
||||
|
@ -125,7 +125,7 @@ export default class OsConfigureCmd extends Command {
|
||||
description: "same as '--application'",
|
||||
exclusive: ['application', 'device'],
|
||||
}),
|
||||
application: _.assign({ exclusive: ['app', 'device'] }, cf.application),
|
||||
application: { exclusive: ['app', 'device'], ...cf.application },
|
||||
config: flags.string({
|
||||
description:
|
||||
'path to a pre-generated config.json file to be injected in the OS image',
|
||||
@ -144,7 +144,7 @@ export default class OsConfigureCmd extends Command {
|
||||
'config-wifi-ssid': flags.string({
|
||||
description: 'WiFi SSID (network name) (non-interactive configuration)',
|
||||
}),
|
||||
device: _.assign({ exclusive: ['app', 'application'] }, cf.device),
|
||||
device: { exclusive: ['app', 'application'], ...cf.device },
|
||||
'device-api-key': flags.string({
|
||||
char: 'k',
|
||||
description:
|
||||
|
@ -14,8 +14,6 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import _ = require('lodash');
|
||||
|
||||
export const yes = {
|
||||
signature: 'yes',
|
||||
description: 'confirm non interactively',
|
||||
@ -34,10 +32,10 @@ export const optionalApplication = {
|
||||
alias: ['a', 'app'],
|
||||
};
|
||||
|
||||
export const application = _.defaults(
|
||||
{ required: 'You have to specify an application' },
|
||||
optionalApplication,
|
||||
);
|
||||
export const application = {
|
||||
...optionalApplication,
|
||||
required: 'You have to specify an application',
|
||||
};
|
||||
|
||||
export const optionalRelease = {
|
||||
signature: 'release',
|
||||
@ -75,12 +73,10 @@ export const optionalOsVersion = {
|
||||
|
||||
export type OptionalOsVersionOption = Partial<OsVersionOption>;
|
||||
|
||||
export const osVersion = _.defaults(
|
||||
{
|
||||
export const osVersion = {
|
||||
...exports.optionalOsVersion,
|
||||
required: 'You have to specify an exact os version',
|
||||
},
|
||||
exports.optionalOsVersion,
|
||||
);
|
||||
};
|
||||
|
||||
export interface OsVersionOption {
|
||||
version?: string;
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
import { flags } from '@oclif/command';
|
||||
import { stripIndent } from 'common-tags';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { ExpectedError } from '../errors';
|
||||
|
||||
|
@ -196,7 +196,7 @@ async function selectAppFromList(applications: BalenaSdk.Application[]) {
|
||||
return selectFromList(
|
||||
'Select application',
|
||||
_.map(applications, app => {
|
||||
return _.merge({ name: app.slug }, app);
|
||||
return { name: app.slug, ...app };
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
import { ChildProcess, spawn, SpawnOptions } from 'child_process';
|
||||
import { stripIndent } from 'common-tags';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
/**
|
||||
* Execute a child process with admin / superuser privileges, prompting the user for
|
||||
|
@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
import Bluebird = require('bluebird');
|
||||
import * as _ from 'lodash';
|
||||
import * as path from 'path';
|
||||
import * as zlib from 'zlib';
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
require('../config-tests'); // required for side effects
|
||||
|
||||
import { expect } from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import { fs } from 'mz';
|
||||
import * as path from 'path';
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { expect } from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import { cleanOutput, runCommand } from '../helpers';
|
||||
|
||||
const SIMPLE_HELP = `
|
||||
|
@ -167,13 +167,13 @@ export async function testDockerBuildStream(o: {
|
||||
const expectedFiles = o.expectedFilesByService[service];
|
||||
const expectedQueryParams = fillTemplateArray(
|
||||
o.expectedQueryParamsByService[service],
|
||||
_.assign({ tag }, o),
|
||||
{ tag, ...o },
|
||||
);
|
||||
const projectPath =
|
||||
service === 'main' ? o.projectPath : path.join(o.projectPath, service);
|
||||
|
||||
o.dockerMock.expectPostBuild(
|
||||
_.assign({}, o, {
|
||||
o.dockerMock.expectPostBuild({
|
||||
...o,
|
||||
checkURI: async (uri: string) => {
|
||||
const url = new URL(uri, 'http://test.net/');
|
||||
const queryParams = Array.from(url.searchParams.entries());
|
||||
@ -182,8 +182,7 @@ export async function testDockerBuildStream(o: {
|
||||
checkBuildRequestBody: (buildRequestBody: string) =>
|
||||
inspectTarStream(buildRequestBody, expectedFiles, projectPath),
|
||||
tag,
|
||||
}),
|
||||
);
|
||||
});
|
||||
o.dockerMock.expectGetImages();
|
||||
}
|
||||
|
||||
@ -211,8 +210,8 @@ export async function testPushBuildStream(o: {
|
||||
const expectedQueryParams = fillTemplateArray(o.expectedQueryParams, o);
|
||||
const expectedResponseLines = fillTemplateArray(o.expectedResponseLines, o);
|
||||
|
||||
o.builderMock.expectPostBuild(
|
||||
_.assign({}, o, {
|
||||
o.builderMock.expectPostBuild({
|
||||
...o,
|
||||
checkURI: async (uri: string) => {
|
||||
const url = new URL(uri, 'http://test.net/');
|
||||
const queryParams = Array.from(url.searchParams.entries());
|
||||
@ -220,8 +219,7 @@ export async function testPushBuildStream(o: {
|
||||
},
|
||||
checkBuildRequestBody: (buildRequestBody: string) =>
|
||||
inspectTarStream(buildRequestBody, o.expectedFiles, o.projectPath),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
const { out, err } = await runCommand(o.commandLine);
|
||||
|
||||
|
@ -19,7 +19,6 @@ import { configureBluebird } from '../build/app-common';
|
||||
|
||||
configureBluebird();
|
||||
|
||||
import * as _ from 'lodash';
|
||||
import * as nock from 'nock';
|
||||
|
||||
export interface ScopeOpts {
|
||||
@ -54,38 +53,34 @@ export class NockMock {
|
||||
|
||||
public optGet(
|
||||
uri: string | RegExp | ((uri: string) => boolean),
|
||||
opts: ScopeOpts,
|
||||
{ optional = false, persist = false }: ScopeOpts,
|
||||
): nock.Interceptor {
|
||||
opts = _.assign({ optional: false, persist: false }, opts);
|
||||
const get = (opts.persist ? this.scope.persist() : this.scope).get(uri);
|
||||
return opts.optional ? get.optionally() : get;
|
||||
const get = (persist ? this.scope.persist() : this.scope).get(uri);
|
||||
return optional ? get.optionally() : get;
|
||||
}
|
||||
|
||||
public optDelete(
|
||||
uri: string | RegExp | ((uri: string) => boolean),
|
||||
opts: ScopeOpts,
|
||||
{ optional = false, persist = false }: ScopeOpts,
|
||||
) {
|
||||
opts = _.assign({ optional: false, persist: false }, opts);
|
||||
const del = (opts.persist ? this.scope.persist() : this.scope).delete(uri);
|
||||
return opts.optional ? del.optionally() : del;
|
||||
const del = (persist ? this.scope.persist() : this.scope).delete(uri);
|
||||
return optional ? del.optionally() : del;
|
||||
}
|
||||
|
||||
public optPatch(
|
||||
uri: string | RegExp | ((uri: string) => boolean),
|
||||
opts: ScopeOpts,
|
||||
{ optional = false, persist = false }: ScopeOpts,
|
||||
) {
|
||||
opts = _.assign({ optional: false, persist: false }, opts);
|
||||
const patch = (opts.persist ? this.scope.persist() : this.scope).patch(uri);
|
||||
return opts.optional ? patch.optionally() : patch;
|
||||
const patch = (persist ? this.scope.persist() : this.scope).patch(uri);
|
||||
return optional ? patch.optionally() : patch;
|
||||
}
|
||||
|
||||
public optPost(
|
||||
uri: string | RegExp | ((uri: string) => boolean),
|
||||
opts: ScopeOpts,
|
||||
{ optional = false, persist = false }: ScopeOpts,
|
||||
) {
|
||||
opts = _.assign({ optional: false, persist: false }, opts);
|
||||
const post = (opts.persist ? this.scope.persist() : this.scope).post(uri);
|
||||
return opts.optional ? post.optionally() : post;
|
||||
const post = (persist ? this.scope.persist() : this.scope).post(uri);
|
||||
return optional ? post.optionally() : post;
|
||||
}
|
||||
|
||||
public done() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user