Skip to content

Commit 02175bd

Browse files
update output format (#2)
* update output format * upate docs
1 parent 403e3db commit 02175bd

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ npx repodocs https://github.com/user/repo
1717
This will:
1818
1. Clone the repository
1919
2. Find all .md files
20-
3. Combine them into a single file named `username__repository-name.txt`
20+
3. Combine them into a single file named `username__repository-name__latestSha__timestamp-YYYY-MM-DD.txt`
2121
4. Clean up temporary files
2222

2323
Each file in the combined output is separated by:

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
},
88
"main": "./src/index.js",
99
"module": "./src/index.js",
10-
"files": [
11-
"src/index.js"
12-
],
10+
"files": ["src/index.js"],
1311
"scripts": {
1412
"build": "rslib build",
1513
"check": "biome check --write",

src/index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ function getRepoInfo(url) {
103103
if (!match) throw new Error('Invalid GitHub repository URL');
104104
return { username: match[1], repo: match[2] };
105105
}
106+
function getRepoMetadata(tmpDir) {
107+
const sha = execSync('git rev-parse --short HEAD', { cwd: tmpDir })
108+
.toString()
109+
.trim();
110+
const date = execSync('git show -s --format=%ci HEAD', { cwd: tmpDir })
111+
.toString()
112+
.trim()
113+
.replace(/\s+.*$/, '') // Remove timezone
114+
.replace(/[:-]/g, ''); // Remove separators
115+
116+
return { sha, date };
117+
}
106118

107119
async function main() {
108120
const repoUrl = process.argv[2];
@@ -115,10 +127,11 @@ async function main() {
115127
try {
116128
const repoInfo = getRepoInfo(repoUrl);
117129
const tmpDir = await cloneRepo(repoUrl);
130+
const metadata = getRepoMetadata(tmpDir);
118131
const mdFiles = await findMarkdownFiles(tmpDir);
119132
const output = await processFiles(mdFiles, tmpDir, repoInfo);
120133

121-
const outputFile = `${repoInfo.username}__${repoInfo.repo}.txt`;
134+
const outputFile = `${repoInfo.username}__${repoInfo.repo}__${metadata.sha}__${metadata.date}.txt`;
122135
await fs.writeFile(outputFile, output);
123136
console.log(`Combined documentation saved to ${outputFile}`);
124137

0 commit comments

Comments
 (0)