GitHub Homepage React Spectrum Libraries Legal Notice

@wuespace/telestion-client-cli

Install using

npm install @wuespace/telestion-client-cli

Exported Members

You can access these members by importing the module:

import { member } from '@wuespace/telestion-client-cli';

LevelLogger (...)

function LevelLogger (
   logger : LogFunction ,
   initial : LogLevel = 'warn'
) : LogFunction

Uses an existing log function to wrap a level logging system around. Use setLogLevel to set the current log level.

@param:

logger - the existing log function

@param:

initial - the initial log level (defaults to 'warn')

@returns:

the modified log function

getLogLevel (...)

function getLogLevel ( ) : LogLevel

Returns the current log level.

setLogLevel (...)

function setLogLevel (
   level : LogLevel
) : void

Sets the current log level of the LevelLogger.

@param:

level - the new log level (one of:

LogLevel

type LogLevel

Alias for: 'debug' | 'info' | 'warn' | 'error' | 'unknown'

Describes the log levels that the level logger can handle.

logLevels

const : Record<LogLevel, number>

Maps a log level name to a log level priority number. (higher = more important)

levelNames

const : any

Maps a log level priority number to a log level name.

getLogger (...)

function getLogger (
   componentName : string
) : ComponentLogger

Returns a logger interface for the specified component.

@param:

componentName - the name of the component

sanitizeArgument (...)

function sanitizeArgument (
   arg : string
) : string

Sanitizes an argument for a CMD command.

@param:

arg - the unsafe argument

getCmdShellString (...)

function getCmdShellString (
   executablePath : string ,
   args : string[] = [] ,
   disableSanitizer : undefined = false
) : string

Converts the executable and the arguments to a string that is executable by the CMD command.

@param:

executablePath - path to the executable (can also be a filename that is available in the path)

@param:

args - arguments that the executable receives on execution

@param:

disableSanitizer - explicitly turn off the argument sanitizer (I sure hope you know what you're doing...)

exec (...)

async function exec (
   executablePath : string ,
   args : string[] = [] ,
   options : ExecOptions & { disableSanitizer?: boolean } = {}
) : Promise<{ stdout: string | Buffer; stderr: string | Buffer }>

Execute an executable from the parent process.

@param:

executablePath - path to the executable (can also be a filename that is available in the path)

@param:

args - arguments that the executable receives on execution

@param:

options - additional exec options

spawn (...)

function spawn (
   executablePath : string ,
   args : readonly string[] = [] ,
   options : SpawnOptions = {}
) : ChildProcess

Spawns an executable from the parent process.

@param:

executablePath - path to the executable (can also be a filename that is available in the path)

@param:

args - arguments that the executable receives on spawning

@param:

options - additional spawn options

fork (...)

function fork (
   modulePath : string ,
   args ? : string[] ,
   options ? : ForkOptions
) : ChildProcess

Forks a JS module from the parent process and opens an IPC channel between both processes.

@param:

modulePath - path to the JS module to execute (can also be a filename that is available in the path)

@param:

args - arguments that the JS module receives on forking

@param:

options - additional fork options

ChildProcess

interface ChildProcess extends NodeChildProcess

No docs provided

Properties

Methods

stop (...)

function stop (
   signal ? : NodeJS.Signals
) : void

Stops the child process platform independently.

copyFile (...)

async function copyFile (
   sourcePath : string ,
   destPath : string ,
   overwrite : undefined = false
) : Promise<void>

Copies a file from the source path to the destination path.

@param:

sourcePath - the path to original file you want to copy

@param:

destPath - the path to the copy

@param:

overwrite - when the destination path is already "occupied" by a file, then replace it

rm (...)

async function rm (
   path : string ,
   recursive : undefined = false
) : Promise<void>

Removes a file or directory at the specified path.

@param:

path - the path to the file or directory you want to delete

@param:

recursive - if it is a directory you want to delete, recurse into it and delete its children too

stat (...)

async function stat (
   path : string
) : Promise<Stats>

Scrapes information about a file.

@param:

path - the path to the file to check

exists (...)

async function exists (
   path : string
) : Promise<boolean>

Returns true if the path exists.

@param:

path - the path to check for existence

existsSync (...)

function existsSync (
   path : string
) : boolean

Returns true if the path exists. (synchronous version)

@param:

path - the path to check for existence

move (...)

async function move (
   oldPath : string ,
   newPath : string
) : Promise<void>

Moves a file from the old path to the new path.

@param:

oldPath - the path to the file you want to move

@param:

newPath - the destination path the file should have once the function returns

rmIfExists (...)

async function rmIfExists (
   path : string ,
   recursive : undefined = false
) : Promise<boolean>

Removes a file or directory if it exists.

@param:

path - the path to the file or directory you want to delete

@param:

recursive - if it is a directory you want to delete, recurse into it and delete its children too

mkdir (...)

async function mkdir (
   dirPath : string ,
   recursive : undefined = false
) : Promise<string | void>

Creates a directory. If the given path already exists and recursive is {@code false}, the function rejects.

@param:

dirPath - the path to new directory

@param:

recursive - when {@code true} parent directory are created if they aren't exist yet

symlink (...)

async function symlink (
   pointsTo : string ,
   symlinkPath : string ,
   options : Partial<SymlinkOptions> = {}
) : Promise<void>

Creates a symlink at the specified path that points to another path.

@param:

pointsTo - the path to which the link should point

@param:

symlinkPath - the path on which the link should be generated

@param:

options - additional options to configure the symlink process further

realPath (...)

async function realPath (
   symlinkPath : string
) : Promise<string>

Determines the actual location of the symlink path.

@param:

symlinkPath - the path to the symbolic link that should be resolved

chmod (...)

async function chmod (
   filePath : string ,
   mode : number | string
) : Promise<void>

Changes the access bits of a file.

@param:

filePath - the file that receives the new access bits

@param:

mode - the access bits in an octal format (1336) or in a human-readable format ("755")

readFile (...)

async function readFile (
   filePath : string
) : Promise<string>

Reads the contents of a file and returns them as a string.

@param:

filePath - the path to the file

readFileSync (...)

function readFileSync (
   filePath : string
) : string

Reads the contents of a file and returns them as a string. (synchronous version)

@param:

filePath - the path to the file

writeFile (...)

async function writeFile (
   filePath : string ,
   content : string ,
   append : undefined = false
) : Promise<void>

Writes the given contents to a file.

@param:

filePath - the path to the file

@param:

content - the new content

@param:

append - when {@code true} the new content is appended to the existing one

readDir (...)

async function readDir (
   dirPath : string
) : Promise<string[]>

Reads the contents of a directory and returns the names of all elements.

@param:

dirPath - the path to the directory

SymlinkOptions

interface SymlinkOptions

No docs provided

Properties

type

Type: 'dir' | 'file' | 'junction'

The type of the symbolic link to create. Only used on Windows systems.

requireAbsolute

Type: boolean

Requires the path to the destination file (where the link points) to be absolute. By default, the file linker resolves the destination file against the link directory.

Note: On Windows systems this option is ignored.

defaultSymlinkOptions

const : SymlinkOptions

No docs provided

openUrl (...)

async function openUrl (
   url : URL
) : Promise<void>

Opens the URL in the system's native browser.

@param:

url the URL to open

EventEmitter

class EventEmitter extends NodeEventEmitter

This class extends the functionality of Node's [import('events') EventEmitter](#import('events') EventEmitter) and adds some convenience functions to connect child processes and register process interrupt handlers.

Constructors

Properties

static readonly STOP_EVENT

Type: undefined

This symbol defines the stop event that are emitted once all connected child processes should be stopped.

Methods

connect (...)

function connect (
   childProcess : ChildProcess
) : () => ChildProcess

Connects the given child process to the event emitter. Once connected, the stop event automatically stops the child process and when the child process dies unexpectedly, it emits the stop event and stops all others connected child processes.

@param:

childProcess the child process that you want to connect to the event emitter

@return:

a function that disconnects the child process from the event emitter and returns the child process instance

stop (...)

function stop (
   signal ? : NodeJS.Signals
) : void

Explicitly stops all connected child processes.

@param:

signal an optional signal that should be sent to all processes

CompositeError

class CompositeError extends Error

A generic error that has an error message and an additional payload.

This error type can be used if you want to attach additional information to your error message.

For example:

try {
    await someMethodThatThrows();
} catch (err) {
    throw new CompositeError('Action xyz does not work', err);
}

Constructors

constructor

function (
   message : string ,
   original : unknown
) : any

No docs provided

Properties

getName (...)

async function getName (
   packageJson : Record<string, unknown>
) : Promise<string>

Searches for the package name in a parsed package.json JSON object.

@param:

packageJson - the parsed package.json JSON object

getDescription (...)

async function getDescription (
   packageJson : Record<string, unknown>
) : Promise<string>

Searches for the package description in a parsed package.json JSON object.

@param:

packageJson - the parsed package.json JSON object

getVersion (...)

async function getVersion (
   packageJson : Record<string, unknown>
) : Promise<string>

Searches for the package version in a parsed package.json JSON object.

@param:

packageJson - the parsed package.json JSON object

getBinaries (...)

async function getBinaries (
   packageJson : Record<string, unknown>
) : Promise<Record<string, string>>

Searches for exported binaries in a parsed package.json JSON object and returns an empty object if the package.json doesn't contain any exported binaries.

@param:

packageJson - the parsed package.json JSON object

getDependencies (...)

async function getDependencies (
   packageJson : Record<string, unknown>
) : Promise<Record<string, string>>

Searches for production dependencies in a parsed package.json JSON object and returns an empty object if the package.json doesn't contain any production dependencies.

@param:

packageJson - the parsed package.json JSON object

getDevDependencies (...)

async function getDevDependencies (
   packageJson : Record<string, unknown>
) : Promise<Record<string, string>>

Searches for development dependencies in a parsed package.json JSON object and returns an empty object if the package.json doesn't contain any development dependencies.

@param:

packageJson - the parsed package.json JSON object

getElectronDependencies (...)

async function getElectronDependencies (
   packageJson : Record<string, unknown>
) : Promise<string[]>

Searches for Electron dependencies in a parsed package.json JSON object and returns an empty array if the package.json doesn't contain any Electron dependencies.

@param:

packageJson - the parsed package.json JSON object

resolveElectronDependencies (...)

async function resolveElectronDependencies (
   packageJson : Record<string, unknown>
) : Promise<Record<string, string>>

Searches for production and Electron dependencies. The production dependencies are filtered through the Electron dependency list resulting in the final production dependencies that Electron needs in the main process.

@param:

packageJson - the parsed package.json JSON object

normalizeProjectName (...)

async function normalizeProjectName (
   prettyName : string
) : Promise<string>

Takes a pretty project name (e.g. from user input) and returns a valid npm project name.

@param:

prettyName - the pretty project name to transform

getPackageVersion (...)

function getPackageVersion ( ) : string

Returns the current version of the @wuespace/telestion-client-cli package.

packageRootPath

const : any

No docs provided

packageJsonPath

const : any

No docs provided

resourcesPath

const : any

No docs provided

wait (...)

async function wait (
   duration : number
) : Promise<void>

Returns a promise that waits the specified duration before it resolves.

@param:

duration - the duration to wait in milliseconds

lastAtLeast (...)

async function lastAtLeast < T > (
   minDuration : number ,
   promise : PromiseLike<T>
) : Promise<T>

Accepts a list of promises and minimal duration. If the provided promises resolve or reject faster than the minimal duration, the returned promise lasts the minimal duration.

@param:

minDuration - the minimal duration in milliseconds

@param:

promise - the promise to run

@return:

a new promise that resolves with the result from the passed promise

@see:

Promise.all

getPackagePath (...)

async function getPackagePath (
   packageName : string
) : Promise<string>

Searches for an installed package and returns an absolute path to its install location. Throws ERR_MODULE_NOT_FOUND if the package is not installed.

@param:

packageName - the name of the package to search for

getPSCConfig (...)

async function getPSCConfig ( ) : Promise<TelestionClientCLIConfig>

No docs provided

BaseOptions

interface BaseOptions

Every command receives this options by commander by default. Extend this interface if you've added more options to your command.

Properties

loglevel

Type: LogLevel

The current application loglevel.

workingDir

Type: string

The application working directory.

BaseWithPartial

type BaseWithPartial < T : BaseOptions >

Alias for: Omit< Partial<T>, keyof BaseOptions > & BaseOptions

Receives command options and make all options optional except the base options-

CommandBuilder

type CommandBuilder

Alias for: (command: Command) => void

A command builder receives the parent command and should attach his command, arguments and options on call.

BuildStartEvent

interface BuildStartEvent

No docs provided

Properties

type

Type: 'buildStart'

No docs provided

BuildProgressEvent

interface BuildProgressEvent

No docs provided

Properties

type

Type: 'buildProgress'

No docs provided

phase

Type: 'resolving' | 'transforming' | 'bundling' | 'packaging' | 'optimizing'

No docs provided

BuildSuccessEvent

interface BuildSuccessEvent

No docs provided

Properties

type

Type: 'buildSuccess'

No docs provided

buildTime

Type: number

No docs provided

numberOfBundles

Type: number

No docs provided

BuildFailureEvent

interface BuildFailureEvent

No docs provided

Properties

type

Type: 'buildFailure'

No docs provided

diagnostics

Type: Array<Diagnostic>

No docs provided

BuildEvent

type BuildEvent

Alias for: | BuildStartEvent | BuildProgressEvent | BuildSuccessEvent | BuildFailureEvent

Build events received by the @wuespace/parcel-reporter-tc-cli.

TelestionClientCLIConfig

type TelestionClientCLIConfig

Alias for: Partial< Omit<Options, 'dir' | 'platform' | 'arch'> & { /** * Whether the PSC should get packaged as an Electron app. */ electron: boolean; } >

No docs provided