vidup 1.0.10 → 1.0.12

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.
Files changed (2) hide show
  1. package/dist/bin/cli.js +1 -1
  2. package/package.json +5 -5
package/dist/bin/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var M=Object.defineProperty;var a=(e,t)=>M(e,"name",{value:t,configurable:!0});import I from"node:path";import O from"node:os";import S from"yargs";import{hideBin as $}from"yargs/helpers";import{l as h,s as x,a as E}from"../sync-DAKTIkq2.js";import"bunnycdn-stream";import"hasha";import"node:fs";import"node:fs/promises";import"node:url";import"ora";import"execa";import"ffmpeg-static";const v=a(e=>Number.isFinite(e)?e:0,"toZeroIfInfinity");function F(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(v(e*1e3)%1e3),nanoseconds:Math.trunc(v(e*1e6)%1e3)}}a(F,"parseNumber");function B(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}a(B,"parseBigint");function k(e){switch(typeof e){case"number":{if(Number.isFinite(e))return F(e);break}case"bigint":return B(e)}throw new TypeError("Expected a finite number or bigint")}a(k,"parseMilliseconds");const C=a(e=>e===0||e===0n,"isZero"),T=a((e,t)=>t===1||t===1n?e:`${e}s`,"pluralize"),z=1e-7,A=24n*60n*60n*1000n;function P(e,t){const u=typeof e=="bigint";if(!u&&!Number.isFinite(e))throw new TypeError("Expected a finite number or bigint");t={...t};const f=e<0?"-":"";e=e<0?-e:e,t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let d=[];const b=a((i,n)=>{const c=Math.floor(i*10**n+z);return(Math.round(c)/10**n).toFixed(n)},"floorDecimals"),r=a((i,n,c,o)=>{if(!((d.length===0||!t.colonNotation)&&C(i)&&!(t.colonNotation&&c==="m"))){if(o??=String(i),t.colonNotation){const m=o.includes(".")?o.split(".")[0].length:o.length,y=d.length>0?2:1;o="0".repeat(Math.max(0,y-m))+o}else o+=t.verbose?" "+T(n,i):c;d.push(o)}},"add"),s=k(e),l=BigInt(s.days);if(t.hideYearAndDays?r(BigInt(l)*24n+BigInt(s.hours),"hour","h"):(t.hideYear?r(l,"day","d"):(r(l/365n,"year","y"),r(l%365n,"day","d")),r(Number(s.hours),"hour","h")),r(Number(s.minutes),"minute","m"),!t.hideSeconds)if(t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3){const i=Number(s.seconds),n=Number(s.milliseconds),c=Number(s.microseconds),o=Number(s.nanoseconds);if(r(i,"second","s"),t.formatSubMilliseconds)r(n,"millisecond","ms"),r(c,"microsecond","\xB5s"),r(o,"nanosecond","ns");else{const m=n+c/1e3+o/1e6,y=typeof t.millisecondsDecimalDigits=="number"?t.millisecondsDecimalDigits:0,w=m>=1?Math.round(m):Math.ceil(m),g=y?m.toFixed(y):w;r(Number.parseFloat(g),"millisecond","ms",g)}}else{const i=(u?Number(e%A):e)/1e3%60,n=typeof t.secondsDecimalDigits=="number"?t.secondsDecimalDigits:1,c=b(i,n),o=t.keepDecimalsOnWholeSeconds?c:c.replace(/\.0+$/,"");r(Number.parseFloat(o),"second","s",o)}if(d.length===0)return f+"0"+(t.verbose?" milliseconds":"ms");const p=t.colonNotation?":":" ";return typeof t.unitCount=="number"&&(d=d.slice(0,Math.max(t.unitCount,1))),f+d.join(p)}a(P,"prettyMilliseconds");const D=O.homedir();function V(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return D?e.replace(/^~(?=$|\/|\\)/,D):e}a(V,"untildify");var _="1.0.10";const L=performance.now(),N=S($(process.argv));await N.scriptName("vidup").usage("$0 [command]","Run a vidup command.").command(["$0 <directory> [options]","sync <directory> [options]"],"Synchronize a remote video streaming service to mirror the contents of a local directory. Warning: This command will irrevocably delete remote videos that are not present in the local directory.",e=>e.positional("directory",{default:void 0,demandOption:!0,describe:"The path to the local directory of video files to sync.",type:"string"}).option("service",{alias:"s",choices:["bunny","mux","cloudflare"],demandOption:!0,describe:"Streaming service / platform to sync local video files to. Only the Bunny.net streaming CDN is supported at this time.",type:"string"}).option("key",{default:void 0,demandOption:!0,describe:"Streaming service API access key.",type:"string"}).option("library",{default:void 0,demandOption:!0,describe:"Streaming service library ID.",type:"string"}).option("strip-metadata",{default:!1,describe:"Remove all metadata from the video files before uploading them to the streaming service. Warning: This will modify local videos in-place.",type:"boolean"}).option("dry-run",{alias:"d",default:!1,describe:"Perform a dry run without making any changes. Useful for testing and debugging. Pairs well with the `--json` command.",type:"boolean"}).option("json",{default:!1,describe:"Output the sync report as JSON.",type:"boolean"}).option("verbose",{default:!1,describe:"Enable verbose logging. All verbose logs and prefixed with their log level and are printed to `stderr` for ease of redirection.",type:"boolean"}).check(t=>{if(t.service==="bunny")return t;throw new Error(`Sorry, vidup doesn't yet implement synchronization support the ${t.service} streaming service. Only Bunny.net is supported at the moment. If you'd like to see support for another service, please open an issue or send a PR on GitHub: https://github.com/kitschpatrol/vidup/issues`)}),async({directory:e,dryRun:t,json:u,key:f,library:d,service:b,stripMetadata:r,verbose:s})=>{h.verbose=s;const l=I.resolve(V(e));h.info("Starting video synchronization..."),t&&h.warn("Dry run enabled, not making any changes");const p=r?await x(l,{dryRun:t,verbose:s}):[],i=await E(l,{credentials:{key:f,library:d},dryRun:t,service:b,verbose:s});if(u){for(const n of i)n.stripMetadata=n.localFile!==void 0&&p.includes(n.localFile);process.stdout.write(JSON.stringify(i,void 0,2)),process.stdout.write(`
2
+ var M=Object.defineProperty;var a=(e,t)=>M(e,"name",{value:t,configurable:!0});import I from"node:path";import O from"node:os";import S from"yargs";import{hideBin as $}from"yargs/helpers";import{l as h,s as x,a as E}from"../sync-DAKTIkq2.js";import"bunnycdn-stream";import"hasha";import"node:fs";import"node:fs/promises";import"node:url";import"ora";import"execa";import"ffmpeg-static";const v=a(e=>Number.isFinite(e)?e:0,"toZeroIfInfinity");function F(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(v(e*1e3)%1e3),nanoseconds:Math.trunc(v(e*1e6)%1e3)}}a(F,"parseNumber");function B(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}a(B,"parseBigint");function k(e){switch(typeof e){case"number":{if(Number.isFinite(e))return F(e);break}case"bigint":return B(e)}throw new TypeError("Expected a finite number or bigint")}a(k,"parseMilliseconds");const C=a(e=>e===0||e===0n,"isZero"),T=a((e,t)=>t===1||t===1n?e:`${e}s`,"pluralize"),z=1e-7,A=24n*60n*60n*1000n;function P(e,t){const u=typeof e=="bigint";if(!u&&!Number.isFinite(e))throw new TypeError("Expected a finite number or bigint");t={...t};const f=e<0?"-":"";e=e<0?-e:e,t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let d=[];const b=a((i,n)=>{const c=Math.floor(i*10**n+z);return(Math.round(c)/10**n).toFixed(n)},"floorDecimals"),r=a((i,n,c,o)=>{if(!((d.length===0||!t.colonNotation)&&C(i)&&!(t.colonNotation&&c==="m"))){if(o??=String(i),t.colonNotation){const m=o.includes(".")?o.split(".")[0].length:o.length,y=d.length>0?2:1;o="0".repeat(Math.max(0,y-m))+o}else o+=t.verbose?" "+T(n,i):c;d.push(o)}},"add"),s=k(e),l=BigInt(s.days);if(t.hideYearAndDays?r(BigInt(l)*24n+BigInt(s.hours),"hour","h"):(t.hideYear?r(l,"day","d"):(r(l/365n,"year","y"),r(l%365n,"day","d")),r(Number(s.hours),"hour","h")),r(Number(s.minutes),"minute","m"),!t.hideSeconds)if(t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3){const i=Number(s.seconds),n=Number(s.milliseconds),c=Number(s.microseconds),o=Number(s.nanoseconds);if(r(i,"second","s"),t.formatSubMilliseconds)r(n,"millisecond","ms"),r(c,"microsecond","\xB5s"),r(o,"nanosecond","ns");else{const m=n+c/1e3+o/1e6,y=typeof t.millisecondsDecimalDigits=="number"?t.millisecondsDecimalDigits:0,w=m>=1?Math.round(m):Math.ceil(m),g=y?m.toFixed(y):w;r(Number.parseFloat(g),"millisecond","ms",g)}}else{const i=(u?Number(e%A):e)/1e3%60,n=typeof t.secondsDecimalDigits=="number"?t.secondsDecimalDigits:1,c=b(i,n),o=t.keepDecimalsOnWholeSeconds?c:c.replace(/\.0+$/,"");r(Number.parseFloat(o),"second","s",o)}if(d.length===0)return f+"0"+(t.verbose?" milliseconds":"ms");const p=t.colonNotation?":":" ";return typeof t.unitCount=="number"&&(d=d.slice(0,Math.max(t.unitCount,1))),f+d.join(p)}a(P,"prettyMilliseconds");const D=O.homedir();function V(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return D?e.replace(/^~(?=$|\/|\\)/,D):e}a(V,"untildify");var _="1.0.12";const L=performance.now(),N=S($(process.argv));await N.scriptName("vidup").usage("$0 [command]","Run a vidup command.").command(["$0 <directory> [options]","sync <directory> [options]"],"Synchronize a remote video streaming service to mirror the contents of a local directory. Warning: This command will irrevocably delete remote videos that are not present in the local directory.",e=>e.positional("directory",{default:void 0,demandOption:!0,describe:"The path to the local directory of video files to sync.",type:"string"}).option("service",{alias:"s",choices:["bunny","mux","cloudflare"],demandOption:!0,describe:"Streaming service / platform to sync local video files to. Only the Bunny.net streaming CDN is supported at this time.",type:"string"}).option("key",{default:void 0,demandOption:!0,describe:"Streaming service API access key.",type:"string"}).option("library",{default:void 0,demandOption:!0,describe:"Streaming service library ID.",type:"string"}).option("strip-metadata",{default:!1,describe:"Remove all metadata from the video files before uploading them to the streaming service. Warning: This will modify local videos in-place.",type:"boolean"}).option("dry-run",{alias:"d",default:!1,describe:"Perform a dry run without making any changes. Useful for testing and debugging. Pairs well with the `--json` command.",type:"boolean"}).option("json",{default:!1,describe:"Output the sync report as JSON.",type:"boolean"}).option("verbose",{default:!1,describe:"Enable verbose logging. All verbose logs and prefixed with their log level and are printed to `stderr` for ease of redirection.",type:"boolean"}).check(t=>{if(t.service==="bunny")return t;throw new Error(`Sorry, vidup doesn't yet implement synchronization support the ${t.service} streaming service. Only Bunny.net is supported at the moment. If you'd like to see support for another service, please open an issue or send a PR on GitHub: https://github.com/kitschpatrol/vidup/issues`)}),async({directory:e,dryRun:t,json:u,key:f,library:d,service:b,stripMetadata:r,verbose:s})=>{h.verbose=s;const l=I.resolve(V(e));h.info("Starting video synchronization..."),t&&h.warn("Dry run enabled, not making any changes");const p=r?await x(l,{dryRun:t,verbose:s}):[],i=await E(l,{credentials:{key:f,library:d},dryRun:t,service:b,verbose:s});if(u){for(const n of i)n.stripMetadata=n.localFile!==void 0&&p.includes(n.localFile);process.stdout.write(JSON.stringify(i,void 0,2)),process.stdout.write(`
3
3
  `)}else{for(const n of p)process.stdout.write(`${t?"Found":"Stripped"} metadata: "${n}"
4
4
  `);for(const n of i)process.stdout.write(`${n.action}: "${n.localFile}" Remote GUID: "${n.remoteId}"
5
5
  `)}h.info(`Synchronized video in ${P(performance.now()-L)}`),process.exitCode=0}).demandCommand(1).alias("h","help").version(_).alias("v","version").help().wrap(process.stdout.isTTY?Math.min(120,N.terminalWidth()):0).parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vidup",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Synchronize a local directory of video files to remote streaming services.",
5
5
  "keywords": [
6
6
  "bunnycdn-stream",
@@ -15,7 +15,7 @@
15
15
  "bugs": "https://github.com/kitschpatrol/vidup/issues",
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "https://github.com/kitschpatrol/vidup"
18
+ "url": "git+https://github.com/kitschpatrol/vidup.git"
19
19
  },
20
20
  "license": "MIT",
21
21
  "author": {
@@ -49,14 +49,14 @@
49
49
  "yargs": "^17.7.2"
50
50
  },
51
51
  "devDependencies": {
52
- "@kitschpatrol/shared-config": "^5.0.7",
53
- "@types/node": "^20.17.22",
52
+ "@kitschpatrol/shared-config": "^5.2.0",
53
+ "@types/node": "^20.17.23",
54
54
  "bumpp": "^10.0.3",
55
55
  "chalk": "^5.4.1",
56
56
  "lowdb": "^7.0.1",
57
57
  "pkgroll": "^2.11.2",
58
58
  "pretty-ms": "^9.2.0",
59
- "typescript": "^5.7.3",
59
+ "typescript": "^5.8.2",
60
60
  "untildify": "^5.0.0"
61
61
  },
62
62
  "engines": {