gitpick 3.16.0-canary.5 → 3.16.0-canary.6
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/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var y=Object.getOwnPropertySymbols;var C=Object.prototype.hasOwnProperty,S=Objec
|
|
|
3
3
|
(e.g. 1h, 30m, 15s) default: 1m`).action(async(e,o,r)=>{G.parse({url:e,target:o,branch:r.branch,overwrite:r.overwrite,watch:r.watch}),r.watch&&(typeof r.watch=="boolean"&&(r.watch="1m"),console.log(`\u{1F440} Watching every ${d(r.watch)/1e3+"s"}
|
|
4
4
|
`));let t=await $(e,{branch:r.branch,target:o}),i=t,{token:n}=i,s=v(i,["token"]);console.log(s,`
|
|
5
5
|
`);let l=H().start();try{l.stop();let c=g.resolve(t.target);if(r.watch&&(r.overwrite=!0),m.existsSync(c+(t.type==="blob"?"/"+t.path.split("/").pop():""))&&(await m.promises.readdir(c)).length&&!r.overwrite){let h=t.type==="tree"?"The target directory is not empty. Do you want to overwrite the files?":"The target file already exists. Do you want to overwrite the file?",{overwrite:u}=await U.prompt([{type:"confirm",name:"overwrite",message:h,default:!1}]);if(!u)throw new Error("Chose not to overwrite files");l.info("You can use -o | --overwrite flag to skip this prompt")}if(await x(l,t,r,c),r.watch){let h=d(r.watch);setInterval(async()=>await x(l,t,r,c),h)}}catch(c){if(console.log(`
|
|
6
|
-
`),l.fail("An error occurred"),c instanceof p.ZodError){let h=A(c);console.error(`
|
|
6
|
+
`),l.fail(" Level 1: An error occurred"),c instanceof p.ZodError){let h=A(c);console.error(`
|
|
7
7
|
Validation Error:
|
|
8
8
|
`+h.toString()+`
|
|
9
9
|
`)}else c instanceof Error?console.error(`
|
|
@@ -13,7 +13,7 @@ Error:
|
|
|
13
13
|
Unexpected Error:
|
|
14
14
|
`+JSON.stringify(c,null,2)+`
|
|
15
15
|
`);process.exit(1)}});async function j(e,o){let r=await m.promises.readdir(e,{withFileTypes:!0});await m.promises.mkdir(o,{recursive:!0});for(let t of r){if(t.name===".git")continue;let n=g.join(e,t.name),s=g.join(o,t.name);t.isDirectory()?await j(n,s):await m.promises.copyFile(n,s)}}var x=async(e,o,r,t)=>{try{let n=O(),s=`https://${o.token?o.token+"@":o.token}github.com/${o.owner}/${o.repository}.git`,l=g.join(I.tmpdir(),`${o.repository}-${Date.now()}`);r.watch||e.start(`Cloning ${o.type} from repository`),await n.clone(s,l,["--depth","1","--single-branch","--branch",o.branch]);let i=g.join(l,o.path);(await m.promises.stat(i)).isDirectory()?(await m.promises.mkdir(t,{recursive:!0}),await j(i,t)):(await m.promises.mkdir(t,{recursive:!0}),await m.promises.copyFile(i,t+"/"+o.path.split("/").pop())),r.watch?e.succeed("Synced at "+new Date().toLocaleTimeString()):e.succeed(`${o.type.slice(0,1).toUpperCase()+o.type.slice(1)} cloned from repository`),await m.promises.rm(l,{recursive:!0,force:!0})}catch(n){console.log(`
|
|
16
|
-
`),e.fail("An error occurred!"),n instanceof Error?console.error(`
|
|
16
|
+
`),e.fail(" Level 2: An error occurred!"),n instanceof Error?console.error(`
|
|
17
17
|
Error:
|
|
18
18
|
`+n.message+`
|
|
19
19
|
`):console.error(`
|