Move to ESM

Change-type: major
This commit is contained in:
Otavio Jacobi 2024-12-19 15:31:07 -03:00
parent 6672d38027
commit c4e956712d
185 changed files with 878 additions and 1789 deletions

View File

@ -20,7 +20,7 @@ import { exec, execFile } from 'child_process';
import type { Stats } from 'fs';
import * as fs from 'fs-extra';
import * as klaw from 'klaw';
import * as path from 'path';
import path from 'path';
import * as rimraf from 'rimraf';
import { promisify } from 'util';
import { notarize } from '@electron/notarize';

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import * as path from 'path';
import path from 'path';
import { MarkdownFileParser } from './utils';
import { GlobSync } from 'glob';

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as path from 'path';
import path from 'path';
import { getCapitanoDoc } from './capitanodoc';
import type { Category, Document, OclifCommand } from './doc-types';
import * as markdown from './markdown';

View File

@ -16,7 +16,7 @@
*/
import { Parser } from '@oclif/core';
import * as ent from 'ent';
import * as _ from 'lodash';
import _ from 'lodash';
import { capitanoizeOclifUsage } from '../../src/utils/oclif-utils';
import type { Category, Document } from './doc-types';

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import * as fs from 'fs';
import fs from 'fs';
import * as readline from 'readline';
export class MarkdownFileParser {

View File

@ -17,9 +17,9 @@
// eslint-disable-next-line no-restricted-imports
import { stripIndent } from 'common-tags';
import * as _ from 'lodash';
import _ from 'lodash';
import { promises as fs } from 'fs';
import * as path from 'path';
import path from 'path';
import { simpleGit } from 'simple-git';
const ROOT = path.normalize(path.join(__dirname, '..'));

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import * as _ from 'lodash';
import _ from 'lodash';
import {
buildOclifInstaller,

View File

@ -16,8 +16,8 @@
*/
import { spawn } from 'child_process';
import * as path from 'path';
import * as fs from 'fs';
import path from 'path';
import fs from 'fs';
import * as whichMod from 'which';
export const ROOT = path.join(__dirname, '..');

877
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@
"url": "git@github.com:balena-io/balena-cli.git"
},
"preferGlobal": true,
"type": "module",
"files": [
"bin/.fast-boot.json",
"bin/",

View File

@ -16,14 +16,14 @@
*/
import * as packageJSON from '../package.json';
import type { AppOptions } from './preparser';
import type { AppOptions } from './preparser.js';
import {
checkDeletedCommand,
preparseArgs,
unsupportedFlag,
} from './preparser';
import { CliSettings } from './utils/bootstrap';
import { onceAsync } from './utils/lazy';
} from './preparser.js';
import { CliSettings } from './utils/bootstrap.js';
import { onceAsync } from './utils/lazy.js';
import { run as mainRun, settings } from '@oclif/core';
/**
@ -31,7 +31,7 @@ import { run as mainRun, settings } from '@oclif/core';
* @see https://docs.sentry.io/error-reporting/quickstart/?platform=node
*/
export const setupSentry = onceAsync(async () => {
const config = await import('./config');
const config = await import('./config.js');
const Sentry = await import('@sentry/node');
Sentry.init({
autoSessionTracking: false,
@ -51,7 +51,7 @@ export const setupSentry = onceAsync(async () => {
async function checkNodeVersion() {
const validNodeVersions = packageJSON.engines.node;
if (!(await import('semver')).satisfies(process.version, validNodeVersions)) {
const { getNodeEngineVersionWarn } = await import('./utils/messages');
const { getNodeEngineVersionWarn } = await import('./utils/messages.js');
console.warn(getNodeEngineVersionWarn(process.version, validNodeVersions));
}
}
@ -89,13 +89,13 @@ async function init() {
const settings = new CliSettings();
// Proxy setup should be done early on, before loading balena-sdk
await (await import('./utils/proxy')).setupGlobalHttpProxy(settings);
await (await import('./utils/proxy.js')).setupGlobalHttpProxy(settings);
setupBalenaSdkSharedOptions(settings);
// check for CLI updates once a day
if (!process.env.BALENARC_OFFLINE_MODE) {
(await import('./utils/update')).notify();
(await import('./utils/update.js')).notify();
}
}
@ -104,7 +104,7 @@ async function oclifRun(command: string[], options: AppOptions) {
let deprecationPromise: Promise<void> | undefined;
// check and enforce the CLI's deprecation policy
if (!(unsupportedFlag || process.env.BALENARC_UNSUPPORTED)) {
const { DeprecationChecker } = await import('./deprecation');
const { DeprecationChecker } = await import('./deprecation.js');
const deprecationChecker = new DeprecationChecker(packageJSON.version);
// warnAndAbortIfDeprecated uses previously cached data only
await deprecationChecker.warnAndAbortIfDeprecated();
@ -147,11 +147,11 @@ async function oclifRun(command: string[], options: AppOptions) {
// the try/catch block above, execution does not get past the
// Promise.all() call below, but I don't understand why.
if (isEEXIT) {
(await import('./fast-boot')).stop();
(await import('./fast-boot.js')).stop();
}
})(!options.noFlush);
const { trackPromise } = await import('./hooks/prerun');
const { trackPromise } = await import('./hooks/prerun.js');
await Promise.all([trackPromise, deprecationPromise, runPromise]);
}
@ -160,7 +160,7 @@ async function oclifRun(command: string[], options: AppOptions) {
export async function run(cliArgs = process.argv, options: AppOptions) {
try {
const { setOfflineModeEnvVars, normalizeEnvVars } = await import(
'./utils/bootstrap'
'./utils/bootstrap.js'
);
setOfflineModeEnvVars();
normalizeEnvVars();
@ -173,10 +173,10 @@ export async function run(cliArgs = process.argv, options: AppOptions) {
const args = await preparseArgs(cliArgs);
await oclifRun(args, options);
} catch (err) {
await (await import('./errors')).handleError(err);
await (await import('./errors.js')).handleError(err);
} finally {
try {
(await import('./fast-boot')).stop();
(await import('./fast-boot.js')).stop();
} catch (e) {
if (process.env.DEBUG) {
console.error(`[debug] Stopping fast-boot: ${e}`);

View File

@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { getBalenaSdk } from '../utils/lazy';
import { LoginServer } from './server';
import { getBalenaSdk } from '../utils/lazy.js';
import { LoginServer } from './server.js';
/**
* @module auth
@ -42,7 +42,7 @@ import { LoginServer } from './server';
* console.log("My session token is: #{sessionToken}")
*/
export async function login({ host = '127.0.0.1', port = 0 }) {
const utils = await import('./utils');
const utils = await import('./utils.js');
const loginServer = new LoginServer();
const {
@ -55,7 +55,7 @@ export async function login({ host = '127.0.0.1', port = 0 }) {
const loginUrl = await utils.getDashboardLoginURL(callbackUrl);
console.info(`Opening web browser for URL:\n${loginUrl}`);
const open = await import('open');
const { default: open } = await import('open');
await open(loginUrl, { wait: false });
const balena = getBalenaSdk();

View File

@ -14,14 +14,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import * as bodyParser from 'body-parser';
import bodyParser from 'body-parser';
import { EventEmitter } from 'events';
import * as express from 'express';
import express from 'express';
import type { Socket } from 'net';
import * as path from 'path';
import path from 'path';
import * as utils from './utils';
import { ExpectedError } from '../errors';
import * as utils from './utils.js';
import { ExpectedError } from '../errors.js';
export class LoginServer extends EventEmitter {
protected expressApp: express.Express;

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { getBalenaSdk } from '../utils/lazy';
import { getBalenaSdk } from '../utils/lazy.js';
/**
* Get dashboard CLI login URL

View File

@ -16,15 +16,15 @@
*/
import { Args, Command } from '@oclif/core';
import { ExpectedError } from '../../errors';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { ExpectedError } from '../../errors.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
async function isLoggedInWithJwt() {
const balena = getBalenaSdk();
try {
const token = await balena.auth.getToken();
const { default: jwtDecode } = await import('jwt-decode');
jwtDecode(token);
jwtDecode.default(token);
return true;
} catch {
return false;

View File

@ -16,8 +16,8 @@
*/
import { Flags, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy.js';
export default class APIKeyListCmd extends Command {
public static aliases = ['api-keys'];
@ -45,7 +45,7 @@ export default class APIKeyListCmd extends Command {
public async run() {
const { flags: options } = await this.parse(APIKeyListCmd);
const { getApplication } = await import('../../utils/sdk');
const { getApplication } = await import('../../utils/sdk.js');
const actorId = options.fleet
? (
await getApplication(getBalenaSdk(), options.fleet, {

View File

@ -16,7 +16,7 @@
*/
import { Args, Command } from '@oclif/core';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class RevokeCmd extends Command {
public static description = stripIndent`

View File

@ -16,7 +16,7 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import { stripIndent } from '../../utils/lazy';
import { stripIndent } from '../../utils/lazy.js';
export default class AppCreateCmd extends Command {
public static description = stripIndent`
@ -71,7 +71,7 @@ export default class AppCreateCmd extends Command {
const { args: params, flags: options } = await this.parse(AppCreateCmd);
await (
await import('../../utils/application-create')
await import('../../utils/application-create.js')
).applicationCreateBase('app', options, params);
}
}

View File

@ -16,7 +16,7 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import { stripIndent } from '../../utils/lazy';
import { stripIndent } from '../../utils/lazy.js';
export default class BlockCreateCmd extends Command {
public static description = stripIndent`
@ -71,7 +71,7 @@ export default class BlockCreateCmd extends Command {
const { args: params, flags: options } = await this.parse(BlockCreateCmd);
await (
await import('../../utils/application-create')
await import('../../utils/application-create.js')
).applicationCreateBase('block', options, params);
}
}

View File

@ -16,9 +16,9 @@
*/
import { Args, Flags, Command } from '@oclif/core';
import { getBalenaSdk } from '../../utils/lazy';
import * as cf from '../../utils/common-flags';
import * as compose from '../../utils/compose';
import { getBalenaSdk } from '../../utils/lazy.js';
import * as cf from '../../utils/common-flags.js';
import * as compose from '../../utils/compose.js';
import type {
ApplicationType,
BalenaSDK,
@ -30,11 +30,12 @@ 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.js';
import type { ComposeCliFlags, ComposeOpts } from '../../utils/compose-types.js';
import { buildProject, composeCliFlags } from '../../utils/compose_ts.js';
import type { BuildOpts, DockerCliFlags } from '../../utils/docker.js';
import { dockerCliFlags } from '../../utils/docker.js';
import type Dockerode from 'dockerode';
type ComposeGenerateOptsParam = Parameters<typeof compose.generateOpts>[0];
@ -103,8 +104,8 @@ ${dockerignoreHelp}
public async run() {
const { args: params, flags: options } = await this.parse(BuildCmd);
const Logger = await import('../../utils/logger');
const { checkLoggedInIf } = await import('../../utils/patterns');
const { default: Logger } = await import('../../utils/logger.js');
const { checkLoggedInIf } = await import('../../utils/patterns.js');
await checkLoggedInIf(!!options.fleet);
@ -157,14 +158,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.js');
throw new ExpectedError(
'You must specify either a fleet (-f), or the device type (-d) and optionally the architecture (-A)',
);
}
// Validate project directory
const { validateProjectDirectory } = await import('../../utils/compose_ts');
const { validateProjectDirectory } = await import('../../utils/compose_ts.js');
const { dockerfilePath, registrySecrets } = await validateProjectDirectory(
sdk,
{
@ -200,7 +201,7 @@ ${dockerignoreHelp}
)) as PineTypedResult<DeviceType, typeof deviceTypeOpts>
).is_of__cpu_architecture[0].slug;
} catch (err) {
const { ExpectedError } = await import('../../errors');
const { ExpectedError } = await import('../../errors.js');
if (err instanceof sdk.errors.BalenaInvalidDeviceType) {
let message = err.message;
if (!(await sdk.auth.isLoggedIn())) {
@ -217,7 +218,7 @@ ${dockerignoreHelp}
protected async getAppAndResolveArch(opts: PrepareBuildOpts) {
if (opts.fleet) {
const { getAppWithArch } = await import('../../utils/helpers');
const { getAppWithArch } = await import('../../utils/helpers.js');
const app = await getAppWithArch(opts.fleet);
opts.arch = app.arch;
opts.deviceType = app.is_for__device_type[0].slug;
@ -225,8 +226,14 @@ ${dockerignoreHelp}
}
}
protected async prepareBuild(options: PrepareBuildOpts) {
const { getDocker, generateBuildOpts } = await import('../../utils/docker');
protected async prepareBuild(options: PrepareBuildOpts): Promise<{
docker: Dockerode;
buildOpts: BuildOpts;
composeOpts: ComposeOpts;
}> {
const { getDocker, generateBuildOpts } = await import(
'../../utils/docker.js'
);
const [docker, buildOpts, composeOpts] = await Promise.all([
getDocker(options),
generateBuildOpts(options),
@ -254,7 +261,7 @@ ${dockerignoreHelp}
*/
protected async buildProject(
docker: import('dockerode'),
logger: import('../../utils/logger'),
logger: import('../../utils/logger.js').default,
composeOpts: ComposeOpts,
opts: {
appType?: Pick<ApplicationType, 'supports_multicontainer'>;
@ -264,7 +271,7 @@ ${dockerignoreHelp}
buildOpts: BuildOpts;
},
) {
const { loadProject } = await import('../../utils/compose_ts');
const { loadProject } = await import('../../utils/compose_ts.js');
const project = await loadProject(
logger,

View File

@ -17,13 +17,13 @@
import { Flags, Command } from '@oclif/core';
import type { Interfaces } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getCliForm, stripIndent } from '../../utils/lazy';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, getCliForm, stripIndent } from '../../utils/lazy.js';
import {
applicationIdInfo,
devModeInfo,
secureBootInfo,
} from '../../utils/messages';
} from '../../utils/messages.js';
import type { BalenaSDK, PineDeferred } from 'balena-sdk';
export default class ConfigGenerateCmd extends Command {
@ -64,17 +64,14 @@ export default class ConfigGenerateCmd extends Command {
description: 'a balenaOS version',
required: true,
}),
fleet: { ...cf.fleet, exclusive: ['device'] },
fleet: cf.fleetExclusive(['device']),
dev: cf.dev,
secureBoot: cf.secureBoot,
device: {
...cf.device,
exclusive: [
'fleet',
'provisioning-key-name',
'provisioning-key-expiry-date',
],
},
device: cf.deviceExclusive([
'fleet',
'provisioning-key-name',
'provisioning-key-expiry-date',
]),
deviceApiKey: Flags.string({
description:
'custom device key - note that this is only supported on balenaOS 2.0.3+',
@ -122,7 +119,7 @@ export default class ConfigGenerateCmd extends Command {
public static authenticated = true;
public async getApplication(balena: BalenaSDK, fleet: string) {
const { getApplication } = await import('../../utils/sdk');
const { getApplication } = await import('../../utils/sdk.js');
return await getApplication(balena, fleet, {
$select: 'slug',
$expand: {
@ -148,7 +145,7 @@ export default class ConfigGenerateCmd extends Command {
$expand: { is_of__device_type: { $select: 'slug' } },
});
if (!rawDevice.belongs_to__application) {
const { ExpectedError } = await import('../../errors');
const { ExpectedError } = await import('../../errors.js');
throw new ExpectedError(stripIndent`
Device ${options.device} does not appear to belong to an accessible fleet.
Try with a different device, or use '--fleet' instead of '--device'.`);
@ -167,14 +164,14 @@ export default class ConfigGenerateCmd extends Command {
// Check compatibility if application and deviceType provided
if (options.fleet && options.deviceType) {
const helpers = await import('../../utils/helpers');
const helpers = await import('../../utils/helpers.js');
if (
!(await helpers.areDeviceTypesCompatible(
resourceDeviceType,
deviceType,
))
) {
const { ExpectedError } = await import('../../errors');
const { ExpectedError } = await import('../../errors.js');
throw new ExpectedError(
`Device type ${options.deviceType} is incompatible with fleet ${options.fleet}`,
);
@ -185,7 +182,7 @@ export default class ConfigGenerateCmd extends Command {
await balena.models.config.getDeviceTypeManifestBySlug(deviceType);
const { validateSecureBootOptionAndWarn } = await import(
'../../utils/config'
'../../utils/config.js'
);
await validateSecureBootOptionAndWarn(
options.secureBoot,
@ -207,7 +204,7 @@ export default class ConfigGenerateCmd extends Command {
// Generate config
const { generateDeviceConfig, generateApplicationConfig } = await import(
'../../utils/config'
'../../utils/config.js'
);
let config;
@ -246,7 +243,7 @@ export default class ConfigGenerateCmd extends Command {
protected async validateOptions(
options: Interfaces.InferredFlags<typeof ConfigGenerateCmd.flags>,
) {
const { ExpectedError } = await import('../../errors');
const { ExpectedError } = await import('../../errors.js');
if (options.device == null && options.fleet == null) {
throw new ExpectedError(this.missingDeviceOrAppMessage);
@ -255,9 +252,9 @@ export default class ConfigGenerateCmd extends Command {
if (!options.fleet && options.deviceType) {
throw new ExpectedError(this.deviceTypeNotAllowedMessage);
}
const { normalizeOsVersion } = await import('../../utils/normalization');
const { normalizeOsVersion } = await import('../../utils/normalization.js');
options.version = normalizeOsVersion(options.version);
const { validateDevOptionAndWarn } = await import('../../utils/config');
const { validateDevOptionAndWarn } = await import('../../utils/config.js');
await validateDevOptionAndWarn(options.dev, options.version);
}
}

View File

@ -16,8 +16,8 @@
*/
import { Args, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getVisuals, stripIndent } from '../../utils/lazy';
import * as cf from '../../utils/common-flags.js';
import { getVisuals, stripIndent } from '../../utils/lazy.js';
export default class ConfigInjectCmd extends Command {
public static description = stripIndent`
@ -52,7 +52,7 @@ export default class ConfigInjectCmd extends Command {
public async run() {
const { args: params, flags: options } = await this.parse(ConfigInjectCmd);
const { safeUmount } = await import('../../utils/umount');
const { safeUmount } = await import('../../utils/umount.js');
const drive =
options.drive || (await getVisuals().drive('Select the device/OS drive'));

View File

@ -16,8 +16,8 @@
*/
import { Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getVisuals, stripIndent } from '../../utils/lazy';
import * as cf from '../../utils/common-flags.js';
import { getVisuals, stripIndent } from '../../utils/lazy.js';
export default class ConfigReadCmd extends Command {
public static description = stripIndent`
@ -47,7 +47,7 @@ export default class ConfigReadCmd extends Command {
public async run() {
const { flags: options } = await this.parse(ConfigReadCmd);
const { safeUmount } = await import('../../utils/umount');
const { safeUmount } = await import('../../utils/umount.js');
const drive =
options.drive || (await getVisuals().drive('Select the device drive'));

View File

@ -16,8 +16,8 @@
*/
import { Flags, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getVisuals, stripIndent } from '../../utils/lazy';
import * as cf from '../../utils/common-flags.js';
import { getVisuals, stripIndent } from '../../utils/lazy.js';
export default class ConfigReconfigureCmd extends Command {
public static description = stripIndent`
@ -55,7 +55,7 @@ export default class ConfigReconfigureCmd extends Command {
public async run() {
const { flags: options } = await this.parse(ConfigReconfigureCmd);
const { safeUmount } = await import('../../utils/umount');
const { safeUmount } = await import('../../utils/umount.js');
const drive =
options.drive || (await getVisuals().drive('Select the device drive'));
@ -66,7 +66,7 @@ export default class ConfigReconfigureCmd extends Command {
await safeUmount(drive);
if (!uuid) {
const { ExpectedError } = await import('../../errors');
const { ExpectedError } = await import('../../errors.js');
throw new ExpectedError(
`Error: UUID not found in 'config.json' file for '${drive}'`,
);
@ -80,7 +80,7 @@ export default class ConfigReconfigureCmd extends Command {
configureCommand.push('--advanced');
}
const { runCommand } = await import('../../utils/helpers');
const { runCommand } = await import('../../utils/helpers.js');
await runCommand(configureCommand);
console.info('Done');

View File

@ -16,8 +16,8 @@
*/
import { Args, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getVisuals, stripIndent } from '../../utils/lazy';
import * as cf from '../../utils/common-flags.js';
import { getVisuals, stripIndent } from '../../utils/lazy.js';
export default class ConfigWriteCmd extends Command {
public static description = stripIndent`
@ -57,7 +57,7 @@ export default class ConfigWriteCmd extends Command {
public async run() {
const { args: params, flags: options } = await this.parse(ConfigWriteCmd);
const { denyMount, safeUmount } = await import('../../utils/umount');
const { denyMount, safeUmount } = await import('../../utils/umount.js');
const drive =
options.drive || (await getVisuals().drive('Select the device drive'));

View File

@ -17,30 +17,29 @@
import { Args, Flags, Command } from '@oclif/core';
import type { ImageDescriptor } from '@balena/compose/dist/parse';
import { ExpectedError } from '../../errors';
import { getBalenaSdk, getChalk, stripIndent } from '../../utils/lazy';
import { ExpectedError } from '../../errors.js';
import { getBalenaSdk, getChalk, stripIndent } from '../../utils/lazy.js';
import {
dockerignoreHelp,
registrySecretsHelp,
buildArgDeprecation,
} from '../../utils/messages';
import * as ca from '../../utils/common-args';
import * as compose from '../../utils/compose';
} from '../../utils/messages.js';
import * as ca from '../../utils/common-args.js';
import * as compose from '../../utils/compose.js';
import type {
BuiltImage,
ComposeCliFlags,
ComposeOpts,
Release as ComposeReleaseInfo,
} from '../../utils/compose-types';
import type { BuildOpts, DockerCliFlags } from '../../utils/docker';
} from '../../utils/compose-types.js';
import type { BuildOpts, DockerCliFlags } from '../../utils/docker.js';
import {
applyReleaseTagKeysAndValues,
buildProject,
composeCliFlags,
isBuildConfig,
parseReleaseTagKeysAndValues,
} from '../../utils/compose_ts';
import { dockerCliFlags } from '../../utils/docker';
} from '../../utils/compose_ts.js';
import { dockerCliFlags } from '../../utils/docker.js';
import type { ApplicationType, DeviceType, Release } from 'balena-sdk';
interface ApplicationWithArch {
@ -149,7 +148,7 @@ ${dockerignoreHelp}
(await import('events')).defaultMaxListeners = 1000;
const Logger = await import('../../utils/logger');
const { default: Logger } = await import('../../utils/logger.js');
const logger = Logger.getLogger();
logger.logDebug('Parsing input...');
@ -169,7 +168,7 @@ ${dockerignoreHelp}
const sdk = getBalenaSdk();
const { getRegistrySecrets, validateProjectDirectory } = await import(
'../../utils/compose_ts'
'../../utils/compose_ts.js'
);
const { releaseTagKeys, releaseTagValues } = parseReleaseTagKeysAndValues(
@ -193,10 +192,10 @@ ${dockerignoreHelp}
(options as FlagsDef)['registry-secrets'] = registrySecrets;
}
const helpers = await import('../../utils/helpers');
const helpers = await import('../../utils/helpers.js');
const app = await helpers.getAppWithArch(fleet);
const dockerUtils = await import('../../utils/docker');
const dockerUtils = await import('../../utils/docker.js');
const [docker, buildOpts, composeOpts] = await Promise.all([
dockerUtils.getDocker(options),
dockerUtils.generateBuildOpts(options as FlagsDef),
@ -226,7 +225,7 @@ ${dockerignoreHelp}
async deployProject(
docker: import('dockerode'),
logger: import('../../utils/logger'),
logger: import('../../utils/logger.js').default,
composeOpts: ComposeOpts,
opts: {
app: ApplicationWithArch; // the application instance to deploy to
@ -244,7 +243,7 @@ ${dockerignoreHelp}
const doodles = await import('resin-doodles');
const sdk = getBalenaSdk();
const { deployProject: $deployProject, loadProject } = await import(
'../../utils/compose_ts'
'../../utils/compose_ts.js'
);
const appType = opts.app.application_type[0];
@ -315,7 +314,7 @@ ${dockerignoreHelp}
builtImagesByService = _.keyBy(builtImages, 'serviceName');
}
const images: BuiltImage[] = project.descriptors.map(
(d) =>
(d: ImageDescriptor) =>
builtImagesByService[d.serviceName] ?? {
serviceName: d.serviceName,
name: (isBuildConfig(d.image) ? d.image.tag : d.image) || '',
@ -324,9 +323,9 @@ ${dockerignoreHelp}
},
);
let release: Release | ComposeReleaseInfo['release'];
let release: Release | Awaited<ReturnType<typeof $deployProject>>;
if (appType.slug === 'legacy-v1' || appType.slug === 'legacy-v2') {
const { deployLegacy } = require('../../utils/deploy-legacy');
const { deployLegacy } = await import('../../utils/deploy-legacy.js');
const msg = getChalk().yellow(
'Target fleet requires legacy deploy method.',

View File

@ -16,8 +16,8 @@
*/
import { Flags, Command } from '@oclif/core';
import type * as BalenaSdk from 'balena-sdk';
import * as _ from 'lodash';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import _ from 'lodash';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy.js';
export default class DeviceTypeListCmd extends Command {
public static aliases = ['devices supported'];

View File

@ -16,8 +16,8 @@
*/
import { Args, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class DeviceDeactivateCmd extends Command {
public static description = stripIndent`
@ -51,7 +51,7 @@ export default class DeviceDeactivateCmd extends Command {
await this.parse(DeviceDeactivateCmd);
const balena = getBalenaSdk();
const patterns = await import('../../utils/patterns');
const patterns = await import('../../utils/patterns.js');
const uuid = params.uuid;
const deactivationWarning = `

View File

@ -16,7 +16,7 @@
*/
import { Flags, Command } from '@oclif/core';
import { getCliUx, stripIndent } from '../../utils/lazy';
import { getCliUx, stripIndent } from '../../utils/lazy.js';
export default class DeviceDetectCmd extends Command {
public static aliases = ['scan'];
@ -63,10 +63,10 @@ export default class DeviceDetectCmd extends Command {
public async run() {
const _ = await import('lodash');
const { discoverLocalBalenaOsDevices } = await import(
'../../utils/discover'
'../../utils/discover.js'
);
const prettyjson = await import('prettyjson');
const dockerUtils = await import('../../utils/docker');
const dockerUtils = await import('../../utils/docker.js');
const dockerPort = 2375;
const dockerTimeout = 2000;

View File

@ -16,8 +16,8 @@
*/
import { Args, Command } from '@oclif/core';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { ExpectedError } from '../../errors';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { ExpectedError } from '../../errors.js';
export default class DeviceIdentifyCmd extends Command {
public static description = stripIndent`

View File

@ -16,10 +16,10 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { expandForAppName } from '../../utils/helpers';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { jsonInfo } from '../../utils/messages';
import * as cf from '../../utils/common-flags.js';
import { expandForAppName } from '../../utils/helpers.js';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy.js';
import { jsonInfo } from '../../utils/messages.js';
import type { Application, Release } from 'balena-sdk';
@ -81,44 +81,44 @@ export default class DeviceCmd extends Command {
params.uuid,
options.json
? {
$expand: {
device_tag: {
$select: ['tag_key', 'value'],
},
...expandForAppName.$expand,
$expand: {
device_tag: {
$select: ['tag_key', 'value'],
},
}
: {
$select: [
'device_name',
'id',
'overall_status',
'is_online',
'ip_address',
'mac_address',
'last_connectivity_event',
'uuid',
'supervisor_version',
'is_web_accessible',
'note',
'os_version',
'memory_usage',
'memory_total',
'public_address',
'storage_block_device',
'storage_usage',
'storage_total',
'cpu_usage',
'cpu_temp',
'cpu_id',
'is_undervolted',
],
...expandForAppName,
...expandForAppName.$expand,
},
}
: {
$select: [
'device_name',
'id',
'overall_status',
'is_online',
'ip_address',
'mac_address',
'last_connectivity_event',
'uuid',
'supervisor_version',
'is_web_accessible',
'note',
'os_version',
'memory_usage',
'memory_total',
'public_address',
'storage_block_device',
'storage_usage',
'storage_total',
'cpu_usage',
'cpu_temp',
'cpu_id',
'is_undervolted',
],
...expandForAppName,
},
)) as ExtendedDevice;
if (options.view) {
const open = await import('open');
const { default: open } = await import('open');
const dashboardUrl = balena.models.device.getDashboardUrl(device.uuid);
await open(dashboardUrl, { wait: false });
return;

View File

@ -16,10 +16,10 @@
*/
import { Flags, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import { runCommand } from '../../utils/helpers';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
import { runCommand } from '../../utils/helpers.js';
interface FlagsDef {
fleet?: string;
@ -108,13 +108,13 @@ export default class DeviceInitCmd extends Command {
// Imports
const { promisify } = await import('util');
const rimraf = promisify(await import('rimraf'));
const rimraf = promisify((await import('rimraf')).default);
const tmp = await import('tmp');
const tmpNameAsync = promisify(tmp.tmpName);
tmp.setGracefulCleanup();
const { downloadOSImage } = await import('../../utils/cloud');
const { getApplication } = await import('../../utils/sdk');
const Logger = await import('../../utils/logger');
const { downloadOSImage } = await import('../../utils/cloud.js');
const { getApplication } = await import('../../utils/sdk.js');
const { default: Logger } = await import('../../utils/logger.js');
const logger = Logger.getLogger();
const balena = getBalenaSdk();
@ -122,14 +122,14 @@ export default class DeviceInitCmd extends Command {
// Get application and
const application = options.fleet
? await getApplication(balena, options.fleet, {
$select: ['id', 'slug'],
$expand: {
is_for__device_type: {
$select: 'slug',
},
$select: ['id', 'slug'],
$expand: {
is_for__device_type: {
$select: 'slug',
},
})
: await (await import('../../utils/patterns')).selectApplication();
},
})
: await (await import('../../utils/patterns.js')).selectApplication();
// Register new device
const deviceUuid = balena.models.device.generateUniqueKey();

View File

@ -16,10 +16,10 @@
*/
import { Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { expandForAppName } from '../../utils/helpers';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { applicationIdInfo, jsonInfo } from '../../utils/messages';
import * as cf from '../../utils/common-flags.js';
import { expandForAppName } from '../../utils/helpers.js';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo, jsonInfo } from '../../utils/messages.js';
import type { Device, PineOptions } from 'balena-sdk';
@ -78,7 +78,7 @@ export default class DeviceListCmd extends Command {
const devices = (
await (async () => {
if (options.fleet != null) {
const { getApplication } = await import('../../utils/sdk');
const { getApplication } = await import('../../utils/sdk.js');
const application = await getApplication(balena, options.fleet, {
$select: 'slug',
$expand: {
@ -115,7 +115,7 @@ export default class DeviceListCmd extends Command {
];
if (options.json) {
const { pickAndRename } = await import('../../utils/helpers');
const { pickAndRename } = await import('../../utils/helpers.js');
const mapped = devices.map((device) => pickAndRename(device, fields));
console.log(JSON.stringify(mapped, null, 4));
} else {

View File

@ -16,7 +16,7 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class DeviceLocalModeCmd extends Command {
public static description = stripIndent`

View File

@ -16,7 +16,7 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import type { LogMessage } from 'balena-sdk';
const MAX_RETRY = 1000;
@ -94,14 +94,14 @@ export default class DeviceLogsCmd extends Command {
const { args: params, flags: options } = await this.parse(DeviceLogsCmd);
const balena = getBalenaSdk();
const { serviceIdToName } = await import('../../utils/cloud');
const { serviceIdToName } = await import('../../utils/cloud.js');
const { connectAndDisplayDeviceLogs, displayLogObject } = await import(
'../../utils/device/logs'
'../../utils/device/logs.js'
);
const { validateIPAddress, validateDotLocalUrl } = await import(
'../../utils/validation'
'../../utils/validation.js'
);
const Logger = await import('../../utils/logger');
const { default: Logger } = await import('../../utils/logger.js');
const logger = Logger.getLogger();
@ -130,13 +130,13 @@ export default class DeviceLogsCmd extends Command {
validateDotLocalUrl(params.device)
) {
// Logs from local device
const { DeviceAPI } = await import('../../utils/device/api');
const { DeviceAPI } = await import('../../utils/device/api.js');
const deviceApi = new DeviceAPI(logger, params.device);
logger.logDebug('Checking we can access device');
try {
await deviceApi.ping();
} catch {
const { ExpectedError } = await import('../../errors');
const { ExpectedError } = await import('../../errors.js');
throw new ExpectedError(
`Cannot access device at address ${params.device}. Device may not be in local mode.`,
);
@ -151,7 +151,7 @@ export default class DeviceLogsCmd extends Command {
maxAttempts: 1 + (options['max-retry'] ?? MAX_RETRY),
});
} else {
const { checkLoggedIn } = await import('../../utils/patterns');
const { checkLoggedIn } = await import('../../utils/patterns.js');
// Logs from cloud
await checkLoggedIn();
if (options.tail) {

View File

@ -22,10 +22,10 @@ import type {
PineOptions,
PineTypedResult,
} from 'balena-sdk';
import * as cf from '../../utils/common-flags';
import { ExpectedError } from '../../errors';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import * as cf from '../../utils/common-flags.js';
import { ExpectedError } from '../../errors.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
export default class DeviceMoveCmd extends Command {
public static description = stripIndent`
@ -97,7 +97,7 @@ export default class DeviceMoveCmd extends Command {
const devices = await this.getDevices(balena, deviceUuids);
// Disambiguate application
const { getApplication } = await import('../../utils/sdk');
const { getApplication } = await import('../../utils/sdk.js');
// Get destination application
const application = options.fleet
@ -147,7 +147,7 @@ export default class DeviceMoveCmd extends Command {
})
.map((deviceType) => deviceType.id);
const patterns = await import('../../utils/patterns');
const patterns = await import('../../utils/patterns.js');
try {
const application = await patterns.selectApplication(
{

View File

@ -16,9 +16,9 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { ExpectedError } from '../../errors.js';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class DeviceNoteCmd extends Command {
public static aliases = ['notes'];
@ -45,7 +45,7 @@ export default class DeviceNoteCmd extends Command {
};
public static flags = {
device: { exclusive: ['dev'], ...cf.device },
device: cf.deviceExclusive(['dev']),
dev: Flags.string({
exclusive: ['device'],
hidden: true,

View File

@ -16,11 +16,11 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent, getCliForm } from '../../utils/lazy';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, stripIndent, getCliForm } from '../../utils/lazy.js';
import type { Device } from 'balena-sdk';
import { ExpectedError } from '../../errors';
import { getExpandedProp } from '../../utils/pine';
import { ExpectedError } from '../../errors.js';
import { getExpandedProp } from '../../utils/pine.js';
export default class DeviceOsUpdateCmd extends Command {
public static description = stripIndent`
@ -119,7 +119,7 @@ export default class DeviceOsUpdateCmd extends Command {
// Get target OS version
let targetOsVersion = options.version;
if (targetOsVersion != null) {
const { normalizeOsVersion } = await import('../../utils/normalization');
const { normalizeOsVersion } = await import('../../utils/normalization.js');
targetOsVersion = normalizeOsVersion(targetOsVersion);
if (!hupVersionInfo.versions.includes(targetOsVersion)) {
throw new ExpectedError(
@ -155,7 +155,7 @@ export default class DeviceOsUpdateCmd extends Command {
currentOsVersion,
targetOsVersion,
)) === 'takeover';
const patterns = await import('../../utils/patterns');
const patterns = await import('../../utils/patterns.js');
// Warn the user if the update requires a takeover
if (takeoverRequired) {
await patterns.confirm(

View File

@ -16,8 +16,8 @@
*/
import { Args, Command } from '@oclif/core';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { getExpandedProp } from '../../utils/pine';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { getExpandedProp } from '../../utils/pine.js';
export default class DevicePinCmd extends Command {
public static description = stripIndent`

View File

@ -16,8 +16,8 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import { ExpectedError } from '../../errors';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { ExpectedError } from '../../errors.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class DevicePublicUrlCmd extends Command {
public static description = stripIndent`

View File

@ -16,7 +16,7 @@
*/
import { Args, Command } from '@oclif/core';
import { getBalenaSdk, getCliUx, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, getCliUx, stripIndent } from '../../utils/lazy.js';
export default class DevicePurgeCmd extends Command {
public static description = stripIndent`

View File

@ -16,8 +16,8 @@
*/
import { Args, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class DeviceRebootCmd extends Command {
public static description = stripIndent`

View File

@ -16,9 +16,9 @@
*/
import { Flags, Command } from '@oclif/core';
import * as ca from '../../utils/common-args';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import * as ca from '../../utils/common-args.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
export default class DeviceRegisterCmd extends Command {
public static description = stripIndent`
@ -59,7 +59,7 @@ export default class DeviceRegisterCmd extends Command {
const { args: params, flags: options } =
await this.parse(DeviceRegisterCmd);
const { getApplication } = await import('../../utils/sdk');
const { getApplication } = await import('../../utils/sdk.js');
const balena = getBalenaSdk();

View File

@ -16,7 +16,7 @@
*/
import { Args, Command } from '@oclif/core';
import { getBalenaSdk, stripIndent, getCliForm } from '../../utils/lazy';
import { getBalenaSdk, stripIndent, getCliForm } from '../../utils/lazy.js';
export default class DeviceRenameCmd extends Command {
public static description = stripIndent`

View File

@ -16,7 +16,7 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import { getBalenaSdk, getCliUx, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, getCliUx, stripIndent } from '../../utils/lazy.js';
import type {
BalenaSDK,
DeviceWithServiceDetails,
@ -89,8 +89,8 @@ export default class DeviceRestartCmd extends Command {
deviceUuid: string,
serviceNames: string[],
) {
const { ExpectedError, instanceOf } = await import('../../errors');
const { getExpandedProp } = await import('../../utils/pine');
const { ExpectedError, instanceOf } = await import('../../errors.js');
const { getExpandedProp } = await import('../../utils/pine.js');
// Get device
let device: DeviceWithServiceDetails<CurrentServiceWithCommit>;
@ -156,7 +156,7 @@ export default class DeviceRestartCmd extends Command {
// Note: device.restartApplication throws `BalenaDeviceNotFound: Device not found` if device not online.
// Need to use device.get first to distinguish between non-existant and disconnected devices.
// Remove this workaround when SDK issue resolved: https://github.com/balena-io/balena-sdk/issues/649
const { instanceOf, ExpectedError } = await import('../../errors');
const { instanceOf, ExpectedError } = await import('../../errors.js');
try {
const device = await balena.models.device.get(deviceUuid);
if (!device.is_online) {

View File

@ -16,8 +16,8 @@
*/
import { Args, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class DeviceRmCmd extends Command {
public static description = stripIndent`
@ -52,7 +52,7 @@ export default class DeviceRmCmd extends Command {
const { args: params, flags: options } = await this.parse(DeviceRmCmd);
const balena = getBalenaSdk();
const patterns = await import('../../utils/patterns');
const patterns = await import('../../utils/patterns.js');
// Confirm
const uuids = params.uuid.split(',');

View File

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

View File

@ -16,11 +16,11 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import {
parseAsInteger,
validateLocalHostnameOrIp,
} from '../../utils/validation';
} from '../../utils/validation.js';
export default class DeviceSSHCmd extends Command {
public static aliases = ['ssh'];
@ -109,7 +109,7 @@ export default class DeviceSSHCmd extends Command {
// Local connection
if (validateLocalHostnameOrIp(params.fleetOrDevice)) {
const { performLocalDeviceSSH } = await import('../../utils/device/ssh');
const { performLocalDeviceSSH } = await import('../../utils/device/ssh.js');
await performLocalDeviceSSH({
hostname: params.fleetOrDevice,
port: options.port || 'local',
@ -121,12 +121,12 @@ export default class DeviceSSHCmd extends Command {
}
// Remote connection
const { getProxyConfig } = await import('../../utils/helpers');
const { getProxyConfig } = await import('../../utils/helpers.js');
const {
getOnlineTargetDeviceUuid,
checkLoggedIn,
checkNotUsingOfflineMode,
} = await import('../../utils/patterns');
} = await import('../../utils/patterns.js');
const sdk = getBalenaSdk();
const proxyConfig = getProxyConfig();
@ -140,7 +140,7 @@ export default class DeviceSSHCmd extends Command {
params.fleetOrDevice,
);
const { which } = await import('../../utils/which');
const { which } = await import('../../utils/which.js');
const [whichProxytunnel, { username }, proxyUrl] = await Promise.all([
useProxy ? which('proxytunnel', false) : undefined,
@ -192,7 +192,7 @@ export default class DeviceSSHCmd extends Command {
let containerId: string | undefined;
if (params.service != null) {
const { getContainerIdForService } = await import(
'../../utils/device/ssh'
'../../utils/device/ssh.js'
);
containerId = await getContainerIdForService({
deviceUuid,
@ -210,7 +210,7 @@ export default class DeviceSSHCmd extends Command {
} else {
accessCommand = `host ${deviceUuid}`;
}
const { runRemoteCommand } = await import('../../utils/ssh');
const { runRemoteCommand } = await import('../../utils/ssh.js');
await runRemoteCommand({
cmd: accessCommand,
hostname: `ssh.${proxyUrl}`,

View File

@ -16,7 +16,7 @@
*/
import { Args, Command } from '@oclif/core';
import { getBalenaSdk, getCliUx, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, getCliUx, stripIndent } from '../../utils/lazy.js';
import type { BalenaSDK } from 'balena-sdk';
export default class DeviceStartServiceCmd extends Command {
@ -70,8 +70,8 @@ export default class DeviceStartServiceCmd extends Command {
deviceUuid: string,
serviceNames: string[],
) {
const { ExpectedError } = await import('../../errors');
const { getExpandedProp } = await import('../../utils/pine');
const { ExpectedError } = await import('../../errors.js');
const { getExpandedProp } = await import('../../utils/pine.js');
// Get device
const device = await balena.models.device.getWithServiceDetails(

View File

@ -16,7 +16,7 @@
*/
import { Args, Command } from '@oclif/core';
import { getBalenaSdk, getCliUx, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, getCliUx, stripIndent } from '../../utils/lazy.js';
import type { BalenaSDK } from 'balena-sdk';
export default class DeviceStopServiceCmd extends Command {
@ -70,8 +70,8 @@ export default class DeviceStopServiceCmd extends Command {
deviceUuid: string,
serviceNames: string[],
) {
const { ExpectedError } = await import('../../errors');
const { getExpandedProp } = await import('../../utils/pine');
const { ExpectedError } = await import('../../errors.js');
const { getExpandedProp } = await import('../../utils/pine.js');
// Get device
const device = await balena.models.device.getWithServiceDetails(

View File

@ -16,7 +16,7 @@
*/
import { Args, Command } from '@oclif/core';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class DeviceTrackFleetCmd extends Command {
public static description = stripIndent`

View File

@ -20,9 +20,9 @@ import {
NoPortsDefinedError,
InvalidPortMappingError,
ExpectedError,
} from '../../errors';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { lowercaseIfSlug } from '../../utils/normalization';
} from '../../errors.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { lowercaseIfSlug } from '../../utils/normalization.js';
import type { Server, Socket } from 'net';
@ -94,7 +94,7 @@ export default class DeviceTunnelCmd extends Command {
public async run() {
const { args: params, flags: options } = await this.parse(DeviceTunnelCmd);
const Logger = await import('../../utils/logger');
const { default: Logger } = await import('../../utils/logger.js');
const logger = Logger.getLogger();
const sdk = getBalenaSdk();
@ -122,7 +122,7 @@ export default class DeviceTunnelCmd extends Command {
}
// Ascertain device uuid
const { getOnlineTargetDeviceUuid } = await import('../../utils/patterns');
const { getOnlineTargetDeviceUuid } = await import('../../utils/patterns.js');
const uuid = await getOnlineTargetDeviceUuid(sdk, params.deviceOrFleet);
logger.logInfo(`Opening a tunnel to ${uuid}...`);
@ -134,7 +134,7 @@ export default class DeviceTunnelCmd extends Command {
.map(async ({ localPort, localAddress, remotePort }) => {
try {
const { tunnelConnectionToDevice } = await import(
'../../utils/tunnel'
'../../utils/tunnel.js'
);
const handler = await tunnelConnectionToDevice(uuid, remotePort, sdk);

View File

@ -17,11 +17,11 @@
import { Flags, Command } from '@oclif/core';
import type { Interfaces } from '@oclif/core';
import type * as SDK from 'balena-sdk';
import * as _ from 'lodash';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import _ from 'lodash';
import { ExpectedError } from '../../errors.js';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
type FlagsDef = Interfaces.InferredFlags<typeof EnvListCmd.flags>;
@ -97,16 +97,16 @@ export default class EnvListCmd extends Command {
];
public static flags = {
fleet: { ...cf.fleet, exclusive: ['device'] },
fleet: cf.fleetExclusive(['device']),
config: Flags.boolean({
default: false,
char: 'c',
description: 'show configuration variables only',
exclusive: ['service'],
}),
device: { ...cf.device, exclusive: ['fleet'] },
device: cf.deviceExclusive(['fleet']),
json: cf.json,
service: { ...cf.service, exclusive: ['config'] },
service: cf.serviceExclusive(['config']),
};
public async run() {
@ -114,7 +114,7 @@ export default class EnvListCmd extends Command {
const variables: EnvironmentVariableInfo[] = [];
const { checkLoggedIn } = await import('../../utils/patterns');
const { checkLoggedIn } = await import('../../utils/patterns.js');
await checkLoggedIn();
@ -126,14 +126,14 @@ export default class EnvListCmd extends Command {
let fleetSlug: string | undefined = options.fleet
? await (
await import('../../utils/sdk')
).getFleetSlug(balena, options.fleet)
await import('../../utils/sdk.js')
).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'
'../../utils/cloud.js'
);
const [device, app] = await getDeviceAndMaybeAppFromUUID(
balena,
@ -187,7 +187,7 @@ export default class EnvListCmd extends Command {
}
if (options.json) {
const { pickAndRename } = await import('../../utils/helpers');
const { pickAndRename } = await import('../../utils/helpers.js');
const mapped = varArray.map((o) => pickAndRename(o, fields));
this.log(JSON.stringify(mapped, null, 4));
} else {

View File

@ -15,9 +15,9 @@
* limitations under the License.
*/
import { Args, Command } from '@oclif/core';
import * as ec from '../../utils/env-common';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { parseAsInteger } from '../../utils/validation';
import * as ec from '../../utils/env-common.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { parseAsInteger } from '../../utils/validation.js';
export default class EnvRenameCmd extends Command {
public static description = stripIndent`
@ -59,7 +59,7 @@ export default class EnvRenameCmd extends Command {
public async run() {
const { args: params, flags: opt } = await this.parse(EnvRenameCmd);
const { checkLoggedIn } = await import('../../utils/patterns');
const { checkLoggedIn } = await import('../../utils/patterns.js');
await checkLoggedIn();

View File

@ -16,9 +16,9 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import * as ec from '../../utils/env-common';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { parseAsInteger } from '../../utils/validation';
import * as ec from '../../utils/env-common.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { parseAsInteger } from '../../utils/validation.js';
export default class EnvRmCmd extends Command {
public static description = stripIndent`
@ -65,11 +65,11 @@ export default class EnvRmCmd extends Command {
public async run() {
const { args: params, flags: opt } = await this.parse(EnvRmCmd);
const { checkLoggedIn } = await import('../../utils/patterns');
const { checkLoggedIn } = await import('../../utils/patterns.js');
await checkLoggedIn();
const { confirm } = await import('../../utils/patterns');
const { confirm } = await import('../../utils/patterns.js');
await confirm(
opt.yes || false,
'Are you sure you want to delete the environment variable?',

View File

@ -17,10 +17,10 @@
import { Args, Command } from '@oclif/core';
import type * as BalenaSdk from 'balena-sdk';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import { ExpectedError } from '../../errors.js';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
interface FlagsDef {
fleet?: string;
@ -95,8 +95,8 @@ export default class EnvSetCmd extends Command {
public static strict = false;
public static flags = {
fleet: { ...cf.fleet, exclusive: ['device'] },
device: { ...cf.device, exclusive: ['fleet'] },
fleet: cf.fleetExclusive(['device']),
device: cf.deviceExclusive(['fleet']),
quiet: cf.quiet,
service: cf.service,
};
@ -111,7 +111,7 @@ export default class EnvSetCmd extends Command {
);
}
const { checkLoggedIn } = await import('../../utils/patterns');
const { checkLoggedIn } = await import('../../utils/patterns.js');
await checkLoggedIn();
@ -139,8 +139,8 @@ export default class EnvSetCmd extends Command {
if (isConfigVar) {
throw new ExpectedError(stripIndent`
Configuration variables prefixed with "${reservedPrefixes.join(
'" or "',
)}" cannot be set per service.
'" or "',
)}" cannot be set per service.
Hint: remove the --service option or rename the variable.
`);
}
@ -186,7 +186,7 @@ async function resolveFleetSlugs(
fleetOption: string,
) {
const fleetSlugs: string[] = [];
const { getFleetSlug } = await import('../../utils/sdk');
const { getFleetSlug } = await import('../../utils/sdk.js');
for (const appNameOrSlug of fleetOption.split(',')) {
try {
fleetSlugs.push(await getFleetSlug(balena, appNameOrSlug));
@ -223,7 +223,7 @@ async function setServiceVars(
}
}
} else if (options.device) {
const { getDeviceAndAppFromUUID } = await import('../../utils/cloud');
const { getDeviceAndAppFromUUID } = await import('../../utils/cloud.js');
for (const uuid of options.device.split(',')) {
let device;
let app;

View File

@ -16,7 +16,7 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import { stripIndent } from '../../utils/lazy';
import { stripIndent } from '../../utils/lazy.js';
export default class FleetCreateCmd extends Command {
public static description = stripIndent`
@ -71,7 +71,7 @@ export default class FleetCreateCmd extends Command {
const { args: params, flags: options } = await this.parse(FleetCreateCmd);
await (
await import('../../utils/application-create')
await import('../../utils/application-create.js')
).applicationCreateBase('fleet', options, params);
}
}

View File

@ -16,10 +16,10 @@
*/
import { Flags, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import * as ca from '../../utils/common-args';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import * as cf from '../../utils/common-flags.js';
import * as ca from '../../utils/common-args.js';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
export default class FleetCmd extends Command {
public static description = stripIndent`
@ -53,7 +53,7 @@ export default class FleetCmd extends Command {
public async run() {
const { args: params, flags: options } = await this.parse(FleetCmd);
const { getApplication } = await import('../../utils/sdk');
const { getApplication } = await import('../../utils/sdk.js');
const balena = getBalenaSdk();
@ -65,7 +65,7 @@ export default class FleetCmd extends Command {
});
if (options.view) {
const open = await import('open');
const { default: open } = await import('open');
const dashboardUrl = balena.models.application.getDashboardUrl(
application.id,
);

View File

@ -16,8 +16,8 @@
*/
import type * as BalenaSdk from 'balena-sdk';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy.js';
import { Command } from '@oclif/core';
interface ExtendedApplication extends ApplicationWithDeviceTypeSlug {

View File

@ -16,8 +16,8 @@
*/
import { Args, Command } from '@oclif/core';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { getExpandedProp } from '../../utils/pine';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { getExpandedProp } from '../../utils/pine.js';
export default class FleetPinCmd extends Command {
public static description = stripIndent`

View File

@ -16,9 +16,9 @@
*/
import { Command } from '@oclif/core';
import * as ca from '../../utils/common-args';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import * as ca from '../../utils/common-args.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
export default class FleetPurgeCmd extends Command {
public static description = stripIndent`
@ -44,7 +44,7 @@ export default class FleetPurgeCmd extends Command {
public async run() {
const { args: params } = await this.parse(FleetPurgeCmd);
const { getApplication } = await import('../../utils/sdk');
const { getApplication } = await import('../../utils/sdk.js');
const balena = getBalenaSdk();

View File

@ -16,9 +16,9 @@
*/
import { Args, Command } from '@oclif/core';
import * as ca from '../../utils/common-args';
import { getBalenaSdk, stripIndent, getCliForm } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import * as ca from '../../utils/common-args.js';
import { getBalenaSdk, stripIndent, getCliForm } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
export default class FleetRenameCmd extends Command {
public static description = stripIndent`
@ -50,13 +50,13 @@ export default class FleetRenameCmd extends Command {
public async run() {
const { args: params } = await this.parse(FleetRenameCmd);
const { validateApplicationName } = await import('../../utils/validation');
const { ExpectedError } = await import('../../errors');
const { validateApplicationName } = await import('../../utils/validation.js');
const { ExpectedError } = await import('../../errors.js');
const balena = getBalenaSdk();
// Disambiguate target application (if params.params is a number, it could either be an ID or a numerical name)
const { getApplication } = await import('../../utils/sdk');
const { getApplication } = await import('../../utils/sdk.js');
const application = await getApplication(balena, params.fleet, {
$select: ['id', 'app_name', 'slug'],
$expand: {

View File

@ -16,9 +16,9 @@
*/
import { Command } from '@oclif/core';
import * as ca from '../../utils/common-args';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import * as ca from '../../utils/common-args.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
export default class FleetRestartCmd extends Command {
public static description = stripIndent`
@ -43,7 +43,7 @@ export default class FleetRestartCmd extends Command {
public async run() {
const { args: params } = await this.parse(FleetRestartCmd);
const { getApplication } = await import('../../utils/sdk');
const { getApplication } = await import('../../utils/sdk.js');
const balena = getBalenaSdk();

View File

@ -15,10 +15,10 @@
* limitations under the License.
*/
import * as cf from '../../utils/common-flags';
import * as ca from '../../utils/common-args';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import * as cf from '../../utils/common-flags.js';
import * as ca from '../../utils/common-args.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
import { Command } from '@oclif/core';
export default class FleetRmCmd extends Command {
@ -51,8 +51,8 @@ export default class FleetRmCmd extends Command {
public async run() {
const { args: params, flags: options } = await this.parse(FleetRmCmd);
const { confirm } = await import('../../utils/patterns');
const { getApplication } = await import('../../utils/sdk');
const { confirm } = await import('../../utils/patterns.js');
const { getApplication } = await import('../../utils/sdk.js');
const balena = getBalenaSdk();
// Confirm

View File

@ -16,7 +16,7 @@
*/
import { Args, Command } from '@oclif/core';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class FleetTrackLatestCmd extends Command {
public static description = stripIndent`

View File

@ -16,7 +16,7 @@
*/
import { Args, Command } from '@oclif/core';
import { stripIndent } from '../../utils/lazy';
import { stripIndent } from '../../utils/lazy.js';
// 'Internal' commands are called during the execution of other commands.
// `osinit` is called during `os initialize`
@ -56,7 +56,7 @@ export default class OsinitCmd extends Command {
const config = JSON.parse(params.config);
const { getManifest, osProgressHandler } = await import(
'../../utils/helpers'
'../../utils/helpers.js'
);
const manifest = await getManifest(params.image, params.type);

View File

@ -16,10 +16,10 @@
*/
import { Args, Flags, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import { parseAsLocalHostnameOrIp } from '../../utils/validation';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
import { parseAsLocalHostnameOrIp } from '../../utils/validation.js';
export default class JoinCmd extends Command {
public static description = stripIndent`
@ -73,9 +73,9 @@ 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.js');
const sdk = getBalenaSdk();
const Logger = await import('../../utils/logger');
const { default: Logger } = await import('../../utils/logger.js');
const logger = Logger.getLogger();
return promote.join(
logger,

View File

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

View File

@ -17,7 +17,7 @@
import { Args, Command } from '@oclif/core';
import { promisify } from 'util';
import { stripIndent } from '../../utils/lazy';
import { stripIndent } from '../../utils/lazy.js';
export default class LocalConfigureCmd extends Command {
public static description = stripIndent`
@ -45,8 +45,8 @@ export default class LocalConfigureCmd extends Command {
const { args: params } = await this.parse(LocalConfigureCmd);
const reconfix = await import('reconfix');
const { denyMount, safeUmount } = await import('../../utils/umount');
const Logger = await import('../../utils/logger');
const { denyMount, safeUmount } = await import('../../utils/umount.js');
const { default: Logger } = await import('../../utils/logger.js');
const logger = Logger.getLogger();

View File

@ -17,9 +17,9 @@
import { Args, Command } from '@oclif/core';
import type { BlockDevice } from 'etcher-sdk/build/source-destination';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getChalk, getVisuals, stripIndent } from '../../utils/lazy';
import { ExpectedError } from '../../errors.js';
import * as cf from '../../utils/common-flags.js';
import { getChalk, getVisuals, stripIndent } from '../../utils/lazy.js';
export default class LocalFlashCmd extends Command {
public static description = stripIndent`
@ -75,7 +75,7 @@ export default class LocalFlashCmd extends Command {
const drive = await this.getDrive(options);
const { confirm } = await import('../../utils/patterns');
const { confirm } = await import('../../utils/patterns.js');
await confirm(
options.yes,
'This will erase the selected drive. Are you sure?',

View File

@ -16,8 +16,8 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import { getBalenaSdk, stripIndent, getCliForm } from '../../utils/lazy';
import { ExpectedError } from '../../errors';
import { getBalenaSdk, stripIndent, getCliForm } from '../../utils/lazy.js';
import { ExpectedError } from '../../errors.js';
import type { WhoamiResult } from 'balena-sdk';
interface FlagsDef {
@ -117,7 +117,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.js');
const balenaUrl = await balena.settings.get('balenaUrl');
// Consolidate user/email options
@ -196,20 +196,20 @@ ${messages.reachingOut}`);
}
// Credentials
else if (loginOptions.credentials) {
const patterns = await import('../../utils/patterns');
const patterns = await import('../../utils/patterns.js');
return patterns.authenticate(loginOptions);
}
// Web
else if (loginOptions.web) {
const auth = await import('../../auth');
const auth = await import('../../auth/index.js');
await auth.login({ port: loginOptions.port });
return;
} else {
const patterns = await import('../../utils/patterns');
const patterns = await import('../../utils/patterns.js');
// User had not selected login preference, prompt interactively
const loginType = await patterns.askLoginType();
if (loginType === 'register') {
const open = await import('open');
const { default: open } = await import('open');
const signupUrl = `https://dashboard.${balenaUrl}/signup`;
await open(signupUrl, { wait: false });
throw new ExpectedError(`Please sign up at ${signupUrl}`);

View File

@ -16,7 +16,7 @@
*/
import { Command } from '@oclif/core';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class LogoutCmd extends Command {
public static description = stripIndent`

View File

@ -16,7 +16,7 @@
*/
import { Command } from '@oclif/core';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy.js';
export default class OrganizationListCmd extends Command {
public static aliases = ['orgs'];
@ -34,7 +34,7 @@ export default class OrganizationListCmd extends Command {
public async run() {
await this.parse(OrganizationListCmd);
const { getOwnOrganizations } = await import('../../utils/sdk');
const { getOwnOrganizations } = await import('../../utils/sdk.js');
// Get organizations
const organizations = await getOwnOrganizations(getBalenaSdk(), {

View File

@ -16,8 +16,8 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import { getCliForm, stripIndent } from '../../utils/lazy';
import * as _ from 'lodash';
import { getCliForm, stripIndent } from '../../utils/lazy.js';
import _ from 'lodash';
import type { DeviceTypeJson } from 'balena-sdk';
export default class OsBuildConfigCmd extends Command {
@ -77,7 +77,7 @@ export default class OsBuildConfigCmd extends Command {
async buildConfig(image: string, deviceTypeSlug: string, advanced: boolean) {
advanced = advanced || false;
const { getManifest } = await import('../../utils/helpers');
const { getManifest } = await import('../../utils/helpers.js');
const deviceTypeManifest = await getManifest(image, deviceTypeSlug);
return this.buildConfigForDeviceType(deviceTypeManifest, advanced);
@ -98,7 +98,7 @@ export default class OsBuildConfigCmd extends Command {
});
if (advancedGroup != null) {
const { getGroupDefaults } = await import('../../utils/helpers');
const { getGroupDefaults } = await import('../../utils/helpers.js');
override = getGroupDefaults(advancedGroup);
}
}

View File

@ -19,15 +19,15 @@ import { Flags, Args, Command } from '@oclif/core';
import type { Interfaces } from '@oclif/core';
import type * as BalenaSdk from 'balena-sdk';
import { promisify } from 'util';
import * as _ from 'lodash';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent, getCliForm } from '../../utils/lazy';
import _ from 'lodash';
import { ExpectedError } from '../../errors.js';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, stripIndent, getCliForm } from '../../utils/lazy.js';
import {
applicationIdInfo,
devModeInfo,
secureBootInfo,
} from '../../utils/messages';
} from '../../utils/messages.js';
const CONNECTIONS_FOLDER = '/system-connections';
@ -97,7 +97,7 @@ export default class OsConfigureCmd extends Command {
description:
'ask advanced configuration questions (when in interactive mode)',
}),
fleet: { ...cf.fleet, exclusive: ['device'] },
fleet: cf.fleetExclusive(['device']),
config: Flags.string({
description:
'path to a pre-generated config.json file to be injected in the OS image',
@ -119,14 +119,11 @@ export default class OsConfigureCmd extends Command {
}),
dev: cf.dev,
secureBoot: cf.secureBoot,
device: {
...cf.device,
exclusive: [
'fleet',
'provisioning-key-name',
'provisioning-key-expiry-date',
],
},
device: cf.deviceExclusive([
'fleet',
'provisioning-key-name',
'provisioning-key-expiry-date',
]),
'device-type': Flags.string({
description:
'device type slug (e.g. "raspberrypi3") to override the fleet device type',
@ -166,10 +163,10 @@ export default class OsConfigureCmd extends Command {
const devInit = await import('balena-device-init');
const { promises: fs } = await import('fs');
const { generateDeviceConfig, generateApplicationConfig } = await import(
'../../utils/config'
'../../utils/config.js'
);
const helpers = await import('../../utils/helpers');
const { getApplication } = await import('../../utils/sdk');
const helpers = await import('../../utils/helpers.js');
const { getApplication } = await import('../../utils/sdk.js');
let app: ApplicationWithDeviceTypeSlug | undefined;
let device;
@ -201,27 +198,27 @@ export default class OsConfigureCmd extends Command {
deviceTypeSlug,
);
let configJson: import('../../utils/config').ImgConfig | undefined;
let configJson: import('../../utils/config.js').ImgConfig | undefined;
if (options.config) {
const rawConfig = await fs.readFile(options.config, 'utf8');
configJson = JSON.parse(rawConfig);
}
const { normalizeOsVersion } = await import('../../utils/normalization');
const { normalizeOsVersion } = await import('../../utils/normalization.js');
const osVersion = normalizeOsVersion(
options.version ||
(await getOsVersionFromImage(
params.image,
deviceTypeManifest,
devInit,
)),
(await getOsVersionFromImage(
params.image,
deviceTypeManifest,
devInit,
)),
);
const { validateDevOptionAndWarn } = await import('../../utils/config');
const { validateDevOptionAndWarn } = await import('../../utils/config.js');
await validateDevOptionAndWarn(options.dev, osVersion);
const { validateSecureBootOptionAndWarn } = await import(
'../../utils/config'
'../../utils/config.js'
);
await validateSecureBootOptionAndWarn(
options.secureBoot,
@ -317,7 +314,7 @@ async function validateOptions(options: FlagsDef) {
);
}
const { checkLoggedIn } = await import('../../utils/patterns');
const { checkLoggedIn } = await import('../../utils/patterns.js');
await checkLoggedIn();
}
@ -361,7 +358,7 @@ async function checkDeviceTypeCompatibility(
},
) {
if (options['device-type']) {
const helpers = await import('../../utils/helpers');
const helpers = await import('../../utils/helpers.js');
if (
!(await helpers.areDeviceTypesCompatible(
app.is_for__device_type[0].slug,
@ -392,7 +389,7 @@ async function checkDeviceTypeCompatibility(
async function askQuestionsForDeviceType(
deviceType: BalenaSdk.DeviceTypeJson.DeviceType,
options: FlagsDef,
configJson?: import('../../utils/config').ImgConfig,
configJson?: import('../../utils/config.js').ImgConfig,
): Promise<Answers> {
const answerSources: any[] = [
{
@ -415,7 +412,7 @@ async function askQuestionsForDeviceType(
isGroup: true,
});
if (!_.isEmpty(advancedGroup)) {
const helpers = await import('../../utils/helpers');
const helpers = await import('../../utils/helpers.js');
answerSources.push(helpers.getGroupDefaults(advancedGroup));
}
}

View File

@ -16,7 +16,7 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import { stripIndent } from '../../utils/lazy';
import { stripIndent } from '../../utils/lazy.js';
export default class OsDownloadCmd extends Command {
public static description = stripIndent`
@ -84,14 +84,14 @@ export default class OsDownloadCmd extends Command {
// balenaOS ESR versions require user authentication
if (options.version) {
const { isESR } = await import('../../utils/image-manager');
const { isESR } = await import('../../utils/image-manager.js');
if (options.version === 'menu-esr' || isESR(options.version)) {
try {
const { checkLoggedIn } = await import('../../utils/patterns');
const { checkLoggedIn } = await import('../../utils/patterns.js');
await checkLoggedIn();
} catch (e) {
const { ExpectedError, NotLoggedInError } = await import(
'../../errors'
'../../errors.js'
);
if (e instanceof NotLoggedInError) {
throw new ExpectedError(stripIndent`
@ -103,7 +103,7 @@ export default class OsDownloadCmd extends Command {
}
}
const { downloadOSImage } = await import('../../utils/cloud');
const { downloadOSImage } = await import('../../utils/cloud.js');
try {
await downloadOSImage(params.type, options.output, options.version);

View File

@ -16,8 +16,8 @@
*/
import { Args, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getCliForm, stripIndent } from '../../utils/lazy';
import * as cf from '../../utils/common-flags.js';
import { getCliForm, stripIndent } from '../../utils/lazy.js';
const INIT_WARNING_MESSAGE = `
@ -58,7 +58,7 @@ export default class OsInitializeCmd extends Command {
public async run() {
const { args: params, flags: options } = await this.parse(OsInitializeCmd);
const { getManifest, sudo } = await import('../../utils/helpers');
const { getManifest, sudo } = await import('../../utils/helpers.js');
console.info(`Initializing device ${INIT_WARNING_MESSAGE}`);
@ -71,13 +71,13 @@ export default class OsInitializeCmd extends Command {
});
if (answers.drive != null) {
const { confirm } = await import('../../utils/patterns');
const { confirm } = await import('../../utils/patterns.js');
await confirm(
options.yes,
`This will erase ${answers.drive}. Are you sure?`,
`Going to erase ${answers.drive}.`,
);
const { safeUmount } = await import('../../utils/umount');
const { safeUmount } = await import('../../utils/umount.js');
await safeUmount(answers.drive);
}
@ -90,7 +90,7 @@ export default class OsInitializeCmd extends Command {
]);
if (answers.drive != null) {
const { safeUmount } = await import('../../utils/umount');
const { safeUmount } = await import('../../utils/umount.js');
await safeUmount(answers.drive);
console.info(`You can safely remove ${answers.drive} now`);
}

View File

@ -16,7 +16,7 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import { stripIndent } from '../../utils/lazy';
import { stripIndent } from '../../utils/lazy.js';
export default class OsVersionsCmd extends Command {
public static description = stripIndent`
@ -53,7 +53,7 @@ export default class OsVersionsCmd extends Command {
const { args: params, flags: options } = await this.parse(OsVersionsCmd);
if (options['include-draft']) {
const { warnify } = await import('../../utils/messages');
const { warnify } = await import('../../utils/messages.js');
console.error(
warnify(stripIndent`
Using pre-release balenaOS versions is only supported for OS updates
@ -63,7 +63,7 @@ export default class OsVersionsCmd extends Command {
}
const { formatOsVersion, getOsVersions } = await import(
'../../utils/cloud'
'../../utils/cloud.js'
);
const vs = await getOsVersions(
params.type,

View File

@ -15,19 +15,19 @@
* limitations under the License.
*/
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { ExpectedError } from '../../errors.js';
import * as cf from '../../utils/common-flags.js';
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.js';
import { applicationIdInfo } from '../../utils/messages.js';
import { dockerConnectionCliFlags } from '../../utils/docker.js';
import { parseAsInteger } from '../../utils/validation.js';
import { Flags, Args, Command } from '@oclif/core';
import * as _ from 'lodash';
import _ from 'lodash';
import type {
Application,
BalenaSDK,
@ -37,6 +37,7 @@ import type {
Release,
} from 'balena-sdk';
import type { Preloader } from 'balena-preload';
import type { EventEmitter } from 'node:events';
export default class PreloadCmd extends Command {
public static description = stripIndent`
@ -138,10 +139,10 @@ Can be repeated to add multiple certificates.\
const { args: params, flags: options } = await this.parse(PreloadCmd);
const balena = getBalenaSdk();
const balenaPreload = await import('balena-preload');
const { default: balenaPreload } = await import('balena-preload');
const visuals = getVisuals();
const nodeCleanup = await import('node-cleanup');
const { instanceOf } = await import('../../errors');
const { default: nodeCleanup } = await import('node-cleanup');
const { instanceOf } = await import('../../errors.js');
// Check image file exists
try {
@ -165,8 +166,8 @@ Can be repeated to add multiple certificates.\
// 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 import('../../utils/sdk.js')
).getFleetSlug(balena, options.fleet)
: undefined;
const progressBars: {
@ -222,7 +223,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.js');
const docker = await dockerUtils.getDocker(options);
const preloader = new balenaPreload.Preloader(
undefined,
@ -236,7 +237,7 @@ Can be repeated to add multiple certificates.\
pinDevice ?? false,
certificates,
additionalSpace,
);
) as Preloader & EventEmitter;;
let gotSignal = false;
@ -476,7 +477,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.js');
return await getApplication(balenaSdk, slug, {
$expand: this.applicationExpandOptions,

View File

@ -17,16 +17,16 @@
import { Flags, Args, Command } from '@oclif/core';
import type { Interfaces } from '@oclif/core';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { dockerignoreHelp, registrySecretsHelp } from '../../utils/messages';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { dockerignoreHelp, registrySecretsHelp } from '../../utils/messages.js';
import type { BalenaSDK } from 'balena-sdk';
import { ExpectedError, instanceOf } from '../../errors';
import { ExpectedError, instanceOf } from '../../errors.js';
import type { RegistrySecrets } from '@balena/compose/dist/multibuild';
import { lowercaseIfSlug } from '../../utils/normalization';
import { lowercaseIfSlug } from '../../utils/normalization.js';
import {
applyReleaseTagKeysAndValues,
parseReleaseTagKeysAndValues,
} from '../../utils/compose_ts';
} from '../../utils/compose_ts.js';
enum BuildTarget {
Cloud,
@ -224,13 +224,13 @@ export default class PushCmd extends Command {
public async run() {
const { args: params, flags: options } = await this.parse(PushCmd);
const Logger = await import('../../utils/logger');
const { default: Logger } = await import('../../utils/logger.js');
const logger = Logger.getLogger();
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.js');
const { dockerfilePath, registrySecrets } = await validateProjectDirectory(
sdk,
{
@ -273,8 +273,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.js');
const { getApplication } = await import('../../utils/sdk.js');
// Check for invalid options
const localOnlyOptions: Array<keyof FlagsDef> = [
@ -293,7 +293,7 @@ export default class PushCmd extends Command {
options['release-tag'] ?? [],
);
const { checkLoggedIn } = await import('../../utils/patterns');
const { checkLoggedIn } = await import('../../utils/patterns.js');
await checkLoggedIn();
const [token, baseUrl] = await Promise.all([
@ -355,7 +355,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.js');
try {
await deviceDeploy.deployToDevice({
@ -375,7 +375,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.js');
if (instanceOf(e, BuildError)) {
throw new ExpectedError(e.toString());
} else {
@ -386,7 +386,7 @@ export default class PushCmd extends Command {
protected async getBuildTarget(appOrDevice: string): Promise<BuildTarget> {
const { validateLocalHostnameOrIp } = await import(
'../../utils/validation'
'../../utils/validation.js'
);
return validateLocalHostnameOrIp(appOrDevice)

View File

@ -16,8 +16,8 @@
*/
import { Command } from '@oclif/core';
import { commitOrIdArg } from '.';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { commitOrIdArg } from './index.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class ReleaseFinalizeCmd extends Command {
public static description = stripIndent`

View File

@ -16,12 +16,12 @@
*/
import { Flags, Args, type Interfaces, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy.js';
import type * as BalenaSdk from 'balena-sdk';
import * as yaml from 'js-yaml';
import { tryAsInteger } from '../../utils/validation';
import { jsonInfo } from '../../utils/messages';
import { tryAsInteger } from '../../utils/validation.js';
import { jsonInfo } from '../../utils/messages.js';
export const commitOrIdArg = Args.custom({
parse: tryAsInteger,

View File

@ -16,8 +16,8 @@
*/
import { Command } from '@oclif/core';
import { commitOrIdArg } from '.';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { commitOrIdArg } from './index.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class ReleaseInvalidateCmd extends Command {
public static description = stripIndent`

View File

@ -16,11 +16,11 @@
*/
import { Args, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { applicationNameNote } from '../../utils/messages';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy.js';
import { applicationNameNote } from '../../utils/messages.js';
import type * as BalenaSdk from 'balena-sdk';
import { jsonInfo } from '../../utils/messages';
import { jsonInfo } from '../../utils/messages.js';
export default class ReleaseListCmd extends Command {
public static aliases = ['releases'];
@ -66,7 +66,7 @@ export default class ReleaseListCmd extends Command {
] satisfies BalenaSdk.PineOptions<BalenaSdk.Release>['$select'];
const balena = getBalenaSdk();
const { getFleetSlug } = await import('../../utils/sdk');
const { getFleetSlug } = await import('../../utils/sdk.js');
const releases = await balena.models.release.getAllByApplication(
await getFleetSlug(balena, params.fleet),

View File

@ -16,8 +16,8 @@
*/
import { Command } from '@oclif/core';
import { commitOrIdArg } from '.';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { commitOrIdArg } from './index.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class ReleaseValidateCmd extends Command {
public static description = stripIndent`

View File

@ -16,7 +16,7 @@
*/
import { Command } from '@oclif/core';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class SettingsCmd extends Command {
public static description = stripIndent`

View File

@ -16,7 +16,7 @@
*/
import { Args, Command } from '@oclif/core';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
export default class SSHKeyAddCmd extends Command {
public static aliases = ['key add'];

View File

@ -16,8 +16,8 @@
*/
import { Args, Command } from '@oclif/core';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { parseAsInteger } from '../../utils/validation';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy.js';
import { parseAsInteger } from '../../utils/validation.js';
export default class SSHKeyCmd extends Command {
public static aliases = ['key'];

View File

@ -16,7 +16,7 @@
*/
import { Command } from '@oclif/core';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy.js';
export default class SSHKeyListCmd extends Command {
public static aliases = ['keys', 'key list'];

View File

@ -16,9 +16,9 @@
*/
import { Args, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { parseAsInteger } from '../../utils/validation';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { parseAsInteger } from '../../utils/validation.js';
export default class SSHKeyRmCmd extends Command {
public static aliases = ['key rm'];
@ -54,7 +54,7 @@ export default class SSHKeyRmCmd extends Command {
public async run() {
const { args: params, flags: options } = await this.parse(SSHKeyRmCmd);
const patterns = await import('../../utils/patterns');
const patterns = await import('../../utils/patterns.js');
await patterns.confirm(
options.yes ?? false,

View File

@ -16,10 +16,10 @@
*/
import { Flags, Args, Command } from '@oclif/core';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getCliUx, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import { ExpectedError } from '../../errors.js';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, getCliUx, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
export default class SupportCmd extends Command {
public static description = stripIndent`
@ -56,11 +56,12 @@ export default class SupportCmd extends Command {
description: 'comma-separated list (no spaces) of device UUIDs',
char: 'd',
}),
fleet: {
...cf.fleet,
fleet: Flags.string({
char: cf.fleet.char,
description:
'comma-separated list (no spaces) of fleet names or slugs (preferred)',
},
parse: cf.fleet.parse,
}),
duration: Flags.string({
description:
'length of time to enable support for, in (h)ours or (d)ays, e.g. 12h, 2d',
@ -112,7 +113,7 @@ export default class SupportCmd extends Command {
ux.action.stop();
}
const { getFleetSlug } = await import('../../utils/sdk');
const { getFleetSlug } = await import('../../utils/sdk.js');
// Process applications
for (const appName of appNames) {

View File

@ -16,10 +16,10 @@
*/
import { Command } from '@oclif/core';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import { ExpectedError } from '../../errors.js';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
export default class TagListCmd extends Command {
public static aliases = ['tags'];
@ -42,18 +42,9 @@ export default class TagListCmd extends Command {
];
public static flags = {
fleet: {
...cf.fleet,
exclusive: ['device', 'release'],
},
device: {
...cf.device,
exclusive: ['fleet', 'release'],
},
release: {
...cf.release,
exclusive: ['fleet', 'device'],
},
fleet: cf.fleetExclusive(['device', 'release']),
device: cf.deviceExclusive(['fleet', 'release']),
release: cf.releaseExclusive(['fleet', 'device']),
};
public static authenticated = true;
@ -71,7 +62,7 @@ export default class TagListCmd extends Command {
let tags;
if (options.fleet) {
const { getFleetSlug } = await import('../../utils/sdk');
const { getFleetSlug } = await import('../../utils/sdk.js');
tags = await balena.models.application.tags.getAllByApplication(
await getFleetSlug(balena, options.fleet),
);
@ -81,7 +72,7 @@ export default class TagListCmd extends Command {
}
if (options.release) {
const { disambiguateReleaseParam } = await import(
'../../utils/normalization'
'../../utils/normalization.js'
);
const releaseParam = await disambiguateReleaseParam(
balena,

View File

@ -16,9 +16,9 @@
*/
import { Args, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
export default class TagRmCmd extends Command {
public static description = stripIndent`
@ -45,18 +45,9 @@ export default class TagRmCmd extends Command {
};
public static flags = {
fleet: {
...cf.fleet,
exclusive: ['device', 'release'],
},
device: {
...cf.device,
exclusive: ['fleet', 'release'],
},
release: {
...cf.release,
exclusive: ['fleet', 'device'],
},
fleet: cf.fleetExclusive(['device', 'release']),
device: cf.deviceExclusive(['fleet', 'release']),
release: cf.releaseExclusive(['fleet', 'device']),
};
public static authenticated = true;
@ -68,12 +59,12 @@ export default class TagRmCmd extends Command {
// Check user has specified one of application/device/release
if (!options.fleet && !options.device && !options.release) {
const { ExpectedError } = await import('../../errors');
const { ExpectedError } = await import('../../errors.js');
throw new ExpectedError(TagRmCmd.missingResourceMessage);
}
if (options.fleet) {
const { getFleetSlug } = await import('../../utils/sdk');
const { getFleetSlug } = await import('../../utils/sdk.js');
return balena.models.application.tags.remove(
await getFleetSlug(balena, options.fleet),
params.tagKey,
@ -84,7 +75,7 @@ export default class TagRmCmd extends Command {
}
if (options.release) {
const { disambiguateReleaseParam } = await import(
'../../utils/normalization'
'../../utils/normalization.js'
);
const releaseParam = await disambiguateReleaseParam(
balena,

View File

@ -16,9 +16,9 @@
*/
import { Args, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { applicationIdInfo } from '../../utils/messages';
import * as cf from '../../utils/common-flags.js';
import { getBalenaSdk, stripIndent } from '../../utils/lazy.js';
import { applicationIdInfo } from '../../utils/messages.js';
export default class TagSetCmd extends Command {
public static description = stripIndent`
@ -59,18 +59,9 @@ export default class TagSetCmd extends Command {
public static strict = false;
public static flags = {
fleet: {
...cf.fleet,
exclusive: ['device', 'release'],
},
device: {
...cf.device,
exclusive: ['fleet', 'release'],
},
release: {
...cf.release,
exclusive: ['fleet', 'device'],
},
fleet: cf.fleetExclusive(['device', 'release']),
device: cf.deviceExclusive(['fleet', 'release']),
release: cf.releaseExclusive(['fleet', 'device']),
};
public static authenticated = true;
@ -82,14 +73,14 @@ export default class TagSetCmd extends Command {
// Check user has specified one of application/device/release
if (!options.fleet && !options.device && !options.release) {
const { ExpectedError } = await import('../../errors');
const { ExpectedError } = await import('../../errors.js');
throw new ExpectedError(TagSetCmd.missingResourceMessage);
}
params.value ??= '';
if (options.fleet) {
const { getFleetSlug } = await import('../../utils/sdk');
const { getFleetSlug } = await import('../../utils/sdk.js');
return balena.models.application.tags.set(
await getFleetSlug(balena, options.fleet),
params.tagKey,
@ -105,7 +96,7 @@ export default class TagSetCmd extends Command {
}
if (options.release) {
const { disambiguateReleaseParam } = await import(
'../../utils/normalization'
'../../utils/normalization.js'
);
const releaseParam = await disambiguateReleaseParam(
balena,

View File

@ -16,7 +16,7 @@
*/
import { Command } from '@oclif/core';
import { stripIndent, getChalk, getVisuals } from '../../utils/lazy';
import { stripIndent, getChalk, getVisuals } from '../../utils/lazy.js';
export default class UtilAvailableDrivesCmd extends Command {
public static description = stripIndent`

View File

@ -16,7 +16,7 @@
*/
import { Flags, Command } from '@oclif/core';
import { stripIndent } from '../../utils/lazy';
import { stripIndent } from '../../utils/lazy.js';
export interface JsonVersions {
'balena-cli': string;

View File

@ -16,7 +16,7 @@
*/
import { Command } from '@oclif/core';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy.js';
export default class WhoamiCmd extends Command {
public static description = stripIndent`

View File

@ -106,7 +106,7 @@ export class DeprecationChecker {
const url = this.getNpmUrl(version);
let response: import('got').Response<Dictionary<any>> | undefined;
try {
response = await got(url, {
response = await got.default(url, {
responseType: 'json',
retry: 0,
timeout: 4000,
@ -198,7 +198,7 @@ or release date not available`);
const nextMajorDate = new Date(nextMajorDateStr).getTime();
const daysElapsed = Math.trunc((this.now - nextMajorDate) / this.msInDay);
if (daysElapsed > this.expiryDays) {
const { ExpectedError } = await import('./errors');
const { ExpectedError } = await import('./errors.js');
throw new ExpectedError(this.getExpiryMsg(daysElapsed));
} else if (daysElapsed > this.deprecationDays && process.stderr.isTTY) {
console.error(this.getDeprecationMsg(daysElapsed));
@ -208,7 +208,7 @@ or release date not available`);
/** Separate function for the benefit of code testing */
getDeprecationMsg(daysElapsed: number) {
const { warnify } =
require('./utils/messages') as typeof import('./utils/messages');
require('./utils/messages.js') as typeof import('./utils/messages.js');
return warnify(`\
CLI version ${this.nextMajorVersion} was released ${daysElapsed} days ago: please upgrade.
This version of the balena CLI (${this.currentVersion}) will exit with an error

View File

@ -15,12 +15,12 @@ limitations under the License.
*/
import type { BalenaError } from 'balena-errors';
import * as _ from 'lodash';
import * as os from 'os';
import _ from 'lodash';
import os from 'os';
import { TypedError } from 'typed-error';
import { getChalk, stripIndent } from './utils/lazy';
import { getHelp } from './utils/messages';
import { CliSettings } from './utils/bootstrap';
import { getChalk, stripIndent } from './utils/lazy.js';
import { getHelp } from './utils/messages.js';
import { CliSettings } from './utils/bootstrap.js';
export class ExpectedError extends TypedError {
public code?: string;

View File

@ -16,7 +16,7 @@
*/
import * as packageJSON from '../package.json';
import { stripIndent } from './utils/lazy';
import { stripIndent } from './utils/lazy.js';
/**
* Track balena CLI usage events (product improvement analytics).
@ -44,7 +44,7 @@ export async function trackCommand(commandSignature: string) {
scope.setExtra('command', commandSignature);
});
}
const { getCachedUsername } = await import('./utils/bootstrap');
const { getCachedUsername } = await import('./utils/bootstrap.js');
let username: string | undefined;
try {
username = (await getCachedUsername())?.username;
@ -95,7 +95,7 @@ async function sendEvent(balenaUrl: string, event: string, username?: string) {
const url = `https://data.${balenaUrl}/amplitude/2/httpapi`;
try {
await got.post(url, {
await got.default.post(url, {
json: trackData,
retry: 0,
timeout: {

Some files were not shown because too many files have changed in this diff Show More