@rindrics/initrepo 0.0.1 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/codeql/codeql-config.yml +7 -0
- package/.github/dependabot.yml +11 -0
- package/.github/release.yml +4 -0
- package/.github/workflows/ci.yml +67 -0
- package/.github/workflows/codeql.yml +46 -0
- package/.github/workflows/publish.yml +35 -0
- package/.github/workflows/tagpr.yml +21 -0
- package/.husky/commit-msg +1 -0
- package/.husky/pre-push +2 -0
- package/.tagpr +7 -0
- package/.tool-versions +1 -0
- package/CHANGELOG.md +28 -0
- package/README.md +40 -28
- package/biome.json +38 -0
- package/bun.lock +334 -0
- package/commitlint.config.js +3 -0
- package/dist/cli.js +11215 -0
- package/docs/adr/0001-simple-module-structure-over-ddd.md +111 -0
- package/package.json +37 -7
- package/src/cli.test.ts +20 -0
- package/src/cli.ts +27 -0
- package/src/commands/init.test.ts +170 -0
- package/src/commands/init.ts +172 -0
- package/src/commands/prepare-release.test.ts +183 -0
- package/src/commands/prepare-release.ts +354 -0
- package/src/config.ts +13 -0
- package/src/generators/project.test.ts +363 -0
- package/src/generators/project.ts +300 -0
- package/src/templates/common/dependabot.yml.ejs +12 -0
- package/src/templates/common/release.yml.ejs +4 -0
- package/src/templates/common/workflows/tagpr.yml.ejs +31 -0
- package/src/templates/typescript/.tagpr.ejs +5 -0
- package/src/templates/typescript/codeql/codeql-config.yml.ejs +7 -0
- package/src/templates/typescript/package.json.ejs +29 -0
- package/src/templates/typescript/src/index.ts.ejs +1 -0
- package/src/templates/typescript/tsconfig.json.ejs +17 -0
- package/src/templates/typescript/workflows/ci.yml.ejs +58 -0
- package/src/templates/typescript/workflows/codeql.yml.ejs +46 -0
- package/src/types.ts +13 -0
- package/src/utils/github-repo.test.ts +34 -0
- package/src/utils/github-repo.ts +141 -0
- package/src/utils/github.ts +47 -0
- package/src/utils/npm.test.ts +99 -0
- package/src/utils/npm.ts +59 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "npm" # See documentation for possible values
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "weekly"
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
push:
|
|
8
|
+
branches:
|
|
9
|
+
- main
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
changes:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
outputs:
|
|
18
|
+
src: ${{ steps.filter.outputs.src }}
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v6
|
|
21
|
+
|
|
22
|
+
- uses: dorny/paths-filter@v3
|
|
23
|
+
id: filter
|
|
24
|
+
with:
|
|
25
|
+
filters: |
|
|
26
|
+
src:
|
|
27
|
+
- 'src/**'
|
|
28
|
+
- 'package.json'
|
|
29
|
+
- 'tsconfig.json'
|
|
30
|
+
- 'biome.json'
|
|
31
|
+
- 'bun.lock'
|
|
32
|
+
- '.github/workflows/ci.yml'
|
|
33
|
+
|
|
34
|
+
check:
|
|
35
|
+
needs: changes
|
|
36
|
+
if: needs.changes.outputs.src == 'true'
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v6
|
|
40
|
+
|
|
41
|
+
- uses: oven-sh/setup-bun@v2
|
|
42
|
+
with:
|
|
43
|
+
bun-version: latest
|
|
44
|
+
|
|
45
|
+
- run: bun install --frozen-lockfile
|
|
46
|
+
|
|
47
|
+
- name: Biome check
|
|
48
|
+
run: bun run check
|
|
49
|
+
|
|
50
|
+
- name: TypeScript check
|
|
51
|
+
run: bun run build
|
|
52
|
+
|
|
53
|
+
test:
|
|
54
|
+
needs: changes
|
|
55
|
+
if: needs.changes.outputs.src == 'true'
|
|
56
|
+
runs-on: ubuntu-latest
|
|
57
|
+
steps:
|
|
58
|
+
- uses: actions/checkout@v6
|
|
59
|
+
|
|
60
|
+
- uses: oven-sh/setup-bun@v2
|
|
61
|
+
with:
|
|
62
|
+
bun-version: latest
|
|
63
|
+
|
|
64
|
+
- run: bun install --frozen-lockfile
|
|
65
|
+
|
|
66
|
+
- name: Test
|
|
67
|
+
run: bun test
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: CodeQL
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
paths:
|
|
7
|
+
- 'src/**'
|
|
8
|
+
- 'package.json'
|
|
9
|
+
- 'tsconfig.json'
|
|
10
|
+
- '.github/workflows/codeql.yml'
|
|
11
|
+
pull_request:
|
|
12
|
+
branches: [main]
|
|
13
|
+
paths:
|
|
14
|
+
- 'src/**'
|
|
15
|
+
- 'package.json'
|
|
16
|
+
- 'tsconfig.json'
|
|
17
|
+
- '.github/workflows/codeql.yml'
|
|
18
|
+
schedule:
|
|
19
|
+
# Run weekly on Sunday at 00:00 UTC
|
|
20
|
+
- cron: '0 0 * * 0'
|
|
21
|
+
workflow_dispatch:
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
analyze:
|
|
25
|
+
name: Analyze
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
timeout-minutes: 10
|
|
28
|
+
permissions:
|
|
29
|
+
actions: read
|
|
30
|
+
contents: read
|
|
31
|
+
security-events: write
|
|
32
|
+
|
|
33
|
+
steps:
|
|
34
|
+
- name: Checkout repository
|
|
35
|
+
uses: actions/checkout@v6
|
|
36
|
+
|
|
37
|
+
- name: Initialize CodeQL
|
|
38
|
+
uses: github/codeql-action/init@v3
|
|
39
|
+
with:
|
|
40
|
+
languages: javascript-typescript
|
|
41
|
+
config-file: ./.github/codeql/codeql-config.yml
|
|
42
|
+
|
|
43
|
+
- name: Perform CodeQL Analysis
|
|
44
|
+
uses: github/codeql-action/analyze@v3
|
|
45
|
+
with:
|
|
46
|
+
category: '/language:javascript-typescript'
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
id-token: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
publish:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v6
|
|
18
|
+
|
|
19
|
+
- uses: oven-sh/setup-bun@v2
|
|
20
|
+
|
|
21
|
+
- uses: actions/setup-node@v6
|
|
22
|
+
with:
|
|
23
|
+
node-version: '24'
|
|
24
|
+
registry-url: 'https://registry.npmjs.org'
|
|
25
|
+
|
|
26
|
+
- run: bun install --frozen-lockfile
|
|
27
|
+
|
|
28
|
+
- name: Build
|
|
29
|
+
run: bun run build
|
|
30
|
+
|
|
31
|
+
- name: Test
|
|
32
|
+
run: bun test
|
|
33
|
+
|
|
34
|
+
- name: Publish to npm with provenance
|
|
35
|
+
run: npm publish --access public --provenance
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: tagpr
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
tagpr:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
pull-requests: write
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v6
|
|
16
|
+
with:
|
|
17
|
+
token: ${{ secrets.PAT_FOR_TAGPR }}
|
|
18
|
+
|
|
19
|
+
- uses: Songmu/tagpr@v1
|
|
20
|
+
env:
|
|
21
|
+
GITHUB_TOKEN: ${{ secrets.PAT_FOR_TAGPR }}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bunx --no -- commitlint --edit $1
|
package/.husky/pre-push
ADDED
package/.tagpr
ADDED
package/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bun 1.3.5
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [v0.1.5](https://github.com/Rindrics/initrepo/compare/v0.1.4...v0.1.5) - 2025-12-28
|
|
4
|
+
- fix: correct binary name by @Rindrics in https://github.com/Rindrics/initrepo/pull/18
|
|
5
|
+
|
|
6
|
+
## [v0.1.4](https://github.com/Rindrics/initrepo/compare/v0.1.3...v0.1.4) - 2025-12-28
|
|
7
|
+
- ci: use Node.js 24 to use npm 11.6 by @Rindrics in https://github.com/Rindrics/initrepo/pull/15
|
|
8
|
+
|
|
9
|
+
## [v0.1.4](https://github.com/Rindrics/initrepo/compare/v0.1.3...v0.1.4) - 2025-12-28
|
|
10
|
+
- ci: use Node.js 24 to use npm 11.6 by @Rindrics in https://github.com/Rindrics/initrepo/pull/15
|
|
11
|
+
|
|
12
|
+
## [v0.1.3](https://github.com/Rindrics/initrepo/compare/v0.1.2...v0.1.3) - 2025-12-28
|
|
13
|
+
- ci: update npm to use OIDC by @Rindrics in https://github.com/Rindrics/initrepo/pull/13
|
|
14
|
+
|
|
15
|
+
## [v0.1.2](https://github.com/Rindrics/initrepo/compare/v0.1.1...v0.1.2) - 2025-12-28
|
|
16
|
+
- ci: use OIDC by @Rindrics in https://github.com/Rindrics/initrepo/pull/11
|
|
17
|
+
|
|
18
|
+
## [v0.1.1](https://github.com/Rindrics/setup-repo/compare/v0.1.0...v0.1.1) - 2025-12-28
|
|
19
|
+
- fix: use bun on CI by @Rindrics in https://github.com/Rindrics/setup-repo/pull/9
|
|
20
|
+
|
|
21
|
+
## [v0.1.0](https://github.com/Rindrics/setup-repo/compare/v0.0.1...v0.1.0) - 2025-12-28
|
|
22
|
+
- feat: enable initialization and release for TypeScript project by @Rindrics in https://github.com/Rindrics/setup-repo/pull/6
|
|
23
|
+
- feat: initialize GitHub repo by init command by @Rindrics in https://github.com/Rindrics/setup-repo/pull/8
|
|
24
|
+
|
|
25
|
+
## [v0.0.1](https://github.com/Rindrics/setup-repo/commits/v0.0.1) - 2025-12-27
|
|
26
|
+
- build(deps): bump octokit from 4.1.4 to 5.0.5 by @dependabot[bot] in https://github.com/Rindrics/setup-repo/pull/3
|
|
27
|
+
- build(deps-dev): bump @commitlint/config-conventional from 19.8.1 to 20.2.0 by @dependabot[bot] in https://github.com/Rindrics/setup-repo/pull/4
|
|
28
|
+
- build(deps): bump commander from 12.1.0 to 14.0.2 by @dependabot[bot] in https://github.com/Rindrics/setup-repo/pull/2
|
package/README.md
CHANGED
|
@@ -1,45 +1,57 @@
|
|
|
1
1
|
# @rindrics/initrepo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
CLI tool for rapid repository setup with CI/CD, code quality tools, and release automation via [tagpr](https://github.com/Songmu/tagpr).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @rindrics/initrepo
|
|
9
|
+
```
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## Usage
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
1. Configure OIDC trusted publishing for the package name `@rindrics/initrepo`
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
13
|
+
### Create a new project
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
```bash
|
|
16
|
+
# Interactive mode (prompts for options)
|
|
17
|
+
initrepo init my-super-project
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
# Non-interactive mode
|
|
20
|
+
initrepo init my-super-project --devcode --create-repo --private
|
|
21
|
+
```
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
Options:
|
|
24
|
+
- `-d, --devcode` - Use devcode mode (adds `private: true` to package.json)
|
|
25
|
+
- `--create-repo` - Create GitHub repository with tagpr labels
|
|
26
|
+
- `-p, --private` - Make GitHub repository private
|
|
27
|
+
- `-a, --author <name>` - Package author
|
|
21
28
|
|
|
22
|
-
|
|
29
|
+
Requires `GITHUB_TOKEN` environment variable for repository creation.
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
31
|
+
### Prepare for release
|
|
28
32
|
|
|
29
|
-
|
|
33
|
+
When ready to publish, convert your devcode project:
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
- Exists only for administrative purposes
|
|
35
|
+
```bash
|
|
36
|
+
cd my-super-project
|
|
37
|
+
initrepo prepare-release @scope/my-package
|
|
38
|
+
```
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
This will:
|
|
41
|
+
- Update `package.json` name and remove `private: true`
|
|
42
|
+
- Configure workflows for `PAT_FOR_TAGPR`
|
|
43
|
+
- Report any unmanaged occurrences of the devcode name for manual review
|
|
38
44
|
|
|
39
|
-
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
45
|
+
### Setup for automated releases
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
1. **Create a PAT** at https://github.com/settings/tokens/new
|
|
48
|
+
- Permissions: `repo` (or `public_repo`), `workflow`
|
|
49
|
+
- Add as repository secret: `PAT_FOR_TAGPR`
|
|
44
50
|
|
|
45
|
-
**
|
|
51
|
+
2. **Configure npm for GitHub Actions publishing**
|
|
52
|
+
- Go to npmjs.com → Package Settings → Publishing access
|
|
53
|
+
- Add your repository to trusted publishers
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|
package/biome.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.3.10/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": true
|
|
7
|
+
},
|
|
8
|
+
"files": {
|
|
9
|
+
"ignoreUnknown": false
|
|
10
|
+
},
|
|
11
|
+
"formatter": {
|
|
12
|
+
"enabled": true,
|
|
13
|
+
"indentStyle": "space",
|
|
14
|
+
"indentWidth": 2,
|
|
15
|
+
"formatWithErrors": true
|
|
16
|
+
},
|
|
17
|
+
"linter": {
|
|
18
|
+
"enabled": true,
|
|
19
|
+
"rules": {
|
|
20
|
+
"recommended": true
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"assist": {
|
|
24
|
+
"actions": {
|
|
25
|
+
"source": {
|
|
26
|
+
"organizeImports": {
|
|
27
|
+
"level": "on"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"javascript": {
|
|
33
|
+
"formatter": {
|
|
34
|
+
"quoteStyle": "single",
|
|
35
|
+
"semicolons": "always"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|