Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git commit message template, package.json.name initializer #22

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitmessage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Need Conventional Commit
see https://conventionalcommits.org/

feat: A new feature
fix: A bug fix
docs: Documentation only changes
style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
refactor: A code change that neither fixes a bug nor adds a feature
perf: A code change that improves performance
test: Adding missing or correcting existing tests
chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
Binary file modified bun.lockb
Binary file not shown.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"name": "bun",
"name": "<default>",
"version": "0.0.0",
"type": "module",
"main": "index.js",
Expand All @@ -13,7 +13,8 @@
"@types/bun": "latest",
"lefthook": "1.8.2",
"textlint": "14.3.0",
"textlint-rule-preset-ja-technical-writing": "10.0.1"
"textlint-rule-preset-ja-technical-writing": "10.0.1",
"type-fest": "^4.26.1"
},
"peerDependencies": {
"typescript": "5.6.3"
Expand Down
33 changes: 30 additions & 3 deletions scripts/dev.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
import { $ } from "bun";
import type { PackageJson } from "type-fest";
import packageJson from "../package.json" with { type: "json" };

if (process.env.NODE_ENV === "development") {
await Promise.all([$`bunx lefthook install`]);
console.log("To get started developing: edit src/server.ts and `bun start`");
if (process.env.NODE_ENV !== "development") {
console.error("NODE_ENV is not development.");
process.exit(1);
}

await Promise.all([
$`bunx lefthook install`,
$`git config commit.template .gitmessage.txt`,
]);
// main tasks
const repoName: string | undefined = new URL(import.meta.url).href
.split("/")
// [..., -3: project root dir, -2: "scripts", -1: "dev.ts"]
.at(-3);
if (repoName == null) {
throw new Error("cannot get cwd name");
}

const newPackageJson: PackageJson = {};
// name
if (packageJson.name == null || packageJson.name === "<default>") {
newPackageJson.name = repoName;
}

await $`bun fmt`;
await $`git add .`;
await $`git commit --amend-m "Initial commit (via bun create)"`;

console.log("To get started developing: edit src/server.ts and `bun start`");