@qiwi/semrel-plugin-creator
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -0,1 +1,9 @@ | ||
# @qiwi/semrel-plugin-creator [1.5.0](https://github.com/qiwi/semantic-release-toolkit/compare/@qiwi/semrel-plugin-creator@1.4.0...@qiwi/semrel-plugin-creator@1.5.0) (2021-01-19) | ||
### Features | ||
* **metabranch:** add debugger ([5180777](https://github.com/qiwi/semantic-release-toolkit/commit/51807779f12a6d6afbf4efb1545bb20a34c85efb)) | ||
* **plugin-creator:** add debugger to handler context ([733c0b2](https://github.com/qiwi/semantic-release-toolkit/commit/733c0b227c31204bf3e821802768d15f3e1f4c8b)), closes [#30](https://github.com/qiwi/semantic-release-toolkit/issues/30) | ||
# @qiwi/semrel-plugin-creator [1.4.0](https://github.com/qiwi/semantic-release-toolkit/compare/@qiwi/semrel-plugin-creator@1.3.1...@qiwi/semrel-plugin-creator@1.4.0) (2021-01-19) | ||
@@ -2,0 +10,0 @@ |
@@ -55,4 +55,8 @@ /** | ||
declare module "@qiwi/semrel-plugin-creator/target/es6/interface" { | ||
import type { Debugger } from "debug"; | ||
import type { Context } from "semantic-release"; | ||
declare export { Debugger } from "debug"; | ||
declare export type TReleaseType = "patch" | "minor" | "major"; | ||
@@ -109,2 +113,3 @@ declare export type TTag = { | ||
step: TReleaseStep, | ||
debug: Debugger, | ||
... | ||
@@ -121,6 +126,10 @@ }; | ||
require: TReleaseStep[], | ||
debug: Debugger, | ||
... | ||
}; | ||
declare export type TPluginFactoryOptions = $Rest< | ||
TPluginFactoryOptionsNormalized, | ||
Omit<TPluginFactoryOptionsNormalized, "debug"> & { | ||
debug: string | Debugger, | ||
... | ||
}, | ||
{ ... } | ||
@@ -185,4 +194,8 @@ >; | ||
declare module "@qiwi/semrel-plugin-creator/target/es5/interface" { | ||
import type { Debugger } from "debug"; | ||
import type { Context } from "semantic-release"; | ||
declare export { Debugger } from "debug"; | ||
declare export type TReleaseType = "patch" | "minor" | "major"; | ||
@@ -239,2 +252,3 @@ declare export type TTag = { | ||
step: TReleaseStep, | ||
debug: Debugger, | ||
... | ||
@@ -251,6 +265,10 @@ }; | ||
require: TReleaseStep[], | ||
debug: Debugger, | ||
... | ||
}; | ||
declare export type TPluginFactoryOptions = $Rest< | ||
TPluginFactoryOptionsNormalized, | ||
Omit<TPluginFactoryOptionsNormalized, "debug"> & { | ||
debug: string | Debugger, | ||
... | ||
}, | ||
{ ... } | ||
@@ -257,0 +275,0 @@ >; |
{ | ||
"name": "@qiwi/semrel-plugin-creator", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"private": false, | ||
@@ -45,3 +45,4 @@ "publishConfig": { | ||
"read-pkg-up": "^7.0.1", | ||
"lodash": "^4.17.20" | ||
"lodash": "^4.17.20", | ||
"debug": "^4.3.1" | ||
}, | ||
@@ -48,0 +49,0 @@ "devDependencies": { |
@@ -1,1 +0,1 @@ | ||
"use strict";var _a,_b,_c;Object.defineProperty(exports,"__esModule",{value:!0}),exports.createPlugin=exports.getStepConfigs=exports.getStepConfig=exports.normalizeOptions=exports.defaultOptions=exports.releaseSteps=void 0;var tslib_1=require("tslib"),lodash_1=require("lodash"),read_pkg_up_1=require("read-pkg-up");tslib_1.__exportStar(require("./interface"),exports),exports.releaseSteps=["verifyConditions","analyzeCommits","verifyRelease","generateNotes","prepare","publish","addChannel","success","fail"],exports.defaultOptions={include:exports.releaseSteps,exclude:[],require:[],handler:function(){return tslib_1.__awaiter(void 0,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return[2]}))}))},name:String(null===(_c=null===(_b=read_pkg_up_1.sync({cwd:null===(_a=null===module||void 0===module?void 0:module.parent)||void 0===_a?void 0:_a.filename}))||void 0===_b?void 0:_b.packageJson)||void 0===_c?void 0:_c.name)};var normalizeOptions=function(e){var t="function"==typeof e?{handler:e}:e;return tslib_1.__assign(tslib_1.__assign({},exports.defaultOptions),t)};exports.normalizeOptions=normalizeOptions;var checkPrevSteps=function(e,t,r){var n=e.invoked,i=t.name,o=t.require;if(0!==o.length){var s=exports.releaseSteps.slice(0,exports.releaseSteps.indexOf(r)).find((function(e){return o.includes(e)&&!n.includes(e)}));if(s)throw new Error("plugin '"+i+"' requires "+s+" to be invoked before "+r)}},getStepConfig=function(e,t,r){var n;return void 0===r&&(r=""),lodash_1.castArray(null===(n=e.options)||void 0===n?void 0:n[t]).map((function(e){if(Array.isArray(e)){var t=tslib_1.__read(e,2),r=t[0],n=t[1];return tslib_1.__assign(tslib_1.__assign({},n),{path:r})}return e})).find((function(e){return(null==e?void 0:e.path)===r}))};exports.getStepConfig=getStepConfig;var getStepConfigs=function(e,t){return void 0===t&&(t=""),exports.releaseSteps.reduce((function(r,n){return r[n]=exports.getStepConfig(e,n,t),r}),{})};exports.getStepConfigs=getStepConfigs;var metaContexts=new WeakMap,getMetaContext=function(e){var t=metaContexts.get(e);return t||(t={invoked:[]},metaContexts.set(e,t)),t},createPlugin=function(e){var t=exports.normalizeOptions(e),r=t.handler,n=t.include,i=t.exclude,o=t.name;return exports.releaseSteps.filter((function(e){return n.includes(e)&&!i.includes(e)})).reduce((function(e,n){return e[n]=function(e,i){var s=getMetaContext(i);checkPrevSteps(s,t,n),s.invoked.push(n);var a=exports.getStepConfigs(i,o),u=a[n];return r({pluginConfig:e,context:i,step:n,stepConfig:u,stepConfigs:a})},e}),{})};exports.createPlugin=createPlugin; | ||
"use strict";var _a,_b,_c;Object.defineProperty(exports,"__esModule",{value:!0}),exports.createPlugin=exports.getStepConfigs=exports.getStepConfig=exports.normalizeOptions=exports.defaultOptions=exports.releaseSteps=void 0;var tslib_1=require("tslib"),debug_1=tslib_1.__importDefault(require("debug")),lodash_1=require("lodash"),read_pkg_up_1=require("read-pkg-up");tslib_1.__exportStar(require("./interface"),exports),exports.releaseSteps=["verifyConditions","analyzeCommits","verifyRelease","generateNotes","prepare","publish","addChannel","success","fail"],exports.defaultOptions={include:exports.releaseSteps,exclude:[],require:[],handler:function(){return tslib_1.__awaiter(void 0,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return[2]}))}))},name:String(null===(_c=null===(_b=read_pkg_up_1.sync({cwd:null===(_a=null===module||void 0===module?void 0:module.parent)||void 0===_a?void 0:_a.filename}))||void 0===_b?void 0:_b.packageJson)||void 0===_c?void 0:_c.name)};var createDebugger=function(e){return"string"==typeof e?debug_1.default(e):e},normalizeOptions=function(e){var t="function"==typeof e?{handler:e}:e,r=createDebugger(t.debug||exports.defaultOptions.name);return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({},exports.defaultOptions),t),{debug:r})};exports.normalizeOptions=normalizeOptions;var checkPrevSteps=function(e,t,r){var n=e.invoked,i=t.name,o=t.require;if(0!==o.length){var s=exports.releaseSteps.slice(0,exports.releaseSteps.indexOf(r)).find((function(e){return o.includes(e)&&!n.includes(e)}));if(s)throw new Error("plugin '"+i+"' requires "+s+" to be invoked before "+r)}},getStepConfig=function(e,t,r){var n;return void 0===r&&(r=""),lodash_1.castArray(null===(n=e.options)||void 0===n?void 0:n[t]).map((function(e){if(Array.isArray(e)){var t=tslib_1.__read(e,2),r=t[0],n=t[1];return tslib_1.__assign(tslib_1.__assign({},n),{path:r})}return e})).find((function(e){return(null==e?void 0:e.path)===r}))};exports.getStepConfig=getStepConfig;var getStepConfigs=function(e,t){return void 0===t&&(t=""),exports.releaseSteps.reduce((function(r,n){return r[n]=exports.getStepConfig(e,n,t),r}),{})};exports.getStepConfigs=getStepConfigs;var metaContexts=new WeakMap,getMetaContext=function(e){var t=metaContexts.get(e);return t||(t={invoked:[]},metaContexts.set(e,t)),t},createPlugin=function(e){var t=exports.normalizeOptions(e),r=t.handler,n=t.include,i=t.exclude,o=t.name,s=t.debug;return exports.releaseSteps.filter((function(e){return n.includes(e)&&!i.includes(e)})).reduce((function(e,n){return e[n]=function(e,i){var a=getMetaContext(i);checkPrevSteps(a,t,n),a.invoked.push(n);var u=exports.getStepConfigs(i,o),p=u[n];return r({pluginConfig:e,context:i,step:n,stepConfig:p,stepConfigs:u,debug:s})},e}),{})};exports.createPlugin=createPlugin; |
@@ -0,2 +1,4 @@ | ||
import { Debugger } from 'debug'; | ||
import { Context } from 'semantic-release'; | ||
export { Debugger } from 'debug'; | ||
export declare type TReleaseType = 'patch' | 'minor' | 'major'; | ||
@@ -44,2 +46,3 @@ export declare type TTag = { | ||
step: TReleaseStep; | ||
debug: Debugger; | ||
}; | ||
@@ -53,4 +56,7 @@ export declare type TReleaseHandler = (context: TPluginHandlerContext) => Promise<any>; | ||
require: TReleaseStep[]; | ||
debug: Debugger; | ||
}; | ||
export declare type TPluginFactoryOptions = Partial<TPluginFactoryOptionsNormalized>; | ||
export declare type TPluginFactoryOptions = Partial<Omit<TPluginFactoryOptionsNormalized, 'debug'> & { | ||
debug: string | Debugger; | ||
}>; | ||
export declare type TPluginFactory = (handler: TPluginFactoryOptions | TReleaseHandler) => TPlugin; | ||
@@ -57,0 +63,0 @@ export declare type TPluginMetaContext = { |
@@ -1,1 +0,1 @@ | ||
"use strict";var _a,_b,_c;Object.defineProperty(exports,"__esModule",{value:!0}),exports.createPlugin=exports.getStepConfigs=exports.getStepConfig=exports.normalizeOptions=exports.defaultOptions=exports.releaseSteps=void 0;const tslib_1=require("tslib"),lodash_1=require("lodash"),read_pkg_up_1=require("read-pkg-up");tslib_1.__exportStar(require("./interface"),exports),exports.releaseSteps=["verifyConditions","analyzeCommits","verifyRelease","generateNotes","prepare","publish","addChannel","success","fail"],exports.defaultOptions={include:exports.releaseSteps,exclude:[],require:[],handler:()=>tslib_1.__awaiter(void 0,void 0,void 0,(function*(){})),name:String(null===(_c=null===(_b=read_pkg_up_1.sync({cwd:null===(_a=null===module||void 0===module?void 0:module.parent)||void 0===_a?void 0:_a.filename}))||void 0===_b?void 0:_b.packageJson)||void 0===_c?void 0:_c.name)};const normalizeOptions=e=>{const t="function"==typeof e?{handler:e}:e;return Object.assign(Object.assign({},exports.defaultOptions),t)};exports.normalizeOptions=normalizeOptions;const checkPrevSteps=({invoked:e},{name:t,require:s},n)=>{if(0===s.length)return;const o=exports.releaseSteps.slice(0,exports.releaseSteps.indexOf(n)).find((t=>s.includes(t)&&!e.includes(t)));if(o)throw new Error(`plugin '${t}' requires ${o} to be invoked before ${n}`)},getStepConfig=(e,t,s="")=>{var n;return lodash_1.castArray(null===(n=e.options)||void 0===n?void 0:n[t]).map((e=>{if(Array.isArray(e)){const[t,s]=e;return Object.assign(Object.assign({},s),{path:t})}return e})).find((e=>(null==e?void 0:e.path)===s))};exports.getStepConfig=getStepConfig;const getStepConfigs=(e,t="")=>exports.releaseSteps.reduce(((s,n)=>(s[n]=exports.getStepConfig(e,n,t),s)),{});exports.getStepConfigs=getStepConfigs;const metaContexts=new WeakMap,getMetaContext=e=>{let t=metaContexts.get(e);return t||(t={invoked:[]},metaContexts.set(e,t)),t},createPlugin=e=>{const t=exports.normalizeOptions(e),{handler:s,include:n,exclude:o,name:r}=t;return exports.releaseSteps.filter((e=>n.includes(e)&&!o.includes(e))).reduce(((e,n)=>(e[n]=(e,o)=>{const i=getMetaContext(o);checkPrevSteps(i,t,n),i.invoked.push(n);const p=exports.getStepConfigs(o,r),a=p[n];return s({pluginConfig:e,context:o,step:n,stepConfig:a,stepConfigs:p})},e)),{})};exports.createPlugin=createPlugin; | ||
"use strict";var _a,_b,_c;Object.defineProperty(exports,"__esModule",{value:!0}),exports.createPlugin=exports.getStepConfigs=exports.getStepConfig=exports.normalizeOptions=exports.defaultOptions=exports.releaseSteps=void 0;const tslib_1=require("tslib"),debug_1=tslib_1.__importDefault(require("debug")),lodash_1=require("lodash"),read_pkg_up_1=require("read-pkg-up");tslib_1.__exportStar(require("./interface"),exports),exports.releaseSteps=["verifyConditions","analyzeCommits","verifyRelease","generateNotes","prepare","publish","addChannel","success","fail"],exports.defaultOptions={include:exports.releaseSteps,exclude:[],require:[],handler:()=>tslib_1.__awaiter(void 0,void 0,void 0,(function*(){})),name:String(null===(_c=null===(_b=read_pkg_up_1.sync({cwd:null===(_a=null===module||void 0===module?void 0:module.parent)||void 0===_a?void 0:_a.filename}))||void 0===_b?void 0:_b.packageJson)||void 0===_c?void 0:_c.name)};const createDebugger=e=>"string"==typeof e?debug_1.default(e):e,normalizeOptions=e=>{const t="function"==typeof e?{handler:e}:e,r="string"==typeof(s=t.debug||exports.defaultOptions.name)?debug_1.default(s):s;var s;return Object.assign(Object.assign(Object.assign({},exports.defaultOptions),t),{debug:r})};exports.normalizeOptions=normalizeOptions;const checkPrevSteps=({invoked:e},{name:t,require:r},s)=>{if(0===r.length)return;const n=exports.releaseSteps.slice(0,exports.releaseSteps.indexOf(s)).find((t=>r.includes(t)&&!e.includes(t)));if(n)throw new Error(`plugin '${t}' requires ${n} to be invoked before ${s}`)},getStepConfig=(e,t,r="")=>{var s;return lodash_1.castArray(null===(s=e.options)||void 0===s?void 0:s[t]).map((e=>{if(Array.isArray(e)){const[t,r]=e;return Object.assign(Object.assign({},r),{path:t})}return e})).find((e=>(null==e?void 0:e.path)===r))};exports.getStepConfig=getStepConfig;const getStepConfigs=(e,t="")=>exports.releaseSteps.reduce(((r,s)=>(r[s]=exports.getStepConfig(e,s,t),r)),{});exports.getStepConfigs=getStepConfigs;const metaContexts=new WeakMap,getMetaContext=e=>{let t=metaContexts.get(e);return t||(t={invoked:[]},metaContexts.set(e,t)),t},createPlugin=e=>{const t=exports.normalizeOptions(e),{handler:r,include:s,exclude:n,name:o,debug:i}=t;return exports.releaseSteps.filter((e=>s.includes(e)&&!n.includes(e))).reduce(((e,s)=>(e[s]=(e,n)=>{const a=getMetaContext(n);checkPrevSteps(a,t,s),a.invoked.push(s);const p=exports.getStepConfigs(n,o),l=p[s];return r({pluginConfig:e,context:n,step:s,stepConfig:l,stepConfigs:p,debug:i})},e)),{})};exports.createPlugin=createPlugin; |
@@ -0,2 +1,4 @@ | ||
import { Debugger } from 'debug'; | ||
import { Context } from 'semantic-release'; | ||
export { Debugger } from 'debug'; | ||
export declare type TReleaseType = 'patch' | 'minor' | 'major'; | ||
@@ -44,2 +46,3 @@ export declare type TTag = { | ||
step: TReleaseStep; | ||
debug: Debugger; | ||
}; | ||
@@ -53,4 +56,7 @@ export declare type TReleaseHandler = (context: TPluginHandlerContext) => Promise<any>; | ||
require: TReleaseStep[]; | ||
debug: Debugger; | ||
}; | ||
export declare type TPluginFactoryOptions = Partial<TPluginFactoryOptionsNormalized>; | ||
export declare type TPluginFactoryOptions = Partial<Omit<TPluginFactoryOptionsNormalized, 'debug'> & { | ||
debug: string | Debugger; | ||
}>; | ||
export declare type TPluginFactory = (handler: TPluginFactoryOptions | TReleaseHandler) => TPlugin; | ||
@@ -57,0 +63,0 @@ export declare type TPluginMetaContext = { |
@@ -0,1 +1,2 @@ | ||
import debugFactory, { Debugger } from 'debug' | ||
import { castArray } from 'lodash' | ||
@@ -40,2 +41,10 @@ import { sync as readPkgUp } from 'read-pkg-up' | ||
const createDebugger = (scope: string | Debugger): Debugger => { | ||
if (typeof scope === 'string') { | ||
return debugFactory(scope) | ||
} | ||
return scope | ||
} | ||
export const normalizeOptions = ( | ||
@@ -47,3 +56,5 @@ options: TReleaseHandler | TPluginFactoryOptions, | ||
return { ...defaultOptions, ...preOptions } | ||
const debug = createDebugger(preOptions.debug || defaultOptions.name) | ||
return { ...defaultOptions, ...preOptions, debug } | ||
} | ||
@@ -119,3 +130,3 @@ | ||
const normalizedOpions = normalizeOptions(options) | ||
const { handler, include, exclude, name } = normalizedOpions | ||
const { handler, include, exclude, name, debug } = normalizedOpions | ||
@@ -135,3 +146,10 @@ return releaseSteps | ||
return handler({ pluginConfig, context, step, stepConfig, stepConfigs }) | ||
return handler({ | ||
pluginConfig, | ||
context, | ||
step, | ||
stepConfig, | ||
stepConfigs, | ||
debug, | ||
}) | ||
} | ||
@@ -138,0 +156,0 @@ |
@@ -0,3 +1,6 @@ | ||
import { Debugger } from 'debug' | ||
import { Context } from 'semantic-release' | ||
export { Debugger } from 'debug' | ||
export type TReleaseType = 'patch' | 'minor' | 'major' | ||
@@ -57,2 +60,3 @@ | ||
step: TReleaseStep | ||
debug: Debugger | ||
} | ||
@@ -68,5 +72,10 @@ | ||
require: TReleaseStep[] | ||
debug: Debugger | ||
} | ||
export type TPluginFactoryOptions = Partial<TPluginFactoryOptionsNormalized> | ||
export type TPluginFactoryOptions = Partial< | ||
Omit<TPluginFactoryOptionsNormalized, 'debug'> & { | ||
debug: string | Debugger | ||
} | ||
> | ||
@@ -73,0 +82,0 @@ export type TPluginFactory = ( |
// Generated by dts-bundle v0.7.4 | ||
// Dependencies for this module: | ||
// ../../../../../../../debug | ||
// ../../../../../../../semantic-release | ||
@@ -23,3 +24,5 @@ | ||
declare module '@qiwi/semrel-plugin-creator/target/es6/interface' { | ||
import { Debugger } from 'debug'; | ||
import { Context } from 'semantic-release'; | ||
export { Debugger } from 'debug'; | ||
export type TReleaseType = 'patch' | 'minor' | 'major'; | ||
@@ -67,2 +70,3 @@ export type TTag = { | ||
step: TReleaseStep; | ||
debug: Debugger; | ||
}; | ||
@@ -76,4 +80,7 @@ export type TReleaseHandler = (context: TPluginHandlerContext) => Promise<any>; | ||
require: TReleaseStep[]; | ||
debug: Debugger; | ||
}; | ||
export type TPluginFactoryOptions = Partial<TPluginFactoryOptionsNormalized>; | ||
export type TPluginFactoryOptions = Partial<Omit<TPluginFactoryOptionsNormalized, 'debug'> & { | ||
debug: string | Debugger; | ||
}>; | ||
export type TPluginFactory = (handler: TPluginFactoryOptions | TReleaseHandler) => TPlugin; | ||
@@ -87,2 +94,3 @@ export type TPluginMetaContext = { | ||
// Dependencies for this module: | ||
// ../../../../../../../debug | ||
// ../../../../../../../semantic-release | ||
@@ -108,3 +116,5 @@ | ||
declare module '@qiwi/semrel-plugin-creator/target/es5/interface' { | ||
import { Debugger } from 'debug'; | ||
import { Context } from 'semantic-release'; | ||
export { Debugger } from 'debug'; | ||
export type TReleaseType = 'patch' | 'minor' | 'major'; | ||
@@ -152,2 +162,3 @@ export type TTag = { | ||
step: TReleaseStep; | ||
debug: Debugger; | ||
}; | ||
@@ -161,4 +172,7 @@ export type TReleaseHandler = (context: TPluginHandlerContext) => Promise<any>; | ||
require: TReleaseStep[]; | ||
debug: Debugger; | ||
}; | ||
export type TPluginFactoryOptions = Partial<TPluginFactoryOptionsNormalized>; | ||
export type TPluginFactoryOptions = Partial<Omit<TPluginFactoryOptionsNormalized, 'debug'> & { | ||
debug: string | Debugger; | ||
}>; | ||
export type TPluginFactory = (handler: TPluginFactoryOptions | TReleaseHandler) => TPlugin; | ||
@@ -165,0 +179,0 @@ export type TPluginMetaContext = { |
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
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
52385
791
6
+ Addeddebug@^4.3.1
+ Addeddebug@4.3.5(transitive)
+ Addedms@2.1.2(transitive)