@gasket/core
Advanced tools
Comparing version 7.0.0-next.21 to 7.0.0-next.22
@@ -1,10 +0,97 @@ | ||
import { Gasket, GasketConfigDefinition } from '@gasket/engine'; | ||
declare module '@gasket/core' { | ||
export type MaybeMultiple<T> = T | Array<T>; | ||
export type MaybeAsync<T> = T | Promise<T>; | ||
export type ResolvedType<T> = T extends Promise<infer Value> ? Value : T; | ||
declare module '@gasket/engine' { | ||
export interface GasketActions {} | ||
export interface GasketConfig {} | ||
// To be extended by plugins | ||
export interface HookExecTypes { | ||
// add makeGasket lifecycles | ||
init(): void | ||
actions(): GasketActions | ||
configure(config: GasketConfig): GasketConfig | ||
} | ||
export interface Gasket { | ||
export type HookId = keyof HookExecTypes | ||
export type HookTimings = { | ||
before?: Array<string>; | ||
after?: Array<string>; | ||
first?: boolean; | ||
last?: boolean; | ||
}; | ||
export type HookHandler<Id extends HookId> = ( | ||
gasket: Gasket, | ||
...args: Parameters<HookExecTypes[Id]> | ||
) => ReturnType<HookExecTypes[Id]>; | ||
export type ApplyHookHandler<Id extends HookId> = ( | ||
...args: Parameters<HookExecTypes[Id]> | ||
) => ReturnType<HookExecTypes[Id]>; | ||
type HookWithTimings<Id extends HookId> = { | ||
timing: HookTimings; | ||
handler: HookHandler<Id>; | ||
}; | ||
export type Hook<Id extends HookId> = HookWithTimings<Id> | HookHandler<Id>; | ||
export type Plugin = { | ||
name: string; | ||
dependencies?: Array<string>; | ||
hooks: { | ||
[K in HookId]?: Hook<K>; | ||
}; | ||
}; | ||
// This is the config | ||
export interface GasketConfig { | ||
plugins: Array<Plugin> | ||
root: string | ||
env: string | ||
} | ||
export class GasketEngine { | ||
constructor(plugins: Array<Plugin>); | ||
exec<Id extends HookId>( | ||
hook: Id, | ||
...args: Parameters<HookExecTypes[Id]> | ||
): Promise<ResolvedType<ReturnType<HookExecTypes[Id]>>[]>; | ||
execSync<Id extends HookId>( | ||
hook: Id, | ||
...args: Parameters<HookExecTypes[Id]> | ||
): ResolvedType<ReturnType<HookExecTypes[Id]>>[]; | ||
execWaterfall<Id extends HookId>( | ||
hook: Id, | ||
...args: Parameters<HookExecTypes[Id]> | ||
): ReturnType<HookExecTypes[Id]>; | ||
execWaterfallSync<Id extends HookId>( | ||
hook: Id, | ||
...args: Parameters<HookExecTypes[Id]> | ||
): ReturnType<HookExecTypes[Id]>; | ||
execApply<Id extends HookId, Return = void>( | ||
hook: Id, | ||
callback: (plugin: Plugin, handler: ApplyHookHandler<Id>) => Promise<Return> | ||
): Promise<Return[]>; | ||
execApplySync<Id extends HookId, Return = void>( | ||
hook: Id, | ||
callback: (plugin: Plugin, handler: ApplyHookHandler<Id>) => Return | ||
): Return[]; | ||
hook<Id extends HookId>(opts: { | ||
event: Id, | ||
pluginName?: string, | ||
timing?: HookTimings, | ||
handler: HookHandler<Id> | ||
}): void; | ||
} | ||
export interface Gasket extends GasketEngine { | ||
command: { | ||
id: string | ||
} | ||
config: GasketConfig; | ||
new (config: GasketConfigDefinition): Gasket | ||
@@ -14,6 +101,11 @@ actions: GasketActions | ||
export interface HookExecTypes { | ||
init(): void | ||
actions(): GasketActions | ||
configure(config: GasketConfig): GasketConfig | ||
type PartialRecursive<T> = | ||
T extends Object | ||
? { [K in keyof T]?: PartialRecursive<T[K]> } | undefined | ||
: T | undefined | ||
export type GasketConfigDefinition = Omit<GasketConfig, 'root' | 'env' | 'command'> & { | ||
root?: string | ||
env?: string | ||
environments?: Record<string, Partial<GasketConfigDefinition>> | ||
} | ||
@@ -20,0 +112,0 @@ } |
/* eslint-disable no-console, no-process-env */ | ||
/// <reference types="./index" /> | ||
import GasketEngine from '@gasket/engine'; | ||
import GasketEngine from './engine.js'; | ||
import { applyConfigOverrides } from '@gasket/utils'; | ||
@@ -45,2 +45,6 @@ | ||
// TODO: Add JSDoc types | ||
/** | ||
* | ||
* @param instance | ||
*/ | ||
function registerActions(instance) { | ||
@@ -90,4 +94,13 @@ const actions = {}; | ||
// TODO: Add JSDoc types | ||
export function makeGasket(gasketConfigDefinition) { | ||
/** | ||
* | ||
* @param gasketConfigDefinition | ||
*/ | ||
function makeGasket(gasketConfigDefinition) { | ||
return new Gasket(gasketConfigDefinition); | ||
} | ||
export { | ||
makeGasket, | ||
GasketEngine | ||
}; |
{ | ||
"name": "@gasket/core", | ||
"version": "7.0.0-next.21", | ||
"version": "7.0.0-next.22", | ||
"description": "Entry point to setting up Gasket instances", | ||
"main": "lib/index.js", | ||
"module": "lib/index.js", | ||
"main": "cjs/index.js", | ||
"exports": { | ||
"import": "./lib/index.js", | ||
"require": "./cjs/index.js" | ||
}, | ||
"types": "lib/index.d.ts", | ||
"files": [ | ||
"lib" | ||
"lib", | ||
"cjs" | ||
], | ||
"scripts": { | ||
"build": "swc lib -d cjs --delete-dir-on-start --strip-leading-paths", | ||
"lint": "eslint .", | ||
@@ -48,2 +55,4 @@ "lint:fix": "npm run lint -- --fix", | ||
"@jest/globals": "^29.7.0", | ||
"@swc/cli": "^0.3.12", | ||
"@swc/core": "^1.5.3", | ||
"@types/jest": "^29.5.12", | ||
@@ -61,2 +70,5 @@ "@types/node": "^20.12.5", | ||
"eslintConfig": { | ||
"ignorePatterns": [ | ||
"cjs/" | ||
], | ||
"extends": [ | ||
@@ -77,7 +89,4 @@ "godaddy", | ||
}, | ||
"jest": { | ||
"testEnvironment": "node" | ||
}, | ||
"type": "module", | ||
"gitHead": "52718d035b5a33c04de7043587f89596dd6da6f4" | ||
"gitHead": "b477b086bf8938f34fffa673e396920eae9a0263" | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
53526
8
1309
13
4
1