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のバージョンをあげるスクリプトv2

Posted at

前回作成したスクリプトだが、biomeはcli以外にもいろいろreleaseしているので動かないときがあった。
よって、release全体からcliに限定して取得するように変更。

import { readFileSync, writeFileSync } from "fs";

const f = await fetch(
    //latestではなくreleases全体を取得します
	"https://api.github.com/repos/biomejs/biome/releases",
);

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 cli = fetchedJson.find((v) => {
    // nightlyは危険なのであげません。
	if (v.tag_name.includes("nightly")) return false;
	return v.tag_name.includes("cli");
});

const tag_name = getVersion(cli.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}`;
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?