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

@dotcom-tool-kit/types

Package Overview
Dependencies
Maintainers
2
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotcom-tool-kit/types - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

44

lib/index.d.ts

@@ -1,17 +0,37 @@

export declare class ToolKitError extends Error {
details?: string;
exitCode?: number;
import { Schema, SchemaOutput } from './schema';
export declare abstract class Task<O extends Schema = Record<string, never>> {
static description: string;
static plugin?: Plugin;
static id?: string;
static defaultOptions: Record<string, unknown>;
options: SchemaOutput<O>;
constructor(options?: Partial<SchemaOutput<O>>);
abstract run(files?: string[]): Promise<void>;
}
export interface ConflictingTask {
task: string;
plugin: string;
export declare type TaskClass = typeof Task;
export declare abstract class Hook {
id?: string;
plugin?: Plugin;
static description?: string;
abstract check(): Promise<boolean>;
abstract install(): Promise<void>;
}
export interface HookTaskConflict {
hook: string;
conflictingTasks: ConflictingTask[];
export interface Plugin {
id: string;
root: string;
parent?: Plugin;
tasks?: TaskClass[];
hooks?: {
[id: string]: Hook;
};
}
export declare class ToolKitConflictError extends ToolKitError {
conflicts: HookTaskConflict[];
constructor(message: string, conflicts: HookTaskConflict[]);
export interface RawPlugin extends Omit<Plugin, 'parent' | 'hooks'> {
parent?: RawPlugin;
hooks?: {
[id: string]: {
new (): Hook;
};
};
}
export declare function instantiatePlugin(plugin: unknown): Plugin;
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToolKitConflictError = exports.ToolKitError = void 0;
class ToolKitError extends Error {
exports.instantiatePlugin = exports.Hook = exports.Task = void 0;
const tslib_1 = require("tslib");
const error_1 = require("@dotcom-tool-kit/error");
const lodash_isplainobject_1 = (0, tslib_1.__importDefault)(require("lodash.isplainobject"));
const lodash_mapvalues_1 = (0, tslib_1.__importDefault)(require("lodash.mapvalues"));
class Task {
constructor(options = {}) {
this.options = Object.assign({}, this.constructor.defaultOptions, options);
}
}
exports.ToolKitError = ToolKitError;
class ToolKitConflictError extends ToolKitError {
constructor(message, conflicts) {
super(message);
this.conflicts = conflicts;
exports.Task = Task;
Task.defaultOptions = {};
class Hook {
}
exports.Hook = Hook;
function instantiatePlugin(plugin) {
const rawPlugin = plugin;
const parent = rawPlugin.parent && instantiatePlugin(rawPlugin.parent);
if (rawPlugin.tasks &&
!(Array.isArray(rawPlugin.tasks) && rawPlugin.tasks.every((task) => task.prototype instanceof Task))) {
throw new error_1.ToolKitError('tasks are not valid');
}
if (rawPlugin.hooks &&
!((0, lodash_isplainobject_1.default)(rawPlugin.hooks) &&
Object.values(rawPlugin.hooks).every((hook) => hook.prototype instanceof Hook))) {
throw new error_1.ToolKitError('hooks are not valid');
}
const hooks = (0, lodash_mapvalues_1.default)(rawPlugin.hooks, (Hook) => {
return new Hook();
});
return { ...rawPlugin, parent, hooks };
}
exports.ToolKitConflictError = ToolKitConflictError;
exports.instantiatePlugin = instantiatePlugin;
{
"name": "@dotcom-tool-kit/types",
"version": "1.2.0",
"version": "1.2.1",
"description": "",

@@ -24,3 +24,13 @@ "main": "lib",

"extends": "../../package.json"
},
"dependencies": {
"@dotcom-tool-kit/error": "^1.2.1",
"lodash.isplainobject": "^4.0.6",
"lodash.mapvalues": "^4.6.0"
},
"devDependencies": {
"@jest/globals": "^26.6.2",
"@types/lodash.isplainobject": "^4.0.6",
"@types/lodash.mapvalues": "^4.6.6"
}
}

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