pagerts 0.4.1 → 1.0.2
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/bin/main.js +6 -27
- package/bin/main.js.map +4 -4
- package/package.json +6 -2
- package/.github/codeql/codeql-config.yml +0 -7
- package/.github/workflows/ci.yml +0 -146
- package/.github/workflows/dependency-update.yml +0 -52
- package/.prettierignore +0 -5
- package/.prettierrc.json +0 -10
- package/MAINTAINERS.md +0 -30
- package/POST-INSTALL.md +0 -205
- package/SECURITY.md +0 -160
- package/eslint.config.mjs +0 -83
- package/jest.config.cjs +0 -213
- package/src/__tests__/PageFetcher.test.ts +0 -48
- package/src/__tests__/security.test.ts +0 -153
- package/src/extractors/AbstractExtractor.ts +0 -4
- package/src/extractors/PageExtractor.ts +0 -21
- package/src/extractors/ResourceExtractor.ts +0 -31
- package/src/extractors/TagExtractor.ts +0 -13
- package/src/extractors/index.ts +0 -4
- package/src/main.ts +0 -71
- package/src/page/Page.ts +0 -24
- package/src/page/PageFetcher.ts +0 -81
- package/src/page/index.ts +0 -3
- package/src/printers/AbstractResourcePrinter.ts +0 -6
- package/src/printers/JSONStylePrinter.ts +0 -9
- package/src/printers/LogStylePrinter.ts +0 -30
- package/src/printers/index.ts +0 -3
- package/src/resource.ts +0 -88
- package/src/security.ts +0 -184
- package/tsconfig.eslint.json +0 -5
- package/tsconfig.json +0 -28
package/bin/main.js
CHANGED
|
@@ -1,32 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
`).
|
|
4
|
-
`)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|.{1,${u-1}}([${d}]|$)|[^${d}]+?([${d}]|$)`,"g"),m=l.match(g)||[];return a+m.map((O,P)=>O===`
|
|
8
|
-
`?"":(P>0?c:"")+O.trimEnd()).join(`
|
|
9
|
-
`)}};J.Help=M});var N=x(L=>{var{InvalidArgumentError:Ce}=w(),U=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let i=ve(e);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new Ce(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return Ee(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},q=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(e,t){let i=t.attributeName();if(!this.dualOptions.has(i))return!0;let r=this.negativeOptions.get(i).presetArg,s=r!==void 0?r:!1;return t.negate===(s===e)}};function Ee(o){return o.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function ve(o){let e,t,i=o.split(/[ |,]+/);return i.length>1&&!/^[[<]/.test(i[1])&&(e=i.shift()),t=i.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}L.Option=U;L.DualOptions=q});var z=x(B=>{function $e(o,e){if(Math.abs(o.length-e.length)>3)return Math.max(o.length,e.length);let t=[];for(let i=0;i<=o.length;i++)t[i]=[i];for(let i=0;i<=e.length;i++)t[0][i]=i;for(let i=1;i<=e.length;i++)for(let r=1;r<=o.length;r++){let s=1;o[r-1]===e[i-1]?s=0:s=1,t[r][i]=Math.min(t[r-1][i]+1,t[r][i-1]+1,t[r-1][i-1]+s),r>1&&i>1&&o[r-1]===e[i-2]&&o[r-2]===e[i-1]&&(t[r][i]=Math.min(t[r][i],t[r-2][i-2]+1))}return t[o.length][e.length]}function Se(o,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=o.startsWith("--");t&&(o=o.slice(2),e=e.map(n=>n.slice(2)));let i=[],r=3,s=.4;return e.forEach(n=>{if(n.length<=1)return;let u=$e(o,n),a=Math.max(o.length,n.length);(a-u)/a>s&&(u<r?(r=u,i=[n]):u===r&&i.push(n))}),i.sort((n,u)=>n.localeCompare(u)),t&&(i=i.map(n=>`--${n}`)),i.length>1?`
|
|
10
|
-
(Did you mean one of ${i.join(", ")}?)`:i.length===1?`
|
|
11
|
-
(Did you mean ${i[0]}?)`:""}B.suggestSimilar=Se});var ee=x(Z=>{var ke=A("node:events").EventEmitter,j=A("node:child_process"),_=A("node:path"),F=A("node:fs"),p=A("node:process"),{Argument:Pe,humanReadableArgName:Ve}=k(),{CommanderError:I}=w(),{Help:Re}=D(),{Option:Y,DualOptions:He}=N(),{suggestSimilar:X}=z(),W=class o extends ke{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:t=>p.stdout.write(t),writeErr:t=>p.stderr.write(t),getOutHelpWidth:()=>p.stdout.isTTY?p.stdout.columns:void 0,getErrHelpWidth:()=>p.stderr.isTTY?p.stderr.columns:void 0,outputError:(t,i)=>i(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,i){let r=t,s=i;typeof r=="object"&&r!==null&&(s=r,r=null),s=s||{};let[,n,u]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(n);return r&&(a.description(r),a._executableHandler=!0),s.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(s.noHelp||s.hidden),a._executableFile=s.executableFile||null,u&&a.arguments(u),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),r?this:a}createCommand(e){return new o(e)}createHelp(){return Object.assign(new Re,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
12
|
-
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new Pe(e,t)}argument(e,t,i,r){let s=this.createArgument(e,t);return typeof i=="function"?s.default(r).argParser(i):s.default(i),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,i,r]=e.match(/([^ ]+) *(.*)/),s=t??"display help for command",n=this.createCommand(i);return n.helpOption(!1),r&&n.arguments(r),s&&n.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=n,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
13
|
-
Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,i){this._exitCallback&&this._exitCallback(new I(e,t,i)),p.exit(e)}action(e){let t=i=>{let r=this.registeredArguments.length,s=i.slice(0,r);return this._storeOptionsAsProperties?s[r]=this:s[r]=this.opts(),s.push(this),e.apply(this,s)};return this._actionHandler=t,this}createOption(e,t){return new Y(e,t)}_callParseArg(e,t,i,r){try{return e.parseArg(t,i)}catch(s){if(s.code==="commander.invalidArgument"){let n=`${r} ${s.message}`;this.error(n,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let i=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'
|
|
14
|
-
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=r=>[r.name()].concat(r.aliases()),i=t(e).find(r=>this._findCommand(r));if(i){let r=t(this._findCommand(i)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${r}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),i=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(i,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(i,e.defaultValue,"default");let r=(s,n,u)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let a=this.getOptionValue(i);s!==null&&e.parseArg?s=this._callParseArg(e,s,a,n):s!==null&&e.variadic&&(s=e._concatValue(s,a)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(i,s,u)};return this.on("option:"+t,s=>{let n=`error: option '${e.flags}' argument '${s}' is invalid.`;r(s,n,"cli")}),e.envVar&&this.on("optionEnv:"+t,s=>{let n=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;r(s,n,"env")}),this}_optionEx(e,t,i,r,s){if(typeof t=="object"&&t instanceof Y)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let n=this.createOption(t,i);if(n.makeOptionMandatory(!!e.mandatory),typeof r=="function")n.default(s).argParser(r);else if(r instanceof RegExp){let u=r;r=(a,l)=>{let c=u.exec(a);return c?c[0]:l},n.default(s).argParser(r)}else n.default(r);return this.addOption(n)}option(e,t,i,r){return this._optionEx({},e,t,i,r)}requiredOption(e,t,i,r){return this._optionEx({mandatory:!0},e,t,i,r)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,i){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=i,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(e)!==void 0&&(t=i.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){p.versions?.electron&&(t.from="electron");let r=p.execArgv??[];(r.includes("-e")||r.includes("--eval")||r.includes("-p")||r.includes("--print"))&&(t.from="eval")}e===void 0&&(e=p.argv),this.rawArgs=e.slice();let i;switch(t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":p.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=e.slice(0);break;case"eval":i=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(e,t){let i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){let i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_executeSubCommand(e,t){t=t.slice();let i=!1,r=[".js",".ts",".tsx",".mjs",".cjs"];function s(c,h){let d=_.resolve(c,h);if(F.existsSync(d))return d;if(r.includes(_.extname(h)))return;let g=r.find(m=>F.existsSync(`${d}${m}`));if(g)return`${d}${g}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=e._executableFile||`${this._name}-${e._name}`,u=this._executableDir||"";if(this._scriptPath){let c;try{c=F.realpathSync(this._scriptPath)}catch{c=this._scriptPath}u=_.resolve(_.dirname(c),u)}if(u){let c=s(u,n);if(!c&&!e._executableFile&&this._scriptPath){let h=_.basename(this._scriptPath,_.extname(this._scriptPath));h!==this._name&&(c=s(u,`${h}-${e._name}`))}n=c||n}i=r.includes(_.extname(n));let a;p.platform!=="win32"?i?(t.unshift(n),t=Q(p.execArgv).concat(t),a=j.spawn(p.argv[0],t,{stdio:"inherit"})):a=j.spawn(n,t,{stdio:"inherit"}):(t.unshift(n),t=Q(p.execArgv).concat(t),a=j.spawn(p.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(h=>{p.on(h,()=>{a.killed===!1&&a.exitCode===null&&a.kill(h)})});let l=this._exitCallback;a.on("close",c=>{c=c??1,l?l(new I(c,"commander.executeSubCommandAsync","(close)")):p.exit(c)}),a.on("error",c=>{if(c.code==="ENOENT"){let h=u?`searched for local subcommand relative to directory '${u}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",d=`'${n}' does not exist
|
|
15
|
-
- if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
16
|
-
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
17
|
-
- ${h}`;throw new Error(d)}else if(c.code==="EACCES")throw new Error(`'${n}' not executable`);if(!l)p.exit(1);else{let h=new I(1,"commander.executeSubCommandAsync","(error)");h.nestedError=c,l(h)}}),this.runningCommand=a}_dispatchSubcommand(e,t,i){let r=this._findCommand(e);r||this.help({error:!0});let s;return s=this._chainOrCallSubCommandHook(s,r,"preSubcommand"),s=this._chainOrCall(s,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(i));else return r._parseCommand(t,i)}),s}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(i,r,s)=>{let n=r;if(r!==null&&i.parseArg){let u=`error: command-argument value '${r}' is invalid for argument '${i.name()}'.`;n=this._callParseArg(i,r,s,u)}return n};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((i,r)=>{let s=i.defaultValue;i.variadic?r<this.args.length?(s=this.args.slice(r),i.parseArg&&(s=s.reduce((n,u)=>e(i,u,n),i.defaultValue))):s===void 0&&(s=[]):r<this.args.length&&(s=this.args[r],i.parseArg&&(s=e(i,s,i.defaultValue))),t[r]=s}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let i=e,r=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[t]!==void 0).forEach(s=>{s._lifeCycleHooks[t].forEach(n=>{r.push({hookedCommand:s,callback:n})})}),t==="postAction"&&r.reverse(),r.forEach(s=>{i=this._chainOrCall(i,()=>s.callback(s.hookedCommand,this))}),i}_chainOrCallSubCommandHook(e,t,i){let r=e;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(s=>{r=this._chainOrCall(r,()=>s(this,t))}),r}_parseCommand(e,t){let i=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(i.operands),t=i.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,"preAction"),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(s,e,t)})),n=this._chainOrCallHooks(n,"postAction"),n}if(this.parent&&this.parent.listenerCount(s))r(),this._processArguments(),this.parent.emit(s,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(i=>{let r=i.attributeName();return this.getOptionValue(r)===void 0?!1:this.getOptionValueSource(r)!=="default"});e.filter(i=>i.conflictsWith.length>0).forEach(i=>{let r=e.find(s=>i.conflictsWith.includes(s.attributeName()));r&&this._conflictingOption(i,r)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],i=[],r=t,s=e.slice();function n(a){return a.length>1&&a[0]==="-"}let u=null;for(;s.length;){let a=s.shift();if(a==="--"){r===i&&r.push(a),r.push(...s);break}if(u&&!n(a)){this.emit(`option:${u.name()}`,a);continue}if(u=null,n(a)){let l=this._findOption(a);if(l){if(l.required){let c=s.shift();c===void 0&&this.optionMissingArgument(l),this.emit(`option:${l.name()}`,c)}else if(l.optional){let c=null;s.length>0&&!n(s[0])&&(c=s.shift()),this.emit(`option:${l.name()}`,c)}else this.emit(`option:${l.name()}`);u=l.variadic?l:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let l=this._findOption(`-${a[1]}`);if(l){l.required||l.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${l.name()}`,a.slice(2)):(this.emit(`option:${l.name()}`),s.unshift(`-${a.slice(2)}`));continue}}if(/^--[^=]+=/.test(a)){let l=a.indexOf("="),c=this._findOption(a.slice(0,l));if(c&&(c.required||c.optional)){this.emit(`option:${c.name()}`,a.slice(l+1));continue}}if(n(a)&&(r=i),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&i.length===0){if(this._findCommand(a)){t.push(a),s.length>0&&i.push(...s);break}else if(this._getHelpCommand()&&a===this._getHelpCommand().name()){t.push(a),s.length>0&&t.push(...s);break}else if(this._defaultCommandName){i.push(a),s.length>0&&i.push(...s);break}}if(this._passThroughOptions){r.push(a),s.length>0&&r.push(...s);break}r.push(a)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let i=0;i<t;i++){let r=this.options[i].attributeName();e[r]=r===this._versionOptionName?this._version:this[r]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
18
|
-
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
19
|
-
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
20
|
-
`),this.outputHelp({error:!0}));let i=t||{},r=i.exitCode||1,s=i.code||"commander.error";this._exit(r,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in p.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,p.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new He(this.options),t=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(r=>!t(r)).forEach(r=>{this.setOptionValueWithSource(r,i.implied[r],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let i=n=>{let u=n.attributeName(),a=this.getOptionValue(u),l=this.options.find(h=>h.negate&&u===h.attributeName()),c=this.options.find(h=>!h.negate&&u===h.attributeName());return l&&(l.presetArg===void 0&&a===!1||l.presetArg!==void 0&&a===l.presetArg)?l:c||n},r=n=>{let u=i(n),a=u.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${u.envVar}'`:`option '${u.flags}'`},s=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let r=[],s=this;do{let n=s.createHelp().visibleOptions(s).filter(u=>u.long).map(u=>u.long);r=r.concat(n),s=s.parent}while(s&&!s._enablePositionalOptions);t=X(e,r)}let i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,i=t===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let r=[];this.createHelp().visibleCommands(this).forEach(s=>{r.push(s.name()),s.alias()&&r.push(s.alias())}),t=X(e,r)}let i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";let r=this.createOption(t,i);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
21
|
-
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(e);if(i){let r=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${r}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(i=>Ve(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=_.basename(e,_.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},i;return t.error?i=r=>this._outputConfiguration.writeErr(r):i=r=>this._outputConfiguration.writeOut(r),t.write=e.write||i,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let i=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(s=>s.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let r=this.helpInformation(i);if(t&&(r=t(r),typeof r!="string"&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(s=>s.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=p.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
22
|
-
Expecting one of '${i.join("', '")}'`);let r=`${e}Help`;return this.on(r,s=>{let n;typeof t=="function"?n=t({error:s.error,command:s.command}):n=t,n&&s.write(`${n}
|
|
23
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(r=>t.is(r))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Q(o){return o.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",r="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?r=s[3]:i=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],i=s[3],r=s[4]),t&&r!=="0"?`${t}=${i}:${parseInt(r)+1}`:e})}Z.Command=W});var se=x(f=>{var{Argument:te}=k(),{Command:K}=ee(),{CommanderError:Te,InvalidArgumentError:ie}=w(),{Help:Me}=D(),{Option:re}=N();f.program=new K;f.createCommand=o=>new K(o);f.createOption=(o,e)=>new re(o,e);f.createArgument=(o,e)=>new te(o,e);f.Command=K;f.Option=re;f.Argument=te;f.Help=Me;f.CommanderError=Te;f.InvalidArgumentError=ie;f.InvalidOptionArgumentError=ie});var ne=xe(se(),1),{program:st,createCommand:nt,createArgument:oe,createOption:ot,CommanderError:at,InvalidArgumentError:lt,InvalidOptionArgumentError:ut,Command:ae,Argument:ct,Option:ht,Help:pt}=ne.default;var le={name:"pagerts",description:"A tool for viewing external relations in a webpage",version:"0.4.1",main:"main.js",bin:{pagerts:"bin/main.js"},engines:{node:">=18.0.0"},scripts:{test:"jest --coverage","test:watch":"jest --watch",build:"esbuild src/main.ts --external:jsdom --bundle --outdir=bin --minify --sourcemap --platform=node --format=esm",lint:"eslint src/**/*.ts","lint:fix":"eslint src/**/*.ts --fix","type-check":"tsc --noEmit",format:'prettier --write "src/**/*.ts"',"format:check":'prettier --check "src/**/*.ts"',"security:audit":"npm audit --audit-level=moderate","security:check":"npm run security:audit && npm run lint",start:"node ./bin/main.js",dev:"tsx src/main.ts",prepare:"npm run build"},keywords:["webpage","hierarchy","management","web-scraping","cli","url-extraction"],author:"Kirill kn253 Nevzorov",license:"MIT",bugs:{url:"https://github.com/akinevz0/pagerts/issues"},homepage:"https://github.com/akinevz0/pagerts",dependencies:{commander:"^12.1.0",jsdom:"^25.0.1"},devDependencies:{"@types/jest":"^29.5.14","@types/jsdom":"^21.1.7","@types/node":"^22.10.5","@typescript-eslint/eslint-plugin":"^8.20.0","@typescript-eslint/parser":"^8.20.0",esbuild:"^0.25.1",eslint:"^9.18.0","eslint-config-prettier":"^9.1.0","eslint-plugin-security":"^3.0.1",jest:"^29.7.0",prettier:"^3.4.2","ts-jest":"^29.2.5",tsx:"^4.19.2",typescript:"^5.7.2"}};var b=class{constructor(e){this.name=e}};var C=class extends b{constructor(){super("page-extractor")}async extract(e){let{window:{document:{title:t,location:{href:i}}}}=e;return{title:t,url:i}}};function Ue(o,e){for(let t of e)if(Ne(t,o))return t}var qe=["id","innerText","textContent","class","ariaLabel","ariaDescription","alt"],Le=["href","data-src","target","action","src","url"];function ue(o){for(let e of qe){let t=o[e];if(t&&typeof t=="string"&&t.trim()!=="")return{key:e,value:t}}}function ce(o){let e=Ue(o,[...Le]);if(!e)return;let t=o[e];if(t&&typeof t=="string"&&t.trim()!=="")return{key:e,url:t}}var Ne=(o,e)=>o in e&&e[o]!==void 0;var E=class extends b{constructor(t){super("page-extractor");this.tags=t}async extract(t){let{document:i}=t.window,r=[];for(let s of this.tags){let n=i.querySelectorAll(s),u=Array.from(n);for(let a of u){let l=ue(a),c=ce(a);!l||!c||c.url.startsWith("http")&&r.push({text:l,link:c})}}return r}};import{JSDOM as he,VirtualConsole as je}from"jsdom";var v=class{timeout;maxRetries;constructor(e=1e4,t=2){this.timeout=e,this.maxRetries=t}async fetchPage(e,t=0){let i=new je().on("jsdomError",r=>{process.stderr.write(`Error parsing ${e}: ${r.message}
|
|
24
|
-
`)});try{let r;e.startsWith("file://")?r=he.fromFile(e.substring(7),{virtualConsole:i}):r=he.fromURL(e,{virtualConsole:i,resources:"usable",runScripts:"outside-only",beforeParse(n){n.setTimeout=()=>{throw new Error("setTimeout disabled for security")},n.setInterval=()=>{throw new Error("setInterval disabled for security")}}});let s=await Promise.race([r,new Promise((n,u)=>setTimeout(()=>u(new Error("Request timeout")),this.timeout))]);return{url:e,content:s}}catch(r){let s=r instanceof Error?r.message:"Unknown error";return t<this.maxRetries&&this.isRetryableError(s)?(process.stderr.write(`Retrying ${e} (attempt ${t+1}/${this.maxRetries})...
|
|
25
|
-
`),await this.delay(1e3*(t+1)),this.fetchPage(e,t+1)):{url:e,error:`Failed to fetch: ${s}`}}}isRetryableError(e){return[/timeout/i,/ECONNRESET/i,/ETIMEDOUT/i,/ENOTFOUND/i,/network/i].some(i=>i.test(e))}delay(e){return new Promise(t=>setTimeout(t,e))}async fetchAll(e){return(await Promise.all(e.map(i=>this.fetchPage(i)))).filter(i=>i.content!==void 0||i.error)}};var y=class{constructor(){}};var $=class extends y{print(...e){let t=JSON.stringify(e);process.stdout.write(t+`
|
|
26
|
-
`)}};var pe=["http:","https:","file:"];var Ie=[/javascript:/i,/data:/i,/vbscript:/i,/<script/i,/on\w+=/i];function We(o){if(!o||!o.trim())return{isValid:!1,error:"URL cannot be empty"};let e=o.trim();if(e.length>2048)return{isValid:!1,error:"URL exceeds maximum length of 2048 characters"};for(let s of Ie)if(s.test(e))return{isValid:!1,error:"URL contains suspicious patterns"};let t;try{t=new URL(e)}catch{return e.startsWith("file://")?{isValid:!0,sanitizedUrl:e}:{isValid:!1,error:"Invalid URL format"}}if(!pe.includes(t.protocol))return{isValid:!1,error:`Protocol ${t.protocol} is not allowed. Allowed protocols: ${pe.join(", ")}`};let i=t.hostname.toLowerCase();return(i==="localhost"||i==="127.0.0.1"||i==="::1"||i.startsWith("192.168.")||i.startsWith("10.")||/^172\.(1[6-9]|2\d|3[01])\./.test(i))&&t.protocol!=="file:"&&console.warn(`Warning: Accessing local network resource: ${e}`),{isValid:!0,sanitizedUrl:t.toString()}}function me(o){let e=[],t=[];for(let i of o){let r=We(i);r.isValid&&r.sanitizedUrl?e.push(r.sanitizedUrl):t.push({url:i,error:r.error||"Unknown validation error"})}return{validUrls:e,errors:t}}var{description:Ke,name:Ge,version:Je}=le,Be=new ae,ze=oe("<url | file...>","remote https://URL or local file://resource.html to extract from");(async()=>await Be.name(Ge).version(Je,"-v, --version").description(Ke).addArgument(ze).action(async o=>{try{let{validUrls:e,errors:t}=me(o);t.length>0&&(console.error(`
|
|
27
|
-
\u274C URL Validation Errors:`),t.forEach(({url:l,error:c})=>{console.error(` - ${l}: ${c}`)})),e.length===0&&(console.error(`
|
|
2
|
+
import{Command as j,createArgument as N}from"commander";var R={name:"pagerts",description:"A tool for viewing external relations in a webpage",version:"1.0.2",type:"module",main:"main.js",bin:{pagerts:"bin/main.js"},files:["bin"],engines:{node:">=18.0.0"},scripts:{test:"jest --coverage","test:watch":"jest --watch",build:"esbuild src/main.ts --bundle --packages=external --outdir=bin --minify --sourcemap --platform=node --format=esm",lint:"eslint src/**/*.ts","lint:fix":"eslint src/**/*.ts --fix","type-check":"tsc --noEmit",format:'prettier --write "src/**/*.ts"',"format:check":'prettier --check "src/**/*.ts"',"security:audit":"npm audit --audit-level=moderate","security:check":"npm run security:audit && npm run lint",start:"node ./bin/main.js",dev:"tsx src/main.ts",prepare:"npm run build"},keywords:["webpage","hierarchy","management","web-scraping","cli","url-extraction"],author:"Kirill kn253 Nevzorov",license:"MIT",bugs:{url:"https://github.com/akinevz0/pagerts/issues"},homepage:"https://github.com/akinevz0/pagerts",dependencies:{commander:"^12.1.0",jsdom:"^25.0.1"},devDependencies:{"@types/jest":"^29.5.14","@types/jsdom":"^21.1.7","@types/node":"^22.10.5","@typescript-eslint/eslint-plugin":"^8.20.0","@typescript-eslint/parser":"^8.20.0",esbuild:"^0.25.1",eslint:"^9.18.0","eslint-config-prettier":"^9.1.0","eslint-plugin-security":"^3.0.1",jest:"^29.7.0",prettier:"^3.4.2","ts-jest":"^29.2.5",tsx:"^4.19.2",typescript:"^5.7.2"}};var a=class{constructor(e){this.name=e}};var d=class extends a{constructor(){super("page-extractor")}async extract(e){let{window:{document:{title:r,location:{href:t}}}}=e;return{title:r,url:t}}};function T(s,e){for(let r of e)if(S(r,s))return r}var k=["id","innerText","textContent","class","ariaLabel","ariaDescription","alt"],M=["href","data-src","target","action","src","url"];function w(s){for(let e of k){let r=s[e];if(r&&typeof r=="string"&&r.trim()!=="")return{key:e,value:r}}}function P(s){let e=T(s,[...M]);if(!e)return;let r=s[e];if(r&&typeof r=="string"&&r.trim()!=="")return{key:e,url:r}}var S=(s,e)=>s in e&&e[s]!==void 0;var f=class extends a{constructor(r){super("page-extractor");this.tags=r}async extract(r){let{document:t}=r.window,o=[];for(let i of this.tags){let c=t.querySelectorAll(i),u=Array.from(c);for(let m of u){let n=w(m),l=P(m);!n||!l||l.url.startsWith("http")&&o.push({text:n,link:l})}}return o}};import{JSDOM as b,VirtualConsole as A}from"jsdom";var g=class{timeout;maxRetries;constructor(e=1e4,r=2){this.timeout=e,this.maxRetries=r}async fetchPage(e,r=0){let t=new A().on("jsdomError",o=>{process.stderr.write(`Error parsing ${e}: ${o.message}
|
|
3
|
+
`)});try{let o;e.startsWith("file://")?o=b.fromFile(e.substring(7),{virtualConsole:t}):o=b.fromURL(e,{virtualConsole:t,resources:"usable",runScripts:"outside-only",beforeParse(c){c.setTimeout=()=>{throw new Error("setTimeout disabled for security")},c.setInterval=()=>{throw new Error("setInterval disabled for security")}}});let i=await Promise.race([o,new Promise((c,u)=>setTimeout(()=>u(new Error("Request timeout")),this.timeout))]);return{url:e,content:i}}catch(o){let i=o instanceof Error?o.message:"Unknown error";return r<this.maxRetries&&this.isRetryableError(i)?(process.stderr.write(`Retrying ${e} (attempt ${r+1}/${this.maxRetries})...
|
|
4
|
+
`),await this.delay(1e3*(r+1)),this.fetchPage(e,r+1)):{url:e,error:`Failed to fetch: ${i}`}}}isRetryableError(e){return[/timeout/i,/ECONNRESET/i,/ETIMEDOUT/i,/ENOTFOUND/i,/network/i].some(t=>t.test(e))}delay(e){return new Promise(r=>setTimeout(r,e))}async fetchAll(e){return(await Promise.all(e.map(t=>this.fetchPage(t)))).filter(t=>t.content!==void 0||t.error)}};var p=class{constructor(){}};var y=class extends p{print(...e){let r=JSON.stringify(e);process.stdout.write(r+`
|
|
5
|
+
`)}};var E=["http:","https:","file:"];var D=[/javascript:/i,/data:/i,/vbscript:/i,/<script/i,/on\w+=/i];function O(s){if(!s||!s.trim())return{isValid:!1,error:"URL cannot be empty"};let e=s.trim();if(e.length>2048)return{isValid:!1,error:"URL exceeds maximum length of 2048 characters"};for(let i of D)if(i.test(e))return{isValid:!1,error:"URL contains suspicious patterns"};let r;try{r=new URL(e)}catch{return e.startsWith("file://")?{isValid:!0,sanitizedUrl:e}:{isValid:!1,error:"Invalid URL format"}}if(!E.includes(r.protocol))return{isValid:!1,error:`Protocol ${r.protocol} is not allowed. Allowed protocols: ${E.join(", ")}`};let t=r.hostname.toLowerCase();return(t==="localhost"||t==="127.0.0.1"||t==="::1"||t.startsWith("192.168.")||t.startsWith("10.")||/^172\.(1[6-9]|2\d|3[01])\./.test(t))&&r.protocol!=="file:"&&console.warn(`Warning: Accessing local network resource: ${e}`),{isValid:!0,sanitizedUrl:r.toString()}}function v(s){let e=[],r=[];for(let t of s){let o=O(t);o.isValid&&o.sanitizedUrl?e.push(o.sanitizedUrl):r.push({url:t,error:o.error||"Unknown validation error"})}return{validUrls:e,errors:r}}var{description:$,name:q,version:_}=R,V=new j,J=N("<url | file...>","remote https://URL or local file://resource.html to extract from");(async()=>await V.name(q).version(_,"-v, --version").description($).addArgument(J).action(async s=>{try{let{validUrls:e,errors:r}=v(s);r.length>0&&(console.error(`
|
|
6
|
+
\u274C URL Validation Errors:`),r.forEach(({url:n,error:l})=>{console.error(` - ${n}: ${l}`)})),e.length===0&&(console.error(`
|
|
28
7
|
\u274C No valid URLs to process. Exiting.`),process.exit(1)),console.error(`
|
|
29
|
-
\u2705 Processing ${e.length} valid URL(s)...`);let
|
|
8
|
+
\u2705 Processing ${e.length} valid URL(s)...`);let t=new y,o=new g,i=new d,c=new f(["a","meta","link","embed"]),u=await o.fetchAll(e),m=[];for(let{content:n,url:l,error:x}of u){let h=x!==void 0||!n?[]:await c.extract(n),U=x!==void 0||!n?{url:l,error:x??"Unknown error",resources:h}:await i.extract(n);m.push({...U,resources:h})}await t.print(...m)}catch(e){console.error(`
|
|
30
9
|
\u274C An error occurred:`,e instanceof Error?e.message:e),process.exit(1)}}).parseAsync(process.argv))();
|
|
31
10
|
/**
|
|
32
11
|
* @license MIT
|