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

@anycli/engine

Package Overview
Dependencies
Maintainers
3
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anycli/engine - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

8

CHANGELOG.md

@@ -0,1 +1,9 @@

<a name="0.3.1"></a>
## [0.3.1](https://github.com/anycli/engine/compare/1e5a8ad108407c95be9077f9aa98d498b116e19e...v0.3.1) (2018-02-02)
### Bug Fixes
* read plugin cache if available ([01d90d9](https://github.com/anycli/engine/commit/01d90d9))
<a name="0.3.0"></a>

@@ -2,0 +10,0 @@ # [0.3.0](https://github.com/anycli/engine/compare/38f3f73a2a8dd9767ac50c5dc0860bf99e6e1b66...v0.3.0) (2018-02-02)

71

lib/engine.js

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

this.config.engine = this;
// set global config for plugins to use in any part of their loading
if (!global.anycli)
global.anycli = {};
if (!global.anycli.config)
global.anycli.config = this.config;
this.debug = require('debug')(['@anycli/engine', this.config.name].join(':'));
this.rootPlugin = await this.loadPlugin({ type: 'core', config, loadDevPlugins: true });
this.rootPlugin = await this.loadPlugin({ type: 'core', config, loadDevPlugins: true, useCache: true });
// await this.runHook('legacy', {engine: this})

@@ -112,3 +107,3 @@ const getAllPluginProps = (plugin) => {

roots = await fetch(config.pluginsModule);
const promises = roots.map((r) => this.loadPlugin(r).catch(cli_ux_1.default.warn));
const promises = roots.map((r) => this.loadPlugin(Object.assign({}, r, { useCache: true })).catch(cli_ux_1.default.warn));
plugins.push(...await Promise.all(promises));

@@ -121,3 +116,3 @@ }

else if (_.isArray(pjson.anycli.plugins)) {
const promises = pjson.anycli.plugins.map(p => this.loadPlugin({ root: config.root, type, name: p }).catch(cli_ux_1.default.warn));
const promises = pjson.anycli.plugins.map(p => this.loadPlugin({ root: config.root, type, name: p, useCache: opts.useCache }).catch(cli_ux_1.default.warn));
plugins.push(..._(await Promise.all(promises)).compact().flatMap().value());

@@ -128,3 +123,3 @@ }

this.debug('loading dev plugins', devPlugins);
const promises = devPlugins.map(p => this.loadPlugin({ root: config.root, type: 'dev', name: p }).catch(cli_ux_1.default.warn));
const promises = devPlugins.map(p => this.loadPlugin({ root: config.root, type: 'dev', name: p, useCache: opts.useCache }).catch(cli_ux_1.default.warn));
plugins.push(..._(await Promise.all(promises)).compact().flatMap().value());

@@ -147,13 +142,19 @@ }

const debug = require('debug')(['@anycli/load', config.name].join(':'));
const fetchFromDir = async (dir) => {
function findCommand(id) {
function commandPath(id) {
return require.resolve(path.join(dir, ...id.split(':')));
}
debug('fetching %s from %s', id, dir);
const p = commandPath(id);
let c = util_1.undefault(require(p));
c.id = id;
return c;
function findCommand(dir, id) {
function commandPath(id) {
return require.resolve(path.join(dir, ...id.split(':')));
}
debug('fetching %s from %s', id, dir);
const p = commandPath(id);
let c = util_1.undefault(require(p));
c.id = id;
return c;
}
const rehydrate = (dir, commands) => {
return commands.map((cmd) => (Object.assign({}, cmd, { load: async () => findCommand(dir, cmd.id) })));
};
const fetchFromDir = async () => {
const dir = config.commandsDirTS || config.commandsDir;
if (!dir)
return [];
const fetch = async () => {

@@ -182,3 +183,3 @@ function getCached(c) {

try {
const cmd = findCommand(id);
const cmd = findCommand(dir, id);
return getCached(cmd);

@@ -192,5 +193,2 @@ }

};
const rehydrate = (commands) => {
return commands.map((cmd) => (Object.assign({}, cmd, { load: async () => findCommand(cmd.id) })));
};
let commands;

@@ -228,20 +226,25 @@ if (opts.useCache) {

}
return rehydrate(commands);
return rehydrate(dir, commands);
};
let commands = [];
if (config.commandsDirTS) {
const loadFromManifest = async () => {
try {
commands.push(...await fetchFromDir(config.commandsDirTS));
const manifest = await fs.readJSON(path.join(config.root, '.anycli.manifest.json'));
if (manifest.version !== config.version) {
const err = new Error(`Mismatched version in plugin manifest. Expected: ${config.version} Received: ${manifest.version}`);
err.code = 'EMISMATCH';
throw err;
}
return rehydrate(config.commandsDir, manifest.commands);
}
catch (err) {
cli_ux_1.default.warn(err);
// debug(err)
switch (err.code) {
case 'ENOENT': return;
case 'EMISMATCH': return debug(err);
default: cli_ux_1.default.warn(err);
}
}
}
else if (config.commandsDir) {
commands.push(...await fetchFromDir(config.commandsDir));
}
};
return {
version: config.version,
commands,
commands: (await loadFromManifest()) || (await fetchFromDir()),
};

@@ -248,0 +251,0 @@ }

{
"name": "@anycli/engine",
"description": "main anycli component",
"version": "0.3.0",
"version": "0.3.1",
"author": "Jeff Dickey @jdxcode",

@@ -27,8 +27,7 @@ "anycli": {

"@anycli/config": "^0.3.0",
"@anycli/plugin-help": "^0.3.7",
"@anycli/plugin-help": "^0.4.1",
"@anycli/plugin-not-found": "^0.1.10",
"@anycli/plugin-plugins": "^0.2.4",
"@anycli/plugin-version": "^0.1.20",
"@anycli/plugin-version": "^0.1.29",
"@anycli/tslint": "^0.2.2",
"@anycli/version": "^0.1.19",
"@types/chai": "^4.1.2",

@@ -35,0 +34,0 @@ "@types/fs-extra": "^5.0.0",

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