semantic-release-vsce 4.0.0 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: npm
4
+ directory: /
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 100
8
+ - package-ecosystem: github-actions
9
+ directory: /
10
+ schedule:
11
+ interval: daily
12
+ open-pull-requests-limit: 100
13
+ commit-message:
14
+ prefix: ci
@@ -0,0 +1,43 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ - next
8
+ pull_request:
9
+ branches:
10
+ - master
11
+ - next
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+
17
+ strategy:
18
+ matrix:
19
+ node-version:
20
+ - 14
21
+ - 16
22
+
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+ - uses: volta-cli/action@v1
26
+ with:
27
+ node-version: ${{ matrix.node-version }}
28
+ - run: npm ci
29
+ - run: npm test
30
+
31
+ release:
32
+ runs-on: ubuntu-latest
33
+
34
+ needs: test
35
+
36
+ steps:
37
+ - uses: actions/checkout@v2
38
+ - uses: volta-cli/action@v1
39
+ - run: npm ci
40
+ - run: npm run release
41
+ env:
42
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npx --no-install commitlint --edit "$1"
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npm test
package/README.md CHANGED
@@ -1,15 +1,14 @@
1
1
  # semantic-release-vsce
2
2
 
3
+ [semantic-release](https://github.com/semantic-release/semantic-release) plugin to package and publish VS Code extensions.
4
+
3
5
  [![npm](https://img.shields.io/npm/v/semantic-release-vsce.svg)](https://www.npmjs.com/package/semantic-release-vsce)
4
6
  [![downloads](https://img.shields.io/npm/dt/semantic-release-vsce.svg)](https://www.npmjs.com/package/semantic-release-vsce)
5
- [![build](https://travis-ci.org/raix/semantic-release-vsce.svg?branch=master)](https://travis-ci.org/raix/semantic-release-vsce)
6
- [![dependencies](https://david-dm.org/raix/semantic-release-vsce/status.svg)](https://david-dm.org/raix/semantic-release-vsce)
7
- [![peerDependencies](https://david-dm.org/raix/semantic-release-vsce/peer-status.svg)](https://david-dm.org/raix/semantic-release-vsce?type=peer)
8
- [![Greenkeeper](https://badges.greenkeeper.io/raix/semantic-release-vsce.svg)](https://greenkeeper.io/)
7
+ [![ci](https://github.com/felipecrs/semantic-release-vsce/workflows/ci/badge.svg)](https://github.com/felipecrs/semantic-release-vsce/actions?query=workflow%3Aci)
8
+ [![dependencies](https://david-dm.org/felipecrs/semantic-release-vsce/status.svg)](https://david-dm.org/felipecrs/semantic-release-vsce)
9
+ [![peerDependencies](https://david-dm.org/felipecrs/semantic-release-vsce/peer-status.svg)](https://david-dm.org/felipecrs/semantic-release-vsce?type=peer)
9
10
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
10
11
 
11
- Semantic release plugin for Visual Studio Code extensions
12
-
13
12
  #### Add config to package.json
14
13
 
15
14
  Use `semantic-release-vsce` as part of `verifyConditions` and `publish`.
@@ -46,7 +45,15 @@ Use `semantic-release-vsce` as part of `verifyConditions` and `publish`.
46
45
  If `packageVsix` is set, will also generate a .vsix file at the set file path after publishing. If is a string, it will be used as value for `--out` of `vsce package`.
47
46
  It is recommended to upload this to your GitHub release page so your users can easily rollback to an earlier version if a version ever introduces a bad bug.
48
47
 
49
- If `yarn` is set to `true`, will use `--yarn`option for `vsce package` and `vsce publish`.
48
+ #### Publishing to OpenVSX
49
+
50
+ Publishing extensions to OpenVSX using this plugin is easy:
51
+
52
+ 1. Get a valid personal access token with the correct privileges to the publisher namespace in OpenVSX. In order to get the personal access token, check this [page](https://github.com/eclipse/openvsx/wiki).
53
+
54
+ 2. Configure the `OVSX_PAT` environment variable in your CI with the token that you created.
55
+
56
+ 3. Enjoy! The plugin will automatically detect the environment variable and it will publish to OpenVSX, no additional configuration is needed.
50
57
 
51
58
  #### Working with older versions
52
59
 
@@ -56,7 +63,7 @@ Prior to v13, you had to override `getLastRelease` to use `@semantic-release/git
56
63
 
57
64
  #### Travis example
58
65
 
59
- Secret environment variables: `VSCE_TOKEN`
66
+ Secret environment variables: `VSCE_PAT`
60
67
 
61
68
  Example:
62
69
 
package/index.js CHANGED
@@ -4,6 +4,7 @@ const vscePrepare = require('./lib/prepare');
4
4
 
5
5
  let verified = false;
6
6
  let prepared = false;
7
+ let packagePath;
7
8
 
8
9
  async function verifyConditions (pluginConfig, { logger }) {
9
10
  await verifyVsce(logger);
@@ -15,7 +16,7 @@ async function prepare (pluginConfig, { nextRelease: { version }, logger }) {
15
16
  await verifyVsce(logger);
16
17
  verified = true;
17
18
  }
18
- await vscePrepare(version, pluginConfig.packageVsix, pluginConfig.yarn, logger);
19
+ packagePath = await vscePrepare(version, pluginConfig.packageVsix, logger);
19
20
  prepared = true;
20
21
  }
21
22
 
@@ -27,9 +28,9 @@ async function publish (pluginConfig, { nextRelease: { version }, logger }) {
27
28
 
28
29
  if (!prepared) {
29
30
  // BC: prior to semantic-release v15 prepare was part of publish
30
- await vscePrepare(version, pluginConfig.packageVsix, pluginConfig.yarn, logger);
31
+ packagePath = await vscePrepare(version, pluginConfig.packageVsix, logger);
31
32
  }
32
- return vscePublish(version, pluginConfig.yarn, logger);
33
+ return vscePublish(version, packagePath, logger);
33
34
  }
34
35
 
35
36
  module.exports = {
package/lib/prepare.js CHANGED
@@ -1,22 +1,29 @@
1
1
  const execa = require('execa');
2
- const updatePackageVersion = require('./update-package-version');
2
+ const { readJson } = require('fs-extra');
3
+ const { isOvsxEnabled } = require('./verify-ovsx-auth');
3
4
 
4
- module.exports = async (version, packageVsix, yarn, logger) => {
5
- await updatePackageVersion(version, logger);
6
-
7
- if (packageVsix) {
8
- logger.log('Packaging version %s as .vsix', version);
5
+ module.exports = async (version, packageVsix, logger) => {
6
+ const ovsxEnabled = isOvsxEnabled();
7
+ if (packageVsix || ovsxEnabled) {
8
+ if (!packageVsix && ovsxEnabled) {
9
+ logger.log('Packaging to VSIX even though `packageVsix` is not set as publish to OpenVSX is enabled.');
10
+ }
9
11
 
10
- const options = ['package'];
12
+ let packagePath;
11
13
 
12
14
  if (typeof packageVsix === 'string') {
13
- options.push(...['--out', packageVsix]);
15
+ packagePath = packageVsix;
16
+ } else {
17
+ const { name } = await readJson('./package.json');
18
+ packagePath = `${name}-${version}.vsix`;
14
19
  }
15
20
 
16
- if (yarn) {
17
- options.push('--yarn');
18
- }
21
+ logger.log(`Packaging version ${version} to ${packagePath}`);
22
+
23
+ const options = ['package', version, '--no-git-tag-version', '--out', packagePath];
19
24
 
20
25
  await execa('vsce', options, { stdio: 'inherit' });
26
+
27
+ return packagePath;
21
28
  }
22
29
  };
package/lib/publish.js CHANGED
@@ -1,25 +1,46 @@
1
1
  const execa = require('execa');
2
2
  const { readJson } = require('fs-extra');
3
+ const { isOvsxEnabled } = require('./verify-ovsx-auth');
3
4
 
4
- module.exports = async (version, yarn, logger) => {
5
- const { VSCE_TOKEN } = process.env;
6
-
5
+ module.exports = async (version, packagePath, logger) => {
7
6
  const { publisher, name } = await readJson('./package.json');
8
7
 
9
- logger.log('Publishing version %s to vs code marketplace', version);
10
-
11
- const options = ['publish', '--pat', VSCE_TOKEN];
8
+ const options = ['publish'];
12
9
 
13
- if (yarn) {
14
- options.push('--yarn');
10
+ if (packagePath) {
11
+ logger.log(`Publishing version ${version} from ${packagePath} to Visual Studio Marketplace`);
12
+ options.push(...['--packagePath', packagePath]);
13
+ } else {
14
+ logger.log(`Publishing version ${version} to Visual Studio Marketplace`);
15
+ options.push(...[version, '--no-git-tag-version']);
15
16
  }
16
17
 
17
18
  await execa('vsce', options, { stdio: 'inherit' });
18
19
 
19
- const url = `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`;
20
- logger.log(`New version is available at ${url}`);
21
- return {
20
+ const vsceUrl = `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`;
21
+ logger.log(`The new version is available at ${vsceUrl}.`);
22
+
23
+ const vsceRelease = {
22
24
  name: 'Visual Studio Marketplace',
23
- url
25
+ url: vsceUrl
24
26
  };
27
+
28
+ if (isOvsxEnabled()) {
29
+ logger.log('Now publishing to OpenVSX');
30
+
31
+ await execa('ovsx', ['publish', packagePath], { stdio: 'inherit' });
32
+
33
+ // TODO: uncomment after https://github.com/semantic-release/semantic-release/issues/2123
34
+ // const ovsxUrl = `https://open-vsx.org/extension/${publisher}/${name}/${version}`;
35
+ // const ovsxRelease = {
36
+ // name: 'Open VSX Registry',
37
+ // url: ovsxUrl
38
+ // };
39
+
40
+ // const releases = [vsceRelease, ovsxRelease];
41
+
42
+ // return releases;
43
+ }
44
+
45
+ return vsceRelease;
25
46
  };
@@ -0,0 +1,16 @@
1
+ const execa = require('execa');
2
+ const SemanticReleaseError = require('@semantic-release/error');
3
+
4
+ module.exports = async (logger) => {
5
+ logger.log('Verifying authentication for vsce');
6
+
7
+ if (!process.env.VSCE_PAT) {
8
+ throw new SemanticReleaseError('No vsce personal access token specified (set the `VSCE_PAT` environment variable).', 'ENOVSCEPAT');
9
+ }
10
+
11
+ try {
12
+ await execa('vsce', ['verify-pat']);
13
+ } catch (e) {
14
+ throw new SemanticReleaseError(`Invalid vsce token. Additional information:\n\n${e}`, 'EINVALIDVSCETOKEN');
15
+ }
16
+ };
@@ -0,0 +1,27 @@
1
+ const SemanticReleaseError = require('@semantic-release/error');
2
+
3
+ const isOvsxEnabled = () => {
4
+ return 'OVSX_PAT' in process.env;
5
+ };
6
+
7
+ module.exports = async (logger) => {
8
+ logger.log('Verifying authentication for ovsx');
9
+
10
+ if (!isOvsxEnabled()) {
11
+ logger.log('Skipping verification of ovsx personal token because the `OVSX_PAT` environment variable is not set.\n\nDid you know you can easily start publishing to OpenVSX with `semantic-release-vsce`?\nLearn more at https://github.com/felipecrs/semantic-release-vsce#publishing-to-openvsx');
12
+ return;
13
+ }
14
+
15
+ if (!process.env.OVSX_PAT) {
16
+ throw new SemanticReleaseError('Empty ovsx personal access token specified.', 'EINVALIDOVSXPAT');
17
+ }
18
+
19
+ // TODO: waiting for https://github.com/eclipse/openvsx/issues/313
20
+ // try {
21
+ // await execa('ovsx', ['verify-pat']);
22
+ // } catch (e) {
23
+ // throw new SemanticReleaseError(`Invalid ovsx personal access token. Additional information:\n\n${e}`, 'EINVALIDOVSXPAT');
24
+ // }
25
+ };
26
+
27
+ module.exports.isOvsxEnabled = isOvsxEnabled;
package/lib/verify-pkg.js CHANGED
@@ -1,10 +1,29 @@
1
1
  const SemanticReleaseError = require('@semantic-release/error');
2
+ const { readJson } = require('fs-extra');
3
+ const fs = require('fs');
4
+
5
+ module.exports = async () => {
6
+ if (!fs.existsSync('./package.json')) {
7
+ throw new SemanticReleaseError(
8
+ 'The `package.json` was not found. A `package.json` is required to release with vsce.',
9
+ 'ENOPKG'
10
+ );
11
+ }
12
+
13
+ let packageJson;
14
+
15
+ try {
16
+ packageJson = await readJson('./package.json');
17
+ } catch (error) {
18
+ throw new SemanticReleaseError('The `package.json` seems to be invalid.', 'EINVALIDPKG');
19
+ }
20
+
21
+ const { name, publisher } = packageJson;
2
22
 
3
- module.exports = ({ name, publisher }) => {
4
23
  if (!name) {
5
- throw new SemanticReleaseError('No "name" found in package.json.', 'ENOPKGNAME');
24
+ throw new SemanticReleaseError('No `name` found in `package.json`.', 'ENOPKGNAME');
6
25
  }
7
26
  if (!publisher) {
8
- throw new SemanticReleaseError('No "publisher" found in package.json.', 'ENOPUBLISHER');
27
+ throw new SemanticReleaseError('No `publisher` found in `package.json`.', 'ENOPUBLISHER');
9
28
  }
10
29
  };
package/lib/verify.js CHANGED
@@ -1,21 +1,11 @@
1
1
  const verifyPkg = require('./verify-pkg');
2
- const setAuth = require('./set-auth');
3
- const getPkg = require('read-pkg-up');
4
- const SemanticReleaseError = require('@semantic-release/error');
2
+ const verifyAuth = require('./verify-auth');
3
+ const verifyOvsxAuth = require('./verify-ovsx-auth');
5
4
 
6
5
  module.exports = async logger => {
7
- const { packageJson } = await getPkg();
8
- if (!packageJson) {
9
- throw new SemanticReleaseError(
10
- 'package.json not found. A package.json is required to release with vsce.',
11
- 'ENOPKG'
12
- );
13
- }
14
- verifyPkg(packageJson);
15
- await setAuth(logger);
16
- try {
17
- // TODO: Verify output
18
- } catch (err) {
19
- throw new SemanticReleaseError('Invalid vsce token.', 'EINVALIDVSCETOKEN');
20
- }
6
+ await verifyPkg();
7
+
8
+ await verifyAuth(logger);
9
+
10
+ await verifyOvsxAuth(logger);
21
11
  };
package/package.json CHANGED
@@ -1,81 +1,80 @@
1
1
  {
2
2
  "name": "semantic-release-vsce",
3
- "description": "Semantic release plugin for vs code extensions",
4
- "version": "4.0.0",
5
- "main": "index.js",
6
- "repository": "https://github.com/raix/semantic-release-vsce.git",
7
- "author": "Morten Henriksen <mh@gi2.dk>",
3
+ "version": "5.0.2",
4
+ "description": "semantic-release plugin to package and publish VS Code extensions",
8
5
  "license": "MIT",
6
+ "engines": {
7
+ "node": ">=14"
8
+ },
9
+ "repository": "https://github.com/felipecrs/semantic-release-vsce.git",
10
+ "bugs": "https://github.com/felipecrs/semantic-release-vsce/issues",
11
+ "homepage": "https://github.com/felipecrs/semantic-release-vsce#readme",
12
+ "author": "Morten Henriksen <mh@gi2.dk>",
13
+ "keywords": [
14
+ "semantic-release",
15
+ "semantic-release-plugin",
16
+ "vscode",
17
+ "vsce"
18
+ ],
19
+ "main": "index.js",
9
20
  "scripts": {
10
21
  "lint": "eslint .",
22
+ "release": "semantic-release",
11
23
  "test": "nyc ava",
12
24
  "posttest": "npm run lint",
13
- "release": "semantic-release"
14
- },
15
- "engines": {
16
- "node": ">=10.18"
17
- },
18
- "dependencies": {
19
- "@semantic-release/error": "^2.2.0",
20
- "commander": "^4.1.1",
21
- "detect-indent": "^6.0.0",
22
- "execa": "^4.0.0",
23
- "fs-extra": "^8.1.0",
24
- "node-fetch": "^2.6.0",
25
- "read-pkg-up": "^7.0.1",
26
- "semver": "^7.1.3"
27
- },
28
- "devDependencies": {
29
- "@commitlint/cli": "^8.0.0",
30
- "@commitlint/config-conventional": "^8.0.0",
31
- "ava": "^3.9.0",
32
- "conventional-changelog-conventionalcommits": "^4.2.1",
33
- "eslint": "^6.8.0",
34
- "eslint-config-standard": "^14.1.0",
35
- "eslint-plugin-import": "^2.20.1",
36
- "eslint-plugin-node": "^11.0.0",
37
- "eslint-plugin-promise": "^4.2.1",
38
- "eslint-plugin-standard": "^4.0.1",
39
- "husky": "^4.2.3",
40
- "nyc": "^15.1.0",
41
- "proxyquire": "^2.1.3",
42
- "semantic-release": "^17.0.3",
43
- "sinon": "^9.0.2"
44
- },
45
- "peerDependencies": {
46
- "semantic-release": ">=16.0.0",
47
- "vsce": ">=1.73.0 < 2"
48
- },
49
- "volta": {
50
- "node": "14.15.4",
51
- "npm": "7.4.2"
25
+ "prepare": "husky install"
52
26
  },
53
27
  "ava": {
54
28
  "files": [
55
29
  "test/**/*.test.js"
56
30
  ]
57
31
  },
32
+ "commitlint": {
33
+ "extends": [
34
+ "@commitlint/config-conventional"
35
+ ]
36
+ },
58
37
  "nyc": {
59
38
  "all": true,
39
+ "exclude": [
40
+ "lib/die.js"
41
+ ],
60
42
  "include": [
61
43
  "index.js",
62
44
  "lib/**/*.js"
63
- ],
64
- "exclude": [
65
- "lib/die.js"
66
45
  ]
67
46
  },
68
- "commitlint": {
69
- "extends": [
70
- "@commitlint/config-conventional"
71
- ]
72
- },
73
- "husky": {
74
- "hooks": {
75
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
76
- }
77
- },
78
47
  "release": {
79
48
  "preset": "conventionalcommits"
49
+ },
50
+ "volta": {
51
+ "node": "16.13.2",
52
+ "npm": "8.3.2"
53
+ },
54
+ "dependencies": {
55
+ "@semantic-release/error": "^3.0.0",
56
+ "execa": "^5.0.0",
57
+ "fs-extra": "^10.0.0",
58
+ "ovsx": "^0.3.0",
59
+ "vsce": "^2.6.3"
60
+ },
61
+ "peerDependencies": {
62
+ "semantic-release": ">=18"
63
+ },
64
+ "devDependencies": {
65
+ "@commitlint/cli": "^16.0.2",
66
+ "@commitlint/config-conventional": "^16.0.0",
67
+ "ava": "^4.0.1",
68
+ "conventional-changelog-conventionalcommits": "^4.2.1",
69
+ "eslint": "^8.7.0",
70
+ "eslint-config-standard": "^17.0.0-0",
71
+ "eslint-plugin-import": "^2.20.1",
72
+ "eslint-plugin-n": "^14.0.0",
73
+ "eslint-plugin-promise": "^6.0.0",
74
+ "husky": "^7.0.4",
75
+ "nyc": "^15.1.0",
76
+ "proxyquire": "^2.1.3",
77
+ "semantic-release": "^19.0.2",
78
+ "sinon": "^12.0.1"
80
79
  }
81
80
  }
@@ -12,8 +12,7 @@ const semanticReleasePayload = {
12
12
  };
13
13
 
14
14
  const pluginConfig = {
15
- packageVsix: 'test.vsix',
16
- yarn: undefined
15
+ packageVsix: 'test.vsix'
17
16
  };
18
17
 
19
18
  test.beforeEach(t => {
@@ -58,7 +57,6 @@ test('prepare and unverified', async t => {
58
57
  t.deepEqual(vscePrepareStub.getCall(0).args, [
59
58
  semanticReleasePayload.nextRelease.version,
60
59
  pluginConfig.packageVsix,
61
- pluginConfig.yarn,
62
60
  semanticReleasePayload.logger
63
61
  ]);
64
62
  });
@@ -78,7 +76,6 @@ test('prepare and verified', async t => {
78
76
  t.deepEqual(vscePrepareStub.getCall(0).args, [
79
77
  semanticReleasePayload.nextRelease.version,
80
78
  pluginConfig.packageVsix,
81
- pluginConfig.yarn,
82
79
  semanticReleasePayload.logger
83
80
  ]);
84
81
  });
@@ -97,7 +94,7 @@ test('publish that is unverified and unprepared', async t => {
97
94
  t.true(vscePrepareStub.calledOnce);
98
95
  t.deepEqual(vscePublishStub.getCall(0).args, [
99
96
  semanticReleasePayload.nextRelease.version,
100
- pluginConfig.yarn,
97
+ undefined,
101
98
  semanticReleasePayload.logger
102
99
  ]);
103
100
  });
@@ -117,7 +114,7 @@ test('publish that is verified but unprepared', async t => {
117
114
  t.true(vscePrepareStub.calledOnce);
118
115
  t.deepEqual(vscePublishStub.getCall(0).args, [
119
116
  semanticReleasePayload.nextRelease.version,
120
- pluginConfig.yarn,
117
+ undefined,
121
118
  semanticReleasePayload.logger
122
119
  ]);
123
120
  });
@@ -131,14 +128,14 @@ test('publish that is already verified & prepared', async t => {
131
128
  });
132
129
 
133
130
  await verifyConditions(pluginConfig, semanticReleasePayload);
134
- await prepare(pluginConfig, semanticReleasePayload);
131
+ const packagePath = await prepare(pluginConfig, semanticReleasePayload);
135
132
  await publish(pluginConfig, semanticReleasePayload);
136
133
 
137
134
  t.true(verifyVsceStub.calledOnce);
138
135
  t.true(vscePrepareStub.calledOnce);
139
136
  t.deepEqual(vscePublishStub.getCall(0).args, [
140
137
  semanticReleasePayload.nextRelease.version,
141
- pluginConfig.yarn,
138
+ packagePath,
142
139
  semanticReleasePayload.logger
143
140
  ]);
144
141
  });
@@ -8,82 +8,87 @@ const logger = {
8
8
 
9
9
  test.beforeEach(t => {
10
10
  t.context.stubs = {
11
- execaStub: sinon.stub(),
12
- updatePackageVersionStub: sinon.stub().resolves()
11
+ execaStub: sinon.stub()
13
12
  };
14
13
  });
15
14
 
16
15
  test.afterEach(t => {
17
16
  t.context.stubs.execaStub.resetHistory();
18
- t.context.stubs.updatePackageVersionStub.resetHistory();
19
17
  });
20
18
 
21
19
  test('packageVsix is not specified', async t => {
22
- const { updatePackageVersionStub, execaStub } = t.context.stubs;
20
+ const { execaStub } = t.context.stubs;
23
21
  const prepare = proxyquire('../lib/prepare', {
24
- execa: execaStub,
25
- './update-package-version': updatePackageVersionStub
26
- });
27
-
28
- await prepare('1.0.0', undefined, undefined, logger);
29
-
30
- t.true(updatePackageVersionStub.calledOnce);
31
- t.true(execaStub.notCalled);
32
- });
33
-
34
- test('packageVsix is not specified but yarn is true', async t => {
35
- const { updatePackageVersionStub, execaStub } = t.context.stubs;
36
- const prepare = proxyquire('../lib/prepare', {
37
- execa: execaStub,
38
- './update-package-version': updatePackageVersionStub
22
+ execa: execaStub
39
23
  });
40
24
 
41
- const yarn = true;
42
- await prepare('1.0.0', undefined, yarn, logger);
25
+ const version = '1.0.0';
26
+ await prepare(version, undefined, logger);
43
27
 
44
- t.true(updatePackageVersionStub.calledOnce);
45
28
  t.true(execaStub.notCalled);
46
29
  });
47
30
 
48
31
  test('packageVsix is a string', async t => {
49
- const { updatePackageVersionStub, execaStub } = t.context.stubs;
32
+ const { execaStub } = t.context.stubs;
50
33
  const prepare = proxyquire('../lib/prepare', {
51
- execa: execaStub,
52
- './update-package-version': updatePackageVersionStub
34
+ execa: execaStub
53
35
  });
54
36
 
37
+ const version = '1.0.0';
55
38
  const packageVsix = 'test.vsix';
56
- await prepare('1.0.0', packageVsix, undefined, logger);
39
+ const packagePath = packageVsix;
40
+ const result = await prepare(version, packageVsix, logger);
57
41
 
58
- t.true(updatePackageVersionStub.calledOnce);
59
- t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', '--out', packageVsix], { stdio: 'inherit' }]);
42
+ t.deepEqual(result, packagePath);
43
+ t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit' }]);
60
44
  });
61
45
 
62
46
  test('packageVsix is true', async t => {
63
- const { updatePackageVersionStub, execaStub } = t.context.stubs;
47
+ const { execaStub } = t.context.stubs;
48
+ const name = 'test';
49
+
64
50
  const prepare = proxyquire('../lib/prepare', {
65
51
  execa: execaStub,
66
- './update-package-version': updatePackageVersionStub
52
+ 'fs-extra': {
53
+ readJson: sinon.stub().returns({
54
+ name
55
+ })
56
+ }
67
57
  });
68
58
 
59
+ const version = '1.0.0';
69
60
  const packageVsix = true;
70
- await prepare('1.0.0', packageVsix, undefined, logger);
61
+ const packagePath = `${name}-${version}.vsix`;
71
62
 
72
- t.true(updatePackageVersionStub.calledOnce);
73
- t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package'], { stdio: 'inherit' }]);
63
+ const result = await prepare(version, packageVsix, logger);
64
+
65
+ t.deepEqual(result, packagePath);
66
+ t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit' }]);
74
67
  });
75
68
 
76
- test('packageVsix is true and yarn is true', async t => {
77
- const { updatePackageVersionStub, execaStub } = t.context.stubs;
69
+ test('packageVsix is not set but OVSX_PAT is', async t => {
70
+ const { execaStub } = t.context.stubs;
71
+ const name = 'test';
72
+
78
73
  const prepare = proxyquire('../lib/prepare', {
79
74
  execa: execaStub,
80
- './update-package-version': updatePackageVersionStub
75
+ 'fs-extra': {
76
+ readJson: sinon.stub().returns({
77
+ name
78
+ })
79
+ }
81
80
  });
82
81
 
83
- const packageVsix = true;
84
- const yarn = true;
85
- await prepare('1.0.0', packageVsix, yarn, logger);
82
+ sinon.stub(process, 'env').value({
83
+ OVSX_PAT: 'abc123'
84
+ });
85
+
86
+ const version = '1.0.0';
87
+ const packageVsix = undefined;
88
+ const packagePath = `${name}-${version}.vsix`;
89
+
90
+ const result = await prepare(version, packageVsix, logger);
86
91
 
87
- t.true(updatePackageVersionStub.calledOnce);
88
- t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', '--yarn'], { stdio: 'inherit' }]);
92
+ t.deepEqual(result, packagePath);
93
+ t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit' }]);
89
94
  });
@@ -30,18 +30,21 @@ test('publish', async t => {
30
30
  }
31
31
  });
32
32
 
33
+ const version = '1.0.0';
33
34
  const token = 'abc123';
34
- process.env.VSCE_TOKEN = token;
35
- const result = await publish('1.0.0', undefined, logger);
35
+ sinon.stub(process, 'env').value({
36
+ VSCE_PAT: token
37
+ });
38
+ const result = await publish(version, undefined, logger);
36
39
 
37
40
  t.deepEqual(result, {
38
41
  name: 'Visual Studio Marketplace',
39
42
  url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`
40
43
  });
41
- t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish', '--pat', token], { stdio: 'inherit' }]);
44
+ t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish', version, '--no-git-tag-version'], { stdio: 'inherit' }]);
42
45
  });
43
46
 
44
- test('publish when yarn is true', async t => {
47
+ test('publish with packagePath', async t => {
45
48
  const { execaStub } = t.context.stubs;
46
49
  const publisher = 'semantic-release-vsce';
47
50
  const name = 'Semantice Release VSCE';
@@ -55,14 +58,53 @@ test('publish when yarn is true', async t => {
55
58
  }
56
59
  });
57
60
 
61
+ const version = '1.0.0';
62
+ const packagePath = 'test.vsix';
58
63
  const token = 'abc123';
59
- process.env.VSCE_TOKEN = token;
60
- const yarn = true;
61
- const result = await publish('1.0.0', yarn, logger);
64
+ sinon.stub(process, 'env').value({
65
+ VSCE_PAT: token
66
+ });
67
+ const result = await publish(version, packagePath, logger);
62
68
 
63
69
  t.deepEqual(result, {
64
70
  name: 'Visual Studio Marketplace',
65
71
  url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`
66
72
  });
67
- t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish', '--pat', token, '--yarn'], { stdio: 'inherit' }]);
73
+ t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish', '--packagePath', packagePath], { stdio: 'inherit' }]);
74
+ });
75
+
76
+ test('publish to OpenVSX', async t => {
77
+ const { execaStub } = t.context.stubs;
78
+ const publisher = 'semantic-release-vsce';
79
+ const name = 'Semantice Release VSCE';
80
+ const publish = proxyquire('../lib/publish', {
81
+ execa: execaStub,
82
+ 'fs-extra': {
83
+ readJson: sinon.stub().returns({
84
+ publisher,
85
+ name
86
+ })
87
+ }
88
+ });
89
+
90
+ const version = '1.0.0';
91
+ const packagePath = 'test.vsix';
92
+ const token = 'abc123';
93
+ sinon.stub(process, 'env').value({
94
+ OVSX_PAT: token,
95
+ VSCE_PAT: token
96
+ });
97
+ const result = await publish(version, packagePath, logger);
98
+
99
+ t.deepEqual(result, {
100
+ name: 'Visual Studio Marketplace',
101
+ url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`
102
+ });
103
+ t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish', '--packagePath', packagePath], { stdio: 'inherit' }]);
104
+
105
+ // t.deepEqual(result[1], {
106
+ // name: 'Open VSX Registry',
107
+ // url: `https://open-vsx.org/extension/${publisher}/${name}/${version}`
108
+ // });
109
+ t.deepEqual(execaStub.getCall(1).args, ['ovsx', ['publish', packagePath], { stdio: 'inherit' }]);
68
110
  });
@@ -0,0 +1,54 @@
1
+ const test = require('ava');
2
+ const sinon = require('sinon');
3
+ const proxyquire = require('proxyquire');
4
+ const SemanticReleaseError = require('@semantic-release/error');
5
+
6
+ const logger = {
7
+ log: sinon.fake()
8
+ };
9
+
10
+ test('VSCE_PAT is set', async t => {
11
+ sinon.stub(process, 'env').value({
12
+ VSCE_PAT: 'abc123'
13
+ });
14
+
15
+ const verifyAuth = proxyquire('../lib/verify-auth', {
16
+ execa: sinon.stub().withArgs('vsce', ['verify-pat']).resolves()
17
+ });
18
+
19
+ await t.notThrowsAsync(() => verifyAuth(logger));
20
+ });
21
+
22
+ test('VSCE_PAT is not set', async t => {
23
+ sinon.stub(process, 'env').value({});
24
+
25
+ const verifyAuth = proxyquire('../lib/verify-auth', {
26
+ execa: sinon.stub().withArgs('vsce', ['verify-pat']).resolves()
27
+ });
28
+
29
+ await t.throwsAsync(() => verifyAuth(logger), { instanceOf: SemanticReleaseError, code: 'ENOVSCEPAT' });
30
+ });
31
+
32
+ test('VSCE_PAT is valid', async t => {
33
+ sinon.stub(process, 'env').value({
34
+ VSCE_PAT: 'abc123'
35
+ });
36
+
37
+ const verifyAuth = proxyquire('../lib/verify-auth', {
38
+ execa: sinon.stub().withArgs('vsce', ['verify-pat']).resolves()
39
+ });
40
+
41
+ await t.notThrowsAsync(() => verifyAuth(logger));
42
+ });
43
+
44
+ test('VSCE_PAT is invalid', async t => {
45
+ sinon.stub(process, 'env').value({
46
+ VSCE_PAT: 'abc123'
47
+ });
48
+
49
+ const verifyAuth = proxyquire('../lib/verify-auth', {
50
+ execa: sinon.stub().withArgs('vsce', ['verify-pat']).rejects()
51
+ });
52
+
53
+ await t.throwsAsync(() => verifyAuth(logger), { instanceOf: SemanticReleaseError, code: 'EINVALIDVSCETOKEN' });
54
+ });
@@ -0,0 +1,27 @@
1
+ const test = require('ava');
2
+ const sinon = require('sinon');
3
+ const SemanticReleaseError = require('@semantic-release/error');
4
+
5
+ const logger = {
6
+ log: sinon.fake()
7
+ };
8
+
9
+ test('OVSX_PAT is set', async t => {
10
+ sinon.stub(process, 'env').value({
11
+ OVSX_PAT: 'abc123'
12
+ });
13
+
14
+ const verifyOvsxAuth = require('../lib/verify-ovsx-auth');
15
+
16
+ await t.notThrowsAsync(() => verifyOvsxAuth(logger));
17
+ });
18
+
19
+ test('OVSX_PAT is invalid', async t => {
20
+ sinon.stub(process, 'env').value({
21
+ OVSX_PAT: ''
22
+ });
23
+
24
+ const verifyOvsxAuth = require('../lib/verify-ovsx-auth');
25
+
26
+ await t.throwsAsync(() => verifyOvsxAuth(logger), { instanceOf: SemanticReleaseError, code: 'EINVALIDOVSXPAT' });
27
+ });
@@ -1,15 +1,105 @@
1
+ const sinon = require('sinon');
1
2
  const test = require('ava');
3
+ const proxyquire = require('proxyquire');
2
4
  const SemanticReleaseError = require('@semantic-release/error');
3
- const verifyPkg = require('../lib/verify-pkg');
4
5
 
5
- test('package is valid', t => {
6
- t.notThrows(() => verifyPkg({ name: 'test', publisher: 'tester' }));
6
+ test('package.json is found', async t => {
7
+ const name = 'test';
8
+ const publisher = 'tester';
9
+
10
+ const verifyPkg = proxyquire('../lib/verify-pkg', {
11
+ fs: {
12
+ existsSync: sinon.stub().returns(true)
13
+ },
14
+ 'fs-extra': {
15
+ readJson: sinon.stub().returns({
16
+ name,
17
+ publisher
18
+ })
19
+ }
20
+ });
21
+
22
+ await t.notThrowsAsync(() => verifyPkg());
23
+ });
24
+
25
+ test('package.json is not found', async t => {
26
+ const name = 'test';
27
+ const publisher = 'tester';
28
+
29
+ const verifyPkg = proxyquire('../lib/verify-pkg', {
30
+ fs: {
31
+ existsSync: sinon.stub().returns(false)
32
+ },
33
+ 'fs-extra': {
34
+ readJson: sinon.stub().returns({
35
+ name,
36
+ publisher
37
+ })
38
+ }
39
+ });
40
+
41
+ await t.throwsAsync(() => verifyPkg(), { instanceOf: SemanticReleaseError, code: 'ENOPKG' });
42
+ });
43
+
44
+ test('package is valid', async t => {
45
+ const name = 'test';
46
+ const publisher = 'tester';
47
+ const verifyPkg = proxyquire('../lib/verify-pkg', {
48
+ fs: {
49
+ existsSync: sinon.stub().returns(true)
50
+ },
51
+ 'fs-extra': {
52
+ readJson: sinon.stub().returns({
53
+ publisher,
54
+ name
55
+ })
56
+ }
57
+ });
58
+
59
+ await t.notThrowsAsync(() => verifyPkg());
7
60
  });
8
61
 
9
- test('package is missing name', t => {
10
- t.throws(() => verifyPkg({ publisher: 'tester' }), { instanceOf: SemanticReleaseError });
62
+ test('package is invalid', async t => {
63
+ const verifyPkg = proxyquire('../lib/verify-pkg', {
64
+ fs: {
65
+ existsSync: sinon.stub().returns(true)
66
+ },
67
+ 'fs-extra': {
68
+ readJson: sinon.stub().rejects()
69
+ }
70
+ });
71
+
72
+ await t.throwsAsync(() => verifyPkg(), { instanceOf: SemanticReleaseError, code: 'EINVALIDPKG' });
11
73
  });
12
74
 
13
- test('package is missing publisher', t => {
14
- t.throws(() => verifyPkg({ name: 'test' }), { instanceOf: SemanticReleaseError });
75
+ test('package is missing name', async t => {
76
+ const publisher = 'tester';
77
+ const verifyPkg = proxyquire('../lib/verify-pkg', {
78
+ fs: {
79
+ existsSync: sinon.stub().returns(true)
80
+ },
81
+ 'fs-extra': {
82
+ readJson: sinon.stub().returns({
83
+ publisher
84
+ })
85
+ }
86
+ });
87
+
88
+ await t.throwsAsync(() => verifyPkg(), { instanceOf: SemanticReleaseError, code: 'ENOPKGNAME' });
89
+ });
90
+
91
+ test('package is missing publisher', async t => {
92
+ const name = 'test';
93
+ const verifyPkg = proxyquire('../lib/verify-pkg', {
94
+ fs: {
95
+ existsSync: sinon.stub().returns(true)
96
+ },
97
+ 'fs-extra': {
98
+ readJson: sinon.stub().returns({
99
+ name
100
+ })
101
+ }
102
+ });
103
+
104
+ await t.throwsAsync(() => verifyPkg(), { instanceOf: SemanticReleaseError, code: 'ENOPUBLISHER' });
15
105
  });
@@ -1,28 +1,34 @@
1
1
  const test = require('ava');
2
2
  const sinon = require('sinon');
3
3
  const proxyquire = require('proxyquire');
4
- const SemanticReleaseError = require('@semantic-release/error');
5
4
 
6
5
  const logger = {
7
6
  log: sinon.fake()
8
7
  };
9
8
 
10
- test('package.json is found', async t => {
9
+ test('resolves', async t => {
11
10
  const verify = proxyquire('../lib/verify', {
12
- './set-auth': sinon.stub().resolves(),
13
- './verify-pkg': sinon.stub(),
14
- 'read-pkg-up': sinon.stub().returns({ packageJson: {} })
11
+ './verify-auth': sinon.stub().resolves(),
12
+ './verify-pkg': sinon.stub().resolves()
15
13
  });
16
14
 
17
15
  await t.notThrowsAsync(() => verify(logger));
18
16
  });
19
17
 
20
- test('package.json is not found', async t => {
18
+ test('rejects with verify-auth', async t => {
21
19
  const verify = proxyquire('../lib/verify', {
22
- './set-auth': sinon.stub().resolves(),
23
- './verify-pkg': sinon.stub(),
24
- 'read-pkg-up': sinon.stub().returns({ })
20
+ './verify-auth': sinon.stub().rejects(),
21
+ './verify-pkg': sinon.stub().resolves()
25
22
  });
26
23
 
27
- await t.throwsAsync(() => verify(logger), { instanceOf: SemanticReleaseError });
24
+ await t.throwsAsync(() => verify(logger));
25
+ });
26
+
27
+ test('rejects with verify-pkg', async t => {
28
+ const verify = proxyquire('../lib/verify', {
29
+ './verify-auth': sinon.stub().resolves(),
30
+ './verify-pkg': sinon.stub().rejects()
31
+ });
32
+
33
+ await t.throwsAsync(() => verify(logger));
28
34
  });
package/.travis.yml DELETED
@@ -1,32 +0,0 @@
1
- language: node_js
2
-
3
- node_js:
4
- - '14'
5
-
6
- cache:
7
- directories:
8
- - ~/.npm
9
-
10
- notifications:
11
- email: false
12
-
13
- install:
14
- - travis_retry npm install
15
-
16
- script:
17
- - npm test
18
-
19
- jobs:
20
- include:
21
- - stage: test
22
- - stage: release
23
- script: npm run release
24
-
25
- stages:
26
- - test
27
- - name: release
28
- if: branch = master AND type = push AND fork = false
29
-
30
- branches:
31
- except:
32
- - /^v\d+\.\d+\.\d+$/
package/lib/die.js DELETED
@@ -1 +0,0 @@
1
- module.exports = (...args) => { console.error(...args); process.exit(1); };
package/lib/set-auth.js DELETED
@@ -1,10 +0,0 @@
1
- const SemanticReleaseError = require('@semantic-release/error');
2
-
3
- module.exports = async (logger) => {
4
- logger.log('Verify authentication for vsce');
5
- const { VSCE_TOKEN } = process.env;
6
-
7
- if (!VSCE_TOKEN) {
8
- throw new SemanticReleaseError('No vsce personal access token specified. (set env "VSCE_TOKEN")', 'ENOVSCEPAT');
9
- }
10
- };
@@ -1,20 +0,0 @@
1
- const { readFile, writeJson, pathExists } = require('fs-extra');
2
- const detectIndent = require('detect-indent');
3
-
4
- module.exports = async (version, logger) => {
5
- const pkgRaw = (await readFile('./package.json')).toString();
6
- const pkg = JSON.parse(pkgRaw);
7
- const pkgIndent = detectIndent(pkgRaw).indent || ' ';
8
-
9
- await writeJson('./package.json', Object.assign(pkg, { version }), { spaces: pkgIndent });
10
- logger.log('Wrote version %s to package.json', version);
11
-
12
- if (await pathExists('./npm-shrinkwrap.json')) {
13
- const shrinkWrapRaw = (await readFile('./npm-shrinkwrap.json')).toString();
14
- const shrinkwrap = JSON.parse(shrinkWrapRaw);
15
- const shrinkWrapIndent = detectIndent(shrinkWrapRaw).indent || ' ';
16
- shrinkwrap.version = version;
17
- await writeJson('./npm-shrinkwrap.json', shrinkwrap, { spaces: shrinkWrapIndent });
18
- logger.log('Wrote version %s to npm-shrinkwrap.json', version);
19
- }
20
- };
@@ -1,18 +0,0 @@
1
- const test = require('ava');
2
- const sinon = require('sinon');
3
- const SemanticReleaseError = require('@semantic-release/error');
4
- const setAuth = require('../lib/set-auth');
5
-
6
- const logger = {
7
- log: sinon.fake()
8
- };
9
-
10
- test('VSCE_TOKEN is set', async t => {
11
- process.env.VSCE_TOKEN = 'abc123';
12
- await t.notThrowsAsync(() => setAuth(logger));
13
- });
14
-
15
- test('VSCE_TOKEN is not set', async t => {
16
- delete process.env.VSCE_TOKEN;
17
- await t.throwsAsync(() => setAuth(logger), { instanceOf: SemanticReleaseError });
18
- });
@@ -1,115 +0,0 @@
1
- const sinon = require('sinon');
2
- const test = require('ava');
3
- const proxyquire = require('proxyquire');
4
-
5
- const logger = {
6
- log: sinon.fake()
7
- };
8
-
9
- test.beforeEach(t => {
10
- t.context.stubs = {
11
- writeJsonStub: sinon.stub()
12
- };
13
- });
14
-
15
- test.afterEach(t => {
16
- t.context.stubs.writeJsonStub.resetHistory();
17
- });
18
-
19
- test('package.json indentation uses spaces', async t => {
20
- const { writeJsonStub } = t.context.stubs;
21
- const updatePackageVersion = proxyquire('../lib/update-package-version', {
22
- 'fs-extra': {
23
- // test with 3 spaces so we don't hit the default
24
- readFile: sinon.stub().returns('{\n "name":"test"\n}'),
25
- writeJson: writeJsonStub,
26
- pathExists: sinon.stub().returns(false)
27
- }
28
- });
29
-
30
- await updatePackageVersion('1.0.0', logger);
31
- t.deepEqual(writeJsonStub.getCall(0).args,
32
- ['./package.json', { name: 'test', version: '1.0.0' }, { spaces: ' ' }]
33
- );
34
- });
35
-
36
- test('package.json indentation uses tabs', async t => {
37
- const { writeJsonStub } = t.context.stubs;
38
- const updatePackageVersion = proxyquire('../lib/update-package-version', {
39
- 'fs-extra': {
40
- readFile: sinon.stub().returns('{\n\t"name":"test"\n}'),
41
- writeJson: writeJsonStub,
42
- pathExists: sinon.stub().returns(false)
43
- }
44
- });
45
-
46
- await updatePackageVersion('1.0.0', logger);
47
- t.deepEqual(writeJsonStub.getCall(0).args,
48
- ['./package.json', { name: 'test', version: '1.0.0' }, { spaces: '\t' }]
49
- );
50
- });
51
-
52
- test('package.json indentation is undetermined', async t => {
53
- const { writeJsonStub } = t.context.stubs;
54
- const updatePackageVersion = proxyquire('../lib/update-package-version', {
55
- 'fs-extra': {
56
- readFile: sinon.stub().returns('{"name":"test"}'),
57
- writeJson: writeJsonStub,
58
- pathExists: sinon.stub().returns(false)
59
- }
60
- });
61
-
62
- await updatePackageVersion('1.0.0', logger);
63
- t.deepEqual(writeJsonStub.getCall(0).args,
64
- ['./package.json', { name: 'test', version: '1.0.0' }, { spaces: ' ' }]
65
- );
66
- });
67
-
68
- test('npm-shrinkwrap.json indentation uses spaces', async t => {
69
- const { writeJsonStub } = t.context.stubs;
70
- const updatePackageVersion = proxyquire('../lib/update-package-version', {
71
- 'fs-extra': {
72
- // test with 3 spaces so we don't hit the default
73
- readFile: sinon.stub().returns('{\n "version":"0.0.0"\n}'),
74
- writeJson: writeJsonStub,
75
- pathExists: sinon.stub().returns(true)
76
- }
77
- });
78
-
79
- await updatePackageVersion('1.0.0', logger);
80
- t.deepEqual(writeJsonStub.getCall(1).args,
81
- ['./npm-shrinkwrap.json', { version: '1.0.0' }, { spaces: ' ' }]
82
- );
83
- });
84
-
85
- test('npm-shrinkwrap.json indentation uses tabs', async t => {
86
- const { writeJsonStub } = t.context.stubs;
87
- const updatePackageVersion = proxyquire('../lib/update-package-version', {
88
- 'fs-extra': {
89
- readFile: sinon.stub().returns('{\n\t"version":"0.0.0"\n}'),
90
- writeJson: writeJsonStub,
91
- pathExists: sinon.stub().returns(true)
92
- }
93
- });
94
-
95
- await updatePackageVersion('1.0.0', logger);
96
- t.deepEqual(writeJsonStub.getCall(1).args,
97
- ['./npm-shrinkwrap.json', { version: '1.0.0' }, { spaces: '\t' }]
98
- );
99
- });
100
-
101
- test('npm-shrinkwrap.json indentation is undetermined', async t => {
102
- const { writeJsonStub } = t.context.stubs;
103
- const updatePackageVersion = proxyquire('../lib/update-package-version', {
104
- 'fs-extra': {
105
- readFile: sinon.stub().returns('{"version":"0.0.0"}'),
106
- writeJson: writeJsonStub,
107
- pathExists: sinon.stub().returns(true)
108
- }
109
- });
110
-
111
- await updatePackageVersion('1.0.0', logger);
112
- t.deepEqual(writeJsonStub.getCall(1).args,
113
- ['./npm-shrinkwrap.json', { version: '1.0.0' }, { spaces: ' ' }]
114
- );
115
- });