0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

biome.jsのバージョンをあげるスクリプト

Posted at
  1. fetchで公式のreleasesのlatestを取得する
  2. jsonから最新のバージョンを確定する
  3. biome.jsonの$shemaのバージョンを書き換える
  4. pnpm updateなどでバージョンをあげる
import { readFileSync, writeFileSync } from "fs";

const f = await fetch(
	"https://api.github.com/repos/biomejs/biome/releases/latest",
);

const fetchedJson = await f.json();

/* 
cli/v1.4.1 -> 1.4.1
*/
const getVersion = (str) => {
	const arr = str.split("/");
	const version = arr[arr.length - 1];
	/* vを取る */
	if (version[0] === "v") {
		return version.slice(1);
	}
	return version;
};

const tag_name = getVersion(fetchedJson.tag_name);

/* biome.jsonの中身も書き換える */
const biomejson = JSON.parse(readFileSync("./biome.json", "utf-8"));
const result = {
	...biomejson,
	$schema: `https://biomejs.dev/schemas/${tag_name}/schema.json`,
};

/* over write */
writeFileSync("./biome.json", JSON.stringify(result, null, 2));

/* install */
await $`pnpm update --save-exact @biomejs/biome@${tag_name}`;

モノレポのプロジェクトごとにバージョンあげるの面倒臭くなったので。
zxで動かします。これをbiome_updateみたいなコマンドにしておいて、turborepoで実行してあげれば自動的にすべてのプロジェクトでbiomeのバージョンが上がります。

バージョンの取得部分がちょっと汚いが、まあ動けばOK……。
const fとかも雑プログラムの悪いところが出ているが、次にスクリプトに手を入れるときに綺麗にしよう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?