Update all imports to match new command directory structure

Signed-off-by: Vipul Gupta (@vipulgupta2048) <vipulgupta2048@gmail.com>
This commit is contained in:
Vipul Gupta (@vipulgupta2048) 2023-11-08 04:02:25 +05:30
parent dc40b0d969
commit 0711eefb7c
No known key found for this signature in database
GPG Key ID: D76FE376041D2649
23 changed files with 173 additions and 156 deletions

View File

@ -16,10 +16,10 @@
*/
import { Flags, Args } from '@oclif/core';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, stripIndent, getCliForm } from '../utils/lazy';
import { ExpectedError } from '../errors';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent, getCliForm } from '../../utils/lazy';
import { ExpectedError } from '../../errors';
import type { WhoamiResult } from 'balena-sdk';
interface FlagsDef {
@ -123,7 +123,7 @@ export default class LoginCmd extends Command {
const { flags: options, args: params } = await this.parse(LoginCmd);
const balena = getBalenaSdk();
const messages = await import('../utils/messages');
const messages = await import('../../utils/messages');
const balenaUrl = await balena.settings.get('balenaUrl');
// Consolidate user/email options
@ -202,16 +202,16 @@ ${messages.reachingOut}`);
}
// Credentials
else if (loginOptions.credentials) {
const patterns = await import('../utils/patterns');
const patterns = await import('../../utils/patterns');
return patterns.authenticate(loginOptions);
}
// Web
else if (loginOptions.web) {
const auth = await import('../auth');
const auth = await import('../../auth');
await auth.login({ port: loginOptions.port });
return;
} else {
const patterns = await import('../utils/patterns');
const patterns = await import('../../utils/patterns');
// User had not selected login preference, prompt interactively
const loginType = await patterns.askLoginType();
if (loginType === 'register') {

View File

@ -15,8 +15,8 @@
* limitations under the License.
*/
import Command from '../command';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
import Command from '../../command';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
export default class LogoutCmd extends Command {
public static description = stripIndent`

View File

@ -15,8 +15,8 @@
* limitations under the License.
*/
import Command from '../command';
import { getBalenaSdk, getVisuals, stripIndent } from '../utils/lazy';
import Command from '../../command';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
export default class WhoamiCmd extends Command {
public static description = stripIndent`

View File

@ -16,20 +16,20 @@
*/
import { Args, Flags } from '@oclif/core';
import Command from '../command';
import { getBalenaSdk } from '../utils/lazy';
import * as cf from '../utils/common-flags';
import * as compose from '../utils/compose';
import Command from '../../command';
import { getBalenaSdk } from '../../utils/lazy';
import * as cf from '../../utils/common-flags';
import * as compose from '../../utils/compose';
import type { ApplicationType, BalenaSDK } from 'balena-sdk';
import {
buildArgDeprecation,
dockerignoreHelp,
registrySecretsHelp,
} from '../utils/messages';
import type { ComposeCliFlags, ComposeOpts } from '../utils/compose-types';
import { buildProject, composeCliFlags } from '../utils/compose_ts';
import type { BuildOpts, DockerCliFlags } from '../utils/docker';
import { dockerCliFlags } from '../utils/docker';
} from '../../utils/messages';
import type { ComposeCliFlags, ComposeOpts } from '../../utils/compose-types';
import { buildProject, composeCliFlags } from '../../utils/compose_ts';
import type { BuildOpts, DockerCliFlags } from '../../utils/docker';
import { dockerCliFlags } from '../../utils/docker';
// TODO: For this special one we can't use Interfaces.InferredFlags/InferredArgs
// because of the 'registry-secrets' type which is defined in the actual code
@ -148,14 +148,14 @@ ${dockerignoreHelp}
(opts.fleet == null && (opts.arch == null || opts.deviceType == null)) ||
(opts.fleet != null && (opts.arch != null || opts.deviceType != null))
) {
const { ExpectedError } = await import('../errors');
const { ExpectedError } = await import('../../errors');
throw new ExpectedError(
'You must specify either a fleet (-f), or the device type (-d) and architecture (-A)',
);
}
// Validate project directory
const { validateProjectDirectory } = await import('../utils/compose_ts');
const { validateProjectDirectory } = await import('../../utils/compose_ts');
const { dockerfilePath, registrySecrets } = await validateProjectDirectory(
sdk,
{
@ -172,7 +172,7 @@ ${dockerignoreHelp}
protected async getAppAndResolveArch(opts: FlagsDef) {
if (opts.fleet) {
const { getAppWithArch } = await import('../utils/helpers');
const { getAppWithArch } = await import('../../utils/helpers');
const app = await getAppWithArch(opts.fleet);
opts.arch = app.arch;
opts.deviceType = app.is_for__device_type[0].slug;
@ -181,7 +181,7 @@ ${dockerignoreHelp}
}
protected async prepareBuild(options: FlagsDef) {
const { getDocker, generateBuildOpts } = await import('../utils/docker');
const { getDocker, generateBuildOpts } = await import('../../utils/docker');
const [docker, buildOpts, composeOpts] = await Promise.all([
getDocker(options),
generateBuildOpts(options),
@ -209,7 +209,7 @@ ${dockerignoreHelp}
*/
protected async buildProject(
docker: import('dockerode'),
logger: import('../utils/logger'),
logger: import('../../utils/logger'),
composeOpts: ComposeOpts,
opts: {
app?: {
@ -221,7 +221,7 @@ ${dockerignoreHelp}
buildOpts: BuildOpts;
},
) {
const { loadProject } = await import('../utils/compose_ts');
const { loadProject } = await import('../../utils/compose_ts');
const project = await loadProject(
logger,

View File

@ -18,31 +18,31 @@
import { Args, Flags } from '@oclif/core';
import type { ImageDescriptor } from '@balena/compose/dist/parse';
import Command from '../command';
import { ExpectedError } from '../errors';
import { getBalenaSdk, getChalk, stripIndent } from '../utils/lazy';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import { getBalenaSdk, getChalk, stripIndent } from '../../utils/lazy';
import {
dockerignoreHelp,
registrySecretsHelp,
buildArgDeprecation,
} from '../utils/messages';
import * as ca from '../utils/common-args';
import * as compose from '../utils/compose';
} from '../../utils/messages';
import * as ca from '../../utils/common-args';
import * as compose from '../../utils/compose';
import type {
BuiltImage,
ComposeCliFlags,
ComposeOpts,
Release as ComposeReleaseInfo,
} from '../utils/compose-types';
import type { BuildOpts, DockerCliFlags } from '../utils/docker';
} from '../../utils/compose-types';
import type { BuildOpts, DockerCliFlags } from '../../utils/docker';
import {
applyReleaseTagKeysAndValues,
buildProject,
composeCliFlags,
isBuildConfig,
parseReleaseTagKeysAndValues,
} from '../utils/compose_ts';
import { dockerCliFlags } from '../utils/docker';
} from '../../utils/compose_ts';
import { dockerCliFlags } from '../../utils/docker';
import type { ApplicationType, DeviceType, Release } from 'balena-sdk';
interface ApplicationWithArch {
@ -175,7 +175,7 @@ ${dockerignoreHelp}
const sdk = getBalenaSdk();
const { getRegistrySecrets, validateProjectDirectory } = await import(
'../utils/compose_ts'
'../../utils/compose_ts'
);
const { releaseTagKeys, releaseTagValues } = parseReleaseTagKeysAndValues(
@ -199,10 +199,10 @@ ${dockerignoreHelp}
(options as FlagsDef)['registry-secrets'] = registrySecrets;
}
const helpers = await import('../utils/helpers');
const helpers = await import('../../utils/helpers');
const app = await helpers.getAppWithArch(fleet);
const dockerUtils = await import('../utils/docker');
const dockerUtils = await import('../../utils/docker');
const [docker, buildOpts, composeOpts] = await Promise.all([
dockerUtils.getDocker(options),
dockerUtils.generateBuildOpts(options as FlagsDef),
@ -232,7 +232,7 @@ ${dockerignoreHelp}
async deployProject(
docker: import('dockerode'),
logger: import('../utils/logger'),
logger: import('../../utils/logger'),
composeOpts: ComposeOpts,
opts: {
app: ApplicationWithArch; // the application instance to deploy to
@ -250,7 +250,7 @@ ${dockerignoreHelp}
const doodles = await import('resin-doodles');
const sdk = getBalenaSdk();
const { deployProject: $deployProject, loadProject } = await import(
'../utils/compose_ts'
'../../utils/compose_ts'
);
const appType = opts.app.application_type[0];
@ -332,7 +332,7 @@ ${dockerignoreHelp}
let release: Release | ComposeReleaseInfo['release'];
if (appType.slug === 'legacy-v1' || appType.slug === 'legacy-v2') {
const { deployLegacy } = require('../utils/deploy-legacy');
const { deployLegacy } = require('../../utils/deploy-legacy');
const msg = getChalk().yellow(
'Target fleet requires legacy deploy method.',

View File

@ -18,11 +18,11 @@ import { Flags } from '@oclif/core';
import type { Interfaces } from '@oclif/core';
import type * as SDK from 'balena-sdk';
import * as _ from 'lodash';
import Command from '../command';
import { ExpectedError } from '../errors';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../utils/lazy';
import { applicationIdInfo } from '../utils/messages';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
type FlagsDef = Interfaces.InferredFlags<typeof EnvsCmd.flags>;
@ -124,12 +124,16 @@ export default class EnvsCmd extends Command {
const balena = getBalenaSdk();
let fleetSlug: string | undefined = options.fleet
? await (await import('../utils/sdk')).getFleetSlug(balena, options.fleet)
? await (
await import('../../utils/sdk')
).getFleetSlug(balena, options.fleet)
: undefined;
let fullUUID: string | undefined; // as oppposed to the short, 7-char UUID
if (options.device) {
const { getDeviceAndMaybeAppFromUUID } = await import('../utils/cloud');
const { getDeviceAndMaybeAppFromUUID } = await import(
'../../utils/cloud'
);
const [device, app] = await getDeviceAndMaybeAppFromUUID(
balena,
options.device,
@ -182,7 +186,7 @@ export default class EnvsCmd extends Command {
}
if (options.json) {
const { pickAndRename } = await import('../utils/helpers');
const { pickAndRename } = await import('../../utils/helpers');
const mapped = varArray.map((o) => pickAndRename(o, fields));
this.log(JSON.stringify(mapped, null, 4));
} else {

View File

@ -17,9 +17,9 @@
import type * as BalenaSdk from 'balena-sdk';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
interface ExtendedApplication extends ApplicationWithDeviceTypeSlug {
device_count: number;

View File

@ -16,8 +16,8 @@
*/
import { Flags } from '@oclif/core';
import Command from '../command';
import { stripIndent } from '../utils/lazy';
import Command from '../../command';
import { stripIndent } from '../../utils/lazy';
export interface JsonVersions {
'balena-cli': string;
@ -72,7 +72,7 @@ export default class VersionCmd extends Command {
public async run() {
const { flags: options } = await this.parse(VersionCmd);
const versions: JsonVersions = {
'balena-cli': (await import('../../package.json')).version,
'balena-cli': (await import('../../../package.json')).version,
'Node.js':
process.version && process.version.startsWith('v')
? process.version.slice(1)

View File

@ -15,9 +15,9 @@
* limitations under the License.
*/
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../utils/lazy';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
export default class KeysCmd extends Command {
public static description = stripIndent`

View File

@ -16,9 +16,9 @@
*/
import { Flags, Args } from '@oclif/core';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { LogMessage } from 'balena-sdk';
const MAX_RETRY = 1000;
@ -96,14 +96,14 @@ export default class LogsCmd extends Command {
const { args: params, flags: options } = await this.parse(LogsCmd);
const balena = getBalenaSdk();
const { serviceIdToName } = await import('../utils/cloud');
const { serviceIdToName } = await import('../../utils/cloud');
const { connectAndDisplayDeviceLogs, displayLogObject } = await import(
'../utils/device/logs'
'../../utils/device/logs'
);
const { validateIPAddress, validateDotLocalUrl } = await import(
'../utils/validation'
'../../utils/validation'
);
const Logger = await import('../utils/logger');
const Logger = await import('../../utils/logger');
const logger = Logger.getLogger();
@ -132,13 +132,13 @@ export default class LogsCmd extends Command {
validateDotLocalUrl(params.device)
) {
// Logs from local device
const { DeviceAPI } = await import('../utils/device/api');
const { DeviceAPI } = await import('../../utils/device/api');
const deviceApi = new DeviceAPI(logger, params.device);
logger.logDebug('Checking we can access device');
try {
await deviceApi.ping();
} catch (e) {
const { ExpectedError } = await import('../errors');
const { ExpectedError } = await import('../../errors');
throw new ExpectedError(
`Cannot access device at address ${params.device}. Device may not be in local mode.`,
);

View File

@ -16,9 +16,9 @@
*/
import { Flags } from '@oclif/core';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getCliUx, stripIndent } from '../utils/lazy';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getCliUx, stripIndent } from '../../utils/lazy';
export default class ScanCmd extends Command {
public static description = stripIndent`
@ -64,9 +64,11 @@ export default class ScanCmd extends Command {
public async run() {
const _ = await import('lodash');
const { discoverLocalBalenaOsDevices } = await import('../utils/discover');
const { discoverLocalBalenaOsDevices } = await import(
'../../utils/discover'
);
const prettyjson = await import('prettyjson');
const dockerUtils = await import('../utils/docker');
const dockerUtils = await import('../../utils/docker');
const dockerPort = 2375;
const dockerTimeout = 2000;

View File

@ -16,10 +16,13 @@
*/
import { Flags, Args } from '@oclif/core';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
import { parseAsInteger, validateLocalHostnameOrIp } from '../utils/validation';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import {
parseAsInteger,
validateLocalHostnameOrIp,
} from '../../utils/validation';
export default class SshCmd extends Command {
public static description = stripIndent`
@ -108,7 +111,7 @@ export default class SshCmd extends Command {
// Local connection
if (validateLocalHostnameOrIp(params.fleetOrDevice)) {
const { performLocalDeviceSSH } = await import('../utils/device/ssh');
const { performLocalDeviceSSH } = await import('../../utils/device/ssh');
return await performLocalDeviceSSH({
hostname: params.fleetOrDevice,
port: options.port || 'local',
@ -119,8 +122,8 @@ export default class SshCmd extends Command {
}
// Remote connection
const { getProxyConfig } = await import('../utils/helpers');
const { getOnlineTargetDeviceUuid } = await import('../utils/patterns');
const { getProxyConfig } = await import('../../utils/helpers');
const { getOnlineTargetDeviceUuid } = await import('../../utils/patterns');
const sdk = getBalenaSdk();
const proxyConfig = getProxyConfig();
@ -134,7 +137,7 @@ export default class SshCmd extends Command {
params.fleetOrDevice,
);
const { which } = await import('../utils/which');
const { which } = await import('../../utils/which');
const [whichProxytunnel, { username }, proxyUrl] = await Promise.all([
useProxy ? which('proxytunnel', false) : undefined,
@ -185,7 +188,9 @@ export default class SshCmd extends Command {
// that we know exists and is accessible
let containerId: string | undefined;
if (params.service != null) {
const { getContainerIdForService } = await import('../utils/device/ssh');
const { getContainerIdForService } = await import(
'../../utils/device/ssh'
);
containerId = await getContainerIdForService({
deviceUuid,
hostname: `ssh.${proxyUrl}`,
@ -202,7 +207,7 @@ export default class SshCmd extends Command {
} else {
accessCommand = `host ${deviceUuid}`;
}
const { runRemoteCommand } = await import('../utils/ssh');
const { runRemoteCommand } = await import('../../utils/ssh');
await runRemoteCommand({
cmd: accessCommand,
hostname: `ssh.${proxyUrl}`,

View File

@ -16,15 +16,15 @@
*/
import { Flags, Args } from '@oclif/core';
import Command from '../command';
import Command from '../../command';
import {
NoPortsDefinedError,
InvalidPortMappingError,
ExpectedError,
} from '../errors';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
import { lowercaseIfSlug } from '../utils/normalization';
} from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { lowercaseIfSlug } from '../../utils/normalization';
import type { Server, Socket } from 'net';
@ -122,7 +122,7 @@ export default class TunnelCmd extends Command {
}
// Ascertain device uuid
const { getOnlineTargetDeviceUuid } = await import('../utils/patterns');
const { getOnlineTargetDeviceUuid } = await import('../../utils/patterns');
const uuid = await getOnlineTargetDeviceUuid(sdk, params.deviceOrFleet);
logger.logInfo(`Opening a tunnel to ${uuid}...`);
@ -133,7 +133,9 @@ export default class TunnelCmd extends Command {
})
.map(async ({ localPort, localAddress, remotePort }) => {
try {
const { tunnelConnectionToDevice } = await import('../utils/tunnel');
const { tunnelConnectionToDevice } = await import(
'../../utils/tunnel'
);
const handler = await tunnelConnectionToDevice(uuid, remotePort, sdk);
const { createServer } = await import('net');

View File

@ -16,10 +16,10 @@
*/
import { Flags, Args } from '@oclif/core';
import Command from '../command';
import { ExpectedError } from '../errors';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
export default class NoteCmd extends Command {
public static description = stripIndent`

View File

@ -15,9 +15,9 @@
* limitations under the License.
*/
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../utils/lazy';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
export default class OrgsCmd extends Command {
public static description = stripIndent`
@ -38,7 +38,7 @@ export default class OrgsCmd extends Command {
public async run() {
await this.parse(OrgsCmd);
const { getOwnOrganizations } = await import('../utils/sdk');
const { getOwnOrganizations } = await import('../../utils/sdk');
// Get organizations
const organizations = await getOwnOrganizations(getBalenaSdk(), {

View File

@ -16,11 +16,11 @@
*/
import { Args, Flags } from '@oclif/core';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
import { applicationIdInfo } from '../utils/messages';
import { parseAsLocalHostnameOrIp } from '../utils/validation';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import { parseAsLocalHostnameOrIp } from '../../utils/validation';
export default class JoinCmd extends Command {
public static description = stripIndent`
@ -78,7 +78,7 @@ export default class JoinCmd extends Command {
public async run() {
const { args: params, flags: options } = await this.parse(JoinCmd);
const promote = await import('../utils/promote');
const promote = await import('../../utils/promote');
const sdk = getBalenaSdk();
const logger = await Command.getLogger();
return promote.join(

View File

@ -16,10 +16,10 @@
*/
import { Args } from '@oclif/core';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { stripIndent } from '../utils/lazy';
import { parseAsLocalHostnameOrIp } from '../utils/validation';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { stripIndent } from '../../utils/lazy';
import { parseAsLocalHostnameOrIp } from '../../utils/validation';
export default class LeaveCmd extends Command {
public static description = stripIndent`
@ -62,7 +62,7 @@ export default class LeaveCmd extends Command {
public async run() {
const { args: params } = await this.parse(LeaveCmd);
const promote = await import('../utils/promote');
const promote = await import('../../utils/promote');
const logger = await Command.getLogger();
return promote.leave(logger, params.deviceIpOrHostname);
}

View File

@ -15,18 +15,18 @@
* limitations under the License.
*/
import Command from '../command';
import { ExpectedError } from '../errors';
import * as cf from '../utils/common-flags';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import {
getBalenaSdk,
getCliForm,
getVisuals,
stripIndent,
} from '../utils/lazy';
import { applicationIdInfo } from '../utils/messages';
import { dockerConnectionCliFlags } from '../utils/docker';
import { parseAsInteger } from '../utils/validation';
} from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import { dockerConnectionCliFlags } from '../../utils/docker';
import { parseAsInteger } from '../../utils/validation';
import { Flags, Args } from '@oclif/core';
import * as _ from 'lodash';
@ -148,7 +148,7 @@ Can be repeated to add multiple certificates.\
const balenaPreload = await import('balena-preload');
const visuals = getVisuals();
const nodeCleanup = await import('node-cleanup');
const { instanceOf } = await import('../errors');
const { instanceOf } = await import('../../errors');
// Check image file exists
try {
@ -171,7 +171,9 @@ Can be repeated to add multiple certificates.\
// balena-preload currently does not work with numerical app IDs
// Load app here, and use app slug from hereon
const fleetSlug: string | undefined = options.fleet
? await (await import('../utils/sdk')).getFleetSlug(balena, options.fleet)
? await (
await import('../../utils/sdk')
).getFleetSlug(balena, options.fleet)
: undefined;
const progressBars: {
@ -227,7 +229,7 @@ Can be repeated to add multiple certificates.\
}
// Get a configured dockerode instance
const dockerUtils = await import('../utils/docker');
const dockerUtils = await import('../../utils/docker');
const docker = await dockerUtils.getDocker(options);
const preloader = new balenaPreload.Preloader(
undefined,
@ -479,7 +481,7 @@ Would you like to disable automatic updates for this fleet now?\
}
async getAppWithReleases(balenaSdk: BalenaSDK, slug: string) {
const { getApplication } = await import('../utils/sdk');
const { getApplication } = await import('../../utils/sdk');
return await getApplication(balenaSdk, slug, {
$expand: this.applicationExpandOptions,

View File

@ -17,18 +17,18 @@
import { Flags, Args } from '@oclif/core';
import type { Interfaces } from '@oclif/core';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
import { dockerignoreHelp, registrySecretsHelp } from '../utils/messages';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { dockerignoreHelp, registrySecretsHelp } from '../../utils/messages';
import type { BalenaSDK } from 'balena-sdk';
import { ExpectedError, instanceOf } from '../errors';
import { ExpectedError, instanceOf } from '../../errors';
import { RegistrySecrets } from '@balena/compose/dist/multibuild';
import { lowercaseIfSlug } from '../utils/normalization';
import { lowercaseIfSlug } from '../../utils/normalization';
import {
applyReleaseTagKeysAndValues,
parseReleaseTagKeysAndValues,
} from '../utils/compose_ts';
} from '../../utils/compose_ts';
enum BuildTarget {
Cloud,
@ -233,7 +233,7 @@ export default class PushCmd extends Command {
logger.logDebug(`Using build source directory: ${options.source} `);
const sdk = getBalenaSdk();
const { validateProjectDirectory } = await import('../utils/compose_ts');
const { validateProjectDirectory } = await import('../../utils/compose_ts');
const { dockerfilePath, registrySecrets } = await validateProjectDirectory(
sdk,
{
@ -276,8 +276,8 @@ export default class PushCmd extends Command {
dockerfilePath: string,
registrySecrets: RegistrySecrets,
) {
const remote = await import('../utils/remote-build');
const { getApplication } = await import('../utils/sdk');
const remote = await import('../../utils/remote-build');
const { getApplication } = await import('../../utils/sdk');
// Check for invalid options
const localOnlyOptions: Array<keyof FlagsDef> = [
@ -356,7 +356,7 @@ export default class PushCmd extends Command {
'is only valid when pushing to a fleet',
);
const deviceDeploy = await import('../utils/device/deploy');
const deviceDeploy = await import('../../utils/device/deploy');
try {
await deviceDeploy.deployToDevice({
@ -376,7 +376,7 @@ export default class PushCmd extends Command {
convertEol: !options['noconvert-eol'],
});
} catch (e) {
const { BuildError } = await import('../utils/device/errors');
const { BuildError } = await import('../../utils/device/errors');
if (instanceOf(e, BuildError)) {
throw new ExpectedError(e.toString());
} else {
@ -386,7 +386,9 @@ export default class PushCmd extends Command {
}
protected async getBuildTarget(appOrDevice: string): Promise<BuildTarget> {
const { validateLocalHostnameOrIp } = await import('../utils/validation');
const { validateLocalHostnameOrIp } = await import(
'../../utils/validation'
);
return validateLocalHostnameOrIp(appOrDevice)
? BuildTarget.Device

View File

@ -16,12 +16,12 @@
*/
import { Args } from '@oclif/core';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../utils/lazy';
import { applicationNameNote } from '../utils/messages';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { applicationNameNote } from '../../utils/messages';
import type * as BalenaSdk from 'balena-sdk';
import { jsonInfo } from '../utils/messages';
import { jsonInfo } from '../../utils/messages';
export default class ReleasesCmd extends Command {
public static description = stripIndent`
@ -67,7 +67,7 @@ export default class ReleasesCmd extends Command {
];
const balena = getBalenaSdk();
const { getFleetSlug } = await import('../utils/sdk');
const { getFleetSlug } = await import('../../utils/sdk');
const releases = await balena.models.release.getAllByApplication(
await getFleetSlug(balena, params.fleet),

View File

@ -15,9 +15,9 @@
* limitations under the License.
*/
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
export default class SettingsCmd extends Command {
public static description = stripIndent`

View File

@ -16,11 +16,11 @@
*/
import { Flags, Args } from '@oclif/core';
import Command from '../command';
import { ExpectedError } from '../errors';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, getCliUx, stripIndent } from '../utils/lazy';
import { applicationIdInfo } from '../utils/messages';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getCliUx, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
export default class SupportCmd extends Command {
public static description = stripIndent`
@ -116,7 +116,7 @@ export default class SupportCmd extends Command {
ux.action.stop();
}
const { getFleetSlug } = await import('../utils/sdk');
const { getFleetSlug } = await import('../../utils/sdk');
// Process applications
for (const appName of appNames) {

View File

@ -15,11 +15,11 @@
* limitations under the License.
*/
import Command from '../command';
import { ExpectedError } from '../errors';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../utils/lazy';
import { applicationIdInfo } from '../utils/messages';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
export default class TagsCmd extends Command {
public static description = stripIndent`
@ -71,7 +71,7 @@ export default class TagsCmd extends Command {
let tags;
if (options.fleet) {
const { getFleetSlug } = await import('../utils/sdk');
const { getFleetSlug } = await import('../../utils/sdk');
tags = await balena.models.application.tags.getAllByApplication(
await getFleetSlug(balena, options.fleet),
);
@ -81,7 +81,7 @@ export default class TagsCmd extends Command {
}
if (options.release) {
const { disambiguateReleaseParam } = await import(
'../utils/normalization'
'../../utils/normalization'
);
const releaseParam = await disambiguateReleaseParam(
balena,