Skip to content

Commit

Permalink
Update dependencies (#10)
Browse files Browse the repository at this point in the history
* update all dependencies

* update src

* update tests

* update loggers

* latest updates

* new yarn lock

* add peerDependenciesMeta

* new yarn lock
  • Loading branch information
dalejo96 authored Jan 13, 2024
1 parent f581329 commit 688a4cf
Show file tree
Hide file tree
Showing 14 changed files with 3,750 additions and 4,232 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [18, 19, 20]
node: [18, 19, 20, 21]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: yarn
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.6.1
21.5.0
874 changes: 0 additions & 874 deletions .yarn/releases/yarn-3.6.0.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.2.cjs

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
compressionLevel: mixed

enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.6.0.cjs
yarnPath: .yarn/releases/yarn-4.0.2.cjs
41 changes: 25 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,37 @@
"release": "semantic-release",
"test": "NODE_ENV=test mocha"
},
"packageManager": "yarn@3.6.0",
"packageManager": "yarn@4.0.2",
"dependencies": {
"axios": "^1.6.0"
"axios": "^1.6.5"
},
"devDependencies": {
"@assertive-ts/core": "^2.0.0",
"@types/mocha": "^10.0.1",
"@types/semantic-release": "^20.0.1",
"@types/sinon": "^17.0.2",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"axios-mock-adapter": "^1.21.5",
"eslint": "^8.41.0",
"eslint-import-resolver-typescript": "^3.5.5",
"@types/mocha": "^10.0.6",
"@types/semantic-release": "^20.0.6",
"@types/signale": "^1.4.7",
"@types/sinon": "^17.0.3",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"axios-mock-adapter": "^1.22.0",
"eslint": "^8.56.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-etc": "^2.0.3",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsdoc": "^46.2.0",
"eslint-plugin-sonarjs": "^0.19.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.0.2",
"eslint-plugin-sonarjs": "^0.23.0",
"mocha": "^10.2.0",
"semantic-release": "^21.0.7",
"semantic-release": "^22.0.12",
"sinon": "^17.0.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.3"
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
"peerDependencies": {
"semantic-release": ">=22.0.0"
},
"peerDependenciesMeta": {
"semantic-release": {
"optional": false
}
}
}
6 changes: 3 additions & 3 deletions src/prepare.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Context } from "semantic-release";
import { PrepareContext } from "semantic-release";

import { PluginConfig } from "./types/pluginConfig";
import { runExecCommand } from "./utils/exec";
Expand All @@ -15,7 +15,7 @@ export const readAndWriteNewCabal = async (fullCabalPath: string, newVersion: st
await writeFile(fullCabalPath, newContents, "utf8");
};

export const prepare = async ({ cabalFile }: PluginConfig, { nextRelease, logger }: Context): Promise<void> => {
export const prepare = async ({ cabalFile }: PluginConfig, { nextRelease, logger }: PrepareContext): Promise<void> => {
const cabalFileName = cabalFile ?? getCabalFilename();
const { version } = nextRelease ?? {};

Expand Down Expand Up @@ -43,5 +43,5 @@ export const prepare = async ({ cabalFile }: PluginConfig, { nextRelease, logger
}

logger.log(output);
logger.log("Prepare done!");
logger.success("Prepare done!");
};
6 changes: 3 additions & 3 deletions src/publish.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from "axios";
import { Context } from "semantic-release";
import { BaseContext } from "semantic-release";

import { PluginConfig } from "./types/pluginConfig";
import { runExecCommand } from "./utils/exec";
Expand Down Expand Up @@ -30,7 +30,7 @@ export const postReleaseCandidate = async (
}
};

export const publish = async ({ packageName }: PluginConfig, { logger }: Context): Promise<void> => {
export const publish = async ({ packageName }: PluginConfig, { logger }: BaseContext): Promise<void> => {
logger.log("Getting sdist path");
const { error, output } = await runExecCommand(`ls dist-newstyle/sdist/${packageName}-*.tar.gz`);

Expand All @@ -46,5 +46,5 @@ export const publish = async ({ packageName }: PluginConfig, { logger }: Context
throw new Error(`Cannot post release candidate now, status: ${status}`);
}

logger.log("Publish done!");
logger.success("Publish done!");
};
6 changes: 3 additions & 3 deletions src/verifyConditions.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Context } from "semantic-release";
import { BaseContext } from "semantic-release";

import { PluginConfig } from "./types/pluginConfig";
import { EnvVarError } from "./utils/EnvVarError";

export const verifyConditions = (_pluginConfig: PluginConfig, { logger }: Context): void => {
export const verifyConditions = (_pluginConfig: PluginConfig, { logger }: BaseContext): void => {
const { HACKAGE_TOKEN } = process.env;

logger.log("Check environment variables");
if (!HACKAGE_TOKEN) {
throw new EnvVarError("HACKAGE_TOKEN");
}

logger.log("Verify conditions done!");
logger.success("Verify conditions done!");
};
88 changes: 64 additions & 24 deletions test/helpers/context.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,58 @@
import { Context } from "semantic-release";
import { VerifyConditionsContext, VerifyReleaseContext } from "semantic-release";
import Sinon from "sinon";

export const semanticContext: Context = {
const LoggerFake = {
addSecrets: Sinon.fake(),
await: Sinon.fake(),
clearSecrets: Sinon.fake(),
complete: Sinon.fake(),
config: Sinon.fake(),
debug: Sinon.fake(),
disable: Sinon.fake(),
enable: Sinon.fake(),
error: Sinon.fake(),
fatal: Sinon.fake(),
fav: Sinon.fake(),
info: Sinon.fake(),
isEnabled: Sinon.fake(),
log: Sinon.fake(),
note: Sinon.fake(),
pause: Sinon.fake(),
pending: Sinon.fake(),
scope: Sinon.fake(),
star: Sinon.fake(),
start: Sinon.fake(),
success: Sinon.fake(),
time: Sinon.fake(),
timeEnd: Sinon.fake(),
unscope: Sinon.fake(),
warn: Sinon.fake(),
watch: Sinon.fake(),
};

export const semanticVerifyReleaseContext: VerifyReleaseContext = {
branch: {
channel: "",
name: "main",
prerelease: false,
range: "",
},
branches: [],
commits: [],
env: {},
lastRelease: undefined,
logger: {
await: Sinon.fake(),
complete: Sinon.fake(),
debug: Sinon.fake(),
error: Sinon.fake(),
fatal: Sinon.fake(),
fav: Sinon.fake(),
info: Sinon.fake(),
log: Sinon.fake(),
note: Sinon.fake(),
pause: Sinon.fake(),
pending: Sinon.fake(),
star: Sinon.fake(),
start: Sinon.fake(),
success: Sinon.fake(),
wait: Sinon.fake(),
warn: Sinon.fake(),
watch: Sinon.fake(),
envCi: {
branch: "",
commit: "",
isCi: false,
},
lastRelease: {
channels: [],
gitHead: "",
gitTag: "",
name: "",
version: "",
},
logger: LoggerFake,
nextRelease: {
channel: "",
gitHead: "h1",
Expand All @@ -39,9 +62,26 @@ export const semanticContext: Context = {
type: "minor",
version: "1.0.0",
},
releases: [],
stderr: process.stderr,
stdout: process.stdout,
};

export const contextWithoutRelease: Context = {
...semanticContext,
nextRelease: undefined,
export const semanticVerifyConditionsContext: VerifyConditionsContext = {
branch: {
channel: "",
name: "main",
prerelease: false,
range: "",
},
branches: [],
env: {},
envCi: {
branch: "",
commit: "",
isCi: false,
},
logger: LoggerFake,
stderr: process.stderr,
stdout: process.stdout,
};
12 changes: 3 additions & 9 deletions test/integration/prepare.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Sinon from "sinon";
import { prepare } from "../../src/prepare";
import { PluginConfig } from "../../src/types/pluginConfig";
import * as exec from "../../src/utils/exec";
import { semanticContext, contextWithoutRelease } from "../helpers/context";
import { semanticVerifyReleaseContext } from "../helpers/context";

const pluginConfig: PluginConfig = {
cabalFile: "test/fixtures/test-1-package.cabal",
Expand All @@ -16,15 +16,9 @@ const pluginConfigWithoutCabal: PluginConfig = {
};

describe("prepare", () => {
context("when release does not exists", () => {
it("rejects the promise because of the release version", async () => {
await expect(prepare(pluginConfig, contextWithoutRelease)).toBeRejected();
});
});

context("when cabal file name does not exists", () => {
it("rejects the promise because of the cabal file", async () => {
await expect(prepare(pluginConfigWithoutCabal, semanticContext)).toBeRejected();
await expect(prepare(pluginConfigWithoutCabal, semanticVerifyReleaseContext)).toBeRejected();
});
});

Expand All @@ -33,7 +27,7 @@ describe("prepare", () => {
const runExecCommandStub = Sinon.stub();
runExecCommandStub.withArgs("cabal sdist").resolves({ error: null, output: "Mocked output" });
Sinon.replace(exec, "runExecCommand", runExecCommandStub);
await expect(prepare(pluginConfig, semanticContext)).toBeResolved();
await expect(prepare(pluginConfig, semanticVerifyReleaseContext)).toBeResolved();
});
});
});
6 changes: 3 additions & 3 deletions test/integration/verifyConditions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from "@assertive-ts/core";
import { PluginConfig } from "../../src/types/pluginConfig";
import { EnvVarError } from "../../src/utils/EnvVarError";
import { verifyConditions } from "../../src/verifyConditions";
import { semanticContext } from "../helpers/context";
import { semanticVerifyReleaseContext } from "../helpers/context";

const pluginConfig: PluginConfig = {
cabalFile: "test-1-package.cabal",
Expand All @@ -14,14 +14,14 @@ describe("verifyConditions", () => {
it("throws EnvVarError when HACKAGE_TOKEN is not defined", () => {
delete process.env.HACKAGE_TOKEN;

expect(() => verifyConditions(pluginConfig, semanticContext))
expect(() => verifyConditions(pluginConfig, semanticVerifyReleaseContext))
.toThrowError(EnvVarError)
.toHaveMessage("Environment variable not found: HACKAGE_TOKEN. Check the README.md for config info.");
});

it("does not throw EnvVarError when HACKAGE_TOKEN is defined", () => {
process.env.HACKAGE_TOKEN = "test_token";

expect(() => verifyConditions(pluginConfig, semanticContext)).not.toThrow();
expect(() => verifyConditions(pluginConfig, semanticVerifyReleaseContext)).not.toThrow();
});
});
Loading

0 comments on commit 688a4cf

Please sign in to comment.