Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ionic/cli-framework

Package Overview
Dependencies
Maintainers
15
Versions
203
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ionic/cli-framework - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

20

CHANGELOG.md

@@ -6,2 +6,22 @@ # Change Log

<a name="1.2.0"></a>
# [1.2.0](https://github.com/ionic-team/ionic-cli/compare/@ionic/cli-framework@1.1.1...@ionic/cli-framework@1.2.0) (2018-10-31)
### Bug Fixes
* **config:** write json file with ending newline ([dc3f2a5](https://github.com/ionic-team/ionic-cli/commit/dc3f2a5))
* **help:** filter out unnecessary global options ([7809c99](https://github.com/ionic-team/ionic-cli/commit/7809c99))
* **process:** keep node running for `sleepForever()` ([ea08f8d](https://github.com/ionic-team/ionic-cli/commit/ea08f8d))
### Features
* **namespace:** add `useAliases` option to `locate()` ([489617b](https://github.com/ionic-team/ionic-cli/commit/489617b))
* **object:** add `keysWithoutAliases()` method to `AliasedMap` ([f4807f4](https://github.com/ionic-team/ionic-cli/commit/f4807f4))
* **terminal:** detect windows shell ([dcc912d](https://github.com/ionic-team/ionic-cli/commit/dcc912d))
<a name="1.1.1"></a>

@@ -8,0 +28,0 @@ ## [1.1.1](https://github.com/ionic-team/ionic-cli/compare/@ionic/cli-framework@1.1.0...@ionic/cli-framework@1.1.1) (2018-10-05)

5

definitions.d.ts

@@ -60,6 +60,9 @@ /// <reference types="node" />

export declare type INamespaceMap<C extends ICommand<C, N, M, I, O>, N extends INamespace<C, N, M, I, O>, M extends CommandMetadata<I, O>, I extends CommandMetadataInput, O extends CommandMetadataOption> = ζobject.AliasedMap<string, NamespaceMapGetter<C, N, M, I, O>>;
export interface NamespaceLocateOptions {
useAliases?: boolean;
}
export interface INamespace<C extends ICommand<C, N, M, I, O>, N extends INamespace<C, N, M, I, O>, M extends CommandMetadata<I, O>, I extends CommandMetadataInput, O extends CommandMetadataOption> {
root: N;
parent: N | undefined;
locate(argv: ReadonlyArray<string>): Promise<NamespaceLocateResult<C, N, M, I, O>>;
locate(argv: ReadonlyArray<string>, options?: NamespaceLocateOptions): Promise<NamespaceLocateResult<C, N, M, I, O>>;
getMetadata(): Promise<NamespaceMetadata>;

@@ -66,0 +69,0 @@ getNamespaces(): Promise<INamespaceMap<C, N, M, I, O>>;

@@ -1,2 +0,2 @@

import { CommandInstanceInfo, CommandLineInputs, CommandLineOptions, CommandMapGetter, CommandMetadata, CommandMetadataInput, CommandMetadataOption, CommandPathItem, HydratedCommandMetadata, HydratedNamespaceMetadata, ICommand, ICommandMap, INamespace, INamespaceMap, NamespaceLocateResult, NamespaceMapGetter, NamespaceMetadata } from '../definitions';
import { CommandInstanceInfo, CommandLineInputs, CommandLineOptions, CommandMapGetter, CommandMetadata, CommandMetadataInput, CommandMetadataOption, CommandPathItem, HydratedCommandMetadata, HydratedNamespaceMetadata, ICommand, ICommandMap, INamespace, INamespaceMap, NamespaceLocateOptions, NamespaceLocateResult, NamespaceMapGetter, NamespaceMetadata } from '../definitions';
import { AliasedMap } from '../utils/object';

@@ -39,3 +39,3 @@ export declare abstract class BaseCommand<C extends ICommand<C, N, M, I, O>, N extends INamespace<C, N, M, I, O>, M extends CommandMetadata<I, O>, I extends CommandMetadataInput, O extends CommandMetadataOption> {

*/
locate(argv: ReadonlyArray<string>): Promise<NamespaceLocateResult<C, N, M, I, O>>;
locate(argv: ReadonlyArray<string>, { useAliases }?: NamespaceLocateOptions): Promise<NamespaceLocateResult<C, N, M, I, O>>;
/**

@@ -63,1 +63,2 @@ * Get all command metadata in a flat structure.

export declare function generateCommandPath<C extends ICommand<C, N, M, I, O>, N extends INamespace<C, N, M, I, O>, M extends CommandMetadata<I, O>, I extends CommandMetadataInput, O extends CommandMetadataOption>(cmd: C): Promise<CommandPathItem<C, N, M, I, O>[]>;
export declare function isCommandVisible<C extends ICommand<C, N, M, I, O>, N extends INamespace<C, N, M, I, O>, M extends CommandMetadata<I, O>, I extends CommandMetadataInput, O extends CommandMetadataOption>(cmd: HydratedCommandMetadata<C, N, M, I, O>): Promise<boolean>;

18

lib/command.js

@@ -8,2 +8,3 @@ "use strict";

const string_1 = require("../utils/string");
const options_1 = require("./options");
const validators_1 = require("./validators");

@@ -89,3 +90,3 @@ class BaseCommand {

*/
locate(argv) {
locate(argv, { useAliases = true } = {}) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {

@@ -95,7 +96,7 @@ const _locate = (inputs, parent, path) => tslib_1.__awaiter(this, void 0, void 0, function* () {

const children = yield parent.getNamespaces();
const nsgetter = children.resolveAliases(key);
if (!nsgetter) {
const nsgetter = useAliases ? children.resolveAlias(key) : children.get(key);
if (!nsgetter || typeof nsgetter === 'string' || typeof nsgetter === 'symbol') {
const commands = yield parent.getCommands();
const cmdgetter = commands.resolveAliases(key);
if (cmdgetter) {
const cmdgetter = useAliases ? commands.resolveAlias(key) : commands.get(key);
if (cmdgetter && typeof cmdgetter !== 'string' && typeof cmdgetter !== 'symbol') {
const cmd = yield cmdgetter();

@@ -237,1 +238,8 @@ return { args: inputs.slice(1), obj: cmd, path: [...path, [key, cmd]] };

exports.generateCommandPath = generateCommandPath;
function isCommandVisible(cmd) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const ns = yield cmd.namespace.getMetadata();
return (!cmd.groups || !cmd.groups.includes(options_1.CommandGroup.Hidden)) && (!ns.groups || !ns.groups.includes(options_1.NamespaceGroup.Hidden));
});
}
exports.isCommandVisible = isCommandVisible;

@@ -38,3 +38,3 @@ "use strict";

utils_fs_1.mkdirpSync(path.dirname(this.p));
writeFileAtomic.sync(this.p, JSON.stringify(v, undefined, 2));
writeFileAtomic.sync(this.p, JSON.stringify(v, undefined, 2) + '\n');
}

@@ -41,0 +41,0 @@ get(property, defaultValue) {

@@ -29,3 +29,3 @@ import { CommandMetadata, CommandMetadataInput, CommandMetadataOption, HydratedCommandMetadata, HydratedNamespaceMetadata, ICommand, INamespace, NamespaceLocateResult, NamespaceMetadata } from '../definitions';

*/
filterCommandCallback?(meta: HydratedCommandMetadata<C, N, M, I, O>): Promise<boolean>;
filterCommandCallback(meta: HydratedCommandMetadata<C, N, M, I, O>): Promise<boolean>;
getNamespaceMetadata(): Promise<NamespaceMetadata>;

@@ -59,3 +59,3 @@ getNamespaceFullName(): Promise<string>;

formatDescription(): Promise<string>;
getExtraOptions(): Promise<string[]>;
getGlobalOptions(): Promise<string[]>;
formatUsage(): Promise<string>;

@@ -105,3 +105,3 @@ formatCommands(): Promise<string>;

*/
filterOptionCallback?(option: O): Promise<boolean>;
filterOptionCallback(option: O): Promise<boolean>;
getCommandMetadata(): Promise<M | HydratedCommandMetadata<C, N, M, I, O>>;

@@ -186,6 +186,2 @@ getCommandFullName(): Promise<string>;

}
export declare function formatOptionName<O extends CommandMetadataOption>(opt: O, { showAliases, colors }?: {
showAliases?: boolean;
colors?: Colors;
}): string;
export declare function createCommandMetadataFromSchema(schema: CommandHelpSchema): Required<CommandMetadata>;

@@ -9,2 +9,4 @@ "use strict";

const colors_1 = require("./colors");
const command_1 = require("./command");
const options_1 = require("./options");
const validators_1 = require("./validators");

@@ -25,2 +27,14 @@ const DEFAULT_DOTS_WIDTH = 25;

}
/**
* Given command metadata, decide whether to keep or discard the command that
* the metadata represents.
*
* @param meta: The metadata of the command.
* @return `true` to keep, `false` to discard
*/
filterCommandCallback(meta) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return command_1.isCommandVisible(meta);
});
}
getNamespaceMetadata() {

@@ -75,3 +89,3 @@ return tslib_1.__awaiter(this, void 0, void 0, function* () {

}
getExtraOptions() {
getGlobalOptions() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {

@@ -85,3 +99,3 @@ return [];

const fullName = yield this.getNamespaceFullName();
const options = ['--help', ...(yield this.getExtraOptions())];
const options = ['--help', ...(yield this.getGlobalOptions())];
const usageLines = [

@@ -103,4 +117,3 @@ `<command> ${weak('[<args>]')} ${options.map(opt => weak('[' + opt + ']')).join(' ')} ${weak('[options]')}`,

const { strong } = this.colors;
const filterCallback = this.filterCommandCallback;
const filteredCommands = filterCallback ? yield array_1.filter(commands, (cmd) => tslib_1.__awaiter(this, void 0, void 0, function* () { return filterCallback(cmd); })) : commands;
const filteredCommands = yield array_1.filter(commands, (cmd) => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.filterCommandCallback(cmd); }));
const [cmdDetails, nsDetails] = yield Promise.all([

@@ -194,2 +207,13 @@ this.getListOfCommandDetails(filteredCommands.filter(cmd => cmd.namespace === this.namespace)),

}
/**
* Given an option definition from command metadata, decide whether to keep
* or discard it.
*
* @return `true` to keep, `false` to discard
*/
filterOptionCallback(option) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return options_1.isOptionVisible(option);
});
}
getCommandMetadata() {

@@ -260,5 +284,4 @@ return tslib_1.__awaiter(this, void 0, void 0, function* () {

const metadata = yield this.getCommandMetadata();
const filterCallback = this.filterOptionCallback;
const options = metadata.options ? metadata.options : [];
const filteredOptions = filterCallback ? yield array_1.filter(options, (opt) => tslib_1.__awaiter(this, void 0, void 0, function* () { return filterCallback(opt); })) : options;
const filteredOptions = yield array_1.filter(options, (opt) => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.filterOptionCallback(opt); }));
const formattedInputs = metadata.inputs ? yield Promise.all(metadata.inputs.map((i) => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.formatInlineInput(i); }))) : [];

@@ -290,3 +313,3 @@ return (`\n ${strong('Usage')}:` +

const { weak } = this.colors;
const optionName = formatOptionName(opt, { colors: this.colors });
const optionName = options_1.formatOptionName(opt, { colors: this.colors });
const optionNameLength = format_1.stringWidth(optionName);

@@ -327,4 +350,3 @@ const fullLength = optionNameLength > this.dotswidth ? optionNameLength + 1 : this.dotswidth;

const { strong } = this.colors;
const filterCallback = this.filterOptionCallback;
const filteredOptions = filterCallback ? yield array_1.filter(options, (opt) => tslib_1.__awaiter(this, void 0, void 0, function* () { return filterCallback(opt); })) : options;
const filteredOptions = yield array_1.filter(options, (opt) => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.filterOptionCallback(opt); }));
if (filteredOptions.length === 0) {

@@ -390,4 +412,3 @@ return '';

return tslib_1.__awaiter(this, void 0, void 0, function* () {
const filterCallback = this.filterCommandCallback;
const filteredCommands = filterCallback ? yield array_1.filter(commands, (cmd) => tslib_1.__awaiter(this, void 0, void 0, function* () { return filterCallback(cmd); })) : commands;
const filteredCommands = yield array_1.filter(commands, (cmd) => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.filterCommandCallback(cmd); }));
return array_1.map(filteredCommands, (cmd) => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.formatCommand(cmd); }));

@@ -436,4 +457,3 @@ });

return tslib_1.__awaiter(this, void 0, void 0, function* () {
const filterCallback = this.filterOptionCallback;
const filteredOptions = filterCallback ? yield array_1.filter(options, (opt) => tslib_1.__awaiter(this, void 0, void 0, function* () { return filterCallback(opt); })) : options;
const filteredOptions = yield array_1.filter(options, (opt) => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.filterOptionCallback(opt); }));
return Promise.all(filteredOptions.map((opt) => tslib_1.__awaiter(this, void 0, void 0, function* () { return this.formatOption(opt); })));

@@ -469,12 +489,2 @@ });

exports.CommandSchemaHelpFormatter = CommandSchemaHelpFormatter;
function formatOptionName(opt, { showAliases = true, colors = colors_1.DEFAULT_COLORS } = {}) {
const { input } = colors;
const showInverse = opt.type === Boolean && opt.default === true && opt.name.length > 1;
return ((showInverse ? input(`--no-${opt.name}`) : input(`-${opt.name.length > 1 ? '-' : ''}${opt.name}`)) +
(showAliases ?
(!showInverse && opt.aliases && opt.aliases.length > 0 ? ', ' + opt.aliases
.map(alias => input(`-${alias}`))
.join(', ') : '') : ''));
}
exports.formatOptionName = formatOptionName;
function createCommandMetadataFromSchema(schema) {

@@ -481,0 +491,0 @@ return {

import * as minimist from 'minimist';
import { CommandLineOptions, CommandMetadataOption, HydratedCommandMetadataOption, HydratedParseArgsOptions, ParsedArg } from '../definitions';
import { Colors } from './colors';
export declare const parseArgs: typeof minimist;

@@ -48,2 +49,8 @@ export { ParsedArgs } from 'minimist';

export declare function hydrateCommandMetadataOption<O extends CommandMetadataOption>(option: O): HydratedCommandMetadataOption<O>;
export interface FormatOptionNameOptions {
readonly showAliases?: boolean;
readonly colors?: Colors | false;
}
export declare function formatOptionName<O extends CommandMetadataOption>(opt: O, { showAliases, colors }?: FormatOptionNameOptions): string;
export declare function isOptionVisible<O extends CommandMetadataOption>(opt: O): Promise<boolean>;
export declare function metadataOptionsToParseArgsOptions(commandOptions: ReadonlyArray<CommandMetadataOption>): HydratedParseArgsOptions;

@@ -50,0 +57,0 @@ export declare type OptionPredicate<O extends CommandMetadataOption> = (option: O, value?: ParsedArg) => boolean;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const lodash = require("lodash");
const minimist = require("minimist");
const colors_1 = require("./colors");
exports.parseArgs = minimist;

@@ -80,2 +82,18 @@ var CommandGroup;

exports.hydrateCommandMetadataOption = hydrateCommandMetadataOption;
function formatOptionName(opt, { showAliases = true, colors = colors_1.DEFAULT_COLORS } = {}) {
const colorfn = colors ? colors.input : lodash.identity;
const showInverse = opt.type === Boolean && opt.default === true && opt.name.length > 1;
return ((showInverse ? colorfn(`--no-${opt.name}`) : colorfn(`-${opt.name.length > 1 ? '-' : ''}${opt.name}`)) +
(showAliases ?
(!showInverse && opt.aliases && opt.aliases.length > 0 ? ', ' + opt.aliases
.map(alias => colorfn(`-${alias}`))
.join(', ') : '') : ''));
}
exports.formatOptionName = formatOptionName;
function isOptionVisible(opt) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return !opt.groups || !opt.groups.includes(OptionGroup.Hidden);
});
}
exports.isOptionVisible = isOptionVisible;
function metadataOptionsToParseArgsOptions(commandOptions) {

@@ -82,0 +100,0 @@ const options = {

{
"name": "@ionic/cli-framework",
"version": "1.1.1",
"version": "1.2.0",
"description": "The foundation framework of the Ionic CLI",

@@ -17,5 +17,4 @@ "homepage": "https://ionicframework.com/",

"watch": "tsc -w --preserveWatchOutput",
"test": "jest",
"prepublishOnly": "npm run build",
"cli-scripts:pre-commit": "lint-staged"
"test": "jest --maxWorkers=4",
"prepublishOnly": "npm run build"
},

@@ -32,3 +31,3 @@ "lint-staged": {

"dependencies": {
"@ionic/utils-fs": "0.0.3",
"@ionic/utils-fs": "0.0.4",
"chalk": "^2.3.0",

@@ -40,3 +39,3 @@ "debug": "^4.0.0",

"rimraf": "^2.6.2",
"slice-ansi": "^1.0.0",
"slice-ansi": "^2.0.0",
"stream-combiner2": "^1.1.1",

@@ -55,2 +54,3 @@ "string-width": "^2.1.1",

"@types/inquirer": "0.0.43",
"@types/jest": "^23.3.5",
"@types/lodash": "^4.14.104",

@@ -67,4 +67,4 @@ "@types/minimist": "^1.2.0",

"jest-cli": "^23.0.1",
"lint-staged": "^7.2.0",
"ts-jest": "~23.1.0",
"lint-staged": "^8.0.0",
"ts-jest": "^23.10.1",
"tslint": "^5.9.1",

@@ -71,0 +71,0 @@ "typescript": "~3.1.1"

@@ -8,3 +8,4 @@ export declare function createCaseInsensitiveObject<T>(): {

getAliases(): Map<AliasedMapKey, AliasedMapKey[]>;
resolveAliases(key: AliasedMapKey | K): V | undefined;
resolveAlias(key: AliasedMapKey | K): V | undefined;
keysWithoutAliases(): K[];
}

@@ -35,3 +35,3 @@ "use strict";

}
resolveAliases(key) {
resolveAlias(key) {
const r = this.get(key);

@@ -41,5 +41,10 @@ if (typeof r !== 'string' && typeof r !== 'symbol') {

}
return this.resolveAliases(r);
return this.resolveAlias(r);
}
keysWithoutAliases() {
return [...this.entries()]
.filter((entry) => typeof entry[1] !== 'string' && typeof entry[1] !== 'symbol')
.map(([k, v]) => k);
}
}
exports.AliasedMap = AliasedMap;

@@ -6,6 +6,6 @@ export declare const ERROR_TIMEOUT_REACHED = "TIMEOUT_REACHED";

*
* On Windows, `process.env` is a magic object that offers case-insensitive
* environment variable access. On other platforms, case sensitivity matters.
* This method creates an empty "`process.env`" object type that works for all
* platforms.
* On a Windows shell, `process.env` is a magic object that offers
* case-insensitive environment variable access. On other platforms, case
* sensitivity matters. This method creates an empty "`process.env`" object
* type that works for all platforms.
*/

@@ -35,3 +35,3 @@ export declare function createProcessEnv(...sources: {

/**
* Never resolves.
* Never resolves and keeps Node running.
*/

@@ -38,0 +38,0 @@ export declare function sleepForever(): Promise<never>;

@@ -8,2 +8,3 @@ "use strict";

const object_1 = require("./object");
const terminal_1 = require("./terminal");
const debug = Debug('ionic:cli-framework:utils:process');

@@ -26,9 +27,9 @@ exports.ERROR_TIMEOUT_REACHED = 'TIMEOUT_REACHED';

*
* On Windows, `process.env` is a magic object that offers case-insensitive
* environment variable access. On other platforms, case sensitivity matters.
* This method creates an empty "`process.env`" object type that works for all
* platforms.
* On a Windows shell, `process.env` is a magic object that offers
* case-insensitive environment variable access. On other platforms, case
* sensitivity matters. This method creates an empty "`process.env`" object
* type that works for all platforms.
*/
function createProcessEnv(...sources) {
return lodash.assign(process.platform === 'win32' ? object_1.createCaseInsensitiveObject() : {}, ...sources);
return lodash.assign(terminal_1.TERMINAL_INFO.windows ? object_1.createCaseInsensitiveObject() : {}, ...sources);
}

@@ -70,7 +71,9 @@ exports.createProcessEnv = createProcessEnv;

/**
* Never resolves.
* Never resolves and keeps Node running.
*/
function sleepForever() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return new Promise(() => { });
return new Promise(() => {
setInterval(() => { }, 1000);
});
});

@@ -77,0 +80,0 @@ }

@@ -8,5 +8,15 @@ /**

export interface TerminalInfo {
/**
* Whether the terminal is an interactive TTY or not.
*/
readonly tty: boolean;
/**
* Whether this is in CI or not.
*/
readonly ci: boolean;
/**
* Whether this is a Windows shell or not.
*/
readonly windows: boolean;
}
export declare const TERMINAL_INFO: TerminalInfo;

@@ -17,2 +17,3 @@ "use strict";

ci: exports.CI_ENVIRONMENT_VARIABLES_DETECTED.length > 0,
windows: process.platform === 'win32' && (process.env.MSYSTEM && /^MINGW(32|64)$/.test(process.env.MSYSTEM) || process.env.TERM === 'cygwin'),
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc