@form8ion/codecov 1.1.0-alpha.2 → 1.4.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 +35 -2
- package/example.js +4 -2
- package/lib/index.cjs.js +87 -22
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.es.js +87 -23
- package/lib/index.es.js.map +1 -1
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -11,20 +11,40 @@ 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)
|
|
24
29
|
* [Contributing](#contributing)
|
|
25
30
|
* [Dependencies](#dependencies)
|
|
26
31
|
* [Verification](#verification)
|
|
27
32
|
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
### Scaffold
|
|
36
|
+
|
|
37
|
+
* Define a coverage status badge to communicate current coverage details
|
|
38
|
+
* Link from the status badge to further details on the [Codecov](https://codecov.io/)
|
|
39
|
+
site
|
|
40
|
+
* Define a coverage status badge for private projects when an [`apiAccessToken` __string__ (_optional_)](#apiaccesstoken-string-optional)
|
|
41
|
+
is provided
|
|
42
|
+
|
|
43
|
+
### Lift
|
|
44
|
+
|
|
45
|
+
* Migrate from the [legacy node uploader](https://github.com/codecov/codecov-node)
|
|
46
|
+
to the [modern uploader](https://docs.codecov.com/docs/codecov-uploader)
|
|
47
|
+
|
|
28
48
|
## Usage
|
|
29
49
|
|
|
30
50
|
<!--consumer-badges start -->
|
|
@@ -46,7 +66,7 @@ $ npm install @form8ion/codecov --save
|
|
|
46
66
|
#### Import
|
|
47
67
|
|
|
48
68
|
```javascript
|
|
49
|
-
import {scaffold} from '
|
|
69
|
+
import {scaffold, lift} from '@form8ion/codecov';
|
|
50
70
|
```
|
|
51
71
|
|
|
52
72
|
#### Execute
|
|
@@ -71,6 +91,8 @@ import {scaffold} from './lib/index.cjs';
|
|
|
71
91
|
},
|
|
72
92
|
apiAccessToken: 'XXXXXX'
|
|
73
93
|
});
|
|
94
|
+
|
|
95
|
+
await lift({projectRoot: process.cwd()});
|
|
74
96
|
})();
|
|
75
97
|
```
|
|
76
98
|
|
|
@@ -108,6 +130,17 @@ Since the [Codecov API](https://docs.codecov.com/reference) appears to only
|
|
|
108
130
|
support GitHub at the time of this implementation, GitHub is the only VCS host
|
|
109
131
|
supported by this scaffolder at this time.
|
|
110
132
|
|
|
133
|
+
#### lift
|
|
134
|
+
|
|
135
|
+
Migrates [Codecov](https://codecov.io/) details from legacy conventions to
|
|
136
|
+
modern conventions.
|
|
137
|
+
|
|
138
|
+
Takes a single options object as an argument, containing:
|
|
139
|
+
|
|
140
|
+
##### `projectRoot` __string__ (_required_)
|
|
141
|
+
|
|
142
|
+
path to the root of the project
|
|
143
|
+
|
|
111
144
|
## Contributing
|
|
112
145
|
|
|
113
146
|
<!--contribution-badges start -->
|
package/example.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import stubbedFs from 'mock-fs';
|
|
4
4
|
import nock from 'nock';
|
|
5
5
|
import {StatusCodes} from 'http-status-codes';
|
|
6
|
-
import {scaffold} from './lib/index.cjs';
|
|
6
|
+
import {scaffold, lift} from './lib/index.cjs';
|
|
7
7
|
|
|
8
8
|
// remark-usage-ignore-next 5
|
|
9
|
-
stubbedFs();
|
|
9
|
+
stubbedFs({'package.json': JSON.stringify({scripts: {}})});
|
|
10
10
|
nock.disableNetConnect();
|
|
11
11
|
nock('https://codecov.io/')
|
|
12
12
|
.get('/api/gh/foo/bar')
|
|
@@ -33,4 +33,6 @@ nock('https://codecov.io/')
|
|
|
33
33
|
},
|
|
34
34
|
apiAccessToken: 'XXXXXX'
|
|
35
35
|
});
|
|
36
|
+
|
|
37
|
+
await lift({projectRoot: process.cwd()});
|
|
36
38
|
})();
|
package/lib/index.cjs.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var got = require('got');
|
|
6
|
+
var fs = require('fs');
|
|
6
7
|
|
|
7
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
9
|
|
|
@@ -13,14 +14,9 @@ function ownKeys(object, enumerableOnly) {
|
|
|
13
14
|
|
|
14
15
|
if (Object.getOwnPropertySymbols) {
|
|
15
16
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
keys.push.apply(keys, symbols);
|
|
17
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
18
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
19
|
+
})), keys.push.apply(keys, symbols);
|
|
24
20
|
}
|
|
25
21
|
|
|
26
22
|
return keys;
|
|
@@ -28,19 +24,12 @@ function ownKeys(object, enumerableOnly) {
|
|
|
28
24
|
|
|
29
25
|
function _objectSpread2(target) {
|
|
30
26
|
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
|
-
}
|
|
27
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
28
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
29
|
+
_defineProperty(target, key, source[key]);
|
|
30
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
31
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
32
|
+
});
|
|
44
33
|
}
|
|
45
34
|
|
|
46
35
|
return target;
|
|
@@ -61,6 +50,42 @@ function _defineProperty(obj, key, value) {
|
|
|
61
50
|
return obj;
|
|
62
51
|
}
|
|
63
52
|
|
|
53
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
54
|
+
if (source == null) return {};
|
|
55
|
+
var target = {};
|
|
56
|
+
var sourceKeys = Object.keys(source);
|
|
57
|
+
var key, i;
|
|
58
|
+
|
|
59
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
60
|
+
key = sourceKeys[i];
|
|
61
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
62
|
+
target[key] = source[key];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return target;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function _objectWithoutProperties(source, excluded) {
|
|
69
|
+
if (source == null) return {};
|
|
70
|
+
|
|
71
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
72
|
+
|
|
73
|
+
var key, i;
|
|
74
|
+
|
|
75
|
+
if (Object.getOwnPropertySymbols) {
|
|
76
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
77
|
+
|
|
78
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
79
|
+
key = sourceSymbolKeys[i];
|
|
80
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
81
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
82
|
+
target[key] = source[key];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return target;
|
|
87
|
+
}
|
|
88
|
+
|
|
64
89
|
function coverageShouldBeReportedToCodecov({
|
|
65
90
|
vcs,
|
|
66
91
|
visibility,
|
|
@@ -78,6 +103,37 @@ function scaffold$2() {
|
|
|
78
103
|
};
|
|
79
104
|
}
|
|
80
105
|
|
|
106
|
+
const _excluded = ["scripts"],
|
|
107
|
+
_excluded2 = ["coverage:report"];
|
|
108
|
+
async function liftReporting ({
|
|
109
|
+
projectRoot
|
|
110
|
+
}) {
|
|
111
|
+
const pathToPackageJson = `${projectRoot}/package.json`;
|
|
112
|
+
const existingPackageContents = await fs.promises.readFile(pathToPackageJson, 'utf-8');
|
|
113
|
+
|
|
114
|
+
const _JSON$parse = JSON.parse(existingPackageContents),
|
|
115
|
+
{
|
|
116
|
+
scripts
|
|
117
|
+
} = _JSON$parse,
|
|
118
|
+
otherTopLevelProperties = _objectWithoutProperties(_JSON$parse, _excluded);
|
|
119
|
+
|
|
120
|
+
const otherScripts = _objectWithoutProperties(scripts, _excluded2);
|
|
121
|
+
|
|
122
|
+
if (scripts['coverage:report']) {
|
|
123
|
+
await fs.promises.writeFile(pathToPackageJson, JSON.stringify(_objectSpread2(_objectSpread2({}, otherTopLevelProperties), {}, {
|
|
124
|
+
scripts: otherScripts
|
|
125
|
+
})));
|
|
126
|
+
return {
|
|
127
|
+
nextSteps: [{
|
|
128
|
+
summary: 'Configure modern reporting to Codecov on your CI service',
|
|
129
|
+
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.'
|
|
130
|
+
}]
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return {};
|
|
135
|
+
}
|
|
136
|
+
|
|
81
137
|
async function fetchRepositoryDetails ({
|
|
82
138
|
vcs,
|
|
83
139
|
apiAccessToken
|
|
@@ -103,7 +159,7 @@ async function scaffold$1({
|
|
|
103
159
|
badges: {
|
|
104
160
|
status: {
|
|
105
161
|
coverage: {
|
|
106
|
-
img: `https://img.shields.io/codecov/c/${vcs.host}/${vcs.owner}/${vcs.name}
|
|
162
|
+
img: `https://img.shields.io/codecov/c/${vcs.host}/${vcs.owner}/${vcs.name}?logo=codecov${apiAccessToken ? `&token=${(await fetchRepositoryDetails({
|
|
107
163
|
vcs,
|
|
108
164
|
apiAccessToken
|
|
109
165
|
})).image_token}` : ''}`,
|
|
@@ -131,5 +187,14 @@ async function scaffold({
|
|
|
131
187
|
}));
|
|
132
188
|
}
|
|
133
189
|
|
|
190
|
+
function lift({
|
|
191
|
+
projectRoot
|
|
192
|
+
}) {
|
|
193
|
+
return liftReporting({
|
|
194
|
+
projectRoot
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
exports.lift = lift;
|
|
134
199
|
exports.scaffold = scaffold;
|
|
135
200
|
//# 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\nexport default async function ({projectRoot}) {\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 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}) {\n return liftReporting({projectRoot});\n}\n"],"names":["coverageShouldBeReportedToCodecov","vcs","visibility","apiAccessToken","host","scaffold","devDependencies","scripts","projectRoot","pathToPackageJson","existingPackageContents","fs","readFile","JSON","parse","otherTopLevelProperties","otherScripts","writeFile","stringify","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;AAID;;;;ACHc,8BAAgB;AAACC,EAAAA;AAAD,CAAhB,EAA+B;AAC5C,QAAMC,iBAAiB,GAAI,GAAED,WAAY,eAAzC;AAEA,QAAME,uBA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QAAQ,EAAE;AACRC,UAAAA,GAAG,EAAG,oCAAmCjC,GAAG,CAACG,IAAK,IAAGH,GAAG,CAACwB,KAAM,IAAGxB,GAAG,CAACyB,IAAK,gBACzEvB,cAAc,GACT,UAAS,CAAC,MAAMgC,sBAAsB,CAAC;AAAClC,YAAAA,GAAD;AAAME,YAAAA;AAAN,WAAD,CAA7B,EAAsDiC,WAAY,EADlE,GAEV,EACL,EALO;AAMRC,UAAAA,IAAI,EAAG,sBAAqBpC,GAAG,CAACG,IAAK,IAAGH,GAAG,CAACwB,KAAM,IAAGxB,GAAG,CAACyB,IAAK,EANtD;AAORY,UAAAA,IAAI,EAAE;AAPE;AADJ;AADF;AADkD,GAD9D;AAiBD;;AChBM,eAAejC,QAAf,CAAwB;AAACJ,EAAAA,GAAD;AAAMC,EAAAA,UAAN;AAAkBC,EAAAA;AAAlB,CAAxB,EAA2D;AAChE,MAAI,CAACH,iCAAiC,CAAC;AAACC,IAAAA,GAAD;AAAMC,IAAAA,UAAN;AAAkBC,IAAAA;AAAlB,GAAD,CAAtC,EAA2E,OAAO,EAAP;AAE3E,2CACKoC,UAAgB,EADrB,GAEK,MAAMC,UAAa,CAAC;AAACvC,IAAAA,GAAD;AAAME,IAAAA;AAAN,GAAD,CAFxB;AAID;;ACTM,SAASsC,IAAT,CAAc;AAACjC,EAAAA;AAAD,CAAd,EAA6B;AAClC,SAAOkC,aAAa,CAAC;AAAClC,IAAAA;AAAD,GAAD,CAApB;AACD;;;;;"}
|
package/lib/index.es.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import got from 'got';
|
|
2
|
+
import { promises } from 'fs';
|
|
2
3
|
|
|
3
4
|
function ownKeys(object, enumerableOnly) {
|
|
4
5
|
var keys = Object.keys(object);
|
|
5
6
|
|
|
6
7
|
if (Object.getOwnPropertySymbols) {
|
|
7
8
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
keys.push.apply(keys, symbols);
|
|
9
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
10
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
11
|
+
})), keys.push.apply(keys, symbols);
|
|
16
12
|
}
|
|
17
13
|
|
|
18
14
|
return keys;
|
|
@@ -20,19 +16,12 @@ function ownKeys(object, enumerableOnly) {
|
|
|
20
16
|
|
|
21
17
|
function _objectSpread2(target) {
|
|
22
18
|
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
|
-
}
|
|
19
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
20
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
21
|
+
_defineProperty(target, key, source[key]);
|
|
22
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
23
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
24
|
+
});
|
|
36
25
|
}
|
|
37
26
|
|
|
38
27
|
return target;
|
|
@@ -53,6 +42,42 @@ function _defineProperty(obj, key, value) {
|
|
|
53
42
|
return obj;
|
|
54
43
|
}
|
|
55
44
|
|
|
45
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
46
|
+
if (source == null) return {};
|
|
47
|
+
var target = {};
|
|
48
|
+
var sourceKeys = Object.keys(source);
|
|
49
|
+
var key, i;
|
|
50
|
+
|
|
51
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
52
|
+
key = sourceKeys[i];
|
|
53
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
54
|
+
target[key] = source[key];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return target;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function _objectWithoutProperties(source, excluded) {
|
|
61
|
+
if (source == null) return {};
|
|
62
|
+
|
|
63
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
64
|
+
|
|
65
|
+
var key, i;
|
|
66
|
+
|
|
67
|
+
if (Object.getOwnPropertySymbols) {
|
|
68
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
69
|
+
|
|
70
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
71
|
+
key = sourceSymbolKeys[i];
|
|
72
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
73
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
74
|
+
target[key] = source[key];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return target;
|
|
79
|
+
}
|
|
80
|
+
|
|
56
81
|
function coverageShouldBeReportedToCodecov({
|
|
57
82
|
vcs,
|
|
58
83
|
visibility,
|
|
@@ -70,6 +95,37 @@ function scaffold$2() {
|
|
|
70
95
|
};
|
|
71
96
|
}
|
|
72
97
|
|
|
98
|
+
const _excluded = ["scripts"],
|
|
99
|
+
_excluded2 = ["coverage:report"];
|
|
100
|
+
async function liftReporting ({
|
|
101
|
+
projectRoot
|
|
102
|
+
}) {
|
|
103
|
+
const pathToPackageJson = `${projectRoot}/package.json`;
|
|
104
|
+
const existingPackageContents = await promises.readFile(pathToPackageJson, 'utf-8');
|
|
105
|
+
|
|
106
|
+
const _JSON$parse = JSON.parse(existingPackageContents),
|
|
107
|
+
{
|
|
108
|
+
scripts
|
|
109
|
+
} = _JSON$parse,
|
|
110
|
+
otherTopLevelProperties = _objectWithoutProperties(_JSON$parse, _excluded);
|
|
111
|
+
|
|
112
|
+
const otherScripts = _objectWithoutProperties(scripts, _excluded2);
|
|
113
|
+
|
|
114
|
+
if (scripts['coverage:report']) {
|
|
115
|
+
await promises.writeFile(pathToPackageJson, JSON.stringify(_objectSpread2(_objectSpread2({}, otherTopLevelProperties), {}, {
|
|
116
|
+
scripts: otherScripts
|
|
117
|
+
})));
|
|
118
|
+
return {
|
|
119
|
+
nextSteps: [{
|
|
120
|
+
summary: 'Configure modern reporting to Codecov on your CI service',
|
|
121
|
+
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.'
|
|
122
|
+
}]
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
128
|
+
|
|
73
129
|
async function fetchRepositoryDetails ({
|
|
74
130
|
vcs,
|
|
75
131
|
apiAccessToken
|
|
@@ -95,7 +151,7 @@ async function scaffold$1({
|
|
|
95
151
|
badges: {
|
|
96
152
|
status: {
|
|
97
153
|
coverage: {
|
|
98
|
-
img: `https://img.shields.io/codecov/c/${vcs.host}/${vcs.owner}/${vcs.name}
|
|
154
|
+
img: `https://img.shields.io/codecov/c/${vcs.host}/${vcs.owner}/${vcs.name}?logo=codecov${apiAccessToken ? `&token=${(await fetchRepositoryDetails({
|
|
99
155
|
vcs,
|
|
100
156
|
apiAccessToken
|
|
101
157
|
})).image_token}` : ''}`,
|
|
@@ -123,5 +179,13 @@ async function scaffold({
|
|
|
123
179
|
}));
|
|
124
180
|
}
|
|
125
181
|
|
|
126
|
-
|
|
182
|
+
function lift({
|
|
183
|
+
projectRoot
|
|
184
|
+
}) {
|
|
185
|
+
return liftReporting({
|
|
186
|
+
projectRoot
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export { lift, scaffold };
|
|
127
191
|
//# 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\nexport default async function ({projectRoot}) {\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 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}) {\n return liftReporting({projectRoot});\n}\n"],"names":["coverageShouldBeReportedToCodecov","vcs","visibility","apiAccessToken","host","scaffold","devDependencies","scripts","projectRoot","pathToPackageJson","existingPackageContents","fs","readFile","JSON","parse","otherTopLevelProperties","otherScripts","writeFile","stringify","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;A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d,EAA6B;AAClC,SAAOkC,aAAa,CAAC;AAAClC,IAAAA;AAAD,GAAD,CAApB;AACD;;;;"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@form8ion/codecov",
|
|
3
3
|
"description": "code coverage service plugin for form8ion",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.4.0",
|
|
6
6
|
"files": [
|
|
7
7
|
"example.js",
|
|
8
8
|
"lib/"
|
|
@@ -48,16 +48,17 @@
|
|
|
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/remark-lint-preset": "2.1.
|
|
57
|
+
"@form8ion/eslint-config-mocha": "1.2.17",
|
|
58
|
+
"@form8ion/remark-lint-preset": "2.1.7",
|
|
59
59
|
"@rollup/plugin-babel": "5.3.0",
|
|
60
|
-
"@
|
|
60
|
+
"@rollup/plugin-node-resolve": "13.1.1",
|
|
61
|
+
"@travi/any": "2.0.19",
|
|
61
62
|
"ban-sensitive-files": "1.9.16",
|
|
62
63
|
"c8": "7.10.0",
|
|
63
64
|
"chai": "4.3.4",
|
|
@@ -77,7 +78,7 @@
|
|
|
77
78
|
"remark-toc": "8.0.1",
|
|
78
79
|
"remark-usage": "10.0.1",
|
|
79
80
|
"rimraf": "3.0.2",
|
|
80
|
-
"rollup": "2.
|
|
81
|
+
"rollup": "2.61.1",
|
|
81
82
|
"rollup-plugin-auto-external": "2.0.0",
|
|
82
83
|
"sinon": "12.0.1"
|
|
83
84
|
},
|