ai-dev-diary
Version:
Intelligent development diary system for AI-assisted projects
92 lines • 3.5 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.detectGitHubUsername = detectGitHubUsername;
exports.formatAuthorName = formatAuthorName;
exports.getAuthorPath = getAuthorPath;
const child_process_1 = require("child_process");
const fs = __importStar(require("fs-extra"));
const path = __importStar(require("path"));
const os = __importStar(require("os"));
async function detectGitHubUsername() {
try {
const gitUser = (0, child_process_1.execSync)('git config --get github.user', { encoding: 'utf-8' }).trim();
if (gitUser)
return `@${gitUser}`;
}
catch { }
try {
const remoteUrl = (0, child_process_1.execSync)('git config --get remote.origin.url', { encoding: 'utf-8' }).trim();
const match = remoteUrl.match(/github\.com[:/]([^/]+)\//);
if (match && match[1])
return `@${match[1]}`;
}
catch { }
try {
const ghConfigPath = path.join(os.homedir(), '.config', 'gh', 'hosts.yml');
if (await fs.pathExists(ghConfigPath)) {
const content = await fs.readFile(ghConfigPath, 'utf-8');
const match = content.match(/user:\s*(\S+)/);
if (match && match[1])
return `@${match[1]}`;
}
}
catch { }
try {
const gitName = (0, child_process_1.execSync)('git config --get user.name', { encoding: 'utf-8' }).trim();
if (gitName)
return `@${gitName.toLowerCase().replace(/\s+/g, '-')}`;
}
catch { }
const envVars = ['GITHUB_USER', 'GITHUB_USERNAME', 'GH_USER'];
for (const envVar of envVars) {
const value = process.env[envVar];
if (value)
return `@${value}`;
}
return null;
}
function formatAuthorName(author) {
if (!author)
return '@unknown';
return author.startsWith('@') ? author : `@${author}`;
}
function getAuthorPath(basePath, author, teamMode) {
if (!teamMode)
return basePath;
const formattedAuthor = formatAuthorName(author);
return path.join(basePath, 'team', formattedAuthor);
}
//# sourceMappingURL=github.js.map