Import just strip-tags from common-tags to reduce startup time

This saves ~100ms for me on startup with no fast-boot cache and ~50ms
with a fast-boot cache

Change-type: patch
This commit is contained in:
Pagan Gazzard 2020-05-04 15:57:23 +01:00
parent f47a4ccb2b
commit 667358b23e
67 changed files with 74 additions and 121 deletions

View File

@ -21,7 +21,6 @@ import { run as oclifRun } from '@oclif/dev-cli';
import * as archiver from 'archiver';
import * as Bluebird from 'bluebird';
import { execFile } from 'child_process';
import { stripIndent } from 'common-tags';
import * as filehound from 'filehound';
import * as fs from 'fs-extra';
import * as _ from 'lodash';
@ -31,6 +30,7 @@ import * as rimraf from 'rimraf';
import * as semver from 'semver';
import * as util from 'util';
import { stripIndent } from '../lib/utils/lazy';
import {
getSubprocessStdout,
loadPackageJson,

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
const { stripIndent } = require('common-tags');
const stripIndent = require('common-tags/lib/stripIndent');
const _ = require('lodash');
const { promises: fs } = require('fs');
const path = require('path');

View File

@ -16,11 +16,10 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
interface FlagsDef {
help: void;

View File

@ -16,11 +16,10 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
interface FlagsDef {
type?: string; // application device type

View File

@ -16,10 +16,9 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals } from '../../utils/lazy';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { tryAsInteger } from '../../utils/validation';
interface FlagsDef {

View File

@ -16,10 +16,9 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { tryAsInteger } from '../../utils/validation';
interface FlagsDef {

View File

@ -16,10 +16,9 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { tryAsInteger } from '../../utils/validation';
interface FlagsDef {

View File

@ -17,10 +17,9 @@
import { flags } from '@oclif/command';
import type { Application } from 'balena-sdk';
import { stripIndent } from 'common-tags';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, getVisuals } from '../utils/lazy';
import { getBalenaSdk, getVisuals, stripIndent } from '../utils/lazy';
import { isV12 } from '../utils/version';
interface ExtendedApplication extends Application {

View File

@ -17,10 +17,9 @@
import { flags } from '@oclif/command';
import type { IArg } from '@oclif/parser/lib/args';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { tryAsInteger } from '../../utils/validation';
import { ExpectedError } from '../../errors';

View File

@ -17,11 +17,10 @@
import { flags } from '@oclif/command';
import { IArg } from '@oclif/parser/lib/args';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { expandForAppName } from '../../utils/helpers';
import { getBalenaSdk, getVisuals } from '../../utils/lazy';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { tryAsInteger } from '../../utils/validation';
import type { Application, Device } from 'balena-sdk';

View File

@ -18,12 +18,11 @@
import { flags } from '@oclif/command';
import type { IArg } from '@oclif/parser/lib/args';
import type { Application, Device } from 'balena-sdk';
import { stripIndent } from 'common-tags';
import * as _ from 'lodash';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { expandForAppName } from '../../utils/helpers';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { tryAsInteger } from '../../utils/validation';
interface ExtendedDevice extends Device {

View File

@ -17,10 +17,9 @@
import { flags } from '@oclif/command';
import type { IArg } from '@oclif/parser/lib/args';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { tryAsInteger } from '../../utils/validation';
import type { Device } from 'balena-sdk';
import { ExpectedError } from '../../errors';

View File

@ -17,11 +17,10 @@
import { flags } from '@oclif/command';
import type { IArg } from '@oclif/parser/lib/args';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { tryAsInteger } from '../../utils/validation';
interface FlagsDef {

View File

@ -17,10 +17,9 @@
import { flags } from '@oclif/command';
import type { IArg } from '@oclif/parser/lib/args';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { tryAsInteger } from '../../utils/validation';
interface FlagsDef {

View File

@ -17,10 +17,9 @@
import { flags } from '@oclif/command';
import type { IArg } from '@oclif/parser/lib/args';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { tryAsInteger } from '../../utils/validation';
interface FlagsDef {

View File

@ -17,10 +17,9 @@
import { flags } from '@oclif/command';
import type { IArg } from '@oclif/parser/lib/args';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { tryAsInteger } from '../../utils/validation';
interface FlagsDef {

View File

@ -17,10 +17,9 @@
import { flags } from '@oclif/command';
import type { IArg } from '@oclif/parser/lib/args';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { tryAsInteger } from '../../utils/validation';
interface FlagsDef {

View File

@ -17,10 +17,9 @@
import { flags } from '@oclif/command';
import type { IArg } from '@oclif/parser/lib/args';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { tryAsInteger } from '../../utils/validation';
import { ExpectedError } from '../../errors';

View File

@ -16,12 +16,11 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import * as _ from 'lodash';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { expandForAppName } from '../../utils/helpers';
import { getBalenaSdk, getVisuals } from '../../utils/lazy';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { tryAsInteger } from '../../utils/validation';
import type { Device, Application } from 'balena-sdk';

View File

@ -16,12 +16,11 @@
*/
import { flags } from '@oclif/command';
import type * as SDK from 'balena-sdk';
import { stripIndent } from 'common-tags';
import * as _ from 'lodash';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals } from '../../utils/lazy';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { CommandHelp } from '../../utils/oclif-utils';
import { isV12 } from '../../utils/version';

View File

@ -17,13 +17,12 @@
import { flags } from '@oclif/command';
import type * as BalenaSdk from 'balena-sdk';
import { stripIndent } from 'common-tags';
import * as _ from 'lodash';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { CommandHelp } from '../../utils/oclif-utils';
interface FlagsDef {

View File

@ -15,12 +15,11 @@
* limitations under the License.
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import * as ec from '../../utils/env-common';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { CommandHelp } from '../../utils/oclif-utils';
import { parseAsInteger } from '../../utils/validation';

View File

@ -16,11 +16,10 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as ec from '../../utils/env-common';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { CommandHelp } from '../../utils/oclif-utils';
import { parseAsInteger } from '../../utils/validation';

View File

@ -16,13 +16,12 @@
*/
import { flags } from '@oclif/command';
import type * as SDK from 'balena-sdk';
import { stripIndent } from 'common-tags';
import * as _ from 'lodash';
import Command from '../command';
import { ExpectedError } from '../errors';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, getVisuals } from '../utils/lazy';
import { getBalenaSdk, getVisuals, stripIndent } from '../utils/lazy';
import { CommandHelp } from '../utils/oclif-utils';
import { isV12 } from '../utils/version';

View File

@ -15,8 +15,8 @@
* limitations under the License.
*/
import { stripIndent } from 'common-tags';
import Command from '../../command';
import { stripIndent } from '../../utils/lazy';
import { CommandHelp } from '../../utils/oclif-utils';
// 'Internal' commands are called during the execution of other commands.

View File

@ -15,8 +15,8 @@
* limitations under the License.
*/
import { stripIndent } from 'common-tags';
import Command from '../../command';
import { stripIndent } from '../../utils/lazy';
// 'Internal' commands are called during the execution of other commands.
// `scandevices` is called during by `join`,`leave'.

View File

@ -16,10 +16,9 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk } from '../utils/lazy';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
interface FlagsDef {
application?: string;

View File

@ -16,11 +16,10 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
interface FlagsDef {
help: void;

View File

@ -16,10 +16,9 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals } from '../../utils/lazy';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { parseAsInteger } from '../../utils/validation';
type IArg<T> = import('@oclif/parser').args.IArg<T>;

View File

@ -16,10 +16,9 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { parseAsInteger } from '../../utils/validation';
type IArg<T> = import('@oclif/parser').args.IArg<T>;

View File

@ -16,10 +16,9 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, getVisuals } from '../utils/lazy';
import { getBalenaSdk, getVisuals, stripIndent } from '../utils/lazy';
interface FlagsDef {
help: void;

View File

@ -16,10 +16,9 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk } from '../utils/lazy';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
interface FlagsDef {
help?: void;

View File

@ -16,10 +16,9 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk } from '../utils/lazy';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
import { ExpectedError } from '../errors';
interface FlagsDef {

View File

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

View File

@ -16,12 +16,11 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import * as _ from 'lodash';
import Command from '../command';
import { ExpectedError } from '../errors';
import * as cf from '../utils/common-flags';
import { getBalenaSdk } from '../utils/lazy';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
interface FlagsDef {
device?: string; // device UUID

View File

@ -18,14 +18,13 @@
import { flags } from '@oclif/command';
import type * as BalenaSdk from 'balena-sdk';
import Bluebird = require('bluebird');
import { stripIndent } from 'common-tags';
import * as _ from 'lodash';
import * as path from 'path';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { CommandHelp } from '../../utils/oclif-utils';
const BOOT_PARTITION = 1;

View File

@ -17,10 +17,9 @@
import { flags } from '@oclif/command';
import type { LocalBalenaOsDevice } from 'balena-sync';
import { stripIndent } from 'common-tags';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getVisuals } from '../utils/lazy';
import { getVisuals, stripIndent } from '../utils/lazy';
interface FlagsDef {
verbose: boolean;

View File

@ -16,10 +16,9 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../command';
import * as cf from '../utils/common-flags';
import { getBalenaSdk } from '../utils/lazy';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
interface FlagsDef {
help: void;

View File

@ -16,11 +16,10 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { disambiguateReleaseParam } from '../../utils/normalization';
import { tryAsInteger } from '../../utils/validation';

View File

@ -16,11 +16,10 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../../command';
import { ExpectedError } from '../../errors';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk } from '../../utils/lazy';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
import { disambiguateReleaseParam } from '../../utils/normalization';
import { tryAsInteger } from '../../utils/validation';

View File

@ -16,11 +16,10 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../command';
import { ExpectedError } from '../errors';
import * as cf from '../utils/common-flags';
import { getBalenaSdk, getVisuals } from '../utils/lazy';
import { getBalenaSdk, getVisuals, stripIndent } from '../utils/lazy';
import { disambiguateReleaseParam } from '../utils/normalization';
import { tryAsInteger } from '../utils/validation';
import { isV12 } from '../utils/version';

View File

@ -16,8 +16,8 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import Command from '../command';
import { stripIndent } from '../utils/lazy';
interface FlagsDef {
all?: boolean;

View File

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

View File

@ -15,9 +15,8 @@ limitations under the License.
*/
import type { CommandDefinition } from 'capitano';
import { stripIndent } from 'common-tags';
import type * as SDK from 'etcher-sdk';
import { getChalk, getVisuals } from '../../utils/lazy';
import { getChalk, getVisuals, stripIndent } from '../../utils/lazy';
async function getDrive(options: {
drive?: string;

View File

@ -16,9 +16,8 @@ limitations under the License.
import type { LogMessage } from 'balena-sdk';
import type { CommandDefinition } from 'capitano';
import { stripIndent } from 'common-tags';
import { getBalenaSdk } from '../utils/lazy';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
import { normalizeUuidProp } from '../utils/normalization';
import { validateDotLocalUrl } from '../utils/validation';

View File

@ -16,10 +16,9 @@ limitations under the License.
import type { BalenaSDK } from 'balena-sdk';
import type { CommandDefinition } from 'capitano';
import { stripIndent } from 'common-tags';
import { ExpectedError } from '../errors';
import { getBalenaSdk } from '../utils/lazy';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
import { dockerignoreHelp, registrySecretsHelp } from '../utils/messages';
import {
validateApplicationName,

View File

@ -15,9 +15,8 @@ limitations under the License.
*/
import type * as BalenaSdk from 'balena-sdk';
import type { CommandDefinition } from 'capitano';
import { stripIndent } from 'common-tags';
import { getBalenaSdk } from '../utils/lazy';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
import { validateDotLocalUrl, validateIPAddress } from '../utils/validation';
async function getContainerId(

View File

@ -15,11 +15,10 @@ limitations under the License.
*/
import * as Bluebird from 'bluebird';
import type { CommandDefinition } from 'capitano';
import { stripIndent } from 'common-tags';
import * as _ from 'lodash';
import { createServer, Server, Socket } from 'net';
import { getBalenaSdk } from '../utils/lazy';
import { getBalenaSdk, stripIndent } from '../utils/lazy';
import { getOnlineTargetUuid } from '../utils/patterns';
import { tunnelConnectionToDevice } from '../utils/tunnel';

View File

@ -20,8 +20,7 @@ limitations under the License.
*/
import type { CommandDefinition } from 'capitano';
import { stripIndent } from 'common-tags';
import { getChalk, getVisuals } from '../utils/lazy';
import { getChalk, getVisuals, stripIndent } from '../utils/lazy';
export const availableDrives: CommandDefinition<{}, {}> = {
signature: 'util available-drives',

View File

@ -16,7 +16,7 @@
*/
import * as packageJSON from '../package.json';
import { onceAsync } from './utils/lazy';
import { onceAsync, stripIndent } from './utils/lazy';
class CliSettings {
public readonly settings: any;
@ -64,10 +64,9 @@ export const setupSentry = onceAsync(async () => {
return Sentry.getCurrentHub();
});
function checkNodeVersion() {
async function checkNodeVersion() {
const validNodeVersions = packageJSON.engines.node;
if (!require('semver').satisfies(process.version, validNodeVersions)) {
const { stripIndent } = require('common-tags');
if (!(await import('semver')).satisfies(process.version, validNodeVersions)) {
console.warn(stripIndent`
------------------------------------------------------------------------------
Warning: Node version "${process.version}" does not match required versions "${validNodeVersions}".

View File

@ -14,12 +14,11 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { BalenaError } from 'balena-errors';
import { stripIndent } from 'common-tags';
import type { BalenaError } from 'balena-errors';
import * as _ from 'lodash';
import * as os from 'os';
import { TypedError } from 'typed-error';
import { getChalk } from './utils/lazy';
import { getChalk, stripIndent } from './utils/lazy';
import { getHelp } from './utils/messages';
export class ExpectedError extends TypedError {}

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { stripIndent } from 'common-tags';
import { stripIndent } from './utils/lazy';
import { exitWithExpectedError } from './errors';

View File

@ -16,8 +16,8 @@
*/
import type * as SDK from 'balena-sdk';
import { stripIndent } from 'common-tags';
import * as _ from 'lodash';
import { stripIndent } from './lazy';
import { ExpectedError } from '../errors';

View File

@ -16,10 +16,9 @@
*/
import * as Bluebird from 'bluebird';
import { stripIndent } from 'common-tags';
import * as path from 'path';
import { getChalk } from './lazy';
import { getChalk, stripIndent } from './lazy';
export const appendProjectOptions = (opts) =>
opts.concat([

View File

@ -16,7 +16,6 @@
*/
import { BalenaSDK } from 'balena-sdk';
import * as Bluebird from 'bluebird';
import { stripIndent } from 'common-tags';
import type * as Dockerode from 'dockerode';
import * as _ from 'lodash';
import { promises as fs } from 'fs';
@ -25,6 +24,7 @@ import { Composition } from 'resin-compose-parse';
import * as MultiBuild from 'resin-multibuild';
import { Readable } from 'stream';
import * as tar from 'tar-stream';
import { stripIndent } from './lazy';
import { ExpectedError } from '../errors';
import { getBalenaSdk, getChalk } from '../utils/lazy';

View File

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import type { ContainerInfo } from 'dockerode';
import { stripIndent } from '../lazy';
export interface DeviceSSHOpts {
address: string;
@ -31,7 +32,6 @@ export async function performLocalDeviceSSH(
const reduce = await import('lodash/reduce');
const { spawnSshAndExitOnError } = await import('../ssh');
const { ExpectedError } = await import('../../errors');
const { stripIndent } = await import('common-tags');
let command = '';

View File

@ -16,7 +16,7 @@
*/
import { flags } from '@oclif/command';
import { stripIndent } from 'common-tags';
import { stripIndent } from './lazy';
import { ExpectedError } from '../errors';

View File

@ -19,6 +19,7 @@ limitations under the License.
import type * as BalenaSdk from 'balena-sdk';
import type { Chalk } from 'chalk';
import type * as visuals from 'resin-cli-visuals';
import type { stripIndent as StripIndent } from 'common-tags';
// Equivalent of _.once but avoiding the need to import lodash for lazy deps
const once = <T>(fn: () => T) => {
@ -50,3 +51,7 @@ export const getVisuals = once(
);
export const getChalk = once(() => require('chalk') as Chalk);
// Directly export stripIndent as we always use it immediately, but importing just `stripIndent` reduces startup time
// tslint:disable-next-line:no-var-requires
export const stripIndent = require('common-tags/lib/stripIndent') as typeof StripIndent;

View File

@ -16,12 +16,11 @@ limitations under the License.
import { BalenaApplicationNotFound } from 'balena-errors';
import type * as BalenaSdk from 'balena-sdk';
import Bluebird = require('bluebird');
import { stripIndent } from 'common-tags';
import _ = require('lodash');
import _form = require('resin-cli-form');
import { exitWithExpectedError, instanceOf, NotLoggedInError } from '../errors';
import { getBalenaSdk, getVisuals } from './lazy';
import { getBalenaSdk, getVisuals, stripIndent } from './lazy';
import validation = require('./validation');
import { isV12 } from './version';

View File

@ -15,10 +15,9 @@
* limitations under the License.
*/
import type * as BalenaSdk from 'balena-sdk';
import { stripIndent } from 'common-tags';
import { ExpectedError, printErrorMessage } from '../errors';
import { getVisuals } from './lazy';
import { getVisuals, stripIndent } from './lazy';
import Logger = require('./logger');
import { exec, execBuffered, getDeviceOsRelease } from './ssh';

View File

@ -16,9 +16,8 @@
*/
import * as Bluebird from 'bluebird';
import { stripIndent } from 'common-tags';
import type * as Dockerode from 'dockerode';
import { getBalenaSdk } from './lazy';
import { getBalenaSdk, stripIndent } from './lazy';
import Logger = require('./logger');
export const QEMU_VERSION = 'v4.0.0+balena2';

View File

@ -26,7 +26,7 @@ import type { Pack } from 'tar-stream';
import { ExpectedError } from '../errors';
import { exitWithExpectedError } from '../errors';
import { tarDirectory } from './compose';
import { getVisuals } from './lazy';
import { getVisuals, stripIndent } from './lazy';
import Logger = require('./logger');
const globalLogger = Logger.getLogger();
@ -183,8 +183,6 @@ function handleHeadlessBuildMessage(message: HeadlessBuilderMessage) {
}
function handleBuilderMetadata(obj: BuilderMessage, build: RemoteBuild) {
const { stripIndent } = require('common-tags');
switch (obj.resource) {
case 'cursor':
if (obj.value == null) {

View File

@ -16,7 +16,7 @@
*/
import { ChildProcess, spawn, SpawnOptions } from 'child_process';
import { stripIndent } from 'common-tags';
import { stripIndent } from './lazy';
/**
* Execute a child process with admin / superuser privileges, prompting the user for

View File

@ -19,11 +19,11 @@
require('../config-tests'); // required for side effects
import { expect } from 'chai';
import { stripIndent } from 'common-tags';
import mock = require('mock-require');
import { promises as fs } from 'fs';
import * as path from 'path';
import { stripIndent } from '../../lib/utils/lazy';
import { BalenaAPIMock } from '../balena-api-mock';
import { expectStreamNoCRLF, testDockerBuildStream } from '../docker-build';
import { DockerMock, dockerResponsePath } from '../docker-mock';

View File

@ -16,7 +16,7 @@
*/
import { expect } from 'chai';
import { stripIndent } from 'common-tags';
import { stripIndent } from '../../../lib/utils/lazy';
import { isV12 } from '../../../lib/utils/version';
import { BalenaAPIMock } from '../../balena-api-mock';

View File

@ -16,7 +16,6 @@
*/
import { expect } from 'chai';
import { stripIndent } from 'common-tags';
import * as _ from 'lodash';
import { promises as fs } from 'fs';
import * as path from 'path';
@ -27,6 +26,7 @@ import * as tar from 'tar-stream';
import { streamToBuffer } from 'tar-utils';
import { URL } from 'url';
import { stripIndent } from '../lib/utils/lazy';
import { BuilderMock } from './builder-mock';
import { DockerMock } from './docker-mock';
import { cleanOutput, fillTemplateArray, runCommand } from './helpers';

View File

@ -2,6 +2,6 @@
"extends": "./node_modules/@balena/lint/config/tslint-prettier.json",
"rules": {
"ignoreDefinitionFiles": false,
"import-blacklist": [true, "resin-cli-visuals", "chalk"]
"import-blacklist": [true, "resin-cli-visuals", "chalk", "common-tags"]
}
}