New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

clime

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clime - npm Package Compare versions

Comparing version 0.5.9 to 0.5.10

2

bld/castable/array.js

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

});
return yield v.map(parts, part => __1.cast(part, type, castingContext));
return v.map(parts, part => __1.cast(part, type, castingContext));
});

@@ -35,0 +35,0 @@ },

@@ -58,2 +58,27 @@ /// <reference types="node" />

private executeCommand(command, commandArgs, commandExtraArgs, commandOptions, context);
/**
* The name of the default sub-command module.
*
* E.g.:
*
* ```ts
* import {CLI} from 'clime';
*
* CLI.commandModuleDefaultName = 'mySpecialDefaultName';
* ```
*/
static commandModuleDefaultName: string;
/**
* The extension to use when looking up sub-command modules.
*
* E.g.:
*
* ```ts
* import {CLI} from 'clime';
*
* CLI.commandModuleExtension = '.cjs'
* ```
*/
static commandModuleExtension: string;
static readonly commandModuleDefaultFileName: string;
private static findEntryBySearchBase(searchBase);

@@ -60,0 +85,0 @@ }

@@ -24,6 +24,6 @@ "use strict";

constructor(
/** Command entry name. */
name,
/** Root directory of command modules. */
roots) {
/** Command entry name. */
name,
/** Root directory of command modules. */
roots) {
this.name = name;

@@ -77,7 +77,7 @@ roots = Array.isArray(roots) ? roots : [roots];

if (!parsedArgs) {
return yield command_1.HelpInfo.build(TargetCommand);
return command_1.HelpInfo.build(TargetCommand);
}
let command = new TargetCommand();
let { args: commandArgs, extraArgs: commandExtraArgs, options: commandOptions, context, } = parsedArgs;
return yield this.executeCommand(command, commandArgs, commandExtraArgs, commandOptions, context);
return this.executeCommand(command, commandArgs, commandExtraArgs, commandOptions, context);
}

@@ -120,3 +120,3 @@ else {

definitionMap.set(definition.name, definition);
let aliases = definition.aliases || definition.alias && [definition.alias];
let aliases = definition.aliases || (definition.alias && [definition.alias]);
if (!aliases) {

@@ -137,4 +137,5 @@ continue;

}
possibleCommandName = definitionMap.has(possibleCommandName) ?
possibleCommandName : aliasMap.get(possibleCommandName) || possibleCommandName;
possibleCommandName = definitionMap.has(possibleCommandName)
? possibleCommandName
: aliasMap.get(possibleCommandName) || possibleCommandName;
searchBase = Path.join(searchBase, possibleCommandName);

@@ -161,3 +162,3 @@ let entry = yield CLI.findEntryBySearchBase(searchBase);

let contexts = yield v.map(this.roots, (root) => __awaiter(this, void 0, void 0, function* () {
let path = Path.join(root.path, 'default.js');
let path = Path.join(root.path, CLI.commandModuleDefaultFileName);
path = (yield internal_util_1.existsFile(path)) ? path : undefined;

@@ -232,2 +233,5 @@ let module;

}
static get commandModuleDefaultFileName() {
return `${this.commandModuleDefaultName}${this.commandModuleExtension}`;
}
/**

@@ -249,4 +253,4 @@ * @internal

let possiblePaths = [
`${searchBase}.js`,
Path.join(searchBase, 'default.js'),
`${searchBase}${this.commandModuleExtension}`,
Path.join(searchBase, this.commandModuleDefaultFileName),
];

@@ -271,2 +275,26 @@ for (let possiblePath of possiblePaths) {

}
/**
* The name of the default sub-command module.
*
* E.g.:
*
* ```ts
* import {CLI} from 'clime';
*
* CLI.commandModuleDefaultName = 'mySpecialDefaultName';
* ```
*/
CLI.commandModuleDefaultName = 'default';
/**
* The extension to use when looking up sub-command modules.
*
* E.g.:
*
* ```ts
* import {CLI} from 'clime';
*
* CLI.commandModuleExtension = '.cjs'
* ```
*/
CLI.commandModuleExtension = '.js';
exports.CLI = CLI;

@@ -286,3 +314,3 @@ class ArgsParser {

for (let definition of this.optionDefinitions) {
let { name, flag, } = definition;
let { name, flag } = definition;
this.optionDefinitionMap.set(name, definition);

@@ -328,5 +356,6 @@ if (flag) {

else {
commandOptions[key] = typeof defaultValue === 'string' ?
yield castArgument(defaultValue, name, type, validators, true) :
defaultValue;
commandOptions[key] =
typeof defaultValue === 'string'
? yield castArgument(defaultValue, name, type, validators, true)
: defaultValue;
}

@@ -379,5 +408,5 @@ }

let defaultValue = definition.default;
let value = typeof defaultValue === 'string' ?
yield castArgument(defaultValue, definition.name, definition.type, definition.validators, true) :
defaultValue;
let value = typeof defaultValue === 'string'
? yield castArgument(defaultValue, definition.name, definition.type, definition.validators, true)
: defaultValue;
commandArgs.push(value);

@@ -439,3 +468,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
let { name, key, type, validators, } = definition;
let { name, key, type, validators } = definition;
let arg = args.shift();

@@ -458,3 +487,3 @@ if (arg === undefined) {

});
return yield object_1.cast(arg, type, castingContext);
return object_1.cast(arg, type, castingContext);
});

@@ -461,0 +490,0 @@ }

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

class Context {
constructor({ cwd, commands, }) {
constructor({ cwd, commands }) {
this.cwd = cwd;

@@ -32,3 +32,3 @@ this.commands = commands;

return __awaiter(this, void 0, void 0, function* () {
return yield _1.HelpInfo.build(this);
return _1.HelpInfo.build(this);
});

@@ -78,3 +78,4 @@ }

}
if (paramsDefinition && paramsDefinition.index !== paramDefinitions.length) {
if (paramsDefinition &&
paramsDefinition.index !== paramDefinitions.length) {
throw new Error('Expecting variadic parameters to be adjacent to other parameters');

@@ -91,3 +92,4 @@ }

let contextConstructorCandidateIndex;
if (optionsConstructorCandidate && optionsConstructorCandidate.prototype instanceof _1.Options) {
if (optionsConstructorCandidate &&
optionsConstructorCandidate.prototype instanceof _1.Options) {
target.optionsConstructor = optionsConstructorCandidate;

@@ -101,4 +103,5 @@ target.optionDefinitions = optionsConstructorCandidate.definitions;

let contextConstructorCandidate = types[contextConstructorCandidateIndex];
if (contextConstructorCandidate && (contextConstructorCandidate === Context ||
contextConstructorCandidate.prototype instanceof Context)) {
if (contextConstructorCandidate &&
(contextConstructorCandidate === Context ||
contextConstructorCandidate.prototype instanceof Context)) {
target.contextConstructor = contextConstructorCandidate;

@@ -105,0 +108,0 @@ }

@@ -25,3 +25,3 @@ /// <reference types="node" />

buildTextForSubCommands(contexts: HelpBuildingContext[]): Promise<void>;
print(stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream): void;
print(_stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream): void;
private buildDescription(description);

@@ -28,0 +28,0 @@ private buildSubcommandsUsage(sequence);

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

let { name, brief } = definition;
let aliases = definition.aliases || definition.alias && [definition.alias] || [];
let aliases = definition.aliases || (definition.alias && [definition.alias]) || [];
let item;

@@ -74,9 +74,10 @@ let existingItem = helpItemMap.get(name);

if (stats.isFile()) {
if (name === 'default.js' || Path.extname(path) !== '.js') {
if (name === cli_1.CLI.commandModuleDefaultFileName ||
Path.extname(path) !== cli_1.CLI.commandModuleExtension) {
continue;
}
name = Path.basename(name, '.js');
name = Path.basename(name, cli_1.CLI.commandModuleExtension);
}
else {
path = Path.join(path, 'default.js');
path = Path.join(path, cli_1.CLI.commandModuleDefaultFileName);
stats = yield internal_util_1.safeStat(path);

@@ -86,3 +87,5 @@ }

// `brief` already set in `subcommands` field
if (existingItem && existingItem.group === groupIndex && existingItem.brief) {
if (existingItem &&
existingItem.group === groupIndex &&
existingItem.brief) {
continue;

@@ -95,3 +98,5 @@ }

commandConstructor = module.default;
brief = commandConstructor && (commandConstructor.brief || commandConstructor.description);
brief =
commandConstructor &&
(commandConstructor.brief || commandConstructor.description);
}

@@ -130,4 +135,3 @@ if (existingItem && existingItem.group === groupIndex) {

let hasAliases = false;
let rows = labelToHelpItemsMap
.get(label)
let rows = labelToHelpItemsMap.get(label)
.filter(item => {

@@ -151,6 +155,3 @@ if (item.overridden) {

else {
return [
Chalk.bold(name),
brief,
];
return [Chalk.bold(name), brief];
}

@@ -167,3 +168,3 @@ });

}
print(stdout, stderr) {
print(_stdout, stderr) {
stderr.write(`\n${this.text}\n`);

@@ -190,12 +191,9 @@ }

parameterUsageTexts = paramDefinitions.map(definition => {
let { name, required, description, default: defaultValue, } = definition;
let { name, required, description, default: defaultValue } = definition;
if (description) {
parameterDescriptionRows.push([
Chalk.bold(name),
description,
]);
parameterDescriptionRows.push([Chalk.bold(name), description]);
}
return required ?
`<${name}>` :
`[${name}${defaultValue !== undefined ? `=${defaultValue}` : ''}]`;
return required
? `<${name}>`
: `[${name}${defaultValue !== undefined ? `=${defaultValue}` : ''}]`;
});

@@ -207,12 +205,7 @@ }

if (paramsDefinition) {
let { name, required, description, } = paramsDefinition;
let { name, required, description } = paramsDefinition;
if (description) {
parameterDescriptionRows.push([
Chalk.bold(name),
description,
]);
parameterDescriptionRows.push([Chalk.bold(name), description]);
}
parameterUsageTexts.push(required ?
`<...${name}>` :
`[...${name}]`);
parameterUsageTexts.push(required ? `<...${name}>` : `[...${name}]`);
}

@@ -240,5 +233,4 @@ let optionDefinitions = TargetCommand.optionDefinitions || [];

if (optionDefinitions.length) {
let optionRows = optionDefinitions
.map(definition => {
let { name, key, flag, placeholder, toggle: isToggle, description, } = definition;
let optionRows = optionDefinitions.map(definition => {
let { name, key, flag, placeholder, toggle: isToggle, description, default: defaultValue, } = definition;
let triggerStr = flag ? `-${flag}, ` : '';

@@ -249,6 +241,8 @@ triggerStr += `--${name}`;

}
return [
Chalk.bold(triggerStr),
description,
];
if (defaultValue !== undefined) {
description = description
? `${description} [${defaultValue}]`
: `[${defaultValue}]`;
}
return [Chalk.bold(triggerStr), description];
});

@@ -255,0 +249,0 @@ this.texts.push(`\

@@ -25,3 +25,5 @@ "use strict";

}
type = type || Reflect.getMetadata('design:type', target, name);
type =
type ||
Reflect.getMetadata('design:type', target, name);
optionName = optionName || hyphenate_1.default(name, { lowerCase: true });

@@ -28,0 +30,0 @@ if (!validators) {

@@ -23,7 +23,11 @@ "use strict";

}
type = type ||
Reflect.getMetadata('design:paramtypes', target, 'execute')[index];
paramName = paramName ||
// tslint:disable-next-line:no-unbound-method
hyphenate_1.default(internal_util_1.Reflection.getFunctionParameterName(target.execute, index), { lowerCase: true });
type =
type ||
Reflect.getMetadata('design:paramtypes', target, 'execute')[index];
paramName =
paramName ||
// tslint:disable-next-line:no-unbound-method
hyphenate_1.default(internal_util_1.Reflection.getFunctionParameterName(target.execute, index), {
lowerCase: true,
});
if (!validators) {

@@ -30,0 +34,0 @@ validators = validator ? [validator] : [];

@@ -17,5 +17,8 @@ "use strict";

}
paramName = paramName ||
// tslint:disable-next-line:no-unbound-method
hyphenate_1.default(internal_util_1.Reflection.getFunctionParameterName(target.execute, index), { lowerCase: true });
paramName =
paramName ||
// tslint:disable-next-line:no-unbound-method
hyphenate_1.default(internal_util_1.Reflection.getFunctionParameterName(target.execute, index), {
lowerCase: true,
});
if (!validators) {

@@ -22,0 +25,0 @@ validators = validator ? [validator] : [];

@@ -7,3 +7,3 @@ /// <reference types="node" />

constructor(message: string, code?: number);
print(stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream): void;
print(_stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream): void;
}

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

}
print(stdout, stderr) {
print(_stdout, stderr) {
let output = `${Chalk.dim.red('ERR')} ${this.message}.\n`;

@@ -13,0 +13,0 @@ stderr.write(output);

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

function isStringCastable(object) {
return !!object && !!object.cast && typeof object.cast === 'function';
return (!!object &&
!!object.cast &&
typeof object.cast === 'function');
}

@@ -24,3 +26,3 @@ exports.isStringCastable = isStringCastable;

let value;
let { name, validators, default: usingDefault, } = context;
let { name, validators, default: usingDefault } = context;
switch (type) {

@@ -47,3 +49,4 @@ case String:

if (!isStringCastable(type)) {
throw new Error(`Type \`${type.name || type}\` cannot be casted from a string, \
throw new Error(`Type \`${type.name ||
type}\` cannot be casted from a string, \
see \`StringCastable\` interface for more information`);

@@ -50,0 +53,0 @@ }

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

return __awaiter(this, void 0, void 0, function* () {
return yield v.call(FS.stat, path).catch(v.bear);
return v.call(FS.stat, path).catch(v.bear);
});

@@ -18,0 +18,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function parseFunctionParameterNames(fn) {
let groups = fn
.toString()
.match(/^[^{=]*\(([\w\d$-,\s]*)\)/);
let groups = fn.toString().match(/^[^{=]*\(([\w\d$-,\s]*)\)/);
return groups ? groups[1].trim().split(/\s*,\s*/) : undefined;

@@ -18,5 +16,5 @@ }

}
return paramNames && paramNames[index] || `param${index}`;
return (paramNames && paramNames[index]) || `param${index}`;
}
exports.getFunctionParameterName = getFunctionParameterName;
//# sourceMappingURL=reflection.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const stripAnsi = require("strip-ansi");
function buildTableOutput(rows, { separators = ' ', indent = 0, } = {}) {
function buildTableOutput(rows, { separators = ' ', indent = 0 } = {}) {
let maxTextLengths = [];

@@ -23,7 +23,6 @@ for (let row of rows) {

}
let indentStr = typeof indent === 'string' ?
indent :
new Array(indent + 1).join(' ');
let indentStr = typeof indent === 'string' ? indent : new Array(indent + 1).join(' ');
return (
// tslint:disable-next-line:prefer-template
return rows
rows
.map(row => {

@@ -48,12 +47,12 @@ let line = indentStr;

})
.join('\n') + '\n';
.join('\n') + '\n');
}
exports.buildTableOutput = buildTableOutput;
function indent(text, indent) {
let indentStr = typeof indent === 'string' ?
indent.replace(/\r/g, '') :
Array(indent + 1).join(' ');
return text.replace(/^/mg, indentStr);
let indentStr = typeof indent === 'string'
? indent.replace(/\r/g, '')
: Array(indent + 1).join(' ');
return text.replace(/^/gm, indentStr);
}
exports.indent = indent;
//# sourceMappingURL=string.js.map
{
"name": "clime",
"version": "0.5.9",
"version": "0.5.10",
"description": "The command-line interface framework for TypeScript.",

@@ -8,3 +8,3 @@ "main": "bld/index.js",

"scripts": {
"lint": "tslint -c tslint.json -p tsconfig.json --type-check",
"lint": "tslint -c tslint.json -p tsconfig.json",
"build": "yarn lint && rimraf bld && tsc",

@@ -56,9 +56,10 @@ "bare-test": "mocha && baseman run bld/test/baseman",

"nyc": "^11.1.0",
"prettier": "^1.10.2",
"rimraf": "^2.6.1",
"source-map-support": "^0.4.16",
"tslint": "^5.6.0",
"tslint-language-service": "^0.9.6",
"typescript": "^2.6.1",
"vts": "^5.6.1"
"tslint": "^5.9.1",
"tslint-language-service": "^0.9.8",
"typescript": "^2.7.2",
"vts": "^5.8.3"
}
}

@@ -11,6 +11,6 @@ [![NPM Package](https://badge.fury.io/js/clime.svg)](https://www.npmjs.com/package/clime)

- Node.js 6+
- TypeScript compilation options in `tsconfig.json`
- `target` needs to be set as `'es6'` / `'es2015'` or higher.
- `experimentalDecorators` and `emitDecoratorMetadata` should both be enabled.
* Node.js 6+
* TypeScript compilation options in `tsconfig.json`
* `target` needs to be set as `'es6'` / `'es2015'` or higher.
* `experimentalDecorators` and `emitDecoratorMetadata` should both be enabled.

@@ -35,3 +35,3 @@ ## Install

import * as Path from 'path';
import { CLI, Shim } from 'clime';
import {CLI, Shim} from 'clime';

@@ -50,7 +50,3 @@ // The second parameter is the path to folder that contains command modules.

```ts
import {
Command,
command,
param,
} from 'clime';
import {Command, command, param} from 'clime';

@@ -75,7 +71,7 @@ @command({

- ☑ Type and schema based parameters/options casting
- ☑ Object and promise based architecture
- ☑ File path based multi-level subcommands
- ☑ Automatic usage generating
- ☑ Multiple command roots support <sup>New in v0.5</sup>
* ☑ Type and schema based parameters/options casting
* ☑ Object and promise based architecture
* ☑ File path based multi-level subcommands
* ☑ Automatic usage generating
* ☑ Multiple command roots support <sup>New in v0.5</sup>

@@ -87,10 +83,3 @@ ### Parameter types and options schema

```ts
import {
Command,
Options,
command,
option,
param,
params,
} from 'clime';
import {Command, Options, command, option, param, params} from 'clime';

@@ -118,3 +107,2 @@ export class SomeOptions extends Options {

foo: string,
@param({

@@ -124,3 +112,2 @@ description: 'optional parameter bar',

bar: number,
@params({

@@ -131,3 +118,2 @@ type: String,

args: string[],
options: SomeOptions,

@@ -154,3 +140,2 @@ ) {

-t, --timeout <timeout> - timeout that does nothing
```

@@ -163,11 +148,11 @@

> Please note that `StringCastable` is correspondent to the type of constructor instead of instance, so no `implements` should be present.
For example:
```ts
import { StringCastable } from 'clime';
import {CastingContext} from 'clime';
class File implements StringCastable {
constructor(
public path: string,
) { }
class File {
constructor(public path: string) {}

@@ -279,3 +264,3 @@ static cast(path: string, context: CastingContext<File>): File {

```ts
import { SubcommandDefinition } from 'clime';
import {SubcommandDefinition} from 'clime';

@@ -297,3 +282,3 @@ export const subcommands: SubcommandDefinition[] = [

```ts
import { SubcommandDefinition } from 'clime';
import {SubcommandDefinition} from 'clime';

@@ -349,8 +334,3 @@ export const subcommands: SubcommandDefinition[] = [

```ts
import {
Command,
Context,
command,
metadata,
} from 'clime';
import {Command, Context, command, metadata} from 'clime';

@@ -378,8 +358,6 @@ export class TestContext extends Context {

```ts
import { Printable } from 'clime';
import {Printable} from 'clime';
export class ExitSignal implements Printable {
constructor(
public code: number,
) { }
constructor(public code: number) {}

@@ -386,0 +364,0 @@ print(): void {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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