Skip to content

Commit

Permalink
Merge pull request #53 from dolittle/update-dependencies
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
woksin authored Dec 5, 2022
2 parents cb95abd + b003885 commit e7025e3
Show file tree
Hide file tree
Showing 51 changed files with 1,988 additions and 3,942 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# EditorConfig helps create consistency for formatting of all
# the code in Dolittle
#
# http://EditorConfig.org

root = true

[*]
end_of_line = lf
indent_style = space
indent_size = 4
charset = utf-8

[*.yml]
indent_size = 2

[*.{js, ts}]
quote_type = single
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.d.ts
node_modules
dist
out
Distribution
wallaby.conf.js
coverage
.eslintrc.js
92 changes: 92 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright (c) Dolittle. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

module.exports = {
extends: '@dolittle',
rules: {
'@typescript-eslint/unified-signatures': 'off',
'import/no-extraneous-dependencies': 'off',
'eol-last': 'error',
'no-multiple-empty-lines': ['error', {'max': 1, 'maxEOF': 0 }],
'header/header': [
2,
'line',
[
' Copyright (c) Dolittle. All rights reserved.',
' Licensed under the MIT license. See LICENSE file in the project root for full license information.',
],
2
],
'jsdoc/require-param-name': 'error',
'jsdoc/require-param-type': 'error',
'jsdoc/check-alignment': 'error',
'jsdoc/check-indentation': 'error',
'jsdoc/valid-types': 'error',
'jsdoc/require-hyphen-before-param-description': 'error',
'jsdoc/check-line-alignment': 'error',
'jsdoc/require-returns-check': 'error',
'jsdoc/require-returns-description': 'error',
'jsdoc/require-returns-type': 'error',
'jsdoc/check-tag-names': 'error',
'jsdoc/check-param-names': 'error',
'jsdoc/check-types': 'error',
'jsdoc/empty-tags': 'error',
'jsdoc/no-bad-blocks': 'error',
'jsdoc/no-undefined-types': 'error',
'jsdoc/multiline-blocks': 'error',
'jsdoc/no-multi-asterisks': 'error',
'jsdoc/require-asterisk-prefix': 'error',
'jsdoc/require-description-complete-sentence': 'error',
'jsdoc/require-param': 'error',
'jsdoc/require-param-description': 'error',
'jsdoc/tag-lines': ['error', 'always', { 'count': 0 }],

'jsdoc/require-jsdoc': ['error', {
'require': {
'FunctionDeclaration': false
},
'contexts': [
'ExportNamedDeclaration>TSTypeAliasDeclaration',
'ExportNamedDeclaration>TSInterfaceDeclaration',
'ExportNamedDeclaration>ClassDeclaration',
'ExportNamedDeclaration[declaration.type="TSDeclareFunction"]:not(ExportNamedDeclaration[declaration.type="TSDeclareFunction"] + ExportNamedDeclaration[declaration.type="TSDeclareFunction"])',
'ExportNamedDeclaration[declaration.type="FunctionDeclaration"]:not(ExportNamedDeclaration[declaration.type="TSDeclareFunction"] + ExportNamedDeclaration[declaration.type="FunctionDeclaration"])',
'MethodDefinition[accessibility!="private"][value.type="TSEmptyBodyFunctionExpression"]:not(MethodDefinition[value.type="TSEmptyBodyFunctionExpression"] + MethodDefinition[value.type="TSEmptyBodyFunctionExpression"])',
'MethodDefinition[accessibility!="private"][value.type="FunctionExpression"]:not(MethodDefinition[value.type="TSEmptyBodyFunctionExpression"] + MethodDefinition[value.type="FunctionExpression"])',
]
}],

'jsdoc/require-returns': ['error', {
'contexts': [
'ArrowFunctionExpression',
'FunctionDeclaration',
'MethodDefinition[kind!="get"]'
]
}],

'jsdoc/require-description': ['error', {
'descriptionStyle': 'body',
'contexts': ['any']
}],
// This is nice - but makes the linter horribly slow
// 'jsdoc/match-description': ['error', {
// matchDescription: '^(?:[^\\{]+|\\{@link [^\\}]+\\})+$',
// tags: {
// param: true
// },
// message: 'Descriptions must use {@link ...} for references to other types.'
// }],
},
overrides: [
{
files: ['**/for_*/**'],
rules: {
'@typescript-eslint/naming-convention': 'off',
'import/no-extraneous-dependencies': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'no-restricted-globals': 'off',
'jsdoc/require-jsdoc': 'off',
},
},
],
};
2 changes: 1 addition & 1 deletion .github/workflows/create-default-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
name: Create Default Labels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1.0.0
- uses: actions/checkout@3
- name: Create labels
uses: lannonbr/[email protected]
env:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/github-javascript-actions-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup node v12
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: Setup node v16
uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 16.x
- run: yarn
- run: yarn release

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/github-javascript-actions-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup node v12
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: Setup node v16
uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 16.x
- run: yarn
- name: Release GitHub Action
uses: technote-space/release-github-actions@v6
Expand Down
7 changes: 7 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) Dolittle. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

require('reflect-metadata');
const dolittle = require('@dolittle/typescript.testing/.mocharc.js');

module.exports = dolittle;
7 changes: 3 additions & 4 deletions Source/CascadingBuildContextEstablisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ import { IFindCurrentVersion } from './Version/IFindCurrentVersion';
/**
* Represents an implementation of {@link ICanEstablishContext}.
*
* @export
* @class CascadingContextEstablisher
* @implements {ICanEstablishContext}
*/
export class CascadingContextEstablisher implements ICanEstablishContext {

/**
* Initializes a new instance of {@link CascadingContextEstablisher}
* @param {IFindCurrentVersion} _currentVersionFinder The current version finder to use for finding the current version.
* @param {ILogger} _logger The logger to use for logging.
* Initializes a new instance of {@link CascadingContextEstablisher}.
* @param {IFindCurrentVersion} _currentVersionFinder - The current version finder to use for finding the current version.
* @param {ILogger} _logger - The logger to use for logging.
*/
constructor(
private readonly _currentVersionFinder: IFindCurrentVersion,
Expand Down
7 changes: 3 additions & 4 deletions Source/ContextEstablishers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ import { ICanEstablishContext } from './ICanEstablishContext';
/**
* Represents an implementation of {@link IContextEstablishers}.
*
* @export
* @class ContextEstablishers
* @implements {IContextEstablishers}
*/
export class ContextEstablishers implements IContextEstablishers {
private readonly _establishers: ICanEstablishContext[];

/**
* Initializes a new instance of {@link ContextEstablishers}
* @param {ICanEstablishContext[]} establishers The implementations of context establishers to use.
* Initializes a new instance of {@link ContextEstablishers}.
* @param {ICanEstablishContext[]} establishers - The implementations of context establishers to use.
*/
constructor(...establishers: ICanEstablishContext[]) {
this._establishers = establishers;
Expand All @@ -33,7 +32,7 @@ export class ContextEstablishers implements IContextEstablishers {
}

private getEstablisherFor(context: Context): ICanEstablishContext | undefined {
let establisher: ICanEstablishContext | undefined = undefined;
let establisher: ICanEstablishContext | undefined;
for (const _establisher of this._establishers) {
if (_establisher.canEstablishFrom(context)) {
if (establisher !== undefined) {
Expand Down
6 changes: 2 additions & 4 deletions Source/ICanEstablishContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,22 @@ import { BuildContext } from './BuildContext';
/**
* Defines a system that can establish the build context of the Github Action.
*
* @export
* @interface ICanEstablishContext
*/
export interface ICanEstablishContext {

/**
* Whether it can establish from a given context.
*
* @param {Context} context The github {Context}.
* @param {Context} context - The github {Context}.
* @returns {boolean} Whether it can establish from {Context}.
*/
canEstablishFrom(context: Context): boolean

/**
* Establishes a {BuildContext} from the given github {Context}.
*
* @param {Context} context The github context.
* @param {InstanceType<typeof GitHub>} github The github REST api.
* @param {Context} context - The github context.
* @returns {Promise<BuildContext>} A {Promise} that, when resolved, returns the {BuildContext}.
*/
establish(context: Context): Promise<BuildContext>
Expand Down
5 changes: 1 addition & 4 deletions Source/IContextEstablishers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ import { BuildContext } from './BuildContext';
/**
* Defines a system that knows about {@link ICanEstablishContext} implementations.
*
* @export
* @interface IContextEstablishers
*/

export interface IContextEstablishers {

/**
* Establishes a {@link BuildContext} from the given github {@link Context}.
*
* @param {Context} context The GitHub context.
* @param {InstanceType<typeof GitHub>} github The GitHub REST api.
* @param {Context} context - The GitHub context.
* @returns {Promise<BuildContext>} A {@link Promise} that, when resolved, returns the {@link BuildContext}.
*/
establishFrom(context: Context): Promise<BuildContext> | Promise<undefined>;
Expand Down
21 changes: 10 additions & 11 deletions Source/MergedPullRequestContextEstablisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,19 @@ const nonPrereleaseLabels = [
/**
* Represents an implementation of {@link ICanEstablishContext}.
*
* @export
* @class MergedPullRequestContextEstablisher
* @implements {ICanEstablishContext}
*/
export class MergedPullRequestContextEstablisher implements ICanEstablishContext {

/**
* Initializes a new instance of {@link MergedPullRequestContextEstablisher}
* @param {string[]} _prereleaseBranches A list of branches that should be considered as pre-release branches.
* @param {string} _environmentBranch An environment to use for prereleases.
* @param {IReleaseTypeExtractor} _releaseTypeExtractor The release type extractor to use for extracting the release type from Pull Request labels.
* @param {IFindCurrentVersion} _currentVersionFinder The current version finder to use for finding the current version.
* @param {InstanceType<typeof GitHub>} _github The github REST api.
* @param {ILogger} _logger The logger to use for logging.
* Initializes a new instance of {@link MergedPullRequestContextEstablisher}.
* @param {string[]} _prereleaseBranches - A list of branches that should be considered as pre-release branches.
* @param {string} _environmentBranch - An environment to use for prereleases.
* @param {IReleaseTypeExtractor} _releaseTypeExtractor - The release type extractor to use for extracting the release type from Pull Request labels.
* @param {IFindCurrentVersion} _currentVersionFinder - The current version finder to use for finding the current version.
* @param {InstanceType<typeof GitHub>} _github - The github REST api.
* @param {ILogger} _logger - The logger to use for logging.
*/
constructor(
private readonly _prereleaseBranches: string[],
Expand Down Expand Up @@ -95,7 +94,7 @@ export class MergedPullRequestContextEstablisher implements ICanEstablishContext
return {
shouldPublish: false,
cascadingRelease: false,
pullRequestBody: mergedPr.body,
pullRequestBody: mergedPr.body ?? undefined,
pullRequestUrl: mergedPr.html_url,
};
}
Expand All @@ -107,15 +106,15 @@ export class MergedPullRequestContextEstablisher implements ICanEstablishContext
cascadingRelease: false,
releaseType,
currentVersion: currentVersion.version,
pullRequestBody: mergedPr.body,
pullRequestBody: mergedPr.body ?? undefined,
pullRequestUrl: mergedPr.html_url
};
}

private async _getMergedPr(owner: string, repo: string, sha: string) {
this._logger.debug(`Trying to get merged PR with merge_commit_sha: ${sha}`);
const mergedPr = await this._github.paginate(
this._github.pulls.list,
this._github.rest.pulls.list,
{ owner, repo, state: 'closed', sort: 'updated', direction: 'desc' }
).then(data => data.find(pr => pr.merge_commit_sha === sha));
return mergedPr;
Expand Down
4 changes: 2 additions & 2 deletions Source/ReleaseType/IReleaseTypeExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

import { ReleaseType } from 'semver';

/**
/**.
* Defines a system that can extract a release type from a list of labels
*
* @export
* @interface IReleaseTypeExtractor
*/
export interface IReleaseTypeExtractor {

/**
/**.
* Extracts a release type from a list of labels
*
* @param {string[]} labels
Expand Down
4 changes: 2 additions & 2 deletions Source/ReleaseType/ReleaseTypeExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const prioritizedReleaseTypes: ReleaseType[] = [
'prerelease'
];

/**
/**.
* Represents an implementation of {IReleaseTypeExtractor}
*
* @export
Expand All @@ -26,7 +26,7 @@ export class ReleaseTypeExtractor implements IReleaseTypeExtractor {

/**
* Creates an instance of ReleaseTypeExtractor.
* @param {ILogger} _logger The logger to use for logging.
* @param {ILogger} _logger - The logger to use for logging.
*/
constructor(private _logger: ILogger) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

import { expect } from 'chai';
import { describeThis } from '@dolittle/typescript.testing';
import { an_extractor } from './given/an_extractor';

describe('when extracting from empty string', () => {
describeThis(__filename, () => {
const extractor = new an_extractor().extractor;
const labels: string[] = [];
const result = extractor.extract(labels);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import { expect } from 'chai';
import { an_extractor } from './given/an_extractor';

describe('when extracting from string with multiple non release types', () => {
import { describeThis } from '@dolittle/typescript.testing';

describeThis(__filename, () => {
const extractor = new an_extractor().extractor;
const labels = ['something','somethingElse'];
const result = extractor.extract(labels);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import { expect } from 'chai';
import { an_extractor } from './given/an_extractor';

describe('when extracting from string with multiple release types', () => {
import { describeThis } from '@dolittle/typescript.testing';

describeThis(__filename, () => {
const extractor = new an_extractor().extractor;
const labels = ['major','minor'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import { expect } from 'chai';
import { an_extractor } from './given/an_extractor';

describe('when extracting from string with only a non release type', () => {
import { describeThis } from '@dolittle/typescript.testing';

describeThis(__filename, () => {
const extractor = new an_extractor().extractor;
const labels = ['something'];
const result = extractor.extract(labels);
Expand Down
Loading

0 comments on commit e7025e3

Please sign in to comment.