mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-23 23:42:24 +00:00
Code formatting
Signed-off-by: Thodoris Greasidis <thodoris@balena.io>
This commit is contained in:
parent
79f33c749b
commit
c2df87bcc6
@ -59,9 +59,10 @@ export function generateBaseConfig(
|
|||||||
appUpdatePollInterval: options.appUpdatePollInterval || 10,
|
appUpdatePollInterval: options.appUpdatePollInterval || 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
const promise = resin.models.os.getConfig(application.app_name, options) as Promise<
|
const promise = resin.models.os.getConfig(
|
||||||
ImgConfig & { apiKey?: string; }
|
application.app_name,
|
||||||
>;
|
options,
|
||||||
|
) as Promise<ImgConfig & { apiKey?: string }>;
|
||||||
return promise.tap(config => {
|
return promise.tap(config => {
|
||||||
// os.getConfig always returns a config for an app
|
// os.getConfig always returns a config for an app
|
||||||
delete config.apiKey;
|
delete config.apiKey;
|
||||||
|
@ -99,7 +99,7 @@ export function askLoginType() {
|
|||||||
|
|
||||||
export function selectDeviceType() {
|
export function selectDeviceType() {
|
||||||
return resin.models.config.getDeviceTypes().then(deviceTypes => {
|
return resin.models.config.getDeviceTypes().then(deviceTypes => {
|
||||||
deviceTypes = _.sortBy(deviceTypes, 'name')
|
deviceTypes = _.sortBy(deviceTypes, 'name');
|
||||||
return form.ask({
|
return form.ask({
|
||||||
message: 'Device Type',
|
message: 'Device Type',
|
||||||
type: 'list',
|
type: 'list',
|
||||||
|
@ -173,8 +173,10 @@ async function getOrSelectLocalDevice(deviceIp?: string): Promise<string> {
|
|||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getApplicationsWithOptionalUsers(sdk: ResinSdk.ResinSDK,
|
async function getApplicationsWithOptionalUsers(
|
||||||
options: ResinSdk.PineOptionsFor<ResinSdk.Application>) {
|
sdk: ResinSdk.ResinSDK,
|
||||||
|
options: ResinSdk.PineOptionsFor<ResinSdk.Application>,
|
||||||
|
) {
|
||||||
const _ = await import('lodash');
|
const _ = await import('lodash');
|
||||||
|
|
||||||
let applications = await sdk.models.application.getAll(options);
|
let applications = await sdk.models.application.getAll(options);
|
||||||
@ -182,7 +184,7 @@ async function getApplicationsWithOptionalUsers(sdk: ResinSdk.ResinSDK,
|
|||||||
// user has access to a collab app with the same name as a personal app.
|
// user has access to a collab app with the same name as a personal app.
|
||||||
if (applications.length !== _.uniqBy(applications, 'app_name').length) {
|
if (applications.length !== _.uniqBy(applications, 'app_name').length) {
|
||||||
options = _.merge(_.cloneDeep(options), {
|
options = _.merge(_.cloneDeep(options), {
|
||||||
$expand: { user: { $select: ['username'] } }
|
$expand: { user: { $select: ['username'] } },
|
||||||
});
|
});
|
||||||
applications = await sdk.models.application.getAll(options);
|
applications = await sdk.models.application.getAll(options);
|
||||||
}
|
}
|
||||||
@ -190,7 +192,6 @@ async function getApplicationsWithOptionalUsers(sdk: ResinSdk.ResinSDK,
|
|||||||
return applications;
|
return applications;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function selectAppFromList(applications: ResinSdk.Application[]) {
|
async function selectAppFromList(applications: ResinSdk.Application[]) {
|
||||||
const _ = await import('lodash');
|
const _ = await import('lodash');
|
||||||
const { selectFromList } = await import('../utils/patterns');
|
const { selectFromList } = await import('../utils/patterns');
|
||||||
@ -199,10 +200,13 @@ async function selectAppFromList(applications: ResinSdk.Application[]) {
|
|||||||
// user has access to a collab app with the same name as a personal app. We
|
// user has access to a collab app with the same name as a personal app. We
|
||||||
// present a list to the user which shows the fully qualified application
|
// present a list to the user which shows the fully qualified application
|
||||||
// name (user/appname) and allows them to select.
|
// name (user/appname) and allows them to select.
|
||||||
const hasSameNameApps = applications.length !== _.uniqBy(applications, 'app_name').length
|
const hasSameNameApps =
|
||||||
|
applications.length !== _.uniqBy(applications, 'app_name').length;
|
||||||
|
|
||||||
return selectFromList(
|
return selectFromList(
|
||||||
hasSameNameApps ? 'Found multiple applications with that name; please select the one to use' : 'Select application',
|
hasSameNameApps
|
||||||
|
? 'Found multiple applications with that name; please select the one to use'
|
||||||
|
: 'Select application',
|
||||||
_.map(applications, app => {
|
_.map(applications, app => {
|
||||||
let name = app.app_name;
|
let name = app.app_name;
|
||||||
if (hasSameNameApps) {
|
if (hasSameNameApps) {
|
||||||
@ -288,7 +292,8 @@ async function getOrSelectApplication(
|
|||||||
default: true,
|
default: true,
|
||||||
});
|
});
|
||||||
if (shouldCreateApp) {
|
if (shouldCreateApp) {
|
||||||
return createApplication(sdk, deviceType, options.$filter.app_name as string);
|
return createApplication(sdk, deviceType, options.$filter
|
||||||
|
.app_name as string);
|
||||||
}
|
}
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
@ -300,7 +305,7 @@ async function getOrSelectApplication(
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (validApplications.length === 0) {
|
if (validApplications.length === 0) {
|
||||||
throw new Error('No application found with a matching device type')
|
throw new Error('No application found with a matching device type');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validApplications.length === 1) {
|
if (validApplications.length === 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user