Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump @semantic-release/error from 3.0.0 to 4.0.0 #470

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @ts-check

const createError = async (message, code) => {
const SemanticReleaseError = (await import('@semantic-release/error'))
.default;
return new SemanticReleaseError(message, code);
};

module.exports = {
createError,
};
6 changes: 3 additions & 3 deletions lib/verify-ovsx-auth.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// @ts-check

const SemanticReleaseError = require('@semantic-release/error');
const { createError } = require('./error');
const execa = require('execa');

module.exports = async (logger, cwd) => {
logger.log('Verifying authentication for ovsx');

if (!process.env.OVSX_PAT) {
throw new SemanticReleaseError(
throw await createError(
'Empty ovsx personal access token (`OVSX_PAT` environment variable) specified.',
'EEMPTYOVSXPAT',
);
Expand All @@ -16,7 +16,7 @@ module.exports = async (logger, cwd) => {
try {
await execa('ovsx', ['verify-pat'], { preferLocal: true, cwd });
} catch (e) {
throw new SemanticReleaseError(
throw await createError(
`Invalid ovsx personal access token. Additional information:\n\n${e}`,
'EINVALIDOVSXPAT',
);
Expand Down
13 changes: 5 additions & 8 deletions lib/verify-pkg.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// @ts-check

const SemanticReleaseError = require('@semantic-release/error');
const { createError } = require('./error');
const { readJson } = require('fs-extra');
const fs = require('fs');

module.exports = async () => {
if (!fs.existsSync('./package.json')) {
throw new SemanticReleaseError(
throw await createError(
'The `package.json` was not found. A `package.json` is required to release with vsce.',
'ENOPKG',
);
Expand All @@ -17,7 +17,7 @@ module.exports = async () => {
try {
packageJson = await readJson('./package.json');
} catch {
throw new SemanticReleaseError(
throw await createError(
'The `package.json` seems to be invalid.',
'EINVALIDPKG',
);
Expand All @@ -26,13 +26,10 @@ module.exports = async () => {
const { name, publisher } = packageJson;

if (!name) {
throw new SemanticReleaseError(
'No `name` found in `package.json`.',
'ENOPKGNAME',
);
throw await createError('No `name` found in `package.json`.', 'ENOPKGNAME');
}
if (!publisher) {
throw new SemanticReleaseError(
throw await createError(
'No `publisher` found in `package.json`.',
'ENOPUBLISHER',
);
Expand Down
6 changes: 3 additions & 3 deletions lib/verify-target.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

const SemanticReleaseError = require('@semantic-release/error');
const { createError } = require('./error');
const { isTargetEnabled } = require('./utils');

module.exports = async () => {
Expand All @@ -9,7 +9,7 @@ module.exports = async () => {
}

if (!process.env.VSCE_TARGET) {
throw new SemanticReleaseError(
throw await createError(
'Empty vsce target specified.',
'EINVALIDVSCETARGET',
);
Expand All @@ -20,7 +20,7 @@ module.exports = async () => {

// Throw if the target is not supported
if (!targets.has(process.env.VSCE_TARGET)) {
throw new SemanticReleaseError(
throw await createError(
`Unsupported vsce target: ${
process.env.VSCE_TARGET
}. Available targets: ${Object.values(targets).join(', ')}`,
Expand Down
6 changes: 3 additions & 3 deletions lib/verify-vsce-auth.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// @ts-check

const SemanticReleaseError = require('@semantic-release/error');
const { createError } = require('./error');
const execa = require('execa');

module.exports = async (logger, cwd) => {
logger.log('Verifying authentication for vsce');

if (!process.env.VSCE_PAT) {
throw new SemanticReleaseError(
throw await createError(
'Empty vsce personal access token (`VSCE_PAT` environment variable) specified.',
'EEMPTYVSCEPAT',
);
Expand All @@ -16,7 +16,7 @@ module.exports = async (logger, cwd) => {
try {
await execa('vsce', ['verify-pat'], { preferLocal: true, cwd });
} catch (e) {
throw new SemanticReleaseError(
throw await createError(
`Invalid vsce personal access token. Additional information:\n\n${e}`,
'EINVALIDVSCEPAT',
);
Expand Down
4 changes: 2 additions & 2 deletions lib/verify.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

const SemanticReleaseError = require('@semantic-release/error');
const { createError } = require('./error');
const verifyPkg = require('./verify-pkg');
const verifyVsceAuth = require('./verify-vsce-auth');
const verifyOvsxAuth = require('./verify-ovsx-auth');
Expand All @@ -15,7 +15,7 @@ module.exports = async (pluginConfig, { logger, cwd }) => {
const vscePublishEnabled = isVscePublishEnabled();
const ovsxPublishEnabled = isOvsxPublishEnabled();
if (!vscePublishEnabled && !ovsxPublishEnabled) {
throw new SemanticReleaseError(
throw await createError(
'No personal access token was detected. Set the `VSCE_PAT` or the `OVSX_PAT` environment variable, at least one of them must be present when publish is enabled.\nLearn more at https://github.com/felipecrs/semantic-release-vsce#publishing',
'ENOPAT',
);
Expand Down
61 changes: 38 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"npm": "9.8.1"
},
"dependencies": {
"@semantic-release/error": "^3.0.0",
"@semantic-release/error": "^4.0.0",
"@vscode/vsce": "^2.15.0",
"execa": "^5.0.0",
"fs-extra": "^11.1.0",
Expand Down
3 changes: 0 additions & 3 deletions test/verify-ovsx-auth.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const test = require('ava').serial;
const sinon = require('sinon');
const proxyquire = require('proxyquire');
const SemanticReleaseError = require('@semantic-release/error');

const cwd = process.cwd();

Expand Down Expand Up @@ -37,7 +36,6 @@ test('OVSX_PAT is invalid', async (t) => {
const verifyOvsxAuth = require('../lib/verify-ovsx-auth');

await t.throwsAsync(() => verifyOvsxAuth(logger), {
instanceOf: SemanticReleaseError,
code: 'EEMPTYOVSXPAT',
});
});
Expand All @@ -54,7 +52,6 @@ test('OVSX_PAT is invalid but not empty', async (t) => {
const verifyOvsxAuth = require('../lib/verify-ovsx-auth');

await t.throwsAsync(() => verifyOvsxAuth(logger), {
instanceOf: SemanticReleaseError,
code: 'EINVALIDOVSXPAT',
});
});
5 changes: 0 additions & 5 deletions test/verify-pkg.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const sinon = require('sinon');
const test = require('ava');
const proxyquire = require('proxyquire');
const SemanticReleaseError = require('@semantic-release/error');

test('package.json is found', async (t) => {
const name = 'test';
Expand Down Expand Up @@ -39,7 +38,6 @@ test('package.json is not found', async (t) => {
});

await t.throwsAsync(() => verifyPkg(), {
instanceOf: SemanticReleaseError,
code: 'ENOPKG',
});
});
Expand Down Expand Up @@ -73,7 +71,6 @@ test('package is invalid', async (t) => {
});

await t.throwsAsync(() => verifyPkg(), {
instanceOf: SemanticReleaseError,
code: 'EINVALIDPKG',
});
});
Expand All @@ -92,7 +89,6 @@ test('package is missing name', async (t) => {
});

await t.throwsAsync(() => verifyPkg(), {
instanceOf: SemanticReleaseError,
code: 'ENOPKGNAME',
});
});
Expand All @@ -111,7 +107,6 @@ test('package is missing publisher', async (t) => {
});

await t.throwsAsync(() => verifyPkg(), {
instanceOf: SemanticReleaseError,
code: 'ENOPUBLISHER',
});
});
3 changes: 0 additions & 3 deletions test/verify-target.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const sinon = require('sinon');
const test = require('ava');
const proxyquire = require('proxyquire');
const SemanticReleaseError = require('@semantic-release/error');

test('VSCE_TARGET is not set', async (t) => {
const vscePackage = sinon.stub().returns({
Expand Down Expand Up @@ -36,7 +35,6 @@ test('VSCE_TARGET is empty', async (t) => {
});

await t.throwsAsync(() => verifyTarget(), {
instanceOf: SemanticReleaseError,
code: 'EINVALIDVSCETARGET',
});
t.false(vscePackage.called);
Expand All @@ -49,7 +47,6 @@ test('VSCE_TARGET is unsupported', async (t) => {
const verifyTarget = require('../lib/verify-target');

await t.throwsAsync(() => verifyTarget(), {
instanceOf: SemanticReleaseError,
code: 'EUNSUPPORTEDVSCETARGET',
});
});
Expand Down
3 changes: 0 additions & 3 deletions test/verify-vsce-auth.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const test = require('ava').serial;
const sinon = require('sinon');
const proxyquire = require('proxyquire');
const SemanticReleaseError = require('@semantic-release/error');

const logger = {
log: sinon.fake(),
Expand Down Expand Up @@ -50,7 +49,6 @@ test('VSCE_PAT is invalid', async (t) => {
const verifyOvsxAuth = require('../lib/verify-vsce-auth');

await t.throwsAsync(() => verifyOvsxAuth(logger), {
instanceOf: SemanticReleaseError,
code: 'EEMPTYVSCEPAT',
});
});
Expand All @@ -68,7 +66,6 @@ test('VSCE_PAT is invalid but not empty', async (t) => {
});

await t.throwsAsync(() => verifyVsceAuth(logger), {
instanceOf: SemanticReleaseError,
code: 'EINVALIDVSCEPAT',
});
});
Loading