Skip to content

Commit 28f2ce0

Browse files
committed
feat: initial commit
0 parents  commit 28f2ce0

File tree

10 files changed

+1465
-0
lines changed

10 files changed

+1465
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/** @type {import('semantic-release').GlobalConfig} */
2+
export default {
3+
branches: ['main'],
4+
plugins: [
5+
'@semantic-release/commit-analyzer',
6+
'@semantic-release/release-notes-generator',
7+
[
8+
'@semantic-release/changelog',
9+
{
10+
changelogFile: 'CHANGELOG.md',
11+
changelogTitle: '# Changelog',
12+
},
13+
],
14+
'@semantic-release/npm',
15+
[
16+
'@semantic-release/git',
17+
{
18+
assets: ['CHANGELOG.md', 'package.json'],
19+
message:
20+
'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
21+
},
22+
],
23+
'@semantic-release/github',
24+
],
25+
};

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
name: Release package
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
issues: write
15+
pull-requests: write
16+
id-token: write
17+
18+
steps:
19+
- name: Checkout repo
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 20
26+
registry-url: "https://registry.npmjs.org/"
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Build
32+
run: npm run build
33+
34+
- name: Semantic release
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
38+
run: npx semantic-release

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# dependencies (bun install)
2+
node_modules
3+
4+
# output
5+
out
6+
dist
7+
*.tgz
8+
9+
# code coverage
10+
coverage
11+
*.lcov
12+
13+
# logs
14+
logs
15+
_.log
16+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
17+
18+
# dotenv environment variable files
19+
.env
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
.env.local
24+
25+
# caches
26+
.eslintcache
27+
.cache
28+
*.tsbuildinfo
29+
30+
# IntelliJ based IDEs
31+
.idea
32+
33+
# Finder (MacOS) folder config
34+
.DS_Store

.vscode/settings.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"editor.defaultFormatter": "biomejs.biome",
3+
"[typescript]": {
4+
"editor.formatOnSave": true
5+
},
6+
"[typescriptreact]": {
7+
"editor.formatOnSave": true
8+
},
9+
"[json]": {
10+
"editor.formatOnSave": true
11+
},
12+
"[javascript]": {
13+
"editor.formatOnSave": true
14+
},
15+
"editor.codeActionsOnSave": {
16+
"quickfix.biome": "explicit",
17+
"source.organizeImports.biome": "explicit"
18+
}
19+
}

biome.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"vcs": {
4+
"enabled": false,
5+
"clientKind": "git",
6+
"useIgnoreFile": false
7+
},
8+
"files": {
9+
"ignoreUnknown": false,
10+
"ignore": []
11+
},
12+
"formatter": {
13+
"enabled": true,
14+
"indentWidth": 4,
15+
"indentStyle": "space"
16+
},
17+
"organizeImports": {
18+
"enabled": true
19+
},
20+
"json": {
21+
"formatter": {
22+
"enabled": true
23+
}
24+
},
25+
"linter": {
26+
"enabled": true,
27+
"rules": {
28+
"recommended": true,
29+
"suspicious": {
30+
"noExplicitAny": "off"
31+
}
32+
}
33+
},
34+
"javascript": {
35+
"formatter": {
36+
"quoteStyle": "single"
37+
}
38+
}
39+
}

bun.lock

Lines changed: 1206 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "who-added",
3+
"version": "0.0.0",
4+
"main": "index.js",
5+
"type": "module",
6+
"bin": {
7+
"who-added": "./dist/index.js"
8+
},
9+
"scripts": {
10+
"build": "tsdown",
11+
"format": "npx @biomejs/biome format --write",
12+
"start": "node --experimental-transform-types --experimental-strip-types index.ts"
13+
},
14+
"keywords": [],
15+
"author": "",
16+
"license": "ISC",
17+
"description": "",
18+
"devDependencies": {
19+
"@biomejs/biome": "^1.9.4",
20+
"@types/node": "^22.14.1",
21+
"semantic-release": "^24.2.3",
22+
"tsdown": "^0.9.6",
23+
"typescript": "^5.8.3"
24+
},
25+
"private": true
26+
}

src/index.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env node
2+
3+
import { execSync } from 'node:child_process';
4+
import { parseArgs } from 'node:util';
5+
6+
const { values, positionals } = parseArgs({
7+
options: {
8+
dependency: { type: 'string', short: 'd' },
9+
file: { type: 'string', short: 'f', default: 'package.json' },
10+
},
11+
strict: false,
12+
allowPositionals: true,
13+
});
14+
15+
const dep = values.dependency || positionals[0];
16+
const file = values.file;
17+
18+
if (!dep) {
19+
console.error('Error: dependency name is required.');
20+
console.error('Usage: who-added --dependency react [--file package.json]');
21+
process.exit(1);
22+
}
23+
24+
const gitCmd = [
25+
'git',
26+
'log',
27+
'--reverse',
28+
`-S'"${dep}\":'`,
29+
"--pretty=format:'%H %an %ad %s'",
30+
'--',
31+
file,
32+
].join(' ');
33+
34+
try {
35+
const output = execSync(gitCmd, {
36+
encoding: 'utf8',
37+
stdio: ['ignore', 'pipe', 'inherit'],
38+
});
39+
const firstLine = output.split('\n')[0];
40+
if (!firstLine) {
41+
console.log(
42+
`No commits found adding or removing '"${dep}\":' in ${file}.`,
43+
);
44+
} else {
45+
console.log('First commit introducing dependency:');
46+
console.log(firstLine);
47+
}
48+
} catch (err) {
49+
console.error('Error running git command:', err);
50+
process.exit(1);
51+
}

tsconfig.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"compilerOptions": {
3+
"esModuleInterop": true,
4+
"skipLibCheck": true,
5+
"target": "es2022",
6+
"allowJs": true,
7+
"resolveJsonModule": true,
8+
"moduleDetection": "force",
9+
"isolatedModules": true,
10+
"verbatimModuleSyntax": true,
11+
"erasableSyntaxOnly": true,
12+
"strict": true,
13+
"noUncheckedIndexedAccess": true,
14+
"noImplicitOverride": true,
15+
16+
"module": "NodeNext",
17+
"outDir": "dist",
18+
"sourceMap": true,
19+
20+
"lib": ["es2022"]
21+
}
22+
}

tsdown.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { defineConfig } from 'tsdown';
2+
3+
export default defineConfig({
4+
entry: ['./src'],
5+
});

0 commit comments

Comments
 (0)