@form8ion/codecov 1.1.0 → 1.5.0
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/README.md +42 -2
- package/example.js +5 -2
- package/lib/index.cjs.js +93 -22
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.es.js +92 -23
- package/lib/index.es.js.map +1 -1
- package/package.json +13 -9
package/README.md
CHANGED
|
@@ -11,20 +11,41 @@ code coverage service plugin for form8ion
|
|
|
11
11
|
|
|
12
12
|
## Table of Contents
|
|
13
13
|
|
|
14
|
+
* [Features](#features)
|
|
15
|
+
* [Scaffold](#scaffold)
|
|
16
|
+
* [Lift](#lift)
|
|
14
17
|
* [Usage](#usage)
|
|
15
18
|
* [Installation](#installation)
|
|
16
19
|
* [Example](#example)
|
|
17
20
|
* [Import](#import)
|
|
18
21
|
* [Execute](#execute)
|
|
19
22
|
* [API](#api)
|
|
20
|
-
* [scaffold](#scaffold)
|
|
23
|
+
* [scaffold](#scaffold-1)
|
|
21
24
|
* [`vcs` __object__ (_required_)](#vcs-object-required)
|
|
22
25
|
* [`visibility` __string__ (_required_)](#visibility-string-required)
|
|
23
26
|
* [`apiAccessToken` __string__ (_optional_)](#apiaccesstoken-string-optional)
|
|
27
|
+
* [lift](#lift-1)
|
|
28
|
+
* [`projectRoot` __string__ (_required_)](#projectroot-string-required)
|
|
29
|
+
* [`packageManager` __string__ (_required_)](#packagemanager-string-required)
|
|
24
30
|
* [Contributing](#contributing)
|
|
25
31
|
* [Dependencies](#dependencies)
|
|
26
32
|
* [Verification](#verification)
|
|
27
33
|
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
### Scaffold
|
|
37
|
+
|
|
38
|
+
* Define a coverage status badge to communicate current coverage details
|
|
39
|
+
* Link from the status badge to further details on the [Codecov](https://codecov.io/)
|
|
40
|
+
site
|
|
41
|
+
* Define a coverage status badge for private projects when an [`apiAccessToken` __string__ (_optional_)](#apiaccesstoken-string-optional)
|
|
42
|
+
is provided
|
|
43
|
+
|
|
44
|
+
### Lift
|
|
45
|
+
|
|
46
|
+
* Migrate from the [legacy node uploader](https://github.com/codecov/codecov-node)
|
|
47
|
+
to the [modern uploader](https://docs.codecov.com/docs/codecov-uploader)
|
|
48
|
+
|
|
28
49
|
## Usage
|
|
29
50
|
|
|
30
51
|
<!--consumer-badges start -->
|
|
@@ -46,7 +67,8 @@ $ npm install @form8ion/codecov --save
|
|
|
46
67
|
#### Import
|
|
47
68
|
|
|
48
69
|
```javascript
|
|
49
|
-
import {
|
|
70
|
+
import {packageManagers} from '@form8ion/javascript-core';
|
|
71
|
+
import {scaffold, lift} from '@form8ion/codecov';
|
|
50
72
|
```
|
|
51
73
|
|
|
52
74
|
#### Execute
|
|
@@ -71,6 +93,8 @@ import {scaffold} from './lib/index.cjs';
|
|
|
71
93
|
},
|
|
72
94
|
apiAccessToken: 'XXXXXX'
|
|
73
95
|
});
|
|
96
|
+
|
|
97
|
+
await lift({projectRoot: process.cwd(), packageManager: packageManagers.NPM});
|
|
74
98
|
})();
|
|
75
99
|
```
|
|
76
100
|
|
|
@@ -108,6 +132,22 @@ Since the [Codecov API](https://docs.codecov.com/reference) appears to only
|
|
|
108
132
|
support GitHub at the time of this implementation, GitHub is the only VCS host
|
|
109
133
|
supported by this scaffolder at this time.
|
|
110
134
|
|
|
135
|
+
#### lift
|
|
136
|
+
|
|
137
|
+
Migrates [Codecov](https://codecov.io/) details from legacy conventions to
|
|
138
|
+
modern conventions.
|
|
139
|
+
|
|
140
|
+
Takes a single options object as an argument, containing:
|
|
141
|
+
|
|
142
|
+
##### `projectRoot` __string__ (_required_)
|
|
143
|
+
|
|
144
|
+
path to the root of the project
|
|
145
|
+
|
|
146
|
+
##### `packageManager` __string__ (_required_)
|
|
147
|
+
|
|
148
|
+
chosen [package manager](https://github.com/form8ion/javascript-core#packagemanagers)
|
|
149
|
+
to be used for the project
|
|
150
|
+
|
|
111
151
|
## Contributing
|
|
112
152
|
|
|
113
153
|
<!--contribution-badges start -->
|
package/example.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
import stubbedFs from 'mock-fs';
|
|
4
4
|
import nock from 'nock';
|
|
5
5
|
import {StatusCodes} from 'http-status-codes';
|
|
6
|
-
import {
|
|
6
|
+
import {packageManagers} from '@form8ion/javascript-core';
|
|
7
|
+
import {scaffold, lift} from './lib/index.cjs';
|
|
7
8
|
|
|
8
9
|
// remark-usage-ignore-next 5
|
|
9
|
-
stubbedFs();
|
|
10
|
+
stubbedFs({'package.json': JSON.stringify({scripts: {}})});
|
|
10
11
|
nock.disableNetConnect();
|
|
11
12
|
nock('https://codecov.io/')
|
|
12
13
|
.get('/api/gh/foo/bar')
|
|
@@ -33,4 +34,6 @@ nock('https://codecov.io/')
|
|
|
33
34
|
},
|
|
34
35
|
apiAccessToken: 'XXXXXX'
|
|
35
36
|
});
|
|
37
|
+
|
|
38
|
+
await lift({projectRoot: process.cwd(), packageManager: packageManagers.NPM});
|
|
36
39
|
})();
|
package/lib/index.cjs.js
CHANGED
|
@@ -3,24 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var got = require('got');
|
|
6
|
+
var fs = require('fs');
|
|
7
|
+
var execa = require('execa');
|
|
6
8
|
|
|
7
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
10
|
|
|
9
11
|
var got__default = /*#__PURE__*/_interopDefaultLegacy(got);
|
|
12
|
+
var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
|
|
10
13
|
|
|
11
14
|
function ownKeys(object, enumerableOnly) {
|
|
12
15
|
var keys = Object.keys(object);
|
|
13
16
|
|
|
14
17
|
if (Object.getOwnPropertySymbols) {
|
|
15
18
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
keys.push.apply(keys, symbols);
|
|
19
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
21
|
+
})), keys.push.apply(keys, symbols);
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
return keys;
|
|
@@ -28,19 +26,12 @@ function ownKeys(object, enumerableOnly) {
|
|
|
28
26
|
|
|
29
27
|
function _objectSpread2(target) {
|
|
30
28
|
for (var i = 1; i < arguments.length; i++) {
|
|
31
|
-
var source = arguments[i]
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
38
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
39
|
-
} else {
|
|
40
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
41
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
42
|
-
});
|
|
43
|
-
}
|
|
29
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
30
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
31
|
+
_defineProperty(target, key, source[key]);
|
|
32
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
33
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
34
|
+
});
|
|
44
35
|
}
|
|
45
36
|
|
|
46
37
|
return target;
|
|
@@ -61,6 +52,42 @@ function _defineProperty(obj, key, value) {
|
|
|
61
52
|
return obj;
|
|
62
53
|
}
|
|
63
54
|
|
|
55
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
56
|
+
if (source == null) return {};
|
|
57
|
+
var target = {};
|
|
58
|
+
var sourceKeys = Object.keys(source);
|
|
59
|
+
var key, i;
|
|
60
|
+
|
|
61
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
62
|
+
key = sourceKeys[i];
|
|
63
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
64
|
+
target[key] = source[key];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return target;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function _objectWithoutProperties(source, excluded) {
|
|
71
|
+
if (source == null) return {};
|
|
72
|
+
|
|
73
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
74
|
+
|
|
75
|
+
var key, i;
|
|
76
|
+
|
|
77
|
+
if (Object.getOwnPropertySymbols) {
|
|
78
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
79
|
+
|
|
80
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
81
|
+
key = sourceSymbolKeys[i];
|
|
82
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
83
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
84
|
+
target[key] = source[key];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return target;
|
|
89
|
+
}
|
|
90
|
+
|
|
64
91
|
function coverageShouldBeReportedToCodecov({
|
|
65
92
|
vcs,
|
|
66
93
|
visibility,
|
|
@@ -78,6 +105,39 @@ function scaffold$2() {
|
|
|
78
105
|
};
|
|
79
106
|
}
|
|
80
107
|
|
|
108
|
+
const _excluded = ["scripts"],
|
|
109
|
+
_excluded2 = ["coverage:report"];
|
|
110
|
+
async function liftReporting ({
|
|
111
|
+
projectRoot,
|
|
112
|
+
packageManager
|
|
113
|
+
}) {
|
|
114
|
+
const pathToPackageJson = `${projectRoot}/package.json`;
|
|
115
|
+
const existingPackageContents = await fs.promises.readFile(pathToPackageJson, 'utf-8');
|
|
116
|
+
|
|
117
|
+
const _JSON$parse = JSON.parse(existingPackageContents),
|
|
118
|
+
{
|
|
119
|
+
scripts
|
|
120
|
+
} = _JSON$parse,
|
|
121
|
+
otherTopLevelProperties = _objectWithoutProperties(_JSON$parse, _excluded);
|
|
122
|
+
|
|
123
|
+
const otherScripts = _objectWithoutProperties(scripts, _excluded2);
|
|
124
|
+
|
|
125
|
+
if (scripts['coverage:report']) {
|
|
126
|
+
await fs.promises.writeFile(pathToPackageJson, JSON.stringify(_objectSpread2(_objectSpread2({}, otherTopLevelProperties), {}, {
|
|
127
|
+
scripts: otherScripts
|
|
128
|
+
})));
|
|
129
|
+
await execa__default["default"](packageManager, ['remove', 'codecov']);
|
|
130
|
+
return {
|
|
131
|
+
nextSteps: [{
|
|
132
|
+
summary: 'Configure modern reporting to Codecov on your CI service',
|
|
133
|
+
description: 'Configure the [Codecov Uploader](https://docs.codecov.com/docs/codecov-uploader) appropriately' + ' for your CI Provider. If available for your provider, prefer one of the dedicated wrappers.'
|
|
134
|
+
}]
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return {};
|
|
139
|
+
}
|
|
140
|
+
|
|
81
141
|
async function fetchRepositoryDetails ({
|
|
82
142
|
vcs,
|
|
83
143
|
apiAccessToken
|
|
@@ -103,7 +163,7 @@ async function scaffold$1({
|
|
|
103
163
|
badges: {
|
|
104
164
|
status: {
|
|
105
165
|
coverage: {
|
|
106
|
-
img: `https://img.shields.io/codecov/c/${vcs.host}/${vcs.owner}/${vcs.name}
|
|
166
|
+
img: `https://img.shields.io/codecov/c/${vcs.host}/${vcs.owner}/${vcs.name}?logo=codecov${apiAccessToken ? `&token=${(await fetchRepositoryDetails({
|
|
107
167
|
vcs,
|
|
108
168
|
apiAccessToken
|
|
109
169
|
})).image_token}` : ''}`,
|
|
@@ -131,5 +191,16 @@ async function scaffold({
|
|
|
131
191
|
}));
|
|
132
192
|
}
|
|
133
193
|
|
|
194
|
+
function lift({
|
|
195
|
+
projectRoot,
|
|
196
|
+
packageManager
|
|
197
|
+
}) {
|
|
198
|
+
return liftReporting({
|
|
199
|
+
projectRoot,
|
|
200
|
+
packageManager
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
exports.lift = lift;
|
|
134
205
|
exports.scaffold = scaffold;
|
|
135
206
|
//# sourceMappingURL=index.cjs.js.map
|
package/lib/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/predicates.js","../src/reporter.js","../src/repository-details-fetcher.js","../src/badge.js","../src/scaffolder.js"],"sourcesContent":["export function coverageShouldBeReportedToCodecov({vcs, visibility, apiAccessToken}) {\n return !!('Public' === visibility || (apiAccessToken && 'github' === vcs.host));\n}\n","export function scaffold() {\n return {\n devDependencies: ['codecov'],\n scripts: {'coverage:report': 'c8 report --reporter=text-lcov > coverage.lcov && codecov'}\n };\n}\n","import got from '
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/predicates.js","../src/reporter/scaffolder.js","../src/reporter/lifter.js","../src/badge/repository-details-fetcher.js","../src/badge/scaffolder.js","../src/scaffolder.js","../src/lifter.js"],"sourcesContent":["export function coverageShouldBeReportedToCodecov({vcs, visibility, apiAccessToken}) {\n return !!('Public' === visibility || (apiAccessToken && 'github' === vcs.host));\n}\n","export function scaffold() {\n return {\n devDependencies: ['codecov'],\n scripts: {'coverage:report': 'c8 report --reporter=text-lcov > coverage.lcov && codecov'}\n };\n}\n","import {promises as fs} from 'fs';\n\nimport execa from '../../thirdparty-wrappers/execa';\n\nexport default async function ({projectRoot, packageManager}) {\n const pathToPackageJson = `${projectRoot}/package.json`;\n\n const existingPackageContents = await fs.readFile(pathToPackageJson, 'utf-8');\n const {scripts, ...otherTopLevelProperties} = JSON.parse(existingPackageContents);\n const {'coverage:report': reportCoverageScript, ...otherScripts} = scripts;\n\n if (scripts['coverage:report']) {\n await fs.writeFile(pathToPackageJson, JSON.stringify({...otherTopLevelProperties, scripts: otherScripts}));\n\n await execa(packageManager, ['remove', 'codecov']);\n\n return {\n nextSteps: [{\n summary: 'Configure modern reporting to Codecov on your CI service',\n description: 'Configure the [Codecov Uploader](https://docs.codecov.com/docs/codecov-uploader) appropriately'\n + ' for your CI Provider. If available for your provider, prefer one of the dedicated wrappers.'\n }]\n };\n }\n\n return {};\n}\n","import got from '../../thirdparty-wrappers/got';\n\nexport default async function ({vcs, apiAccessToken}) {\n const {body: {repo}} = await got(\n `https://codecov.io/api/gh/${vcs.owner}/${vcs.name}`,\n {headers: {Authorization: apiAccessToken}, responseType: 'json'}\n );\n\n return repo;\n}\n","import fetchRepositoryDetails from './repository-details-fetcher';\n\nexport async function scaffold({vcs, apiAccessToken}) {\n return {\n ...['github', 'gitlab', 'bitbucket'].includes(vcs?.host) && {\n badges: {\n status: {\n coverage: {\n img: `https://img.shields.io/codecov/c/${vcs.host}/${vcs.owner}/${vcs.name}?logo=codecov${\n apiAccessToken\n ? `&token=${(await fetchRepositoryDetails({vcs, apiAccessToken})).image_token}`\n : ''\n }`,\n link: `https://codecov.io/${vcs.host}/${vcs.owner}/${vcs.name}`,\n text: 'Codecov'\n }\n }\n }\n }\n };\n}\n","import {coverageShouldBeReportedToCodecov} from './predicates';\nimport {scaffold as scaffoldReporter} from './reporter';\nimport {scaffold as scaffoldBadge} from './badge';\n\nexport async function scaffold({vcs, visibility, apiAccessToken}) {\n if (!coverageShouldBeReportedToCodecov({vcs, visibility, apiAccessToken})) return {};\n\n return {\n ...scaffoldReporter(),\n ...await scaffoldBadge({vcs, apiAccessToken})\n };\n}\n","import {lift as liftReporting} from './reporter';\n\nexport function lift({projectRoot, packageManager}) {\n return liftReporting({projectRoot, packageManager});\n}\n"],"names":["coverageShouldBeReportedToCodecov","vcs","visibility","apiAccessToken","host","scaffold","devDependencies","scripts","projectRoot","packageManager","pathToPackageJson","existingPackageContents","fs","readFile","JSON","parse","otherTopLevelProperties","otherScripts","writeFile","stringify","execa","nextSteps","summary","description","body","repo","got","owner","name","headers","Authorization","responseType","includes","badges","status","coverage","img","fetchRepositoryDetails","image_token","link","text","scaffoldRe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EAAAA;AAAlB,CAAxB,EAA2D;AAChE,MAAI,CAACH,iCAAiC,CAAC;AAACC,IAAAA,GAAD;AAAMC,IAAAA,UAAN;AAAkBC,IAAAA;AAAlB,GAAD,CAAtC,EAA2E,OAAO,EAAP;AAE3E,2CACKsC,UAAgB,EADrB,GAEK,MAAMC,UAAa,CAAC;AAACzC,IAAAA,GAAD;AAAME,IAAAA;AAAN,GAAD,CAFxB;AAID;;ACTM,SAASwC,IAAT,CAAc;AAACnC,EAAAA,WAAD;AAAcC,EAAAA;AAAd,CAAd,EAA6C;AAClD,SAAOmC,aAAa,CAAC;AAACpC,IAAAA,WAAD;AAAcC,IAAAA;AAAd,GAAD,CAApB;AACD;;;;;"}
|
package/lib/index.es.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import got from 'got';
|
|
2
|
+
import { promises } from 'fs';
|
|
3
|
+
import execa from 'execa';
|
|
2
4
|
|
|
3
5
|
function ownKeys(object, enumerableOnly) {
|
|
4
6
|
var keys = Object.keys(object);
|
|
5
7
|
|
|
6
8
|
if (Object.getOwnPropertySymbols) {
|
|
7
9
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
keys.push.apply(keys, symbols);
|
|
10
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
11
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
12
|
+
})), keys.push.apply(keys, symbols);
|
|
16
13
|
}
|
|
17
14
|
|
|
18
15
|
return keys;
|
|
@@ -20,19 +17,12 @@ function ownKeys(object, enumerableOnly) {
|
|
|
20
17
|
|
|
21
18
|
function _objectSpread2(target) {
|
|
22
19
|
for (var i = 1; i < arguments.length; i++) {
|
|
23
|
-
var source = arguments[i]
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
30
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
31
|
-
} else {
|
|
32
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
33
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
34
|
-
});
|
|
35
|
-
}
|
|
20
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
21
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
22
|
+
_defineProperty(target, key, source[key]);
|
|
23
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
24
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
25
|
+
});
|
|
36
26
|
}
|
|
37
27
|
|
|
38
28
|
return target;
|
|
@@ -53,6 +43,42 @@ function _defineProperty(obj, key, value) {
|
|
|
53
43
|
return obj;
|
|
54
44
|
}
|
|
55
45
|
|
|
46
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
47
|
+
if (source == null) return {};
|
|
48
|
+
var target = {};
|
|
49
|
+
var sourceKeys = Object.keys(source);
|
|
50
|
+
var key, i;
|
|
51
|
+
|
|
52
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
53
|
+
key = sourceKeys[i];
|
|
54
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
55
|
+
target[key] = source[key];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return target;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function _objectWithoutProperties(source, excluded) {
|
|
62
|
+
if (source == null) return {};
|
|
63
|
+
|
|
64
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
65
|
+
|
|
66
|
+
var key, i;
|
|
67
|
+
|
|
68
|
+
if (Object.getOwnPropertySymbols) {
|
|
69
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
70
|
+
|
|
71
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
72
|
+
key = sourceSymbolKeys[i];
|
|
73
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
74
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
75
|
+
target[key] = source[key];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return target;
|
|
80
|
+
}
|
|
81
|
+
|
|
56
82
|
function coverageShouldBeReportedToCodecov({
|
|
57
83
|
vcs,
|
|
58
84
|
visibility,
|
|
@@ -70,6 +96,39 @@ function scaffold$2() {
|
|
|
70
96
|
};
|
|
71
97
|
}
|
|
72
98
|
|
|
99
|
+
const _excluded = ["scripts"],
|
|
100
|
+
_excluded2 = ["coverage:report"];
|
|
101
|
+
async function liftReporting ({
|
|
102
|
+
projectRoot,
|
|
103
|
+
packageManager
|
|
104
|
+
}) {
|
|
105
|
+
const pathToPackageJson = `${projectRoot}/package.json`;
|
|
106
|
+
const existingPackageContents = await promises.readFile(pathToPackageJson, 'utf-8');
|
|
107
|
+
|
|
108
|
+
const _JSON$parse = JSON.parse(existingPackageContents),
|
|
109
|
+
{
|
|
110
|
+
scripts
|
|
111
|
+
} = _JSON$parse,
|
|
112
|
+
otherTopLevelProperties = _objectWithoutProperties(_JSON$parse, _excluded);
|
|
113
|
+
|
|
114
|
+
const otherScripts = _objectWithoutProperties(scripts, _excluded2);
|
|
115
|
+
|
|
116
|
+
if (scripts['coverage:report']) {
|
|
117
|
+
await promises.writeFile(pathToPackageJson, JSON.stringify(_objectSpread2(_objectSpread2({}, otherTopLevelProperties), {}, {
|
|
118
|
+
scripts: otherScripts
|
|
119
|
+
})));
|
|
120
|
+
await execa(packageManager, ['remove', 'codecov']);
|
|
121
|
+
return {
|
|
122
|
+
nextSteps: [{
|
|
123
|
+
summary: 'Configure modern reporting to Codecov on your CI service',
|
|
124
|
+
description: 'Configure the [Codecov Uploader](https://docs.codecov.com/docs/codecov-uploader) appropriately' + ' for your CI Provider. If available for your provider, prefer one of the dedicated wrappers.'
|
|
125
|
+
}]
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return {};
|
|
130
|
+
}
|
|
131
|
+
|
|
73
132
|
async function fetchRepositoryDetails ({
|
|
74
133
|
vcs,
|
|
75
134
|
apiAccessToken
|
|
@@ -95,7 +154,7 @@ async function scaffold$1({
|
|
|
95
154
|
badges: {
|
|
96
155
|
status: {
|
|
97
156
|
coverage: {
|
|
98
|
-
img: `https://img.shields.io/codecov/c/${vcs.host}/${vcs.owner}/${vcs.name}
|
|
157
|
+
img: `https://img.shields.io/codecov/c/${vcs.host}/${vcs.owner}/${vcs.name}?logo=codecov${apiAccessToken ? `&token=${(await fetchRepositoryDetails({
|
|
99
158
|
vcs,
|
|
100
159
|
apiAccessToken
|
|
101
160
|
})).image_token}` : ''}`,
|
|
@@ -123,5 +182,15 @@ async function scaffold({
|
|
|
123
182
|
}));
|
|
124
183
|
}
|
|
125
184
|
|
|
126
|
-
|
|
185
|
+
function lift({
|
|
186
|
+
projectRoot,
|
|
187
|
+
packageManager
|
|
188
|
+
}) {
|
|
189
|
+
return liftReporting({
|
|
190
|
+
projectRoot,
|
|
191
|
+
packageManager
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export { lift, scaffold };
|
|
127
196
|
//# sourceMappingURL=index.es.js.map
|
package/lib/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/predicates.js","../src/reporter.js","../src/repository-details-fetcher.js","../src/badge.js","../src/scaffolder.js"],"sourcesContent":["export function coverageShouldBeReportedToCodecov({vcs, visibility, apiAccessToken}) {\n return !!('Public' === visibility || (apiAccessToken && 'github' === vcs.host));\n}\n","export function scaffold() {\n return {\n devDependencies: ['codecov'],\n scripts: {'coverage:report': 'c8 report --reporter=text-lcov > coverage.lcov && codecov'}\n };\n}\n","import got from '
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/predicates.js","../src/reporter/scaffolder.js","../src/reporter/lifter.js","../src/badge/repository-details-fetcher.js","../src/badge/scaffolder.js","../src/scaffolder.js","../src/lifter.js"],"sourcesContent":["export function coverageShouldBeReportedToCodecov({vcs, visibility, apiAccessToken}) {\n return !!('Public' === visibility || (apiAccessToken && 'github' === vcs.host));\n}\n","export function scaffold() {\n return {\n devDependencies: ['codecov'],\n scripts: {'coverage:report': 'c8 report --reporter=text-lcov > coverage.lcov && codecov'}\n };\n}\n","import {promises as fs} from 'fs';\n\nimport execa from '../../thirdparty-wrappers/execa';\n\nexport default async function ({projectRoot, packageManager}) {\n const pathToPackageJson = `${projectRoot}/package.json`;\n\n const existingPackageContents = await fs.readFile(pathToPackageJson, 'utf-8');\n const {scripts, ...otherTopLevelProperties} = JSON.parse(existingPackageContents);\n const {'coverage:report': reportCoverageScript, ...otherScripts} = scripts;\n\n if (scripts['coverage:report']) {\n await fs.writeFile(pathToPackageJson, JSON.stringify({...otherTopLevelProperties, scripts: otherScripts}));\n\n await execa(packageManager, ['remove', 'codecov']);\n\n return {\n nextSteps: [{\n summary: 'Configure modern reporting to Codecov on your CI service',\n description: 'Configure the [Codecov Uploader](https://docs.codecov.com/docs/codecov-uploader) appropriately'\n + ' for your CI Provider. If available for your provider, prefer one of the dedicated wrappers.'\n }]\n };\n }\n\n return {};\n}\n","import got from '../../thirdparty-wrappers/got';\n\nexport default async function ({vcs, apiAccessToken}) {\n const {body: {repo}} = await got(\n `https://codecov.io/api/gh/${vcs.owner}/${vcs.name}`,\n {headers: {Authorization: apiAccessToken}, responseType: 'json'}\n );\n\n return repo;\n}\n","import fetchRepositoryDetails from './repository-details-fetcher';\n\nexport async function scaffold({vcs, apiAccessToken}) {\n return {\n ...['github', 'gitlab', 'bitbucket'].includes(vcs?.host) && {\n badges: {\n status: {\n coverage: {\n img: `https://img.shields.io/codecov/c/${vcs.host}/${vcs.owner}/${vcs.name}?logo=codecov${\n apiAccessToken\n ? `&token=${(await fetchRepositoryDetails({vcs, apiAccessToken})).image_token}`\n : ''\n }`,\n link: `https://codecov.io/${vcs.host}/${vcs.owner}/${vcs.name}`,\n text: 'Codecov'\n }\n }\n }\n }\n };\n}\n","import {coverageShouldBeReportedToCodecov} from './predicates';\nimport {scaffold as scaffoldReporter} from './reporter';\nimport {scaffold as scaffoldBadge} from './badge';\n\nexport async function scaffold({vcs, visibility, apiAccessToken}) {\n if (!coverageShouldBeReportedToCodecov({vcs, visibility, apiAccessToken})) return {};\n\n return {\n ...scaffoldReporter(),\n ...await scaffoldBadge({vcs, apiAccessToken})\n };\n}\n","import {lift as liftReporting} from './reporter';\n\nexport function lift({projectRoot, packageManager}) {\n return liftReporting({projectRoot, packageManager});\n}\n"],"names":["coverageShouldBeReportedToCodecov","vcs","visibility","apiAccessToken","host","scaffold","devDependencies","scripts","projectRoot","packageManager","pathToPackageJson","existingPackageContents","fs","readFile","JSON","parse","otherTopLevelProperties","otherScripts","writeFile","stringify","execa","nextSteps","summary","description","body","repo","got","owner","name","headers","Authorization","responseType","includes","badges","status","coverage","img","fetchRepositoryDetails","image_token","link","text","scaffoldReporter","scaffoldBadge","lift","liftReporting"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAASA,iCAAT,CAA2C;AAACC,EAAAA,GAAD;AAAMC,EAAAA,UAAN;AAAkBC,EAAAA;AAAlB,CAA3C,EAA8E;AACnF,SAAO,CAAC,EAAE,aAAaD,UAAb,IAA4BC,cAAc,IAAI,aAAaF,GAAG,CAACG,IAAjE,CAAR;AACD;;ACFM,SAASC,UAAT,GAAoB;AACzB,SAAO;AACLC,IAAAA,eAAe,EAAE,CAAC,SAAD,CADZ;AAELC,IAAAA,OAAO,EAAE;AAAC,yBAAmB;AAApB;AAFJ,GAAP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|
|
2
2
|
"name": "@form8ion/codecov",
|
|
3
3
|
"description": "code coverage service plugin for form8ion",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.5.0",
|
|
6
6
|
"files": [
|
|
7
7
|
"example.js",
|
|
8
8
|
"lib/"
|
|
@@ -48,16 +48,18 @@
|
|
|
48
48
|
"test:integration:focus": "run-s 'test:integration:base -- --profile focus'"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@babel/register": "7.16.
|
|
51
|
+
"@babel/register": "7.16.5",
|
|
52
52
|
"@cucumber/cucumber": "8.0.0-rc.1",
|
|
53
|
-
"@form8ion/babel-preset": "1.6.
|
|
53
|
+
"@form8ion/babel-preset": "1.6.73",
|
|
54
54
|
"@form8ion/commitlint-config": "1.0.23",
|
|
55
|
-
"@form8ion/eslint-config": "
|
|
55
|
+
"@form8ion/eslint-config": "2.0.2",
|
|
56
56
|
"@form8ion/eslint-config-cucumber": "1.4.0",
|
|
57
|
-
"@form8ion/eslint-config-mocha": "1.2.
|
|
58
|
-
"@form8ion/
|
|
57
|
+
"@form8ion/eslint-config-mocha": "1.2.17",
|
|
58
|
+
"@form8ion/javascript-core": "4.0.1",
|
|
59
|
+
"@form8ion/remark-lint-preset": "2.1.7",
|
|
59
60
|
"@rollup/plugin-babel": "5.3.0",
|
|
60
|
-
"@
|
|
61
|
+
"@rollup/plugin-node-resolve": "13.1.1",
|
|
62
|
+
"@travi/any": "2.0.19",
|
|
61
63
|
"ban-sensitive-files": "1.9.16",
|
|
62
64
|
"c8": "7.10.0",
|
|
63
65
|
"chai": "4.3.4",
|
|
@@ -77,11 +79,13 @@
|
|
|
77
79
|
"remark-toc": "8.0.1",
|
|
78
80
|
"remark-usage": "10.0.1",
|
|
79
81
|
"rimraf": "3.0.2",
|
|
80
|
-
"rollup": "2.
|
|
82
|
+
"rollup": "2.61.1",
|
|
81
83
|
"rollup-plugin-auto-external": "2.0.0",
|
|
82
|
-
"sinon": "12.0.1"
|
|
84
|
+
"sinon": "12.0.1",
|
|
85
|
+
"testdouble": "3.16.3"
|
|
83
86
|
},
|
|
84
87
|
"dependencies": {
|
|
88
|
+
"execa": "^5.1.1",
|
|
85
89
|
"got": "^11.8.2"
|
|
86
90
|
}
|
|
87
91
|
}
|