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

@nowa/core

Package Overview
Dependencies
Maintainers
4
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nowa/core - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0-beta.31783c1c

27

CHANGELOG.md

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

<a name="0.7.0-beta.31783c1c"></a>
# [0.7.0-beta.31783c1c](https://github.com/nowa-webpack/nowa2/compare/@nowa/core@0.6.0...@nowa/core@0.7.0-beta.31783c1c) (2018-07-16)
### Bug Fixes
* command path parsing issue ([31783c1](https://github.com/nowa-webpack/nowa2/commit/31783c1))
### Features
* support path-like command description ([50e46e6](https://github.com/nowa-webpack/nowa2/commit/50e46e6))
<a name="0.7.0-beta.50e46e61"></a>
# [0.7.0-beta.50e46e61](https://github.com/nowa-webpack/nowa2/compare/@nowa/core@0.6.0...@nowa/core@0.7.0-beta.50e46e61) (2018-07-16)
### Features
* support path-like command description ([50e46e6](https://github.com/nowa-webpack/nowa2/commit/50e46e6))
<a name="0.6.0"></a>

@@ -8,0 +35,0 @@ # [0.6.0](https://github.com/nowa-webpack/nowa2/compare/@nowa/core@0.5.0...@nowa/core@0.6.0) (2018-05-27)

12

lib/moduleQueue.d.ts

@@ -11,8 +11,8 @@ import { Module } from './core/module';

run(done?: (error?: Error) => void): Promise<void>;
private _initModule(module);
private _runModule(module, loopID);
private _runNewLoop(module, error?);
private _checkLoopIsValid(loopID);
private _handleInitError(error);
private _handleRunError(error);
private _initModule;
private _runModule;
private _runNewLoop;
private _checkLoopIsValid;
private _handleInitError;
private _handleRunError;
}

@@ -19,0 +19,0 @@ export declare namespace ModuleQueue {

import { Runner } from '../runner';
export declare class InitErrorPlugin {
apply(runner: Runner, {logger}: Runner.Utils): void;
apply(runner: Runner, { logger }: Runner.Utils): void;
}

@@ -5,3 +5,3 @@ import { Runner } from '../runner';

constructor(options?: LoadConfigPlugin.IOptions);
apply(runner: Runner, {logger}: Runner.Utils): void;
apply(runner: Runner, { logger }: Runner.Utils): void;
}

@@ -8,0 +8,0 @@ export declare namespace LoadConfigPlugin {

@@ -5,5 +5,5 @@ import { Runner } from '../runner';

constructor(options?: LoadModulesPlugin.IOptions);
apply(runner: Runner, {logger}: Runner.Utils): void;
private _loadModule(pathOrModuleName, context, prefixes, logger);
private _checkIsNowaModule(module);
apply(runner: Runner, { logger }: Runner.Utils): void;
private _loadModule;
private _checkIsNowaModule;
}

@@ -10,0 +10,0 @@ export declare namespace LoadModulesPlugin {

import { Runner } from '../runner';
export declare class LoadPluginsPlugin {
apply(runner: Runner, {logger}: Runner.Utils): void;
apply(runner: Runner, { logger }: Runner.Utils): void;
}

@@ -5,3 +5,3 @@ import { Runner } from '../runner';

constructor(options?: LoadSolutionPlugin.IOptions);
apply(runner: Runner, {logger}: Runner.Utils): void;
apply(runner: Runner, { logger }: Runner.Utils): void;
}

@@ -8,0 +8,0 @@ export declare namespace LoadSolutionPlugin {

import { Runner } from '../runner';
export declare class ParseConfigPlugin {
apply(runner: Runner, {logger}: Runner.Utils): void;
apply(runner: Runner, { logger }: Runner.Utils): void;
}
import { Runner } from '../runner';
export declare class ParseSolutionPlugin {
apply(runner: Runner, {logger}: Runner.Utils): void;
apply(runner: Runner, { logger }: Runner.Utils): void;
}

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

logger.debug('no command found');
return { actualCommands: [], result: [{}, [], undefined] };
return [{}, [], undefined];
}

@@ -16,3 +16,6 @@ const configResult = utils_1.parser('config.commands', commands, logger.debug, config.commands);

logger.debug('using config.commands');
return configResult;
if (typeof configResult.result === 'function') {
return configResult.result({ params: configResult.params });
}
return configResult.result;
}

@@ -22,3 +25,6 @@ const solutionResult = utils_1.parser('solution.commands', commands, logger.debug, solution.commands);

logger.debug('using solution.commands');
return solutionResult;
if (typeof solutionResult.result === 'function') {
return solutionResult.result({ params: solutionResult.params });
}
return solutionResult.result;
}

@@ -25,0 +31,0 @@ logger.error(`neither of config / solution has described commands.${commands.join('.')}`);

import { Runner } from '../runner';
export declare class RunErrorPlugin {
apply(runner: Runner, {logger}: Runner.Utils): void;
apply(runner: Runner, { logger }: Runner.Utils): void;
}

@@ -22,6 +22,3 @@ import { Module } from './core/module';

'parse-config': [Pick<IRuntime, 'context'> & IRuntime['raw'], IRuntime['parsed']['config']];
'parse-solution': [Pick<IRuntime, 'context'> & IRuntime['raw'], {
actualCommands: string[];
result: IRuntime['parsed']['solution'];
}];
'parse-solution': [Pick<IRuntime, 'context'> & IRuntime['raw'], IRuntime['parsed']['solution']];
'load-options': [Pick<IRuntime, 'context'> & Pick<IRuntime['parsed'], 'commands' | 'config' | 'solution'> & {

@@ -28,0 +25,0 @@ rawConfig: IRuntime['raw']['config'];

@@ -48,5 +48,4 @@ "use strict";

logger.debug('apply parse-solution');
const { actualCommands, result: solutionResult } = yield this.$applyHookBail('parse-solution', Object.assign({ commands: this.runtime.parsed.commands, context: this.runtime.context }, this.runtime.raw));
const solutionResult = yield this.$applyHookBail('parse-solution', Object.assign({ commands: this.runtime.parsed.commands, context: this.runtime.context }, this.runtime.raw));
this.runtime.parsed.solution = solutionResult;
this.runtime.parsed.commands = actualCommands;
logger.debug('apply load-options');

@@ -53,0 +52,0 @@ const options = yield this.$applyHookBail('load-options', {

@@ -40,7 +40,12 @@ import { Chalk } from 'chalk';

export interface IConfigConfigRegistry {
[commandName: string]: string | IConfigConfigValues | IConfigConfigRegistry;
[commandPath: string]: IConfigConfigValues | ((arg?: {
params: {
[paramName: string]: string;
};
context: string;
}) => IConfigConfigValues);
}
export declare type IConfigConfigValues = [{
export declare type IConfigConfigValues = {
[optionName: string]: any;
}];
};
export interface ISolution {

@@ -74,4 +79,6 @@ commands: ISolutionCommandRegistry;

export interface ISolutionCommandRegistry {
default: string | ISolutionCommandDescription;
[commandName: string]: string | ISolutionCommandDescription | ISolutionCommandRegistry;
[commandPath: string]: ISolutionCommandDescription | ((arg?: {
options: IConfigConfigValues[0];
context: string;
}) => ISolutionCommandDescription);
}

@@ -78,0 +85,0 @@ export interface IBaseOptionDescription {

import { IConfigConfigRegistry, IConfigConfigValues, ISolutionCommandDescription, ISolutionCommandRegistry } from './types';
export declare function parser(target: 'config.config', commands: string[], debug: (...args: any[]) => void, source: IConfigConfigRegistry | undefined): {
actualCommands: string[];
params: {
[paramName: string]: string;
};
result: IConfigConfigValues;
} | undefined;
export declare function parser(target: 'solution.commands' | 'config.commands', commands: string[], debug: (...args: any[]) => void, source: ISolutionCommandRegistry | undefined): {
actualCommands: string[];
params: {
[paramName: string]: string;
};
result: ISolutionCommandDescription;
} | undefined;
export declare function parser(target: 'solution.commands' | 'config.commands' | 'config.config', commands: string[], debug: (...args: any[]) => void, source: ISolutionCommandRegistry | IConfigConfigRegistry | undefined): {
actualCommands: string[];
result: IConfigConfigValues | ISolutionCommandDescription;
} | undefined;
export declare function parser(target: string, commands: string[], debug: (...args: any[]) => void, source: any): {
actualCommands: string[];
result: any;
} | undefined;
export declare const handleESModuleDefault: <T extends any>(moduleExport: T) => T;

@@ -19,0 +15,0 @@ export declare const deleteUndefined: <T extends object>(obj: T, recursive?: boolean) => T;

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

const fs_extra_1 = require("fs-extra");
const pathToRegexp = require("path-to-regexp");
function parser(target, commands, debug, source) {

@@ -12,36 +13,29 @@ if (!source) {

}
let cursor = source;
let index = 0;
do {
const currentCommandPart = commands[index] || 'default';
const currentCommand = commands.slice(0, index + 1);
const currentPath = currentCommand.join('.');
let next = cursor[currentCommandPart];
if (typeof next === 'string') {
next = cursor[next];
}
if (Array.isArray(next)) {
debug(`find ${target} @ ${target}.${currentPath}`);
return { result: next, actualCommands: currentCommand };
}
else if (next !== undefined) {
cursor = next;
index += 1;
debug(`continue on ${target}.${currentPath}`);
}
else {
if (cursor.default) {
debug(`find and try to fallback to ${target}.${commands.slice(0, index).join('.')}.default`);
if (Array.isArray(cursor.default)) {
return { result: cursor.default, actualCommands: currentCommand };
}
else {
debug(`default config should be an array`);
return undefined;
}
const commandPath = '/' + commands.join('/');
const routes = Object.keys(source).map(path => {
const keys = [];
const re = pathToRegexp(path, keys);
const test = (path) => {
const result = re.exec(`/${path}`);
if (!result || keys.length === 0) {
return result ? {} : null;
}
break;
const params = {};
keys.forEach(({ name }, index) => {
params[name] = result[index + 1];
});
return params;
};
return {
result: source[path],
test,
};
});
for (const route of routes) {
const { test, result } = route;
const params = test(commandPath);
if (params) {
return { params, result };
}
} while (cursor);
debug(`can not retrieve from ${target}.${commands.join('.')}`);
}
return undefined;

@@ -48,0 +42,0 @@ }

{
"name": "@nowa/core",
"version": "0.6.0",
"version": "0.7.0-beta.31783c1c",
"description": "the nowa core",

@@ -28,2 +28,3 @@ "scripts": {

"fs-extra": "^6.0.1",
"path-to-regexp": "^2.2.1",
"tslib": "^1.9.1"

@@ -30,0 +31,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