@mlaursen/eslint-config 1.3.0 → 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/CHANGELOG.md +7 -0
- package/package.json +22 -7
- package/scripts/release.ts +142 -0
- package/tsconfig.json +19 -0
- package/tsconfig.node.json +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.4.0](https://github.com/mlaursen/eslint-config/compare/v1.3.0...v1.4.0) (2022-01-11)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **deps:** bump all dependencies to latest ([0e7b8f5](https://github.com/mlaursen/eslint-config/commit/0e7b8f5042d5b99bceaa47d10e0316496e857944))
|
|
11
|
+
|
|
5
12
|
## [1.3.0](https://github.com/mlaursen/eslint-config/compare/v1.2.0...v1.3.0) (2022-01-01)
|
|
6
13
|
|
|
7
14
|
|
package/package.json
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mlaursen/eslint-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "An eslint config used by mlaursen for most projects.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "https://github.com/mlaursen/eslint-config.git",
|
|
7
7
|
"author": "Mikkel Laursen <mlaursen03@gmail.com>",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"
|
|
10
|
+
"run-script": "ts-node -T -P tsconfig.node.json",
|
|
11
|
+
"release": "yarn run-script scripts/release.ts"
|
|
11
12
|
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/mlaursen/eslint-config/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"eslint",
|
|
18
|
+
"typescript"
|
|
19
|
+
],
|
|
12
20
|
"dependencies": {
|
|
13
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
14
|
-
"@typescript-eslint/parser": "^5.
|
|
21
|
+
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
|
22
|
+
"@typescript-eslint/parser": "^5.9.1",
|
|
15
23
|
"confusing-browser-globals": "^1.0.11",
|
|
16
24
|
"eslint-config-prettier": "^8.2.0",
|
|
17
|
-
"eslint-plugin-import": "^2.25.
|
|
18
|
-
"eslint-plugin-jest": "^25.3.
|
|
25
|
+
"eslint-plugin-import": "^2.25.4",
|
|
26
|
+
"eslint-plugin-jest": "^25.3.4",
|
|
19
27
|
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
20
28
|
"eslint-plugin-react": "^7.28.0",
|
|
21
29
|
"eslint-plugin-react-hooks": "^4.3.0",
|
|
@@ -23,7 +31,14 @@
|
|
|
23
31
|
},
|
|
24
32
|
"devDependencies": {
|
|
25
33
|
"@mlaursen/changelog-preset": "^1.1.0",
|
|
26
|
-
"
|
|
34
|
+
"@octokit/core": "^3.5.1",
|
|
35
|
+
"@types/inquirer": "^8.1.3",
|
|
36
|
+
"@types/node": "^17.0.8",
|
|
37
|
+
"dotenv": "^11.0.0",
|
|
38
|
+
"inquirer": "^8.2.0",
|
|
39
|
+
"standard-version": "^9.3.2",
|
|
40
|
+
"ts-node": "^10.4.0",
|
|
41
|
+
"typescript": "^4.5.4"
|
|
27
42
|
},
|
|
28
43
|
"peerDependencies": {
|
|
29
44
|
"eslint": ">= 8.0.0",
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Octokit } from "@octokit/core";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
import dotenv from "dotenv";
|
|
4
|
+
import inquirer from "inquirer";
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
|
|
8
|
+
function loggedCommand(command: string): void {
|
|
9
|
+
console.log(command);
|
|
10
|
+
execSync(command, { stdio: "inherit" });
|
|
11
|
+
console.log("");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function undo(version?: string): void {
|
|
15
|
+
loggedCommand("git reset HEAD^");
|
|
16
|
+
if (typeof version === "string") {
|
|
17
|
+
loggedCommand(`git tag -d v${version}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const NEW_ENTRY = /^#{1,3}\s+\[\d/;
|
|
22
|
+
|
|
23
|
+
async function getReleaseNotes(version: string): Promise<string> {
|
|
24
|
+
console.log("Update the CHANGELOG.md with any additional changes.");
|
|
25
|
+
const { confirmed } = await inquirer.prompt<{ confirmed: boolean }>([
|
|
26
|
+
{
|
|
27
|
+
type: "confirm",
|
|
28
|
+
name: "confirmed",
|
|
29
|
+
message: "Continue the release?",
|
|
30
|
+
},
|
|
31
|
+
]);
|
|
32
|
+
if (!confirmed) {
|
|
33
|
+
console.error("Canceling the release.");
|
|
34
|
+
undo(version);
|
|
35
|
+
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const changelog = readFileSync(join(process.cwd(), "CHANGELOG.md"), "utf8");
|
|
40
|
+
const lines = changelog.split(/\r?\n/);
|
|
41
|
+
let lastEntryStart = -1;
|
|
42
|
+
let nextEntryStart = -1;
|
|
43
|
+
|
|
44
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
45
|
+
if (NEW_ENTRY.test(lines[i])) {
|
|
46
|
+
if (lastEntryStart === -1) {
|
|
47
|
+
lastEntryStart = i + 1;
|
|
48
|
+
} else if (nextEntryStart === -1) {
|
|
49
|
+
nextEntryStart = i;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (lastEntryStart === -1 || nextEntryStart === -1) {
|
|
56
|
+
console.error("Unable to find a release block.");
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return lines.slice(lastEntryStart, nextEntryStart).join("\n");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const RELEASE_TYPES = ["major", "minor", "patch"];
|
|
64
|
+
|
|
65
|
+
async function run(): Promise<void> {
|
|
66
|
+
let type = "";
|
|
67
|
+
let prerelease = "";
|
|
68
|
+
for (let i = 0; i < process.argv.length; i += 1) {
|
|
69
|
+
const flag = process.argv[i];
|
|
70
|
+
const value = process.argv[i + 1];
|
|
71
|
+
if (
|
|
72
|
+
flag === "-t" &&
|
|
73
|
+
typeof value === "string" &&
|
|
74
|
+
RELEASE_TYPES.includes(value)
|
|
75
|
+
) {
|
|
76
|
+
type = ` --release-as ${value}`;
|
|
77
|
+
} else if (flag === "-p" || flag === "--prerelease") {
|
|
78
|
+
prerelease = " --prerelease";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const githubDotEnv = join(process.cwd(), ".env.github");
|
|
83
|
+
dotenv.config({ path: githubDotEnv });
|
|
84
|
+
|
|
85
|
+
const { GITHUB_TOKEN } = process.env;
|
|
86
|
+
if (!GITHUB_TOKEN) {
|
|
87
|
+
console.error(
|
|
88
|
+
`Missing a \`GITHUB_TOKEN\` environment variable. This should be located at:
|
|
89
|
+
- ${githubDotEnv}
|
|
90
|
+
|
|
91
|
+
A token can be created at:
|
|
92
|
+
- https://github.com/settings/tokens/new?scopes=repo
|
|
93
|
+
`
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
loggedCommand(`yarn standard-version${type}${prerelease}`);
|
|
100
|
+
|
|
101
|
+
const { version } = JSON.parse(
|
|
102
|
+
readFileSync(join(process.cwd(), "package.json"), "utf8")
|
|
103
|
+
);
|
|
104
|
+
if (typeof version !== "string") {
|
|
105
|
+
console.error("Unable to get the package version.");
|
|
106
|
+
undo();
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const releaseNotes = await getReleaseNotes(version);
|
|
111
|
+
const { confirmed } = await inquirer.prompt<{ confirmed: boolean }>([
|
|
112
|
+
{
|
|
113
|
+
type: "confirm",
|
|
114
|
+
name: "confirmed",
|
|
115
|
+
message: `Open the authenticator app to get a one-time password and run the following command:
|
|
116
|
+
|
|
117
|
+
npm publish --otp
|
|
118
|
+
`,
|
|
119
|
+
},
|
|
120
|
+
]);
|
|
121
|
+
if (!confirmed) {
|
|
122
|
+
console.error("Canceling the release.");
|
|
123
|
+
undo(version);
|
|
124
|
+
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
loggedCommand("git push --follow-tags origin main");
|
|
128
|
+
const octokit = new Octokit({ auth: GITHUB_TOKEN });
|
|
129
|
+
const response = await octokit.request(
|
|
130
|
+
"POST /repos/{owner}/{repo}/releases",
|
|
131
|
+
{
|
|
132
|
+
owner: "mlaursen",
|
|
133
|
+
repo: "eslint-config",
|
|
134
|
+
tag_name: `v${version}`,
|
|
135
|
+
body: releaseNotes,
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
console.log(`Created release: ${response.data.html_url}`);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
run();
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"strict": true,
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true,
|
|
11
|
+
"allowSyntheticDefaultImports": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"lib": [
|
|
14
|
+
"dom",
|
|
15
|
+
"dom.iterable",
|
|
16
|
+
"esnext"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
}
|