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.0.1 to 1.0.2-beta.1

lib/schema/babel.d.ts

48

lib/index.d.ts

@@ -1,17 +0,41 @@

export declare class ToolKitError extends Error {
details?: string;
exitCode?: number;
import type { Logger } from 'winston';
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>;
logger: Logger;
constructor(logger: Logger, 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;
logger: Logger;
static description?: string;
constructor(logger: Logger);
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 (logger: Logger): Hook;
};
};
}
export declare function instantiatePlugin(plugin: unknown, logger: Logger): 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(logger, options = {}) {
const staticThis = this.constructor;
this.options = Object.assign({}, staticThis.defaultOptions, options);
this.logger = logger.child({ task: staticThis.id });
}
}
exports.ToolKitError = ToolKitError;
class ToolKitConflictError extends ToolKitError {
constructor(message, conflicts) {
super(message);
this.conflicts = conflicts;
exports.Task = Task;
Task.defaultOptions = {};
class Hook {
constructor(logger) {
this.logger = logger.child({ hook: this.constructor.name });
}
}
exports.ToolKitConflictError = ToolKitConflictError;
exports.Hook = Hook;
function instantiatePlugin(plugin, logger) {
const rawPlugin = plugin;
const parent = rawPlugin.parent && instantiatePlugin(rawPlugin.parent, logger);
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(logger);
});
return { ...rawPlugin, parent, hooks };
}
exports.instantiatePlugin = instantiatePlugin;

@@ -0,4 +1,7 @@

import type prompts from 'prompts';
import type { Logger } from 'winston';
export declare type ScalarSchemaType = 'string' | 'number' | 'boolean' | `|${string},${string}` | 'unknown';
export declare type SchemaType = ScalarSchemaType | `array.${ScalarSchemaType}` | `record.${ScalarSchemaType}`;
export declare type ModifiedSchemaType = SchemaType | `${SchemaType}?`;
export declare type SchemaPromptGenerator<T> = (logger: Logger, prompt: typeof prompts, onCancel: () => void) => Promise<T>;
export declare type ModifiedSchemaType = SchemaType | `${SchemaType}?` | SchemaPromptGenerator<unknown>;
export declare type Schema = {

@@ -12,4 +15,32 @@ readonly [option: string]: ModifiedSchemaType;

-readonly [option in keyof T as T[option] extends `${string}?` ? option : never]?: T[option] extends `${infer S}?` ? S extends SchemaType ? SchemaTypeOutput<S> : never : never;
} & {
-readonly [option in keyof T as T[option] extends SchemaPromptGenerator<unknown> ? option : never]: T[option] extends SchemaPromptGenerator<infer R> ? R : never;
};
import type { ESLintOptions } from './schema/eslint';
import type { HerokuOptions } from './schema/heroku';
import type { MochaOptions } from './schema/mocha';
import type { SmokeTestOptions } from './schema/n-test';
import type { UploadAssetsToS3Options } from './schema/upload-assets-to-s3';
import type { VaultOptions } from './schema/vault';
import type { WebpackOptions } from './schema/webpack';
import type { NodeOptions } from './schema/node';
import type { NextRouterOptions } from './schema/next-router';
import type { PrettierOptions } from './schema/prettier';
import type { LintStagedNpmOptions } from './schema/lint-staged-npm';
import type { BabelOptions } from './schema/babel';
export declare type Options = {
'@dotcom-tool-kit/eslint'?: ESLintOptions;
'@dotcom-tool-kit/heroku'?: HerokuOptions;
'@dotcom-tool-kit/mocha'?: MochaOptions;
'@dotcom-tool-kit/n-test'?: SmokeTestOptions;
'@dotcom-tool-kit/upload-assets-to-s3'?: UploadAssetsToS3Options;
'@dotcom-tool-kit/vault'?: VaultOptions;
'@dotcom-tool-kit/webpack'?: WebpackOptions;
'@dotcom-tool-kit/node'?: NodeOptions;
'@dotcom-tool-kit/next-router'?: NextRouterOptions;
'@dotcom-tool-kit/prettier'?: PrettierOptions;
'@dotcom-tool-kit/lint-staged-npm'?: LintStagedNpmOptions;
'@dotcom-tool-kit/babel'?: BabelOptions;
};
export {};
//# sourceMappingURL=schema.d.ts.map

@@ -1,15 +0,21 @@

import { SchemaOutput } from '../schema';
import { SchemaOutput, SchemaPromptGenerator } from '../schema';
export interface HerokuScaling {
[app: string]: {
[processType: string]: {
size: string;
quantity: number;
};
};
}
export declare const HerokuSchema: {
readonly pipeline: "string?";
readonly vaultTeam: "string?";
readonly vaultApp: "string?";
readonly systemCode: "string?";
readonly pipeline: "string";
readonly systemCode: "string";
readonly scaling: SchemaPromptGenerator<HerokuScaling>;
};
export declare type HerokuOptions = SchemaOutput<typeof HerokuSchema>;
export declare const Schema: {
readonly pipeline: "string?";
readonly vaultTeam: "string?";
readonly vaultApp: "string?";
readonly systemCode: "string?";
readonly pipeline: "string";
readonly systemCode: "string";
readonly scaling: SchemaPromptGenerator<HerokuScaling>;
};
//# sourceMappingURL=heroku.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Schema = exports.HerokuSchema = void 0;
const scaling = async (logger, prompt, onCancel) => {
logger.error('You must configure the scaling for each of the Heroku apps in your pipeline.');
const scaling = {};
let allAppsConfigured = false;
while (!allAppsConfigured) {
const { app } = await prompt({
name: 'app',
type: 'text',
message: 'Enter the name of the Heroku app to configure'
}, { onCancel });
const { processType, size, quantity, moreApps } = await prompt([
{
name: 'processType',
type: 'text',
initial: 'web',
message: `What is the process type of ${app}?`
},
{ name: 'size', type: 'text', initial: 'standard-1X', message: `What should the size of ${app} be?` },
{ name: 'quantity', type: 'number', message: `What should the dyno size of ${app} be?` },
{ name: 'moreApps', type: 'confirm', message: 'Are there more Heroku apps in this pipeline?' }
], { onCancel });
scaling[app] = { [processType]: { size, quantity } };
allAppsConfigured = !moreApps;
}
return scaling;
};
exports.HerokuSchema = {
pipeline: 'string?',
vaultTeam: 'string?',
vaultApp: 'string?',
systemCode: 'string?'
pipeline: 'string',
systemCode: 'string',
scaling
};
exports.Schema = exports.HerokuSchema;
{
"name": "@dotcom-tool-kit/types",
"version": "1.0.1",
"version": "1.0.2-beta.1",
"description": "",

@@ -15,6 +15,6 @@ "main": "lib",

"url": "https://github.com/financial-times/dotcom-tool-kit.git",
"directory": "packages/types"
"directory": "lib/types"
},
"bugs": "https://github.com/financial-times/dotcom-tool-kit/issues",
"homepage": "https://github.com/financial-times/dotcom-tool-kit/tree/main/packages/types",
"homepage": "https://github.com/financial-times/dotcom-tool-kit/tree/main/lib/types",
"files": [

@@ -25,3 +25,15 @@ "/lib"

"extends": "../../package.json"
},
"dependencies": {
"@dotcom-tool-kit/error": "^1.0.2-beta.1",
"lodash.isplainobject": "^4.0.6",
"lodash.mapvalues": "^4.6.0"
},
"devDependencies": {
"@jest/globals": "^27.4.6",
"@types/lodash.isplainobject": "^4.0.6",
"@types/lodash.mapvalues": "^4.6.6",
"@types/prompts": "^2.0.14",
"winston": "^3.5.1"
}
}

@@ -86,5 +86,5 @@ # Tool Kit Option Schemas

You should also follow the convention of storing your schema at `<tool kit root>/packages/types/schema/<package name>.ts`, and export it from the module as
You should also follow the convention of storing your schema at `<tool kit root>/lib/types/schema/<package name>.ts`, and export it from the module as
`Schema`. This allows the `create` package to dynamically read the schema and
prompt the user for options to set when they are initialising Tool Kit and its
plugins.

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