Skip to content

Commit c67c75b

Browse files
authored
chore: use changesets (#201)
1 parent c1a2ad8 commit c67c75b

File tree

9 files changed

+168
-66
lines changed

9 files changed

+168
-66
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{
6+
"repo": "ota-meshi/eslint-plugin-json-schema-validator"
7+
}
8+
],
9+
"commit": false,
10+
"linked": [],
11+
"baseBranch": "main",
12+
"updateInternalDependencies": "patch",
13+
"bumpVersionsWithWorkspaceProtocolOnly": true,
14+
"ignore": []
15+
}

.env-cmdrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
},
88
"version": {
99
"IN_VERSION_SCRIPT": "true"
10+
},
11+
"version-ci": {
12+
"IN_VERSION_CI_SCRIPT": "true"
1013
}
1114
}

.github/workflows/NpmPublish.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/Release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout Repo
14+
uses: actions/checkout@v3
15+
with:
16+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
17+
fetch-depth: 0
18+
19+
- name: Setup Node.js 16
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: 18
23+
24+
- name: Install Dependencies
25+
run: npm install
26+
- name: Build
27+
run: npm run build
28+
29+
- name: Create Release Pull Request or Publish to npm
30+
id: changesets
31+
uses: changesets/action@v1
32+
with:
33+
# this expects you to have a npm script called version that runs some logic and then calls `changeset version`.
34+
version: npm run version:ci
35+
# This expects you to have a script called release which does a build for your packages and calls changeset publish
36+
publish: npm run release
37+
commit: "chore: release eslint-plugin-json-schema-validator"
38+
title: "chore: release eslint-plugin-json-schema-validator"
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@
3636
"new": "yarn ts ./tools/new-rule",
3737
"prebuild": "yarn -s clean",
3838
"predocs:watch": "yarn build:ts",
39+
"prerelease": "yarn test && yarn build",
3940
"preversion": "yarn test && git add .",
41+
"release": "changeset publish",
4042
"test": "env-cmd -e test yarn mocha \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
4143
"ts": "env-cmd -e base node -r esbuild-register",
4244
"update": "yarn ts ./tools/update && yarn lint-fix",
43-
"version": "env-cmd -e version yarn update && git add ."
45+
"version": "env-cmd -e version yarn update && git add .",
46+
"version:ci": "env-cmd -e version-ci yarn update && changeset version"
4447
},
4548
"peerDependencies": {
4649
"eslint": ">=6.0.0"
@@ -59,6 +62,8 @@
5962
},
6063
"devDependencies": {
6164
"@actions/core": "^1.2.6",
65+
"@changesets/changelog-github": "^0.4.6",
66+
"@changesets/cli": "^2.24.2",
6267
"@ota-meshi/eslint-plugin": "^0.13.0",
6368
"@types/debug": "^4.1.5",
6469
"@types/eslint": "^8.0.0",
@@ -105,5 +110,8 @@
105110
"vue-eslint-parser": "^9.0.0",
106111
"vuepress": "^1.5.2",
107112
"yaml": "^2.1.1"
113+
},
114+
"publishConfig": {
115+
"access": "public"
108116
}
109117
}

src/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ export interface RuleMetaData {
2323
url: string;
2424
ruleId: string;
2525
ruleName: string;
26-
replacedBy?: string[];
2726
default?: "error" | "warn";
2827
};
2928
messages: { [messageId: string]: string };
3029
fixable?: "code" | "whitespace";
30+
hasSuggestions?: boolean;
3131
schema: JSONSchema4 | JSONSchema4[];
3232
deprecated?: boolean;
33+
replacedBy?: string[];
3334
type: "problem" | "suggestion" | "layout";
3435
}
3536

@@ -45,13 +46,14 @@ export interface PartialRuleMetaData {
4546
docs: {
4647
description: string;
4748
categories: "recommended"[] | null;
48-
replacedBy?: string[];
4949
default?: "error" | "warn";
5050
};
5151
messages: { [messageId: string]: string };
5252
fixable?: "code" | "whitespace";
53+
hasSuggestions?: boolean;
5354
schema: JSONSchema4 | JSONSchema4[];
5455
deprecated?: boolean;
56+
replacedBy?: string[];
5557
type: "problem" | "suggestion" | "layout";
5658
}
5759

tools/lib/changesets-util.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import assembleReleasePlan from "@changesets/assemble-release-plan";
2+
import readChangesets from "@changesets/read";
3+
import { read } from "@changesets/config";
4+
import { getPackages } from "@manypkg/get-packages";
5+
import { readPreState } from "@changesets/pre";
6+
import path from "path";
7+
8+
const root = path.resolve(__dirname, "../..");
9+
10+
/** Get new version string from changesets */
11+
export async function getNewVersion(): Promise<string> {
12+
const packages = await getPackages(root);
13+
const preState = await readPreState(root);
14+
const config = await read(root, packages);
15+
const changesets = await readChangesets(root);
16+
17+
const releasePlan = assembleReleasePlan(
18+
changesets,
19+
packages,
20+
config,
21+
preState
22+
);
23+
24+
return releasePlan.releases.find(
25+
({ name }) => name === "eslint-plugin-json-schema-validator"
26+
)!.newVersion;
27+
}

0 commit comments

Comments
 (0)