Skip to content

Commit

Permalink
chore: upgrade deps
Browse files Browse the repository at this point in the history
  • Loading branch information
joscha committed Jun 29, 2021
1 parent 48cf002 commit 61cdf80
Show file tree
Hide file tree
Showing 26 changed files with 2,817 additions and 5,133 deletions.
27 changes: 8 additions & 19 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
{
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
],
"extends": ["plugin:@typescript-eslint/recommended", "prettier"],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/explicit-function-return-type": [ "error", { "allowExpressions": true }],
"@typescript-eslint/explicit-function-return-type": [
"error",
{ "allowExpressions": true }
],
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-parameter-properties": "off"
},
"overrides": [
{
"files": ["**/__tests__/**"],
"rules": {
"@typescript-eslint/camelcase": "off"
}
}
]
}
}
}
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage
dist
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"trailingComma": "all",
"tabWidth": 4,
"singleQuote": true
"singleQuote": true,
"semi": true
}
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: node_js
node_js:
- 10
- 12
- 14
- 16
jobs:
include:
# Define the release stage that runs semantic-release
Expand Down
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ module.exports = {
// timers: "real",

// A map from regular expressions to paths to transformers
// transform: null,
transform: {
'^.+\\.(ts|tsx)?$': 'ts-jest',
},

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
Expand Down
46 changes: 24 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,45 @@
],
"devDependencies": {
"@types/graphviz": "^0.0.32",
"@types/jest": "^26.0.14",
"@types/js-yaml": "^3.12.1",
"@types/jest": "^26.0.23",
"@types/js-yaml": "^4.0.1",
"@types/lodash.sortby": "^4.7.6",
"@types/node": "^14.11.8",
"@types/uniqid": "^5.2.0",
"@typescript-eslint/eslint-plugin": "^2.9.0",
"@typescript-eslint/parser": "^2.9.0",
"@types/node": "^15.12.5",
"@types/uniqid": "^5.3.0",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"cz-conventional-changelog": "3.3.0",
"eslint": "^7.11.0",
"eslint-config-prettier": "^6.7.0",
"husky": "^4.3.0",
"jest": "^26.5.3",
"prettier": "^2.1.2",
"pretty-quick": "^3.0.2",
"rimraf": "^3.0.0",
"semantic-release": "^17.2.0",
"ts-jest": "^26.4.1",
"ts-node": "^9.0.0",
"typescript": "^4.0.3"
"eslint": "^7.29.0",
"eslint-config-prettier": "^8.3.0",
"husky": "^6.0.0",
"jest": "^27.0.6",
"prettier": "^2.3.2",
"pretty-quick": "^3.1.1",
"rimraf": "^3.0.2",
"semantic-release": "^17.4.4",
"ts-jest": "^27.0.3",
"ts-node": "^10.0.0",
"typescript": "^4.3.4"
},
"scripts": {
"eslint": "eslint . --ext .js,.jsx,.ts,.tsx",
"prettier": "prettier --write .",
"preprepare": "rimraf dist/",
"prepare": "tsc",
"pretest": "yarn lint",
"lint": "eslint --ext .ts src",
"pretest": "prettier --check . && yarn lint",
"test": "jest --ci --coverage",
"test:watch": "jest --watch",
"test:watch": "jest --watch --notify",
"semantic-release": "semantic-release"
},
"dependencies": {
"@sindresorhus/slugify": "^1.1.0",
"graphviz": "^0.0.9",
"js-yaml": "^3.13.1",
"js-yaml": "^4.1.0",
"lodash.sortby": "^4.7.0",
"ow": "^0.18.0",
"ow": "^0.25.0",
"topological-sort": "^0.3.0",
"uniqid": "^5.2.0"
"uniqid": "^5.3.0"
},
"husky": {
"hooks": {
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/__snapshots__/command.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1659,7 +1659,7 @@ exports[`buildkite-graph Steps Command retry yaml 4`] = `
retry:
manual:
allowed: false
reason: 'Sorry, you can''t retry a deployment'
reason: Sorry, you can't retry a deployment
"
`;
Expand Down Expand Up @@ -1745,7 +1745,7 @@ exports[`buildkite-graph Steps Command retry yaml_depends_on 4`] = `
retry:
manual:
allowed: false
reason: 'Sorry, you can''t retry a deployment'
reason: Sorry, you can't retry a deployment
"
`;
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/conditional.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ describe('buildkite-graph', () => {

const tests = new MyConditional(
() =>
new Promise<Step>(resolve =>
new Promise<Step>((resolve) =>
setTimeout(
() =>
resolve(
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const createTest = (
describeFn = describe,
): void =>
describeFn(name, () => {
test.each(serializersToTest)('%s', async type => {
test.each(serializersToTest)('%s', async (type) => {
resetUuidCounter();
let entities = gen();
if (!Array.isArray(entities)) {
Expand Down
8 changes: 3 additions & 5 deletions src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export abstract class Step implements BaseStep, Serializable {

async toJson(
opts: ToJsonSerializationOptions = { explicitDependencies: false },
): Promise<object> {
): Promise<Record<string, unknown>> {
if (!opts.explicitDependencies) {
return {};
}
Expand All @@ -112,15 +112,13 @@ export abstract class Step implements BaseStep, Serializable {
opts.cache,
)
).map((s) => ({
/* eslint-disable @typescript-eslint/camelcase */
step: s.key,
allow_failure: this._allowDependencyFailure
? undefined
: this.always || undefined,
})),
'step',
);
/* eslint-disable @typescript-eslint/camelcase */
return {
key: this.key,
depends_on: dependsOn.length ? dependsOn : undefined,
Expand All @@ -139,7 +137,7 @@ export class BranchLimitedStep extends Step {
}
async toJson(
opts: ToJsonSerializationOptions = { explicitDependencies: false },
): Promise<object> {
): Promise<Record<string, unknown>> {
return {
branches: this.branches.size
? [...this.branches].sort().join(' ')
Expand All @@ -163,7 +161,7 @@ export class LabeledStep extends BranchLimitedStep {

async toJson(
opts: ToJsonSerializationOptions = { explicitDependencies: false },
): Promise<object> {
): Promise<Record<string, unknown>> {
return {
label: this.label,
...(await super.toJson(opts)),
Expand Down
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ export type ToJsonSerializationOptions =
cache: StepCache;
}
| { explicitDependencies: false };

type JSON = Record<string, unknown> | JSON[];
export interface Serializable {
toJson(opts?: ToJsonSerializationOptions): Promise<object | undefined>;
toJson(opts?: ToJsonSerializationOptions): Promise<JSON | undefined>;
}

export type PotentialStep = Step | Conditional<Step>;
Expand All @@ -60,7 +62,7 @@ export class Pipeline implements Serializable {
}

add(...step: PotentialStep[]): this {
step.forEach(s => {
step.forEach((s) => {
if (this.steps.includes(s)) {
throw new Error('Can not add the same step more than once');
}
Expand Down Expand Up @@ -110,7 +112,7 @@ export class Pipeline implements Serializable {

async toJson(
opts: SerializationOptions = { explicitDependencies: false },
): Promise<object> {
): Promise<Record<string, unknown>> {
const newOpts: ToJsonSerializationOptions = opts.explicitDependencies
? {
explicitDependencies: true,
Expand All @@ -123,7 +125,7 @@ export class Pipeline implements Serializable {
return {
env: await (this.env as KeyValueImpl<this>).toJson(),
steps: await Promise.all(
(await this.toList(newOpts)).map(s => s.toJson(newOpts)),
(await this.toList(newOpts)).map((s) => s.toJson(newOpts)),
),
};
}
Expand Down
8 changes: 5 additions & 3 deletions src/key_value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ export interface KeyValue<T> {
set(name: string, value: string): T;
}

export class KeyValueImpl<T> extends Chainable<T>
implements KeyValue<T>, Serializable {
export class KeyValueImpl<T>
extends Chainable<T>
implements KeyValue<T>, Serializable
{
public readonly vars: Map<string, string> = new Map();

set(name: string, value: string): T {
Expand All @@ -17,7 +19,7 @@ export class KeyValueImpl<T> extends Chainable<T>
return this.parent;
}

async toJson(): Promise<object | undefined> {
async toJson(): Promise<Record<string, unknown> | undefined> {
return this.vars.size ? mapToObject(this.vars) : undefined;
}
}
6 changes: 4 additions & 2 deletions src/serializers/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ type JsonSerializationOptions = {
stringify?: boolean;
} & SerializationOptions;

export class JsonSerializer implements Serializer<object | string> {
export class JsonSerializer
implements Serializer<Record<string, unknown> | string>
{
constructor(private readonly opts: JsonSerializationOptions = {}) {}

async serialize(e: Pipeline): Promise<object | string> {
async serialize(e: Pipeline): Promise<Record<string, unknown> | string> {
const serialized = JSON.stringify(await e.toJson(this.opts));
// Workaround to get rid of undefined values
return this.opts.stringify ? serialized : JSON.parse(serialized);
Expand Down
2 changes: 1 addition & 1 deletion src/serializers/structural.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { Serializer } from '.';
export class StructuralSerializer implements Serializer<string> {
async serialize(p: Pipeline): Promise<string> {
const steps = await p.toList();
return steps.map(step => `* ${step.toString()}`).join('\n');
return steps.map((step) => `* ${step.toString()}`).join('\n');
}
}
6 changes: 4 additions & 2 deletions src/serializers/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import { Serializer } from '.';
import { JsonSerializer } from './json';

export class YamlSerializer implements Serializer<string> {
private readonly jsonSerializer: Serializer<string | object>;
private readonly jsonSerializer: Serializer<
string | Record<string, unknown>
>;

constructor(opts: SerializationOptions = {}) {
this.jsonSerializer = new JsonSerializer({ ...opts, stringify: false });
}

async serialize(e: Pipeline): Promise<string> {
return jsyaml.safeDump(await this.jsonSerializer.serialize(e), {
return jsyaml.dump(await this.jsonSerializer.serialize(e), {
skipInvalid: true,
noRefs: true,
styles: {
Expand Down
6 changes: 3 additions & 3 deletions src/sortedSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function sortedSteps(
): Promise<Step[]> {
const steps = await unwrapSteps(e.steps, cache);
const sortOp = new TopologicalSort<Step, Step>(
new Map(steps.map(step => [step, step])),
new Map(steps.map((step) => [step, step])),
);

async function getAndCacheDependency(
Expand Down Expand Up @@ -110,6 +110,6 @@ export async function sortedSteps(
}
}
return Array.from(sortOp.sort().values())
.map(i => i.node)
.filter(s => !removedEffects.has(s));
.map((i) => i.node)
.filter((s) => !removedEffects.has(s));
}
2 changes: 1 addition & 1 deletion src/steps/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class BlockStep extends BranchLimitedStep {

async toJson(
opts: ToJsonSerializationOptions = { explicitDependencies: false },
): Promise<object> {
): Promise<Record<string, unknown>> {
return {
...(await super.toJson(opts)),
block: this.title,
Expand Down
Loading

0 comments on commit 61cdf80

Please sign in to comment.