Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: felipecrs/semantic-release-vsce
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.3.1
Choose a base ref
...
head repository: felipecrs/semantic-release-vsce
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.4.0
Choose a head ref
  • 3 commits
  • 17 files changed
  • 1 contributor

Commits on Jun 13, 2021

  1. feat: use vsce to bump version

    As this feature was introduced in vsce@1.93.0 through
    microsoft/vscode-vsce#555.
    felipecrs committed Jun 13, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    db9132d View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    crazy-max CrazyMax
    Copy the full SHA
    33f9f78 View commit details
  3. fix: extension being packaged twice

    When using the `packageVsix` option.
    felipecrs committed Jun 13, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    f9768d6 View commit details
Showing with 399 additions and 279 deletions.
  1. +4 −3 index.js
  2. +0 −1 lib/die.js
  3. +12 −7 lib/prepare.js
  4. +10 −4 lib/publish.js
  5. +0 −20 lib/update-package-version.js
  6. +3 −4 lib/verify-auth.js
  7. +22 −3 lib/verify-pkg.js
  8. +2 −11 lib/verify.js
  9. +98 −41 package-lock.json
  10. +0 −2 package.json
  11. +4 −1 test/index.test.js
  12. +44 −29 test/prepare.test.js
  13. +36 −6 test/publish.test.js
  14. +0 −115 test/update-package-version.test.js
  15. +53 −17 test/verify-auth.test.js
  16. +97 −7 test/verify-pkg.test.js
  17. +14 −8 test/verify.test.js
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ const vscePrepare = require('./lib/prepare');

let verified = false;
let prepared = false;
let packagePath;

async function verifyConditions (pluginConfig, { logger }) {
await verifyVsce(logger);
@@ -15,7 +16,7 @@ async function prepare (pluginConfig, { nextRelease: { version }, logger }) {
await verifyVsce(logger);
verified = true;
}
await vscePrepare(version, pluginConfig.packageVsix, pluginConfig.yarn, logger);
packagePath = await vscePrepare(version, pluginConfig.packageVsix, pluginConfig.yarn, logger);
prepared = true;
}

@@ -27,9 +28,9 @@ async function publish (pluginConfig, { nextRelease: { version }, logger }) {

if (!prepared) {
// BC: prior to semantic-release v15 prepare was part of publish
await vscePrepare(version, pluginConfig.packageVsix, pluginConfig.yarn, logger);
packagePath = await vscePrepare(version, pluginConfig.packageVsix, pluginConfig.yarn, logger);
}
return vscePublish(version, pluginConfig.yarn, logger);
return vscePublish(version, packagePath, pluginConfig.yarn, logger);
}

module.exports = {
1 change: 0 additions & 1 deletion lib/die.js

This file was deleted.

19 changes: 12 additions & 7 deletions lib/prepare.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
const execa = require('execa');
const updatePackageVersion = require('./update-package-version');
const { readJson } = require('fs-extra');

module.exports = async (version, packageVsix, yarn, logger) => {
await updatePackageVersion(version, logger);

if (packageVsix) {
logger.log('Packaging version %s as .vsix', version);

const options = ['package'];
let packagePath;

if (typeof packageVsix === 'string') {
options.push(...['--out', packageVsix]);
packagePath = packageVsix;
} else {
const { name } = await readJson('./package.json');
packagePath = `${name}-${version}.vsix`;
}

logger.log(`Packaging version ${version} to ${packagePath}`);

const options = ['package', version, '--no-git-tag-version', '--out', packagePath];

if (yarn) {
options.push('--yarn');
}

await execa('vsce', options, { stdio: 'inherit' });

return packagePath;
}
};
14 changes: 10 additions & 4 deletions lib/publish.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
const execa = require('execa');
const { readJson } = require('fs-extra');

module.exports = async (version, yarn, logger) => {
module.exports = async (version, packagePath, yarn, logger) => {
const { publisher, name } = await readJson('./package.json');

logger.log('Publishing version %s to vs code marketplace', version);

const options = ['publish'];

if (packagePath) {
logger.log(`Publishing version ${version} from ${packagePath} to Visual Studio Marketplace`);
options.push(...['--packagePath', packagePath]);
} else {
logger.log(`Publishing version ${version} to Visual Studio Marketplace`);
options.push(...[version, '--no-git-tag-version']);
}

if (yarn) {
options.push('--yarn');
}

await execa('vsce', options, { stdio: 'inherit' });

const url = `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`;
logger.log(`New version is available at ${url}`);
logger.log(`The new version is available at ${url}`);
return {
name: 'Visual Studio Marketplace',
url
20 changes: 0 additions & 20 deletions lib/update-package-version.js

This file was deleted.

7 changes: 3 additions & 4 deletions lib/verify-auth.js
Original file line number Diff line number Diff line change
@@ -2,20 +2,19 @@ const execa = require('execa');
const SemanticReleaseError = require('@semantic-release/error');

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

if (!('VSCE_PAT' in process.env) && ('VSCE_TOKEN' in process.env)) {
logger.log('VSCE_TOKEN is deprecated and may be removed in the next major release, please use VSCE_PAT instead.');
process.env.VSCE_PAT = process.env.VSCE_TOKEN;
}

if (!process.env.VSCE_PAT) {
throw new SemanticReleaseError('No vsce personal access token specified (set the "VSCE_PAT" environment variable).', 'ENOVSCEPAT');
throw new SemanticReleaseError('No vsce personal access token specified (set the `VSCE_PAT` environment variable).', 'ENOVSCEPAT');
}

try {
const options = ['verify-pat'];
execa.sync('vsce', options);
await execa('vsce', ['verify-pat']);
} catch (e) {
throw new SemanticReleaseError(`Invalid vsce token. Additional information:\n\n${e}`, 'EINVALIDVSCETOKEN');
}
25 changes: 22 additions & 3 deletions lib/verify-pkg.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
const SemanticReleaseError = require('@semantic-release/error');
const { readJson } = require('fs-extra');
const fs = require('fs');

module.exports = async () => {
if (!fs.existsSync('./package.json')) {
throw new SemanticReleaseError(
'The `package.json` was not found. A `package.json` is required to release with vsce.',
'ENOPKG'
);
}

let packageJson;

try {
packageJson = await readJson('./package.json');
} catch (error) {
throw new SemanticReleaseError('The `package.json` seems to be invalid.', 'EINVALIDPKG');
}

const { name, publisher } = packageJson;

module.exports = ({ name, publisher }) => {
if (!name) {
throw new SemanticReleaseError('No "name" found in package.json.', 'ENOPKGNAME');
throw new SemanticReleaseError('No `name` found in `package.json`.', 'ENOPKGNAME');
}
if (!publisher) {
throw new SemanticReleaseError('No "publisher" found in package.json.', 'ENOPUBLISHER');
throw new SemanticReleaseError('No `publisher` found in `package.json`.', 'ENOPUBLISHER');
}
};
13 changes: 2 additions & 11 deletions lib/verify.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
const verifyPkg = require('./verify-pkg');
const verifyAuth = require('./verify-auth');
const getPkg = require('read-pkg-up');
const SemanticReleaseError = require('@semantic-release/error');

module.exports = async logger => {
const { packageJson } = await getPkg();
if (!packageJson) {
throw new SemanticReleaseError(
'package.json not found. A package.json is required to release with vsce.',
'ENOPKG'
);
}
verifyPkg(packageJson);
await verifyPkg();

verifyAuth(logger);
await verifyAuth(logger);
};
Loading