@form8ion/codecov 4.0.1 → 5.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -55
- package/example.js +5 -14
- package/lib/index.cjs.js +74 -197
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.es.js +73 -189
- package/lib/index.es.js.map +1 -1
- package/package.json +30 -27
package/README.md
CHANGED
|
@@ -6,13 +6,13 @@ code coverage service plugin for form8ion
|
|
|
6
6
|
|
|
7
7
|
[![Node CI Workflow Status][github-actions-ci-badge]][github-actions-ci-link]
|
|
8
8
|
[![Codecov][coverage-badge]][coverage-link]
|
|
9
|
+
![SLSA Level 2][slsa-badge]
|
|
9
10
|
|
|
10
11
|
<!--status-badges end -->
|
|
11
12
|
|
|
12
13
|
## Table of Contents
|
|
13
14
|
|
|
14
15
|
* [Features](#features)
|
|
15
|
-
* [Scaffold](#scaffold)
|
|
16
16
|
* [Lift](#lift)
|
|
17
17
|
* [Usage](#usage)
|
|
18
18
|
* [Installation](#installation)
|
|
@@ -20,29 +20,22 @@ code coverage service plugin for form8ion
|
|
|
20
20
|
* [Import](#import)
|
|
21
21
|
* [Execute](#execute)
|
|
22
22
|
* [API](#api)
|
|
23
|
-
* [scaffold](#scaffold
|
|
24
|
-
* [`vcs` __object__ (_required_)](#vcs-object-required)
|
|
25
|
-
* [`visibility` __string__ (_required_)](#visibility-string-required)
|
|
26
|
-
* [`apiAccessToken` __string__ (_optional_)](#apiaccesstoken-string-optional)
|
|
23
|
+
* [scaffold](#scaffold)
|
|
27
24
|
* [lift](#lift-1)
|
|
28
25
|
* [`projectRoot` __string__ (_required_)](#projectroot-string-required)
|
|
29
26
|
* [`packageManager` __string__ (_required_)](#packagemanager-string-required)
|
|
27
|
+
* [`vcs` __object__ (_required_)](#vcs-object-required)
|
|
30
28
|
* [Contributing](#contributing)
|
|
31
29
|
* [Dependencies](#dependencies)
|
|
32
30
|
* [Verification](#verification)
|
|
33
31
|
|
|
34
32
|
## Features
|
|
35
33
|
|
|
36
|
-
###
|
|
34
|
+
### Lift
|
|
37
35
|
|
|
38
36
|
* Define a coverage status badge to communicate current coverage details
|
|
39
37
|
* Link from the status badge to further details on the [Codecov](https://codecov.io/)
|
|
40
38
|
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
39
|
* Migrate from the [legacy node uploader](https://github.com/codecov/codecov-node)
|
|
47
40
|
to the [modern uploader](https://docs.codecov.com/docs/codecov-uploader)
|
|
48
41
|
* Currently supports the following CI Providers:
|
|
@@ -78,26 +71,17 @@ import {scaffold, lift} from '@form8ion/codecov';
|
|
|
78
71
|
|
|
79
72
|
```javascript
|
|
80
73
|
(async () => {
|
|
81
|
-
await scaffold(
|
|
82
|
-
visibility: 'Public',
|
|
83
|
-
vcs: {
|
|
84
|
-
host: 'github',
|
|
85
|
-
owner: 'foo',
|
|
86
|
-
name: 'bar'
|
|
87
|
-
}
|
|
88
|
-
});
|
|
74
|
+
await scaffold();
|
|
89
75
|
|
|
90
|
-
await
|
|
91
|
-
|
|
76
|
+
await lift({
|
|
77
|
+
projectRoot: process.cwd(),
|
|
78
|
+
packageManager: packageManagers.NPM,
|
|
92
79
|
vcs: {
|
|
93
80
|
host: 'github',
|
|
94
81
|
owner: 'foo',
|
|
95
82
|
name: 'bar'
|
|
96
|
-
}
|
|
97
|
-
apiAccessToken: 'XXXXXX'
|
|
83
|
+
}
|
|
98
84
|
});
|
|
99
|
-
|
|
100
|
-
await lift({projectRoot: process.cwd(), packageManager: packageManagers.NPM});
|
|
101
85
|
})();
|
|
102
86
|
```
|
|
103
87
|
|
|
@@ -105,35 +89,8 @@ import {scaffold, lift} from '@form8ion/codecov';
|
|
|
105
89
|
|
|
106
90
|
#### scaffold
|
|
107
91
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Takes a single options object as an argument, containing:
|
|
112
|
-
|
|
113
|
-
##### `vcs` __object__ (_required_)
|
|
114
|
-
|
|
115
|
-
* `host` __string__ (_required_)
|
|
116
|
-
VCS hosting service
|
|
117
|
-
* `owner` __string__ (_required_)
|
|
118
|
-
account name on the host service for the repository
|
|
119
|
-
* `name` __string__ (_required_)
|
|
120
|
-
repository name
|
|
121
|
-
|
|
122
|
-
##### `visibility` __string__ (_required_)
|
|
123
|
-
|
|
124
|
-
Visibility of the project (`Public` or `Private`).
|
|
125
|
-
Unless [`apiAccessToken`](#apiaccesstoken-string-optional) is provided, Codecov
|
|
126
|
-
details will only be scaffolded for public projects.
|
|
127
|
-
|
|
128
|
-
##### `apiAccessToken` __string__ (_optional_)
|
|
129
|
-
|
|
130
|
-
Personal Access Token for accessing the [Codecov API](https://docs.codecov.com/reference).
|
|
131
|
-
Providing an access token enables [fetching the `image_token` for the repository](https://docs.codecov.com/reference/repositories#get-a-single-repository)
|
|
132
|
-
so that the coverage badge can display the proper coverage state of the
|
|
133
|
-
project when the project is not public.
|
|
134
|
-
Since the [Codecov API](https://docs.codecov.com/reference) appears to only
|
|
135
|
-
support GitHub at the time of this implementation, GitHub is the only VCS host
|
|
136
|
-
supported by this scaffolder at this time.
|
|
92
|
+
The scaffolder of this plugin is currently a no-op since the work is all done
|
|
93
|
+
as part of the lifting process
|
|
137
94
|
|
|
138
95
|
#### lift
|
|
139
96
|
|
|
@@ -151,6 +108,15 @@ path to the root of the project
|
|
|
151
108
|
chosen [package manager](https://github.com/form8ion/javascript-core#packagemanagers)
|
|
152
109
|
to be used for the project
|
|
153
110
|
|
|
111
|
+
##### `vcs` __object__ (_required_)
|
|
112
|
+
|
|
113
|
+
* `host` __string__ (_required_)
|
|
114
|
+
VCS hosting service
|
|
115
|
+
* `owner` __string__ (_required_)
|
|
116
|
+
account name on the host service for the repository
|
|
117
|
+
* `name` __string__ (_required_)
|
|
118
|
+
repository name
|
|
119
|
+
|
|
154
120
|
## Contributing
|
|
155
121
|
|
|
156
122
|
<!--contribution-badges start -->
|
|
@@ -190,7 +156,7 @@ $ npm test
|
|
|
190
156
|
|
|
191
157
|
[semantic-release-link]: https://github.com/semantic-release/semantic-release
|
|
192
158
|
|
|
193
|
-
[semantic-release-badge]: https://img.shields.io/badge
|
|
159
|
+
[semantic-release-badge]: https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release
|
|
194
160
|
|
|
195
161
|
[renovate-link]: https://renovatebot.com
|
|
196
162
|
|
|
@@ -217,3 +183,5 @@ $ npm test
|
|
|
217
183
|
[runkit-badge]: https://badge.runkitcdn.com/@form8ion/codecov.svg
|
|
218
184
|
|
|
219
185
|
[node-badge]: https://img.shields.io/node/v/@form8ion/codecov?logo=node.js
|
|
186
|
+
|
|
187
|
+
[slsa-badge]: https://slsa.dev/images/gh-badge-level2.svg
|
package/example.js
CHANGED
|
@@ -16,24 +16,15 @@ nock('https://codecov.io/')
|
|
|
16
16
|
// #### Execute
|
|
17
17
|
|
|
18
18
|
(async () => {
|
|
19
|
-
await scaffold(
|
|
20
|
-
visibility: 'Public',
|
|
21
|
-
vcs: {
|
|
22
|
-
host: 'github',
|
|
23
|
-
owner: 'foo',
|
|
24
|
-
name: 'bar'
|
|
25
|
-
}
|
|
26
|
-
});
|
|
19
|
+
await scaffold();
|
|
27
20
|
|
|
28
|
-
await
|
|
29
|
-
|
|
21
|
+
await lift({
|
|
22
|
+
projectRoot: process.cwd(),
|
|
23
|
+
packageManager: packageManagers.NPM,
|
|
30
24
|
vcs: {
|
|
31
25
|
host: 'github',
|
|
32
26
|
owner: 'foo',
|
|
33
27
|
name: 'bar'
|
|
34
|
-
}
|
|
35
|
-
apiAccessToken: 'XXXXXX'
|
|
28
|
+
}
|
|
36
29
|
});
|
|
37
|
-
|
|
38
|
-
await lift({projectRoot: process.cwd(), packageManager: packageManagers.NPM});
|
|
39
30
|
})();
|
package/lib/index.cjs.js
CHANGED
|
@@ -1,243 +1,120 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var got = require('got');
|
|
3
|
+
var deepmerge = require('deepmerge');
|
|
6
4
|
var fs = require('fs');
|
|
7
5
|
var execa = require('execa');
|
|
8
6
|
var jsYaml = require('js-yaml');
|
|
9
7
|
var core = require('@form8ion/core');
|
|
8
|
+
var got = require('got');
|
|
10
9
|
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
var got__default = /*#__PURE__*/_interopDefaultLegacy(got);
|
|
14
|
-
var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) {
|
|
17
|
-
var keys = Object.keys(object);
|
|
18
|
-
|
|
19
|
-
if (Object.getOwnPropertySymbols) {
|
|
20
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
21
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
22
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
23
|
-
})), keys.push.apply(keys, symbols);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return keys;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function _objectSpread2(target) {
|
|
30
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
31
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
32
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
33
|
-
_defineProperty(target, key, source[key]);
|
|
34
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
35
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return target;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function _defineProperty(obj, key, value) {
|
|
43
|
-
if (key in obj) {
|
|
44
|
-
Object.defineProperty(obj, key, {
|
|
45
|
-
value: value,
|
|
46
|
-
enumerable: true,
|
|
47
|
-
configurable: true,
|
|
48
|
-
writable: true
|
|
49
|
-
});
|
|
50
|
-
} else {
|
|
51
|
-
obj[key] = value;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return obj;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
58
|
-
if (source == null) return {};
|
|
59
|
-
var target = {};
|
|
60
|
-
var sourceKeys = Object.keys(source);
|
|
61
|
-
var key, i;
|
|
62
|
-
|
|
63
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
64
|
-
key = sourceKeys[i];
|
|
65
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
66
|
-
target[key] = source[key];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return target;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function _objectWithoutProperties(source, excluded) {
|
|
73
|
-
if (source == null) return {};
|
|
74
|
-
|
|
75
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
76
|
-
|
|
77
|
-
var key, i;
|
|
78
|
-
|
|
79
|
-
if (Object.getOwnPropertySymbols) {
|
|
80
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
81
|
-
|
|
82
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
83
|
-
key = sourceSymbolKeys[i];
|
|
84
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
85
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
86
|
-
target[key] = source[key];
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return target;
|
|
10
|
+
async function scaffold$1() {
|
|
11
|
+
return {};
|
|
91
12
|
}
|
|
92
13
|
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return !!('Public' === visibility || apiAccessToken && 'github' === vcs.host);
|
|
99
|
-
}
|
|
14
|
+
async function fetchRepositoryDetails ({vcs, apiAccessToken}) {
|
|
15
|
+
const {body: {repo}} = await got(
|
|
16
|
+
`https://codecov.io/api/gh/${vcs.owner}/${vcs.name}`,
|
|
17
|
+
{headers: {Authorization: apiAccessToken}, responseType: 'json'}
|
|
18
|
+
);
|
|
100
19
|
|
|
101
|
-
async function fetchRepositoryDetails ({
|
|
102
|
-
vcs,
|
|
103
|
-
apiAccessToken
|
|
104
|
-
}) {
|
|
105
|
-
const {
|
|
106
|
-
body: {
|
|
107
|
-
repo
|
|
108
|
-
}
|
|
109
|
-
} = await got__default["default"](`https://codecov.io/api/gh/${vcs.owner}/${vcs.name}`, {
|
|
110
|
-
headers: {
|
|
111
|
-
Authorization: apiAccessToken
|
|
112
|
-
},
|
|
113
|
-
responseType: 'json'
|
|
114
|
-
});
|
|
115
20
|
return repo;
|
|
116
21
|
}
|
|
117
22
|
|
|
118
|
-
async function scaffold
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
23
|
+
async function scaffold({vcs, apiAccessToken}) {
|
|
24
|
+
return {
|
|
25
|
+
...['github', 'gitlab', 'bitbucket'].includes(vcs?.host) && {
|
|
26
|
+
badges: {
|
|
27
|
+
status: {
|
|
28
|
+
coverage: {
|
|
29
|
+
img: `https://img.shields.io/codecov/c/${vcs.host}/${vcs.owner}/${vcs.name}?logo=codecov${
|
|
30
|
+
apiAccessToken
|
|
31
|
+
? `&token=${(await fetchRepositoryDetails({vcs, apiAccessToken})).image_token}`
|
|
32
|
+
: ''
|
|
33
|
+
}`,
|
|
34
|
+
link: `https://codecov.io/${vcs.host}/${vcs.owner}/${vcs.name}`,
|
|
35
|
+
text: 'Codecov'
|
|
36
|
+
}
|
|
132
37
|
}
|
|
133
38
|
}
|
|
134
39
|
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async function scaffold({
|
|
139
|
-
vcs,
|
|
140
|
-
visibility,
|
|
141
|
-
apiAccessToken
|
|
142
|
-
}) {
|
|
143
|
-
if (!coverageShouldBeReportedToCodecov({
|
|
144
|
-
vcs,
|
|
145
|
-
visibility,
|
|
146
|
-
apiAccessToken
|
|
147
|
-
})) return {};
|
|
148
|
-
return _objectSpread2({}, await scaffold$1({
|
|
149
|
-
vcs,
|
|
150
|
-
apiAccessToken
|
|
151
|
-
}));
|
|
40
|
+
};
|
|
152
41
|
}
|
|
153
42
|
|
|
154
43
|
function getPathToWorkflowFile(projectRoot) {
|
|
155
44
|
return `${projectRoot}/.github/workflows/node-ci.yml`;
|
|
156
45
|
}
|
|
157
46
|
|
|
158
|
-
function test({
|
|
159
|
-
projectRoot
|
|
160
|
-
}) {
|
|
47
|
+
function test({projectRoot}) {
|
|
161
48
|
return core.fileExists(getPathToWorkflowFile(projectRoot));
|
|
162
49
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}) {
|
|
50
|
+
|
|
51
|
+
async function lift$1({projectRoot}) {
|
|
166
52
|
const pathToWorkflowFile = getPathToWorkflowFile(projectRoot);
|
|
53
|
+
|
|
167
54
|
const workflowDetails = jsYaml.load(await fs.promises.readFile(pathToWorkflowFile, 'utf-8'));
|
|
168
|
-
const {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
await fs.promises.writeFile(pathToWorkflowFile, jsYaml.dump(_objectSpread2(_objectSpread2({}, workflowDetails), {}, {
|
|
185
|
-
jobs: _objectSpread2(_objectSpread2({}, workflowDetails.jobs), {}, {
|
|
186
|
-
verify: _objectSpread2(_objectSpread2({}, workflowDetails.jobs.verify), {}, {
|
|
187
|
-
steps: [...stepsWithLegacyReportingRemoved, {
|
|
188
|
-
uses: 'codecov/codecov-action@v3'
|
|
189
|
-
}]
|
|
190
|
-
})
|
|
55
|
+
const {jobs: {verify: {steps}}} = workflowDetails;
|
|
56
|
+
|
|
57
|
+
if (!steps.find(step => step.uses?.startsWith('codecov/codecov-action'))) {
|
|
58
|
+
const stepsWithLegacyReportingRemoved = steps.filter(({run}) => 'npm run coverage:report' !== run);
|
|
59
|
+
|
|
60
|
+
await fs.promises.writeFile(
|
|
61
|
+
pathToWorkflowFile,
|
|
62
|
+
jsYaml.dump({
|
|
63
|
+
...workflowDetails,
|
|
64
|
+
jobs: {
|
|
65
|
+
...workflowDetails.jobs,
|
|
66
|
+
verify: {
|
|
67
|
+
...workflowDetails.jobs.verify,
|
|
68
|
+
steps: [...stepsWithLegacyReportingRemoved, {uses: 'codecov/codecov-action@v3'}]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
191
71
|
})
|
|
192
|
-
|
|
72
|
+
);
|
|
193
73
|
}
|
|
194
74
|
}
|
|
195
75
|
|
|
196
|
-
|
|
197
|
-
async function liftReporting ({
|
|
198
|
-
projectRoot,
|
|
199
|
-
packageManager
|
|
200
|
-
}) {
|
|
76
|
+
async function liftReporting ({projectRoot, packageManager}) {
|
|
201
77
|
const pathToPackageJson = `${projectRoot}/package.json`;
|
|
202
|
-
const [ciProviderCanBeLifted, existingPackageContents] = await Promise.all([test({
|
|
203
|
-
projectRoot
|
|
204
|
-
}), fs.promises.readFile(pathToPackageJson, 'utf-8')]);
|
|
205
|
-
const parsedPackageContents = JSON.parse(existingPackageContents);
|
|
206
|
-
const {
|
|
207
|
-
scripts
|
|
208
|
-
} = parsedPackageContents;
|
|
209
78
|
|
|
210
|
-
const
|
|
79
|
+
const [ciProviderCanBeLifted, existingPackageContents] = await Promise.all([
|
|
80
|
+
test({projectRoot}),
|
|
81
|
+
fs.promises.readFile(pathToPackageJson, 'utf-8')
|
|
82
|
+
]);
|
|
83
|
+
const parsedPackageContents = JSON.parse(existingPackageContents);
|
|
84
|
+
const {scripts} = parsedPackageContents;
|
|
85
|
+
const {'coverage:report': reportCoverageScript, ...otherScripts} = scripts;
|
|
211
86
|
|
|
212
|
-
if (ciProviderCanBeLifted) await lift$1({
|
|
213
|
-
projectRoot
|
|
214
|
-
});
|
|
87
|
+
if (ciProviderCanBeLifted) await lift$1({projectRoot});
|
|
215
88
|
|
|
216
89
|
if (scripts['coverage:report']) {
|
|
217
90
|
parsedPackageContents.scripts = otherScripts;
|
|
218
91
|
await fs.promises.writeFile(pathToPackageJson, JSON.stringify(parsedPackageContents));
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
92
|
+
|
|
93
|
+
await execa(packageManager, ['remove', 'codecov']);
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
...!ciProviderCanBeLifted && {
|
|
97
|
+
nextSteps: [{
|
|
98
|
+
summary: 'Configure modern reporting to Codecov on your CI service',
|
|
99
|
+
description: 'Configure the [Codecov Uploader](https://docs.codecov.com/docs/codecov-uploader) appropriately'
|
|
100
|
+
+ ' for your CI Provider. If available for your provider, prefer one of the dedicated wrappers.'
|
|
101
|
+
}]
|
|
102
|
+
}
|
|
103
|
+
};
|
|
226
104
|
}
|
|
227
105
|
|
|
228
106
|
return {};
|
|
229
107
|
}
|
|
230
108
|
|
|
231
|
-
function lift({
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
});
|
|
109
|
+
async function lift({projectRoot, packageManager, vcs}) {
|
|
110
|
+
const [reportingResults, badgeResults] = await Promise.all([
|
|
111
|
+
liftReporting({projectRoot, packageManager}),
|
|
112
|
+
scaffold({vcs})
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
return deepmerge.all([reportingResults, badgeResults]);
|
|
239
116
|
}
|
|
240
117
|
|
|
241
118
|
exports.lift = lift;
|
|
242
|
-
exports.scaffold = scaffold;
|
|
119
|
+
exports.scaffold = scaffold$1;
|
|
243
120
|
//# sourceMappingURL=index.cjs.js.map
|
package/lib/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/scaffolder.js","../src/badge/repository-details-fetcher.js","../src/badge/scaffolder.js","../src/reporter/ci-providers/github-workflows/lifter.js","../src/reporter/lifter.js","../src/lifter.js"],"sourcesContent":["export async function scaffold() {\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 {promises as fs} from 'fs';\nimport {dump, load} from 'js-yaml';\nimport {fileExists} from '@form8ion/core';\n\nfunction getPathToWorkflowFile(projectRoot) {\n return `${projectRoot}/.github/workflows/node-ci.yml`;\n}\n\nexport function test({projectRoot}) {\n return fileExists(getPathToWorkflowFile(projectRoot));\n}\n\nexport async function lift({projectRoot}) {\n const pathToWorkflowFile = getPathToWorkflowFile(projectRoot);\n\n const workflowDetails = load(await fs.readFile(pathToWorkflowFile, 'utf-8'));\n const {jobs: {verify: {steps}}} = workflowDetails;\n\n if (!steps.find(step => step.uses?.startsWith('codecov/codecov-action'))) {\n const stepsWithLegacyReportingRemoved = steps.filter(({run}) => 'npm run coverage:report' !== run);\n\n await fs.writeFile(\n pathToWorkflowFile,\n dump({\n ...workflowDetails,\n jobs: {\n ...workflowDetails.jobs,\n verify: {\n ...workflowDetails.jobs.verify,\n steps: [...stepsWithLegacyReportingRemoved, {uses: 'codecov/codecov-action@v3'}]\n }\n }\n })\n );\n }\n}\n","import {promises as fs} from 'fs';\n\nimport execa from '../../thirdparty-wrappers/execa';\nimport {lift as liftCiProvider, test as ciProviderIsLiftable} from './ci-providers';\n\nexport default async function ({projectRoot, packageManager}) {\n const pathToPackageJson = `${projectRoot}/package.json`;\n\n const [ciProviderCanBeLifted, existingPackageContents] = await Promise.all([\n ciProviderIsLiftable({projectRoot}),\n fs.readFile(pathToPackageJson, 'utf-8')\n ]);\n const parsedPackageContents = JSON.parse(existingPackageContents);\n const {scripts} = parsedPackageContents;\n const {'coverage:report': reportCoverageScript, ...otherScripts} = scripts;\n\n if (ciProviderCanBeLifted) await liftCiProvider({projectRoot});\n\n if (scripts['coverage:report']) {\n parsedPackageContents.scripts = otherScripts;\n await fs.writeFile(pathToPackageJson, JSON.stringify(parsedPackageContents));\n\n await execa(packageManager, ['remove', 'codecov']);\n\n return {\n ...!ciProviderCanBeLifted && {\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\n return {};\n}\n","import deepmerge from 'deepmerge';\n\nimport {scaffold as scaffoldBadge} from './badge';\nimport {lift as liftReporting} from './reporter';\n\nexport async function lift({projectRoot, packageManager, vcs}) {\n const [reportingResults, badgeResults] = await Promise.all([\n liftReporting({projectRoot, packageManager}),\n scaffoldBadge({vcs})\n ]);\n\n return deepmerge.all([reportingResults, badgeResults]);\n}\n"],"names":["scaffold","fileExists","lift","load","fs","dump","ciProviderIsLiftable","liftCiProvider","scaffoldBadge"],"mappings":";;;;;;;;;AAAO,eAAeA,UAAQ,GAAG;AACjC,EAAE,OAAO,EAAE,CAAC;AACZ;;ACAe,qCAAc,EAAE,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE;AACtD,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG;AAClC,IAAI,CAAC,0BAA0B,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;AACxD,IAAI,CAAC,OAAO,EAAE,CAAC,aAAa,EAAE,cAAc,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC;AACpE,GAAG,CAAC;AACJ;AACA,EAAE,OAAO,IAAI,CAAC;AACd;;ACPO,eAAe,QAAQ,CAAC,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE;AACtD,EAAE,OAAO;AACT,IAAI,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI;AAChE,MAAM,MAAM,EAAE;AACd,QAAQ,MAAM,EAAE;AAChB,UAAU,QAAQ,EAAE;AACpB,YAAY,GAAG,EAAE,CAAC,iCAAiC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,aAAa;AACpG,cAAc,cAAc;AAC5B,kBAAkB,CAAC,OAAO,EAAE,CAAC,MAAM,sBAAsB,CAAC,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;AAC/F,kBAAkB,EAAE;AACpB,aAAa,CAAC;AACd,YAAY,IAAI,EAAE,CAAC,mBAAmB,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,EA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ACnC,QAAQ,SAAS,EAAE,CAAC;AACpB,UAAU,OAAO,EAAE,0DAA0D;AAC7E,UAAU,WAAW,EAAE,gGAAgG;AACvH,cAAc,8FAA8F;AAC5G,SAAS,CAAC;AACV,OAAO;AACP,KAAK,CAAC;AACN,GAAG;AACH;AACA,EAAE,OAAO,EAAE,CAAC;AACZ;;AC/BO,eAAe,IAAI,CAAC,CAAC,WAAW,EAAE,cAAc,EAAE,GAAG,CAAC,EAAE;AAC/D,EAAE,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;AAC7D,IAAI,aAAa,CAAC,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;AAChD,IAAII,QAAa,CAAC,CAAC,GAAG,CAAC,CAAC;AACxB,GAAG,CAAC,CAAC;AACL;AACA,EAAE,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC,CAAC;AACzD;;;;;"}
|
package/lib/index.es.js
CHANGED
|
@@ -1,233 +1,117 @@
|
|
|
1
|
-
import
|
|
1
|
+
import deepmerge from 'deepmerge';
|
|
2
2
|
import { promises } from 'fs';
|
|
3
3
|
import execa from 'execa';
|
|
4
4
|
import { load, dump } from 'js-yaml';
|
|
5
5
|
import { fileExists } from '@form8ion/core';
|
|
6
|
+
import got from 'got';
|
|
6
7
|
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (Object.getOwnPropertySymbols) {
|
|
11
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
12
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
13
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
14
|
-
})), keys.push.apply(keys, symbols);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return keys;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _objectSpread2(target) {
|
|
21
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
22
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
23
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
24
|
-
_defineProperty(target, key, source[key]);
|
|
25
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
26
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return target;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function _defineProperty(obj, key, value) {
|
|
34
|
-
if (key in obj) {
|
|
35
|
-
Object.defineProperty(obj, key, {
|
|
36
|
-
value: value,
|
|
37
|
-
enumerable: true,
|
|
38
|
-
configurable: true,
|
|
39
|
-
writable: true
|
|
40
|
-
});
|
|
41
|
-
} else {
|
|
42
|
-
obj[key] = value;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return obj;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
49
|
-
if (source == null) return {};
|
|
50
|
-
var target = {};
|
|
51
|
-
var sourceKeys = Object.keys(source);
|
|
52
|
-
var key, i;
|
|
53
|
-
|
|
54
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
55
|
-
key = sourceKeys[i];
|
|
56
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
57
|
-
target[key] = source[key];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return target;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function _objectWithoutProperties(source, excluded) {
|
|
64
|
-
if (source == null) return {};
|
|
65
|
-
|
|
66
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
67
|
-
|
|
68
|
-
var key, i;
|
|
69
|
-
|
|
70
|
-
if (Object.getOwnPropertySymbols) {
|
|
71
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
72
|
-
|
|
73
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
74
|
-
key = sourceSymbolKeys[i];
|
|
75
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
76
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
77
|
-
target[key] = source[key];
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return target;
|
|
8
|
+
async function scaffold$1() {
|
|
9
|
+
return {};
|
|
82
10
|
}
|
|
83
11
|
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return !!('Public' === visibility || apiAccessToken && 'github' === vcs.host);
|
|
90
|
-
}
|
|
12
|
+
async function fetchRepositoryDetails ({vcs, apiAccessToken}) {
|
|
13
|
+
const {body: {repo}} = await got(
|
|
14
|
+
`https://codecov.io/api/gh/${vcs.owner}/${vcs.name}`,
|
|
15
|
+
{headers: {Authorization: apiAccessToken}, responseType: 'json'}
|
|
16
|
+
);
|
|
91
17
|
|
|
92
|
-
async function fetchRepositoryDetails ({
|
|
93
|
-
vcs,
|
|
94
|
-
apiAccessToken
|
|
95
|
-
}) {
|
|
96
|
-
const {
|
|
97
|
-
body: {
|
|
98
|
-
repo
|
|
99
|
-
}
|
|
100
|
-
} = await got(`https://codecov.io/api/gh/${vcs.owner}/${vcs.name}`, {
|
|
101
|
-
headers: {
|
|
102
|
-
Authorization: apiAccessToken
|
|
103
|
-
},
|
|
104
|
-
responseType: 'json'
|
|
105
|
-
});
|
|
106
18
|
return repo;
|
|
107
19
|
}
|
|
108
20
|
|
|
109
|
-
async function scaffold
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
21
|
+
async function scaffold({vcs, apiAccessToken}) {
|
|
22
|
+
return {
|
|
23
|
+
...['github', 'gitlab', 'bitbucket'].includes(vcs?.host) && {
|
|
24
|
+
badges: {
|
|
25
|
+
status: {
|
|
26
|
+
coverage: {
|
|
27
|
+
img: `https://img.shields.io/codecov/c/${vcs.host}/${vcs.owner}/${vcs.name}?logo=codecov${
|
|
28
|
+
apiAccessToken
|
|
29
|
+
? `&token=${(await fetchRepositoryDetails({vcs, apiAccessToken})).image_token}`
|
|
30
|
+
: ''
|
|
31
|
+
}`,
|
|
32
|
+
link: `https://codecov.io/${vcs.host}/${vcs.owner}/${vcs.name}`,
|
|
33
|
+
text: 'Codecov'
|
|
34
|
+
}
|
|
123
35
|
}
|
|
124
36
|
}
|
|
125
37
|
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
async function scaffold({
|
|
130
|
-
vcs,
|
|
131
|
-
visibility,
|
|
132
|
-
apiAccessToken
|
|
133
|
-
}) {
|
|
134
|
-
if (!coverageShouldBeReportedToCodecov({
|
|
135
|
-
vcs,
|
|
136
|
-
visibility,
|
|
137
|
-
apiAccessToken
|
|
138
|
-
})) return {};
|
|
139
|
-
return _objectSpread2({}, await scaffold$1({
|
|
140
|
-
vcs,
|
|
141
|
-
apiAccessToken
|
|
142
|
-
}));
|
|
38
|
+
};
|
|
143
39
|
}
|
|
144
40
|
|
|
145
41
|
function getPathToWorkflowFile(projectRoot) {
|
|
146
42
|
return `${projectRoot}/.github/workflows/node-ci.yml`;
|
|
147
43
|
}
|
|
148
44
|
|
|
149
|
-
function test({
|
|
150
|
-
projectRoot
|
|
151
|
-
}) {
|
|
45
|
+
function test({projectRoot}) {
|
|
152
46
|
return fileExists(getPathToWorkflowFile(projectRoot));
|
|
153
47
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}) {
|
|
48
|
+
|
|
49
|
+
async function lift$1({projectRoot}) {
|
|
157
50
|
const pathToWorkflowFile = getPathToWorkflowFile(projectRoot);
|
|
51
|
+
|
|
158
52
|
const workflowDetails = load(await promises.readFile(pathToWorkflowFile, 'utf-8'));
|
|
159
|
-
const {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
await promises.writeFile(pathToWorkflowFile, dump(_objectSpread2(_objectSpread2({}, workflowDetails), {}, {
|
|
176
|
-
jobs: _objectSpread2(_objectSpread2({}, workflowDetails.jobs), {}, {
|
|
177
|
-
verify: _objectSpread2(_objectSpread2({}, workflowDetails.jobs.verify), {}, {
|
|
178
|
-
steps: [...stepsWithLegacyReportingRemoved, {
|
|
179
|
-
uses: 'codecov/codecov-action@v3'
|
|
180
|
-
}]
|
|
181
|
-
})
|
|
53
|
+
const {jobs: {verify: {steps}}} = workflowDetails;
|
|
54
|
+
|
|
55
|
+
if (!steps.find(step => step.uses?.startsWith('codecov/codecov-action'))) {
|
|
56
|
+
const stepsWithLegacyReportingRemoved = steps.filter(({run}) => 'npm run coverage:report' !== run);
|
|
57
|
+
|
|
58
|
+
await promises.writeFile(
|
|
59
|
+
pathToWorkflowFile,
|
|
60
|
+
dump({
|
|
61
|
+
...workflowDetails,
|
|
62
|
+
jobs: {
|
|
63
|
+
...workflowDetails.jobs,
|
|
64
|
+
verify: {
|
|
65
|
+
...workflowDetails.jobs.verify,
|
|
66
|
+
steps: [...stepsWithLegacyReportingRemoved, {uses: 'codecov/codecov-action@v3'}]
|
|
67
|
+
}
|
|
68
|
+
}
|
|
182
69
|
})
|
|
183
|
-
|
|
70
|
+
);
|
|
184
71
|
}
|
|
185
72
|
}
|
|
186
73
|
|
|
187
|
-
|
|
188
|
-
async function liftReporting ({
|
|
189
|
-
projectRoot,
|
|
190
|
-
packageManager
|
|
191
|
-
}) {
|
|
74
|
+
async function liftReporting ({projectRoot, packageManager}) {
|
|
192
75
|
const pathToPackageJson = `${projectRoot}/package.json`;
|
|
193
|
-
const [ciProviderCanBeLifted, existingPackageContents] = await Promise.all([test({
|
|
194
|
-
projectRoot
|
|
195
|
-
}), promises.readFile(pathToPackageJson, 'utf-8')]);
|
|
196
|
-
const parsedPackageContents = JSON.parse(existingPackageContents);
|
|
197
|
-
const {
|
|
198
|
-
scripts
|
|
199
|
-
} = parsedPackageContents;
|
|
200
76
|
|
|
201
|
-
const
|
|
77
|
+
const [ciProviderCanBeLifted, existingPackageContents] = await Promise.all([
|
|
78
|
+
test({projectRoot}),
|
|
79
|
+
promises.readFile(pathToPackageJson, 'utf-8')
|
|
80
|
+
]);
|
|
81
|
+
const parsedPackageContents = JSON.parse(existingPackageContents);
|
|
82
|
+
const {scripts} = parsedPackageContents;
|
|
83
|
+
const {'coverage:report': reportCoverageScript, ...otherScripts} = scripts;
|
|
202
84
|
|
|
203
|
-
if (ciProviderCanBeLifted) await lift$1({
|
|
204
|
-
projectRoot
|
|
205
|
-
});
|
|
85
|
+
if (ciProviderCanBeLifted) await lift$1({projectRoot});
|
|
206
86
|
|
|
207
87
|
if (scripts['coverage:report']) {
|
|
208
88
|
parsedPackageContents.scripts = otherScripts;
|
|
209
89
|
await promises.writeFile(pathToPackageJson, JSON.stringify(parsedPackageContents));
|
|
90
|
+
|
|
210
91
|
await execa(packageManager, ['remove', 'codecov']);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
...!ciProviderCanBeLifted && {
|
|
95
|
+
nextSteps: [{
|
|
96
|
+
summary: 'Configure modern reporting to Codecov on your CI service',
|
|
97
|
+
description: 'Configure the [Codecov Uploader](https://docs.codecov.com/docs/codecov-uploader) appropriately'
|
|
98
|
+
+ ' for your CI Provider. If available for your provider, prefer one of the dedicated wrappers.'
|
|
99
|
+
}]
|
|
100
|
+
}
|
|
101
|
+
};
|
|
217
102
|
}
|
|
218
103
|
|
|
219
104
|
return {};
|
|
220
105
|
}
|
|
221
106
|
|
|
222
|
-
function lift({
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
});
|
|
107
|
+
async function lift({projectRoot, packageManager, vcs}) {
|
|
108
|
+
const [reportingResults, badgeResults] = await Promise.all([
|
|
109
|
+
liftReporting({projectRoot, packageManager}),
|
|
110
|
+
scaffold({vcs})
|
|
111
|
+
]);
|
|
112
|
+
|
|
113
|
+
return deepmerge.all([reportingResults, badgeResults]);
|
|
230
114
|
}
|
|
231
115
|
|
|
232
|
-
export { lift, scaffold };
|
|
116
|
+
export { lift, scaffold$1 as scaffold };
|
|
233
117
|
//# sourceMappingURL=index.es.js.map
|
package/lib/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/scaffolder.js","../src/badge/repository-details-fetcher.js","../src/badge/scaffolder.js","../src/reporter/ci-providers/github-workflows/lifter.js","../src/reporter/lifter.js","../src/lifter.js"],"sourcesContent":["export async function scaffold() {\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 {promises as fs} from 'fs';\nimport {dump, load} from 'js-yaml';\nimport {fileExists} from '@form8ion/core';\n\nfunction getPathToWorkflowFile(projectRoot) {\n return `${projectRoot}/.github/workflows/node-ci.yml`;\n}\n\nexport function test({projectRoot}) {\n return fileExists(getPathToWorkflowFile(projectRoot));\n}\n\nexport async function lift({projectRoot}) {\n const pathToWorkflowFile = getPathToWorkflowFile(projectRoot);\n\n const workflowDetails = load(await fs.readFile(pathToWorkflowFile, 'utf-8'));\n const {jobs: {verify: {steps}}} = workflowDetails;\n\n if (!steps.find(step => step.uses?.startsWith('codecov/codecov-action'))) {\n const stepsWithLegacyReportingRemoved = steps.filter(({run}) => 'npm run coverage:report' !== run);\n\n await fs.writeFile(\n pathToWorkflowFile,\n dump({\n ...workflowDetails,\n jobs: {\n ...workflowDetails.jobs,\n verify: {\n ...workflowDetails.jobs.verify,\n steps: [...stepsWithLegacyReportingRemoved, {uses: 'codecov/codecov-action@v3'}]\n }\n }\n })\n );\n }\n}\n","import {promises as fs} from 'fs';\n\nimport execa from '../../thirdparty-wrappers/execa';\nimport {lift as liftCiProvider, test as ciProviderIsLiftable} from './ci-providers';\n\nexport default async function ({projectRoot, packageManager}) {\n const pathToPackageJson = `${projectRoot}/package.json`;\n\n const [ciProviderCanBeLifted, existingPackageContents] = await Promise.all([\n ciProviderIsLiftable({projectRoot}),\n fs.readFile(pathToPackageJson, 'utf-8')\n ]);\n const parsedPackageContents = JSON.parse(existingPackageContents);\n const {scripts} = parsedPackageContents;\n const {'coverage:report': reportCoverageScript, ...otherScripts} = scripts;\n\n if (ciProviderCanBeLifted) await liftCiProvider({projectRoot});\n\n if (scripts['coverage:report']) {\n parsedPackageContents.scripts = otherScripts;\n await fs.writeFile(pathToPackageJson, JSON.stringify(parsedPackageContents));\n\n await execa(packageManager, ['remove', 'codecov']);\n\n return {\n ...!ciProviderCanBeLifted && {\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\n return {};\n}\n","import deepmerge from 'deepmerge';\n\nimport {scaffold as scaffoldBadge} from './badge';\nimport {lift as liftReporting} from './reporter';\n\nexport async function lift({projectRoot, packageManager, vcs}) {\n const [reportingResults, badgeResults] = await Promise.all([\n liftReporting({projectRoot, packageManager}),\n scaffoldBadge({vcs})\n ]);\n\n return deepmerge.all([reportingResults, badgeResults]);\n}\n"],"names":["scaffold","lift","fs","ciProviderIsLiftable","liftCiProvider","scaffoldBadge"],"mappings":";;;;;;;AAAO,eAAeA,UAAQ,GAAG;AACjC,EAAE,OAAO,EAAE,CAAC;AACZ;;ACAe,qCAAc,EAAE,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE;AACtD,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG;AAClC,IAAI,CAAC,0BAA0B,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;AACxD,IAAI,CAAC,OAAO,EAAE,CAAC,aAAa,EAAE,cAAc,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC;AACpE,GAAG,CAAC;AACJ;AACA,EAAE,OAAO,IAAI,CAAC;AACd;;ACPO,eAAe,QAAQ,CAAC,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE;AACtD,EAAE,OAAO;AACT,IAAI,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI;AAChE,MAAM,MAAM,EAAE;AACd,QAAQ,MAAM,EAAE;AAChB,UAAU,QAAQ,EAAE;AACpB,YAAY,GAAG,EAAE,CAAC,iCAAiC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,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ClC,IAAI,qBAAqB,CAAC,OAAO,GAAG,YAAY,CAAC;AACjD,IAAI,MAAMF,QAAE,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAAC;AACjF;AACA,IAAI,MAAM,KAAK,CAAC,cAAc,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AACvD;AACA,IAAI,OAAO;AACX,MAAM,GAAG,CAAC,qBAAqB,IAAI;AACnC,QAAQ,SAAS,EAAE,CAAC;AACpB,UAAU,OAAO,EAAE,0DAA0D;AAC7E,UAAU,WAAW,EAAE,gGAAgG;AACvH,cAAc,8FAA8F;AAC5G,SAAS,CAAC;AACV,OAAO;AACP,KAAK,CAAC;AACN,GAAG;AACH;AACA,EAAE,OAAO,EAAE,CAAC;AACZ;;AC/BO,eAAe,IAAI,CAAC,CAAC,WAAW,EAAE,cAAc,EAAE,GAAG,CAAC,EAAE;AAC/D,EAAE,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;AAC7D,IAAI,aAAa,CAAC,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;AAChD,IAAIG,QAAa,CAAC,CAAC,GAAG,CAAC,CAAC;AACxB,GAAG,CAAC,CAAC;AACL;AACA,EAAE,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC,CAAC;AACzD;;;;"}
|
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": "
|
|
5
|
+
"version": "5.0.0-beta.2",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=16"
|
|
8
8
|
},
|
|
@@ -41,56 +41,59 @@
|
|
|
41
41
|
"test:integration:wip": "run-s 'test:integration:base -- --profile wip'",
|
|
42
42
|
"test:integration:wip:debug": "DEBUG=test run-s 'test:integration:wip'",
|
|
43
43
|
"test:integration:focus": "run-s 'test:integration:base -- --profile focus'",
|
|
44
|
-
"lint:engines": "ls-engines"
|
|
44
|
+
"lint:engines": "ls-engines",
|
|
45
|
+
"lint:publish": "publint"
|
|
45
46
|
},
|
|
46
47
|
"files": [
|
|
47
48
|
"example.js",
|
|
48
49
|
"lib/"
|
|
49
50
|
],
|
|
50
51
|
"publishConfig": {
|
|
51
|
-
"access": "public"
|
|
52
|
+
"access": "public",
|
|
53
|
+
"provenance": true
|
|
52
54
|
},
|
|
53
55
|
"dependencies": {
|
|
54
56
|
"@form8ion/core": "^2.0.0",
|
|
57
|
+
"deepmerge": "^4.3.1",
|
|
55
58
|
"execa": "^5.1.1",
|
|
56
59
|
"got": "^11.8.5",
|
|
57
60
|
"js-yaml": "^4.1.0"
|
|
58
61
|
},
|
|
59
62
|
"devDependencies": {
|
|
60
|
-
"@babel/register": "7.
|
|
61
|
-
"@cucumber/cucumber": "
|
|
62
|
-
"@form8ion/babel-preset": "1.6.
|
|
63
|
-
"@form8ion/commitlint-config": "1.0.
|
|
64
|
-
"@form8ion/eslint-config": "
|
|
63
|
+
"@babel/register": "7.22.5",
|
|
64
|
+
"@cucumber/cucumber": "9.3.0",
|
|
65
|
+
"@form8ion/babel-preset": "1.6.107",
|
|
66
|
+
"@form8ion/commitlint-config": "1.0.53",
|
|
67
|
+
"@form8ion/eslint-config": "6.0.0",
|
|
65
68
|
"@form8ion/eslint-config-cucumber": "1.4.1",
|
|
66
|
-
"@form8ion/eslint-config-mocha": "
|
|
67
|
-
"@form8ion/javascript-core": "
|
|
68
|
-
"@form8ion/remark-lint-preset": "
|
|
69
|
-
"@rollup/plugin-
|
|
70
|
-
"@
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"chai": "4.3.6",
|
|
69
|
+
"@form8ion/eslint-config-mocha": "3.0.0",
|
|
70
|
+
"@form8ion/javascript-core": "10.0.1",
|
|
71
|
+
"@form8ion/remark-lint-preset": "6.0.0",
|
|
72
|
+
"@rollup/plugin-node-resolve": "15.1.0",
|
|
73
|
+
"@travi/any": "2.1.8",
|
|
74
|
+
"ban-sensitive-files": "1.9.19",
|
|
75
|
+
"c8": "8.0.1",
|
|
76
|
+
"chai": "4.3.7",
|
|
75
77
|
"cross-env": "7.0.3",
|
|
76
78
|
"cz-conventional-changelog": "3.3.0",
|
|
77
79
|
"gherkin-lint": "4.2.2",
|
|
78
80
|
"http-status-codes": "2.2.0",
|
|
79
|
-
"husky": "8.0.
|
|
80
|
-
"lockfile-lint": "4.
|
|
81
|
-
"ls-engines": "0.
|
|
82
|
-
"mocha": "10.
|
|
83
|
-
"mock-fs": "5.
|
|
84
|
-
"nock": "13.2
|
|
81
|
+
"husky": "8.0.3",
|
|
82
|
+
"lockfile-lint": "4.12.0",
|
|
83
|
+
"ls-engines": "0.9.0",
|
|
84
|
+
"mocha": "10.2.0",
|
|
85
|
+
"mock-fs": "5.2.0",
|
|
86
|
+
"nock": "13.3.2",
|
|
85
87
|
"npm-run-all": "4.1.5",
|
|
86
88
|
"package-preview": "4.0.0",
|
|
89
|
+
"publint": "0.2.0",
|
|
87
90
|
"remark-cli": "11.0.0",
|
|
88
91
|
"remark-toc": "8.0.1",
|
|
89
92
|
"remark-usage": "10.0.1",
|
|
90
|
-
"rimraf": "
|
|
91
|
-
"rollup": "
|
|
93
|
+
"rimraf": "5.0.1",
|
|
94
|
+
"rollup": "3.27.2",
|
|
92
95
|
"rollup-plugin-auto-external": "2.0.0",
|
|
93
|
-
"sinon": "
|
|
94
|
-
"testdouble": "3.16.
|
|
96
|
+
"sinon": "15.2.0",
|
|
97
|
+
"testdouble": "3.16.7"
|
|
95
98
|
}
|
|
96
99
|
}
|