Skip to content

Commit

Permalink
Merge pull request #112 from mogeko/dev
Browse files Browse the repository at this point in the history
Rewrite build scripts with TypeScript
  • Loading branch information
mogeko authored Jun 17, 2024
2 parents a66c158 + 9c76ddd commit 840b792
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 67 deletions.
14 changes: 0 additions & 14 deletions .github/changeset-version.cjs

This file was deleted.

25 changes: 25 additions & 0 deletions .github/changeset-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ORIGINALLY FROM CLOUDFLARE WRANGLER:
// https://github.com/cloudflare/wrangler2/blob/main/.github/changeset-version.js

import { exec } from "node:child_process";
import util from "node:util";

const execPromise = util.promisify(exec);

try {
const results = [
// This script is used by the `release.yml` workflow to update the version of the packages being released.
// The standard step is only to run `changeset version` but this does not update the pnpm-lock.yaml file.
// So we also run `pnpm install`, which does this update.
// This is a workaround until this is handled automatically by `changeset version`.
// See https://github.com/changesets/changesets/issues/421.
await execPromise("pnpm changeset version"),
// Run `pnpm install` to update the pnpm-lock.yaml file.
await execPromise("pnpm install --lockfile-only"),
];

console.log(results.map(({ stdout, stderr }) => stdout || stderr).join("\n"));
} catch (error) {
console.error(error.message);
process.exit(1);
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@
"build": "turbo run build && pnpm run meta",
"test": "turbo run test",
"cov": "turbo run cov",
"meta": "node ./scripts/meta.cjs",
"meta": "vite-node ./scripts/meta.ts",
"lint": "turbo run lint",
"fmt": "turbo run fmt"
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.5",
"@types/node": "^20.14.2",
"prettier": "^3.3.2",
"turbo": "^2.0.4",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"vite-node": "^1.6.0"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
36 changes: 22 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 0 additions & 37 deletions scripts/meta.cjs

This file was deleted.

30 changes: 30 additions & 0 deletions scripts/meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import fs from "node:fs/promises";
import path from "node:path";
import pkg from "../package.json";

const releasePath = path.resolve(__dirname, "../release");
const releaseFiles = await fs.readdir(releasePath);
const baseURL = process.env.BASE_URL || "https://mogeko.github.io/userscripts";

const meta = {
name: pkg.name,
description: pkg.description,
homepage: pkg.homepage,
author: pkg.author,
license: pkg.license,
resource: releaseFiles
.filter((file) => !file.endsWith("index.json"))
.map((file) => [baseURL, file].join("/")),
packer: "https://www.npmjs.com/package/vite",
env: {
NODE_VERSION: process.version,
RUNNER_OS: process.env.RUNNER_OS,
RUNNER_ARCH: process.env.RUNNER_ARCH,
},
date: new Date(Date.now()).toISOString(),
};

await fs.writeFile(
path.resolve(__dirname, "../release/index.json"),
JSON.stringify(meta, null, 2)
);

0 comments on commit 840b792

Please sign in to comment.