semantic-release-vsce 4.0.1 → 5.0.3
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.
- package/.github/dependabot.yml +4 -0
- package/.github/workflows/ci.yaml +5 -6
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/README.md +10 -4
- package/index.js +4 -3
- package/lib/prepare.js +18 -11
- package/lib/publish.js +33 -12
- package/lib/verify-auth.js +16 -0
- package/lib/verify-ovsx-auth.js +27 -0
- package/lib/verify-pkg.js +22 -3
- package/lib/verify.js +7 -17
- package/package.json +53 -54
- package/release.config.js +66 -0
- package/test/index.test.js +5 -8
- package/test/prepare.test.js +46 -41
- package/test/publish.test.js +50 -8
- package/test/verify-auth.test.js +54 -0
- package/test/verify-ovsx-auth.test.js +27 -0
- package/test/verify-pkg.test.js +97 -7
- package/test/verify.test.js +16 -10
- package/lib/die.js +0 -1
- package/lib/set-auth.js +0 -10
- package/lib/update-package-version.js +0 -20
- package/test/set-auth.test.js +0 -18
- package/test/update-package-version.test.js +0 -115
package/.github/dependabot.yml
CHANGED
|
@@ -4,9 +4,11 @@ on:
|
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
6
|
- master
|
|
7
|
+
- next
|
|
7
8
|
pull_request:
|
|
8
9
|
branches:
|
|
9
10
|
- master
|
|
11
|
+
- next
|
|
10
12
|
|
|
11
13
|
jobs:
|
|
12
14
|
test:
|
|
@@ -15,13 +17,12 @@ jobs:
|
|
|
15
17
|
strategy:
|
|
16
18
|
matrix:
|
|
17
19
|
node-version:
|
|
18
|
-
- 10
|
|
19
|
-
- 12
|
|
20
20
|
- 14
|
|
21
|
+
- 16
|
|
21
22
|
|
|
22
23
|
steps:
|
|
23
24
|
- uses: actions/checkout@v2
|
|
24
|
-
- uses:
|
|
25
|
+
- uses: volta-cli/action@v1
|
|
25
26
|
with:
|
|
26
27
|
node-version: ${{ matrix.node-version }}
|
|
27
28
|
- run: npm ci
|
|
@@ -34,9 +35,7 @@ jobs:
|
|
|
34
35
|
|
|
35
36
|
steps:
|
|
36
37
|
- uses: actions/checkout@v2
|
|
37
|
-
- uses:
|
|
38
|
-
with:
|
|
39
|
-
node-version: 14
|
|
38
|
+
- uses: volta-cli/action@v1
|
|
40
39
|
- run: npm ci
|
|
41
40
|
- run: npm run release
|
|
42
41
|
env:
|
package/README.md
CHANGED
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
[](https://david-dm.org/felipecrs/semantic-release-vsce?type=peer)
|
|
10
10
|
[](https://github.com/semantic-release/semantic-release)
|
|
11
11
|
|
|
12
|
-
Semantic release plugin for Visual Studio Code extensions
|
|
13
|
-
|
|
14
12
|
#### Add config to package.json
|
|
15
13
|
|
|
16
14
|
Use `semantic-release-vsce` as part of `verifyConditions` and `publish`.
|
|
@@ -47,7 +45,15 @@ Use `semantic-release-vsce` as part of `verifyConditions` and `publish`.
|
|
|
47
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`.
|
|
48
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.
|
|
49
47
|
|
|
50
|
-
|
|
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.
|
|
51
57
|
|
|
52
58
|
#### Working with older versions
|
|
53
59
|
|
|
@@ -57,7 +63,7 @@ Prior to v13, you had to override `getLastRelease` to use `@semantic-release/git
|
|
|
57
63
|
|
|
58
64
|
#### Travis example
|
|
59
65
|
|
|
60
|
-
Secret environment variables: `
|
|
66
|
+
Secret environment variables: `VSCE_PAT`
|
|
61
67
|
|
|
62
68
|
Example:
|
|
63
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,
|
|
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,
|
|
31
|
+
packagePath = await vscePrepare(version, pluginConfig.packageVsix, logger);
|
|
31
32
|
}
|
|
32
|
-
return vscePublish(version,
|
|
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
|
|
2
|
+
const { readJson } = require('fs-extra');
|
|
3
|
+
const { isOvsxEnabled } = require('./verify-ovsx-auth');
|
|
3
4
|
|
|
4
|
-
module.exports = async (version, packageVsix,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
12
|
+
let packagePath;
|
|
11
13
|
|
|
12
14
|
if (typeof packageVsix === 'string') {
|
|
13
|
-
|
|
15
|
+
packagePath = packageVsix;
|
|
16
|
+
} else {
|
|
17
|
+
const { name } = await readJson('./package.json');
|
|
18
|
+
packagePath = `${name}-${version}.vsix`;
|
|
14
19
|
}
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
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,
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
const options = ['publish', '--pat', VSCE_TOKEN];
|
|
8
|
+
const options = ['publish'];
|
|
12
9
|
|
|
13
|
-
if (
|
|
14
|
-
|
|
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
|
|
20
|
-
logger.log(`
|
|
21
|
-
|
|
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
|
|
24
|
+
throw new SemanticReleaseError('No `name` found in `package.json`.', 'ENOPKGNAME');
|
|
6
25
|
}
|
|
7
26
|
if (!publisher) {
|
|
8
|
-
throw new SemanticReleaseError('No
|
|
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
|
|
3
|
-
const
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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,78 +1,77 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semantic-release-vsce",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
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.3",
|
|
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
|
-
"
|
|
14
|
-
},
|
|
15
|
-
"engines": {
|
|
16
|
-
"node": ">=10.18"
|
|
17
|
-
},
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@semantic-release/error": "^2.2.0",
|
|
20
|
-
"detect-indent": "^6.0.0",
|
|
21
|
-
"execa": "^5.0.0",
|
|
22
|
-
"fs-extra": "^9.0.1",
|
|
23
|
-
"read-pkg-up": "^7.0.1",
|
|
24
|
-
"vsce": "^1.73.0"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@commitlint/cli": "^11.0.0",
|
|
28
|
-
"@commitlint/config-conventional": "^11.0.0",
|
|
29
|
-
"ava": "^3.9.0",
|
|
30
|
-
"conventional-changelog-conventionalcommits": "^4.2.1",
|
|
31
|
-
"eslint": "^6.8.0",
|
|
32
|
-
"eslint-config-standard": "^14.1.0",
|
|
33
|
-
"eslint-plugin-import": "^2.20.1",
|
|
34
|
-
"eslint-plugin-node": "^11.0.0",
|
|
35
|
-
"eslint-plugin-promise": "^4.2.1",
|
|
36
|
-
"eslint-plugin-standard": "^4.0.1",
|
|
37
|
-
"husky": "^4.2.3",
|
|
38
|
-
"nyc": "^15.1.0",
|
|
39
|
-
"proxyquire": "^2.1.3",
|
|
40
|
-
"semantic-release": "^17.0.3",
|
|
41
|
-
"sinon": "^9.0.2"
|
|
42
|
-
},
|
|
43
|
-
"peerDependencies": {
|
|
44
|
-
"semantic-release": ">=16.0.0"
|
|
45
|
-
},
|
|
46
|
-
"volta": {
|
|
47
|
-
"node": "14.15.4",
|
|
48
|
-
"npm": "7.4.2"
|
|
25
|
+
"prepare": "husky install"
|
|
49
26
|
},
|
|
50
27
|
"ava": {
|
|
51
28
|
"files": [
|
|
52
29
|
"test/**/*.test.js"
|
|
53
30
|
]
|
|
54
31
|
},
|
|
32
|
+
"commitlint": {
|
|
33
|
+
"extends": [
|
|
34
|
+
"@commitlint/config-conventional"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
55
37
|
"nyc": {
|
|
56
38
|
"all": true,
|
|
39
|
+
"exclude": [
|
|
40
|
+
"lib/die.js"
|
|
41
|
+
],
|
|
57
42
|
"include": [
|
|
58
43
|
"index.js",
|
|
59
44
|
"lib/**/*.js"
|
|
60
|
-
],
|
|
61
|
-
"exclude": [
|
|
62
|
-
"lib/die.js"
|
|
63
45
|
]
|
|
64
46
|
},
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
47
|
+
"volta": {
|
|
48
|
+
"node": "16.13.2",
|
|
49
|
+
"npm": "8.4.0"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@semantic-release/error": "^3.0.0",
|
|
53
|
+
"execa": "^5.0.0",
|
|
54
|
+
"fs-extra": "^10.0.0",
|
|
55
|
+
"ovsx": "^0.3.0",
|
|
56
|
+
"vsce": "^2.6.3"
|
|
69
57
|
},
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
73
|
-
}
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"semantic-release": ">=18"
|
|
74
60
|
},
|
|
75
|
-
"
|
|
76
|
-
"
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@commitlint/cli": "^16.0.2",
|
|
63
|
+
"@commitlint/config-conventional": "^16.0.0",
|
|
64
|
+
"ava": "^4.0.1",
|
|
65
|
+
"conventional-changelog-conventionalcommits": "^4.2.1",
|
|
66
|
+
"eslint": "^8.7.0",
|
|
67
|
+
"eslint-config-standard": "^17.0.0-0",
|
|
68
|
+
"eslint-plugin-import": "^2.20.1",
|
|
69
|
+
"eslint-plugin-n": "^14.0.0",
|
|
70
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
71
|
+
"husky": "^7.0.4",
|
|
72
|
+
"nyc": "^15.1.0",
|
|
73
|
+
"proxyquire": "^2.1.3",
|
|
74
|
+
"semantic-release": "^19.0.2",
|
|
75
|
+
"sinon": "^13.0.0"
|
|
77
76
|
}
|
|
78
77
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
plugins: [
|
|
3
|
+
[
|
|
4
|
+
'@semantic-release/commit-analyzer',
|
|
5
|
+
{
|
|
6
|
+
releaseRules: [
|
|
7
|
+
{
|
|
8
|
+
type: 'perf',
|
|
9
|
+
release: 'patch'
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
type: 'refactor',
|
|
13
|
+
release: 'patch'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
type: 'build',
|
|
17
|
+
scope: 'deps',
|
|
18
|
+
release: 'patch'
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
'@semantic-release/release-notes-generator',
|
|
25
|
+
{
|
|
26
|
+
presetConfig: {
|
|
27
|
+
types: [
|
|
28
|
+
{
|
|
29
|
+
type: 'feat',
|
|
30
|
+
section: 'Features'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: 'fix',
|
|
34
|
+
section: 'Bug Fixes'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'perf',
|
|
38
|
+
section: 'Performance Improvements'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'revert',
|
|
42
|
+
section: 'Reverts'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'refactor',
|
|
46
|
+
section: 'Code Refactoring'
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: 'build',
|
|
50
|
+
scope: 'deps',
|
|
51
|
+
section: 'Dependencies'
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
'@semantic-release/npm',
|
|
58
|
+
[
|
|
59
|
+
'@semantic-release/github',
|
|
60
|
+
{
|
|
61
|
+
addReleases: 'bottom'
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
],
|
|
65
|
+
preset: 'conventionalcommits'
|
|
66
|
+
};
|
package/test/index.test.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
138
|
+
packagePath,
|
|
142
139
|
semanticReleasePayload.logger
|
|
143
140
|
]);
|
|
144
141
|
});
|
package/test/prepare.test.js
CHANGED
|
@@ -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 {
|
|
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
|
|
42
|
-
await prepare(
|
|
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 {
|
|
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
|
-
|
|
39
|
+
const packagePath = packageVsix;
|
|
40
|
+
const result = await prepare(version, packageVsix, logger);
|
|
57
41
|
|
|
58
|
-
t.
|
|
59
|
-
t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', '--out',
|
|
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 {
|
|
47
|
+
const { execaStub } = t.context.stubs;
|
|
48
|
+
const name = 'test';
|
|
49
|
+
|
|
64
50
|
const prepare = proxyquire('../lib/prepare', {
|
|
65
51
|
execa: execaStub,
|
|
66
|
-
'
|
|
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
|
-
|
|
61
|
+
const packagePath = `${name}-${version}.vsix`;
|
|
71
62
|
|
|
72
|
-
|
|
73
|
-
|
|
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
|
|
77
|
-
const {
|
|
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
|
-
'
|
|
75
|
+
'fs-extra': {
|
|
76
|
+
readJson: sinon.stub().returns({
|
|
77
|
+
name
|
|
78
|
+
})
|
|
79
|
+
}
|
|
81
80
|
});
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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.
|
|
88
|
-
t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', '--
|
|
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
|
});
|
package/test/publish.test.js
CHANGED
|
@@ -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
|
|
35
|
-
|
|
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', '--
|
|
44
|
+
t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish', version, '--no-git-tag-version'], { stdio: 'inherit' }]);
|
|
42
45
|
});
|
|
43
46
|
|
|
44
|
-
test('publish
|
|
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
|
|
60
|
-
|
|
61
|
-
|
|
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', '--
|
|
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
|
+
});
|
package/test/verify-pkg.test.js
CHANGED
|
@@ -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
|
|
6
|
-
|
|
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
|
|
10
|
-
|
|
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
|
|
14
|
-
|
|
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
|
});
|
package/test/verify.test.js
CHANGED
|
@@ -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('
|
|
9
|
+
test('resolves', async t => {
|
|
11
10
|
const verify = proxyquire('../lib/verify', {
|
|
12
|
-
'./
|
|
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('
|
|
18
|
+
test('rejects with verify-auth', async t => {
|
|
21
19
|
const verify = proxyquire('../lib/verify', {
|
|
22
|
-
'./
|
|
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)
|
|
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/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
|
-
};
|
package/test/set-auth.test.js
DELETED
|
@@ -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
|
-
});
|