apify-cli 1.7.2-beta.6 → 1.7.2-beta.8
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from"node:process";import t from"chalk";import n from"indent-string";import r from"widest-line";import i from"wrap-ansi";import{inspect as a,parseArgs as s,promisify as c}from"node:util";import{gt as l,gte as u,minVersion as f,satisfies as p}from"semver";import{appendFileSync as m,constants as h,copyFileSync as g,createWriteStream as _,existsSync as v,fstat as y,mkdirSync as b,openSync as x,readFileSync as S,readdirSync as C,realpathSync as ee,renameSync as te,rmSync as w,statSync as T,unlinkSync as ne,writeFileSync as E}from"node:fs";import D,{basename as re,dirname as O,isAbsolute as ie,join as k,relative as ae,resolve as oe,sep as A}from"node:path";import se from"string-width";import ce from"strip-ansi";import{once as le}from"node:events";import{homedir as ue,platform as de}from"node:os";import fe from"ci-info";import{ACTOR_ENV_VARS as j,ACTOR_JOB_STATUSES as M,ACTOR_JOB_TERMINAL_STATUSES as pe,ACTOR_NAME as me,ACTOR_SOURCE_TYPES as he,APIFY_ENV_VARS as N,KEY_VALUE_STORE_KEYS as ge,LOCAL_ACTOR_ENV_VARS as _e,LOCAL_STORAGE_SUBDIRS as ve,MAX_MULTIFILE_BYTES as ye,META_ORIGINS as be,SOURCE_FILE_FORMATS as xe}from"@apify/consts";import{jaroWinkler as Se}from"@skyra/jaro-winkler";import Ce from"js-levenshtein";import{createHmacSignature as we,cryptoRandomObjectId as Te}from"@apify/utilities";import{execSync as Ee,spawn as De}from"node:child_process";import{access as Oe,appendFile as ke,lstat as Ae,mkdir as P,readFile as F,readdir as I,rename as je,rm as Me,stat as L,symlink as Ne,unlink as Pe,writeFile as R}from"node:fs/promises";import{DurationFormatter as Fe,Time as Ie,TimeTypes as z}from"@sapphire/duration";import{Timestamp as Le}from"@sapphire/timestamp";import Re from"adm-zip";import ze from"ajv/dist/2019.js";import{ApifyClient as Be,DownloadItemsFormat as B}from"apify-client";import{ZipArchive as Ve}from"archiver";import He,{AxiosHeaders as Ue}from"axios";import We from"escape-string-regexp";import Ge from"ignore";import{getEncoding as Ke}from"istextorbinary";import qe,{Mime as Je}from"mime";import Ye from"mime/types/other.js";import Xe from"mime/types/standard.js";import{glob as Ze}from"tinyglobby";import{rimraf as Qe}from"rimraf";import{Result as $e,err as et,none as V,ok as tt,some as nt}from"@sapphire/result";import rt from"configparser";import it from"@inquirer/input";import at from"is-ci";import{execa as ot}from"execa";import st from"which";import{calculateRunDynamicMemory as ct}from"@apify/actor-memory-expression";import{Separator as lt,createPrompt as ut,isEnterKey as dt,makeTheme as ft,useKeypress as pt,usePrefix as mt,useState as ht}from"@inquirer/core";import{pipeline as gt}from"node:stream/promises";import{MemoryStorage as _t}from"@crawlee/memory-storage";import{compile as vt}from"json-schema-to-typescript";import{cloneDeep as yt}from"es-toolkit";import{validateInputSchema as bt,validateInputUsingValidator as xt}from"@apify/input_schema";import{getDatasetSchemaValidator as St,getKeyValueStoreSchemaValidator as Ct,getOutputSchemaValidator as wt}from"@apify/json_schemas";import Tt from"cli-table3";import{downloadTemplate as Et}from"giget";import Dt from"jju";import Ot from"open";import{fetchManifest as kt,manifestUrl as At,wrapperManifestUrl as jt}from"@apify/actor-templates";import Mt from"computer-name";import Nt from"cors";import Pt from"express";import Ft from"@inquirer/password";import It from"@inquirer/select";import Lt from"node:assert";import{ReadStream as Rt}from"node:tty";import zt from"detect-indent";import{fileURLToPath as Bt}from"node:url";import Vt from"@root/walk";import Ht from"handlebars";function internalLog(e){e.stdoutOutput&&console.log(...e.stdoutOutput),e.stderrOutput&&console.error(...e.stderrOutput)}function simpleLog(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[e.message]})}function error(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.red(`Error:`),e.message]})}function warning(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.yellow.bold(`Warning:`),e.message]})}function success(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.green(`Success:`),e.message]})}function run(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.gray(`Run:`),e.message]})}function info(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.white(`Info:`),e.message]})}function detectInstallMethod(){if(process.env.APIFY_CLI_BUNDLE)return`bundle`;let e=process.argv[1];if(!e)return warning({message:`Failed to detect install method of CLI, assuming npm`}),`npm`;let t=ee(e);return process.env.VOLTA_HOME&&t.includes(process.env.VOLTA_HOME)?`volta`:t.includes(`homebrew/Cellar`)||t.includes(`linuxbrew/Cellar`)?`homebrew`:process.env.PNPM_HOME&&t.includes(process.env.PNPM_HOME)?`pnpm`:process.env.BUN_INSTALL&&t.includes(process.env.BUN_INSTALL)?`bun`:`npm`}function getRuntimeInfo(){return process.versions.bun?{runtime:`bun`,version:process.versions.bun,nodeVersion:process.versions.node}:process.versions.deno?{runtime:`deno`,version:process.versions.deno,nodeVersion:process.versions.node}:{runtime:`node`,version:process.versions.node}}let Ut=null;function useCLIMetadata(){if(Ut)return Ut;let e=detectInstallMethod(),t=getRuntimeInfo();return Ut={version:`1.7.2-beta.
|
|
1
|
+
import e from"node:process";import t from"chalk";import n from"indent-string";import r from"widest-line";import i from"wrap-ansi";import{inspect as a,parseArgs as s,promisify as c}from"node:util";import{gt as l,gte as u,minVersion as f,satisfies as p}from"semver";import{appendFileSync as m,constants as h,copyFileSync as g,createWriteStream as _,existsSync as v,fstat as y,mkdirSync as b,openSync as x,readFileSync as S,readdirSync as C,realpathSync as ee,renameSync as te,rmSync as w,statSync as T,unlinkSync as ne,writeFileSync as E}from"node:fs";import D,{basename as re,dirname as O,isAbsolute as ie,join as k,relative as ae,resolve as oe,sep as A}from"node:path";import se from"string-width";import ce from"strip-ansi";import{once as le}from"node:events";import{homedir as ue,platform as de}from"node:os";import fe from"ci-info";import{ACTOR_ENV_VARS as j,ACTOR_JOB_STATUSES as M,ACTOR_JOB_TERMINAL_STATUSES as pe,ACTOR_NAME as me,ACTOR_SOURCE_TYPES as he,APIFY_ENV_VARS as N,KEY_VALUE_STORE_KEYS as ge,LOCAL_ACTOR_ENV_VARS as _e,LOCAL_STORAGE_SUBDIRS as ve,MAX_MULTIFILE_BYTES as ye,META_ORIGINS as be,SOURCE_FILE_FORMATS as xe}from"@apify/consts";import{jaroWinkler as Se}from"@skyra/jaro-winkler";import Ce from"js-levenshtein";import{createHmacSignature as we,cryptoRandomObjectId as Te}from"@apify/utilities";import{execSync as Ee,spawn as De}from"node:child_process";import{access as Oe,appendFile as ke,lstat as Ae,mkdir as P,readFile as F,readdir as I,rename as je,rm as Me,stat as L,symlink as Ne,unlink as Pe,writeFile as R}from"node:fs/promises";import{DurationFormatter as Fe,Time as Ie,TimeTypes as z}from"@sapphire/duration";import{Timestamp as Le}from"@sapphire/timestamp";import Re from"adm-zip";import ze from"ajv/dist/2019.js";import{ApifyClient as Be,DownloadItemsFormat as B}from"apify-client";import{ZipArchive as Ve}from"archiver";import He,{AxiosHeaders as Ue}from"axios";import We from"escape-string-regexp";import Ge from"ignore";import{getEncoding as Ke}from"istextorbinary";import qe,{Mime as Je}from"mime";import Ye from"mime/types/other.js";import Xe from"mime/types/standard.js";import{glob as Ze}from"tinyglobby";import{rimraf as Qe}from"rimraf";import{Result as $e,err as et,none as V,ok as tt,some as nt}from"@sapphire/result";import rt from"configparser";import it from"@inquirer/input";import at from"is-ci";import{execa as ot}from"execa";import st from"which";import{calculateRunDynamicMemory as ct}from"@apify/actor-memory-expression";import{Separator as lt,createPrompt as ut,isEnterKey as dt,makeTheme as ft,useKeypress as pt,usePrefix as mt,useState as ht}from"@inquirer/core";import{pipeline as gt}from"node:stream/promises";import{MemoryStorage as _t}from"@crawlee/memory-storage";import{compile as vt}from"json-schema-to-typescript";import{cloneDeep as yt}from"es-toolkit";import{validateInputSchema as bt,validateInputUsingValidator as xt}from"@apify/input_schema";import{getDatasetSchemaValidator as St,getKeyValueStoreSchemaValidator as Ct,getOutputSchemaValidator as wt}from"@apify/json_schemas";import Tt from"cli-table3";import{downloadTemplate as Et}from"giget";import Dt from"jju";import Ot from"open";import{fetchManifest as kt,manifestUrl as At,wrapperManifestUrl as jt}from"@apify/actor-templates";import Mt from"computer-name";import Nt from"cors";import Pt from"express";import Ft from"@inquirer/password";import It from"@inquirer/select";import Lt from"node:assert";import{ReadStream as Rt}from"node:tty";import zt from"detect-indent";import{fileURLToPath as Bt}from"node:url";import Vt from"@root/walk";import Ht from"handlebars";function internalLog(e){e.stdoutOutput&&console.log(...e.stdoutOutput),e.stderrOutput&&console.error(...e.stderrOutput)}function simpleLog(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[e.message]})}function error(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.red(`Error:`),e.message]})}function warning(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.yellow.bold(`Warning:`),e.message]})}function success(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.green(`Success:`),e.message]})}function run(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.gray(`Run:`),e.message]})}function info(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.white(`Info:`),e.message]})}function detectInstallMethod(){if(process.env.APIFY_CLI_BUNDLE)return`bundle`;let e=process.argv[1];if(!e)return warning({message:`Failed to detect install method of CLI, assuming npm`}),`npm`;let t=ee(e);return process.env.VOLTA_HOME&&t.includes(process.env.VOLTA_HOME)?`volta`:t.includes(`homebrew/Cellar`)||t.includes(`linuxbrew/Cellar`)?`homebrew`:process.env.PNPM_HOME&&t.includes(process.env.PNPM_HOME)?`pnpm`:process.env.BUN_INSTALL&&t.includes(process.env.BUN_INSTALL)?`bun`:`npm`}function getRuntimeInfo(){return process.versions.bun?{runtime:`bun`,version:process.versions.bun,nodeVersion:process.versions.node}:process.versions.deno?{runtime:`deno`,version:process.versions.deno,nodeVersion:process.versions.node}:{runtime:`node`,version:process.versions.node}}let Ut=null;function useCLIMetadata(){if(Ut)return Ut;let e=detectInstallMethod(),t=getRuntimeInfo();return Ut={version:`1.7.2-beta.8`,hash:`d38c8f430d07f5c9b29f98d114faca17d3e2830e`,arch:process.env.APIFY_BUNDLE_ARCH??process.arch,platform:process.platform===`win32`?`windows`:process.platform,runtime:t,extraRuntimeData:t.nodeVersion?`(emulating node ${t.nodeVersion})`:``,installMethod:e,get fullVersionString(){return`apify-cli/${this.version} (${this.hash.slice(0,7)}) running on ${this.platform}-${this.arch} with ${this.runtime.runtime}-${t.version}${this.extraRuntimeData?` ${this.extraRuntimeData}`:``}, installed via ${this.installMethod}`},get isBeta(){return this.version.includes(`beta`)||this.version===`0.0.0`}},e===`bundle`&&(Ut.installPath=O(process.execPath)),Ut}let Wt;function getMaxLineWidth(){if(Wt)return Wt;let e=Number(process.env.APIFY_CLI_MAX_LINE_WIDTH);if(!Number.isNaN(e))Wt=e;else if(!process.stdout.isTTY)Wt=80;else{let e=process.stdout.getWindowSize?.()[0]??-1;Wt=e<1?80:e<40?40:e}return Wt}var BaseCommandRenderer=class{command;entrypoint;constructor(e,t){this.entrypoint=e,this.command=t}pushShortDescription(e){let n=this.command.interactive?`${t.yellow(`[INTERACTIVE]`)} `:``;this.command.shortDescription?e.push(`${n}${this.command.shortDescription}`,``):this.command.description&&e.push(`${n}${this.command.description.split(`
|
|
2
2
|
`)[0]}`,``)}pushDescription(e){if(!this.command.description)return;e.push(t.bold(`DESCRIPTION`));let r=n(i(this.command.description,getMaxLineWidth()-2,{trim:!1}),2);e.push(r),e.push(``)}pushExamples(e){let{examples:r}=this.command;if(r?.length){e.push(t.bold(`EXAMPLES`));for(let a of r){if(a.description){let r=n(i(a.description,getMaxLineWidth()-4,{trim:!1}).split(`
|
|
3
3
|
`).map(e=>`# ${e}`).join(`
|
|
4
4
|
`),2);e.push(t.dim(r))}e.push(` $ ${this.normalizeExampleCommand(a.command)}`),e.push(``)}}}normalizeExampleCommand(e){let t=this.entrypoint.split(` `);if(t.length<2)return e;let n=t[t.length-1],r=`${t.slice(0,-1).join(` `)} `,i=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),a=e;return a.startsWith(`${n} `)&&(a=`${r}${a}`),a=a.replace(RegExp(`\\|\\s+${i}\\s`,`g`),`| ${r}${n} `),a}pushInteractiveNote(e){if(!this.command.interactive)return;e.push(t.bold(`NOTE`));let r=n(i(this.command.interactiveNote||`This command prompts the user for input. To run non-interactively (e.g. in CI or from an AI agent), pass all required arguments and flags explicitly.`,getMaxLineWidth()-2,{trim:!1}),2);e.push(r),e.push(``)}pushLearnMore(e){this.command.docsUrl&&(e.push(t.bold(`LEARN MORE`)),e.push(` ${this.command.docsUrl}`),e.push(``))}pushNewLineBeforeNewEntryIfLengthIsPastTheLimit({state:e,itemToAdd:t,indentSize:n}){se(e.join(` `).split(`
|
|
@@ -17,13 +17,13 @@ import e from"node:process";import t from"chalk";import n from"indent-string";im
|
|
|
17
17
|
`))||1,renderEntry=([e])=>{let t=e.shortDescription||e.description?.split(`
|
|
18
18
|
`)[0]||``;return` ${n(i(`${e.name.padEnd(p)} ${t}`,getMaxLineWidth()-p-4),p+2+2).trim()}`};for(let e of u){let n=l.get(e);n.length&&(s.push(t.bold(e.toUpperCase())),s.push(...n.map(renderEntry),``))}let m=e===`actor`?Yt:Jt;if(m.length){s.push(t.bold(`EXAMPLES`));for(let e=0;e<m.length;e++){let r=m[e];if(r.description){e>0&&s.push(``);let a=i(r.description,getMaxLineWidth()-4,{trim:!1}).split(`
|
|
19
19
|
`).map(e=>`# ${e}`).join(`
|
|
20
|
-
`);s.push(t.dim(n(a,2)))}s.push(` $ ${r.command}`),r.description&&e<m.length-1&&s.push(``)}s.push(``)}return s.push(t.bold(`LEARN MORE`),` Use '${e} <command> --help' for more information about a command.`,` Read the docs at https://docs.apify.com/cli.`,``),s.push(t.bold(`TROUBLESHOOTING`),` For general support, reach out to us at https://apify.com/contact.`,` If you believe you are encountering a bug, file it at https://github.com/apify/apify-cli/issues/new.`),s.join(`
|
|
20
|
+
`);s.push(t.dim(n(a,2)))}s.push(` $ ${r.command}`),r.description&&e<m.length-1&&s.push(``)}s.push(``)}return s.push(t.bold(`LEARN MORE`),` Use '${e} <command> --help' for more information about a command.`,` Read the docs at https://docs.apify.com/cli.`,` Run '${e} help --skill' to print the Apify CLI agent skill (guidance for driving 'apify' from agents).`,``),s.push(t.bold(`TROUBLESHOOTING`),` For general support, reach out to us at https://apify.com/contact.`,` If you believe you are encountering a bug, file it at https://github.com/apify/apify-cli/issues/new.`),s.join(`
|
|
21
21
|
`).trim()}let Xt=function(e){return e[e.NODEJS_ERR_PARSE_ARGS_INVALID_OPTION_VALUE=0]=`NODEJS_ERR_PARSE_ARGS_INVALID_OPTION_VALUE`,e[e.NODEJS_ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL=1]=`NODEJS_ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL`,e[e.NODEJS_ERR_PARSE_ARGS_UNKNOWN_OPTION=2]=`NODEJS_ERR_PARSE_ARGS_UNKNOWN_OPTION`,e[e.APIFY_FLAG_PROVIDED_MULTIPLE_TIMES=3]=`APIFY_FLAG_PROVIDED_MULTIPLE_TIMES`,e[e.APIFY_INVALID_FLAG_INTEGER_VALUE=4]=`APIFY_INVALID_FLAG_INTEGER_VALUE`,e[e.APIFY_INVALID_CHOICE=5]=`APIFY_INVALID_CHOICE`,e[e.APIFY_MISSING_FLAG=6]=`APIFY_MISSING_FLAG`,e[e.APIFY_FLAG_IS_EXCLUSIVE_WITH_ANOTHER_FLAG=7]=`APIFY_FLAG_IS_EXCLUSIVE_WITH_ANOTHER_FLAG`,e[e.APIFY_TOO_MANY_REQUESTERS_OF_STDIN=8]=`APIFY_TOO_MANY_REQUESTERS_OF_STDIN`,e[e.APIFY_UNKNOWN_ERROR=9]=`APIFY_UNKNOWN_ERROR`,e}({});var H=class CommandError extends Error{code;command;metadata;constructor({code:e,message:t=``,metadata:n={},command:r}){super(t||String(Xt[e])),this.code=e,this.metadata=n,this.command=r}extractFlagNameFromMessage(){switch(this.code){case 0:{let e=/'(?:-[a-z], )?-?-(?<flagName>[a-zA-Z-]+)(?: <value>)?' (?<noArg>does not take)?(?<missingArg>argument missing)?(?<ambiguous>argument is ambiguous\.(?<ambiguousMessage>\s*.*\s*.*)?)?/gi.exec(this.message);if(!e)throw Error(`Encountered unparsable error message from argument parser: ${this.message}.\n\nPlease report this issue at https://github.com/apify/apify-cli/issues`);return{name:e.groups.flagName,expectsValue:e.groups.noArg===void 0,ambiguousFlag:e.groups.ambiguous?e.groups.ambiguous:void 0,ambiguousMessage:e.groups.ambiguousMessage?e.groups.ambiguousMessage.trim():void 0}}case 2:{let e=/Unknown option '-(?<longForm>-)?(?<optionName>.+)'\.(?<nodeSuggestion>.*)/gi.exec(this.message);if(!e)throw Error(`Encountered unparsable error message from argument parser: ${this.message}.\n\nPlease report this issue at https://github.com/apify/apify-cli/issues`);return{name:e.groups.optionName,expectsValue:!1,unknownOptionSuggestion:e.groups.nodeSuggestion,shortForm:!e.groups.longForm}}default:throw Error(`Not implemented`)}}getPrettyMessage(){switch(this.code){case 0:{let e=this.extractFlagNameFromMessage();return CommandError.buildMessageFromFlagData(e)}case 2:{let e=this.extractFlagNameFromMessage(),n=selectiveRenderHelpForCommand(this.command,{showUsageString:!0});return[t.gray(`Unknown flag provided: ${t.white.bold(e.shortForm?`-${e.name}`:`--${e.name}`)}`),e.unknownOptionSuggestion?t.gray(` ${e.unknownOptionSuggestion.trim()}`):null,``,n].filter(e=>e!==null).join(`
|
|
22
22
|
`)}case 3:{let e=`--${this.metadata.flag}`;return t.gray(`Flag ${t.white.bold(e)} can only be specified once.`)}case 4:{let e=`--${this.metadata.flag}`,n=t.whiteBright(String(this.metadata.value));return t.gray(`The provided value for the '${t.white.bold(e)}' flag could not be processed as an integer. Received: ${n}.`)}case 6:{let{flag:e,matcher:n,providedButReceivedNoValue:r}=this.metadata,i=`'${t.white.bold(`--${e}`)}'`;return n&&(i=`${i} (alias used: '${t.white.bold(`--${n}`)}')`),r?t.gray(`Flag ${i} was provided, but no value was received. Did you mean to pass the value as an argument or through standard input?`):t.gray(`Flag ${i} is required, but was not provided.`)}case 7:{let{flagPairs:e}=this.metadata,n=[t.gray(`The following errors occurred:`)],r=t.red(` > `);for(let[i,a]of e)n.push(t.gray(`${r}${t.white.bold(i)} cannot also be provided when using ${t.white.bold(a)}`));return n.push(t.gray(`${r}See more help with ${t.white.bold(`--help`)}`)),n.join(`
|
|
23
23
|
`)}case 8:{let{firstUse:e,secondUse:n}=this.metadata;return t.gray(`Flag ${t.white.bold(`--${e}`)} and ${t.white.bold(`--${n}`)} cannot both request that their value comes from standard input at the same time.`)}default:{let e=useCLIMetadata();return[`The CLI encountered an unhandled argument parsing error!`,`Please report this issue at https://github.com/apify/apify-cli/issues, and provide the following information:`,``,`- Error code: ${this.code} (${Xt[this.code]})`,`- Error metadata: ${JSON.stringify(this.metadata)}`,``,`- Stack:\n${this.stack}`,``,`- Arguments (!!!only provide these as is if there is no sensitive information!!!):`,` ${JSON.stringify(process.argv.slice(2))}`,``,`- CLI version: \`${e.fullVersionString}\``,`- CLI debug logs (process.env.APIFY_CLI_DEBUG): ${process.env.APIFY_CLI_DEBUG?`Enabled`:`Disabled`}`,`- Stdin data? ${fn?`Yes`:`No`}`].join(`
|
|
24
24
|
`)}}}static buildMessageFromFlagData(e){let n=[`Flag ${t.white.bold(e.shortForm?`-${e.name}`:`--${e.name}`)}`];return e.ambiguousFlag?(n.push(`is ambiguous (meaning the provided value could be interpreted as a flag too).`),e.ambiguousMessage?n.push(`\n${e.ambiguousMessage.split(`
|
|
25
25
|
`).map(e=>` ${e}`).join(`
|
|
26
|
-
`)}`):n.push(`To solve this, provide the flag like this: --${e.name}=<value>`)):e.expectsValue?n.push(`expects a value`):n.push(`does not take an argument`),n.map(e=>t.gray(e)).join(` `)}static into(e,t){if(e instanceof CommandError)return e;if(e instanceof Error&&`code`in e){let n=e;switch(n.code){case`ERR_PARSE_ARGS_INVALID_OPTION_VALUE`:return new CommandError({code:0,message:n.message,command:t});case`ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL`:return new CommandError({code:1,message:n.message,command:t});case`ERR_PARSE_ARGS_UNKNOWN_OPTION`:return new CommandError({code:2,message:n.message,command:t});default:return new CommandError({code:9,message:`Unknown error: ${e instanceof Error?e.message:String(e)}`,command:t})}}return new CommandError({code:9,message:`Unknown error: ${e instanceof Error?e.message:String(e)}`,command:t})}};function cliDebugPrint(e,...n){process.env.APIFY_CLI_DEBUG&&console.error(t.gray(`[${e}]`),...n)}const Zt=c(y);let Qt;async function useStdin(){if(Qt)return Qt;let t=e.stdin,n={isTTY:t.isTTY,hasData:!1,waitDelay:0,stream:t},r=await Zt(0).then(t=>{if(cliDebugPrint(`useStdin`,{stat:t,isRegularFile:t.isFile(),isDirectory:t.isDirectory(),isBlockDevice:t.isBlockDevice(),isCharDevice:t.isCharacterDevice(),isSymbolicLink:t.isSymbolicLink(),isFIFO:t.isFIFO(),isSocket:t.isSocket()}),e.platform===`win32`){if((t.mode&h.S_IFIFO)===h.S_IFIFO)return 100;if(t.isFile())return 50}return t.isFIFO()||t.isFile()||(t.isSocket()?50:!1)}).catch(()=>!1);return cliDebugPrint(`useStdin`,{hasData:n.hasData,waitDelay:n.waitDelay,isTTY:n.isTTY,pipedIn:r,readableEnded:t.readableEnded}),(!t.isTTY||r!==!1&&(t.isTTY!==void 0||!t.readableEnded))&&(n.hasData=!0),typeof r==`number`&&(n.waitDelay=r),Qt=n,n}async function readStdin(){let e=await useStdin(),{hasData:t,waitDelay:n,stream:r}=e;if(!t)return;let i=[],a=new AbortController,s=null;n&&(s=setTimeout(()=>{a.abort()},n).unref())
|
|
26
|
+
`)}`):n.push(`To solve this, provide the flag like this: --${e.name}=<value>`)):e.expectsValue?n.push(`expects a value`):n.push(`does not take an argument`),n.map(e=>t.gray(e)).join(` `)}static into(e,t){if(e instanceof CommandError)return e;if(e instanceof Error&&`code`in e){let n=e;switch(n.code){case`ERR_PARSE_ARGS_INVALID_OPTION_VALUE`:return new CommandError({code:0,message:n.message,command:t});case`ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL`:return new CommandError({code:1,message:n.message,command:t});case`ERR_PARSE_ARGS_UNKNOWN_OPTION`:return new CommandError({code:2,message:n.message,command:t});default:return new CommandError({code:9,message:`Unknown error: ${e instanceof Error?e.message:String(e)}`,command:t})}}return new CommandError({code:9,message:`Unknown error: ${e instanceof Error?e.message:String(e)}`,command:t})}};function cliDebugPrint(e,...n){process.env.APIFY_CLI_DEBUG&&console.error(t.gray(`[${e}]`),...n)}const Zt=c(y);let Qt;async function useStdin(){if(Qt)return Qt;let t=e.stdin,n={isTTY:t.isTTY,hasData:!1,waitDelay:0,stream:t},r=await Zt(0).then(t=>{if(cliDebugPrint(`useStdin`,{stat:t,isRegularFile:t.isFile(),isDirectory:t.isDirectory(),isBlockDevice:t.isBlockDevice(),isCharDevice:t.isCharacterDevice(),isSymbolicLink:t.isSymbolicLink(),isFIFO:t.isFIFO(),isSocket:t.isSocket()}),e.platform===`win32`){if((t.mode&h.S_IFIFO)===h.S_IFIFO)return 100;if(t.isFile())return 50}return t.isFIFO()||t.isFile()||(t.isSocket()?50:!1)}).catch(()=>!1);return cliDebugPrint(`useStdin`,{hasData:n.hasData,waitDelay:n.waitDelay,isTTY:n.isTTY,pipedIn:r,readableEnded:t.readableEnded}),(!t.isTTY||r!==!1&&(t.isTTY!==void 0||!t.readableEnded))&&(n.hasData=!0),typeof r==`number`&&(n.waitDelay=r),Qt=n,n}async function readStdin(){let e=await useStdin(),{hasData:t,waitDelay:n,stream:r}=e;if(!t)return;let i=[],a=new AbortController,s=null;n&&(s=setTimeout(()=>{a.abort()},n).unref());let onData=e=>{i.push(e),s&&=(clearTimeout(s),null)};r.on(`data`,onData);try{await le(r,`end`,{signal:a.signal})}catch(e){if(e.name===`AbortError`)return}finally{r.off(`data`,onData),r.pause()}s&&clearTimeout(s),e.hasData=!1;let c=Buffer.concat(i);if(c.length)return c}var $t={node:`>=20`};const en=`storage`,tn={actorSpecification:1,name:null,version:`0.0`,buildTag:`latest`,environmentVariables:{}},nn=[`SIGINT`,`SIGTERM`,`SIGHUP`],GLOBAL_CONFIGS_FOLDER=()=>{let t=k(ue(),`.apify`);return e.env.__APIFY_INTERNAL_TEST_AUTH_PATH__?k(t,e.env.__APIFY_INTERNAL_TEST_AUTH_PATH__):t},AUTH_FILE_PATH=()=>k(GLOBAL_CONFIGS_FOLDER(),`auth.json`),SECRETS_FILE_PATH=()=>k(GLOBAL_CONFIGS_FOLDER(),`secrets.json`),STATE_FILE_PATH=()=>k(GLOBAL_CONFIGS_FOLDER(),`state.json`),TELEMETRY_FILE_PATH=()=>k(GLOBAL_CONFIGS_FOLDER(),`telemetry.json`),rn=`.actor`,U=k(rn,`actor.json`),an=$t.node,on=fe.GITHUB_ACTIONS?`${e.env.GITHUB_SERVER_URL}/${e.env.GITHUB_REPOSITORY}/actions/runs/${e.env.GITHUB_RUN_ID}`:void 0,sn={"X-Apify-Request-Origin":fe.isCI?be.CI:be.CLI,...on&&{"X-Apify-Github-Actions-Run-Url":on}},W=`3.11.0`;function migrateStateV0ToV1$1(e){if(e.version&&e.version>=1)return!1;let t=e;if(t.latestNpmVersionCheckedAt){let n=new Date(t.latestNpmVersionCheckedAt).getTime(),r=t.latestNpmVersion;cliDebugPrint(`LocalStateV0ToV1`,`Migrating state from v0 to v1`,{oldState:e,newState:{versionCheck:{lastChecked:n,lastVersion:r}}}),updateLocalState({version:1},e=>{e.versionCheck={lastChecked:n,lastVersion:r}})}return!0}const cn={version:1};function useLocalState(){let e=STATE_FILE_PATH();if(!v(e))return cn;let t=JSON.parse(S(e,`utf-8`));return migrateStateV0ToV1$1(t)?useLocalState():t}function updateLocalState(e,t){let n={...e};t(n),b(O(STATE_FILE_PATH()),{recursive:!0}),E(STATE_FILE_PATH(),JSON.stringify(n,null,` `))}const ln=useCLIMetadata(),un=`Apify CLI/${ln.version} (https://github.com/apify/apify-cli)`,dn=[`https://1.1.1.1`,`https://8.8.8.8`];async function isOnline(e=500){let t=new AbortController,n=setTimeout(()=>{t.abort()},e),r=await Promise.any(dn.map(async e=>fetch(e,{signal:t.signal,headers:{"User-Agent":un},keepalive:!1}))).catch(()=>null);return clearTimeout(n),r?r.ok?(cliDebugPrint(`isOnline`,{state:`online`,site:r.url}),!0):(cliDebugPrint(`isOnline`,{state:`offline`}),!1):(cliDebugPrint(`isOnline`,{state:`timeout`}),!1)}async function getLatestVersion(e){let t=await fetch(`https://api.github.com/repos/apify/apify-cli/releases/latest`,{headers:{"User-Agent":un}});if(!t.ok)return cliDebugPrint(`useCLIVersionCheck`,`Failed to fetch latest version`,{statusCode:t.status,body:await t.text()}),warning({message:`Failed to fetch latest version of Apify CLI, using the cached version instead.`}),null;let n=(await t.json()).tag_name.replace(/^v/,``);return cliDebugPrint(`useCLIVersionCheck`,`Fetched latest version`,{version:n}),updateLocalState(e,e=>{e.versionCheck={lastChecked:Date.now(),lastVersion:n}}),n}function shouldSkipVersionCheck(){return!!(process.env.APIFY_CLI_SKIP_UPDATE_CHECK&&![`0`,`false`].includes(process.env.APIFY_CLI_SKIP_UPDATE_CHECK))}async function useCLIVersionCheck(e=!1){let t=useLocalState(),n=!t.versionCheck||Date.now()-t.versionCheck.lastChecked>864e5,r=e||n&&await isOnline(),i=r?await getLatestVersion(t):t.versionCheck?.lastVersion;if(!i)return{currentVersion:ln.version,latestVersion:`unknown`,shouldUpdate:!1,cacheHit:!1};let a=l(i,ln.version);return{currentVersion:ln.version,latestVersion:i,shouldUpdate:a,cacheHit:!r}}function useCommandSuggestions(e){let t=[...J.entries()].sort(([e],[t])=>e.localeCompare(t)),n=e.toLowerCase();return t.map(([e,t])=>{let r=e.toLowerCase(),i=e.split(` `),a=i[i.length-1].toLowerCase(),s=t.aliases?.includes(a)||t.hiddenAliases?.includes(a)||!1,c=Ce(n,r),l=Se(n,r),u=c<=2||l>=.975;return u?(cliDebugPrint(`useCommandSuggestions`,{inputString:n,lowercased:r,matches:u,levenshtein:c,jaroWinkler:l}),s?{string:`${r} (alias for ${t.name})`,distance:l}:{string:`${r}`,distance:l}):null}).filter(e=>e!==null).sort((e,t)=>t.distance-e.distance).map(e=>e.string)}const fn=await readStdin(),pn=useCLIMetadata(),mn=`Apify CLI/${pn.version} (https://github.com/apify/apify-cli)`;function processVersionCheck(t){pn.installMethod!==`bundle`&&(p(e.version,an)||(error({message:`${t} CLI requires Node.js version ${an}. Your current version is ${e.version}.`}),e.exit(1)))}function printCLIVersionAndExitIfFlagUsed(t){t.values.version===!0&&t.positionals.length===0&&(console.log(pn.fullVersionString),e.exit(0))}function printHelpAndExitIfFlagUsedOrNoCommandPassed(t,n){(t.values.help===!0&&t.positionals.length===0||t.positionals.length===0)&&(console.log(renderMainHelpMenu(n)),e.exit(0))}function handleCommandNotFound(n){let r=useCommandSuggestions(String(n)),i=t.gray(`Command ${t.whiteBright(n)} not found`);r.length&&(i+=`
|
|
27
27
|
`,i+=t.gray(`Did you mean: ${r.map(e=>t.whiteBright(e)).join(`, `)}?`)),error({message:i}),e.exit(1)}async function runVersionCheck(e,t){let n=J.get(`upgrade`);if([n.name,...n.aliases??[]].some(e=>t===e)){cliDebugPrint(`[VersionCheckMiddleware]`,`upgrade command detected, skipping version check`);return}if(shouldSkipVersionCheck()){cliDebugPrint(`[VersionCheckMiddleware]`,`skipping version check because APIFY_CLI_SKIP_UPDATE_CHECK is set`);return}await internalRunCommand(e,n,{flags_internalAutomaticCall:!0})}async function runCLI(t){cliDebugPrint(`CLIMetadata`,{...pn,fullVersionString:pn.fullVersionString,argv:e.argv,cwd:e.cwd(),execPath:e.execPath});let n=e.argv.slice(2);cliDebugPrint(`ProcessArgv`,n);let r=s({allowPositionals:!0,strict:!1,options:{help:{type:`boolean`,short:`h`},version:{type:`boolean`,short:`v`}},args:n});printCLIVersionAndExitIfFlagUsed(r),printHelpAndExitIfFlagUsedOrNoCommandPassed(r,t),await runVersionCheck(t,r.positionals[0]),cliDebugPrint(`TopLevelOptions`,r);let i=r.positionals[0],a=-1;if(J.get(i)?.subcommands?.length){if(r.positionals[1]?.toLowerCase()===`help`)a=1;else if(r.positionals[2]?.toLowerCase()===`help`){let e=J.get(`${i} ${r.positionals[1]}`);e&&!e.args&&(a=2)}}if(a!==-1){let e=r.positionals[a],t=n.indexOf(e);t!==-1&&n.splice(t,1),!n.includes(`--help`)&&!n.includes(`-h`)&&n.push(`--help`),r.positionals.splice(a,1),r.values.help=!0}let c=r.positionals[1],l=!1,u=J.get(i);if(!u)return handleCommandNotFound(i);let f=u;if(u.subcommands?.length){if(!c)return u.printHelp();l=!0,f=J.get(`${i} ${c}`)}if(!f)return handleCommandNotFound(`${i} ${c}`);let p=[...n],m=p.indexOf(i);if(cliDebugPrint(`CommandNameIndex`,m),p.splice(m,1),l){let e=p.indexOf(c);cliDebugPrint(`SubcommandNameIndex`,e),p.splice(e,1)}cliDebugPrint(`RebuiltArgs`,p),cliDebugPrint(`CommandToRun`,f);let h=new f(t,l?`${u.name} ${c}`:u.name,i,l?c:void 0),g=h._buildParseArgsOption();cliDebugPrint(`ParserOptionsForCommand`,g);try{let e=s({...g,args:p});await h._run(e),cliDebugPrint(`CommandArgsResult`,e)}catch(t){error({message:H.into(t,f).getPrettyMessage()}),e.exit(1)}}const hn=[[`CLAUDECODE`,`claude_code`],[`CLAUDE_CODE_ENTRYPOINT`,`claude_code`],[`CURSOR_AGENT`,`cursor`],[`CLINE_ACTIVE`,`cline`],[`CODEX_SANDBOX`,`codex_cli`],[`CODEX_THREAD_ID`,`codex_cli`],[`GEMINI_CLI`,`gemini_cli`],[`OPENCODE`,`open_code`],[`OPENCLAW_SHELL`,`openclaw`]];function detectAiAgent(){for(let[e,t]of hn)if(process.env[e])return t}function detectCi(){return fe.isCI?{isCi:!0,ciProvider:fe.id?.toLowerCase()??`unknown`}:{isCi:!1,ciProvider:void 0}}function detectIsInteractive(){return!!process.stdin.isTTY&&!!process.stdout.isTTY}const updateLocalJson=async(e,t={},n=null)=>{let r=await F(e,`utf-8`),i=JSON.parse(r),a;n?(a=i,a[n]={...i[n],...t}):a={...i,...t},await R(e,JSON.stringify(a,null,` `))},ensureFolderExistsSync=(e,t)=>{t||(t=e,e=`.`),t.split(A).reduce((e,t)=>(e=k(e,t),v(e)||b(e),e),e)},rimrafPromised=async e=>{await Qe(e)},deleteFile=async e=>{(await L(e)).isFile()&&await Pe(e)};function ensureApifyDirectory(e){b(O(e),{recursive:!0})}const sumFilesSizeInBytes=async(e,t)=>(await Promise.all(e.map(async e=>L(k(t,e))))).map(e=>e.size).reduce((e,t)=>e+t,0),gn=`token`,_n=`proxy-password`;let vn,yn,bn;async function loadKeyringModule(){return vn===void 0&&(vn=await importKeyringModule()),vn}async function importKeyringModule(){if(useCLIMetadata().installMethod===`bundle`)try{let e=await import(`__APIFY_KEYRING_NATIVE_SUBPACKAGE__`),t=e.Entry??e.default?.Entry;return t?{Entry:t}:null}catch(e){return cliDebugPrint(`credentials`,`failed to load bundled keyring`,e),null}try{return await import(`@napi-rs/keyring`)}catch(e){return cliDebugPrint(`credentials`,`failed to load @napi-rs/keyring`,e),null}}async function getBackend(){return yn||(yn=(async()=>e.env.APIFY_DISABLE_KEYRING===`1`||readAuthFile().secretsBackend===`file`?`file`:await loadKeyringModule()?`keyring`:`file`)(),yn)}function downgradeBackendToFile(){yn=Promise.resolve(`file`)}function readAuthFile(){if(!v(AUTH_FILE_PATH()))return{};try{let e=S(AUTH_FILE_PATH(),`utf-8`);return JSON.parse(e)}catch{return{}}}function writeAuthFile(e){ensureApifyDirectory(AUTH_FILE_PATH()),E(AUTH_FILE_PATH(),JSON.stringify(e,null,` `),{mode:384})}async function getKeyringEntry(e){let t=await loadKeyringModule();return t?new t.Entry(`com.apify.cli`,e):null}async function readKeyring(e){try{let t=await getKeyringEntry(e);return t?t.getPassword()??void 0:void 0}catch(t){cliDebugPrint(`credentials`,`failed to read ${e} from keyring`,t);return}}async function writeKeyring(e,t){let n=await getKeyringEntry(e);if(!n)throw Error(`OS keyring is not available.`);n.setPassword(t)}async function deleteKeyring(e){try{let t=await getKeyringEntry(e);if(!t)return;t.deletePassword()}catch(t){cliDebugPrint(`credentials`,`failed to delete ${e} from keyring`,t)}}async function getToken(){return await getBackend()===`keyring`?readKeyring(gn):readAuthFile().token}async function getProxyPassword(){return await getBackend()===`keyring`?readKeyring(_n):readAuthFile().proxy?.password}async function setToken(e,t={}){let n=await getBackend();if(t.skipIfUnchanged&&(n===`keyring`?await readKeyring(gn):readAuthFile().token)===e)return;if(n===`keyring`)try{await writeKeyring(gn,e);return}catch(e){cliDebugPrint(`credentials`,`keyring write failed; falling back to file`,e),downgradeBackendToFile()}let r=readAuthFile();r.token=e,r.secretsBackend=`file`,writeAuthFile(r)}async function setProxyPassword(e,t={}){let n=await getBackend();if(t.skipIfUnchanged&&(n===`keyring`?await readKeyring(_n):readAuthFile().proxy?.password)===e)return;if(n===`keyring`)try{await writeKeyring(_n,e);return}catch(e){cliDebugPrint(`credentials`,`keyring write failed; falling back to file`,e),downgradeBackendToFile()}let r=readAuthFile();r.proxy={...r.proxy,password:e},r.secretsBackend=`file`,writeAuthFile(r)}async function clearKeyringSecrets(){await deleteKeyring(gn),await deleteKeyring(_n)}async function ensureMigrated(){return bn||(bn=(async()=>{try{let e=readAuthFile();if(e.secretsBackend||!e.token&&!e.proxy?.password)return;if(await getBackend()===`file`){e.secretsBackend=`file`,writeAuthFile(e);return}try{e.token&&await writeKeyring(gn,e.token),e.proxy?.password&&await writeKeyring(_n,e.proxy.password)}catch(t){cliDebugPrint(`credentials`,`keyring write failed during migration; falling back to file`,t),downgradeBackendToFile(),e.secretsBackend=`file`,writeAuthFile(e);return}delete e.token,e.proxy&&(delete e.proxy.password,Object.keys(e.proxy).length===0&&delete e.proxy),e.secretsBackend=`keyring`,writeAuthFile(e)}catch(e){cliDebugPrint(`credentials`,`migration failed`,e)}})(),bn)}const xn=`__CLI_`;function resolveInputKey(){return process.env[j.INPUT_KEY]||process.env[N.INPUT_KEY]||process.env.CRAWLEE_INPUT_KEY||`INPUT`}function inputFileRegExp(e){return RegExp(`(^${We(e)}(?:\\.[^.]+)?$)`)}const Sn=Ge,Cn=ze,getLocalStorageDir=()=>{let t=N.LOCAL_STORAGE_DIR;return e.env[t]||e.env.CRAWLEE_STORAGE_DIR||`storage`},getLocalKeyValueStorePath=t=>{let n=j.DEFAULT_KEY_VALUE_STORE_ID,r=t||e.env[n]||_e[n];return k(getLocalStorageDir(),ve.keyValueStores,r)},getLocalDatasetPath=t=>{let n=j.DEFAULT_DATASET_ID,r=t||e.env[n]||_e[n];return k(getLocalStorageDir(),ve.datasets,r)},getLocalRequestQueuePath=t=>{let n=j.DEFAULT_REQUEST_QUEUE_ID,r=t||e.env[n]||_e[n];return k(getLocalStorageDir(),ve.requestQueues,r)},getLocalUserInfo=async()=>{await ensureMigrated();let e={};try{let t=await F(AUTH_FILE_PATH(),`utf-8`);e=JSON.parse(t)}catch{}if(await getBackend()===`keyring`){let t=await getToken();t&&(e.token=t);let n=await getProxyPassword();n&&(e.proxy={...e.proxy,password:n})}let t=!!(e.username||e.id);if(!(t||e.token))return{};if(!t)throw Error(`Stale credentials found without user metadata. Please run "apify login" again.`);return e};async function getLoggedClientOrThrow(){let t=await getLoggedClient();if(!t)throw e.exitCode=1,Error(`You are not logged in with your Apify account. Call "apify login" to fix that.`);return t}const resolveToken=async e=>e||(await ensureMigrated(),getToken()),getApifyClientOptions=async(t,n)=>({token:await resolveToken(t),baseUrl:n||e.env.APIFY_CLIENT_BASE_URL,requestInterceptors:[e=>{e.headers??=new Ue;for(let[t,n]of Object.entries(sn))e.headers[t]=n;return e}]});async function getLoggedClient(e,t){let n=new Be(await getApifyClientOptions(await resolveToken(e),t)),r;try{r=await n.user(`me`).get()}catch(e){return cliDebugPrint(`[getLoggedClient] error getting user info`,{error:e,apiBaseUrl:t}),null}n.token&&await setToken(n.token,{skipIfUnchanged:!0});let i=r.proxy?.password;i&&await setProxyPassword(i,{skipIfUnchanged:!0}),ensureApifyDirectory(AUTH_FILE_PATH());let a=(()=>{try{return JSON.parse(S(AUTH_FILE_PATH(),`utf-8`))}catch{return{}}})(),s=await getBackend(),c={...a,...r,secretsBackend:s};if(s===`keyring`&&(delete c.token,c.proxy&&typeof c.proxy==`object`)){let{password:e,...t}=c.proxy;Object.keys(t).length>0?c.proxy=t:delete c.proxy}return E(AUTH_FILE_PATH(),JSON.stringify(c,null,` `),{mode:384}),n}const getLocalConfigPath=e=>k(e,U),getJsonFileContent=e=>{if(v(e))return JSON.parse(S(e,{encoding:`utf-8`}))},getLocalConfig=e=>getJsonFileContent(getLocalConfigPath(e)),setLocalConfig=async(t,n)=>{let r=k(n||e.cwd(),U);await P(O(r),{recursive:!0}),E(r,JSON.stringify(t,null,` `))},wn=[getLocalStorageDir(),`node_modules`,`.venv`],setLocalEnv=async e=>{let t=getLocalKeyValueStorePath();ensureFolderExistsSync(e,getLocalDatasetPath()),ensureFolderExistsSync(e,getLocalRequestQueuePath()),ensureFolderExistsSync(e,t);let n=k(e,`.gitignore`),r=``;v(n)&&(r=S(n,{encoding:`utf-8`}));let i=[];for(let e of wn)RegExp(`^${We(e)}$`,`mg`).test(r)||i.push(e);i.length>0&&(r.length>0?(i.unshift(`# Added by Apify CLI`),E(n,`\n${i.join(`
|
|
28
28
|
`)}\n`,{flag:`a`})):E(n,`${i.join(`
|
|
29
29
|
`)}\n`,{flag:`w`}))},Tn=new Je(Xe,Ye).define({"application/gzip":[`tgz`],"text/typescript":[`ts`,`tsx`,`mts`]},!0),getSourceFileFormat=(e,t)=>{let n=Tn.getType(e);return n?n.startsWith(`text/`)||n.includes(`javascript`)||n.includes(`json`)||n.includes(`xml`)||n.includes(`application/node`)||n.includes(`application/toml`)||n.includes(`application/x-sh`)||n.includes(`application/x-httpd-php`)?xe.TEXT:xe.BASE64:Ke(t)===`binary`?xe.BASE64:xe.TEXT},createSourceFiles=async(e,t)=>e.map(e=>{let n=S(k(t,e)),r=getSourceFileFormat(e,n);return{name:e,format:r,content:r===xe.TEXT?n.toString(`utf8`):n.toString(`base64`)}}),getGitignoreFallbackFilter=async e=>{let t=await Ze(`**/.gitignore`,{dot:!0,cwd:e,ignore:[`.git/**`],expandDirectories:!1}),n=[];for(let r of t){let t=O(r),i=await F(k(e,r),`utf-8`);n.push({dir:t===`.`?``:t,ig:Sn().add(i)})}let r=O(e);for(;r!==O(r)&&!v(k(r,`.git`));){let t=k(r,`.gitignore`);if(v(t))try{let i=await F(t,`utf-8`),a=ae(r,e);n.push({dir:``,ig:Sn().add(i),ancestorPrefix:a})}catch{}r=O(r)}return n.length===0?e=>e:e=>e.filter(e=>{for(let{dir:t,ig:r,ancestorPrefix:i}of n){let n;if(n=t?e.startsWith(`${t}/`)?e.slice(t.length+1):null:i?`${i}/${e}`:e,n!==null&&r.ignores(n))return!1}return!0})},parseActorIgnore=async e=>{let t=k(e,`.actorignore`);if(!v(t))return{excludeFilter:null,forceIncludePatterns:[]};let n=(await F(t,`utf-8`)).split(`
|
|
@@ -230,4 +230,4 @@ When no path is provided, validates all schemas found in '${U}':
|
|
|
230
230
|
- Dataset schema (from "storages.dataset")
|
|
231
231
|
- Output schema (from "output")
|
|
232
232
|
- Key-Value Store schema (from "storages.keyValueStore")`;static group=`Local Actor Development`;static examples=[{description:`Validate the input schema discovered from the default locations.`,command:`apify validate-schema`},{description:`Validate a specific INPUT_SCHEMA.json file.`,command:`apify validate-schema ./my-schema.json`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-validate-schema`;static args={path:Z.string({required:!1,description:`Optional path to your INPUT_SCHEMA.json file. If not provided, validates all schemas in '${U}'.`})};static hiddenAliases=[`vis`];async run(){if(this.args.path){await this.validateInputSchemaAtPath(this.args.path);return}await this.validateAllSchemas()}async validateInputSchemaAtPath(t){await readAndValidateInputSchema({forcePath:t,cwd:e.cwd(),getMessage:e=>`Validating input schema at ${e??t}`}),success({message:`Input schema is valid.`})}async validateAllSchemas(){let t=e.cwd(),n=!1,r=!1;try{let{inputSchema:e,inputSchemaPath:r}=await readInputSchema({cwd:t,throwOnMissing:!0});e&&(n=!0,info({message:`Validating input schema ${r?`at ${r}`:`embedded in '${U}'`}`}),bt(new Cn({strict:!1}),e),success({message:`Input schema is valid.`}))}catch(e){n=!0,r=!0,error({message:e.message})}let i=[{label:`Dataset`,read:()=>readStorageSchema({cwd:t,key:`dataset`,label:`Dataset`,throwOnMissing:!0}),validate:validateDatasetSchema},{label:`Output`,read:()=>readStorageSchema({cwd:t,key:`output`,label:`Output`,getRef:e=>e?.output,throwOnMissing:!0}),validate:validateOutputSchema},{label:`Key-Value Store`,read:()=>readStorageSchema({cwd:t,key:`keyValueStore`,label:`Key-Value Store`,throwOnMissing:!0}),validate:validateKvsSchema}];for(let{label:e,read:t,validate:a}of i)try{let r=t();r&&(n=!0,info({message:`Validating ${e} schema ${r.schemaPath?`at ${r.schemaPath}`:`embedded in '${U}'`}`}),a(r.schema),success({message:`${e} schema is valid.`}))}catch(e){n=!0,r=!0,error({message:e.message})}if(!n)throw Error(`No schemas found. Make sure '${U}' exists and defines at least one schema.`);r&&(e.exitCode=5)}};const Jr=[ActorIndexCommand,ActorsIndexCommand,AuthIndexCommand,BuildsIndexCommand,DatasetsIndexCommand,KeyValueStoresIndexCommand,MCPIndexCommand,RequestQueuesIndexCommand,RunsIndexCommand,SecretsIndexCommand,TasksIndexCommand,TelemetryIndexCommand,ApiCommand,TopLevelCallCommand,UpgradeCommand,InstallCommand,CreateCommand,EditInputSchemaCommand,InfoCommand,WrapScrapyCommand,InitCommand,LoginCommand,LogoutCommand,TopLevelPullCommand,ToplevelPushCommand,RunCommand,ValidateSchemaCommand,HelpCommand],Yr=[ActorSetValueCommand,ActorPushDataCommand,ActorGetValueCommand,ActorGetPublicUrlCommand,ActorGetInputCommand,ActorChargeCommand,ActorCalculateMemoryCommand,ActorGenerateSchemaTypesCommand,HelpCommand,UpgradeCommand,InstallCommand,TelemetryIndexCommand];export{runCLI as i,Jr as n,processVersionCheck as r,Yr as t};
|
|
233
|
-
//# sourceMappingURL=_register-
|
|
233
|
+
//# sourceMappingURL=_register-CUqij_sX.js.map
|