github-archiver 1.0.9 → 1.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  ## [1.0.8](https://github.com/mynameistito/github-archiver/compare/v1.0.7...v1.0.8) (2026-01-11)
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`3322224`](https://github.com/mynameistito/github-archiver/commit/3322224c8518cf6ce3a0a9afbbcbe3b283c5427d) Thanks [@mynameistito](https://github.com/mynameistito)! - Replace 'done' text input with CTRL+D hotkey
8
+
9
+ - Remove 'done' command requirement for finishing repository input
10
+ - Implement native CTRL+D (EOF) signal handling via readline close event
11
+ - Add guard flag to prevent double execution
12
+ - Update help text to guide users to press CTRL+D instead of typing 'done'
13
+ - Maintains cross-platform compatibility (Windows, Mac, Linux)
14
+
15
+ - [`3322224`](https://github.com/mynameistito/github-archiver/commit/3322224c8518cf6ce3a0a9afbbcbe3b283c5427d) Thanks [@mynameistito](https://github.com/mynameistito)! - Improve dry-run logging with console output and fix summary box alignment
16
+
17
+ - Add console output to dry-run validation to show progress in real-time (🔍 emoji)
18
+ - Fix startTime initialization in Archiver to properly calculate operation duration
19
+ - Refactor summary box formatting with dynamic padding that accounts for emoji character widths
20
+ - Ensure all numeric values in summary box are properly right-aligned
21
+
3
22
  ## 1.0.9
4
23
 
5
24
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{Command as Me}from"commander";import{Command as Ae}from"commander";var g={AUTH_SUCCESS:"Successfully authenticated with GitHub",ARCHIVE_SUCCESS:"Repository archived successfully",TOKEN_SAVED:"GitHub token saved successfully",TOKEN_REMOVED:"GitHub token removed",INVALID_TOKEN:"Invalid or expired GitHub token",REPO_NOT_FOUND:"Repository not found",ALREADY_ARCHIVED:"Repository is already archived",PERMISSION_DENIED:"You do not have permission to archive this repository",RATE_LIMITED:"GitHub API rate limit exceeded. Please try again later",NETWORK_ERROR:"Network error. Please check your connection",INVALID_URL:"Invalid GitHub repository URL",NO_TOKEN:'No GitHub token found. Please run "github-archiver auth login" first',OPENING_EDITOR:"Opening text editor for repository URLs...",NO_REPOS_PROVIDED:"No repositories provided",ARCHIVING_START:"Starting to archive repositories...",ARCHIVING_COMPLETE:"Archiving complete",DRY_RUN_MODE:"Running in dry-run mode (no repositories will be archived)",CONFIRM_ARCHIVE:"Are you sure you want to archive these repositories?",ENTER_TOKEN:"Enter your GitHub Personal Access Token (will not be displayed):",CONFIRM_LOGOUT:"Are you sure you want to remove the stored token?"};import{homedir as ie}from"node:os";import{join as A}from"node:path";var w=A(ie(),".github-archiver"),p={APP_DIR:w,CONFIG_FILE:A(w,"config.json"),LOG_DIR:A(w,"logs"),COMBINED_LOG:A(w,"logs","combined.log"),ERROR_LOG:A(w,"logs","errors.log")};import se from"p-queue";var u={INVALID_AUTH:"INVALID_AUTH",REPO_NOT_FOUND:"REPO_NOT_FOUND",ALREADY_ARCHIVED:"ALREADY_ARCHIVED",PERMISSION_DENIED:"PERMISSION_DENIED",RATE_LIMITED:"RATE_LIMITED",NETWORK_ERROR:"NETWORK_ERROR",INVALID_URL:"INVALID_URL",PARSE_ERROR:"PARSE_ERROR",EDITOR_ERROR:"EDITOR_ERROR",CONFIG_ERROR:"CONFIG_ERROR",FILE_ERROR:"FILE_ERROR"},l=class r extends Error{constructor(e,t,i,o=!1){super(t),this.name="ArchiveError",this.code=e,this.statusCode=i,this.retryable=o,Object.setPrototypeOf(this,r.prototype)}};function V(r){return r instanceof l}function U(r,e){return new l(u.INVALID_AUTH,r,e,!0)}function B(r,e){return new l(u.REPO_NOT_FOUND,`Repository ${r}/${e} not found`,404,!1)}function Y(r,e){return new l(u.ALREADY_ARCHIVED,`Repository ${r}/${e} is already archived`,422,!1)}function K(r,e){return new l(u.PERMISSION_DENIED,`Permission denied for ${r}/${e}. You must be the repository owner or have push access.`,403,!1)}function W(){return new l(u.RATE_LIMITED,g.RATE_LIMITED,429,!0)}function x(r){return new l(u.NETWORK_ERROR,r||g.NETWORK_ERROR,void 0,!0)}function z(r){return new l(u.CONFIG_ERROR,r)}function O(r){return new l(u.FILE_ERROR,r)}import{promises as ne}from"node:fs";import y from"winston";var S="info";var T;async function j(r){try{await ne.mkdir(r,{recursive:!0})}catch(e){console.error("Failed to create log directory:",e)}}function H(r){let e=r?.logLevel||S,t=r?.logDir||p.LOG_DIR;return y.createLogger({level:e,format:y.format.combine(y.format.timestamp({format:"YYYY-MM-DD HH:mm:ss"}),y.format.errors({stack:!0}),y.format.json()),defaultMeta:{service:"github-archiver"},transports:[new y.transports.File({filename:`${t}/errors.log`,level:"error"}),new y.transports.File({filename:`${t}/combined.log`})]})}function c(){return T||(T=H()),T}function q(r){T=r}var v=c(),D=class{constructor(e,t){this.results=[];this.completed=0;this.failed=0;this.startTime=0;this.gitHubService=e,this.queue=new se({concurrency:t.concurrency,timeout:t.timeout*1e3,interval:1e3,intervalCap:t.concurrency}),v.info("Archiver initialized",{concurrency:t.concurrency,timeout:t.timeout,dryRun:t.dryRun})}async archiveRepositories(e,t){this.results=[],this.completed=0,this.failed=0,v.info(`Starting to archive ${e.length} repositories`,{dryRun:t.dryRun});let i=e.map(o=>this.queue.add(()=>this.archiveRepository(o,t)));return await Promise.all(i),this.results}async archiveRepository(e,t){let i=Date.now();try{if(t.dryRun){v.info(`[DRY-RUN] Would archive ${e.owner}/${e.repo}`);let s={owner:e.owner,repo:e.repo,success:!0,archived:!1,duration:Date.now()-i,message:"[DRY-RUN] Validation successful"};this.results.push(s),this.completed++;return}let o=await this.gitHubService.validateRepository(e.owner,e.repo);if(!o.exists){v.warn(`Repository not found: ${e.owner}/${e.repo}`);let s={owner:e.owner,repo:e.repo,success:!1,archived:!1,error:"Repository not found",duration:Date.now()-i,message:"Repository does not exist on GitHub"};this.results.push(s),this.failed++;return}if(o.isArchived){v.info(`Repository already archived: ${e.owner}/${e.repo}`);let s={owner:e.owner,repo:e.repo,success:!0,archived:!1,duration:Date.now()-i,message:"Repository is already archived"};this.results.push(s),this.completed++;return}console.log(`\u{1F4E6} Archiving ${e.owner}/${e.repo}...`),await this.gitHubService.archiveRepository(e.owner,e.repo);let n={owner:e.owner,repo:e.repo,success:!0,archived:!0,duration:Date.now()-i,message:"Repository archived successfully"};this.results.push(n),this.completed++,v.info(`\u2713 Archived ${e.owner}/${e.repo}`,{duration:n.duration})}catch(o){if(V(o)&&o.code===u.ALREADY_ARCHIVED){v.info(`Repository already archived: ${e.owner}/${e.repo}`);let a={owner:e.owner,repo:e.repo,success:!0,archived:!1,duration:Date.now()-i,message:"Repository is already archived"};this.results.push(a),this.completed++;return}let n=o instanceof Error?o.message:String(o);v.error(`\u2717 Failed to archive ${e.owner}/${e.repo}: ${n}`);let s={owner:e.owner,repo:e.repo,success:!1,archived:!1,error:n,duration:Date.now()-i,message:`Error: ${n}`};this.results.push(s),this.failed++}}getProgress(){return{completed:this.completed,failed:this.failed,total:this.results.length}}getSummary(){let e=this.results.filter(n=>n.success&&n.archived).length,t=this.results.filter(n=>!n.success).length,i=this.results.filter(n=>n.success&&!n.archived).length,o=Date.now()-this.startTime;return{successful:e,failed:t,skipped:i,totalDuration:o}}};import{Octokit as X}from"octokit";import{promises as I}from"node:fs";import{join as J}from"node:path";var L=class{constructor(e=p.APP_DIR){this.configDir=e,this.configFile=J(e,"config.json")}async loadConfig(){try{let e=process.env.GH_TOKEN,t=await this.loadFileCredentials();return{token:e||t?.token,concurrency:3,timeout:300,logLevel:S,logDir:J(this.configDir,"logs"),configDir:this.configDir}}catch(e){throw z(`Failed to load configuration: ${e instanceof Error?e.message:String(e)}`)}}async saveConfig(e){try{await this.ensureConfigDir(),await I.writeFile(this.configFile,JSON.stringify(e,null,2),"utf-8")}catch(t){throw O(`Failed to save configuration: ${t instanceof Error?t.message:String(t)}`)}}async ensureConfigDir(){try{await I.mkdir(this.configDir,{recursive:!0})}catch(e){throw O(`Failed to create config directory: ${e instanceof Error?e.message:String(e)}`)}}async getStoredCredentials(){try{let e=await I.readFile(this.configFile,"utf-8");return JSON.parse(e)}catch{return null}}async removeStoredCredentials(){try{await I.unlink(this.configFile)}catch(e){if(e.code!=="ENOENT")throw O(`Failed to remove stored credentials: ${e instanceof Error?e.message:String(e)}`)}}async loadFileCredentials(){try{let e=await I.readFile(this.configFile,"utf-8");return JSON.parse(e)}catch{return null}}};var E=class{constructor(e=p.APP_DIR){this.configManager=new L(e)}async saveToken(e){if(!e||typeof e!="string")throw U("Invalid token format");let t=new X({auth:e});try{let{data:i}=await t.rest.users.getAuthenticated(),o={token:e,savedAt:new Date().toISOString(),githubUser:i.login};await this.configManager.saveConfig(o)}catch(i){throw U(`Failed to validate token: ${i instanceof Error?i.message:String(i)}`)}}async getToken(){return process.env.GH_TOKEN?process.env.GH_TOKEN:(await this.configManager.getStoredCredentials())?.token}async removeToken(){await this.configManager.removeStoredCredentials()}async validateToken(e){try{let t=new X({auth:e}),{data:i}=await t.rest.users.getAuthenticated();return{valid:!0,user:i.login}}catch{return{valid:!1}}}getStoredCredentials(){return this.configManager.getStoredCredentials()}ensureConfigDir(){return this.configManager.ensureConfigDir()}loadConfig(){return this.configManager.loadConfig()}};import{Octokit as de}from"octokit";var d=c(),_=class{constructor(e){this.octokit=new de({auth:e})}async archiveRepository(e,t){let i=Date.now();d.debug(`Attempting to archive ${e}/${t}`),await this.retryWithBackoff(async()=>{try{await this.octokit.rest.repos.update({owner:e,repo:t,archived:!0});let o=Date.now()-i;d.info(`Successfully archived ${e}/${t} in ${o}ms`)}catch(o){this.handleArchiveError(o,e,t)}})}handleArchiveError(e,t,i){let o=this.parseOctokitError(e);throw d.error(`Failed to archive ${t}/${i}: ${o.message}`,{status:o.status,code:o.code}),o.status===404?B(t,i):o.status===403||o.message.includes("permission")?K(t,i):o.status===422&&o.message.includes("archived")?Y(t,i):o.message.includes("API rate limit")?W():o.message.includes("ECONNREFUSED")||o.message.includes("ETIMEDOUT")||o.message.includes("EHOSTUNREACH")||o.message.includes("socket hang up")?x(o.message):e}parseOctokitError(e){let t=e instanceof Error?e.message:String(e),i=e;return{message:t,status:i?.status||0,code:i?.response?.data?.message}}async validateRepository(e,t){try{d.debug(`Validating repository ${e}/${t}`);let{data:i}=await this.octokit.rest.repos.get({owner:e,repo:t}),o={exists:!0,isArchived:i.archived};return d.debug(`Repository ${e}/${t} validated`,o),o}catch(i){if(i instanceof Error&&i.message.includes("404"))return d.debug(`Repository ${e}/${t} does not exist`),{exists:!1,isArchived:!1};throw d.error(`Error validating ${e}/${t}:`,i),i}}async getRateLimitStatus(){try{d.debug("Fetching rate limit status");let{data:e}=await this.octokit.rest.rateLimit.get(),t={remaining:e.rate.remaining,reset:new Date(e.rate.reset*1e3),limit:e.rate.limit};return d.debug("Rate limit status retrieved",{remaining:t.remaining,limit:t.limit,resetAt:t.reset.toISOString()}),t}catch(e){throw d.error("Failed to fetch rate limit status:",e),e}}async validateAuth(){try{d.debug("Validating authentication");let{data:e}=await this.octokit.rest.users.getAuthenticated();return d.info(`Authenticated as user: ${e.login}`),e.login}catch(e){throw d.error("Authentication validation failed:",e),x(e instanceof Error?e.message:"Authentication failed")}}async retryWithBackoff(e,t=3){let i;for(let o=0;o<t;o++)try{return await e()}catch(n){i=n;let s=i.message.toLowerCase();if(!(s.includes("rate limit")||s.includes("timeout")||s.includes("econnrefused")||s.includes("etimedout")||s.includes("ehostunreach")||s.includes("socket hang up"))||o===t-1)throw n;let m=1e3*2**o;d.warn(`Retry attempt ${o+1}/${t} after ${m}ms`,{error:s}),await new Promise($=>setTimeout($,m))}throw i||new Error("Unknown error during retry")}};import{promises as fe}from"node:fs";import{createInterface as M}from"node:readline";var P=c(),me=/^[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$/,ge=[/^(?:https?:\/\/)?(?:www\.)?github\.com[/:]([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:\/)?$/i,/^git@github\.com:([\w.-]+)\/([\w.-]+?)(?:\.git)?$/i,/^([\w.-]+)\/([\w.-]+)$/];function Q(r){let e=r.trim();if(!e)throw new l(u.INVALID_URL,"URL cannot be empty");for(let t of ge){let i=e.match(t);if(i){let o=i[1],n=i[2];if(!(o&&n))throw new l(u.INVALID_URL,`Invalid GitHub URL format: ${r}`);if(!Z(o))throw new l(u.INVALID_URL,`Invalid owner name: ${o}. Owner names must contain only alphanumeric characters, hyphens, or periods.`);if(!Z(n))throw new l(u.INVALID_URL,`Invalid repository name: ${n}. Repository names must contain only alphanumeric characters, hyphens, underscores, or periods.`);let s=`https://github.com/${o}/${n}`;return P.debug("Parsed repository URL",{original:e,owner:o,repo:n,normalized:s}),{owner:o,repo:n,url:s}}}throw new l(u.INVALID_URL,`Invalid GitHub URL: ${r}`)}function Z(r){return me.test(r)}function pe(r){let e=[],t=[];for(let[i,o]of r.entries()){let n=i+1,s=o.trim();if(!(!s||s.startsWith("#")))try{let a=Q(s);e.push(a),P.debug(`Line ${n}: Valid repository`,{owner:a.owner,repo:a.repo})}catch(a){let m=a instanceof Error?a.message:String(a);t.push({url:s,error:m,line:n}),P.warn(`Line ${n}: Invalid repository`,{url:s,error:m})}}return P.info("Batch parsing complete",{total:r.length,valid:e.length,invalid:t.length,skipped:r.length-e.length-t.length}),{valid:e,invalid:t}}var k={parseRepositoryUrl:Q,parseRepositoriesBatch:pe};var f=c(),N=class{getRepositoriesFromInteractive(){return f.info("Starting interactive CLI input for repositories"),new Promise(e=>{let t=M({input:process.stdin,output:process.stdout});console.log(""),console.log("\u{1F4DD} Enter repository URLs one at a time:"),console.log(' (Type "done" when finished, or leave empty and press Enter to skip)'),console.log("");let i=[],o=1,n=()=>{t.question(`[${o}] > `,a=>{let m=a.trim();if(m.toLowerCase()==="done"){s();return}if(m===""){o++,n();return}i.push(m),o++,n()})},s=()=>{t.close();let a=k.parseRepositoriesBatch(i);a.invalid.length>0&&f.warn(`Found ${a.invalid.length} invalid repositories`,{errors:a.invalid}),f.info(`Parsed ${a.valid.length} valid repositories`),e({repos:a.valid,errors:a.invalid})};t.on("close",()=>{s()}),n()})}async getRepositoriesFromFile(e){f.info(`Reading repositories from file: ${e}`);try{let i=(await fe.readFile(e,"utf-8")).split(`
2
- `),o=k.parseRepositoriesBatch(i);return o.invalid.length>0&&f.warn(`Found ${o.invalid.length} invalid entries in file`,{errors:o.invalid}),f.info(`Parsed ${o.valid.length} valid repositories from file`),{repos:o.valid,errors:o.invalid}}catch(t){let i=t instanceof Error?t.message:String(t);throw f.error(`Failed to read file ${e}: ${i}`),new Error(`Failed to read file: ${i}`)}}getRepositoriesFromStdin(){return f.info("Reading repositories from stdin"),new Promise(e=>{let t=[],i=M({input:process.stdin,output:process.stdout});i.on("line",o=>{t.push(o)}),i.on("close",()=>{let o=k.parseRepositoriesBatch(t);o.invalid.length>0&&f.warn(`Found ${o.invalid.length} invalid entries from stdin`,{errors:o.invalid}),f.info(`Parsed ${o.valid.length} valid repositories from stdin`),e({repos:o.valid,errors:o.invalid})})})}promptForConfirmation(e){return new Promise(t=>{let i=M({input:process.stdin,output:process.stdout});i.question(`${e} [y/N]: `,o=>{i.close();let n=o.toLowerCase()==="y";f.info(`User confirmation: ${n}`),t(n)})})}};function he(r){if(r<1e3)return`${r}ms`;if(r<6e4)return`${(r/1e3).toFixed(1)}s`;let e=Math.floor(r/6e4),t=(r%6e4/1e3).toFixed(0);return`${e}m ${t}s`}function ve(r){if(r===0)return"0 B";let e=1024,t=["B","KB","MB","GB"],i=Math.floor(Math.log(r)/Math.log(e));return`${(r/e**i).toFixed(2)} ${t[i]}`}function Re(r,e){return e===0?"0%":`${(r/e*100).toFixed(1)}%`}function ye(r,e,t=30){if(e===0)return"[ ]";let i=Math.round(r/e*t),o=t-i,n="=".repeat(i),s=" ".repeat(o),a=(r/e*100).toFixed(0);return`[${n}${s}] ${a}%`}function Ee(r,e){let t=Math.max(0,(e-r.length)/2);return" ".repeat(Math.floor(t))+r}function we(r,e){return r.length<=e?r:`${r.substring(0,e-3)}...`}var b={formatDuration:he,formatBytes:ve,formatPercent:Re,createProgressBar:ye,centerText:Ee,truncate:we};var F=class{constructor(){this.lastUpdate=0;this.updateInterval=500;this.startTime=Date.now()}shouldUpdate(){let e=Date.now();return e-this.lastUpdate>=this.updateInterval?(this.lastUpdate=e,!0):!1}getProgressBar(e){let{completed:t,total:i,current:o}=e,n=i>0?t/i*100:0,a=`${b.createProgressBar(t,i,25)} ${t}/${i} (${n.toFixed(0)}%)`;return o&&(a+=` - ${o.owner}/${o.repo}`),a}getSummaryBox(e){let{successful:t,failed:i,skipped:o,totalDuration:n}=e,s=t+i+o,a=b.formatDuration(n);return["\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557","\u2551 Archive Operation Summary \u2551","\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563",`\u2551 \u2705 Successful: ${String(t).padEnd(20)} \u2551`,`\u2551 \u26A0\uFE0F Skipped: ${String(o).padEnd(20)} \u2551`,`\u2551 \u274C Failed: ${String(i).padEnd(20)} \u2551`,"\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563",`\u2551 Total: ${String(s).padEnd(20)} \u2551`,`\u2551 Duration: ${String(a).padEnd(20)} \u2551`,"\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"].join(`
3
- `)}getElapsedTime(){let e=Date.now()-this.startTime;return b.formatDuration(e)}getEstimatedTimeRemaining(e,t){if(e===0)return null;let o=(Date.now()-this.startTime)/e,n=(t-e)*o;return n>0?b.formatDuration(n):null}};var R=c();function ee(){return new Ae("archive").description("Archive GitHub repositories").option("--file <path>","Read repository URLs from file").option("--stdin","Read repository URLs from standard input").option("--dry-run","Validate without archiving",!1).option("--concurrency <n>","Number of parallel operations","3").option("--timeout <n>","API timeout in seconds","300").option("--verbose","Verbose logging",!1).option("--force","Skip confirmations",!1).action(async r=>{await Ie(r)})}async function Ie(r){try{R.info("Archive command started",{options:r});let{concurrency:e,timeout:t}=be(r),i=new E(p.APP_DIR),o=new N,n=new F,s=await Ce(i),{repositories:a,parseErrors:m}=await $e(r,o);m.length>0&&Oe(m),a.length===0&&(console.error(`\u274C ${g.NO_REPOS_PROVIDED}`),process.exit(1)),Se(a,r.dryRun),await Te(r,o);let $={dryRun:r.dryRun,concurrency:e,timeout:t,force:r.force,verbose:r.verbose};console.log(""),console.log(`${g.ARCHIVING_START} (concurrency: ${e})`),console.log("");let G=new D(s,$),oe=await De(G,a,$,n);Le(G,oe,n)}catch(e){_e(e)}}function be(r){let e=Number.parseInt(r.concurrency,10),t=Number.parseInt(r.timeout,10);return(e<1||e>50)&&(console.error("\u274C Concurrency must be between 1 and 50"),process.exit(1)),(t<10||t>3600)&&(console.error("\u274C Timeout must be between 10 and 3600 seconds"),process.exit(1)),{concurrency:e,timeout:t}}async function Ce(r){console.log("\u{1F510} Checking authentication...");let e=await r.getToken();e||(console.error(`\u274C ${g.NO_TOKEN}`),console.error(" Run: github-archiver auth login"),process.exit(1));let t=new _(e);try{let i=await t.validateAuth();return console.log(`\u2705 Authenticated as: ${i}`),t}catch(i){console.error("\u274C Authentication failed"),R.error("Auth validation failed:",i),process.exit(1)}}async function $e(r,e){console.log(""),console.log("\u{1F4DD} Getting repositories...");let t=[],i=[];if(r.file){R.info(`Using file input: ${r.file}`);let o=await e.getRepositoriesFromFile(r.file);t=o.repos,i=o.errors}else if(r.stdin){R.info("Using stdin input"),console.log("Enter repository URLs (one per line, press Ctrl+D to finish):");let o=await e.getRepositoriesFromStdin();t=o.repos,i=o.errors}else{R.info("Using interactive CLI input");let o=await e.getRepositoriesFromInteractive();t=o.repos,i=o.errors}return{repositories:t,parseErrors:i}}function Oe(r){console.warn(`\u26A0\uFE0F Found ${r.length} invalid repositories:`);for(let e of r)console.warn(` Line ${e.line}: ${e.error}`);console.warn("")}function Se(r,e){console.log(`\u{1F4CB} Will ${e?"validate":"archive"} ${r.length} repositories:`);for(let t=0;t<Math.min(r.length,5);t++){let i=r[t];i&&console.log(` ${t+1}. ${i.owner}/${i.repo}`)}r.length>5&&console.log(` ... and ${r.length-5} more`)}async function Te(r,e){console.log(""),r.force||r.dryRun?r.dryRun&&console.log(`\u2139\uFE0F ${g.DRY_RUN_MODE}`):await e.promptForConfirmation("Are you sure you want to archive these repositories?")||(console.log("\u274C Cancelled"),process.exit(1))}async function De(r,e,t,i){let o=await r.archiveRepositories(e,t),n=r.getSummary(),s={completed:n.successful+n.failed+n.skipped,failed:n.failed,total:e.length};return i.shouldUpdate()&&console.log(`\r${i.getProgressBar(s)}`),o}function Le(r,e,t){console.log(""),console.log("");let i=r.getSummary();if(console.log(t.getSummaryBox(i)),i.failed>0){console.log(""),console.log("\u274C Failed repositories:");for(let o of e)o.success||console.log(` ${o.owner}/${o.repo}: ${o.message}`)}if(i.skipped>0){console.log(""),console.log("\u26A0\uFE0F Skipped repositories:");for(let o of e)o.success&&!o.archived&&console.log(` ${o.owner}/${o.repo}: ${o.message}`)}i.failed>0?(R.warn(`Archive command completed with ${i.failed} failures`),process.exit(1)):(console.log(""),console.log("\u2705 All repositories processed successfully!"),R.info("Archive command completed successfully"),process.exit(0))}function _e(r){let e=r instanceof Error?r.message:String(r);console.error(`\u274C Error: ${e}`),R.error("Archive command failed:",r),Pe(e),process.exit(1)}function Pe(r){let e=r.toLowerCase();if(e.includes("token")||e.includes("authentication")){console.log(""),console.log("\u{1F4A1} Troubleshooting:"),console.log(" 1. Make sure you have a valid GitHub Personal Access Token"),console.log(' 2. The token needs "repo" scope to archive repositories'),console.log(" 3. Run: github-archiver auth login");return}if(e.includes("rate limit")){console.log(""),console.log("\u{1F4A1} Troubleshooting:"),console.log(" 1. GitHub API rate limit has been exceeded"),console.log(" 2. Wait a few minutes and try again"),console.log(" 3. Use lower concurrency: --concurrency 1");return}if(e.includes("permission")||e.includes("403")){console.log(""),console.log("\u{1F4A1} Troubleshooting:"),console.log(" 1. You must be the repository owner or have push access"),console.log(" 2. Check that your GitHub token has correct permissions"),console.log(" 3. Verify you have push access to the repositories");return}if(e.includes("not found")||e.includes("404")){console.log(""),console.log("\u{1F4A1} Troubleshooting:"),console.log(" 1. Make sure the repository URL is correct"),console.log(" 2. The repository may have been deleted"),console.log(" 3. Check your GitHub access to the repository");return}(e.includes("network")||e.includes("timeout"))&&(console.log(""),console.log("\u{1F4A1} Troubleshooting:"),console.log(" 1. Check your internet connection"),console.log(" 2. GitHub API may be temporarily unavailable"),console.log(" 3. Try again in a moment"),console.log(" 4. Increase timeout: --timeout 600"))}import{createInterface as re}from"node:readline";import{Command as C}from"commander";var h=new E(p.APP_DIR);function ke(){return new C("login").description("Set up GitHub authentication with a Personal Access Token").action(async()=>{try{await h.ensureConfigDir();let r=await xe();r||(console.error("No token provided. Aborting."),process.exit(1)),console.log("Validating token..."),await h.saveToken(r);let e=await h.getStoredCredentials();console.log(`\u2713 ${g.AUTH_SUCCESS}`),console.log(` User: ${e?.githubUser}`),c().info("Token saved successfully",{user:e?.githubUser})}catch(r){let e=r instanceof Error?r.message:String(r);console.error(`\u2717 Error: ${e}`),c().error("Failed to save token",{error:e}),process.exit(1)}})}function Ne(){return new C("logout").description("Remove stored GitHub authentication token").action(async()=>{try{if(!await h.getStoredCredentials()){console.log("No stored credentials found.");return}if(!await He(g.CONFIRM_LOGOUT)){console.log("Cancelled.");return}await h.removeToken(),console.log(`\u2713 ${g.TOKEN_REMOVED}`),c().info("Token removed")}catch(r){let e=r instanceof Error?r.message:String(r);console.error(`\u2717 Error: ${e}`),c().error("Failed to remove token",{error:e}),process.exit(1)}})}function Fe(){return new C("status").description("Check authentication status").action(async()=>{try{let r=await h.getToken();if(!r){console.log("\u2717 Not authenticated"),console.log(' Run "github-archiver auth login" to set up authentication');return}console.log("\u2713 Authenticated");let e=await h.validateToken(r);if(e.valid){console.log(` User: ${e.user}`);let t=await h.getStoredCredentials();t&&console.log(` Saved at: ${new Date(t.savedAt).toLocaleString()}`),c().info("Authentication status check passed")}else console.log("\u2717 Token is invalid or expired"),c().warn("Token validation failed")}catch(r){let e=r instanceof Error?r.message:String(r);console.error(`\u2717 Error: ${e}`),c().error("Failed to check auth status",{error:e}),process.exit(1)}})}function Ue(){return new C("validate").description("Validate stored authentication token").action(async()=>{try{let r=await h.getToken();r||(console.log("\u2717 No token found"),process.exit(1)),console.log("Validating token...");let e=await h.validateToken(r);e.valid?(console.log(`\u2713 Token is valid (user: ${e.user})`),c().info("Token validation successful",{user:e.user})):(console.log("\u2717 Token is invalid or expired"),c().warn("Token validation failed"),process.exit(1))}catch(r){let e=r instanceof Error?r.message:String(r);console.error(`\u2717 Error: ${e}`),c().error("Token validation error",{error:e}),process.exit(1)}})}function xe(){return new Promise(r=>{let e=re({input:process.stdin,output:process.stdout});e.question(g.ENTER_TOKEN,t=>{e.close(),r(t.trim())})})}function He(r){return new Promise(e=>{let t=re({input:process.stdin,output:process.stdout});t.question(`${r} [y/N]: `,i=>{t.close(),e(i.toLowerCase()==="y")})})}function te(){return new C("auth").description("Manage GitHub authentication").addCommand(ke()).addCommand(Ne()).addCommand(Fe()).addCommand(Ue())}var Ge="1.0.6",Ve="Archive GitHub repositories via CLI";async function Be(){try{await j(p.LOG_DIR);let r=H();q(r);let e=new Me;e.name("github-archiver").description(Ve).version(Ge,"-v, --version","Display version"),e.addCommand(te()),e.addCommand(ee()),e.addHelpCommand(!0),await e.parseAsync(process.argv),process.argv.slice(2).length||e.outputHelp()}catch(r){let e=r instanceof Error?r.message:String(r);console.error(`\u2717 Fatal error: ${e}`),process.exit(1)}}Be();
1
+ import{Command as Be}from"commander";import{Command as Ce}from"commander";var m={AUTH_SUCCESS:"Successfully authenticated with GitHub",ARCHIVE_SUCCESS:"Repository archived successfully",TOKEN_SAVED:"GitHub token saved successfully",TOKEN_REMOVED:"GitHub token removed",INVALID_TOKEN:"Invalid or expired GitHub token",REPO_NOT_FOUND:"Repository not found",ALREADY_ARCHIVED:"Repository is already archived",PERMISSION_DENIED:"You do not have permission to archive this repository",RATE_LIMITED:"GitHub API rate limit exceeded. Please try again later",NETWORK_ERROR:"Network error. Please check your connection",INVALID_URL:"Invalid GitHub repository URL",NO_TOKEN:'No GitHub token found. Please run "github-archiver auth login" first',OPENING_EDITOR:"Opening text editor for repository URLs...",NO_REPOS_PROVIDED:"No repositories provided",ARCHIVING_START:"Starting to archive repositories...",ARCHIVING_COMPLETE:"Archiving complete",DRY_RUN_MODE:"Running in dry-run mode (no repositories will be archived)",CONFIRM_ARCHIVE:"Are you sure you want to archive these repositories?",ENTER_TOKEN:"Enter your GitHub Personal Access Token (will not be displayed):",CONFIRM_LOGOUT:"Are you sure you want to remove the stored token?"};import{homedir as ae}from"node:os";import{join as b}from"node:path";var I=b(ae(),".github-archiver"),f={APP_DIR:I,CONFIG_FILE:b(I,"config.json"),LOG_DIR:b(I,"logs"),COMBINED_LOG:b(I,"logs","combined.log"),ERROR_LOG:b(I,"logs","errors.log")};import le from"p-queue";var d={INVALID_AUTH:"INVALID_AUTH",REPO_NOT_FOUND:"REPO_NOT_FOUND",ALREADY_ARCHIVED:"ALREADY_ARCHIVED",PERMISSION_DENIED:"PERMISSION_DENIED",RATE_LIMITED:"RATE_LIMITED",NETWORK_ERROR:"NETWORK_ERROR",INVALID_URL:"INVALID_URL",PARSE_ERROR:"PARSE_ERROR",EDITOR_ERROR:"EDITOR_ERROR",CONFIG_ERROR:"CONFIG_ERROR",FILE_ERROR:"FILE_ERROR"},u=class r extends Error{constructor(e,t,i,o=!1){super(t),this.name="ArchiveError",this.code=e,this.statusCode=i,this.retryable=o,Object.setPrototypeOf(this,r.prototype)}};function Y(r){return r instanceof u}function H(r,e){return new u(d.INVALID_AUTH,r,e,!0)}function K(r,e){return new u(d.REPO_NOT_FOUND,`Repository ${r}/${e} not found`,404,!1)}function W(r,e){return new u(d.ALREADY_ARCHIVED,`Repository ${r}/${e} is already archived`,422,!1)}function z(r,e){return new u(d.PERMISSION_DENIED,`Permission denied for ${r}/${e}. You must be the repository owner or have push access.`,403,!1)}function j(){return new u(d.RATE_LIMITED,m.RATE_LIMITED,429,!0)}function M(r){return new u(d.NETWORK_ERROR,r||m.NETWORK_ERROR,void 0,!0)}function q(r){return new u(d.CONFIG_ERROR,r)}function O(r){return new u(d.FILE_ERROR,r)}import{promises as ce}from"node:fs";import E from"winston";var T="info";var D;async function J(r){try{await ce.mkdir(r,{recursive:!0})}catch(e){console.error("Failed to create log directory:",e)}}function G(r){let e=r?.logLevel||T,t=r?.logDir||f.LOG_DIR;return E.createLogger({level:e,format:E.format.combine(E.format.timestamp({format:"YYYY-MM-DD HH:mm:ss"}),E.format.errors({stack:!0}),E.format.json()),defaultMeta:{service:"github-archiver"},transports:[new E.transports.File({filename:`${t}/errors.log`,level:"error"}),new E.transports.File({filename:`${t}/combined.log`})]})}function l(){return D||(D=G()),D}function X(r){D=r}var R=l(),L=class{constructor(e,t){this.results=[];this.completed=0;this.failed=0;this.gitHubService=e,this.startTime=Date.now(),this.queue=new le({concurrency:t.concurrency,timeout:t.timeout*1e3,interval:1e3,intervalCap:t.concurrency}),R.info("Archiver initialized",{concurrency:t.concurrency,timeout:t.timeout,dryRun:t.dryRun})}async archiveRepositories(e,t){this.results=[],this.completed=0,this.failed=0,R.info(`Starting to archive ${e.length} repositories`,{dryRun:t.dryRun});let i=e.map(o=>this.queue.add(()=>this.archiveRepository(o,t)));return await Promise.all(i),this.results}async archiveRepository(e,t){let i=Date.now();try{if(t.dryRun){console.log(`\u{1F50D} Validating ${e.owner}/${e.repo}...`),R.info(`[DRY-RUN] Would archive ${e.owner}/${e.repo}`);let s={owner:e.owner,repo:e.repo,success:!0,archived:!1,duration:Date.now()-i,message:"[DRY-RUN] Validation successful"};this.results.push(s),this.completed++;return}let o=await this.gitHubService.validateRepository(e.owner,e.repo);if(!o.exists){R.warn(`Repository not found: ${e.owner}/${e.repo}`);let s={owner:e.owner,repo:e.repo,success:!1,archived:!1,error:"Repository not found",duration:Date.now()-i,message:"Repository does not exist on GitHub"};this.results.push(s),this.failed++;return}if(o.isArchived){R.info(`Repository already archived: ${e.owner}/${e.repo}`);let s={owner:e.owner,repo:e.repo,success:!0,archived:!1,duration:Date.now()-i,message:"Repository is already archived"};this.results.push(s),this.completed++;return}console.log(`\u{1F4E6} Archiving ${e.owner}/${e.repo}...`),await this.gitHubService.archiveRepository(e.owner,e.repo);let n={owner:e.owner,repo:e.repo,success:!0,archived:!0,duration:Date.now()-i,message:"Repository archived successfully"};this.results.push(n),this.completed++,R.info(`\u2713 Archived ${e.owner}/${e.repo}`,{duration:n.duration})}catch(o){if(Y(o)&&o.code===d.ALREADY_ARCHIVED){R.info(`Repository already archived: ${e.owner}/${e.repo}`);let a={owner:e.owner,repo:e.repo,success:!0,archived:!1,duration:Date.now()-i,message:"Repository is already archived"};this.results.push(a),this.completed++;return}let n=o instanceof Error?o.message:String(o);R.error(`\u2717 Failed to archive ${e.owner}/${e.repo}: ${n}`);let s={owner:e.owner,repo:e.repo,success:!1,archived:!1,error:n,duration:Date.now()-i,message:`Error: ${n}`};this.results.push(s),this.failed++}}getProgress(){return{completed:this.completed,failed:this.failed,total:this.results.length}}getSummary(){let e=this.results.filter(n=>n.success&&n.archived).length,t=this.results.filter(n=>!n.success).length,i=this.results.filter(n=>n.success&&!n.archived).length,o=Date.now()-this.startTime;return{successful:e,failed:t,skipped:i,totalDuration:o}}};import{Octokit as Q}from"octokit";import{promises as C}from"node:fs";import{join as Z}from"node:path";var _=class{constructor(e=f.APP_DIR){this.configDir=e,this.configFile=Z(e,"config.json")}async loadConfig(){try{let e=process.env.GH_TOKEN,t=await this.loadFileCredentials();return{token:e||t?.token,concurrency:3,timeout:300,logLevel:T,logDir:Z(this.configDir,"logs"),configDir:this.configDir}}catch(e){throw q(`Failed to load configuration: ${e instanceof Error?e.message:String(e)}`)}}async saveConfig(e){try{await this.ensureConfigDir(),await C.writeFile(this.configFile,JSON.stringify(e,null,2),"utf-8")}catch(t){throw O(`Failed to save configuration: ${t instanceof Error?t.message:String(t)}`)}}async ensureConfigDir(){try{await C.mkdir(this.configDir,{recursive:!0})}catch(e){throw O(`Failed to create config directory: ${e instanceof Error?e.message:String(e)}`)}}async getStoredCredentials(){try{let e=await C.readFile(this.configFile,"utf-8");return JSON.parse(e)}catch{return null}}async removeStoredCredentials(){try{await C.unlink(this.configFile)}catch(e){if(e.code!=="ENOENT")throw O(`Failed to remove stored credentials: ${e instanceof Error?e.message:String(e)}`)}}async loadFileCredentials(){try{let e=await C.readFile(this.configFile,"utf-8");return JSON.parse(e)}catch{return null}}};var w=class{constructor(e=f.APP_DIR){this.configManager=new _(e)}async saveToken(e){if(!e||typeof e!="string")throw H("Invalid token format");let t=new Q({auth:e});try{let{data:i}=await t.rest.users.getAuthenticated(),o={token:e,savedAt:new Date().toISOString(),githubUser:i.login};await this.configManager.saveConfig(o)}catch(i){throw H(`Failed to validate token: ${i instanceof Error?i.message:String(i)}`)}}async getToken(){return process.env.GH_TOKEN?process.env.GH_TOKEN:(await this.configManager.getStoredCredentials())?.token}async removeToken(){await this.configManager.removeStoredCredentials()}async validateToken(e){try{let t=new Q({auth:e}),{data:i}=await t.rest.users.getAuthenticated();return{valid:!0,user:i.login}}catch{return{valid:!1}}}getStoredCredentials(){return this.configManager.getStoredCredentials()}ensureConfigDir(){return this.configManager.ensureConfigDir()}loadConfig(){return this.configManager.loadConfig()}};import{Octokit as fe}from"octokit";var g=l(),P=class{constructor(e){this.octokit=new fe({auth:e})}async archiveRepository(e,t){let i=Date.now();g.debug(`Attempting to archive ${e}/${t}`),await this.retryWithBackoff(async()=>{try{await this.octokit.rest.repos.update({owner:e,repo:t,archived:!0});let o=Date.now()-i;g.info(`Successfully archived ${e}/${t} in ${o}ms`)}catch(o){this.handleArchiveError(o,e,t)}})}handleArchiveError(e,t,i){let o=this.parseOctokitError(e);throw g.error(`Failed to archive ${t}/${i}: ${o.message}`,{status:o.status,code:o.code}),o.status===404?K(t,i):o.status===403||o.message.includes("permission")?z(t,i):o.status===422&&o.message.includes("archived")?W(t,i):o.message.includes("API rate limit")?j():o.message.includes("ECONNREFUSED")||o.message.includes("ETIMEDOUT")||o.message.includes("EHOSTUNREACH")||o.message.includes("socket hang up")?M(o.message):e}parseOctokitError(e){let t=e instanceof Error?e.message:String(e),i=e;return{message:t,status:i?.status||0,code:i?.response?.data?.message}}async validateRepository(e,t){try{g.debug(`Validating repository ${e}/${t}`);let{data:i}=await this.octokit.rest.repos.get({owner:e,repo:t}),o={exists:!0,isArchived:i.archived};return g.debug(`Repository ${e}/${t} validated`,o),o}catch(i){if(i instanceof Error&&i.message.includes("404"))return g.debug(`Repository ${e}/${t} does not exist`),{exists:!1,isArchived:!1};throw g.error(`Error validating ${e}/${t}:`,i),i}}async getRateLimitStatus(){try{g.debug("Fetching rate limit status");let{data:e}=await this.octokit.rest.rateLimit.get(),t={remaining:e.rate.remaining,reset:new Date(e.rate.reset*1e3),limit:e.rate.limit};return g.debug("Rate limit status retrieved",{remaining:t.remaining,limit:t.limit,resetAt:t.reset.toISOString()}),t}catch(e){throw g.error("Failed to fetch rate limit status:",e),e}}async validateAuth(){try{g.debug("Validating authentication");let{data:e}=await this.octokit.rest.users.getAuthenticated();return g.info(`Authenticated as user: ${e.login}`),e.login}catch(e){throw g.error("Authentication validation failed:",e),M(e instanceof Error?e.message:"Authentication failed")}}async retryWithBackoff(e,t=3){let i;for(let o=0;o<t;o++)try{return await e()}catch(n){i=n;let s=i.message.toLowerCase();if(!(s.includes("rate limit")||s.includes("timeout")||s.includes("econnrefused")||s.includes("etimedout")||s.includes("ehostunreach")||s.includes("socket hang up"))||o===t-1)throw n;let c=1e3*2**o;g.warn(`Retry attempt ${o+1}/${t} after ${c}ms`,{error:s}),await new Promise(v=>setTimeout(v,c))}throw i||new Error("Unknown error during retry")}};import{promises as Re}from"node:fs";import{createInterface as V}from"node:readline";var k=l(),pe=/^[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$/,he=[/^(?:https?:\/\/)?(?:www\.)?github\.com[/:]([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:\/)?$/i,/^git@github\.com:([\w.-]+)\/([\w.-]+?)(?:\.git)?$/i,/^([\w.-]+)\/([\w.-]+)$/];function re(r){let e=r.trim();if(!e)throw new u(d.INVALID_URL,"URL cannot be empty");for(let t of he){let i=e.match(t);if(i){let o=i[1],n=i[2];if(!(o&&n))throw new u(d.INVALID_URL,`Invalid GitHub URL format: ${r}`);if(!ee(o))throw new u(d.INVALID_URL,`Invalid owner name: ${o}. Owner names must contain only alphanumeric characters, hyphens, or periods.`);if(!ee(n))throw new u(d.INVALID_URL,`Invalid repository name: ${n}. Repository names must contain only alphanumeric characters, hyphens, underscores, or periods.`);let s=`https://github.com/${o}/${n}`;return k.debug("Parsed repository URL",{original:e,owner:o,repo:n,normalized:s}),{owner:o,repo:n,url:s}}}throw new u(d.INVALID_URL,`Invalid GitHub URL: ${r}`)}function ee(r){return pe.test(r)}function ve(r){let e=[],t=[];for(let[i,o]of r.entries()){let n=i+1,s=o.trim();if(!(!s||s.startsWith("#")))try{let a=re(s);e.push(a),k.debug(`Line ${n}: Valid repository`,{owner:a.owner,repo:a.repo})}catch(a){let c=a instanceof Error?a.message:String(a);t.push({url:s,error:c,line:n}),k.warn(`Line ${n}: Invalid repository`,{url:s,error:c})}}return k.info("Batch parsing complete",{total:r.length,valid:e.length,invalid:t.length,skipped:r.length-e.length-t.length}),{valid:e,invalid:t}}var N={parseRepositoryUrl:re,parseRepositoriesBatch:ve};var p=l(),F=class{getRepositoriesFromInteractive(){return p.info("Starting interactive CLI input for repositories"),new Promise(e=>{let t=V({input:process.stdin,output:process.stdout});console.log(""),console.log("\u{1F4DD} Enter repository URLs one at a time:"),console.log(" (Press CTRL+D to finish, or leave empty and press Enter to skip)"),console.log("");let i=[],o=1,n=!1,s=()=>{t.question(`[${o}] > `,c=>{let v=c.trim();if(v===""){o++,s();return}i.push(v),o++,s()})},a=()=>{if(n)return;n=!0,t.close();let c=N.parseRepositoriesBatch(i);c.invalid.length>0&&p.warn(`Found ${c.invalid.length} invalid repositories`,{errors:c.invalid}),p.info(`Parsed ${c.valid.length} valid repositories`),e({repos:c.valid,errors:c.invalid})};t.on("close",()=>{a()}),s()})}async getRepositoriesFromFile(e){p.info(`Reading repositories from file: ${e}`);try{let i=(await Re.readFile(e,"utf-8")).split(`
2
+ `),o=N.parseRepositoriesBatch(i);return o.invalid.length>0&&p.warn(`Found ${o.invalid.length} invalid entries in file`,{errors:o.invalid}),p.info(`Parsed ${o.valid.length} valid repositories from file`),{repos:o.valid,errors:o.invalid}}catch(t){let i=t instanceof Error?t.message:String(t);throw p.error(`Failed to read file ${e}: ${i}`),new Error(`Failed to read file: ${i}`)}}getRepositoriesFromStdin(){return p.info("Reading repositories from stdin"),new Promise(e=>{let t=[],i=V({input:process.stdin,output:process.stdout});i.on("line",o=>{t.push(o)}),i.on("close",()=>{let o=N.parseRepositoriesBatch(t);o.invalid.length>0&&p.warn(`Found ${o.invalid.length} invalid entries from stdin`,{errors:o.invalid}),p.info(`Parsed ${o.valid.length} valid repositories from stdin`),e({repos:o.valid,errors:o.invalid})})})}promptForConfirmation(e){return new Promise(t=>{let i=V({input:process.stdin,output:process.stdout});i.question(`${e} [y/N]: `,o=>{i.close();let n=o.toLowerCase()==="y";p.info(`User confirmation: ${n}`),t(n)})})}};function ye(r){if(r<1e3)return`${r}ms`;if(r<6e4)return`${(r/1e3).toFixed(1)}s`;let e=Math.floor(r/6e4),t=(r%6e4/1e3).toFixed(0);return`${e}m ${t}s`}function Ee(r){if(r===0)return"0 B";let e=1024,t=["B","KB","MB","GB"],i=Math.floor(Math.log(r)/Math.log(e));return`${(r/e**i).toFixed(2)} ${t[i]}`}function we(r,e){return e===0?"0%":`${(r/e*100).toFixed(1)}%`}function Ae(r,e,t=30){if(e===0)return"[ ]";let i=Math.round(r/e*t),o=t-i,n="=".repeat(i),s=" ".repeat(o),a=(r/e*100).toFixed(0);return`[${n}${s}] ${a}%`}function Ie(r,e){let t=Math.max(0,(e-r.length)/2);return" ".repeat(Math.floor(t))+r}function be(r,e){return r.length<=e?r:`${r.substring(0,e-3)}...`}var $={formatDuration:ye,formatBytes:Ee,formatPercent:we,createProgressBar:Ae,centerText:Ie,truncate:be};var x=class{constructor(){this.lastUpdate=0;this.updateInterval=500;this.startTime=Date.now()}shouldUpdate(){let e=Date.now();return e-this.lastUpdate>=this.updateInterval?(this.lastUpdate=e,!0):!1}getProgressBar(e){let{completed:t,total:i,current:o}=e,n=i>0?t/i*100:0,a=`${$.createProgressBar(t,i,25)} ${t}/${i} (${n.toFixed(0)}%)`;return o&&(a+=` - ${o.owner}/${o.repo}`),a}getSummaryBox(e){let{successful:t,failed:i,skipped:o,totalDuration:n}=e,s=t+i+o,a=$.formatDuration(n),c=(A,U,ne=0)=>{let B=String(U),se=31-(A.length+B.length)+ne;return`\u2551 ${A}${" ".repeat(Math.max(1,se))}${B} \u2551`};return["\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557","\u2551 Archive Operation Summary \u2551","\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563",c("\u2705 Successful:",String(t),2),c("\u26A0\uFE0F Skipped:",String(o),3),c("\u274C Failed:",String(i),2),"\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563",c("Total:",String(s),3),c("Duration:",a,3),"\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"].join(`
3
+ `)}getElapsedTime(){let e=Date.now()-this.startTime;return $.formatDuration(e)}getEstimatedTimeRemaining(e,t){if(e===0)return null;let o=(Date.now()-this.startTime)/e,n=(t-e)*o;return n>0?$.formatDuration(n):null}};var y=l();function te(){return new Ce("archive").description("Archive GitHub repositories").option("--file <path>","Read repository URLs from file").option("--stdin","Read repository URLs from standard input").option("--dry-run","Validate without archiving",!1).option("--concurrency <n>","Number of parallel operations","3").option("--timeout <n>","API timeout in seconds","300").option("--verbose","Verbose logging",!1).option("--force","Skip confirmations",!1).action(async r=>{await $e(r)})}async function $e(r){try{y.info("Archive command started",{options:r});let{concurrency:e,timeout:t}=Se(r),i=new w(f.APP_DIR),o=new F,n=new x,s=await Oe(i),{repositories:a,parseErrors:c}=await Te(r,o);c.length>0&&De(c),a.length===0&&(console.error(`\u274C ${m.NO_REPOS_PROVIDED}`),process.exit(1)),Le(a,r.dryRun),await _e(r,o);let v={dryRun:r.dryRun,concurrency:e,timeout:t,force:r.force,verbose:r.verbose};console.log(""),console.log(`${m.ARCHIVING_START} (concurrency: ${e})`),console.log("");let A=new L(s,v),U=await Pe(A,a,v,n);ke(A,U,n)}catch(e){Ne(e)}}function Se(r){let e=Number.parseInt(r.concurrency,10),t=Number.parseInt(r.timeout,10);return(e<1||e>50)&&(console.error("\u274C Concurrency must be between 1 and 50"),process.exit(1)),(t<10||t>3600)&&(console.error("\u274C Timeout must be between 10 and 3600 seconds"),process.exit(1)),{concurrency:e,timeout:t}}async function Oe(r){console.log("\u{1F510} Checking authentication...");let e=await r.getToken();e||(console.error(`\u274C ${m.NO_TOKEN}`),console.error(" Run: github-archiver auth login"),process.exit(1));let t=new P(e);try{let i=await t.validateAuth();return console.log(`\u2705 Authenticated as: ${i}`),t}catch(i){console.error("\u274C Authentication failed"),y.error("Auth validation failed:",i),process.exit(1)}}async function Te(r,e){console.log(""),console.log("\u{1F4DD} Getting repositories...");let t=[],i=[];if(r.file){y.info(`Using file input: ${r.file}`);let o=await e.getRepositoriesFromFile(r.file);t=o.repos,i=o.errors}else if(r.stdin){y.info("Using stdin input"),console.log("Enter repository URLs (one per line, press Ctrl+D to finish):");let o=await e.getRepositoriesFromStdin();t=o.repos,i=o.errors}else{y.info("Using interactive CLI input");let o=await e.getRepositoriesFromInteractive();t=o.repos,i=o.errors}return{repositories:t,parseErrors:i}}function De(r){console.warn(`\u26A0\uFE0F Found ${r.length} invalid repositories:`);for(let e of r)console.warn(` Line ${e.line}: ${e.error}`);console.warn("")}function Le(r,e){console.log(`\u{1F4CB} Will ${e?"validate":"archive"} ${r.length} repositories:`);for(let t=0;t<Math.min(r.length,5);t++){let i=r[t];i&&console.log(` ${t+1}. ${i.owner}/${i.repo}`)}r.length>5&&console.log(` ... and ${r.length-5} more`)}async function _e(r,e){console.log(""),r.force||r.dryRun?r.dryRun&&console.log(`\u2139\uFE0F ${m.DRY_RUN_MODE}`):await e.promptForConfirmation("Are you sure you want to archive these repositories?")||(console.log("\u274C Cancelled"),process.exit(1))}async function Pe(r,e,t,i){let o=await r.archiveRepositories(e,t),n=r.getSummary(),s={completed:n.successful+n.failed+n.skipped,failed:n.failed,total:e.length};return i.shouldUpdate()&&console.log(`\r${i.getProgressBar(s)}`),o}function ke(r,e,t){console.log(""),console.log("");let i=r.getSummary();if(console.log(t.getSummaryBox(i)),i.failed>0){console.log(""),console.log("\u274C Failed repositories:");for(let o of e)o.success||console.log(` ${o.owner}/${o.repo}: ${o.message}`)}if(i.skipped>0){console.log(""),console.log("\u26A0\uFE0F Skipped repositories:");for(let o of e)o.success&&!o.archived&&console.log(` ${o.owner}/${o.repo}: ${o.message}`)}i.failed>0?(y.warn(`Archive command completed with ${i.failed} failures`),process.exit(1)):(console.log(""),console.log("\u2705 All repositories processed successfully!"),y.info("Archive command completed successfully"),process.exit(0))}function Ne(r){let e=r instanceof Error?r.message:String(r);console.error(`\u274C Error: ${e}`),y.error("Archive command failed:",r),Fe(e),process.exit(1)}function Fe(r){let e=r.toLowerCase();if(e.includes("token")||e.includes("authentication")){console.log(""),console.log("\u{1F4A1} Troubleshooting:"),console.log(" 1. Make sure you have a valid GitHub Personal Access Token"),console.log(' 2. The token needs "repo" scope to archive repositories'),console.log(" 3. Run: github-archiver auth login");return}if(e.includes("rate limit")){console.log(""),console.log("\u{1F4A1} Troubleshooting:"),console.log(" 1. GitHub API rate limit has been exceeded"),console.log(" 2. Wait a few minutes and try again"),console.log(" 3. Use lower concurrency: --concurrency 1");return}if(e.includes("permission")||e.includes("403")){console.log(""),console.log("\u{1F4A1} Troubleshooting:"),console.log(" 1. You must be the repository owner or have push access"),console.log(" 2. Check that your GitHub token has correct permissions"),console.log(" 3. Verify you have push access to the repositories");return}if(e.includes("not found")||e.includes("404")){console.log(""),console.log("\u{1F4A1} Troubleshooting:"),console.log(" 1. Make sure the repository URL is correct"),console.log(" 2. The repository may have been deleted"),console.log(" 3. Check your GitHub access to the repository");return}(e.includes("network")||e.includes("timeout"))&&(console.log(""),console.log("\u{1F4A1} Troubleshooting:"),console.log(" 1. Check your internet connection"),console.log(" 2. GitHub API may be temporarily unavailable"),console.log(" 3. Try again in a moment"),console.log(" 4. Increase timeout: --timeout 600"))}import{createInterface as oe}from"node:readline";import{Command as S}from"commander";var h=new w(f.APP_DIR);function xe(){return new S("login").description("Set up GitHub authentication with a Personal Access Token").action(async()=>{try{await h.ensureConfigDir();let r=await Ge();r||(console.error("No token provided. Aborting."),process.exit(1)),console.log("Validating token..."),await h.saveToken(r);let e=await h.getStoredCredentials();console.log(`\u2713 ${m.AUTH_SUCCESS}`),console.log(` User: ${e?.githubUser}`),l().info("Token saved successfully",{user:e?.githubUser})}catch(r){let e=r instanceof Error?r.message:String(r);console.error(`\u2717 Error: ${e}`),l().error("Failed to save token",{error:e}),process.exit(1)}})}function Ue(){return new S("logout").description("Remove stored GitHub authentication token").action(async()=>{try{if(!await h.getStoredCredentials()){console.log("No stored credentials found.");return}if(!await Ve(m.CONFIRM_LOGOUT)){console.log("Cancelled.");return}await h.removeToken(),console.log(`\u2713 ${m.TOKEN_REMOVED}`),l().info("Token removed")}catch(r){let e=r instanceof Error?r.message:String(r);console.error(`\u2717 Error: ${e}`),l().error("Failed to remove token",{error:e}),process.exit(1)}})}function He(){return new S("status").description("Check authentication status").action(async()=>{try{let r=await h.getToken();if(!r){console.log("\u2717 Not authenticated"),console.log(' Run "github-archiver auth login" to set up authentication');return}console.log("\u2713 Authenticated");let e=await h.validateToken(r);if(e.valid){console.log(` User: ${e.user}`);let t=await h.getStoredCredentials();t&&console.log(` Saved at: ${new Date(t.savedAt).toLocaleString()}`),l().info("Authentication status check passed")}else console.log("\u2717 Token is invalid or expired"),l().warn("Token validation failed")}catch(r){let e=r instanceof Error?r.message:String(r);console.error(`\u2717 Error: ${e}`),l().error("Failed to check auth status",{error:e}),process.exit(1)}})}function Me(){return new S("validate").description("Validate stored authentication token").action(async()=>{try{let r=await h.getToken();r||(console.log("\u2717 No token found"),process.exit(1)),console.log("Validating token...");let e=await h.validateToken(r);e.valid?(console.log(`\u2713 Token is valid (user: ${e.user})`),l().info("Token validation successful",{user:e.user})):(console.log("\u2717 Token is invalid or expired"),l().warn("Token validation failed"),process.exit(1))}catch(r){let e=r instanceof Error?r.message:String(r);console.error(`\u2717 Error: ${e}`),l().error("Token validation error",{error:e}),process.exit(1)}})}function Ge(){return new Promise(r=>{let e=oe({input:process.stdin,output:process.stdout});e.question(m.ENTER_TOKEN,t=>{e.close(),r(t.trim())})})}function Ve(r){return new Promise(e=>{let t=oe({input:process.stdin,output:process.stdout});t.question(`${r} [y/N]: `,i=>{t.close(),e(i.toLowerCase()==="y")})})}function ie(){return new S("auth").description("Manage GitHub authentication").addCommand(xe()).addCommand(Ue()).addCommand(He()).addCommand(Me())}var Ye="1.0.6",Ke="Archive GitHub repositories via CLI";async function We(){try{await J(f.LOG_DIR);let r=G();X(r);let e=new Be;e.name("github-archiver").description(Ke).version(Ye,"-v, --version","Display version"),e.addCommand(ie()),e.addCommand(te()),e.addHelpCommand(!0),await e.parseAsync(process.argv),process.argv.slice(2).length||e.outputHelp()}catch(r){let e=r instanceof Error?r.message:String(r);console.error(`\u2717 Fatal error: ${e}`),process.exit(1)}}We();
4
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts", "../src/commands/archive.ts", "../src/constants/messages.ts", "../src/constants/paths.ts", "../src/services/archiver.ts", "../src/types/error.ts", "../src/utils/errors.ts", "../src/utils/logger.ts", "../src/constants/defaults.ts", "../src/services/auth-manager.ts", "../src/utils/config.ts", "../src/services/github.ts", "../src/utils/input-handler.ts", "../src/utils/parser.ts", "../src/utils/formatting.ts", "../src/utils/progress.ts", "../src/commands/auth.ts"],
4
- "sourcesContent": ["import { Command } from \"commander\";\nimport { createArchiveCommand } from \"./commands/archive\";\nimport { createAuthCommand } from \"./commands/auth\";\nimport { PATHS } from \"./constants/paths\";\nimport { createLogger, initializeLogger, setLogger } from \"./utils/logger\";\n\nconst VERSION = \"1.0.6\";\nconst DESCRIPTION = \"Archive GitHub repositories via CLI\";\n\nasync function main() {\n try {\n await initializeLogger(PATHS.LOG_DIR);\n\n const fileLogger = createLogger();\n\n setLogger(fileLogger);\n\n const program = new Command();\n\n program\n .name(\"github-archiver\")\n .description(DESCRIPTION)\n .version(VERSION, \"-v, --version\", \"Display version\");\n\n program.addCommand(createAuthCommand());\n program.addCommand(createArchiveCommand());\n\n program.addHelpCommand(true);\n\n await program.parseAsync(process.argv);\n\n if (!process.argv.slice(2).length) {\n program.outputHelp();\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`\u2717 Fatal error: ${message}`);\n process.exit(1);\n }\n}\n\nmain();\n", "import { Command } from \"commander\";\nimport { MESSAGES } from \"../constants/messages\";\nimport { PATHS } from \"../constants/paths\";\nimport { Archiver } from \"../services/archiver\";\nimport { AuthManager } from \"../services/auth-manager\";\nimport { GitHubService } from \"../services/github\";\nimport type {\n ArchiveOptions,\n ArchiveResult,\n CommandOptions,\n RepositoryIdentifier,\n} from \"../types\";\nimport { InputHandler } from \"../utils/input-handler\";\nimport { getLogger } from \"../utils/logger\";\nimport { ProgressDisplay } from \"../utils/progress\";\n\nconst logger = getLogger();\n\nexport function createArchiveCommand(): Command {\n return new Command(\"archive\")\n .description(\"Archive GitHub repositories\")\n .option(\"--file <path>\", \"Read repository URLs from file\")\n .option(\"--stdin\", \"Read repository URLs from standard input\")\n .option(\"--dry-run\", \"Validate without archiving\", false)\n .option(\"--concurrency <n>\", \"Number of parallel operations\", \"3\")\n .option(\"--timeout <n>\", \"API timeout in seconds\", \"300\")\n .option(\"--verbose\", \"Verbose logging\", false)\n .option(\"--force\", \"Skip confirmations\", false)\n .action(async (options: CommandOptions) => {\n await archiveCommand(options);\n });\n}\n\nasync function archiveCommand(options: CommandOptions): Promise<void> {\n try {\n logger.info(\"Archive command started\", { options });\n\n const { concurrency, timeout } = validateOptions(options);\n\n const authManager = new AuthManager(PATHS.APP_DIR);\n const inputHandler = new InputHandler();\n const progressDisplay = new ProgressDisplay();\n\n const githubService = await authenticateUser(authManager);\n\n const { repositories, parseErrors } = await getRepositories(\n options,\n inputHandler\n );\n\n if (parseErrors.length > 0) {\n logParseErrors(parseErrors);\n }\n\n if (repositories.length === 0) {\n console.error(`\u274C ${MESSAGES.NO_REPOS_PROVIDED}`);\n process.exit(1);\n }\n\n showRepositoriesPreview(repositories, options.dryRun);\n\n await confirmOperation(options, inputHandler);\n\n const archiveOptions: ArchiveOptions = {\n dryRun: options.dryRun,\n concurrency,\n timeout,\n force: options.force,\n verbose: options.verbose,\n };\n\n console.log(\"\");\n console.log(`${MESSAGES.ARCHIVING_START} (concurrency: ${concurrency})`);\n console.log(\"\");\n\n const archiver = new Archiver(githubService, archiveOptions);\n const results = await archiveRepositories(\n archiver,\n repositories,\n archiveOptions,\n progressDisplay\n );\n\n displayResults(archiver, results, progressDisplay);\n } catch (error) {\n handleArchiveError(error);\n }\n}\n\nfunction validateOptions(options: CommandOptions): {\n concurrency: number;\n timeout: number;\n} {\n const concurrency = Number.parseInt(options.concurrency, 10);\n const timeout = Number.parseInt(options.timeout, 10);\n\n if (concurrency < 1 || concurrency > 50) {\n console.error(\"\u274C Concurrency must be between 1 and 50\");\n process.exit(1);\n }\n\n if (timeout < 10 || timeout > 3600) {\n console.error(\"\u274C Timeout must be between 10 and 3600 seconds\");\n process.exit(1);\n }\n\n return { concurrency, timeout };\n}\n\nasync function authenticateUser(\n authManager: AuthManager\n): Promise<GitHubService> {\n console.log(\"\uD83D\uDD10 Checking authentication...\");\n const token = await authManager.getToken();\n\n if (!token) {\n console.error(`\u274C ${MESSAGES.NO_TOKEN}`);\n console.error(\" Run: github-archiver auth login\");\n process.exit(1);\n }\n\n const githubService = new GitHubService(token);\n\n try {\n const authenticatedUser = await githubService.validateAuth();\n console.log(`\u2705 Authenticated as: ${authenticatedUser}`);\n return githubService;\n } catch (error) {\n console.error(\"\u274C Authentication failed\");\n logger.error(\"Auth validation failed:\", error);\n process.exit(1);\n }\n}\n\nasync function getRepositories(\n options: CommandOptions,\n inputHandler: InputHandler\n): Promise<{\n repositories: RepositoryIdentifier[];\n parseErrors: Array<{ url: string; error: string; line: number }>;\n}> {\n console.log(\"\");\n console.log(\"\uD83D\uDCDD Getting repositories...\");\n\n let repositories: RepositoryIdentifier[] = [];\n let parseErrors: Array<{ url: string; error: string; line: number }> = [];\n\n if (options.file) {\n logger.info(`Using file input: ${options.file}`);\n const result = await inputHandler.getRepositoriesFromFile(options.file);\n repositories = result.repos;\n parseErrors = result.errors;\n } else if (options.stdin) {\n logger.info(\"Using stdin input\");\n console.log(\n \"Enter repository URLs (one per line, press Ctrl+D to finish):\"\n );\n const result = await inputHandler.getRepositoriesFromStdin();\n repositories = result.repos;\n parseErrors = result.errors;\n } else {\n logger.info(\"Using interactive CLI input\");\n const result = await inputHandler.getRepositoriesFromInteractive();\n repositories = result.repos;\n parseErrors = result.errors;\n }\n\n return { repositories, parseErrors };\n}\n\nfunction logParseErrors(\n parseErrors: Array<{ url: string; error: string; line: number }>\n): void {\n console.warn(`\u26A0\uFE0F Found ${parseErrors.length} invalid repositories:`);\n for (const err of parseErrors) {\n console.warn(` Line ${err.line}: ${err.error}`);\n }\n console.warn(\"\");\n}\n\nfunction showRepositoriesPreview(\n repositories: RepositoryIdentifier[],\n dryRun: boolean\n): void {\n console.log(\n `\uD83D\uDCCB Will ${dryRun ? \"validate\" : \"archive\"} ${repositories.length} repositories:`\n );\n for (let index = 0; index < Math.min(repositories.length, 5); index++) {\n const repo = repositories[index];\n if (repo) {\n console.log(` ${index + 1}. ${repo.owner}/${repo.repo}`);\n }\n }\n if (repositories.length > 5) {\n console.log(` ... and ${repositories.length - 5} more`);\n }\n}\n\nasync function confirmOperation(\n options: CommandOptions,\n inputHandler: InputHandler\n): Promise<void> {\n console.log(\"\");\n if (!(options.force || options.dryRun)) {\n const confirmed = await inputHandler.promptForConfirmation(\n \"Are you sure you want to archive these repositories?\"\n );\n\n if (!confirmed) {\n console.log(\"\u274C Cancelled\");\n process.exit(1);\n }\n } else if (options.dryRun) {\n console.log(`\u2139\uFE0F ${MESSAGES.DRY_RUN_MODE}`);\n }\n}\n\nasync function archiveRepositories(\n archiver: Archiver,\n repositories: RepositoryIdentifier[],\n options: ArchiveOptions,\n progressDisplay: ProgressDisplay\n): Promise<ArchiveResult[]> {\n const results = await archiver.archiveRepositories(repositories, options);\n\n const summary = archiver.getSummary();\n const progress = {\n completed: summary.successful + summary.failed + summary.skipped,\n failed: summary.failed,\n total: repositories.length,\n };\n\n if (progressDisplay.shouldUpdate()) {\n console.log(`\\r${progressDisplay.getProgressBar(progress)}`);\n }\n\n return results;\n}\n\nfunction displayResults(\n archiver: Archiver,\n results: ArchiveResult[],\n progressDisplay: ProgressDisplay\n): void {\n console.log(\"\");\n console.log(\"\");\n\n const summary = archiver.getSummary();\n console.log(progressDisplay.getSummaryBox(summary));\n\n if (summary.failed > 0) {\n console.log(\"\");\n console.log(\"\u274C Failed repositories:\");\n for (const r of results) {\n if (!r.success) {\n console.log(` ${r.owner}/${r.repo}: ${r.message}`);\n }\n }\n }\n\n if (summary.skipped > 0) {\n console.log(\"\");\n console.log(\"\u26A0\uFE0F Skipped repositories:\");\n for (const r of results) {\n if (r.success && !r.archived) {\n console.log(` ${r.owner}/${r.repo}: ${r.message}`);\n }\n }\n }\n\n if (summary.failed > 0) {\n logger.warn(`Archive command completed with ${summary.failed} failures`);\n process.exit(1);\n } else {\n console.log(\"\");\n console.log(\"\u2705 All repositories processed successfully!\");\n logger.info(\"Archive command completed successfully\");\n process.exit(0);\n }\n}\n\nfunction handleArchiveError(error: unknown): never {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`\u274C Error: ${message}`);\n logger.error(\"Archive command failed:\", error);\n\n provideErrorGuidance(message);\n\n process.exit(1);\n}\n\nfunction provideErrorGuidance(message: string): void {\n const lowerMessage = message.toLowerCase();\n\n if (\n lowerMessage.includes(\"token\") ||\n lowerMessage.includes(\"authentication\")\n ) {\n console.log(\"\");\n console.log(\"\uD83D\uDCA1 Troubleshooting:\");\n console.log(\n \" 1. Make sure you have a valid GitHub Personal Access Token\"\n );\n console.log(' 2. The token needs \"repo\" scope to archive repositories');\n console.log(\" 3. Run: github-archiver auth login\");\n return;\n }\n\n if (lowerMessage.includes(\"rate limit\")) {\n console.log(\"\");\n console.log(\"\uD83D\uDCA1 Troubleshooting:\");\n console.log(\" 1. GitHub API rate limit has been exceeded\");\n console.log(\" 2. Wait a few minutes and try again\");\n console.log(\" 3. Use lower concurrency: --concurrency 1\");\n return;\n }\n\n if (lowerMessage.includes(\"permission\") || lowerMessage.includes(\"403\")) {\n console.log(\"\");\n console.log(\"\uD83D\uDCA1 Troubleshooting:\");\n console.log(\" 1. You must be the repository owner or have push access\");\n console.log(\" 2. Check that your GitHub token has correct permissions\");\n console.log(\" 3. Verify you have push access to the repositories\");\n return;\n }\n\n if (lowerMessage.includes(\"not found\") || lowerMessage.includes(\"404\")) {\n console.log(\"\");\n console.log(\"\uD83D\uDCA1 Troubleshooting:\");\n console.log(\" 1. Make sure the repository URL is correct\");\n console.log(\" 2. The repository may have been deleted\");\n console.log(\" 3. Check your GitHub access to the repository\");\n return;\n }\n\n if (lowerMessage.includes(\"network\") || lowerMessage.includes(\"timeout\")) {\n console.log(\"\");\n console.log(\"\uD83D\uDCA1 Troubleshooting:\");\n console.log(\" 1. Check your internet connection\");\n console.log(\" 2. GitHub API may be temporarily unavailable\");\n console.log(\" 3. Try again in a moment\");\n console.log(\" 4. Increase timeout: --timeout 600\");\n }\n}\n", "export const MESSAGES = {\n AUTH_SUCCESS: \"Successfully authenticated with GitHub\",\n ARCHIVE_SUCCESS: \"Repository archived successfully\",\n TOKEN_SAVED: \"GitHub token saved successfully\",\n TOKEN_REMOVED: \"GitHub token removed\",\n INVALID_TOKEN: \"Invalid or expired GitHub token\",\n REPO_NOT_FOUND: \"Repository not found\",\n ALREADY_ARCHIVED: \"Repository is already archived\",\n PERMISSION_DENIED: \"You do not have permission to archive this repository\",\n RATE_LIMITED: \"GitHub API rate limit exceeded. Please try again later\",\n NETWORK_ERROR: \"Network error. Please check your connection\",\n INVALID_URL: \"Invalid GitHub repository URL\",\n NO_TOKEN:\n 'No GitHub token found. Please run \"github-archiver auth login\" first',\n OPENING_EDITOR: \"Opening text editor for repository URLs...\",\n NO_REPOS_PROVIDED: \"No repositories provided\",\n ARCHIVING_START: \"Starting to archive repositories...\",\n ARCHIVING_COMPLETE: \"Archiving complete\",\n DRY_RUN_MODE: \"Running in dry-run mode (no repositories will be archived)\",\n CONFIRM_ARCHIVE: \"Are you sure you want to archive these repositories?\",\n ENTER_TOKEN:\n \"Enter your GitHub Personal Access Token (will not be displayed):\",\n CONFIRM_LOGOUT: \"Are you sure you want to remove the stored token?\",\n};\n", "import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\n\nconst appDir = join(homedir(), \".github-archiver\");\n\nexport const PATHS = {\n APP_DIR: appDir,\n CONFIG_FILE: join(appDir, \"config.json\"),\n LOG_DIR: join(appDir, \"logs\"),\n COMBINED_LOG: join(appDir, \"logs\", \"combined.log\"),\n ERROR_LOG: join(appDir, \"logs\", \"errors.log\"),\n};\n", "import PQueue from \"p-queue\";\nimport type {\n ArchiveOptions,\n ArchiveResult,\n RepositoryIdentifier,\n} from \"../types\";\nimport { ErrorCode } from \"../types\";\nimport { isArchiveError } from \"../utils/errors\";\nimport { getLogger } from \"../utils/logger\";\nimport type { GitHubService } from \"./github\";\n\nconst logger = getLogger();\n\nexport class Archiver {\n private readonly queue: PQueue;\n private results: ArchiveResult[] = [];\n private readonly gitHubService: GitHubService;\n private completed = 0;\n private failed = 0;\n private readonly startTime = 0;\n\n constructor(gitHubService: GitHubService, options: ArchiveOptions) {\n this.gitHubService = gitHubService;\n this.queue = new PQueue({\n concurrency: options.concurrency,\n timeout: options.timeout * 1000,\n interval: 1000,\n intervalCap: options.concurrency,\n });\n\n logger.info(\"Archiver initialized\", {\n concurrency: options.concurrency,\n timeout: options.timeout,\n dryRun: options.dryRun,\n });\n }\n\n async archiveRepositories(\n repos: RepositoryIdentifier[],\n options: ArchiveOptions\n ): Promise<ArchiveResult[]> {\n this.results = [];\n this.completed = 0;\n this.failed = 0;\n\n logger.info(`Starting to archive ${repos.length} repositories`, {\n dryRun: options.dryRun,\n });\n\n const tasks = repos.map((repo) =>\n this.queue.add(() => this.archiveRepository(repo, options))\n );\n\n await Promise.all(tasks);\n\n return this.results;\n }\n\n private async archiveRepository(\n repo: RepositoryIdentifier,\n options: ArchiveOptions\n ): Promise<void> {\n const startTime = Date.now();\n\n try {\n if (options.dryRun) {\n logger.info(`[DRY-RUN] Would archive ${repo.owner}/${repo.repo}`);\n const result: ArchiveResult = {\n owner: repo.owner,\n repo: repo.repo,\n success: true,\n archived: false,\n duration: Date.now() - startTime,\n message: \"[DRY-RUN] Validation successful\",\n };\n this.results.push(result);\n this.completed++;\n return;\n }\n\n const validation = await this.gitHubService.validateRepository(\n repo.owner,\n repo.repo\n );\n\n if (!validation.exists) {\n logger.warn(`Repository not found: ${repo.owner}/${repo.repo}`);\n const result: ArchiveResult = {\n owner: repo.owner,\n repo: repo.repo,\n success: false,\n archived: false,\n error: \"Repository not found\",\n duration: Date.now() - startTime,\n message: \"Repository does not exist on GitHub\",\n };\n this.results.push(result);\n this.failed++;\n return;\n }\n\n if (validation.isArchived) {\n logger.info(`Repository already archived: ${repo.owner}/${repo.repo}`);\n const result: ArchiveResult = {\n owner: repo.owner,\n repo: repo.repo,\n success: true,\n archived: false,\n duration: Date.now() - startTime,\n message: \"Repository is already archived\",\n };\n this.results.push(result);\n this.completed++;\n return;\n }\n\n console.log(`\uD83D\uDCE6 Archiving ${repo.owner}/${repo.repo}...`);\n await this.gitHubService.archiveRepository(repo.owner, repo.repo);\n\n const result: ArchiveResult = {\n owner: repo.owner,\n repo: repo.repo,\n success: true,\n archived: true,\n duration: Date.now() - startTime,\n message: \"Repository archived successfully\",\n };\n this.results.push(result);\n this.completed++;\n logger.info(`\u2713 Archived ${repo.owner}/${repo.repo}`, {\n duration: result.duration,\n });\n } catch (error) {\n if (isArchiveError(error) && error.code === ErrorCode.ALREADY_ARCHIVED) {\n logger.info(`Repository already archived: ${repo.owner}/${repo.repo}`);\n const result: ArchiveResult = {\n owner: repo.owner,\n repo: repo.repo,\n success: true,\n archived: false,\n duration: Date.now() - startTime,\n message: \"Repository is already archived\",\n };\n this.results.push(result);\n this.completed++;\n return;\n }\n\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n logger.error(\n `\u2717 Failed to archive ${repo.owner}/${repo.repo}: ${errorMessage}`\n );\n\n const result: ArchiveResult = {\n owner: repo.owner,\n repo: repo.repo,\n success: false,\n archived: false,\n error: errorMessage,\n duration: Date.now() - startTime,\n message: `Error: ${errorMessage}`,\n };\n this.results.push(result);\n this.failed++;\n }\n }\n\n getProgress(): { completed: number; failed: number; total: number } {\n return {\n completed: this.completed,\n failed: this.failed,\n total: this.results.length,\n };\n }\n\n getSummary(): {\n successful: number;\n failed: number;\n skipped: number;\n totalDuration: number;\n } {\n const successful = this.results.filter(\n (r) => r.success && r.archived\n ).length;\n const failed = this.results.filter((r) => !r.success).length;\n const skipped = this.results.filter((r) => r.success && !r.archived).length;\n const totalDuration = Date.now() - this.startTime;\n\n return { successful, failed, skipped, totalDuration };\n }\n}\n", "export const ErrorCode = {\n INVALID_AUTH: \"INVALID_AUTH\",\n REPO_NOT_FOUND: \"REPO_NOT_FOUND\",\n ALREADY_ARCHIVED: \"ALREADY_ARCHIVED\",\n PERMISSION_DENIED: \"PERMISSION_DENIED\",\n RATE_LIMITED: \"RATE_LIMITED\",\n NETWORK_ERROR: \"NETWORK_ERROR\",\n INVALID_URL: \"INVALID_URL\",\n PARSE_ERROR: \"PARSE_ERROR\",\n EDITOR_ERROR: \"EDITOR_ERROR\",\n CONFIG_ERROR: \"CONFIG_ERROR\",\n FILE_ERROR: \"FILE_ERROR\",\n} as const;\n\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\nexport class ArchiveError extends Error {\n code: ErrorCode;\n statusCode?: number;\n retryable: boolean;\n\n constructor(\n code: ErrorCode,\n message: string,\n statusCode?: number,\n retryable = false\n ) {\n super(message);\n this.name = \"ArchiveError\";\n this.code = code;\n this.statusCode = statusCode;\n this.retryable = retryable;\n Object.setPrototypeOf(this, ArchiveError.prototype);\n }\n}\n", "import { MESSAGES } from \"../constants/messages\";\nimport { ArchiveError, ErrorCode } from \"../types\";\n\nexport function isArchiveError(error: unknown): error is ArchiveError {\n return error instanceof ArchiveError;\n}\n\nexport function getErrorMessage(error: unknown): string {\n if (isArchiveError(error)) {\n return error.message;\n }\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n}\n\nexport function createAuthError(\n message: string,\n statusCode?: number\n): ArchiveError {\n return new ArchiveError(ErrorCode.INVALID_AUTH, message, statusCode, true);\n}\n\nexport function createRepoNotFoundError(\n owner: string,\n repo: string\n): ArchiveError {\n return new ArchiveError(\n ErrorCode.REPO_NOT_FOUND,\n `Repository ${owner}/${repo} not found`,\n 404,\n false\n );\n}\n\nexport function createAlreadyArchivedError(\n owner: string,\n repo: string\n): ArchiveError {\n return new ArchiveError(\n ErrorCode.ALREADY_ARCHIVED,\n `Repository ${owner}/${repo} is already archived`,\n 422,\n false\n );\n}\n\nexport function createPermissionError(\n owner: string,\n repo: string\n): ArchiveError {\n return new ArchiveError(\n ErrorCode.PERMISSION_DENIED,\n `Permission denied for ${owner}/${repo}. You must be the repository owner or have push access.`,\n 403,\n false\n );\n}\n\nexport function createRateLimitError(): ArchiveError {\n return new ArchiveError(\n ErrorCode.RATE_LIMITED,\n MESSAGES.RATE_LIMITED,\n 429,\n true\n );\n}\n\nexport function createNetworkError(message?: string): ArchiveError {\n return new ArchiveError(\n ErrorCode.NETWORK_ERROR,\n message || MESSAGES.NETWORK_ERROR,\n undefined,\n true\n );\n}\n\nexport function createInvalidUrlError(url: string): ArchiveError {\n return new ArchiveError(ErrorCode.INVALID_URL, `Invalid GitHub URL: ${url}`);\n}\n\nexport function createConfigError(message: string): ArchiveError {\n return new ArchiveError(ErrorCode.CONFIG_ERROR, message);\n}\n\nexport function createFileError(message: string): ArchiveError {\n return new ArchiveError(ErrorCode.FILE_ERROR, message);\n}\n\nexport function createEditorError(message: string): ArchiveError {\n return new ArchiveError(ErrorCode.EDITOR_ERROR, message);\n}\n", "import { promises as fs } from \"node:fs\";\nimport winston from \"winston\";\nimport { DEFAULT_LOG_LEVEL } from \"../constants/defaults\";\nimport { PATHS } from \"../constants/paths\";\nimport type { Config } from \"../types\";\n\nlet loggerInstance: winston.Logger;\n\nexport async function initializeLogger(logDir: string): Promise<void> {\n try {\n await fs.mkdir(logDir, { recursive: true });\n } catch (error) {\n console.error(\"Failed to create log directory:\", error);\n }\n}\n\nexport function createLogger(config?: Partial<Config>): winston.Logger {\n const level = config?.logLevel || DEFAULT_LOG_LEVEL;\n const logDir = config?.logDir || PATHS.LOG_DIR;\n\n return winston.createLogger({\n level,\n format: winston.format.combine(\n winston.format.timestamp({ format: \"YYYY-MM-DD HH:mm:ss\" }),\n winston.format.errors({ stack: true }),\n winston.format.json()\n ),\n defaultMeta: { service: \"github-archiver\" },\n transports: [\n new winston.transports.File({\n filename: `${logDir}/errors.log`,\n level: \"error\",\n }),\n new winston.transports.File({\n filename: `${logDir}/combined.log`,\n }),\n ],\n });\n}\n\nexport function createConsoleLogger(): winston.Logger {\n return winston.createLogger({\n format: winston.format.combine(\n winston.format.colorize(),\n winston.format.printf(({ level, message, ...metadata }) => {\n const meta = Object.keys(metadata).length\n ? JSON.stringify(metadata)\n : \"\";\n return `${level}: ${message} ${meta}`;\n })\n ),\n transports: [new winston.transports.Console()],\n });\n}\n\nexport function getLogger(): winston.Logger {\n if (!loggerInstance) {\n loggerInstance = createLogger();\n }\n return loggerInstance;\n}\n\nexport function setLogger(logger: winston.Logger): void {\n loggerInstance = logger;\n}\n", "export const DEFAULT_CONCURRENCY = 3;\nexport const DEFAULT_TIMEOUT = 300; // seconds\nexport const DEFAULT_LOG_LEVEL = \"info\" as const;\nexport const MAX_RETRIES = 3;\nexport const RETRY_DELAY_MS = 1000; // base delay for exponential backoff\nexport const GITHUB_API_URL = \"https://api.github.com\";\n", "import { Octokit } from \"octokit\";\nimport { PATHS } from \"../constants/paths\";\nimport type { Config, StoredCredentials } from \"../types\";\nimport { ConfigManager } from \"../utils/config\";\nimport { createAuthError } from \"../utils/errors\";\n\nexport class AuthManager {\n private readonly configManager: ConfigManager;\n\n constructor(configDir: string = PATHS.APP_DIR) {\n this.configManager = new ConfigManager(configDir);\n }\n\n async saveToken(token: string): Promise<void> {\n if (!token || typeof token !== \"string\") {\n throw createAuthError(\"Invalid token format\");\n }\n\n const octokit = new Octokit({ auth: token });\n\n try {\n const { data } = await octokit.rest.users.getAuthenticated();\n\n const credentials: StoredCredentials = {\n token,\n savedAt: new Date().toISOString(),\n githubUser: data.login,\n };\n\n await this.configManager.saveConfig(credentials);\n } catch (error) {\n throw createAuthError(\n `Failed to validate token: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async getToken(): Promise<string | undefined> {\n if (process.env.GH_TOKEN) {\n return process.env.GH_TOKEN;\n }\n\n const credentials = await this.configManager.getStoredCredentials();\n return credentials?.token;\n }\n\n async removeToken(): Promise<void> {\n await this.configManager.removeStoredCredentials();\n }\n\n async validateToken(\n token: string\n ): Promise<{ valid: boolean; user?: string }> {\n try {\n const octokit = new Octokit({ auth: token });\n const { data } = await octokit.rest.users.getAuthenticated();\n return {\n valid: true,\n user: data.login,\n };\n } catch (_error) {\n return {\n valid: false,\n };\n }\n }\n\n getStoredCredentials(): Promise<StoredCredentials | null> {\n return this.configManager.getStoredCredentials();\n }\n\n ensureConfigDir(): Promise<void> {\n return this.configManager.ensureConfigDir();\n }\n\n loadConfig(): Promise<Config> {\n return this.configManager.loadConfig();\n }\n}\n", "import { promises as fs } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n DEFAULT_CONCURRENCY,\n DEFAULT_LOG_LEVEL,\n DEFAULT_TIMEOUT,\n} from \"../constants/defaults\";\nimport { PATHS } from \"../constants/paths\";\nimport type { Config, StoredCredentials } from \"../types\";\nimport { createConfigError, createFileError } from \"./errors\";\n\nexport class ConfigManager {\n private readonly configDir: string;\n private readonly configFile: string;\n\n constructor(configDir: string = PATHS.APP_DIR) {\n this.configDir = configDir;\n this.configFile = join(configDir, \"config.json\");\n }\n\n async loadConfig(): Promise<Config> {\n try {\n const token = process.env.GH_TOKEN;\n const fileCredentials = await this.loadFileCredentials();\n\n return {\n token: token || fileCredentials?.token,\n concurrency: DEFAULT_CONCURRENCY,\n timeout: DEFAULT_TIMEOUT,\n logLevel: DEFAULT_LOG_LEVEL,\n logDir: join(this.configDir, \"logs\"),\n configDir: this.configDir,\n };\n } catch (error) {\n throw createConfigError(\n `Failed to load configuration: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async saveConfig(credentials: StoredCredentials): Promise<void> {\n try {\n await this.ensureConfigDir();\n await fs.writeFile(\n this.configFile,\n JSON.stringify(credentials, null, 2),\n \"utf-8\"\n );\n } catch (error) {\n throw createFileError(\n `Failed to save configuration: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async ensureConfigDir(): Promise<void> {\n try {\n await fs.mkdir(this.configDir, { recursive: true });\n } catch (error) {\n throw createFileError(\n `Failed to create config directory: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async getStoredCredentials(): Promise<StoredCredentials | null> {\n try {\n const data = await fs.readFile(this.configFile, \"utf-8\");\n return JSON.parse(data) as StoredCredentials;\n } catch {\n return null;\n }\n }\n\n async removeStoredCredentials(): Promise<void> {\n try {\n await fs.unlink(this.configFile);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw createFileError(\n `Failed to remove stored credentials: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n }\n\n private async loadFileCredentials(): Promise<StoredCredentials | null> {\n try {\n const data = await fs.readFile(this.configFile, \"utf-8\");\n return JSON.parse(data) as StoredCredentials;\n } catch {\n return null;\n }\n }\n}\n", "import { Octokit } from \"octokit\";\nimport { MAX_RETRIES, RETRY_DELAY_MS } from \"../constants/defaults\";\nimport type { RateLimitInfo } from \"../types\";\nimport {\n createAlreadyArchivedError,\n createNetworkError,\n createPermissionError,\n createRateLimitError,\n createRepoNotFoundError,\n} from \"../utils/errors\";\nimport { getLogger } from \"../utils/logger\";\n\nconst logger = getLogger();\n\ninterface OctokitError {\n status: number;\n response?: {\n data?: {\n message: string;\n };\n };\n message: string;\n}\n\nexport class GitHubService {\n private readonly octokit: Octokit;\n\n constructor(token: string) {\n this.octokit = new Octokit({ auth: token });\n }\n\n async archiveRepository(owner: string, repo: string): Promise<void> {\n const startTime = Date.now();\n logger.debug(`Attempting to archive ${owner}/${repo}`);\n\n await this.retryWithBackoff(async () => {\n try {\n await this.octokit.rest.repos.update({\n owner,\n repo,\n archived: true,\n });\n const duration = Date.now() - startTime;\n logger.info(`Successfully archived ${owner}/${repo} in ${duration}ms`);\n } catch (error) {\n this.handleArchiveError(error, owner, repo);\n }\n });\n }\n\n private handleArchiveError(\n error: unknown,\n owner: string,\n repo: string\n ): never {\n const err = this.parseOctokitError(error);\n logger.error(`Failed to archive ${owner}/${repo}: ${err.message}`, {\n status: err.status,\n code: err.code,\n });\n\n if (err.status === 404) {\n throw createRepoNotFoundError(owner, repo);\n }\n\n if (err.status === 403 || err.message.includes(\"permission\")) {\n throw createPermissionError(owner, repo);\n }\n\n if (err.status === 422 && err.message.includes(\"archived\")) {\n throw createAlreadyArchivedError(owner, repo);\n }\n\n if (err.message.includes(\"API rate limit\")) {\n throw createRateLimitError();\n }\n\n if (\n err.message.includes(\"ECONNREFUSED\") ||\n err.message.includes(\"ETIMEDOUT\") ||\n err.message.includes(\"EHOSTUNREACH\") ||\n err.message.includes(\"socket hang up\")\n ) {\n throw createNetworkError(err.message);\n }\n\n throw error;\n }\n\n private parseOctokitError(error: unknown): {\n message: string;\n status: number;\n code: string | undefined;\n } {\n const message = error instanceof Error ? error.message : String(error);\n const err = error as unknown as OctokitError;\n return {\n message,\n status: err?.status || 0,\n code: err?.response?.data?.message,\n };\n }\n\n async validateRepository(\n owner: string,\n repo: string\n ): Promise<{ exists: boolean; isArchived: boolean }> {\n try {\n logger.debug(`Validating repository ${owner}/${repo}`);\n const { data } = await this.octokit.rest.repos.get({\n owner,\n repo,\n });\n\n const result = {\n exists: true,\n isArchived: data.archived,\n };\n logger.debug(`Repository ${owner}/${repo} validated`, result);\n return result;\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"404\")) {\n logger.debug(`Repository ${owner}/${repo} does not exist`);\n return {\n exists: false,\n isArchived: false,\n };\n }\n\n logger.error(`Error validating ${owner}/${repo}:`, error);\n throw error;\n }\n }\n\n async getRateLimitStatus(): Promise<RateLimitInfo> {\n try {\n logger.debug(\"Fetching rate limit status\");\n const { data } = await this.octokit.rest.rateLimit.get();\n\n const info: RateLimitInfo = {\n remaining: data.rate.remaining,\n reset: new Date(data.rate.reset * 1000),\n limit: data.rate.limit,\n };\n\n logger.debug(\"Rate limit status retrieved\", {\n remaining: info.remaining,\n limit: info.limit,\n resetAt: info.reset.toISOString(),\n });\n\n return info;\n } catch (error) {\n logger.error(\"Failed to fetch rate limit status:\", error);\n throw error;\n }\n }\n\n async validateAuth(): Promise<string> {\n try {\n logger.debug(\"Validating authentication\");\n const { data } = await this.octokit.rest.users.getAuthenticated();\n logger.info(`Authenticated as user: ${data.login}`);\n return data.login;\n } catch (error) {\n logger.error(\"Authentication validation failed:\", error);\n throw createNetworkError(\n error instanceof Error ? error.message : \"Authentication failed\"\n );\n }\n }\n\n private async retryWithBackoff<T>(\n fn: () => Promise<T>,\n maxRetries: number = MAX_RETRIES\n ): Promise<T> {\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt < maxRetries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n\n const message = lastError.message.toLowerCase();\n const isRetryable =\n message.includes(\"rate limit\") ||\n message.includes(\"timeout\") ||\n message.includes(\"econnrefused\") ||\n message.includes(\"etimedout\") ||\n message.includes(\"ehostunreach\") ||\n message.includes(\"socket hang up\");\n\n if (!isRetryable || attempt === maxRetries - 1) {\n throw error;\n }\n\n const delay = RETRY_DELAY_MS * 2 ** attempt;\n logger.warn(\n `Retry attempt ${attempt + 1}/${maxRetries} after ${delay}ms`,\n {\n error: message,\n }\n );\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n }\n\n throw lastError || new Error(\"Unknown error during retry\");\n }\n}\n", "import { promises as fs } from \"node:fs\";\nimport { createInterface } from \"node:readline\";\nimport type { RepositoryIdentifier } from \"../types\";\nimport { getLogger } from \"./logger\";\nimport { URLParser } from \"./parser\";\n\nconst logger = getLogger();\n\nexport class InputHandler {\n getRepositoriesFromInteractive(): Promise<{\n repos: RepositoryIdentifier[];\n errors: Array<{ url: string; error: string; line: number }>;\n }> {\n logger.info(\"Starting interactive CLI input for repositories\");\n\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n console.log(\"\");\n console.log(\"\uD83D\uDCDD Enter repository URLs one at a time:\");\n console.log(\n ' (Type \"done\" when finished, or leave empty and press Enter to skip)'\n );\n console.log(\"\");\n\n const urls: string[] = [];\n let lineNumber = 1;\n\n const promptNext = () => {\n rl.question(`[${lineNumber}] > `, (input) => {\n const trimmedInput = input.trim();\n\n if (trimmedInput.toLowerCase() === \"done\") {\n finishInput();\n return;\n }\n\n if (trimmedInput === \"\") {\n lineNumber++;\n promptNext();\n return;\n }\n\n urls.push(trimmedInput);\n lineNumber++;\n promptNext();\n });\n };\n\n const finishInput = () => {\n rl.close();\n const result = URLParser.parseRepositoriesBatch(urls);\n\n if (result.invalid.length > 0) {\n logger.warn(`Found ${result.invalid.length} invalid repositories`, {\n errors: result.invalid,\n });\n }\n\n logger.info(`Parsed ${result.valid.length} valid repositories`);\n resolve({\n repos: result.valid,\n errors: result.invalid,\n });\n };\n\n rl.on(\"close\", () => {\n finishInput();\n });\n\n promptNext();\n });\n }\n\n async getRepositoriesFromFile(filePath: string): Promise<{\n repos: RepositoryIdentifier[];\n errors: Array<{ url: string; error: string; line: number }>;\n }> {\n logger.info(`Reading repositories from file: ${filePath}`);\n\n try {\n const content = await fs.readFile(filePath, \"utf-8\");\n const lines = content.split(\"\\n\");\n\n const result = URLParser.parseRepositoriesBatch(lines);\n\n if (result.invalid.length > 0) {\n logger.warn(`Found ${result.invalid.length} invalid entries in file`, {\n errors: result.invalid,\n });\n }\n\n logger.info(`Parsed ${result.valid.length} valid repositories from file`);\n return {\n repos: result.valid,\n errors: result.invalid,\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error(`Failed to read file ${filePath}: ${message}`);\n throw new Error(`Failed to read file: ${message}`);\n }\n }\n\n getRepositoriesFromStdin(): Promise<{\n repos: RepositoryIdentifier[];\n errors: Array<{ url: string; error: string; line: number }>;\n }> {\n logger.info(\"Reading repositories from stdin\");\n\n return new Promise((resolve) => {\n const lines: string[] = [];\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n rl.on(\"line\", (line) => {\n lines.push(line);\n });\n\n rl.on(\"close\", () => {\n const result = URLParser.parseRepositoriesBatch(lines);\n\n if (result.invalid.length > 0) {\n logger.warn(\n `Found ${result.invalid.length} invalid entries from stdin`,\n {\n errors: result.invalid,\n }\n );\n }\n\n logger.info(\n `Parsed ${result.valid.length} valid repositories from stdin`\n );\n resolve({\n repos: result.valid,\n errors: result.invalid,\n });\n });\n });\n }\n\n promptForConfirmation(message: string): Promise<boolean> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n rl.question(`${message} [y/N]: `, (answer) => {\n rl.close();\n const confirmed = answer.toLowerCase() === \"y\";\n logger.info(`User confirmation: ${confirmed}`);\n resolve(confirmed);\n });\n });\n }\n}\n", "import type { RepositoryIdentifier } from \"../types\";\nimport { ArchiveError, ErrorCode } from \"../types\";\nimport { getLogger } from \"./logger\";\n\nconst logger = getLogger();\nconst NAME_REGEX = /^[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$/;\n\nconst GITHUB_URL_PATTERNS: RegExp[] = [\n // https://github.com/owner/repo or https://github.com/owner/repo.git\n /^(?:https?:\\/\\/)?(?:www\\.)?github\\.com[/:]([\\w.-]+)\\/([\\w.-]+?)(?:\\.git)?(?:\\/)?$/i,\n // git@github.com:owner/repo.git or git@github.com:owner/repo\n /^git@github\\.com:([\\w.-]+)\\/([\\w.-]+?)(?:\\.git)?$/i,\n // owner/repo (shorthand)\n /^([\\w.-]+)\\/([\\w.-]+)$/,\n];\n\nfunction parseRepositoryUrl(url: string): RepositoryIdentifier {\n const trimmed = url.trim();\n\n if (!trimmed) {\n throw new ArchiveError(ErrorCode.INVALID_URL, \"URL cannot be empty\");\n }\n\n for (const pattern of GITHUB_URL_PATTERNS) {\n const match = trimmed.match(pattern);\n if (match) {\n const owner = match[1];\n const repo = match[2];\n\n if (!(owner && repo)) {\n throw new ArchiveError(\n ErrorCode.INVALID_URL,\n `Invalid GitHub URL format: ${url}`\n );\n }\n\n if (!isValidName(owner)) {\n throw new ArchiveError(\n ErrorCode.INVALID_URL,\n `Invalid owner name: ${owner}. Owner names must contain only alphanumeric characters, hyphens, or periods.`\n );\n }\n\n if (!isValidName(repo)) {\n throw new ArchiveError(\n ErrorCode.INVALID_URL,\n `Invalid repository name: ${repo}. Repository names must contain only alphanumeric characters, hyphens, underscores, or periods.`\n );\n }\n\n const normalizedUrl = `https://github.com/${owner}/${repo}`;\n\n logger.debug(\"Parsed repository URL\", {\n original: trimmed,\n owner,\n repo,\n normalized: normalizedUrl,\n });\n\n return {\n owner,\n repo,\n url: normalizedUrl,\n };\n }\n }\n\n throw new ArchiveError(ErrorCode.INVALID_URL, `Invalid GitHub URL: ${url}`);\n}\n\nfunction isValidName(name: string): boolean {\n return NAME_REGEX.test(name);\n}\n\nfunction parseRepositoriesBatch(urls: string[]): {\n valid: RepositoryIdentifier[];\n invalid: Array<{ url: string; error: string; line: number }>;\n} {\n const valid: RepositoryIdentifier[] = [];\n const invalid: Array<{ url: string; error: string; line: number }> = [];\n\n for (const [index, url] of urls.entries()) {\n const lineNumber = index + 1;\n const trimmed = url.trim();\n\n if (!trimmed || trimmed.startsWith(\"#\")) {\n continue;\n }\n\n try {\n const parsed = parseRepositoryUrl(trimmed);\n valid.push(parsed);\n logger.debug(`Line ${lineNumber}: Valid repository`, {\n owner: parsed.owner,\n repo: parsed.repo,\n });\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n invalid.push({\n url: trimmed,\n error: errorMessage,\n line: lineNumber,\n });\n logger.warn(`Line ${lineNumber}: Invalid repository`, {\n url: trimmed,\n error: errorMessage,\n });\n }\n }\n\n logger.info(\"Batch parsing complete\", {\n total: urls.length,\n valid: valid.length,\n invalid: invalid.length,\n skipped: urls.length - valid.length - invalid.length,\n });\n\n return { valid, invalid };\n}\n\nexport const URLParser = {\n parseRepositoryUrl,\n parseRepositoriesBatch,\n};\n", "function formatDuration(ms: number): string {\n if (ms < 1000) {\n return `${ms}ms`;\n }\n if (ms < 60_000) {\n return `${(ms / 1000).toFixed(1)}s`;\n }\n const minutes = Math.floor(ms / 60_000);\n const seconds = ((ms % 60_000) / 1000).toFixed(0);\n return `${minutes}m ${seconds}s`;\n}\n\nfunction formatBytes(bytes: number): string {\n if (bytes === 0) {\n return \"0 B\";\n }\n const k = 1024;\n const sizes = [\"B\", \"KB\", \"MB\", \"GB\"];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n return `${(bytes / k ** i).toFixed(2)} ${sizes[i]}`;\n}\n\nfunction formatPercent(value: number, total: number): string {\n if (total === 0) {\n return \"0%\";\n }\n return `${((value / total) * 100).toFixed(1)}%`;\n}\n\nfunction createProgressBar(\n completed: number,\n total: number,\n width = 30\n): string {\n if (total === 0) {\n return \"[ ]\";\n }\n const filledWidth = Math.round((completed / total) * width);\n const emptyWidth = width - filledWidth;\n const filled = \"=\".repeat(filledWidth);\n const empty = \" \".repeat(emptyWidth);\n const percentage = ((completed / total) * 100).toFixed(0);\n return `[${filled}${empty}] ${percentage}%`;\n}\n\nfunction centerText(text: string, width: number): string {\n const padding = Math.max(0, (width - text.length) / 2);\n return \" \".repeat(Math.floor(padding)) + text;\n}\n\nfunction truncate(text: string, maxLength: number): string {\n if (text.length <= maxLength) {\n return text;\n }\n return `${text.substring(0, maxLength - 3)}...`;\n}\n\nexport const Formatting = {\n formatDuration,\n formatBytes,\n formatPercent,\n createProgressBar,\n centerText,\n truncate,\n};\n", "import { Formatting } from \"./formatting\";\n\nexport interface ProgressUpdate {\n completed: number;\n failed: number;\n total: number;\n current?: {\n owner: string;\n repo: string;\n };\n}\n\nexport class ProgressDisplay {\n private readonly startTime: number;\n private lastUpdate = 0;\n private readonly updateInterval = 500; // ms\n\n constructor() {\n this.startTime = Date.now();\n }\n\n shouldUpdate(): boolean {\n const now = Date.now();\n if (now - this.lastUpdate >= this.updateInterval) {\n this.lastUpdate = now;\n return true;\n }\n return false;\n }\n\n getProgressBar(progress: ProgressUpdate): string {\n const { completed, total, current } = progress;\n const percent = total > 0 ? (completed / total) * 100 : 0;\n const bar = Formatting.createProgressBar(completed, total, 25);\n\n let line = `${bar} ${completed}/${total} (${percent.toFixed(0)}%)`;\n\n if (current) {\n line += ` - ${current.owner}/${current.repo}`;\n }\n\n return line;\n }\n\n getSummaryBox(summary: {\n successful: number;\n failed: number;\n skipped: number;\n totalDuration: number;\n }): string {\n const { successful, failed, skipped, totalDuration } = summary;\n const total = successful + failed + skipped;\n const duration = Formatting.formatDuration(totalDuration);\n\n const lines = [\n \"\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557\",\n \"\u2551 Archive Operation Summary \u2551\",\n \"\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563\",\n `\u2551 \u2705 Successful: ${String(successful).padEnd(20)} \u2551`,\n `\u2551 \u26A0\uFE0F Skipped: ${String(skipped).padEnd(20)} \u2551`,\n `\u2551 \u274C Failed: ${String(failed).padEnd(20)} \u2551`,\n \"\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563\",\n `\u2551 Total: ${String(total).padEnd(20)} \u2551`,\n `\u2551 Duration: ${String(duration).padEnd(20)} \u2551`,\n \"\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\",\n ];\n\n return lines.join(\"\\n\");\n }\n\n getElapsedTime(): string {\n const elapsed = Date.now() - this.startTime;\n return Formatting.formatDuration(elapsed);\n }\n\n getEstimatedTimeRemaining(completed: number, total: number): string | null {\n if (completed === 0) {\n return null;\n }\n\n const elapsed = Date.now() - this.startTime;\n const avgTime = elapsed / completed;\n const remaining = (total - completed) * avgTime;\n\n return remaining > 0 ? Formatting.formatDuration(remaining) : null;\n }\n}\n", "import { createInterface } from \"node:readline\";\nimport { Command } from \"commander\";\nimport { MESSAGES } from \"../constants/messages\";\nimport { PATHS } from \"../constants/paths\";\nimport { AuthManager } from \"../services/auth-manager\";\nimport { getLogger } from \"../utils/logger\";\n\nconst authManager = new AuthManager(PATHS.APP_DIR);\n\nfunction createLoginCommand(): Command {\n return new Command(\"login\")\n .description(\"Set up GitHub authentication with a Personal Access Token\")\n .action(async () => {\n try {\n await authManager.ensureConfigDir();\n\n const token = await promptForToken();\n\n if (!token) {\n console.error(\"No token provided. Aborting.\");\n process.exit(1);\n }\n\n console.log(\"Validating token...\");\n await authManager.saveToken(token);\n\n const credentials = await authManager.getStoredCredentials();\n console.log(`\u2713 ${MESSAGES.AUTH_SUCCESS}`);\n console.log(` User: ${credentials?.githubUser}`);\n\n getLogger().info(\"Token saved successfully\", {\n user: credentials?.githubUser,\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`\u2717 Error: ${message}`);\n getLogger().error(\"Failed to save token\", { error: message });\n process.exit(1);\n }\n });\n}\n\nfunction createLogoutCommand(): Command {\n return new Command(\"logout\")\n .description(\"Remove stored GitHub authentication token\")\n .action(async () => {\n try {\n const credentials = await authManager.getStoredCredentials();\n\n if (!credentials) {\n console.log(\"No stored credentials found.\");\n return;\n }\n\n const confirmed = await confirmAction(MESSAGES.CONFIRM_LOGOUT);\n\n if (!confirmed) {\n console.log(\"Cancelled.\");\n return;\n }\n\n await authManager.removeToken();\n console.log(`\u2713 ${MESSAGES.TOKEN_REMOVED}`);\n getLogger().info(\"Token removed\");\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`\u2717 Error: ${message}`);\n getLogger().error(\"Failed to remove token\", { error: message });\n process.exit(1);\n }\n });\n}\n\nfunction createStatusCommand(): Command {\n return new Command(\"status\")\n .description(\"Check authentication status\")\n .action(async () => {\n try {\n const token = await authManager.getToken();\n\n if (!token) {\n console.log(\"\u2717 Not authenticated\");\n console.log(\n ' Run \"github-archiver auth login\" to set up authentication'\n );\n return;\n }\n\n console.log(\"\u2713 Authenticated\");\n\n const validation = await authManager.validateToken(token);\n\n if (validation.valid) {\n console.log(` User: ${validation.user}`);\n const credentials = await authManager.getStoredCredentials();\n if (credentials) {\n console.log(\n ` Saved at: ${new Date(credentials.savedAt).toLocaleString()}`\n );\n }\n getLogger().info(\"Authentication status check passed\");\n } else {\n console.log(\"\u2717 Token is invalid or expired\");\n getLogger().warn(\"Token validation failed\");\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`\u2717 Error: ${message}`);\n getLogger().error(\"Failed to check auth status\", { error: message });\n process.exit(1);\n }\n });\n}\n\nfunction createValidateCommand(): Command {\n return new Command(\"validate\")\n .description(\"Validate stored authentication token\")\n .action(async () => {\n try {\n const token = await authManager.getToken();\n\n if (!token) {\n console.log(\"\u2717 No token found\");\n process.exit(1);\n }\n\n console.log(\"Validating token...\");\n const validation = await authManager.validateToken(token);\n\n if (validation.valid) {\n console.log(`\u2713 Token is valid (user: ${validation.user})`);\n getLogger().info(\"Token validation successful\", {\n user: validation.user,\n });\n } else {\n console.log(\"\u2717 Token is invalid or expired\");\n getLogger().warn(\"Token validation failed\");\n process.exit(1);\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`\u2717 Error: ${message}`);\n getLogger().error(\"Token validation error\", { error: message });\n process.exit(1);\n }\n });\n}\n\nfunction promptForToken(): Promise<string> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n rl.question(MESSAGES.ENTER_TOKEN, (answer) => {\n rl.close();\n resolve(answer.trim());\n });\n });\n}\n\nfunction confirmAction(message: string): Promise<boolean> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n rl.question(`${message} [y/N]: `, (answer) => {\n rl.close();\n resolve(answer.toLowerCase() === \"y\");\n });\n });\n}\n\nexport function createAuthCommand(): Command {\n return new Command(\"auth\")\n .description(\"Manage GitHub authentication\")\n .addCommand(createLoginCommand())\n .addCommand(createLogoutCommand())\n .addCommand(createStatusC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,EAAQ,WAAW,CAEvB,OAASI,EAAO,CACd,IAAMC,EAAUD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACrE,QAAQ,MAAM,uBAAkBC,CAAO,EAAE,EACzC,QAAQ,KAAK,CAAC,CAChB,CACF,CAEAX,GAAK",
6
- "names": ["Command", "Command", "MESSAGES", "homedir", "join", "appDir", "PATHS", "PQueue", "ErrorCode", "ArchiveError", "_ArchiveError", "code", "message", "statusCode", "retryable", "isArchiveError", "error", "ArchiveError", "createAuthError", "message", "statusCode", "ArchiveError", "ErrorCode", "createRepoNotFoundError", "owner", "repo", "createAlreadyArchivedError", "createPermissionError", "createRateLimitError", "MESSAGES", "createNetworkError", "createConfigError", "message", "ArchiveError", "ErrorCode", "createFileError", "fs", "winston", "DEFAULT_LOG_LEVEL", "loggerInstance", "initializeLogger", "logDir", "fs", "error", "createLogger", "config", "level", "DEFAULT_LOG_LEVEL", "PATHS", "winston", "getLogger", "loggerInstance", "createLogger", "setLogger", "logger", "logger", "getLogger", "Archiver", "gitHubService", "options", "PQueue", "repos", "tasks", "repo", "startTime", "result", "validation", "error", "isArchiveError", "ErrorCode", "errorMessage", "successful", "r", "failed", "skipped", "totalDuration", "Octokit", "fs", "join", "ConfigManager", "configDir", "PATHS", "join", "token", "fileCredentials", "DEFAULT_LOG_LEVEL", "error", "createConfigError", "credentials", "fs", "createFileError", "data", "AuthManager", "configDir", "PATHS", "ConfigManager", "token", "createAuthError", "octokit", "Octokit", "data", "credentials", "error", "Octokit", "logger", "getLogger", "GitHubService", "token", "Octokit", "owner", "repo", "startTime", "duration", "error", "err", "createRepoNotFoundError", "createPermissionError", "createAlreadyArchivedError", "createRateLimitError", "createNetworkError", "message", "data", "result", "info", "fn", "maxRetries", "lastError", "attempt", "delay", "resolve", "fs", "createInterface", "logger", "getLogger", "NAME_REGEX", "GITHUB_URL_PATTERNS", "parseRepositoryUrl", "url", "trimmed", "ArchiveError", "ErrorCode", "pattern", "match", "owner", "repo", "isValidName", "normalizedUrl", "name", "parseRepositoriesBatch", "urls", "valid", "invalid", "index", "lineNumber", "parsed", "error", "errorMessage", "URLParser", "logger", "getLogger", "InputHandler", "resolve", "rl", "createInterface", "urls", "lineNumber", "promptNext", "input", "trimmedInput", "finishInput", "result", "URLParser", "filePath", "lines", "fs", "error", "message", "line", "answer", "confirmed", "formatDuration", "ms", "minutes", "seconds", "formatBytes", "bytes", "k", "sizes", "formatPercent", "value", "total", "createProgressBar", "completed", "width", "filledWidth", "emptyWidth", "filled", "empty", "percentage", "centerText", "text", "padding", "truncate", "maxLength", "Formatting", "ProgressDisplay", "now", "progress", "completed", "total", "current", "percent", "line", "Formatting", "summary", "successful", "failed", "skipped", "totalDuration", "duration", "elapsed", "avgTime", "remaining", "logger", "getLogger", "createArchiveCommand", "Command", "options", "archiveCommand", "concurrency", "timeout", "validateOptions", "authManager", "AuthManager", "PATHS", "inputHandler", "InputHandler", "progressDisplay", "ProgressDisplay", "githubService", "authenticateUser", "repositories", "parseErrors", "getRepositories", "logParseErrors", "MESSAGES", "showRepositoriesPreview", "confirmOperation", "archiveOptions", "archiver", "Archiver", "results", "archiveRepositories", "displayResults", "error", "handleArchiveError", "token", "GitHubService", "authenticatedUser", "result", "err", "dryRun", "index", "repo", "summary", "progress", "r", "message", "provideErrorGuidance", "lowerMessage", "createInterface", "Command", "authManager", "AuthManager", "PATHS", "createLoginCommand", "Command", "token", "promptForToken", "credentials", "MESSAGES", "getLogger", "error", "message", "createLogoutCommand", "confirmAction", "createStatusCommand", "validation", "createValidateCommand", "resolve", "rl", "createInterface", "answer", "createAuthCommand", "VERSION", "DESCRIPTION", "main", "initializeLogger", "PATHS", "fileLogger", "createLogger", "setLogger", "program", "Command", "createAuthCommand", "createArchiveCommand", "error", "message"]
4
+ "sourcesContent": ["import { Command } from \"commander\";\nimport { createArchiveCommand } from \"./commands/archive\";\nimport { createAuthCommand } from \"./commands/auth\";\nimport { PATHS } from \"./constants/paths\";\nimport { createLogger, initializeLogger, setLogger } from \"./utils/logger\";\n\nconst VERSION = \"1.0.6\";\nconst DESCRIPTION = \"Archive GitHub repositories via CLI\";\n\nasync function main() {\n try {\n await initializeLogger(PATHS.LOG_DIR);\n\n const fileLogger = createLogger();\n\n setLogger(fileLogger);\n\n const program = new Command();\n\n program\n .name(\"github-archiver\")\n .description(DESCRIPTION)\n .version(VERSION, \"-v, --version\", \"Display version\");\n\n program.addCommand(createAuthCommand());\n program.addCommand(createArchiveCommand());\n\n program.addHelpCommand(true);\n\n await program.parseAsync(process.argv);\n\n if (!process.argv.slice(2).length) {\n program.outputHelp();\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`\u2717 Fatal error: ${message}`);\n process.exit(1);\n }\n}\n\nmain();\n", "import { Command } from \"commander\";\nimport { MESSAGES } from \"../constants/messages\";\nimport { PATHS } from \"../constants/paths\";\nimport { Archiver } from \"../services/archiver\";\nimport { AuthManager } from \"../services/auth-manager\";\nimport { GitHubService } from \"../services/github\";\nimport type {\n ArchiveOptions,\n ArchiveResult,\n CommandOptions,\n RepositoryIdentifier,\n} from \"../types\";\nimport { InputHandler } from \"../utils/input-handler\";\nimport { getLogger } from \"../utils/logger\";\nimport { ProgressDisplay } from \"../utils/progress\";\n\nconst logger = getLogger();\n\nexport function createArchiveCommand(): Command {\n return new Command(\"archive\")\n .description(\"Archive GitHub repositories\")\n .option(\"--file <path>\", \"Read repository URLs from file\")\n .option(\"--stdin\", \"Read repository URLs from standard input\")\n .option(\"--dry-run\", \"Validate without archiving\", false)\n .option(\"--concurrency <n>\", \"Number of parallel operations\", \"3\")\n .option(\"--timeout <n>\", \"API timeout in seconds\", \"300\")\n .option(\"--verbose\", \"Verbose logging\", false)\n .option(\"--force\", \"Skip confirmations\", false)\n .action(async (options: CommandOptions) => {\n await archiveCommand(options);\n });\n}\n\nasync function archiveCommand(options: CommandOptions): Promise<void> {\n try {\n logger.info(\"Archive command started\", { options });\n\n const { concurrency, timeout } = validateOptions(options);\n\n const authManager = new AuthManager(PATHS.APP_DIR);\n const inputHandler = new InputHandler();\n const progressDisplay = new ProgressDisplay();\n\n const githubService = await authenticateUser(authManager);\n\n const { repositories, parseErrors } = await getRepositories(\n options,\n inputHandler\n );\n\n if (parseErrors.length > 0) {\n logParseErrors(parseErrors);\n }\n\n if (repositories.length === 0) {\n console.error(`\u274C ${MESSAGES.NO_REPOS_PROVIDED}`);\n process.exit(1);\n }\n\n showRepositoriesPreview(repositories, options.dryRun);\n\n await confirmOperation(options, inputHandler);\n\n const archiveOptions: ArchiveOptions = {\n dryRun: options.dryRun,\n concurrency,\n timeout,\n force: options.force,\n verbose: options.verbose,\n };\n\n console.log(\"\");\n console.log(`${MESSAGES.ARCHIVING_START} (concurrency: ${concurrency})`);\n console.log(\"\");\n\n const archiver = new Archiver(githubService, archiveOptions);\n const results = await archiveRepositories(\n archiver,\n repositories,\n archiveOptions,\n progressDisplay\n );\n\n displayResults(archiver, results, progressDisplay);\n } catch (error) {\n handleArchiveError(error);\n }\n}\n\nfunction validateOptions(options: CommandOptions): {\n concurrency: number;\n timeout: number;\n} {\n const concurrency = Number.parseInt(options.concurrency, 10);\n const timeout = Number.parseInt(options.timeout, 10);\n\n if (concurrency < 1 || concurrency > 50) {\n console.error(\"\u274C Concurrency must be between 1 and 50\");\n process.exit(1);\n }\n\n if (timeout < 10 || timeout > 3600) {\n console.error(\"\u274C Timeout must be between 10 and 3600 seconds\");\n process.exit(1);\n }\n\n return { concurrency, timeout };\n}\n\nasync function authenticateUser(\n authManager: AuthManager\n): Promise<GitHubService> {\n console.log(\"\uD83D\uDD10 Checking authentication...\");\n const token = await authManager.getToken();\n\n if (!token) {\n console.error(`\u274C ${MESSAGES.NO_TOKEN}`);\n console.error(\" Run: github-archiver auth login\");\n process.exit(1);\n }\n\n const githubService = new GitHubService(token);\n\n try {\n const authenticatedUser = await githubService.validateAuth();\n console.log(`\u2705 Authenticated as: ${authenticatedUser}`);\n return githubService;\n } catch (error) {\n console.error(\"\u274C Authentication failed\");\n logger.error(\"Auth validation failed:\", error);\n process.exit(1);\n }\n}\n\nasync function getRepositories(\n options: CommandOptions,\n inputHandler: InputHandler\n): Promise<{\n repositories: RepositoryIdentifier[];\n parseErrors: Array<{ url: string; error: string; line: number }>;\n}> {\n console.log(\"\");\n console.log(\"\uD83D\uDCDD Getting repositories...\");\n\n let repositories: RepositoryIdentifier[] = [];\n let parseErrors: Array<{ url: string; error: string; line: number }> = [];\n\n if (options.file) {\n logger.info(`Using file input: ${options.file}`);\n const result = await inputHandler.getRepositoriesFromFile(options.file);\n repositories = result.repos;\n parseErrors = result.errors;\n } else if (options.stdin) {\n logger.info(\"Using stdin input\");\n console.log(\n \"Enter repository URLs (one per line, press Ctrl+D to finish):\"\n );\n const result = await inputHandler.getRepositoriesFromStdin();\n repositories = result.repos;\n parseErrors = result.errors;\n } else {\n logger.info(\"Using interactive CLI input\");\n const result = await inputHandler.getRepositoriesFromInteractive();\n repositories = result.repos;\n parseErrors = result.errors;\n }\n\n return { repositories, parseErrors };\n}\n\nfunction logParseErrors(\n parseErrors: Array<{ url: string; error: string; line: number }>\n): void {\n console.warn(`\u26A0\uFE0F Found ${parseErrors.length} invalid repositories:`);\n for (const err of parseErrors) {\n console.warn(` Line ${err.line}: ${err.error}`);\n }\n console.warn(\"\");\n}\n\nfunction showRepositoriesPreview(\n repositories: RepositoryIdentifier[],\n dryRun: boolean\n): void {\n console.log(\n `\uD83D\uDCCB Will ${dryRun ? \"validate\" : \"archive\"} ${repositories.length} repositories:`\n );\n for (let index = 0; index < Math.min(repositories.length, 5); index++) {\n const repo = repositories[index];\n if (repo) {\n console.log(` ${index + 1}. ${repo.owner}/${repo.repo}`);\n }\n }\n if (repositories.length > 5) {\n console.log(` ... and ${repositories.length - 5} more`);\n }\n}\n\nasync function confirmOperation(\n options: CommandOptions,\n inputHandler: InputHandler\n): Promise<void> {\n console.log(\"\");\n if (!(options.force || options.dryRun)) {\n const confirmed = await inputHandler.promptForConfirmation(\n \"Are you sure you want to archive these repositories?\"\n );\n\n if (!confirmed) {\n console.log(\"\u274C Cancelled\");\n process.exit(1);\n }\n } else if (options.dryRun) {\n console.log(`\u2139\uFE0F ${MESSAGES.DRY_RUN_MODE}`);\n }\n}\n\nasync function archiveRepositories(\n archiver: Archiver,\n repositories: RepositoryIdentifier[],\n options: ArchiveOptions,\n progressDisplay: ProgressDisplay\n): Promise<ArchiveResult[]> {\n const results = await archiver.archiveRepositories(repositories, options);\n\n const summary = archiver.getSummary();\n const progress = {\n completed: summary.successful + summary.failed + summary.skipped,\n failed: summary.failed,\n total: repositories.length,\n };\n\n if (progressDisplay.shouldUpdate()) {\n console.log(`\\r${progressDisplay.getProgressBar(progress)}`);\n }\n\n return results;\n}\n\nfunction displayResults(\n archiver: Archiver,\n results: ArchiveResult[],\n progressDisplay: ProgressDisplay\n): void {\n console.log(\"\");\n console.log(\"\");\n\n const summary = archiver.getSummary();\n console.log(progressDisplay.getSummaryBox(summary));\n\n if (summary.failed > 0) {\n console.log(\"\");\n console.log(\"\u274C Failed repositories:\");\n for (const r of results) {\n if (!r.success) {\n console.log(` ${r.owner}/${r.repo}: ${r.message}`);\n }\n }\n }\n\n if (summary.skipped > 0) {\n console.log(\"\");\n console.log(\"\u26A0\uFE0F Skipped repositories:\");\n for (const r of results) {\n if (r.success && !r.archived) {\n console.log(` ${r.owner}/${r.repo}: ${r.message}`);\n }\n }\n }\n\n if (summary.failed > 0) {\n logger.warn(`Archive command completed with ${summary.failed} failures`);\n process.exit(1);\n } else {\n console.log(\"\");\n console.log(\"\u2705 All repositories processed successfully!\");\n logger.info(\"Archive command completed successfully\");\n process.exit(0);\n }\n}\n\nfunction handleArchiveError(error: unknown): never {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`\u274C Error: ${message}`);\n logger.error(\"Archive command failed:\", error);\n\n provideErrorGuidance(message);\n\n process.exit(1);\n}\n\nfunction provideErrorGuidance(message: string): void {\n const lowerMessage = message.toLowerCase();\n\n if (\n lowerMessage.includes(\"token\") ||\n lowerMessage.includes(\"authentication\")\n ) {\n console.log(\"\");\n console.log(\"\uD83D\uDCA1 Troubleshooting:\");\n console.log(\n \" 1. Make sure you have a valid GitHub Personal Access Token\"\n );\n console.log(' 2. The token needs \"repo\" scope to archive repositories');\n console.log(\" 3. Run: github-archiver auth login\");\n return;\n }\n\n if (lowerMessage.includes(\"rate limit\")) {\n console.log(\"\");\n console.log(\"\uD83D\uDCA1 Troubleshooting:\");\n console.log(\" 1. GitHub API rate limit has been exceeded\");\n console.log(\" 2. Wait a few minutes and try again\");\n console.log(\" 3. Use lower concurrency: --concurrency 1\");\n return;\n }\n\n if (lowerMessage.includes(\"permission\") || lowerMessage.includes(\"403\")) {\n console.log(\"\");\n console.log(\"\uD83D\uDCA1 Troubleshooting:\");\n console.log(\" 1. You must be the repository owner or have push access\");\n console.log(\" 2. Check that your GitHub token has correct permissions\");\n console.log(\" 3. Verify you have push access to the repositories\");\n return;\n }\n\n if (lowerMessage.includes(\"not found\") || lowerMessage.includes(\"404\")) {\n console.log(\"\");\n console.log(\"\uD83D\uDCA1 Troubleshooting:\");\n console.log(\" 1. Make sure the repository URL is correct\");\n console.log(\" 2. The repository may have been deleted\");\n console.log(\" 3. Check your GitHub access to the repository\");\n return;\n }\n\n if (lowerMessage.includes(\"network\") || lowerMessage.includes(\"timeout\")) {\n console.log(\"\");\n console.log(\"\uD83D\uDCA1 Troubleshooting:\");\n console.log(\" 1. Check your internet connection\");\n console.log(\" 2. GitHub API may be temporarily unavailable\");\n console.log(\" 3. Try again in a moment\");\n console.log(\" 4. Increase timeout: --timeout 600\");\n }\n}\n", "export const MESSAGES = {\n AUTH_SUCCESS: \"Successfully authenticated with GitHub\",\n ARCHIVE_SUCCESS: \"Repository archived successfully\",\n TOKEN_SAVED: \"GitHub token saved successfully\",\n TOKEN_REMOVED: \"GitHub token removed\",\n INVALID_TOKEN: \"Invalid or expired GitHub token\",\n REPO_NOT_FOUND: \"Repository not found\",\n ALREADY_ARCHIVED: \"Repository is already archived\",\n PERMISSION_DENIED: \"You do not have permission to archive this repository\",\n RATE_LIMITED: \"GitHub API rate limit exceeded. Please try again later\",\n NETWORK_ERROR: \"Network error. Please check your connection\",\n INVALID_URL: \"Invalid GitHub repository URL\",\n NO_TOKEN:\n 'No GitHub token found. Please run \"github-archiver auth login\" first',\n OPENING_EDITOR: \"Opening text editor for repository URLs...\",\n NO_REPOS_PROVIDED: \"No repositories provided\",\n ARCHIVING_START: \"Starting to archive repositories...\",\n ARCHIVING_COMPLETE: \"Archiving complete\",\n DRY_RUN_MODE: \"Running in dry-run mode (no repositories will be archived)\",\n CONFIRM_ARCHIVE: \"Are you sure you want to archive these repositories?\",\n ENTER_TOKEN:\n \"Enter your GitHub Personal Access Token (will not be displayed):\",\n CONFIRM_LOGOUT: \"Are you sure you want to remove the stored token?\",\n};\n", "import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\n\nconst appDir = join(homedir(), \".github-archiver\");\n\nexport const PATHS = {\n APP_DIR: appDir,\n CONFIG_FILE: join(appDir, \"config.json\"),\n LOG_DIR: join(appDir, \"logs\"),\n COMBINED_LOG: join(appDir, \"logs\", \"combined.log\"),\n ERROR_LOG: join(appDir, \"logs\", \"errors.log\"),\n};\n", "import PQueue from \"p-queue\";\nimport type {\n ArchiveOptions,\n ArchiveResult,\n RepositoryIdentifier,\n} from \"../types\";\nimport { ErrorCode } from \"../types\";\nimport { isArchiveError } from \"../utils/errors\";\nimport { getLogger } from \"../utils/logger\";\nimport type { GitHubService } from \"./github\";\n\nconst logger = getLogger();\n\nexport class Archiver {\n private readonly queue: PQueue;\n private results: ArchiveResult[] = [];\n private readonly gitHubService: GitHubService;\n private completed = 0;\n private failed = 0;\n private readonly startTime: number;\n\n constructor(gitHubService: GitHubService, options: ArchiveOptions) {\n this.gitHubService = gitHubService;\n this.startTime = Date.now();\n this.queue = new PQueue({\n concurrency: options.concurrency,\n timeout: options.timeout * 1000,\n interval: 1000,\n intervalCap: options.concurrency,\n });\n\n logger.info(\"Archiver initialized\", {\n concurrency: options.concurrency,\n timeout: options.timeout,\n dryRun: options.dryRun,\n });\n }\n\n async archiveRepositories(\n repos: RepositoryIdentifier[],\n options: ArchiveOptions\n ): Promise<ArchiveResult[]> {\n this.results = [];\n this.completed = 0;\n this.failed = 0;\n\n logger.info(`Starting to archive ${repos.length} repositories`, {\n dryRun: options.dryRun,\n });\n\n const tasks = repos.map((repo) =>\n this.queue.add(() => this.archiveRepository(repo, options))\n );\n\n await Promise.all(tasks);\n\n return this.results;\n }\n\n private async archiveRepository(\n repo: RepositoryIdentifier,\n options: ArchiveOptions\n ): Promise<void> {\n const startTime = Date.now();\n\n try {\n if (options.dryRun) {\n console.log(`\uD83D\uDD0D Validating ${repo.owner}/${repo.repo}...`);\n logger.info(`[DRY-RUN] Would archive ${repo.owner}/${repo.repo}`);\n const result: ArchiveResult = {\n owner: repo.owner,\n repo: repo.repo,\n success: true,\n archived: false,\n duration: Date.now() - startTime,\n message: \"[DRY-RUN] Validation successful\",\n };\n this.results.push(result);\n this.completed++;\n return;\n }\n\n const validation = await this.gitHubService.validateRepository(\n repo.owner,\n repo.repo\n );\n\n if (!validation.exists) {\n logger.warn(`Repository not found: ${repo.owner}/${repo.repo}`);\n const result: ArchiveResult = {\n owner: repo.owner,\n repo: repo.repo,\n success: false,\n archived: false,\n error: \"Repository not found\",\n duration: Date.now() - startTime,\n message: \"Repository does not exist on GitHub\",\n };\n this.results.push(result);\n this.failed++;\n return;\n }\n\n if (validation.isArchived) {\n logger.info(`Repository already archived: ${repo.owner}/${repo.repo}`);\n const result: ArchiveResult = {\n owner: repo.owner,\n repo: repo.repo,\n success: true,\n archived: false,\n duration: Date.now() - startTime,\n message: \"Repository is already archived\",\n };\n this.results.push(result);\n this.completed++;\n return;\n }\n\n console.log(`\uD83D\uDCE6 Archiving ${repo.owner}/${repo.repo}...`);\n await this.gitHubService.archiveRepository(repo.owner, repo.repo);\n\n const result: ArchiveResult = {\n owner: repo.owner,\n repo: repo.repo,\n success: true,\n archived: true,\n duration: Date.now() - startTime,\n message: \"Repository archived successfully\",\n };\n this.results.push(result);\n this.completed++;\n logger.info(`\u2713 Archived ${repo.owner}/${repo.repo}`, {\n duration: result.duration,\n });\n } catch (error) {\n if (isArchiveError(error) && error.code === ErrorCode.ALREADY_ARCHIVED) {\n logger.info(`Repository already archived: ${repo.owner}/${repo.repo}`);\n const result: ArchiveResult = {\n owner: repo.owner,\n repo: repo.repo,\n success: true,\n archived: false,\n duration: Date.now() - startTime,\n message: \"Repository is already archived\",\n };\n this.results.push(result);\n this.completed++;\n return;\n }\n\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n logger.error(\n `\u2717 Failed to archive ${repo.owner}/${repo.repo}: ${errorMessage}`\n );\n\n const result: ArchiveResult = {\n owner: repo.owner,\n repo: repo.repo,\n success: false,\n archived: false,\n error: errorMessage,\n duration: Date.now() - startTime,\n message: `Error: ${errorMessage}`,\n };\n this.results.push(result);\n this.failed++;\n }\n }\n\n getProgress(): { completed: number; failed: number; total: number } {\n return {\n completed: this.completed,\n failed: this.failed,\n total: this.results.length,\n };\n }\n\n getSummary(): {\n successful: number;\n failed: number;\n skipped: number;\n totalDuration: number;\n } {\n const successful = this.results.filter(\n (r) => r.success && r.archived\n ).length;\n const failed = this.results.filter((r) => !r.success).length;\n const skipped = this.results.filter((r) => r.success && !r.archived).length;\n const totalDuration = Date.now() - this.startTime;\n\n return { successful, failed, skipped, totalDuration };\n }\n}\n", "export const ErrorCode = {\n INVALID_AUTH: \"INVALID_AUTH\",\n REPO_NOT_FOUND: \"REPO_NOT_FOUND\",\n ALREADY_ARCHIVED: \"ALREADY_ARCHIVED\",\n PERMISSION_DENIED: \"PERMISSION_DENIED\",\n RATE_LIMITED: \"RATE_LIMITED\",\n NETWORK_ERROR: \"NETWORK_ERROR\",\n INVALID_URL: \"INVALID_URL\",\n PARSE_ERROR: \"PARSE_ERROR\",\n EDITOR_ERROR: \"EDITOR_ERROR\",\n CONFIG_ERROR: \"CONFIG_ERROR\",\n FILE_ERROR: \"FILE_ERROR\",\n} as const;\n\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\nexport class ArchiveError extends Error {\n code: ErrorCode;\n statusCode?: number;\n retryable: boolean;\n\n constructor(\n code: ErrorCode,\n message: string,\n statusCode?: number,\n retryable = false\n ) {\n super(message);\n this.name = \"ArchiveError\";\n this.code = code;\n this.statusCode = statusCode;\n this.retryable = retryable;\n Object.setPrototypeOf(this, ArchiveError.prototype);\n }\n}\n", "import { MESSAGES } from \"../constants/messages\";\nimport { ArchiveError, ErrorCode } from \"../types\";\n\nexport function isArchiveError(error: unknown): error is ArchiveError {\n return error instanceof ArchiveError;\n}\n\nexport function getErrorMessage(error: unknown): string {\n if (isArchiveError(error)) {\n return error.message;\n }\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n}\n\nexport function createAuthError(\n message: string,\n statusCode?: number\n): ArchiveError {\n return new ArchiveError(ErrorCode.INVALID_AUTH, message, statusCode, true);\n}\n\nexport function createRepoNotFoundError(\n owner: string,\n repo: string\n): ArchiveError {\n return new ArchiveError(\n ErrorCode.REPO_NOT_FOUND,\n `Repository ${owner}/${repo} not found`,\n 404,\n false\n );\n}\n\nexport function createAlreadyArchivedError(\n owner: string,\n repo: string\n): ArchiveError {\n return new ArchiveError(\n ErrorCode.ALREADY_ARCHIVED,\n `Repository ${owner}/${repo} is already archived`,\n 422,\n false\n );\n}\n\nexport function createPermissionError(\n owner: string,\n repo: string\n): ArchiveError {\n return new ArchiveError(\n ErrorCode.PERMISSION_DENIED,\n `Permission denied for ${owner}/${repo}. You must be the repository owner or have push access.`,\n 403,\n false\n );\n}\n\nexport function createRateLimitError(): ArchiveError {\n return new ArchiveError(\n ErrorCode.RATE_LIMITED,\n MESSAGES.RATE_LIMITED,\n 429,\n true\n );\n}\n\nexport function createNetworkError(message?: string): ArchiveError {\n return new ArchiveError(\n ErrorCode.NETWORK_ERROR,\n message || MESSAGES.NETWORK_ERROR,\n undefined,\n true\n );\n}\n\nexport function createInvalidUrlError(url: string): ArchiveError {\n return new ArchiveError(ErrorCode.INVALID_URL, `Invalid GitHub URL: ${url}`);\n}\n\nexport function createConfigError(message: string): ArchiveError {\n return new ArchiveError(ErrorCode.CONFIG_ERROR, message);\n}\n\nexport function createFileError(message: string): ArchiveError {\n return new ArchiveError(ErrorCode.FILE_ERROR, message);\n}\n\nexport function createEditorError(message: string): ArchiveError {\n return new ArchiveError(ErrorCode.EDITOR_ERROR, message);\n}\n", "import { promises as fs } from \"node:fs\";\nimport winston from \"winston\";\nimport { DEFAULT_LOG_LEVEL } from \"../constants/defaults\";\nimport { PATHS } from \"../constants/paths\";\nimport type { Config } from \"../types\";\n\nlet loggerInstance: winston.Logger;\n\nexport async function initializeLogger(logDir: string): Promise<void> {\n try {\n await fs.mkdir(logDir, { recursive: true });\n } catch (error) {\n console.error(\"Failed to create log directory:\", error);\n }\n}\n\nexport function createLogger(config?: Partial<Config>): winston.Logger {\n const level = config?.logLevel || DEFAULT_LOG_LEVEL;\n const logDir = config?.logDir || PATHS.LOG_DIR;\n\n return winston.createLogger({\n level,\n format: winston.format.combine(\n winston.format.timestamp({ format: \"YYYY-MM-DD HH:mm:ss\" }),\n winston.format.errors({ stack: true }),\n winston.format.json()\n ),\n defaultMeta: { service: \"github-archiver\" },\n transports: [\n new winston.transports.File({\n filename: `${logDir}/errors.log`,\n level: \"error\",\n }),\n new winston.transports.File({\n filename: `${logDir}/combined.log`,\n }),\n ],\n });\n}\n\nexport function createConsoleLogger(): winston.Logger {\n return winston.createLogger({\n format: winston.format.combine(\n winston.format.colorize(),\n winston.format.printf(({ level, message, ...metadata }) => {\n const meta = Object.keys(metadata).length\n ? JSON.stringify(metadata)\n : \"\";\n return `${level}: ${message} ${meta}`;\n })\n ),\n transports: [new winston.transports.Console()],\n });\n}\n\nexport function getLogger(): winston.Logger {\n if (!loggerInstance) {\n loggerInstance = createLogger();\n }\n return loggerInstance;\n}\n\nexport function setLogger(logger: winston.Logger): void {\n loggerInstance = logger;\n}\n", "export const DEFAULT_CONCURRENCY = 3;\nexport const DEFAULT_TIMEOUT = 300; // seconds\nexport const DEFAULT_LOG_LEVEL = \"info\" as const;\nexport const MAX_RETRIES = 3;\nexport const RETRY_DELAY_MS = 1000; // base delay for exponential backoff\nexport const GITHUB_API_URL = \"https://api.github.com\";\n", "import { Octokit } from \"octokit\";\nimport { PATHS } from \"../constants/paths\";\nimport type { Config, StoredCredentials } from \"../types\";\nimport { ConfigManager } from \"../utils/config\";\nimport { createAuthError } from \"../utils/errors\";\n\nexport class AuthManager {\n private readonly configManager: ConfigManager;\n\n constructor(configDir: string = PATHS.APP_DIR) {\n this.configManager = new ConfigManager(configDir);\n }\n\n async saveToken(token: string): Promise<void> {\n if (!token || typeof token !== \"string\") {\n throw createAuthError(\"Invalid token format\");\n }\n\n const octokit = new Octokit({ auth: token });\n\n try {\n const { data } = await octokit.rest.users.getAuthenticated();\n\n const credentials: StoredCredentials = {\n token,\n savedAt: new Date().toISOString(),\n githubUser: data.login,\n };\n\n await this.configManager.saveConfig(credentials);\n } catch (error) {\n throw createAuthError(\n `Failed to validate token: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async getToken(): Promise<string | undefined> {\n if (process.env.GH_TOKEN) {\n return process.env.GH_TOKEN;\n }\n\n const credentials = await this.configManager.getStoredCredentials();\n return credentials?.token;\n }\n\n async removeToken(): Promise<void> {\n await this.configManager.removeStoredCredentials();\n }\n\n async validateToken(\n token: string\n ): Promise<{ valid: boolean; user?: string }> {\n try {\n const octokit = new Octokit({ auth: token });\n const { data } = await octokit.rest.users.getAuthenticated();\n return {\n valid: true,\n user: data.login,\n };\n } catch (_error) {\n return {\n valid: false,\n };\n }\n }\n\n getStoredCredentials(): Promise<StoredCredentials | null> {\n return this.configManager.getStoredCredentials();\n }\n\n ensureConfigDir(): Promise<void> {\n return this.configManager.ensureConfigDir();\n }\n\n loadConfig(): Promise<Config> {\n return this.configManager.loadConfig();\n }\n}\n", "import { promises as fs } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n DEFAULT_CONCURRENCY,\n DEFAULT_LOG_LEVEL,\n DEFAULT_TIMEOUT,\n} from \"../constants/defaults\";\nimport { PATHS } from \"../constants/paths\";\nimport type { Config, StoredCredentials } from \"../types\";\nimport { createConfigError, createFileError } from \"./errors\";\n\nexport class ConfigManager {\n private readonly configDir: string;\n private readonly configFile: string;\n\n constructor(configDir: string = PATHS.APP_DIR) {\n this.configDir = configDir;\n this.configFile = join(configDir, \"config.json\");\n }\n\n async loadConfig(): Promise<Config> {\n try {\n const token = process.env.GH_TOKEN;\n const fileCredentials = await this.loadFileCredentials();\n\n return {\n token: token || fileCredentials?.token,\n concurrency: DEFAULT_CONCURRENCY,\n timeout: DEFAULT_TIMEOUT,\n logLevel: DEFAULT_LOG_LEVEL,\n logDir: join(this.configDir, \"logs\"),\n configDir: this.configDir,\n };\n } catch (error) {\n throw createConfigError(\n `Failed to load configuration: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async saveConfig(credentials: StoredCredentials): Promise<void> {\n try {\n await this.ensureConfigDir();\n await fs.writeFile(\n this.configFile,\n JSON.stringify(credentials, null, 2),\n \"utf-8\"\n );\n } catch (error) {\n throw createFileError(\n `Failed to save configuration: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async ensureConfigDir(): Promise<void> {\n try {\n await fs.mkdir(this.configDir, { recursive: true });\n } catch (error) {\n throw createFileError(\n `Failed to create config directory: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async getStoredCredentials(): Promise<StoredCredentials | null> {\n try {\n const data = await fs.readFile(this.configFile, \"utf-8\");\n return JSON.parse(data) as StoredCredentials;\n } catch {\n return null;\n }\n }\n\n async removeStoredCredentials(): Promise<void> {\n try {\n await fs.unlink(this.configFile);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw createFileError(\n `Failed to remove stored credentials: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n }\n\n private async loadFileCredentials(): Promise<StoredCredentials | null> {\n try {\n const data = await fs.readFile(this.configFile, \"utf-8\");\n return JSON.parse(data) as StoredCredentials;\n } catch {\n return null;\n }\n }\n}\n", "import { Octokit } from \"octokit\";\nimport { MAX_RETRIES, RETRY_DELAY_MS } from \"../constants/defaults\";\nimport type { RateLimitInfo } from \"../types\";\nimport {\n createAlreadyArchivedError,\n createNetworkError,\n createPermissionError,\n createRateLimitError,\n createRepoNotFoundError,\n} from \"../utils/errors\";\nimport { getLogger } from \"../utils/logger\";\n\nconst logger = getLogger();\n\ninterface OctokitError {\n status: number;\n response?: {\n data?: {\n message: string;\n };\n };\n message: string;\n}\n\nexport class GitHubService {\n private readonly octokit: Octokit;\n\n constructor(token: string) {\n this.octokit = new Octokit({ auth: token });\n }\n\n async archiveRepository(owner: string, repo: string): Promise<void> {\n const startTime = Date.now();\n logger.debug(`Attempting to archive ${owner}/${repo}`);\n\n await this.retryWithBackoff(async () => {\n try {\n await this.octokit.rest.repos.update({\n owner,\n repo,\n archived: true,\n });\n const duration = Date.now() - startTime;\n logger.info(`Successfully archived ${owner}/${repo} in ${duration}ms`);\n } catch (error) {\n this.handleArchiveError(error, owner, repo);\n }\n });\n }\n\n private handleArchiveError(\n error: unknown,\n owner: string,\n repo: string\n ): never {\n const err = this.parseOctokitError(error);\n logger.error(`Failed to archive ${owner}/${repo}: ${err.message}`, {\n status: err.status,\n code: err.code,\n });\n\n if (err.status === 404) {\n throw createRepoNotFoundError(owner, repo);\n }\n\n if (err.status === 403 || err.message.includes(\"permission\")) {\n throw createPermissionError(owner, repo);\n }\n\n if (err.status === 422 && err.message.includes(\"archived\")) {\n throw createAlreadyArchivedError(owner, repo);\n }\n\n if (err.message.includes(\"API rate limit\")) {\n throw createRateLimitError();\n }\n\n if (\n err.message.includes(\"ECONNREFUSED\") ||\n err.message.includes(\"ETIMEDOUT\") ||\n err.message.includes(\"EHOSTUNREACH\") ||\n err.message.includes(\"socket hang up\")\n ) {\n throw createNetworkError(err.message);\n }\n\n throw error;\n }\n\n private parseOctokitError(error: unknown): {\n message: string;\n status: number;\n code: string | undefined;\n } {\n const message = error instanceof Error ? error.message : String(error);\n const err = error as unknown as OctokitError;\n return {\n message,\n status: err?.status || 0,\n code: err?.response?.data?.message,\n };\n }\n\n async validateRepository(\n owner: string,\n repo: string\n ): Promise<{ exists: boolean; isArchived: boolean }> {\n try {\n logger.debug(`Validating repository ${owner}/${repo}`);\n const { data } = await this.octokit.rest.repos.get({\n owner,\n repo,\n });\n\n const result = {\n exists: true,\n isArchived: data.archived,\n };\n logger.debug(`Repository ${owner}/${repo} validated`, result);\n return result;\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"404\")) {\n logger.debug(`Repository ${owner}/${repo} does not exist`);\n return {\n exists: false,\n isArchived: false,\n };\n }\n\n logger.error(`Error validating ${owner}/${repo}:`, error);\n throw error;\n }\n }\n\n async getRateLimitStatus(): Promise<RateLimitInfo> {\n try {\n logger.debug(\"Fetching rate limit status\");\n const { data } = await this.octokit.rest.rateLimit.get();\n\n const info: RateLimitInfo = {\n remaining: data.rate.remaining,\n reset: new Date(data.rate.reset * 1000),\n limit: data.rate.limit,\n };\n\n logger.debug(\"Rate limit status retrieved\", {\n remaining: info.remaining,\n limit: info.limit,\n resetAt: info.reset.toISOString(),\n });\n\n return info;\n } catch (error) {\n logger.error(\"Failed to fetch rate limit status:\", error);\n throw error;\n }\n }\n\n async validateAuth(): Promise<string> {\n try {\n logger.debug(\"Validating authentication\");\n const { data } = await this.octokit.rest.users.getAuthenticated();\n logger.info(`Authenticated as user: ${data.login}`);\n return data.login;\n } catch (error) {\n logger.error(\"Authentication validation failed:\", error);\n throw createNetworkError(\n error instanceof Error ? error.message : \"Authentication failed\"\n );\n }\n }\n\n private async retryWithBackoff<T>(\n fn: () => Promise<T>,\n maxRetries: number = MAX_RETRIES\n ): Promise<T> {\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt < maxRetries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n\n const message = lastError.message.toLowerCase();\n const isRetryable =\n message.includes(\"rate limit\") ||\n message.includes(\"timeout\") ||\n message.includes(\"econnrefused\") ||\n message.includes(\"etimedout\") ||\n message.includes(\"ehostunreach\") ||\n message.includes(\"socket hang up\");\n\n if (!isRetryable || attempt === maxRetries - 1) {\n throw error;\n }\n\n const delay = RETRY_DELAY_MS * 2 ** attempt;\n logger.warn(\n `Retry attempt ${attempt + 1}/${maxRetries} after ${delay}ms`,\n {\n error: message,\n }\n );\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n }\n\n throw lastError || new Error(\"Unknown error during retry\");\n }\n}\n", "import { promises as fs } from \"node:fs\";\nimport { createInterface } from \"node:readline\";\nimport type { RepositoryIdentifier } from \"../types\";\nimport { getLogger } from \"./logger\";\nimport { URLParser } from \"./parser\";\n\nconst logger = getLogger();\n\nexport class InputHandler {\n getRepositoriesFromInteractive(): Promise<{\n repos: RepositoryIdentifier[];\n errors: Array<{ url: string; error: string; line: number }>;\n }> {\n logger.info(\"Starting interactive CLI input for repositories\");\n\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n console.log(\"\");\n console.log(\"\uD83D\uDCDD Enter repository URLs one at a time:\");\n console.log(\n \" (Press CTRL+D to finish, or leave empty and press Enter to skip)\"\n );\n console.log(\"\");\n\n const urls: string[] = [];\n let lineNumber = 1;\n let isFinished = false;\n\n const promptNext = () => {\n rl.question(`[${lineNumber}] > `, (input) => {\n const trimmedInput = input.trim();\n\n if (trimmedInput === \"\") {\n lineNumber++;\n promptNext();\n return;\n }\n\n urls.push(trimmedInput);\n lineNumber++;\n promptNext();\n });\n };\n\n const finishInput = () => {\n if (isFinished) {\n return;\n }\n isFinished = true;\n rl.close();\n const result = URLParser.parseRepositoriesBatch(urls);\n\n if (result.invalid.length > 0) {\n logger.warn(`Found ${result.invalid.length} invalid repositories`, {\n errors: result.invalid,\n });\n }\n\n logger.info(`Parsed ${result.valid.length} valid repositories`);\n resolve({\n repos: result.valid,\n errors: result.invalid,\n });\n };\n\n rl.on(\"close\", () => {\n finishInput();\n });\n\n promptNext();\n });\n }\n\n async getRepositoriesFromFile(filePath: string): Promise<{\n repos: RepositoryIdentifier[];\n errors: Array<{ url: string; error: string; line: number }>;\n }> {\n logger.info(`Reading repositories from file: ${filePath}`);\n\n try {\n const content = await fs.readFile(filePath, \"utf-8\");\n const lines = content.split(\"\\n\");\n\n const result = URLParser.parseRepositoriesBatch(lines);\n\n if (result.invalid.length > 0) {\n logger.warn(`Found ${result.invalid.length} invalid entries in file`, {\n errors: result.invalid,\n });\n }\n\n logger.info(`Parsed ${result.valid.length} valid repositories from file`);\n return {\n repos: result.valid,\n errors: result.invalid,\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error(`Failed to read file ${filePath}: ${message}`);\n throw new Error(`Failed to read file: ${message}`);\n }\n }\n\n getRepositoriesFromStdin(): Promise<{\n repos: RepositoryIdentifier[];\n errors: Array<{ url: string; error: string; line: number }>;\n }> {\n logger.info(\"Reading repositories from stdin\");\n\n return new Promise((resolve) => {\n const lines: string[] = [];\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n rl.on(\"line\", (line) => {\n lines.push(line);\n });\n\n rl.on(\"close\", () => {\n const result = URLParser.parseRepositoriesBatch(lines);\n\n if (result.invalid.length > 0) {\n logger.warn(\n `Found ${result.invalid.length} invalid entries from stdin`,\n {\n errors: result.invalid,\n }\n );\n }\n\n logger.info(\n `Parsed ${result.valid.length} valid repositories from stdin`\n );\n resolve({\n repos: result.valid,\n errors: result.invalid,\n });\n });\n });\n }\n\n promptForConfirmation(message: string): Promise<boolean> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n rl.question(`${message} [y/N]: `, (answer) => {\n rl.close();\n const confirmed = answer.toLowerCase() === \"y\";\n logger.info(`User confirmation: ${confirmed}`);\n resolve(confirmed);\n });\n });\n }\n}\n", "import type { RepositoryIdentifier } from \"../types\";\nimport { ArchiveError, ErrorCode } from \"../types\";\nimport { getLogger } from \"./logger\";\n\nconst logger = getLogger();\nconst NAME_REGEX = /^[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$/;\n\nconst GITHUB_URL_PATTERNS: RegExp[] = [\n // https://github.com/owner/repo or https://github.com/owner/repo.git\n /^(?:https?:\\/\\/)?(?:www\\.)?github\\.com[/:]([\\w.-]+)\\/([\\w.-]+?)(?:\\.git)?(?:\\/)?$/i,\n // git@github.com:owner/repo.git or git@github.com:owner/repo\n /^git@github\\.com:([\\w.-]+)\\/([\\w.-]+?)(?:\\.git)?$/i,\n // owner/repo (shorthand)\n /^([\\w.-]+)\\/([\\w.-]+)$/,\n];\n\nfunction parseRepositoryUrl(url: string): RepositoryIdentifier {\n const trimmed = url.trim();\n\n if (!trimmed) {\n throw new ArchiveError(ErrorCode.INVALID_URL, \"URL cannot be empty\");\n }\n\n for (const pattern of GITHUB_URL_PATTERNS) {\n const match = trimmed.match(pattern);\n if (match) {\n const owner = match[1];\n const repo = match[2];\n\n if (!(owner && repo)) {\n throw new ArchiveError(\n ErrorCode.INVALID_URL,\n `Invalid GitHub URL format: ${url}`\n );\n }\n\n if (!isValidName(owner)) {\n throw new ArchiveError(\n ErrorCode.INVALID_URL,\n `Invalid owner name: ${owner}. Owner names must contain only alphanumeric characters, hyphens, or periods.`\n );\n }\n\n if (!isValidName(repo)) {\n throw new ArchiveError(\n ErrorCode.INVALID_URL,\n `Invalid repository name: ${repo}. Repository names must contain only alphanumeric characters, hyphens, underscores, or periods.`\n );\n }\n\n const normalizedUrl = `https://github.com/${owner}/${repo}`;\n\n logger.debug(\"Parsed repository URL\", {\n original: trimmed,\n owner,\n repo,\n normalized: normalizedUrl,\n });\n\n return {\n owner,\n repo,\n url: normalizedUrl,\n };\n }\n }\n\n throw new ArchiveError(ErrorCode.INVALID_URL, `Invalid GitHub URL: ${url}`);\n}\n\nfunction isValidName(name: string): boolean {\n return NAME_REGEX.test(name);\n}\n\nfunction parseRepositoriesBatch(urls: string[]): {\n valid: RepositoryIdentifier[];\n invalid: Array<{ url: string; error: string; line: number }>;\n} {\n const valid: RepositoryIdentifier[] = [];\n const invalid: Array<{ url: string; error: string; line: number }> = [];\n\n for (const [index, url] of urls.entries()) {\n const lineNumber = index + 1;\n const trimmed = url.trim();\n\n if (!trimmed || trimmed.startsWith(\"#\")) {\n continue;\n }\n\n try {\n const parsed = parseRepositoryUrl(trimmed);\n valid.push(parsed);\n logger.debug(`Line ${lineNumber}: Valid repository`, {\n owner: parsed.owner,\n repo: parsed.repo,\n });\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n invalid.push({\n url: trimmed,\n error: errorMessage,\n line: lineNumber,\n });\n logger.warn(`Line ${lineNumber}: Invalid repository`, {\n url: trimmed,\n error: errorMessage,\n });\n }\n }\n\n logger.info(\"Batch parsing complete\", {\n total: urls.length,\n valid: valid.length,\n invalid: invalid.length,\n skipped: urls.length - valid.length - invalid.length,\n });\n\n return { valid, invalid };\n}\n\nexport const URLParser = {\n parseRepositoryUrl,\n parseRepositoriesBatch,\n};\n", "function formatDuration(ms: number): string {\n if (ms < 1000) {\n return `${ms}ms`;\n }\n if (ms < 60_000) {\n return `${(ms / 1000).toFixed(1)}s`;\n }\n const minutes = Math.floor(ms / 60_000);\n const seconds = ((ms % 60_000) / 1000).toFixed(0);\n return `${minutes}m ${seconds}s`;\n}\n\nfunction formatBytes(bytes: number): string {\n if (bytes === 0) {\n return \"0 B\";\n }\n const k = 1024;\n const sizes = [\"B\", \"KB\", \"MB\", \"GB\"];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n return `${(bytes / k ** i).toFixed(2)} ${sizes[i]}`;\n}\n\nfunction formatPercent(value: number, total: number): string {\n if (total === 0) {\n return \"0%\";\n }\n return `${((value / total) * 100).toFixed(1)}%`;\n}\n\nfunction createProgressBar(\n completed: number,\n total: number,\n width = 30\n): string {\n if (total === 0) {\n return \"[ ]\";\n }\n const filledWidth = Math.round((completed / total) * width);\n const emptyWidth = width - filledWidth;\n const filled = \"=\".repeat(filledWidth);\n const empty = \" \".repeat(emptyWidth);\n const percentage = ((completed / total) * 100).toFixed(0);\n return `[${filled}${empty}] ${percentage}%`;\n}\n\nfunction centerText(text: string, width: number): string {\n const padding = Math.max(0, (width - text.length) / 2);\n return \" \".repeat(Math.floor(padding)) + text;\n}\n\nfunction truncate(text: string, maxLength: number): string {\n if (text.length <= maxLength) {\n return text;\n }\n return `${text.substring(0, maxLength - 3)}...`;\n}\n\nexport const Formatting = {\n formatDuration,\n formatBytes,\n formatPercent,\n createProgressBar,\n centerText,\n truncate,\n};\n", "import { Formatting } from \"./formatting\";\n\nexport interface ProgressUpdate {\n completed: number;\n failed: number;\n total: number;\n current?: {\n owner: string;\n repo: string;\n };\n}\n\nexport class ProgressDisplay {\n private readonly startTime: number;\n private lastUpdate = 0;\n private readonly updateInterval = 500; // ms\n\n constructor() {\n this.startTime = Date.now();\n }\n\n shouldUpdate(): boolean {\n const now = Date.now();\n if (now - this.lastUpdate >= this.updateInterval) {\n this.lastUpdate = now;\n return true;\n }\n return false;\n }\n\n getProgressBar(progress: ProgressUpdate): string {\n const { completed, total, current } = progress;\n const percent = total > 0 ? (completed / total) * 100 : 0;\n const bar = Formatting.createProgressBar(completed, total, 25);\n\n let line = `${bar} ${completed}/${total} (${percent.toFixed(0)}%)`;\n\n if (current) {\n line += ` - ${current.owner}/${current.repo}`;\n }\n\n return line;\n }\n getSummaryBox(summary: {\n successful: number;\n failed: number;\n skipped: number;\n totalDuration: number;\n }): string {\n const { successful, failed, skipped, totalDuration } = summary;\n const total = successful + failed + skipped;\n const duration = Formatting.formatDuration(totalDuration);\n\n const createLine = (\n label: string,\n value: string,\n extraPadding = 0\n ): string => {\n const valueStr = String(value);\n const contentLength = label.length + valueStr.length;\n const padding = 31 - contentLength + extraPadding;\n return `\u2551 ${label}${\" \".repeat(Math.max(1, padding))}${valueStr} \u2551`;\n };\n\n const lines = [\n \"\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557\",\n \"\u2551 Archive Operation Summary \u2551\",\n \"\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563\",\n createLine(\"\u2705 Successful:\", String(successful), 2),\n createLine(\"\u26A0\uFE0F Skipped:\", String(skipped), 3),\n createLine(\"\u274C Failed:\", String(failed), 2),\n \"\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563\",\n createLine(\"Total:\", String(total), 3),\n createLine(\"Duration:\", duration, 3),\n \"\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\",\n ];\n\n return lines.join(\"\\n\");\n }\n\n getElapsedTime(): string {\n const elapsed = Date.now() - this.startTime;\n return Formatting.formatDuration(elapsed);\n }\n\n getEstimatedTimeRemaining(completed: number, total: number): string | null {\n if (completed === 0) {\n return null;\n }\n\n const elapsed = Date.now() - this.startTime;\n const avgTime = elapsed / completed;\n const remaining = (total - completed) * avgTime;\n\n return remaining > 0 ? Formatting.formatDuration(remaining) : null;\n }\n}\n", "import { createInterface } from \"node:readline\";\nimport { Command } from \"commander\";\nimport { MESSAGES } from \"../constants/messages\";\nimport { PATHS } from \"../constants/paths\";\nimport { AuthManager } from \"../services/auth-manager\";\nimport { getLogger } from \"../utils/logger\";\n\nconst authManager = new AuthManager(PATHS.APP_DIR);\n\nfunction createLoginCommand(): Command {\n return new Command(\"login\")\n .description(\"Set up GitHub authentication with a Personal Access Token\")\n .action(async () => {\n try {\n await authManager.ensureConfigDir();\n\n const token = await promptForToken();\n\n if (!token) {\n console.error(\"No token provided. Aborting.\");\n process.exit(1);\n }\n\n console.log(\"Validating token...\");\n await authManager.saveToken(token);\n\n const credentials = await authManager.getStoredCredentials();\n console.log(`\u2713 ${MESSAGES.AUTH_SUCCESS}`);\n console.log(` User: ${credentials?.githubUser}`);\n\n getLogger().info(\"Token saved successfully\", {\n user: credentials?.githubUser,\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`\u2717 Error: ${message}`);\n getLogger().error(\"Failed to save token\", { error: message });\n process.exit(1);\n }\n });\n}\n\nfunction createLogoutCommand(): Command {\n return new Command(\"logout\")\n .description(\"Remove stored GitHub authentication token\")\n .action(async () => {\n try {\n const credentials = await authManager.getStoredCredentials();\n\n if (!credentials) {\n console.log(\"No stored credentials found.\");\n return;\n }\n\n const confirmed = await confirmAction(MESSAGES.CONFIRM_LOGOUT);\n\n if (!confirmed) {\n console.log(\"Cancelled.\");\n return;\n }\n\n await authManager.removeToken();\n console.log(`\u2713 ${MESSAGES.TOKEN_REMOVED}`);\n getLogger().info(\"Token removed\");\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`\u2717 Error: ${message}`);\n getLogger().error(\"Failed to remove token\", { error: message });\n process.exit(1);\n }\n });\n}\n\nfunction createStatusCommand(): Command {\n return new Command(\"status\")\n .description(\"Check authentication status\")\n .action(async () => {\n try {\n const token = await authManager.getToken();\n\n if (!token) {\n console.log(\"\u2717 Not authenticated\");\n console.log(\n ' Run \"github-archiver auth login\" to set up authentication'\n );\n return;\n }\n\n console.log(\"\u2713 Authenticated\");\n\n const validation = await authManager.validateToken(token);\n\n if (validation.valid) {\n console.log(` User: ${validation.user}`);\n const credentials = await authManager.getStoredCredentials();\n if (credentials) {\n console.log(\n ` Saved at: ${new Date(credentials.savedAt).toLocaleString()}`\n );\n }\n getLogger().info(\"Authentication status check passed\");\n } else {\n console.log(\"\u2717 Token is invalid or expired\");\n getLogger().warn(\"Token validation failed\");\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`\u2717 Error: ${message}`);\n getLogger().error(\"Failed to check auth status\", { error: message });\n process.exit(1);\n }\n });\n}\n\nfunction createValidateCommand(): Command {\n return new Command(\"validate\")\n .description(\"Validate stored authentication token\")\n .action(async () => {\n try {\n const token = await authManager.getToken();\n\n if (!token) {\n console.log(\"\u2717 No token found\");\n process.exit(1);\n }\n\n console.log(\"Validating token...\");\n const validation = await authManager.validateToken(token);\n\n if (validation.valid) {\n console.log(`\u2713 Token is valid (user: ${validation.user})`);\n getLogger().info(\"Token validation successful\", {\n user: validation.user,\n });\n } else {\n console.log(\"\u2717 Token is invalid or expired\");\n getLogger().warn(\"Token validation failed\");\n process.exit(1);\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`\u2717 Error: ${message}`);\n getLogger().error(\"Token validation error\", { error: message });\n process.exit(1);\n }\n });\n}\n\nfunction promptForToken(): Promise<string> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n rl.question(MESSAGES.ENTER_TOKEN, (answer) => {\n rl.close();\n resolve(answer.trim());\n });\n });\n}\n\nfunction confirmAction(message: string): Promise<boolean> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n rl.question(`${message} [y/N]: `, (answer) => {\n rl.close();\n resolve(answer.toLowerCase() === \"y\");\n });\n });\n}\n\nexport function createAuthCommand(): Command {\n return new Command(\"auth\")\n .description(\"Manage GitHub authentication\")\n .addCommand(createLoginCommand())\n .addCommand(createLogoutCommand())\n .addCommand(createStatusCommand())\n .addCommand(createValidateCommand());\n}\n"],
5
+ "mappings": "AAAA,OAAS,WAAAA,OAAe,YCAxB,OAAS,WAAAC,OAAe,YCAjB,IAAMC,EAAW,CACtB,aAAc,yCACd,gBAAiB,mCACjB,YAAa,kCACb,cAAe,uBACf,cAAe,kCACf,eAAgB,uBAChB,iBAAkB,iCAClB,kBAAmB,wDACnB,aAAc,yDACd,cAAe,8CACf,YAAa,gCACb,SACE,uEACF,eAAgB,6CAChB,kBAAmB,2BACnB,gBAAiB,sCACjB,mBAAoB,qBACpB,aAAc,6DACd,gBAAiB,uDACjB,YACE,mEACF,eAAgB,mDAClB,ECvBA,OAAS,WAAAC,OAAe,UACxB,OAAS,QAAAC,MAAY,YAErB,IAAMC,EAASD,EAAKD,GAAQ,EAAG,kBAAkB,EAEpCG,EAAQ,CACnB,QAASD,EACT,YAAaD,EAAKC,EAAQ,aAAa,EACvC,QAASD,EAAKC,EAAQ,MAAM,EAC5B,aAAcD,EAAKC,EAAQ,OAAQ,cAAc,EACjD,UAAWD,EAAKC,EAAQ,OAAQ,YAAY,CAC9C,ECXA,OAAOE,OAAY,UCAZ,IAAMC,EAAY,CACvB,aAAc,eACd,eAAgB,iBAChB,iBAAkB,mBAClB,kBAAmB,oBACnB,aAAc,eACd,cAAe,gBACf,YAAa,cACb,YAAa,cACb,aAAc,eACd,aAAc,eACd,WAAY,YACd,EAIaC,EAAN,MAAMC,UAAqB,KAAM,CAKtC,YACEC,EACAC,EACAC,EACAC,EAAY,GACZ,CACA,MAAMF,CAAO,EACb,KAAK,KAAO,eACZ,KAAK,KAAOD,EACZ,KAAK,WAAaE,EAClB,KAAK,UAAYC,EACjB,OAAO,eAAe,KAAMJ,EAAa,SAAS,CACpD,CACF,EC/BO,SAASK,EAAeC,EAAuC,CACpE,OAA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BC,EAAM,OAAO,EAEpC,IAAMC,EAAaC,EAAa,EAEhCC,EAAUF,CAAU,EAEpB,IAAMG,EAAU,IAAIC,GAEpBD,EACG,KAAK,iBAAiB,EACtB,YAAYP,EAAW,EACvB,QAAQD,GAAS,gBAAiB,iBAAiB,EAEtDQ,EAAQ,WAAWE,GAAkB,CAAC,EACtCF,EAAQ,WAAWG,GAAqB,CAAC,EAEzCH,EAAQ,eAAe,EAAI,EAE3B,MAAMA,EAAQ,WAAW,QAAQ,IAAI,EAEhC,QAAQ,KAAK,MAAM,CAAC,EAAE,QACzBA,EAAQ,WAAW,CAEvB,OAASI,EAAO,CACd,IAAMC,EAAUD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACrE,QAAQ,MAAM,uBAAkBC,CAAO,EAAE,EACzC,QAAQ,KAAK,CAAC,CAChB,CACF,CAEAX,GAAK",
6
+ "names": ["Command", "Command", "MESSAGES", "homedir", "join", "appDir", "PATHS", "PQueue", "ErrorCode", "ArchiveError", "_ArchiveError", "code", "message", "statusCode", "retryable", "isArchiveError", "error", "ArchiveError", "createAuthError", "message", "statusCode", "ArchiveError", "ErrorCode", "createRepoNotFoundError", "owner", "repo", "createAlreadyArchivedError", "createPermissionError", "createRateLimitError", "MESSAGES", "createNetworkError", "createConfigError", "message", "ArchiveError", "ErrorCode", "createFileError", "fs", "winston", "DEFAULT_LOG_LEVEL", "loggerInstance", "initializeLogger", "logDir", "fs", "error", "createLogger", "config", "level", "DEFAULT_LOG_LEVEL", "PATHS", "winston", "getLogger", "loggerInstance", "createLogger", "setLogger", "logger", "logger", "getLogger", "Archiver", "gitHubService", "options", "PQueue", "repos", "tasks", "repo", "startTime", "result", "validation", "error", "isArchiveError", "ErrorCode", "errorMessage", "successful", "r", "failed", "skipped", "totalDuration", "Octokit", "fs", "join", "ConfigManager", "configDir", "PATHS", "join", "token", "fileCredentials", "DEFAULT_LOG_LEVEL", "error", "createConfigError", "credentials", "fs", "createFileError", "data", "AuthManager", "configDir", "PATHS", "ConfigManager", "token", "createAuthError", "octokit", "Octokit", "data", "credentials", "error", "Octokit", "logger", "getLogger", "GitHubService", "token", "Octokit", "owner", "repo", "startTime", "duration", "error", "err", "createRepoNotFoundError", "createPermissionError", "createAlreadyArchivedError", "createRateLimitError", "createNetworkError", "message", "data", "result", "info", "fn", "maxRetries", "lastError", "attempt", "delay", "resolve", "fs", "createInterface", "logger", "getLogger", "NAME_REGEX", "GITHUB_URL_PATTERNS", "parseRepositoryUrl", "url", "trimmed", "ArchiveError", "ErrorCode", "pattern", "match", "owner", "repo", "isValidName", "normalizedUrl", "name", "parseRepositoriesBatch", "urls", "valid", "invalid", "index", "lineNumber", "parsed", "error", "errorMessage", "URLParser", "logger", "getLogger", "InputHandler", "resolve", "rl", "createInterface", "urls", "lineNumber", "isFinished", "promptNext", "input", "trimmedInput", "finishInput", "result", "URLParser", "filePath", "lines", "fs", "error", "message", "line", "answer", "confirmed", "formatDuration", "ms", "minutes", "seconds", "formatBytes", "bytes", "k", "sizes", "formatPercent", "value", "total", "createProgressBar", "completed", "width", "filledWidth", "emptyWidth", "filled", "empty", "percentage", "centerText", "text", "padding", "truncate", "maxLength", "Formatting", "ProgressDisplay", "now", "progress", "completed", "total", "current", "percent", "line", "Formatting", "summary", "successful", "failed", "skipped", "totalDuration", "duration", "createLine", "label", "value", "extraPadding", "valueStr", "padding", "elapsed", "avgTime", "remaining", "logger", "getLogger", "createArchiveCommand", "Command", "options", "archiveCommand", "concurrency", "timeout", "validateOptions", "authManager", "AuthManager", "PATHS", "inputHandler", "InputHandler", "progressDisplay", "ProgressDisplay", "githubService", "authenticateUser", "repositories", "parseErrors", "getRepositories", "logParseErrors", "MESSAGES", "showRepositoriesPreview", "confirmOperation", "archiveOptions", "archiver", "Archiver", "results", "archiveRepositories", "displayResults", "error", "handleArchiveError", "token", "GitHubService", "authenticatedUser", "result", "err", "dryRun", "index", "repo", "summary", "progress", "r", "message", "provideErrorGuidance", "lowerMessage", "createInterface", "Command", "authManager", "AuthManager", "PATHS", "createLoginCommand", "Command", "token", "promptForToken", "credentials", "MESSAGES", "getLogger", "error", "message", "createLogoutCommand", "confirmAction", "createStatusCommand", "validation", "createValidateCommand", "resolve", "rl", "createInterface", "answer", "createAuthCommand", "VERSION", "DESCRIPTION", "main", "initializeLogger", "PATHS", "fileLogger", "createLogger", "setLogger", "program", "Command", "createAuthCommand", "createArchiveCommand", "error", "message"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-archiver",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
4
4
  "description": "Archive GitHub repositories via CLI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/.releaserc.json DELETED
@@ -1,30 +0,0 @@
1
- {
2
- "branches": ["main"],
3
- "plugins": [
4
- [
5
- "@semantic-release/commit-analyzer",
6
- {
7
- "releaseRules": [{ "type": "*", "release": "patch" }],
8
- "parserOpts": {
9
- "conventionalCommits": false
10
- }
11
- }
12
- ],
13
- "@semantic-release/release-notes-generator",
14
- [
15
- "@semantic-release/changelog",
16
- {
17
- "changelogFile": "CHANGELOG.md"
18
- }
19
- ],
20
- "@semantic-release/npm",
21
- [
22
- "@semantic-release/git",
23
- {
24
- "assets": ["package.json", "CHANGELOG.md", "README.md"],
25
- "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
26
- }
27
- ],
28
- "@semantic-release/github"
29
- ]
30
- }