@rindrics/initrepo 0.2.1 → 0.3.0
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/workflows/tagpr.yml +3 -1
- package/CHANGELOG.md +4 -0
- package/dist/cli.js +91 -1
- package/package.json +1 -1
- package/renovate.json +14 -0
- package/src/cli.ts +2 -0
- package/src/commands/setup-tagpr.ts +147 -0
- package/.github/dependabot.yml +0 -11
|
@@ -16,11 +16,13 @@ jobs:
|
|
|
16
16
|
with:
|
|
17
17
|
token: ${{ secrets.PAT_FOR_TAGPR }}
|
|
18
18
|
|
|
19
|
-
- name: Configure SSH signing
|
|
19
|
+
- name: Configure Git and SSH signing
|
|
20
20
|
run: |
|
|
21
21
|
mkdir -p ~/.ssh
|
|
22
22
|
echo "${{ secrets.SSH_SIGNING_KEY }}" > ~/.ssh/signing_key
|
|
23
23
|
chmod 600 ~/.ssh/signing_key
|
|
24
|
+
git config --global user.name "Rindrics"
|
|
25
|
+
git config --global user.email "${{ secrets.GIT_USER_EMAIL }}"
|
|
24
26
|
git config --global gpg.format ssh
|
|
25
27
|
git config --global user.signingkey ~/.ssh/signing_key
|
|
26
28
|
git config --global commit.gpgsign true
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [v0.3.0](https://github.com/Rindrics/initrepo/compare/v0.2.1...v0.3.0) - 2026-01-19
|
|
4
|
+
- ci: use renovate to use bun by @Rindrics in https://github.com/Rindrics/initrepo/pull/35
|
|
5
|
+
- feat: generate tagpr config by @Rindrics in https://github.com/Rindrics/initrepo/pull/37
|
|
6
|
+
|
|
3
7
|
## [v0.2.1](https://github.com/Rindrics/initrepo/compare/v0.2.0...v0.2.1) - 2026-01-19
|
|
4
8
|
- docs: update README.md by @Rindrics in https://github.com/Rindrics/initrepo/pull/24
|
|
5
9
|
- feat: add command setup-husky by @Rindrics in https://github.com/Rindrics/initrepo/pull/32
|
package/dist/cli.js
CHANGED
|
@@ -4207,7 +4207,7 @@ var {
|
|
|
4207
4207
|
// package.json
|
|
4208
4208
|
var package_default = {
|
|
4209
4209
|
name: "@rindrics/initrepo",
|
|
4210
|
-
version: "0.
|
|
4210
|
+
version: "0.3.0",
|
|
4211
4211
|
description: "setup GitHub repo with dev tools",
|
|
4212
4212
|
type: "module",
|
|
4213
4213
|
bin: {
|
|
@@ -11641,6 +11641,95 @@ function registerSetupHuskyCommand(program2) {
|
|
|
11641
11641
|
});
|
|
11642
11642
|
}
|
|
11643
11643
|
|
|
11644
|
+
// src/commands/setup-tagpr.ts
|
|
11645
|
+
import * as fs4 from "node:fs/promises";
|
|
11646
|
+
import * as path4 from "node:path";
|
|
11647
|
+
async function fileExists2(filePath) {
|
|
11648
|
+
try {
|
|
11649
|
+
await fs4.access(filePath);
|
|
11650
|
+
return true;
|
|
11651
|
+
} catch {
|
|
11652
|
+
return false;
|
|
11653
|
+
}
|
|
11654
|
+
}
|
|
11655
|
+
async function generateTagprSetup() {
|
|
11656
|
+
const actionVersions = await getLatestActionVersions();
|
|
11657
|
+
return [
|
|
11658
|
+
{
|
|
11659
|
+
path: ".tagpr",
|
|
11660
|
+
content: loadTemplate("typescript/.tagpr.ejs", {})
|
|
11661
|
+
},
|
|
11662
|
+
{
|
|
11663
|
+
path: ".github/workflows/tagpr.yml",
|
|
11664
|
+
content: loadTemplate("common/workflows/tagpr.yml.ejs", {
|
|
11665
|
+
isDevcode: false,
|
|
11666
|
+
actionVersions
|
|
11667
|
+
})
|
|
11668
|
+
}
|
|
11669
|
+
];
|
|
11670
|
+
}
|
|
11671
|
+
async function writeFiles2(targetDir, files, force) {
|
|
11672
|
+
const written = [];
|
|
11673
|
+
const skipped = [];
|
|
11674
|
+
for (const file of files) {
|
|
11675
|
+
const filePath = path4.join(targetDir, file.path);
|
|
11676
|
+
const fileDir = path4.dirname(filePath);
|
|
11677
|
+
if (!force && await fileExists2(filePath)) {
|
|
11678
|
+
skipped.push(file.path);
|
|
11679
|
+
continue;
|
|
11680
|
+
}
|
|
11681
|
+
await fs4.mkdir(fileDir, { recursive: true });
|
|
11682
|
+
await fs4.writeFile(filePath, file.content, "utf-8");
|
|
11683
|
+
written.push(file.path);
|
|
11684
|
+
}
|
|
11685
|
+
return { written, skipped };
|
|
11686
|
+
}
|
|
11687
|
+
async function setupTagpr(options) {
|
|
11688
|
+
const targetDir = options.targetDir ?? process.cwd();
|
|
11689
|
+
const force = options.force ?? false;
|
|
11690
|
+
const packageJsonPath = path4.join(targetDir, "package.json");
|
|
11691
|
+
if (!await fileExists2(packageJsonPath)) {
|
|
11692
|
+
throw new Error("package.json not found. Are you in a project directory?");
|
|
11693
|
+
}
|
|
11694
|
+
console.log(`\uD83D\uDD27 Setting up tagpr configuration...
|
|
11695
|
+
`);
|
|
11696
|
+
const files = await generateTagprSetup();
|
|
11697
|
+
const { written, skipped } = await writeFiles2(targetDir, files, force);
|
|
11698
|
+
if (written.length > 0) {
|
|
11699
|
+
console.log("✅ Created files:");
|
|
11700
|
+
for (const file of written) {
|
|
11701
|
+
console.log(` ${file}`);
|
|
11702
|
+
}
|
|
11703
|
+
}
|
|
11704
|
+
if (skipped.length > 0) {
|
|
11705
|
+
console.log(`
|
|
11706
|
+
⏭️ Skipped (already exist, use --force to overwrite):`);
|
|
11707
|
+
for (const file of skipped) {
|
|
11708
|
+
console.log(` ${file}`);
|
|
11709
|
+
}
|
|
11710
|
+
}
|
|
11711
|
+
console.log(`
|
|
11712
|
+
\uD83C\uDF89 Tagpr setup complete!`);
|
|
11713
|
+
console.log(`
|
|
11714
|
+
\uD83D\uDCCB Required secrets:`);
|
|
11715
|
+
console.log(" PAT_FOR_TAGPR - Personal Access Token with repo & workflow permissions");
|
|
11716
|
+
console.log(" SSH_SIGNING_KEY - SSH private key for commit signing");
|
|
11717
|
+
console.log(" GIT_USER_EMAIL - Email address for commits (optional)");
|
|
11718
|
+
}
|
|
11719
|
+
function registerSetupTagprCommand(program2) {
|
|
11720
|
+
program2.command("setup-tagpr").description("Set up tagpr configuration in an existing project").option("-t, --target-dir <path>", "Target directory (defaults to current directory)").option("-f, --force", "Overwrite existing files").action(async (opts) => {
|
|
11721
|
+
try {
|
|
11722
|
+
await setupTagpr({
|
|
11723
|
+
targetDir: opts.targetDir,
|
|
11724
|
+
force: opts.force
|
|
11725
|
+
});
|
|
11726
|
+
} catch (error) {
|
|
11727
|
+
console.error(`❌ Failed to setup tagpr: ${error instanceof Error ? error.message : String(error)}`);
|
|
11728
|
+
process.exit(1);
|
|
11729
|
+
}
|
|
11730
|
+
});
|
|
11731
|
+
}
|
|
11732
|
+
|
|
11644
11733
|
// src/cli.ts
|
|
11645
11734
|
var { version: VERSION17, name: NAME } = package_default;
|
|
11646
11735
|
function createProgram() {
|
|
@@ -11649,6 +11738,7 @@ function createProgram() {
|
|
|
11649
11738
|
registerInitCommand(program2);
|
|
11650
11739
|
registerPrepareReleaseCommand(program2);
|
|
11651
11740
|
registerSetupHuskyCommand(program2);
|
|
11741
|
+
registerSetupTagprCommand(program2);
|
|
11652
11742
|
return program2;
|
|
11653
11743
|
}
|
|
11654
11744
|
if (__require.main == __require.module) {
|
package/package.json
CHANGED
package/renovate.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
3
|
+
"extends": ["config:recommended"],
|
|
4
|
+
"packageRules": [
|
|
5
|
+
{
|
|
6
|
+
"matchUpdateTypes": ["major", "minor", "patch"],
|
|
7
|
+
"automerge": true
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"lockFileMaintenance": {
|
|
11
|
+
"enabled": true,
|
|
12
|
+
"schedule": ["before 5am on monday"]
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/cli.ts
CHANGED
|
@@ -4,6 +4,7 @@ import packageJson from '../package.json';
|
|
|
4
4
|
import { registerInitCommand } from './commands/init';
|
|
5
5
|
import { registerPrepareReleaseCommand } from './commands/prepare-release';
|
|
6
6
|
import { registerSetupHuskyCommand } from './commands/setup-husky';
|
|
7
|
+
import { registerSetupTagprCommand } from './commands/setup-tagpr';
|
|
7
8
|
|
|
8
9
|
const { version: VERSION, name: NAME } = packageJson;
|
|
9
10
|
|
|
@@ -18,6 +19,7 @@ export function createProgram(): Command {
|
|
|
18
19
|
registerInitCommand(program);
|
|
19
20
|
registerPrepareReleaseCommand(program);
|
|
20
21
|
registerSetupHuskyCommand(program);
|
|
22
|
+
registerSetupTagprCommand(program);
|
|
21
23
|
|
|
22
24
|
return program;
|
|
23
25
|
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import type { Command } from 'commander';
|
|
4
|
+
import type { GeneratedFile } from '../generators/project';
|
|
5
|
+
import { loadTemplate } from '../generators/project';
|
|
6
|
+
import { getLatestActionVersions } from '../utils/github';
|
|
7
|
+
|
|
8
|
+
export interface SetupTagprOptions {
|
|
9
|
+
/** Target directory (defaults to current directory) */
|
|
10
|
+
targetDir?: string;
|
|
11
|
+
/** Force overwrite existing files */
|
|
12
|
+
force?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Check if file exists
|
|
17
|
+
*/
|
|
18
|
+
async function fileExists(filePath: string): Promise<boolean> {
|
|
19
|
+
try {
|
|
20
|
+
await fs.access(filePath);
|
|
21
|
+
return true;
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Generate tagpr-related files
|
|
29
|
+
*/
|
|
30
|
+
async function generateTagprSetup(): Promise<GeneratedFile[]> {
|
|
31
|
+
const actionVersions = await getLatestActionVersions();
|
|
32
|
+
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
path: '.tagpr',
|
|
36
|
+
content: loadTemplate('typescript/.tagpr.ejs', {}),
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
path: '.github/workflows/tagpr.yml',
|
|
40
|
+
content: loadTemplate('common/workflows/tagpr.yml.ejs', {
|
|
41
|
+
isDevcode: false,
|
|
42
|
+
actionVersions,
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Write generated files to target directory
|
|
50
|
+
*/
|
|
51
|
+
async function writeFiles(
|
|
52
|
+
targetDir: string,
|
|
53
|
+
files: GeneratedFile[],
|
|
54
|
+
force: boolean,
|
|
55
|
+
): Promise<{ written: string[]; skipped: string[] }> {
|
|
56
|
+
const written: string[] = [];
|
|
57
|
+
const skipped: string[] = [];
|
|
58
|
+
|
|
59
|
+
for (const file of files) {
|
|
60
|
+
const filePath = path.join(targetDir, file.path);
|
|
61
|
+
const fileDir = path.dirname(filePath);
|
|
62
|
+
|
|
63
|
+
// Check if file exists
|
|
64
|
+
if (!force && (await fileExists(filePath))) {
|
|
65
|
+
skipped.push(file.path);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Create directory if needed
|
|
70
|
+
await fs.mkdir(fileDir, { recursive: true });
|
|
71
|
+
|
|
72
|
+
// Write file
|
|
73
|
+
await fs.writeFile(filePath, file.content, 'utf-8');
|
|
74
|
+
written.push(file.path);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return { written, skipped };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Main setup-tagpr logic
|
|
82
|
+
*/
|
|
83
|
+
export async function setupTagpr(options: SetupTagprOptions): Promise<void> {
|
|
84
|
+
const targetDir = options.targetDir ?? process.cwd();
|
|
85
|
+
const force = options.force ?? false;
|
|
86
|
+
|
|
87
|
+
// Check if package.json exists
|
|
88
|
+
const packageJsonPath = path.join(targetDir, 'package.json');
|
|
89
|
+
if (!(await fileExists(packageJsonPath))) {
|
|
90
|
+
throw new Error('package.json not found. Are you in a project directory?');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
console.log('🔧 Setting up tagpr configuration...\n');
|
|
94
|
+
|
|
95
|
+
// Generate tagpr files
|
|
96
|
+
const files = await generateTagprSetup();
|
|
97
|
+
|
|
98
|
+
// Write files
|
|
99
|
+
const { written, skipped } = await writeFiles(targetDir, files, force);
|
|
100
|
+
|
|
101
|
+
// Report results
|
|
102
|
+
if (written.length > 0) {
|
|
103
|
+
console.log('✅ Created files:');
|
|
104
|
+
for (const file of written) {
|
|
105
|
+
console.log(` ${file}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (skipped.length > 0) {
|
|
110
|
+
console.log('\n⏭️ Skipped (already exist, use --force to overwrite):');
|
|
111
|
+
for (const file of skipped) {
|
|
112
|
+
console.log(` ${file}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
console.log('\n🎉 Tagpr setup complete!');
|
|
117
|
+
console.log('\n📋 Required secrets:');
|
|
118
|
+
console.log(
|
|
119
|
+
' PAT_FOR_TAGPR - Personal Access Token with repo & workflow permissions',
|
|
120
|
+
);
|
|
121
|
+
console.log(' SSH_SIGNING_KEY - SSH private key for commit signing');
|
|
122
|
+
console.log(' GIT_USER_EMAIL - Email address for commits (optional)');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function registerSetupTagprCommand(program: Command): void {
|
|
126
|
+
program
|
|
127
|
+
.command('setup-tagpr')
|
|
128
|
+
.description('Set up tagpr configuration in an existing project')
|
|
129
|
+
.option(
|
|
130
|
+
'-t, --target-dir <path>',
|
|
131
|
+
'Target directory (defaults to current directory)',
|
|
132
|
+
)
|
|
133
|
+
.option('-f, --force', 'Overwrite existing files')
|
|
134
|
+
.action(async (opts: { targetDir?: string; force?: boolean }) => {
|
|
135
|
+
try {
|
|
136
|
+
await setupTagpr({
|
|
137
|
+
targetDir: opts.targetDir,
|
|
138
|
+
force: opts.force,
|
|
139
|
+
});
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error(
|
|
142
|
+
`❌ Failed to setup tagpr: ${error instanceof Error ? error.message : String(error)}`,
|
|
143
|
+
);
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
package/.github/dependabot.yml
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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"
|