news-fragments 2.0.0-3 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -15
- package/package.json +5 -6
- package/.editorconfig +0 -8
- package/.eslintrc.cjs +0 -19
- package/.github/dependabot.yml +0 -15
- package/.github/workflows/fortify.yml +0 -42
- package/.github/workflows/main.yml +0 -36
- package/.github/workflows/publish.yml +0 -30
- package/.github/workflows/sonar.yml +0 -47
- package/.nvmrc +0 -1
- package/fragments/.gitkeep +0 -0
- package/jest.config.js +0 -6
- package/myself-release.js +0 -12
- package/sonar-project.properties +0 -8
- package/tests/__snapshots__/config.test.js.snap +0 -11
- package/tests/build-template.test.js +0 -128
- package/tests/cli/burn.test.js +0 -63
- package/tests/cli/create.test.js +0 -55
- package/tests/cli/preview.test.js +0 -104
- package/tests/config.test.js +0 -58
- package/tests/file.test.js +0 -84
- package/tests/helpers.test.js +0 -30
- package/tests/index.test.js +0 -63
package/CHANGELOG.md
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
|
|
2
|
-
[//]: # (s-2.0.
|
|
2
|
+
[//]: # (s-2.0.2)
|
|
3
3
|
|
|
4
|
-
# [2.0.
|
|
4
|
+
# [2.0.2] - (2022-07-26)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[//]: # (s-2.0.0-2)
|
|
6
|
+
## Misc
|
|
7
|
+
* Update project dependencies.
|
|
10
8
|
|
|
11
|
-
#
|
|
9
|
+
[//]: # (e-2.0.2)
|
|
12
10
|
|
|
13
|
-
[//]: # (e-2.0.0-2)
|
|
14
11
|
|
|
12
|
+
[//]: # (s-2.0.1)
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
# [2.0.1] - (2022-07-05)
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
## Misc
|
|
17
|
+
* Update dependencies.
|
|
19
18
|
|
|
20
|
-
[//]: # (e-2.0.
|
|
19
|
+
[//]: # (e-2.0.1)
|
|
21
20
|
|
|
22
21
|
|
|
23
|
-
[//]: # (s-2.0.0
|
|
22
|
+
[//]: # (s-2.0.0)
|
|
24
23
|
|
|
25
|
-
# [2.0.0
|
|
24
|
+
# [2.0.0] - (2022-06-27)
|
|
26
25
|
|
|
27
26
|
## Features
|
|
28
27
|
* Move project to esm and use the latest version of release-it.
|
|
29
28
|
|
|
30
|
-
[//]: # (e-2.0.0
|
|
31
|
-
|
|
29
|
+
[//]: # (e-2.0.0)
|
|
32
30
|
|
|
33
31
|
[//]: # (s-1.14.5)
|
|
34
32
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "news-fragments",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "A release-it plugin to manipulate changelogs",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --detectOpenHandles --collectCoverage --runInBand --verbose --forceExit",
|
|
9
9
|
"lint": "eslint . --ext .js --ignore-pattern node_modules/",
|
|
10
|
-
"lint:fix": "eslint . --ext .js --ignore-pattern node_modules/",
|
|
10
|
+
"lint:fix": "eslint . --ext .js --fix --ignore-pattern node_modules/",
|
|
11
11
|
"release": "release-it"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
@@ -29,11 +29,10 @@
|
|
|
29
29
|
"homepage": "https://github.com/grupoboticario/news-fragments#readme",
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@release-it/bumper": "4.0.0",
|
|
32
|
-
"eslint": "8.
|
|
32
|
+
"eslint": "8.20.0",
|
|
33
33
|
"eslint-config-prettier": "^8.3.0",
|
|
34
|
-
"eslint-plugin-prettier": "^4.
|
|
34
|
+
"eslint-plugin-prettier": "^4.1.0",
|
|
35
35
|
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
36
|
-
"eslint-plugin-sort-import": "^1.0.7",
|
|
37
36
|
"jest": "^28.0.1",
|
|
38
37
|
"mock-fs": "^5.1.0",
|
|
39
38
|
"mockdate": "^3.0.5",
|
|
@@ -51,7 +50,7 @@
|
|
|
51
50
|
"marked-terminal": "^5.1.1",
|
|
52
51
|
"meow": "10.1.3",
|
|
53
52
|
"moment": "^2.29.1",
|
|
54
|
-
"release-it": "15.
|
|
53
|
+
"release-it": "15.2.0"
|
|
55
54
|
},
|
|
56
55
|
"engines": {
|
|
57
56
|
"node": ">=14"
|
package/.editorconfig
DELETED
package/.eslintrc.cjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
es6: true,
|
|
4
|
-
node: true,
|
|
5
|
-
},
|
|
6
|
-
extends: ["plugin:prettier/recommended"],
|
|
7
|
-
globals: {
|
|
8
|
-
Atomics: "readonly",
|
|
9
|
-
SharedArrayBuffer: "readonly",
|
|
10
|
-
},
|
|
11
|
-
parserOptions: {
|
|
12
|
-
ecmaVersion: 2020,
|
|
13
|
-
sourceType: "module"
|
|
14
|
-
},
|
|
15
|
-
plugins: ["simple-import-sort"],
|
|
16
|
-
"rules": {
|
|
17
|
-
"simple-import-sort/imports": "error"
|
|
18
|
-
}
|
|
19
|
-
};
|
package/.github/dependabot.yml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
-
# package ecosystems to update and where the package manifests are located.
|
|
3
|
-
# Please see the documentation for all configuration options:
|
|
4
|
-
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
-
|
|
6
|
-
version: 2
|
|
7
|
-
updates:
|
|
8
|
-
- package-ecosystem: "npm"
|
|
9
|
-
directory: "/" # Location of package manifests
|
|
10
|
-
schedule:
|
|
11
|
-
interval: "daily"
|
|
12
|
-
- package-ecosystem: "github-actions"
|
|
13
|
-
directory: "/"
|
|
14
|
-
schedule:
|
|
15
|
-
interval: "daily"
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
name: Fortify
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
fortify:
|
|
9
|
-
runs-on: [self-hosted, devsecops]
|
|
10
|
-
name: Fortify
|
|
11
|
-
steps:
|
|
12
|
-
- name: Checkout
|
|
13
|
-
uses: actions/checkout@v3
|
|
14
|
-
- name: Checkout Application & Version Action
|
|
15
|
-
run: git clone git@github.com-fortify-action-api:grupoboticario/fortify-action-api.git .github/fortify-action-api
|
|
16
|
-
- name: Checkout SAST Assessment Action
|
|
17
|
-
run: git clone git@github.com-fortify-action-sast:grupoboticario/fortify-action-sast.git .github/fortify-action-sast
|
|
18
|
-
- name: Import Secrets
|
|
19
|
-
uses: hashicorp/vault-action@v2.4.1
|
|
20
|
-
with:
|
|
21
|
-
url: https://heimdall.grupoboticario.digital
|
|
22
|
-
token: ${{ secrets.FORTIFY_VAULT_TOKEN }}
|
|
23
|
-
secrets: |
|
|
24
|
-
fortify/secrets/gbaction userf ;
|
|
25
|
-
fortify/secrets/gbaction citoken ;
|
|
26
|
-
fortify/secrets/gbaction scancentral
|
|
27
|
-
- name: Create Application & Version
|
|
28
|
-
uses: ./.github/fortify-action-api
|
|
29
|
-
id: fortify_api
|
|
30
|
-
with:
|
|
31
|
-
api_credentials: '${{ env.USERF }}'
|
|
32
|
-
application_name: '${{ github.repository }}'
|
|
33
|
-
application_version: 'main'
|
|
34
|
-
- name: SAST
|
|
35
|
-
uses: ./.github/fortify-action-sast
|
|
36
|
-
id: SAST
|
|
37
|
-
with:
|
|
38
|
-
application_name: '${{ github.repository }}'
|
|
39
|
-
application_version: 'main'
|
|
40
|
-
client_token: '${{ env.SCANCENTRAL }}'
|
|
41
|
-
ci_token: '${{ env.CITOKEN }}'
|
|
42
|
-
language_profile: other
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
name: "[TEST] NewsFragments"
|
|
2
|
-
|
|
3
|
-
on: [pull_request]
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
build:
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
|
|
9
|
-
steps:
|
|
10
|
-
- uses: actions/checkout@v3
|
|
11
|
-
|
|
12
|
-
- name: Setup node 16.x
|
|
13
|
-
uses: actions/setup-node@v3.3.0
|
|
14
|
-
with:
|
|
15
|
-
node-version: 16.x
|
|
16
|
-
|
|
17
|
-
- name: Get npm cache directory
|
|
18
|
-
id: npm-cache
|
|
19
|
-
run: |
|
|
20
|
-
echo "::set-output name=dir::$(npm config get cache)"
|
|
21
|
-
|
|
22
|
-
- uses: actions/cache@v3.0.4
|
|
23
|
-
with:
|
|
24
|
-
path: ${{ steps.npm-cache.outputs.dir }}
|
|
25
|
-
key: ubuntu-latest-node-${{ hashFiles('**/yarn.lock') }}
|
|
26
|
-
restore-keys: |
|
|
27
|
-
ubuntu-latest-node-
|
|
28
|
-
|
|
29
|
-
- name: Install dependencies
|
|
30
|
-
run: yarn install
|
|
31
|
-
|
|
32
|
-
- name: Run lint
|
|
33
|
-
run: yarn lint
|
|
34
|
-
|
|
35
|
-
- name: Build & Test
|
|
36
|
-
run: yarn test
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
name: "[PUBLISH] NewsFragments"
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
tags:
|
|
6
|
-
- "*"
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
npm-publish:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v3
|
|
13
|
-
- uses: actions/setup-node@v3.3.0
|
|
14
|
-
with:
|
|
15
|
-
node-version: 16.x
|
|
16
|
-
- run: yarn install
|
|
17
|
-
- run: yarn lint
|
|
18
|
-
- run: yarn test
|
|
19
|
-
- id: "publish"
|
|
20
|
-
uses: JS-DevTools/npm-publish@v1
|
|
21
|
-
with:
|
|
22
|
-
token: ${{ secrets.NPM_AUTH_TOKEN }}
|
|
23
|
-
|
|
24
|
-
- if: steps.publish.type != 'none'
|
|
25
|
-
run: |
|
|
26
|
-
echo "Version changed: ${{ steps.publish.old-version }} => ${{ steps.publish.version }}"
|
|
27
|
-
|
|
28
|
-
- if: steps.publish.type == 'none'
|
|
29
|
-
run: |
|
|
30
|
-
echo "Version not changed."
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
name: "[SONAR] NewsFragments"
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
pull_request:
|
|
8
|
-
types: [opened, synchronize, reopened]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
sonarCloudTrigger:
|
|
12
|
-
name: SonarCloud Trigger
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v3
|
|
16
|
-
|
|
17
|
-
- name: Setup node 16.x
|
|
18
|
-
uses: actions/setup-node@v3.3.0
|
|
19
|
-
with:
|
|
20
|
-
node-version: 16.x
|
|
21
|
-
|
|
22
|
-
- name: Get npm cache directory
|
|
23
|
-
id: npm-cache
|
|
24
|
-
run: |
|
|
25
|
-
echo "::set-output name=dir::$(npm config get cache)"
|
|
26
|
-
|
|
27
|
-
- uses: actions/cache@v3.0.4
|
|
28
|
-
with:
|
|
29
|
-
path: ${{ steps.npm-cache.outputs.dir }}
|
|
30
|
-
key: ubuntu-latest-node-${{ hashFiles('**/package-lock.json') }}
|
|
31
|
-
restore-keys: |
|
|
32
|
-
ubuntu-latest-node-
|
|
33
|
-
|
|
34
|
-
- name: Install dependencies
|
|
35
|
-
run: yarn install
|
|
36
|
-
|
|
37
|
-
- name: Run lint
|
|
38
|
-
run: yarn lint
|
|
39
|
-
|
|
40
|
-
- name: Build & Test
|
|
41
|
-
run: yarn test
|
|
42
|
-
|
|
43
|
-
- name: SonarCloud Scan
|
|
44
|
-
uses: sonarsource/sonarcloud-github-action@master
|
|
45
|
-
env:
|
|
46
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
47
|
-
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
16
|
package/fragments/.gitkeep
DELETED
|
File without changes
|
package/jest.config.js
DELETED
package/myself-release.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "fs";
|
|
2
|
-
|
|
3
|
-
import NewsFragments from "./src/index.js";
|
|
4
|
-
|
|
5
|
-
const pjson = JSON.parse(
|
|
6
|
-
readFileSync(new URL("./package.json", import.meta.url))
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
const newsFragments = new NewsFragments();
|
|
10
|
-
|
|
11
|
-
newsFragments.init();
|
|
12
|
-
newsFragments.bump(pjson.version);
|
package/sonar-project.properties
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
sonar.projectName=news-fragments
|
|
2
|
-
sonar.organization=gboticario
|
|
3
|
-
sonar.projectKey=54b291df-ce9e-4a5f-b1dd-36cb380195ec
|
|
4
|
-
sonar.projectVersion=2.0.0-3
|
|
5
|
-
sonar.sources=.
|
|
6
|
-
sonar.sourceEncoding=UTF-8
|
|
7
|
-
sonar.javascript.lcov.reportPaths=coverage/lcov.info
|
|
8
|
-
sonar.coverage.exclusions=**test**,**settings**,**jest.config.js,**mocks**,src/cli/index.js
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`should throw error when receive invalid parameters 1`] = `"\\"changelogFile\\" must be a string"`;
|
|
4
|
-
|
|
5
|
-
exports[`should throw error when receive invalid parameters 2`] = `"\\"changelogDateFormat\\" must be a string"`;
|
|
6
|
-
|
|
7
|
-
exports[`should throw error when receive invalid parameters 3`] = `"\\"changelogTemplate\\" must be a string"`;
|
|
8
|
-
|
|
9
|
-
exports[`should throw error when receive invalid parameters 4`] = `"\\"fragmentsFolder\\" is required"`;
|
|
10
|
-
|
|
11
|
-
exports[`should throw error when receive invalid parameters 5`] = `"\\"fragmentsTypes\\" does not contain 1 required value(s)"`;
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import fs from "fs-extra";
|
|
2
|
-
import mockFs from "mock-fs";
|
|
3
|
-
import moment from "moment";
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
generateTemplateData,
|
|
7
|
-
renderTemplate,
|
|
8
|
-
saveChangelogToFile,
|
|
9
|
-
} from "../src/build-template";
|
|
10
|
-
import { buildConfig } from "../src/config";
|
|
11
|
-
|
|
12
|
-
let changelogTemplate;
|
|
13
|
-
let changelogFile;
|
|
14
|
-
|
|
15
|
-
const TODAY = moment().format("YYYY-MM-DD");
|
|
16
|
-
|
|
17
|
-
const mockData = {
|
|
18
|
-
newVersion: "0.0.2",
|
|
19
|
-
bumpDate: TODAY,
|
|
20
|
-
fragments: [
|
|
21
|
-
{
|
|
22
|
-
title: "Feature",
|
|
23
|
-
fragmentEntries: ["Implements JWT handler", "Add x-request-id to logger"],
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
title: "Bugfix",
|
|
27
|
-
fragmentEntries: [
|
|
28
|
-
"Update auth function to work properly when JWT is null",
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const expectedOutput = `
|
|
35
|
-
[//]: # (s-0.0.2)
|
|
36
|
-
|
|
37
|
-
# [0.0.2] - (${TODAY})
|
|
38
|
-
|
|
39
|
-
## Feature
|
|
40
|
-
* Implements JWT handler
|
|
41
|
-
* Add x-request-id to logger
|
|
42
|
-
|
|
43
|
-
## Bugfix
|
|
44
|
-
* Update auth function to work properly when JWT is null
|
|
45
|
-
|
|
46
|
-
[//]: # (e-0.0.2)
|
|
47
|
-
|
|
48
|
-
`;
|
|
49
|
-
|
|
50
|
-
beforeEach(() => {
|
|
51
|
-
var config = buildConfig({});
|
|
52
|
-
changelogTemplate = config.changelogTemplate;
|
|
53
|
-
changelogFile = config.changelogFile;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
afterEach(() => {
|
|
57
|
-
mockFs.restore();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("should render correctly the template", () => {
|
|
61
|
-
const result = renderTemplate(changelogTemplate, mockData, "0.0.2");
|
|
62
|
-
expect(result).toStrictEqual(expectedOutput);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test("should write in an empty file", () => {
|
|
66
|
-
mockFs({
|
|
67
|
-
"CHANGELOG.md": "",
|
|
68
|
-
});
|
|
69
|
-
const renderedTemplate = renderTemplate(changelogTemplate, mockData, "0.0.2");
|
|
70
|
-
saveChangelogToFile(changelogFile, renderedTemplate);
|
|
71
|
-
expect(fs.readFileSync(changelogFile).toString()).toStrictEqual(`
|
|
72
|
-
[//]: # (s-0.0.2)
|
|
73
|
-
|
|
74
|
-
# [0.0.2] - (${TODAY})
|
|
75
|
-
|
|
76
|
-
## Feature
|
|
77
|
-
* Implements JWT handler
|
|
78
|
-
* Add x-request-id to logger
|
|
79
|
-
|
|
80
|
-
## Bugfix
|
|
81
|
-
* Update auth function to work properly when JWT is null
|
|
82
|
-
|
|
83
|
-
[//]: # (e-0.0.2)
|
|
84
|
-
|
|
85
|
-
`);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test("should prepend in a file with content", () => {
|
|
89
|
-
mockFs({
|
|
90
|
-
"CHANGELOG.md": "matheuszin_reidelas2011@hotmail.com",
|
|
91
|
-
});
|
|
92
|
-
const renderedTemplate = renderTemplate(changelogTemplate, mockData, "0.0.2");
|
|
93
|
-
saveChangelogToFile(changelogFile, renderedTemplate);
|
|
94
|
-
const data = fs.readFileSync(changelogFile);
|
|
95
|
-
expect(data.toString()).toStrictEqual(`
|
|
96
|
-
[//]: # (s-0.0.2)
|
|
97
|
-
|
|
98
|
-
# [0.0.2] - (${TODAY})
|
|
99
|
-
|
|
100
|
-
## Feature
|
|
101
|
-
* Implements JWT handler
|
|
102
|
-
* Add x-request-id to logger
|
|
103
|
-
|
|
104
|
-
## Bugfix
|
|
105
|
-
* Update auth function to work properly when JWT is null
|
|
106
|
-
|
|
107
|
-
[//]: # (e-0.0.2)
|
|
108
|
-
|
|
109
|
-
matheuszin_reidelas2011@hotmail.com`);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
test("should generate the data to use in template", () => {
|
|
113
|
-
const fakeFragments = [
|
|
114
|
-
{
|
|
115
|
-
title: "Feature",
|
|
116
|
-
fragmentEntries: ["Implements JWT handler", "Add x-request-id to logger"],
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
title: "Bugfix",
|
|
120
|
-
fragmentEntries: [
|
|
121
|
-
"Update auth function to work properly when JWT is null",
|
|
122
|
-
],
|
|
123
|
-
},
|
|
124
|
-
];
|
|
125
|
-
expect(
|
|
126
|
-
generateTemplateData("0.0.2", "YYYY-MM-DD", fakeFragments)
|
|
127
|
-
).toStrictEqual(mockData);
|
|
128
|
-
});
|
package/tests/cli/burn.test.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import chalkTemplate from "chalk-template";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import mockFs from "mock-fs";
|
|
4
|
-
import MockDate from "mockdate";
|
|
5
|
-
|
|
6
|
-
import { burn } from "../../src/cli/burn";
|
|
7
|
-
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
MockDate.set("2020-12-02T11:01:58.135Z");
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
afterEach(() => {
|
|
13
|
-
mockFs.restore();
|
|
14
|
-
MockDate.reset();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test("should show an error when no version is passed", async () => {
|
|
18
|
-
const result = burn(["burn"]);
|
|
19
|
-
|
|
20
|
-
const expected = chalkTemplate`No version was found.
|
|
21
|
-
Please, provide one like: {green news-fragments burn 0.0.1}`;
|
|
22
|
-
|
|
23
|
-
expect(result).toEqual(expected);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test("should show an error if there is no fragment to burn", async () => {
|
|
27
|
-
mockFs({
|
|
28
|
-
fragments: {},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const result = burn(["burn", "0.0.1"]);
|
|
32
|
-
|
|
33
|
-
const expected = chalkTemplate`No fragments were found.
|
|
34
|
-
Remember to create with {green news-fragments create <fragment-type> <fragment-text>}`;
|
|
35
|
-
|
|
36
|
-
expect(result).toEqual(expected);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test("should save the changelog and delete the fragments", async () => {
|
|
40
|
-
mockFs({
|
|
41
|
-
fragments: {
|
|
42
|
-
"xpto.feature": "Adiciona uma feature.",
|
|
43
|
-
},
|
|
44
|
-
"CHANGELOG.md": "",
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const result = burn(["burn", "0.0.1"]);
|
|
48
|
-
const expected = `
|
|
49
|
-
[//]: # (s-0.0.1)
|
|
50
|
-
|
|
51
|
-
# [0.0.1] - (2020-12-02)
|
|
52
|
-
|
|
53
|
-
## Features
|
|
54
|
-
* Adiciona uma feature.
|
|
55
|
-
|
|
56
|
-
[//]: # (e-0.0.1)
|
|
57
|
-
|
|
58
|
-
`;
|
|
59
|
-
|
|
60
|
-
expect(fs.readFileSync("CHANGELOG.md", "utf8")).toEqual(expected);
|
|
61
|
-
expect(fs.existsSync("fragments/xpto.feature")).toBeFalsy();
|
|
62
|
-
expect(result).toEqual("1 fragments burned in CHANGELOG.md");
|
|
63
|
-
});
|
package/tests/cli/create.test.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import chalkTemplate from "chalk-template";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import mockFs from "mock-fs";
|
|
4
|
-
import MockDate from "mockdate";
|
|
5
|
-
|
|
6
|
-
import { create } from "../../src/cli/create";
|
|
7
|
-
|
|
8
|
-
mockFs({
|
|
9
|
-
fragments: {},
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
MockDate.set("2019-05-14T11:01:58.135Z");
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
afterEach(() => {
|
|
17
|
-
mockFs.restore();
|
|
18
|
-
MockDate.reset();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test("should return success message when create a fragment", async () => {
|
|
22
|
-
const result = create(["create", "feature", "show"]);
|
|
23
|
-
|
|
24
|
-
expect(result).toStrictEqual(
|
|
25
|
-
"Fragment fragments/1557831718135.feature created with success!"
|
|
26
|
-
);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test("should return error message when try to create a fragment file", async () => {
|
|
30
|
-
const result = create(["create", "doidera"]);
|
|
31
|
-
|
|
32
|
-
const expected = chalkTemplate`Fragment type {red doidera} is invalid.
|
|
33
|
-
Choose one of available fragment types: {green feature,bugfix,doc,removal,misc}`;
|
|
34
|
-
|
|
35
|
-
expect(result).toStrictEqual(expected);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test("should append dot at end of changelog message", async () => {
|
|
39
|
-
create(["create", "feature", "a changelog message"]);
|
|
40
|
-
|
|
41
|
-
const contents = fs.readFileSync("fragments/1557831718135.feature", "utf8");
|
|
42
|
-
expect(contents).toStrictEqual("a changelog message.");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test.each(["", "message."])(
|
|
46
|
-
"should not append dot at end of changelog message -> '%s'",
|
|
47
|
-
async (message) => {
|
|
48
|
-
create(["create", "feature", message]);
|
|
49
|
-
|
|
50
|
-
const contents = fs.readFileSync("fragments/1557831718135.feature", "utf8");
|
|
51
|
-
|
|
52
|
-
expect(contents).toStrictEqual(message);
|
|
53
|
-
fs.unlinkSync("fragments/1557831718135.feature");
|
|
54
|
-
}
|
|
55
|
-
);
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import mockFs from "mock-fs";
|
|
2
|
-
import MockDate from "mockdate";
|
|
3
|
-
|
|
4
|
-
import { preview } from "../../src/cli/preview";
|
|
5
|
-
|
|
6
|
-
afterEach(() => {
|
|
7
|
-
mockFs.restore();
|
|
8
|
-
MockDate.reset();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
const FAKE_DATE = "2019-05-14T11:01:58.135Z";
|
|
12
|
-
|
|
13
|
-
const fakeChangelog = `
|
|
14
|
-
[//]: # (s-1.0.2)
|
|
15
|
-
|
|
16
|
-
# [1.0.2] - (2020-03-11)
|
|
17
|
-
|
|
18
|
-
## Bugfixes
|
|
19
|
-
|
|
20
|
-
- Remove `getLatestVersion` method from NewsFragments.
|
|
21
|
-
|
|
22
|
-
[//]: # (e-1.0.2)
|
|
23
|
-
|
|
24
|
-
[//]: # (s-1.0.1)
|
|
25
|
-
|
|
26
|
-
# [1.0.1] - (2020-03-11)
|
|
27
|
-
|
|
28
|
-
## Bugfixes
|
|
29
|
-
|
|
30
|
-
- Remove method `getName` from NewsFragments plugin.
|
|
31
|
-
|
|
32
|
-
[//]: # (e-1.0.1)
|
|
33
|
-
|
|
34
|
-
[//]: # (s-1.0.0)
|
|
35
|
-
|
|
36
|
-
# [1.0.0] - (2020-03-11)
|
|
37
|
-
|
|
38
|
-
## Features
|
|
39
|
-
|
|
40
|
-
- First release! 🚀
|
|
41
|
-
|
|
42
|
-
[//]: # (e-1.0.0)
|
|
43
|
-
`;
|
|
44
|
-
|
|
45
|
-
test("should only return date when there are no fragments", async () => {
|
|
46
|
-
MockDate.set(FAKE_DATE);
|
|
47
|
-
|
|
48
|
-
mockFs({
|
|
49
|
-
fragments: {},
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const result = preview({});
|
|
53
|
-
|
|
54
|
-
expect(result).toContain("# [NEXT_RELEASE] - (2019-05-14)");
|
|
55
|
-
expect(result).not.toContain("## Features");
|
|
56
|
-
expect(result).not.toContain("## Bugfixes");
|
|
57
|
-
expect(result).not.toContain("## Documentation");
|
|
58
|
-
expect(result).not.toContain("## Deprecations and Removals");
|
|
59
|
-
expect(result).not.toContain("## Misc");
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test("should return data from fragments", async () => {
|
|
63
|
-
MockDate.set(FAKE_DATE);
|
|
64
|
-
|
|
65
|
-
mockFs({
|
|
66
|
-
fragments: {
|
|
67
|
-
"test.feature": "My feature",
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const result = preview({});
|
|
72
|
-
|
|
73
|
-
expect(result).toContain("# [NEXT_RELEASE] - (2019-05-14)");
|
|
74
|
-
expect(result).toContain("## Features");
|
|
75
|
-
expect(result).toContain("My feature");
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
test("should return a previous version", async () => {
|
|
79
|
-
MockDate.set(FAKE_DATE);
|
|
80
|
-
|
|
81
|
-
mockFs({
|
|
82
|
-
"CHANGELOG.md": fakeChangelog,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const result = preview({}, { previousVersion: "1.0.1" });
|
|
86
|
-
|
|
87
|
-
expect(result).toContain("# [1.0.1] - (2020-03-11)");
|
|
88
|
-
expect(result).toContain("## Bugfixes");
|
|
89
|
-
expect(result).toContain(
|
|
90
|
-
"Remove method `getName` from NewsFragments plugin."
|
|
91
|
-
);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
test("should return nothing when the previous version doesn't exist", async () => {
|
|
95
|
-
MockDate.set(FAKE_DATE);
|
|
96
|
-
|
|
97
|
-
mockFs({
|
|
98
|
-
"CHANGELOG.md": fakeChangelog,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
const result = preview({}, { previousVersion: "5.0.1" });
|
|
102
|
-
|
|
103
|
-
expect(result).toEqual("");
|
|
104
|
-
});
|
package/tests/config.test.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Config } from "release-it";
|
|
2
|
-
|
|
3
|
-
import { buildConfig, retrieveUserConfig } from "../src/config";
|
|
4
|
-
|
|
5
|
-
test("should return a base config", async () => {
|
|
6
|
-
const config = buildConfig({});
|
|
7
|
-
|
|
8
|
-
expect(config.changelogFile).toBe("CHANGELOG.md");
|
|
9
|
-
expect(config.changelogDateFormat).toBe("YYYY-MM-DD");
|
|
10
|
-
expect(config.fragmentsFolder).toBe("fragments");
|
|
11
|
-
expect(config.changelogTemplate).toBe(`# [{{newVersion}}] - ({{bumpDate}})
|
|
12
|
-
{{#fragments}}
|
|
13
|
-
|
|
14
|
-
## {{title}}
|
|
15
|
-
{{#each fragmentEntries}}
|
|
16
|
-
* {{this}}
|
|
17
|
-
{{/each}}
|
|
18
|
-
{{/fragments}}
|
|
19
|
-
`);
|
|
20
|
-
expect(config.fragmentsTypes).toEqual([
|
|
21
|
-
{ title: "Features", extension: "feature" },
|
|
22
|
-
{ title: "Bugfixes", extension: "bugfix" },
|
|
23
|
-
{ title: "Documentation", extension: "doc" },
|
|
24
|
-
{ title: "Deprecations and Removals", extension: "removal" },
|
|
25
|
-
{ title: "Misc", extension: "misc" },
|
|
26
|
-
]);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test.each([
|
|
30
|
-
[{ changelogFile: 1 }],
|
|
31
|
-
[{ changelogDateFormat: 1 }],
|
|
32
|
-
[{ changelogTemplate: 1 }],
|
|
33
|
-
[{ fragmentsFolder: undefined }],
|
|
34
|
-
[{ fragmentsTypes: [] }],
|
|
35
|
-
])("should throw error when receive invalid parameters", async (element) => {
|
|
36
|
-
expect(() => {
|
|
37
|
-
buildConfig(element);
|
|
38
|
-
}).toThrowErrorMatchingSnapshot();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test("should retrieve user config info on package.json", () => {
|
|
42
|
-
const fakeConfig = new Config({
|
|
43
|
-
config: false,
|
|
44
|
-
plugins: {
|
|
45
|
-
xpto: {
|
|
46
|
-
foo: "bar",
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
expect(retrieveUserConfig(fakeConfig, "xpto")).toStrictEqual({ foo: "bar" });
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test("should return null when package.json doesnt have any configs", () => {
|
|
54
|
-
const fakeConfig = new Config({
|
|
55
|
-
config: false,
|
|
56
|
-
});
|
|
57
|
-
expect(retrieveUserConfig(fakeConfig, null)).toBeNull();
|
|
58
|
-
});
|
package/tests/file.test.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import fs from "fs-extra";
|
|
2
|
-
import mockFs from "mock-fs";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
deleteFragmentsFiles,
|
|
6
|
-
getChangelogContent,
|
|
7
|
-
getFragmentsContent,
|
|
8
|
-
getFragmentsFilesByFragmentType,
|
|
9
|
-
} from "../src/file";
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
mockFs({
|
|
13
|
-
"fragments/.gitkeep": "",
|
|
14
|
-
"fragments/test.bugfix": "fake bugfix content",
|
|
15
|
-
"fragments/test.feature": "fake feature content",
|
|
16
|
-
"fragments/test2.feature": "fake 2 feature content",
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
afterEach(() => {
|
|
21
|
-
mockFs.restore();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("should return a list of fragment files based on fragment type", async () => {
|
|
25
|
-
const bugfix = getFragmentsFilesByFragmentType("fragments", "bugfix");
|
|
26
|
-
const feature = getFragmentsFilesByFragmentType("fragments", "feature");
|
|
27
|
-
|
|
28
|
-
expect(bugfix).toEqual(["fragments/test.bugfix"]);
|
|
29
|
-
expect(feature).toEqual([
|
|
30
|
-
"fragments/test.feature",
|
|
31
|
-
"fragments/test2.feature",
|
|
32
|
-
]);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test("should return an empty list when no fragments found", async () => {
|
|
36
|
-
const misc = getFragmentsFilesByFragmentType("fragments", "misc");
|
|
37
|
-
|
|
38
|
-
expect(misc).toEqual([]);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test("should return a list of fragment data", async () => {
|
|
42
|
-
const bugfix = getFragmentsFilesByFragmentType("fragments", "bugfix");
|
|
43
|
-
const feature = getFragmentsFilesByFragmentType("fragments", "feature");
|
|
44
|
-
|
|
45
|
-
const bugfixData = getFragmentsContent(bugfix);
|
|
46
|
-
const featureData = getFragmentsContent(feature);
|
|
47
|
-
|
|
48
|
-
expect(bugfixData).toEqual(["fake bugfix content"]);
|
|
49
|
-
expect(featureData).toEqual([
|
|
50
|
-
"fake feature content",
|
|
51
|
-
"fake 2 feature content",
|
|
52
|
-
]);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test("should delete fragment files", async () => {
|
|
56
|
-
const bugfix = getFragmentsFilesByFragmentType("fragments", "bugfix");
|
|
57
|
-
const feature = getFragmentsFilesByFragmentType("fragments", "feature");
|
|
58
|
-
|
|
59
|
-
deleteFragmentsFiles(bugfix);
|
|
60
|
-
deleteFragmentsFiles(feature);
|
|
61
|
-
|
|
62
|
-
expect(fs.readdirSync("fragments")).toStrictEqual([".gitkeep"]);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test("should return empty when there is no changelog content", async () => {
|
|
66
|
-
const fakeNewsFragmentsConfig = {
|
|
67
|
-
changelogFile: "CHANGELOG.md",
|
|
68
|
-
};
|
|
69
|
-
expect(getChangelogContent(fakeNewsFragmentsConfig)).toEqual("");
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test("should return the changelog content", async () => {
|
|
73
|
-
mockFs({
|
|
74
|
-
"CHANGELOG.md": "My content bruh",
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const fakeNewsFragmentsConfig = {
|
|
78
|
-
changelogFile: "CHANGELOG.md",
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
expect(getChangelogContent(fakeNewsFragmentsConfig)).toEqual(
|
|
82
|
-
"My content bruh"
|
|
83
|
-
);
|
|
84
|
-
});
|
package/tests/helpers.test.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import fs from "fs-extra";
|
|
2
|
-
import mockFs from "mock-fs";
|
|
3
|
-
|
|
4
|
-
import { checkChangelogFile, checkFragmentsFolder } from "../src/helpers";
|
|
5
|
-
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
mockFs({
|
|
8
|
-
"virtual-env": {},
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
afterEach(() => {
|
|
13
|
-
mockFs.restore();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test("should create a changelog file if doesnt exist", () => {
|
|
17
|
-
const FILE = "virtual-env/CHANGELOG.md";
|
|
18
|
-
expect(fs.existsSync(FILE)).toBeFalsy();
|
|
19
|
-
checkChangelogFile(FILE);
|
|
20
|
-
expect(fs.existsSync(FILE)).toBeTruthy();
|
|
21
|
-
checkChangelogFile(FILE);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("should create a fragments folder with .gitkeep if doesnt exist", () => {
|
|
25
|
-
const FOLDER = "virtual-env/fragments/.gitkeep";
|
|
26
|
-
expect(fs.existsSync(FOLDER)).toBeFalsy();
|
|
27
|
-
checkFragmentsFolder(FOLDER);
|
|
28
|
-
expect(fs.existsSync(FOLDER)).toBeTruthy();
|
|
29
|
-
checkFragmentsFolder(FOLDER);
|
|
30
|
-
});
|
package/tests/index.test.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "fs";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
import mockFs from "mock-fs";
|
|
4
|
-
import moment from "moment";
|
|
5
|
-
|
|
6
|
-
import { newsFragmentsUserConfig } from "../src/config";
|
|
7
|
-
import Plugin from "../src/index";
|
|
8
|
-
|
|
9
|
-
const pjson = JSON.parse(
|
|
10
|
-
readFileSync(new URL("../package.json", import.meta.url))
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
let newsFragments;
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
mockFs({
|
|
17
|
-
fragments: {
|
|
18
|
-
".gitkeep": "",
|
|
19
|
-
"collect-me.feature": "Coleta com sucesso",
|
|
20
|
-
},
|
|
21
|
-
"CHANGELOG.md": "",
|
|
22
|
-
});
|
|
23
|
-
newsFragments = new Plugin();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
afterEach(() => {
|
|
27
|
-
mockFs.restore();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test("should collect a fragment when running init method", () => {
|
|
31
|
-
newsFragments.init();
|
|
32
|
-
expect(newsFragments.fragmentsToBurn).toStrictEqual([
|
|
33
|
-
{ title: "Features", fragmentEntries: ["Coleta com sucesso"] },
|
|
34
|
-
]);
|
|
35
|
-
expect(newsFragments.fragmentsToDelete).toStrictEqual([
|
|
36
|
-
"fragments/collect-me.feature",
|
|
37
|
-
]);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test("should delete fragments when generated changelog", () => {
|
|
41
|
-
const version = pjson.version;
|
|
42
|
-
const date = moment().format("YYYY-MM-DD");
|
|
43
|
-
const expectedOutput = `
|
|
44
|
-
[//]: # (s-${version})
|
|
45
|
-
|
|
46
|
-
# [${version}] - (${date})
|
|
47
|
-
|
|
48
|
-
## Features
|
|
49
|
-
* Coleta com sucesso
|
|
50
|
-
|
|
51
|
-
[//]: # (e-${version})
|
|
52
|
-
|
|
53
|
-
`;
|
|
54
|
-
newsFragments.init();
|
|
55
|
-
newsFragments.bump(version);
|
|
56
|
-
|
|
57
|
-
expect(fs.readdirSync(newsFragmentsUserConfig.fragmentsFolder)).toStrictEqual(
|
|
58
|
-
[".gitkeep"]
|
|
59
|
-
);
|
|
60
|
-
expect(
|
|
61
|
-
fs.readFileSync(newsFragmentsUserConfig.changelogFile, "utf8")
|
|
62
|
-
).toStrictEqual(expectedOutput);
|
|
63
|
-
});
|