File tree Expand file tree Collapse file tree 10 files changed +83
-23
lines changed Expand file tree Collapse file tree 10 files changed +83
-23
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"hooks" : {
3
- "pre-commit" : " lint-staged" ,
3
+ "pre-commit" : " npm run ts-compile-check && lint-staged" ,
4
4
"commit-msg" : " commitlint -E HUSKY_GIT_PARAMS"
5
5
}
6
6
}
Original file line number Diff line number Diff line change 5
5
"main" : " src/index.js" ,
6
6
"scripts" : {
7
7
"lint" : " prettier-standard --lint '{src,test}/**/*.js'" ,
8
+ "ts-compile-check" : " tsc -p tsconfig.json --noEmit" ,
8
9
"test" : " nyc mocha test"
9
10
},
10
11
"engines" : {
37
38
"@types/chai" : " 4.2.12" ,
38
39
"@types/mocha" : " 8.0.3" ,
39
40
"@types/node" : " 12.12.55" ,
41
+ "@types/semantic-release" : " 17.1.0" ,
40
42
"chai" : " 4.2.0" ,
41
43
"eslint" : " 7.8.1" ,
42
44
"eslint-plugin-array-func" : " 3.1.7" ,
57
59
"semantic-release" : " 17.1.1" ,
58
60
"sinon" : " 9.0.3" ,
59
61
"stream-buffers" : " 3.0.2" ,
60
- "tempy" : " 0.6.0"
62
+ "tempy" : " 0.6.0" ,
63
+ "typescript" : " 4.0.2"
61
64
},
62
65
"peerDependencies" : {
63
66
"semantic-release" : " >=11.0.0 <18.0.0"
Original file line number Diff line number Diff line change 1
1
/**
2
- * @typedef {import('semantic-release').Context } Context
2
+ * @typedef {import('./types').Context } Context
3
+ * @typedef {import('./types').SemanticReleaseError } SemanticReleaseError
3
4
*/
5
+
6
+ const pkg = require ( '../package.json' )
7
+
8
+ const [ homepage ] = pkg . homepage . split ( '#' )
9
+ /* eslint-disable no-unused-vars */
4
10
/**
5
- * @typedef {Object } SemanticReleaseError
6
- * @property {string } message -
7
- * @property {string } details -
11
+ * @param {string } file -
12
+ * @returns {string } -
13
+ * @example
14
+ * const link = linkify(href)
8
15
*/
16
+ const linkify = file => `${ homepage } /blob/master/${ file } `
17
+ /* eslint-enable no-unused-vars */
9
18
10
19
module . exports = new Map ( [
11
20
[
@@ -14,7 +23,7 @@ module.exports = new Map([
14
23
* @param {Context } ctx -
15
24
* @returns {SemanticReleaseError } -
16
25
*/
17
- ( ctx ) => ( {
26
+ ctx => ( {
18
27
message : 'A custom message.' ,
19
28
details : 'A custom description.'
20
29
} )
Original file line number Diff line number Diff line change 1
1
const SemanticReleaseError = require ( '@semantic-release/error' )
2
2
const ERROR_DEFINITIONS = require ( './errors' )
3
3
4
- /** @typedef {import('semantic-release ').Context } Context */
4
+ /** @typedef {import('./types ').Context } Context */
5
5
/**
6
6
* @param {string } code -
7
7
* @param {Context } ctx -
8
8
* @returns {Error } -
9
9
* @example
10
10
* const throw getError('CUSTOMERROR')
11
11
*/
12
- module . exports = ( code , ctx = { } ) => {
12
+ module . exports = ( code , ctx ) => {
13
13
const { message, details } = ERROR_DEFINITIONS . get ( code ) ( ctx )
14
14
return new SemanticReleaseError ( message , code , details )
15
15
}
Original file line number Diff line number Diff line change 1
1
/**
2
- * @typedef {import('semantic-release ').Context } Context
3
- * @typedef {import('semantic-release ').Config } Config
2
+ * @typedef {import('./types ').Context } Context
3
+ * @typedef {import('./types ').Config } Config
4
4
*/
5
5
/**
6
6
* @param {Config } pluginConfig -
Original file line number Diff line number Diff line change
1
+ import {
2
+ Config as SemanticReleaseConfig ,
3
+ Context as SemanticReleaseContext ,
4
+ Result as SemanticReleaseResult
5
+ } from 'semantic-release'
6
+
7
+ export interface Context
8
+ extends SemanticReleaseContext ,
9
+ SemanticReleaseConfig ,
10
+ SemanticReleaseResult { }
11
+
12
+ export interface Config { }
13
+
14
+ export interface SemanticReleaseError {
15
+ message : string
16
+ details : string
17
+ }
Original file line number Diff line number Diff line change 1
1
const getError = require ( './get-error' )
2
2
3
3
/**
4
- * @typedef {import('semantic-release ').Context } Context
5
- * @typedef {import('semantic-release ').Config } Config
4
+ * @typedef {import('./types ').Context } Context
5
+ * @typedef {import('./types ').Config } Config
6
6
*/
7
7
/**
8
8
* @param {Config } pluginConfig -
@@ -13,6 +13,6 @@ const getError = require('./get-error')
13
13
*/
14
14
module . exports = ( pluginConfig , ctx ) => {
15
15
if ( ! ctx . env . CUSTOM_ENV ) {
16
- throw getError ( 'CUSTOMERROR' )
16
+ throw getError ( 'CUSTOMERROR' , ctx )
17
17
}
18
18
}
Original file line number Diff line number Diff line change 1
- const { describe, it, before } = require ( 'mocha' )
1
+ const { describe, it } = require ( 'mocha' )
2
2
const { expect } = require ( 'chai' )
3
3
const tempy = require ( 'tempy' )
4
4
const verify = require ( '../src/verify' )
5
5
6
6
describe ( 'Verify' , ( ) => {
7
- let cwd
8
-
9
- before ( ( ) => {
10
- cwd = tempy . directory ( )
11
- } )
7
+ /** @type {import('../src/types').Context } */
8
+ const ctx = {
9
+ cwd : tempy . directory ( ) ,
10
+ env : { } ,
11
+ logger : { log : ( ) => ( { } ) , error : ( ) => ( { } ) }
12
+ }
12
13
13
14
it ( 'Return SemanticReleaseError if a custom environment variable is not defined' , async ( ) => {
14
15
try {
15
- await verify ( { } , { cwd , env : { } } )
16
+ await verify ( { } , ctx )
16
17
} catch ( err ) {
17
18
expect ( err . name ) . to . equal ( 'SemanticReleaseError' )
18
19
expect ( err . code ) . to . equal ( 'CUSTOMERROR' )
19
20
}
20
21
} )
21
22
22
23
it ( 'Verify alias from a custom environmen variable' , async ( ) => {
23
- const env = { CUSTOM_ENV : 'custom' }
24
- expect ( await verify ( { } , { cwd , env } ) ) . to . be . a ( 'undefined' )
24
+ ctx . env = { CUSTOM_ENV : 'custom' }
25
+ expect ( await verify ( { } , ctx ) ) . to . be . a ( 'undefined' )
25
26
} )
26
27
} )
Original file line number Diff line number Diff line change
1
+ {
2
+ "compilerOptions" : {
3
+ "lib" : [ " es2017" , " es7" ],
4
+ "allowJs" : true ,
5
+ "checkJs" : true ,
6
+ "downlevelIteration" : true ,
7
+ "outDir" : " build" ,
8
+ "skipLibCheck" : true ,
9
+ "resolveJsonModule" : true
10
+ },
11
+ "exclude" : [
12
+ " node_modules" ,
13
+ " coverage"
14
+ ]
15
+ }
You can’t perform that action at this time.
0 commit comments