Skip to content

Commit

Permalink
fix: revert bump of @semantic-release/error from 3.0.0 to 4.0.0 (#470)
Browse files Browse the repository at this point in the history
This reverts commit 5fcd8f2 (#470)
because it depends on Node 18 while this library is still compatible
with Node 14.
  • Loading branch information
felipecrs committed Oct 4, 2023
1 parent 5fcd8f2 commit 4e80315
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 69 deletions.
11 changes: 0 additions & 11 deletions lib/error.js

This file was deleted.

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 { createError } = require('./error');
const SemanticReleaseError = require('@semantic-release/error');
const execa = require('execa');

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

if (!process.env.OVSX_PAT) {
throw await createError(
throw new SemanticReleaseError(
'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 await createError(
throw new SemanticReleaseError(
`Invalid ovsx personal access token. Additional information:\n\n${e}`,
'EINVALIDOVSXPAT',
);
Expand Down
13 changes: 8 additions & 5 deletions lib/verify-pkg.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// @ts-check

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

module.exports = async () => {
if (!fs.existsSync('./package.json')) {
throw await createError(
throw new SemanticReleaseError(
'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 await createError(
throw new SemanticReleaseError(
'The `package.json` seems to be invalid.',
'EINVALIDPKG',
);
Expand All @@ -26,10 +26,13 @@ module.exports = async () => {
const { name, publisher } = packageJson;

if (!name) {
throw await createError('No `name` found in `package.json`.', 'ENOPKGNAME');
throw new SemanticReleaseError(
'No `name` found in `package.json`.',
'ENOPKGNAME',
);
}
if (!publisher) {
throw await createError(
throw new SemanticReleaseError(
'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 { createError } = require('./error');
const SemanticReleaseError = require('@semantic-release/error');
const { isTargetEnabled } = require('./utils');

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

if (!process.env.VSCE_TARGET) {
throw await createError(
throw new SemanticReleaseError(
'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 await createError(
throw new SemanticReleaseError(
`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 { createError } = require('./error');
const SemanticReleaseError = require('@semantic-release/error');
const execa = require('execa');

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

if (!process.env.VSCE_PAT) {
throw await createError(
throw new SemanticReleaseError(
'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 await createError(
throw new SemanticReleaseError(
`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 { createError } = require('./error');
const SemanticReleaseError = require('@semantic-release/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 await createError(
throw new SemanticReleaseError(
'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: 23 additions & 38 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": "^4.0.0",
"@semantic-release/error": "^3.0.0",
"@vscode/vsce": "^2.15.0",
"execa": "^5.0.0",
"fs-extra": "^11.1.0",
Expand Down
3 changes: 3 additions & 0 deletions test/verify-ovsx-auth.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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 @@ -36,6 +37,7 @@ 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 @@ -52,6 +54,7 @@ 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: 5 additions & 0 deletions test/verify-pkg.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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 @@ -38,6 +39,7 @@ test('package.json is not found', async (t) => {
});

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

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

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

await t.throwsAsync(() => verifyPkg(), {
instanceOf: SemanticReleaseError,
code: 'ENOPUBLISHER',
});
});
3 changes: 3 additions & 0 deletions test/verify-target.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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 @@ -35,6 +36,7 @@ test('VSCE_TARGET is empty', async (t) => {
});

await t.throwsAsync(() => verifyTarget(), {
instanceOf: SemanticReleaseError,
code: 'EINVALIDVSCETARGET',
});
t.false(vscePackage.called);
Expand All @@ -47,6 +49,7 @@ 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: 3 additions & 0 deletions test/verify-vsce-auth.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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 @@ -49,6 +50,7 @@ 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 @@ -66,6 +68,7 @@ test('VSCE_PAT is invalid but not empty', async (t) => {
});

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

0 comments on commit 4e80315

Please sign in to comment.