apify-cli 1.4.2-beta.9 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/actor.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{a as o,b as r,d as m}from"./chunk-XLY3B6IF.js";o("Actor");for(let a of m)a.registerCommand("actor");await r("actor");
2
+ import{a as o,b as r,d as m}from"./chunk-DAGVJNAI.js";o("Actor");for(let a of m)a.registerCommand("actor");await r("actor");
3
3
  //# sourceMappingURL=actor.js.map
package/dist/apify.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{a as o,b as r,c as i}from"./chunk-XLY3B6IF.js";o("Apify");for(let m of i)m.registerCommand("apify");await r("apify");
2
+ import{a as o,b as r,c as i}from"./chunk-DAGVJNAI.js";o("Apify");for(let m of i)m.registerCommand("apify");await r("apify");
3
3
  //# sourceMappingURL=apify.js.map
@@ -1,4 +1,4 @@
1
- var Hc=Object.defineProperty;var m=(r,e)=>Hc(r,"name",{value:e,configurable:!0});import xe from"process";import{parseArgs as ua}from"util";import lo from"chalk";import{satisfies as Zd}from"semver";import bt from"process";import gi from"chalk";import xd from"indent-string";import _d from"widest-line";import Pd from"wrap-ansi";import Ki from"ci-info";var Jc=[["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 Wi(){for(let[r,e]of Jc)if(process.env[r])return e}m(Wi,"detectAiAgent");function zi(){return Ki.isCI?{isCi:!0,ciProvider:Ki.id?.toLowerCase()??"unknown"}:{isCi:!1,ciProvider:void 0}}m(zi,"detectCi");function Xi(){return!!process.stdin.isTTY&&!!process.stdout.isTTY}m(Xi,"detectIsInteractive");import qc from"chalk";function T(r,...e){process.env.APIFY_CLI_DEBUG&&console.error(qc.gray(`[${r}]`),...e)}m(T,"cliDebugPrint");import{realpathSync as Kc}from"fs";import{dirname as Wc}from"path";import gt from"chalk";function tt(r){r.stdoutOutput&&console.log(...r.stdoutOutput),r.stderrOutput&&console.error(...r.stderrOutput)}m(tt,"internalLog");function $(r){tt({[r.stdout?"stdoutOutput":"stderrOutput"]:[r.message]})}m($,"simpleLog");function g(r){tt({[r.stdout?"stdoutOutput":"stderrOutput"]:[gt.red("Error:"),r.message]})}m(g,"error");function x(r){tt({[r.stdout?"stdoutOutput":"stderrOutput"]:[gt.yellow.bold("Warning:"),r.message]})}m(x,"warning");function R(r){tt({[r.stdout?"stdoutOutput":"stderrOutput"]:[gt.green("Success:"),r.message]})}m(R,"success");function Ce(r){tt({[r.stdout?"stdoutOutput":"stderrOutput"]:[gt.gray("Run:"),r.message]})}m(Ce,"run");function b(r){tt({[r.stdout?"stdoutOutput":"stderrOutput"]:[gt.white("Info:"),r.message]})}m(b,"info");function Js(r){tt({[r.stdout?"stdoutOutput":"stderrOutput"]:[gt.blue(r.message),r.url]})}m(Js,"link");var qs="0.0.0";var zc="1.4.2-beta.9",Xc="f7ed07ab108221c9f40a84149f1a8c43fe4a53f0";function Zc(){if(process.env.APIFY_CLI_MARKED_INSTALL_METHOD)return process.env.APIFY_CLI_MARKED_INSTALL_METHOD;if(process.env.APIFY_CLI_BUNDLE)return"bundle";let r=process.argv[1];if(!r)return x({message:"Failed to detect install method of CLI, assuming npm"}),"npm";let e=Kc(r);return process.env.VOLTA_HOME&&e.includes(process.env.VOLTA_HOME)?"volta":e.includes("homebrew/Cellar")||e.includes("linuxbrew/Cellar")?"homebrew":process.env.PNPM_HOME&&e.includes(process.env.PNPM_HOME)?"pnpm":process.env.BUN_INSTALL&&e.includes(process.env.BUN_INSTALL)?"bun":"npm"}m(Zc,"detectInstallMethod");function Qc(){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}}m(Qc,"getRuntimeInfo");var Gt=null;function z(){if(Gt)return Gt;let r=Zc(),e=Qc();return Gt={version:zc,hash:Xc,arch:process.env.APIFY_BUNDLE_ARCH??process.arch,platform:process.platform==="win32"?"windows":process.platform,runtime:e,extraRuntimeData:e.nodeVersion?`(emulating node ${e.nodeVersion})`:"",installMethod:r,get fullVersionString(){return`apify-cli/${this.version} (${this.hash.slice(0,7)}) running on ${this.platform}-${this.arch} with ${this.runtime.runtime}-${e.version}${this.extraRuntimeData?` ${this.extraRuntimeData}`:""}, installed via ${this.installMethod}`},get isBeta(){return this.version.includes("beta")||this.version===qs}},r==="bundle"&&(Gt.installPath=Wc(process.execPath)),Gt}m(z,"useCLIMetadata");import{existsSync as Ul,mkdirSync as Ml,readFileSync as jl,writeFileSync as Bl}from"fs";import{dirname as Vl}from"path";import{cryptoRandomObjectId as Gl}from"@apify/utilities";import{homedir as tl}from"os";import{join as rt}from"path";import{KEY_VALUE_STORE_KEYS as rl,META_ORIGINS as ol}from"@apify/consts";var Zi={name:"apify-cli",version:"1.4.2-beta.9",description:"Apify command-line interface (CLI) helps you manage the Apify cloud platform and develop, build, and deploy Apify Actors.",exports:"./dist/index.js",type:"module",scripts:{"dev:apify":"tsx ./src/entrypoints/apify.ts","dev:actor":"tsx ./src/entrypoints/actor.ts","test:all":"yarn test:local && yarn test:api","test:local":"vitest run --testNamePattern '^((?!\\[api]).)*$' --exclude ./test/api --exclude ./test/e2e","test:e2e":"vitest run --testNamePattern '\\[e2e\\]' --exclude ./test/api","test:e2e:local":"vitest run --testNamePattern '^(?=.*\\[e2e\\])(?!.*\\[api\\]).*$' --exclude ./test/api","test:api":"vitest run --testNamePattern '^(?=.*\\[api\\])(?!.*\\[e2e\\]).*$' --exclude ./test/e2e","test:python":"vitest run --testNamePattern '\\[python\\]'",lint:"eslint src test scripts --ext .ts,.cjs,.mjs","lint:fix":"eslint src test scripts --fix --ext .ts,.cjs,.mjs",format:'biome format . && prettier --check "**/*.{md,yml,yaml}"',"format:fix":'biome format --write . && prettier --write "**/*.{md,yml,yaml}"',clean:"rimraf dist",build:"yarn clean && tsc && tsup","build-bundles":"bun run scripts/build-cli-bundles.ts",prepack:"yarn insert-cli-metadata && yarn build && yarn update-docs","insert-cli-metadata":"tsx scripts/insert-cli-metadata.ts","update-docs":"tsx scripts/generate-cli-docs.ts",postinstall:`node -e "console.log('We have an active developer community on Discord. You can find it on https://discord.gg/crawlee-apify-801163717915574323.');"`,prepare:"husky"},files:["dist"],bin:{actor:"./dist/actor.js",apify:"./dist/apify.js","apify-cli":"./dist/apify.js"},contributors:["Jakub Drobn\xEDk <jakub.drobnik@apify.com>","Jan Curn <jan@apify.com>","Vlad Frangu <vlad.frangu@apify.com>"],repository:{type:"git",url:"git+https://github.com/apify/apify-cli.git"},keywords:["apify","client","node","command","line","bash"],author:{name:"Apify",email:"support@apify.com",url:"https://www.apify.com"},license:"Apache-2.0",bugs:{url:"https://github.com/apify/apify-cli/issues"},homepage:"https://github.com/apify/apify-cli#readme",engines:{node:">=20"},dependencies:{"@apify/actor-memory-expression":"^0.1.12","@apify/actor-templates":"^0.1.5","@apify/consts":"^2.36.0","@apify/input_schema":"^3.17.0","@apify/utilities":"^2.18.0","@crawlee/memory-storage":"^3.12.0","@inquirer/core":"^11.0.0","@inquirer/input":"^5.0.0","@inquirer/password":"^5.0.0","@inquirer/select":"^5.0.0","@root/walk":"~1.1.0","@sapphire/duration":"^1.1.2","@sapphire/result":"^2.7.2","@sapphire/timestamp":"^1.0.3","@skyra/jaro-winkler":"^1.1.1","adm-zip":"~0.5.15",ajv:"~8.18.0","apify-client":"^2.22.0",archiver:"~7.0.1",axios:"^1.15.0",chalk:"~5.6.0","ci-info":"~4.4.0","cli-table3":"^0.6.5","computer-name":"~0.1.0",configparser:"~0.3.10",cors:"~2.8.5","detect-indent":"~7.0.1","es-toolkit":"^1.45.1","escape-string-regexp":"~5.0.0",execa:"^9.5.2",express:"~5.2.0",handlebars:"~4.7.8",ignore:"^7.0.0","indent-string":"^5.0.0","is-ci":"~4.1.0",istextorbinary:"~9.5.0",jju:"~1.4.0","js-levenshtein":"^1.1.6","json-schema-to-typescript":"^15.0.4",mime:"~4.1.0",open:"~11.0.0",rimraf:"~6.1.0",semver:"~7.7.0","string-width":"^8.0.0","strip-ansi":"^7.1.0",tiged:"~2.12.7",tinyglobby:"^0.2.15",which:"^6.0.0","widest-line":"^6.0.0","wrap-ansi":"^10.0.0"},devDependencies:{"@apify/eslint-config":"^1.0.0","@apify/tsconfig":"^0.1.1","@biomejs/biome":"^2.0.0","@crawlee/types":"^3.11.1","@types/adm-zip":"^0.5.5","@types/archiver":"^7.0.0","@types/bun":"^1.2.5","@types/cors":"^2.8.17","@types/execa":"^2.0.2","@types/express":"^5.0.0","@types/jju":"^1.4.5","@types/js-levenshtein":"^1","@types/mime":"^4.0.0","@types/node":"^24.0.0","@types/semver":"^7.5.8","@types/which":"^3.0.4","@yarnpkg/core":"^4.1.2",apify:"^3.2.4","cross-env":"^10.0.0",eslint:"^9.25.1","eslint-config-prettier":"^10.1.2",husky:"^9","lint-staged":"^16.0.0","mock-stdin":"^1.0.0",prettier:"^3.5.3",tsup:"^8.5.0",tsx:"^4.16.5",typescript:"^6.0.0","typescript-eslint":"^8.31.0",vitest:"^4.0.0"},volta:{node:"24.14.1",yarn:"4.13.0"},packageManager:"yarn@4.13.0",devEngines:{runtime:[{name:"node",version:">= 20",onFail:"error"},{name:"bun",version:">= 1.2.5",onFail:"ignore"}],packageManager:{name:"yarn",version:">= 4",onFail:"warn"}},"lint-staged":{"*":"biome format --write --no-errors-on-unmatched","*.{mjs,js,ts}":"eslint --fix --ext mjs,js,ts","*.md":"prettier --write"},resolutions:{tar:"7.5.13"}};var ot="storage",Ks="apify_storage",Ws=1,Ir={actorSpecification:Ws,name:null,version:"0.0",buildTag:"latest",environmentVariables:{}},Qi=1440*60*1e3,ht=m(()=>{let r=rt(tl(),".apify");return process.env.__APIFY_INTERNAL_TEST_AUTH_PATH__?rt(r,process.env.__APIFY_INTERNAL_TEST_AUTH_PATH__):r},"GLOBAL_CONFIGS_FOLDER"),ge=m(()=>rt(ht(),"auth.json"),"AUTH_FILE_PATH"),Er=m(()=>rt(ht(),"secrets.json"),"SECRETS_FILE_PATH"),$r=m(()=>rt(ht(),"state.json"),"STATE_FILE_PATH"),Rr=m(()=>rt(ht(),"telemetry.json"),"TELEMETRY_FILE_PATH"),xr="apify.json",_r=".actor",sl="actor.json",D=rt(_r,sl),zs=new RegExp(`(^${rl.INPUT}(?:\\.[^.]+)?$)`),Ie=Zi.engines.node,Pr={"X-Apify-Request-Origin":ol.CLI},st="3.9.0",en=".venv";import{execSync as ul}from"child_process";import{createWriteStream as pl,existsSync as oe,mkdirSync as fl,readdirSync as an,readFileSync as Wt,writeFileSync as Or}from"fs";import{mkdir as gl,readFile as Nr}from"fs/promises";import{get as hl}from"https";import{homedir as Xs}from"os";import{dirname as yt,join as q,relative as yl}from"path";import X from"process";import{finished as wl}from"stream/promises";import{DurationFormatter as cn,TimeTypes as it}from"@sapphire/duration";import{Timestamp as Zs}from"@sapphire/timestamp";import Al from"adm-zip";import vl from"ajv/dist/2019.js";import{ApifyClient as ln}from"apify-client";import bl from"archiver";import{AxiosHeaders as Sl}from"axios";import Tl from"escape-string-regexp";import Cl from"ignore";import{getEncoding as Il}from"istextorbinary";import{Mime as El}from"mime";import $l from"mime/types/other.js";import Rl from"mime/types/standard.js";import{gte as xl,minVersion as _l,satisfies as Pl}from"semver";import{glob as Qs}from"tinyglobby";import{ACTOR_ENV_VARS as ei,ACTOR_JOB_TERMINAL_STATUSES as kl,ACTOR_NAME as qt,APIFY_ENV_VARS as Ol,KEY_VALUE_STORE_KEYS as nn,LOCAL_ACTOR_ENV_VARS as ti,LOCAL_STORAGE_SUBDIRS as ri,SOURCE_FILE_FORMATS as Jt}from"@apify/consts";import{existsSync as il,mkdirSync as nl}from"fs";import{readFile as al,stat as tn,unlink as cl,writeFile as ll}from"fs/promises";import{join as rn,sep as dl}from"path";import{rimraf as ml}from"rimraf";var on=m(async(r,e={},t=null)=>{let o=await al(r,"utf-8"),s=JSON.parse(o),i;t?(i=s,i[t]={...s[t],...e}):i={...s,...e},await ll(r,JSON.stringify(i,null," "))},"updateLocalJson"),kr=m((r,e)=>{e||(e=r,r="."),e.split(dl).reduce((o,s)=>(o=rn(o,s),il(o)||nl(o),o),r)},"ensureFolderExistsSync"),Yt=m(async r=>{await ml(r)},"rimrafPromised"),Ht=m(async r=>{(await tn(r)).isFile()&&await cl(r)},"deleteFile"),sn=m(async(r,e)=>(await Promise.all(r.map(async s=>tn(rn(e,s))))).map(s=>s.size).reduce((s,i)=>s+i,0),"sumFilesSizeInBytes");var Kt=Cl,zt=vl,Lr=m(async r=>new Promise((e,t)=>{hl(r,o=>{o.statusCode===301||o.statusCode===302?(e(Lr(o.headers.location)),o.destroy()):e(o)}).on("error",t)}),"httpsGet"),we=m(()=>{let r=Ol.LOCAL_STORAGE_DIR;return X.env[r]||X.env.CRAWLEE_STORAGE_DIR||ot},"getLocalStorageDir"),he=m(r=>{let e=ei.DEFAULT_KEY_VALUE_STORE_ID,t=r||X.env[e]||ti[e];return q(we(),ri.keyValueStores,t)},"getLocalKeyValueStorePath"),dn=m(r=>{let e=ei.DEFAULT_DATASET_ID,t=r||X.env[e]||ti[e];return q(we(),ri.datasets,t)},"getLocalDatasetPath"),mn=m(r=>{let e=ei.DEFAULT_REQUEST_QUEUE_ID,t=r||X.env[e]||ti[e];return q(we(),ri.requestQueues,t)},"getLocalRequestQueuePath"),M=m(async()=>{let r={};try{let e=await Nr(ge(),"utf-8");r=JSON.parse(e)}catch{return{}}if(!r.username&&!r.id)throw new Error('Corrupted local user info was found. Please run "apify login" to fix it.');return r},"getLocalUserInfo");async function I(){let r=await Zt();if(!r)throw X.exitCode=1,new Error('You are not logged in with your Apify account. Call "apify login" to fix that.');return r}m(I,"getLoggedClientOrThrow");var un=m(r=>{if(!r&&oe(ht())&&oe(ge())){let e=Wt(ge(),"utf-8");return JSON.parse(e).token}return r},"getTokenWithAuthFileFallback"),Xt=m((r,e)=>(r=un(r),{token:r,baseUrl:e||X.env.APIFY_CLIENT_BASE_URL,requestInterceptors:[t=>{t.headers??=new Sl;for(let[o,s]of Object.entries(Pr))t.headers[o]=s;return t}]}),"getApifyClientOptions");async function Zt(r,e){r=un(r);let t=new ln(Xt(r,e)),o;try{o=await t.user("me").get()}catch(s){return T("[getLoggedClient] error getting user info",{error:s,apiBaseUrl:e}),null}return si(ge()),Or(ge(),JSON.stringify({token:t.token,...o},null," ")),t}m(Zt,"getLoggedClient");var oi=m(r=>q(r,D),"getLocalConfigPath"),de=m(r=>{if(oe(r))return JSON.parse(Wt(r,{encoding:"utf-8"}))},"getJsonFileContent"),Me=m(r=>de(oi(r)),"getLocalConfig"),Dr=m(async(r,e)=>{let t=q(e||X.cwd(),D);await gl(yt(t),{recursive:!0}),Or(t,JSON.stringify(r,null," "))},"setLocalConfig"),Nl=[we(),"node_modules",".venv"],Fr=m(async r=>{let e=he();kr(r,dn()),kr(r,mn()),kr(r,e);let t=q(r,".gitignore"),o="";oe(t)&&(o=Wt(t,{encoding:"utf-8"}));let s=[];for(let i of Nl)RegExp(`^${Tl(i)}$`,"mg").test(o)||s.push(i);s.length>0&&(o.length>0?(s.unshift("# Added by Apify CLI"),Or(t,`
1
+ var Hc=Object.defineProperty;var m=(r,e)=>Hc(r,"name",{value:e,configurable:!0});import xe from"process";import{parseArgs as ua}from"util";import lo from"chalk";import{satisfies as Zd}from"semver";import bt from"process";import gi from"chalk";import xd from"indent-string";import _d from"widest-line";import Pd from"wrap-ansi";import Ki from"ci-info";var Jc=[["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 Wi(){for(let[r,e]of Jc)if(process.env[r])return e}m(Wi,"detectAiAgent");function zi(){return Ki.isCI?{isCi:!0,ciProvider:Ki.id?.toLowerCase()??"unknown"}:{isCi:!1,ciProvider:void 0}}m(zi,"detectCi");function Xi(){return!!process.stdin.isTTY&&!!process.stdout.isTTY}m(Xi,"detectIsInteractive");import qc from"chalk";function T(r,...e){process.env.APIFY_CLI_DEBUG&&console.error(qc.gray(`[${r}]`),...e)}m(T,"cliDebugPrint");import{realpathSync as Kc}from"fs";import{dirname as Wc}from"path";import gt from"chalk";function tt(r){r.stdoutOutput&&console.log(...r.stdoutOutput),r.stderrOutput&&console.error(...r.stderrOutput)}m(tt,"internalLog");function $(r){tt({[r.stdout?"stdoutOutput":"stderrOutput"]:[r.message]})}m($,"simpleLog");function g(r){tt({[r.stdout?"stdoutOutput":"stderrOutput"]:[gt.red("Error:"),r.message]})}m(g,"error");function x(r){tt({[r.stdout?"stdoutOutput":"stderrOutput"]:[gt.yellow.bold("Warning:"),r.message]})}m(x,"warning");function R(r){tt({[r.stdout?"stdoutOutput":"stderrOutput"]:[gt.green("Success:"),r.message]})}m(R,"success");function Ce(r){tt({[r.stdout?"stdoutOutput":"stderrOutput"]:[gt.gray("Run:"),r.message]})}m(Ce,"run");function b(r){tt({[r.stdout?"stdoutOutput":"stderrOutput"]:[gt.white("Info:"),r.message]})}m(b,"info");function Js(r){tt({[r.stdout?"stdoutOutput":"stderrOutput"]:[gt.blue(r.message),r.url]})}m(Js,"link");var qs="0.0.0";var zc="1.5.0",Xc="3d04a74c5141d7af9998e93cc52904b04c02029e";function Zc(){if(process.env.APIFY_CLI_MARKED_INSTALL_METHOD)return process.env.APIFY_CLI_MARKED_INSTALL_METHOD;if(process.env.APIFY_CLI_BUNDLE)return"bundle";let r=process.argv[1];if(!r)return x({message:"Failed to detect install method of CLI, assuming npm"}),"npm";let e=Kc(r);return process.env.VOLTA_HOME&&e.includes(process.env.VOLTA_HOME)?"volta":e.includes("homebrew/Cellar")||e.includes("linuxbrew/Cellar")?"homebrew":process.env.PNPM_HOME&&e.includes(process.env.PNPM_HOME)?"pnpm":process.env.BUN_INSTALL&&e.includes(process.env.BUN_INSTALL)?"bun":"npm"}m(Zc,"detectInstallMethod");function Qc(){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}}m(Qc,"getRuntimeInfo");var Gt=null;function z(){if(Gt)return Gt;let r=Zc(),e=Qc();return Gt={version:zc,hash:Xc,arch:process.env.APIFY_BUNDLE_ARCH??process.arch,platform:process.platform==="win32"?"windows":process.platform,runtime:e,extraRuntimeData:e.nodeVersion?`(emulating node ${e.nodeVersion})`:"",installMethod:r,get fullVersionString(){return`apify-cli/${this.version} (${this.hash.slice(0,7)}) running on ${this.platform}-${this.arch} with ${this.runtime.runtime}-${e.version}${this.extraRuntimeData?` ${this.extraRuntimeData}`:""}, installed via ${this.installMethod}`},get isBeta(){return this.version.includes("beta")||this.version===qs}},r==="bundle"&&(Gt.installPath=Wc(process.execPath)),Gt}m(z,"useCLIMetadata");import{existsSync as Ul,mkdirSync as Ml,readFileSync as jl,writeFileSync as Bl}from"fs";import{dirname as Vl}from"path";import{cryptoRandomObjectId as Gl}from"@apify/utilities";import{homedir as tl}from"os";import{join as rt}from"path";import{KEY_VALUE_STORE_KEYS as rl,META_ORIGINS as ol}from"@apify/consts";var Zi={name:"apify-cli",version:"1.5.0",description:"Apify command-line interface (CLI) helps you manage the Apify cloud platform and develop, build, and deploy Apify Actors.",exports:"./dist/index.js",type:"module",scripts:{"dev:apify":"tsx ./src/entrypoints/apify.ts","dev:actor":"tsx ./src/entrypoints/actor.ts","test:all":"yarn test:local && yarn test:api","test:local":"vitest run --testNamePattern '^((?!\\[api]).)*$' --exclude ./test/api --exclude ./test/e2e","test:e2e":"vitest run --testNamePattern '\\[e2e\\]' --exclude ./test/api","test:e2e:local":"vitest run --testNamePattern '^(?=.*\\[e2e\\])(?!.*\\[api\\]).*$' --exclude ./test/api","test:api":"vitest run --testNamePattern '^(?=.*\\[api\\])(?!.*\\[e2e\\]).*$' --exclude ./test/e2e","test:python":"vitest run --testNamePattern '\\[python\\]'",lint:"eslint src test scripts --ext .ts,.cjs,.mjs","lint:fix":"eslint src test scripts --fix --ext .ts,.cjs,.mjs",format:'biome format . && prettier --check "**/*.{md,yml,yaml}"',"format:fix":'biome format --write . && prettier --write "**/*.{md,yml,yaml}"',clean:"rimraf dist",build:"yarn clean && tsc && tsup","build-bundles":"bun run scripts/build-cli-bundles.ts",prepack:"yarn insert-cli-metadata && yarn build && yarn update-docs","insert-cli-metadata":"tsx scripts/insert-cli-metadata.ts","update-docs":"tsx scripts/generate-cli-docs.ts",postinstall:`node -e "console.log('We have an active developer community on Discord. You can find it on https://discord.gg/crawlee-apify-801163717915574323.');"`,prepare:"husky"},files:["dist"],bin:{actor:"./dist/actor.js",apify:"./dist/apify.js","apify-cli":"./dist/apify.js"},contributors:["Jakub Drobn\xEDk <jakub.drobnik@apify.com>","Jan Curn <jan@apify.com>","Vlad Frangu <vlad.frangu@apify.com>"],repository:{type:"git",url:"git+https://github.com/apify/apify-cli.git"},keywords:["apify","client","node","command","line","bash"],author:{name:"Apify",email:"support@apify.com",url:"https://www.apify.com"},license:"Apache-2.0",bugs:{url:"https://github.com/apify/apify-cli/issues"},homepage:"https://github.com/apify/apify-cli#readme",engines:{node:">=20"},dependencies:{"@apify/actor-memory-expression":"^0.1.12","@apify/actor-templates":"^0.1.5","@apify/consts":"^2.36.0","@apify/input_schema":"^3.17.0","@apify/utilities":"^2.18.0","@crawlee/memory-storage":"^3.12.0","@inquirer/core":"^11.0.0","@inquirer/input":"^5.0.0","@inquirer/password":"^5.0.0","@inquirer/select":"^5.0.0","@root/walk":"~1.1.0","@sapphire/duration":"^1.1.2","@sapphire/result":"^2.7.2","@sapphire/timestamp":"^1.0.3","@skyra/jaro-winkler":"^1.1.1","adm-zip":"~0.5.15",ajv:"~8.18.0","apify-client":"^2.22.0",archiver:"~7.0.1",axios:"^1.15.0",chalk:"~5.6.0","ci-info":"~4.4.0","cli-table3":"^0.6.5","computer-name":"~0.1.0",configparser:"~0.3.10",cors:"~2.8.5","detect-indent":"~7.0.1","es-toolkit":"^1.45.1","escape-string-regexp":"~5.0.0",execa:"^9.5.2",express:"~5.2.0",handlebars:"~4.7.8",ignore:"^7.0.0","indent-string":"^5.0.0","is-ci":"~4.1.0",istextorbinary:"~9.5.0",jju:"~1.4.0","js-levenshtein":"^1.1.6","json-schema-to-typescript":"^15.0.4",mime:"~4.1.0",open:"~11.0.0",rimraf:"~6.1.0",semver:"~7.7.0","string-width":"^8.0.0","strip-ansi":"^7.1.0",tiged:"~2.12.7",tinyglobby:"^0.2.15",which:"^6.0.0","widest-line":"^6.0.0","wrap-ansi":"^10.0.0"},devDependencies:{"@apify/eslint-config":"^1.0.0","@apify/tsconfig":"^0.1.1","@biomejs/biome":"^2.0.0","@crawlee/types":"^3.11.1","@types/adm-zip":"^0.5.5","@types/archiver":"^7.0.0","@types/bun":"^1.2.5","@types/cors":"^2.8.17","@types/execa":"^2.0.2","@types/express":"^5.0.0","@types/jju":"^1.4.5","@types/js-levenshtein":"^1","@types/mime":"^4.0.0","@types/node":"^24.0.0","@types/semver":"^7.5.8","@types/which":"^3.0.4","@yarnpkg/core":"^4.1.2",apify:"^3.2.4","cross-env":"^10.0.0",eslint:"^9.25.1","eslint-config-prettier":"^10.1.2",husky:"^9","lint-staged":"^16.0.0","mock-stdin":"^1.0.0",prettier:"^3.5.3",tsup:"^8.5.0",tsx:"^4.16.5",typescript:"^6.0.0","typescript-eslint":"^8.31.0",vitest:"^4.0.0"},volta:{node:"24.14.1",yarn:"4.13.0"},packageManager:"yarn@4.13.0",devEngines:{runtime:[{name:"node",version:">= 20",onFail:"error"},{name:"bun",version:">= 1.2.5",onFail:"ignore"}],packageManager:{name:"yarn",version:">= 4",onFail:"warn"}},"lint-staged":{"*":"biome format --write --no-errors-on-unmatched","*.{mjs,js,ts}":"eslint --fix --ext mjs,js,ts","*.md":"prettier --write"},resolutions:{tar:"7.5.13"}};var ot="storage",Ks="apify_storage",Ws=1,Ir={actorSpecification:Ws,name:null,version:"0.0",buildTag:"latest",environmentVariables:{}},Qi=1440*60*1e3,ht=m(()=>{let r=rt(tl(),".apify");return process.env.__APIFY_INTERNAL_TEST_AUTH_PATH__?rt(r,process.env.__APIFY_INTERNAL_TEST_AUTH_PATH__):r},"GLOBAL_CONFIGS_FOLDER"),ge=m(()=>rt(ht(),"auth.json"),"AUTH_FILE_PATH"),Er=m(()=>rt(ht(),"secrets.json"),"SECRETS_FILE_PATH"),$r=m(()=>rt(ht(),"state.json"),"STATE_FILE_PATH"),Rr=m(()=>rt(ht(),"telemetry.json"),"TELEMETRY_FILE_PATH"),xr="apify.json",_r=".actor",sl="actor.json",D=rt(_r,sl),zs=new RegExp(`(^${rl.INPUT}(?:\\.[^.]+)?$)`),Ie=Zi.engines.node,Pr={"X-Apify-Request-Origin":ol.CLI},st="3.9.0",en=".venv";import{execSync as ul}from"child_process";import{createWriteStream as pl,existsSync as oe,mkdirSync as fl,readdirSync as an,readFileSync as Wt,writeFileSync as Or}from"fs";import{mkdir as gl,readFile as Nr}from"fs/promises";import{get as hl}from"https";import{homedir as Xs}from"os";import{dirname as yt,join as q,relative as yl}from"path";import X from"process";import{finished as wl}from"stream/promises";import{DurationFormatter as cn,TimeTypes as it}from"@sapphire/duration";import{Timestamp as Zs}from"@sapphire/timestamp";import Al from"adm-zip";import vl from"ajv/dist/2019.js";import{ApifyClient as ln}from"apify-client";import bl from"archiver";import{AxiosHeaders as Sl}from"axios";import Tl from"escape-string-regexp";import Cl from"ignore";import{getEncoding as Il}from"istextorbinary";import{Mime as El}from"mime";import $l from"mime/types/other.js";import Rl from"mime/types/standard.js";import{gte as xl,minVersion as _l,satisfies as Pl}from"semver";import{glob as Qs}from"tinyglobby";import{ACTOR_ENV_VARS as ei,ACTOR_JOB_TERMINAL_STATUSES as kl,ACTOR_NAME as qt,APIFY_ENV_VARS as Ol,KEY_VALUE_STORE_KEYS as nn,LOCAL_ACTOR_ENV_VARS as ti,LOCAL_STORAGE_SUBDIRS as ri,SOURCE_FILE_FORMATS as Jt}from"@apify/consts";import{existsSync as il,mkdirSync as nl}from"fs";import{readFile as al,stat as tn,unlink as cl,writeFile as ll}from"fs/promises";import{join as rn,sep as dl}from"path";import{rimraf as ml}from"rimraf";var on=m(async(r,e={},t=null)=>{let o=await al(r,"utf-8"),s=JSON.parse(o),i;t?(i=s,i[t]={...s[t],...e}):i={...s,...e},await ll(r,JSON.stringify(i,null," "))},"updateLocalJson"),kr=m((r,e)=>{e||(e=r,r="."),e.split(dl).reduce((o,s)=>(o=rn(o,s),il(o)||nl(o),o),r)},"ensureFolderExistsSync"),Yt=m(async r=>{await ml(r)},"rimrafPromised"),Ht=m(async r=>{(await tn(r)).isFile()&&await cl(r)},"deleteFile"),sn=m(async(r,e)=>(await Promise.all(r.map(async s=>tn(rn(e,s))))).map(s=>s.size).reduce((s,i)=>s+i,0),"sumFilesSizeInBytes");var Kt=Cl,zt=vl,Lr=m(async r=>new Promise((e,t)=>{hl(r,o=>{o.statusCode===301||o.statusCode===302?(e(Lr(o.headers.location)),o.destroy()):e(o)}).on("error",t)}),"httpsGet"),we=m(()=>{let r=Ol.LOCAL_STORAGE_DIR;return X.env[r]||X.env.CRAWLEE_STORAGE_DIR||ot},"getLocalStorageDir"),he=m(r=>{let e=ei.DEFAULT_KEY_VALUE_STORE_ID,t=r||X.env[e]||ti[e];return q(we(),ri.keyValueStores,t)},"getLocalKeyValueStorePath"),dn=m(r=>{let e=ei.DEFAULT_DATASET_ID,t=r||X.env[e]||ti[e];return q(we(),ri.datasets,t)},"getLocalDatasetPath"),mn=m(r=>{let e=ei.DEFAULT_REQUEST_QUEUE_ID,t=r||X.env[e]||ti[e];return q(we(),ri.requestQueues,t)},"getLocalRequestQueuePath"),M=m(async()=>{let r={};try{let e=await Nr(ge(),"utf-8");r=JSON.parse(e)}catch{return{}}if(!r.username&&!r.id)throw new Error('Corrupted local user info was found. Please run "apify login" to fix it.');return r},"getLocalUserInfo");async function I(){let r=await Zt();if(!r)throw X.exitCode=1,new Error('You are not logged in with your Apify account. Call "apify login" to fix that.');return r}m(I,"getLoggedClientOrThrow");var un=m(r=>{if(!r&&oe(ht())&&oe(ge())){let e=Wt(ge(),"utf-8");return JSON.parse(e).token}return r},"getTokenWithAuthFileFallback"),Xt=m((r,e)=>(r=un(r),{token:r,baseUrl:e||X.env.APIFY_CLIENT_BASE_URL,requestInterceptors:[t=>{t.headers??=new Sl;for(let[o,s]of Object.entries(Pr))t.headers[o]=s;return t}]}),"getApifyClientOptions");async function Zt(r,e){r=un(r);let t=new ln(Xt(r,e)),o;try{o=await t.user("me").get()}catch(s){return T("[getLoggedClient] error getting user info",{error:s,apiBaseUrl:e}),null}return si(ge()),Or(ge(),JSON.stringify({token:t.token,...o},null," ")),t}m(Zt,"getLoggedClient");var oi=m(r=>q(r,D),"getLocalConfigPath"),de=m(r=>{if(oe(r))return JSON.parse(Wt(r,{encoding:"utf-8"}))},"getJsonFileContent"),Me=m(r=>de(oi(r)),"getLocalConfig"),Dr=m(async(r,e)=>{let t=q(e||X.cwd(),D);await gl(yt(t),{recursive:!0}),Or(t,JSON.stringify(r,null," "))},"setLocalConfig"),Nl=[we(),"node_modules",".venv"],Fr=m(async r=>{let e=he();kr(r,dn()),kr(r,mn()),kr(r,e);let t=q(r,".gitignore"),o="";oe(t)&&(o=Wt(t,{encoding:"utf-8"}));let s=[];for(let i of Nl)RegExp(`^${Tl(i)}$`,"mg").test(o)||s.push(i);s.length>0&&(o.length>0?(s.unshift("# Added by Apify CLI"),Or(t,`
2
2
  ${s.join(`
3
3
  `)}
4
4
  `,{flag:"a"})):Or(t,`${s.join(`
@@ -112,7 +112,7 @@ ${vo.gray("Timeout for printing logs was hit, there may be future logs.")}
112
112
  `):console.error()}catch(y){x({message:"Can not get log:"}),console.error(y)}if(f=await r.run(f.id).get(),l)for(;!Na.includes(f.status)&&(f=await r.run(f.id).get(),!Na.includes(f.status));)await new Promise(y=>{setTimeout(y,1e3)});c||(f.status===qe.SUCCEEDED?R({message:`${i} finished.`}):f.status===qe.RUNNING?x({message:`${i} is still running!`}):f.status===qe.ABORTED||f.status===qe.ABORTING?(x({message:`${i} was aborted!`}),Ci.exitCode=3):(g({message:`${i} failed!`}),Ci.exitCode=1)),yield f}m(Dt,"runActorOrTaskOnCloud");var Ft=m(r=>({build:w.string({char:"b",description:'Tag or number of the build to run (e.g. "latest" or "1.2.34").',required:!1}),timeout:w.integer({char:"t",description:`Timeout for the ${r} run in seconds. Zero value means there is no timeout.`,required:!1}),memory:w.integer({char:"m",description:`Amount of memory allocated for the ${r} run, in megabytes.`,required:!1})}),"SharedRunOnCloudFlags");var Ke=class r extends h{static name="call";static description=`Executes Actor remotely using your authenticated account.
113
113
  Reads input from local key-value store by default.`;static group="Apify Console";static examples=[{description:"Call the Actor defined in the current directory (from .actor/actor.json).",command:"apify call"},{description:"Call a specific Actor by its full name.",command:"apify call apify/hello-world"},{description:"Call an Actor with inline JSON input.",command:`apify call apify/hello-world --input '{"url":"https://example.com"}'`},{description:"Call an Actor with input from a file and print the dataset on success.",command:"apify call apify/web-scraper --input-file input.json --output-dataset"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-call";static flags={...Ft("Actor"),input:w.string({char:"i",description:"Optional JSON input to be given to the Actor.",required:!1,stdin:2,exclusive:["input-file"]}),"input-file":w.string({char:"f",description:"Optional path to a file with JSON input to be given to the Actor. The file must be a valid JSON file. You can also specify `-` to read from standard input.",required:!1,stdin:2,exclusive:["input"]}),silent:w.boolean({char:"s",description:"Prevents printing the logs of the Actor run to the console.",default:!1}),"output-dataset":w.boolean({char:"o",description:"Prints out the entire default dataset on successful run of the Actor."})};static enableJsonFlag=!0;static args={actorId:A.string({required:!1,description:`Name or ID of the Actor to run (e.g. "my-actor", "apify/hello-world" or "E2jjCZBezvAZnX8Rb"). If not provided, the command runs the remote Actor specified in the '${D}' file.`})};async run(){let e=La.cwd(),t=Me(e)||{},o=await I(),s=await M(),i=s.username||s.id;if(this.flags.json&&this.flags.outputDataset){g({message:"You cannot use both the --json and --output-dataset flags when running this command."}),La.exitCode=5;return}let{id:n,userFriendlyId:a,actorData:c}=await r.resolveActorId({client:o,localActorName:t.name,usernameOrId:i,providedActorNameOrId:this.args.actorId}),l={waitForFinish:2};this.flags.build&&(l.build=this.flags.build),this.flags.timeout&&(l.timeout=this.flags.timeout),this.flags.memory&&(l.memory=this.flags.memory);let d=await Lt(e,this.flags.input,this.flags.inputFile);if(d===!1)return;let u=!1,p,f,y,v=Dt(o,{actorOrTaskData:{id:n,userFriendlyId:a},runOptions:l,type:"Actor",inputOverride:d?.input,silent:this.flags.silent,waitForRunToFinish:!0,printRunLogs:!0});for await(let S of v)if(p=S,!u&&(u=!0,!this.flags.silent)){f=`https://console.apify.com/actors/${n}/runs/${S.id}`,y=`https://console.apify.com/storage/datasets/${S.defaultDatasetId}`;let E=[`${ce.yellow("Started")}: ${Y.display(S.startedAt)}`];S.containerUrl&&E.push(`${ce.yellow("Container URL")}: ${ce.blue(S.containerUrl)}`);let C=p.buildNumber.split(".").slice(0,2).join("."),P=c.versions.find(U=>U.versionNumber===C),N=Object.entries(c.taggedBuilds??{}).find(([,U])=>U.buildNumber===S.buildNumber)?.[0],O=[`${ce.yellow("Build")}:`,ce.cyan(p.buildNumber)];N?O.push(`(${ce.yellow(N)})`):O.push(`(${ce.gray("N/A")})`),P&&O.push(`| ${ce.gray("Actor version:")} ${ce.cyan(P.versionNumber)} (${ce.yellow(P.buildTag)})`),E.push(O.join(" ")),E.push(`${ce.yellow("Timeout")}: ${p.options.timeoutSecs.toLocaleString("en-US")} seconds`),E.push(`${ce.yellow("Memory")}: ${p.options.memoryMbytes} MB`),E.push(`${ce.blue("View on Apify Console")}: ${f}`,""),$({message:E.join(`
114
114
  `),stdout:!this.flags.json})}if(this.flags.json){L(p);return}if(this.flags.silent||$({message:["",`${ce.blue("Export results")}: ${y}`,`${ce.blue("View on Apify Console")}: ${f}`].join(`
115
- `),stdout:!0}),this.flags.outputDataset){let S=p.defaultDatasetId,E,C=4;do{if(E=await o.dataset(S).get(),E?.itemCount)break;await new Promise(N=>{setTimeout(N,250)})}while(C--);let P=await o.dataset(S).downloadItems(Gm.JSON,{clean:!0});console.log(P.toString())}}static async resolveActorId({client:e,localActorName:t,usernameOrId:o,providedActorNameOrId:s}){if(s?.includes("/")){let i=await e.actor(s).get();if(!i)throw new Error(`Cannot find Actor with ID '${s}' in your account.`);return{userFriendlyId:`${i.username}/${i.name}`,id:i.id,actorData:i}}if(s){let i=await e.actor(s).get();if(i)return{userFriendlyId:`${i.username}/${i.name}`,id:i.id,actorData:i};let n=await e.actor(`${o}/${s.toLowerCase()}`).get();if(n)return{userFriendlyId:`${n.username}/${n.name}`,id:n.id,actorData:n};throw new Error(`Cannot find Actor with name or ID '${s}' in your account.`)}if(t){let i=await e.actor(`${o}/${t}`).get();if(!i)throw new Error(`Cannot find Actor with ID '${o}/${t}' in your account. Call "apify push" to push this Actor to Apify platform.`);return{userFriendlyId:`${i.username}/${i.name}`,id:i.id,actorData:i}}throw new Error("Please provide an Actor ID or name, or run this command from a directory with a valid Apify Actor.")}};import k from"chalk";import Ym from"cli-table3";var Hm={mid:"","left-mid":"","mid-mid":"","right-mid":"",middle:" ","top-mid":"\u2500","bottom-mid":"\u2500"},Jm={middle:" ","top-mid":"\u2500","bottom-mid":"\u2500",top:"\u2500",bottom:"\u2500","left-mid":"\u251C",mid:"\u2500","mid-mid":"\u2500","right-mid":"\u2524"},qm={left:"",right:"",mid:"","bottom-left":"","bottom-mid":"","bottom-right":"",top:"","top-left":"","top-mid":"","top-right":"","left-mid":"","mid-mid":"","right-mid":"",bottom:"",middle:" "};var Km={[-1]:void 0,0:Hm,1:Jm,2:qm};function Wm(r){return Array.from({length:r},()=>"cyan")}m(Wm,"generateHeaderColors");var zm=process.stdout.columns??100,bo=Symbol.for("@apify/cli:responsive-table:skip-column"),B=class r{static{m(this,"ResponsiveTable")}options;rows=[];constructor(e){this.options=e}pushRow(e){this.rows.push(e)}render(e){let t=r.isSmallTerminal()?this.options.mandatoryColumns:this.options.allColumns,o=Wm(t.length),s=e===0||e===2,i=Km[e],n=[],a=[],c=[];for(let d of t)this.options.hiddenColumns?.includes(d)||this.rows.some(u=>u[d]===bo)||(n.push(this.options.columnAlignments?.[d]||"left"),r.isSmallTerminal()?(a.push(this.options.breakpointOverrides?.small?.[d]?.label??d),c.push(this.options.breakpointOverrides?.small?.[d]?.valueFrom??d)):(a.push(d),c.push(d)));let l=new Ym({head:a,style:{head:o,compact:s},colAligns:n,chars:i});for(let d of this.rows){let u=c.map(p=>d[p]);l.push(u)}return l.toString()}static isSmallTerminal(){return zm<100}};var So="\u200B",To="\u200B\u200B",Da=new B({allColumns:[So,To],mandatoryColumns:[So,To],columnAlignments:{[So]:"left",[To]:"right"}}),Co=class extends h{static name="info";static description="Get information about an Actor.";static examples=[{description:"Print summary information about an Actor.",command:"apify actors info apify/hello-world"},{description:"Print the Actor README only.",command:"apify actors info apify/hello-world --readme"},{description:"Print the Actor input schema as JSON.",command:"apify actors info apify/hello-world --input"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-actors-info";static flags={readme:w.boolean({description:"Return the Actor README.",exclusive:["input"]}),input:w.boolean({description:"Return the Actor input schema.",exclusive:["readme"]})};static args={actorId:A.string({description:"The ID of the Actor to return information about.",required:!0})};static enableJsonFlag=!0;async run(){let{actorId:e}=this.args,{readme:t,input:o,json:s}=this.flags,i=await I(),n=await Je({providedActorNameOrId:e,client:i});if(!n.valid){g({message:`${n.reason}. Please specify the Actor ID.`,stdout:!0});return}let a=await i.actor(n.id).get(),c=await i.user(a.userId).get();a.actorMaker=c;for(let p of Object.values(a.taggedBuilds??{})){if(!p.buildId)continue;let f=await i.build(p.buildId).get();p.build=f}if(s){L(a);return}let l=a.taggedBuilds?.latest;if(t){if(!l){g({message:"No README found for this Actor.",stdout:!0});return}if(!l.build?.readme){g({message:"No README found for this Actor.",stdout:!0});return}$({message:l.build.readme,stdout:!0})}if(o){if(!l){g({message:"No input schema found for this Actor.",stdout:!0});return}if(!l.build?.inputSchema){g({message:"No input schema found for this Actor.",stdout:!0});return}$({message:l.build.inputSchema,stdout:!0})}let d=[`Information about Actor ${k.yellow(`${a.username}/${a.name}`)} (${k.gray(a.id)})`,""];a.title&&d.push(`${k.yellow("Title:")} ${k.bold(a.title)}`),a.description&&d.push(`${k.yellow("Description:")} ${a.description}`),d.push(`${k.yellow("Created at:")} ${k.cyan(Y.display(a.createdAt))} ${k.gray("|")} ${k.yellow("Updated at:")} ${k.cyan(Y.display(a.modifiedAt))}`),a.actorMaker&&(d.push("",`${k.yellow("Made by:")} ${k.cyan(a.actorMaker.profile.name??a.actorMaker.username)}`),Reflect.get(a,"isCritical")&&(d[d.length-1]+=` ${k.bgGray("Maintained by Apify")}`)),a.isPublic?d.push("",`${k.yellow("Actor is")} ${k.green("PUBLIC")}`):d.push("",`${k.yellow("Actor is")} ${k.cyan("PRIVATE")}`),a.isDeprecated&&d.push("",`${k.yellow("Actor is")} ${k.red("DEPRECATED")}`);let u=Reflect.get(a,"pricingInfos");if(u?.length){let p=u.at(-1);switch(p.pricingModel){case"FLAT_PRICE_PER_MONTH":{if(d.push(`${k.yellow("Pricing information:")} ${k.bgGray(`$${p.pricePerUnitUsd}/month + usage`)}`),p.trialMinutes){let f=p.trialMinutes*60*1e3,y=rr.format(f);d.push(` ${k.yellow("Trial duration:")} ${k.bold(y)}`)}break}case"PRICE_PER_DATASET_ITEM":{let f=p.pricePerUnitUsd*1e3;d.push(`${k.yellow("Pricing information:")} ${k.bgGray(`$${f.toFixed(2)} / 1,000 results`)}`);break}case"PAY_PER_EVENT":{d.push(`${k.yellow("Pricing information:")} ${k.bgGray("Pay per event")}`);let f=Object.values(p.pricingPerEvent?.actorChargeEvents??{});for(let S of f)Da.pushRow({[So]:S.eventTitle,[To]:k.bold(`$${S.eventPriceUsd.toFixed(2)}`)});let v=Da.render(0).split(`
115
+ `),stdout:!0}),this.flags.outputDataset){let S=p.defaultDatasetId,E,C=4;do{if(E=await o.dataset(S).get(),E?.itemCount)break;await new Promise(N=>{setTimeout(N,250)})}while(C--);let P=await o.dataset(S).downloadItems(Gm.JSON,{clean:!0});console.log(P.toString())}}static async resolveActorId({client:e,localActorName:t,usernameOrId:o,providedActorNameOrId:s}){if(s?.includes("/")){let i=await e.actor(s).get();if(!i)throw new Error(`Cannot find Actor with ID '${s}' in your account.`);return{userFriendlyId:`${i.username}/${i.name}`,id:i.id,actorData:i}}if(s){let i=await e.actor(s).get();if(i)return{userFriendlyId:`${i.username}/${i.name}`,id:i.id,actorData:i};let n=await e.actor(`${o}/${s.toLowerCase()}`).get();if(n)return{userFriendlyId:`${n.username}/${n.name}`,id:n.id,actorData:n};throw new Error(`Cannot find Actor with name or ID '${s}' in your account.`)}if(t){let i=await e.actor(`${o}/${t}`).get();if(!i)throw new Error(`Cannot find Actor with ID '${o}/${t}' in your account. Call "apify push" to push this Actor to Apify platform.`);return{userFriendlyId:`${i.username}/${i.name}`,id:i.id,actorData:i}}throw new Error("Please provide an Actor ID or name, or run this command from a directory with a valid Apify Actor.")}};import k from"chalk";import Ym from"cli-table3";var Hm={mid:"","left-mid":"","mid-mid":"","right-mid":"",middle:" ","top-mid":"\u2500","bottom-mid":"\u2500"},Jm={middle:" ","top-mid":"\u2500","bottom-mid":"\u2500",top:"\u2500",bottom:"\u2500","left-mid":"\u251C",mid:"\u2500","mid-mid":"\u2500","right-mid":"\u2524"},qm={left:"",right:"",mid:"","bottom-left":"","bottom-mid":"","bottom-right":"",top:"","top-left":"","top-mid":"","top-right":"","left-mid":"","mid-mid":"","right-mid":"",bottom:"",middle:" "};var Km={[-1]:void 0,0:Hm,1:Jm,2:qm};function Wm(r){return Array.from({length:r},()=>"cyan")}m(Wm,"generateHeaderColors");var zm=process.stdout.columns??100,bo=Symbol.for("@apify/cli:responsive-table:skip-column"),B=class r{static{m(this,"ResponsiveTable")}options;rows=[];constructor(e){this.options=e}pushRow(e){this.rows.push(e)}render(e){let t=r.isSmallTerminal()?this.options.mandatoryColumns:this.options.allColumns,o=Wm(t.length),s=e===0||e===2,i=Km[e],n=[],a=[],c=[];for(let d of t)this.options.hiddenColumns?.includes(d)||this.rows.some(u=>u[d]===bo)||(n.push(this.options.columnAlignments?.[d]||"left"),r.isSmallTerminal()?(a.push(this.options.breakpointOverrides?.small?.[d]?.label??d),c.push(this.options.breakpointOverrides?.small?.[d]?.valueFrom??d)):(a.push(d),c.push(d)));let l=new Ym({head:a,style:{head:o,compact:s},colAligns:n,chars:i});for(let d of this.rows){let u=c.map(p=>d[p]);l.push(u)}return l.toString()}static isSmallTerminal(){return zm<100}};var So="\u200B",To="\u200B\u200B",Da=new B({allColumns:[So,To],mandatoryColumns:[So,To],columnAlignments:{[So]:"left",[To]:"right"}}),Co=class extends h{static name="info";static description="Get information about an Actor.";static examples=[{description:"Print summary information about an Actor.",command:"apify actors info apify/hello-world"},{description:"Print the Actor README only.",command:"apify actors info apify/hello-world --readme"},{description:"Print the Actor input schema as JSON.",command:"apify actors info apify/hello-world --input"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-actors-info";static flags={readme:w.boolean({description:"Return the Actor README.",exclusive:["input"]}),input:w.boolean({description:"Return the Actor input schema.",exclusive:["readme"]})};static args={actorId:A.string({description:"The ID of the Actor to return information about.",required:!0})};static enableJsonFlag=!0;async run(){let{actorId:e}=this.args,{readme:t,input:o,json:s}=this.flags,i=await I(),n=await Je({providedActorNameOrId:e,client:i});if(!n.valid){g({message:`${n.reason}. Please specify the Actor ID.`,stdout:!0});return}let a=await i.actor(n.id).get(),c=await i.user(a.userId).get();a.actorMaker=c;for(let p of Object.values(a.taggedBuilds??{})){if(!p.buildId)continue;let f=await i.build(p.buildId).get();p.build=f}if(s){L(a);return}let l=a.taggedBuilds?.latest;if(t){if(!l){g({message:"No README found for this Actor.",stdout:!0});return}if(!l.build?.readme){g({message:"No README found for this Actor.",stdout:!0});return}$({message:l.build.readme,stdout:!0});return}if(o){if(!l){g({message:"No input schema found for this Actor.",stdout:!0});return}if(!l.build?.inputSchema){g({message:"No input schema found for this Actor.",stdout:!0});return}$({message:l.build.inputSchema,stdout:!0});return}let d=[`Information about Actor ${k.yellow(`${a.username}/${a.name}`)} (${k.gray(a.id)})`,""];a.title&&d.push(`${k.yellow("Title:")} ${k.bold(a.title)}`),a.description&&d.push(`${k.yellow("Description:")} ${a.description}`),d.push(`${k.yellow("Created at:")} ${k.cyan(Y.display(a.createdAt))} ${k.gray("|")} ${k.yellow("Updated at:")} ${k.cyan(Y.display(a.modifiedAt))}`),a.actorMaker&&(d.push("",`${k.yellow("Made by:")} ${k.cyan(a.actorMaker.profile.name??a.actorMaker.username)}`),Reflect.get(a,"isCritical")&&(d[d.length-1]+=` ${k.bgGray("Maintained by Apify")}`)),a.isPublic?d.push("",`${k.yellow("Actor is")} ${k.green("PUBLIC")}`):d.push("",`${k.yellow("Actor is")} ${k.cyan("PRIVATE")}`),a.isDeprecated&&d.push("",`${k.yellow("Actor is")} ${k.red("DEPRECATED")}`);let u=Reflect.get(a,"pricingInfos");if(u?.length){let p=u.at(-1);switch(p.pricingModel){case"FLAT_PRICE_PER_MONTH":{if(d.push(`${k.yellow("Pricing information:")} ${k.bgGray(`$${p.pricePerUnitUsd}/month + usage`)}`),p.trialMinutes){let f=p.trialMinutes*60*1e3,y=rr.format(f);d.push(` ${k.yellow("Trial duration:")} ${k.bold(y)}`)}break}case"PRICE_PER_DATASET_ITEM":{let f=p.pricePerUnitUsd*1e3;d.push(`${k.yellow("Pricing information:")} ${k.bgGray(`$${f.toFixed(2)} / 1,000 results`)}`);break}case"PAY_PER_EVENT":{d.push(`${k.yellow("Pricing information:")} ${k.bgGray("Pay per event")}`);let f=Object.values(p.pricingPerEvent?.actorChargeEvents??{});for(let S of f)Da.pushRow({[So]:S.eventTitle,[To]:k.bold(`$${S.eventPriceUsd.toFixed(2)}`)});let v=Da.render(0).split(`
116
116
  `);v.splice(1,1),d.push(v.join(`
117
117
  `));break}case"FREE":{d.push(`${k.yellow("Pricing information:")} ${k.bgGray("Pay for usage")}`);break}default:d.push(`${k.yellow("Pricing information:")} ${k.bgGray(`Unknown pricing model (${k.yellow(p.pricingModel)})`)}`)}}else d.push(`${k.yellow("Pricing information:")} ${k.bgGray("Pay for usage")}`);if((a.seoTitle||a.seoDescription)&&(d.push("",k.yellow("SEO information:")),a.seoTitle&&d.push(` ${k.yellow("Title:")} ${a.seoTitle}`),a.seoDescription&&d.push(` ${k.yellow("Description:")} ${a.seoDescription}`)),a.taggedBuilds){d.push("",k.yellow("Builds:"));let p=a.taggedBuilds.latest;p&&d.push(` ${k.yellow("-")} ${k.cyan(p.buildNumber)} ${k.gray("/")} ${k.yellow("latest")}`);for(let[f,y]of Object.entries(a.taggedBuilds))f!=="latest"&&d.push(` ${k.yellow("-")} ${k.cyan(y.buildNumber)} ${k.gray("/")} ${k.yellow(f)}`)}$({message:d.join(`
118
118
  `),stdout:!0})}};import{Time as Xm}from"@sapphire/duration";import Q from"chalk";import je from"chalk";function Pe(r){switch(r){case"READY":return je.green("Ready");case"RUNNING":return je.blue("Running");case"SUCCEEDED":return je.green("Succeeded");case"FAILED":return je.red("Failed");case"ABORTING":return je.yellow("Aborting");case"ABORTED":return je.red("Aborted");case"TIMING-OUT":return je.yellow("Timing Out");case"TIMED-OUT":return je.red("Timed Out");default:return je.gray(r.split("-").map(e=>e[0].toUpperCase()+e.slice(1).toLowerCase()).join(" "))}}m(Pe,"prettyPrintStatus");var Zm={"TIMED-OUT":Q.gray("after"),"TIMING-OUT":Q.gray("after"),ABORTED:Q.gray("after"),ABORTING:Q.gray("after"),FAILED:Q.gray("after"),READY:Q.gray("for"),RUNNING:Q.gray("for"),SUCCEEDED:Q.gray("after")},Qm=new B({allColumns:["Name","Runs","Last run started at","Last run status","Last run duration","_Small_LastRunText"],mandatoryColumns:["Name","Runs","Last run status","Last run duration"],columnAlignments:{Runs:"right","Last run duration":"right",Name:"left","Last run status":"center"},hiddenColumns:["_Small_LastRunText"],breakpointOverrides:{small:{"Last run status":{label:"Last run",valueFrom:"_Small_LastRunText"}}}}),eu=new B({allColumns:["Name","Modified at","Builds","Default build","Runs","Last run","Last run status","Last run duration","_Small_LastRunText"],mandatoryColumns:["Name","Runs","Last run","Last run duration"],hiddenColumns:["_Small_LastRunText"],columnAlignments:{Builds:"right",Runs:"right","Last run duration":"right",Name:"left","Last run status":"center"},breakpointOverrides:{small:{"Last run":{label:"Last run",valueFrom:"_Small_LastRunText"}}}}),Io=class extends h{static name="ls";static description="Prints a list of recently executed Actors or Actors you own.";static examples=[{description:"List Actors you recently interacted with.",command:"apify actors ls"},{description:"List Actors you own, newest first.",command:"apify actors ls --my --desc"},{description:"List the next page of 50 Actors.",command:"apify actors ls --limit 50 --offset 50"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-actors-ls";static flags={my:w.boolean({description:"Whether to list Actors made by the logged in user.",default:!1}),offset:w.integer({description:"Number of Actors that will be skipped.",default:0}),limit:w.integer({description:"Number of Actors that will be listed.",default:20}),desc:w.boolean({description:"Sort Actors in descending order.",default:!1})};static enableJsonFlag=!0;async run(){let{desc:e,limit:t,offset:o,my:s,json:i}=this.flags,n=await I(),a=await n.actors().list({limit:t,offset:o,desc:e,my:s});if(a.count===0){if(i){L(a);return}b({message:s?"You don't have any Actors yet!":"There are no recent Actors used by you.",stdout:!0});return}let c={...a,items:await Promise.all(a.items.map(async u=>{let p=await n.actor(u.id).get(),f=await n.actor(u.id).runs().list({desc:!0,limit:1}).catch(()=>({count:0,desc:!0,items:[],limit:1,offset:0,total:0}));return{...u,actor:p??null,lastRun:f.items[0]??null}}))};if(c.items=s?this.sortByModifiedAt(c.items):this.sortByLastRun(c.items),i){L(c);return}let l=s?eu:Qm,d=c.items.reduce((u,p)=>{let f=`${p.username}/${p.name}`;return f.length>u?f.length:u},0)+2+6;for(let u of c.items){let p=u.stats.lastRunStartedAt?tr.display(u.stats.lastRunStartedAt):"",f=u.lastRun?(()=>{if(u.lastRun.finishedAt)return me.format(u.lastRun.finishedAt.getTime()-u.lastRun.startedAt.getTime());let S=Date.now()-u.lastRun.startedAt.getTime();return`${me.format(S)}\u2026`})():"",y=u.actor?(()=>{let S=Object.entries(u.actor.taggedBuilds??{}).find(([E,C])=>C.buildNumber===u.actor.defaultRunOptions.build||E===u.actor.defaultRunOptions.build);return S?`${Q.yellow(S[0])} / ${Q.cyan(S[1].buildNumber??u.actor.defaultRunOptions.build)}`:Q.gray("Unknown")})():Q.gray("Unknown"),v=(()=>{if(u.lastRun){let E=[Pe(u.lastRun.status)];if(f&&E.push(Zm[u.lastRun.status],Q.cyan(f)),u.lastRun.finishedAt){let C=Date.now()-u.lastRun.finishedAt.getTime();C<Xm.Week?E.push(`
@@ -150,12 +150,11 @@ All other commands use these stored credentials.
150
150
  Run 'apify logout' to remove authentication.`;static group="Authentication";static interactive=!0;static interactiveNote="Prompts for an API token if not provided. To run non-interactively, pass --token <api-token>.";static examples=[{description:"Log in interactively (prompts to choose a method, then completes the flow accordingly).",command:"apify login"},{description:"Log in non-interactively with an API token.",command:"apify login --token apify_api_xxxxx"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-login";static flags={token:w.string({char:"t",description:"Apify API token.",required:!1}),method:w.string({char:"m",description:"Method of logging in to Apify.",choices:["console","manual"],required:!1})};async run(){let{token:e,method:t}=this.flags;if(e){await ki(e);return}let o=t;if(t||(o=await ze({message:"Choose how you want to log in to Apify",choices:[{value:"console",name:"Through Apify Console in your default browser",short:"Through Apify Console"},{value:"manual",name:"Enter API token manually",short:"Manually"}],loop:!0})),o==="console"){let s,i=Pi();i.use(Ou({origin:Du,allowedHeaders:["Content-Type","Authorization"]})),i.use((d,u,p)=>{u.set("Connection","close"),p()}),i.use(Pi.json());let n=Lu();i.use((d,u,p)=>{let{token:f}=d.query;if(!f){let y=d.get("Authorization");if(y){let[v,S,...E]=y.trim().split(/\s+/);v.toLowerCase()==="bearer"&&S&&E.length===0&&(f=S)}}f!==n?(u.status(401),u.send("Authorization failed")):p()});let a=Pi.Router();i.use(`/api/${Qa}`,a),a.post("/login-token",async(d,u)=>{try{if(d.body.apiToken)await ki(d.body.apiToken);else throw new Error("Request did not contain API token");u.end()}catch(p){let f=`Login to Apify failed with error: ${p.message}`;g({message:f}),u.status(500),u.send(f)}s.close()}),a.post("/exit",(d,u)=>{d.body.isWindowClosed?g({message:"Login to Apify failed, the console window was closed."}):d.body.actionCanceled?g({message:"Login to Apify failed, the action was canceled in the Apify Console."}):g({message:"Login to Apify failed."}),u.end(),s.close()}),s=i.listen(0);let{port:c}=s.address(),l=new URL(Oi);l.searchParams.set("localCliCommand","login"),l.searchParams.set("localCliPort",`${c}`),l.searchParams.set("localCliToken",n),l.searchParams.set("localCliApiVersion",Qa);try{l.searchParams.set("localCliComputerName",encodeURIComponent(ku()))}catch{}b({message:`Opening Apify Console at "${l.href}"...`}),await Nu(l.href)}else{console.log("Enter your Apify API token. You can find it at https://console.apify.com/settings/integrations");let s=await Za({message:"token:"});await ki(s)}}};var Vt=class extends h{static name="logout";static description=`Removes authentication by deleting your API token and account information from '${le(ge())}'.
151
151
  Run 'apify login' to authenticate again.`;static group="Authentication";static examples=[{description:"Remove the stored Apify credentials.",command:"apify logout"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-logout";async run(){await Yt(ge()),await Gr(null),R({message:"You are logged out from your Apify account."})}};var Po=class extends h{static name="token";static description="Prints the current API token for the Apify CLI.";static examples=[{description:"Print the stored API token to stdout (use with care \u2014 it is a secret).",command:"apify auth token"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-auth-token";async run(){await I();let e=await M();e.token&&$({message:e.token,stdout:!0})}};var ko=class extends h{static name="auth";static description="Log in, log out, and inspect your stored Apify API token. Also available as `apify login` / `apify logout`.";static group="Authentication";static docsUrl="https://docs.apify.com/cli/docs/reference#apify-auth";static subcommands=[Bt,Vt,Po];async run(){this.printHelp()}};import Oo from"chalk";var No=class extends h{static name="add-tag";static description="Adds a tag to a specific Actor build.";static examples=[{description:'Tag a successful build as "latest".',command:"apify builds add-tag --build <buildId> --tag latest"},{description:'Tag a build with a custom name like "beta".',command:"apify builds add-tag --build <buildId> --tag beta"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-builds-add-tag";static flags={build:w.string({char:"b",description:"The build ID to tag.",required:!0}),tag:w.string({char:"t",description:"The tag to add to the build.",required:!0})};async run(){let{build:e,tag:t}=this.flags,o=await I(),s=await o.build(e).get();if(!s){g({message:`Build with ID "${e}" was not found on your account.`,stdout:!0});return}if(s.status!=="SUCCEEDED"){g({message:`Build with ID "${e}" has status "${s.status}". Only successful builds can be tagged.`,stdout:!0});return}let i=await o.actor(s.actId).get();if(!i){g({message:`Actor with ID "${s.actId}" was not found.`,stdout:!0});return}let a=(i.taggedBuilds??{})[t];if(a?.buildId===e){x({message:`Build "${e}" is already tagged as "${t}".`,stdout:!0});return}try{await o.actor(s.actId).update({taggedBuilds:{[t]:{buildId:s.id}}});let c=a?.buildNumber?` (previously pointed to build ${Oo.gray(a.buildNumber)})`:"";R({message:`Tag "${Oo.yellow(t)}" added to build ${Oo.gray(s.buildNumber)} (${Oo.gray(e)})${c}`,stdout:!0})}catch(c){let l=c;g({message:`Failed to add tag "${t}" to build "${e}".
152
152
  ${l.message||l}`,stdout:!0})}}};import te from"chalk";var Uu=m(r=>r,"noColor");function ee({bytes:r,shortBytes:e=!1,colorFunc:t=Uu,precision:o=2}){let s=[e?"B":"Bytes","KB","MB","GB","TB"];if(r===0)return e?`${0 .toPrecision(o)} B`:`${0 .toPrecision(o)} Byte`;let i=Math.floor(Math.log(r)/Math.log(1e3));return`${(r/1e3**i).toFixed(o)} ${t(s[i])}`}m(ee,"prettyPrintBytes");var Lo=class extends h{static name="info";static description="Prints information about a specific build.";static examples=[{description:"Print information about a build.",command:"apify builds info <buildId>"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-builds-info";static args={buildId:A.string({required:!0,description:"The build ID to get information about."})};static enableJsonFlag=!0;async run(){let{buildId:e}=this.args,t=await I(),o=await t.build(e).get();if(!o){g({message:`Build with ID "${e}" was not found on your account.`,stdout:!0});return}if(this.flags.json){L(o);return}let s=await t.actor(o.actId).get(),i;if(s?.taggedBuilds){for(let[f,y]of Object.entries(s.taggedBuilds))if(y.buildId===o.id){i=f;break}}let n=Reflect.get(o,"exitCode"),a=s?.username?`${s.username}/${s.name}`:s?.name??"unknown-actor",c=i?` (tagged as ${te.yellow(i)})`:"",l=typeof n<"u"?` (exit code: ${te.gray(n)})`:"",d=[`${te.yellow("Actor")}: ${a} (${te.gray(o.actId)})`,"",`${te.yellow("Build Information")} (ID: ${te.gray(o.id)})`,` ${te.yellow("Build Number")}: ${o.buildNumber}${c}`,` ${te.yellow("Status")}: ${Pe(o.status)}${l}`,` ${te.yellow("Started")}: ${Y.display(o.startedAt)}`];if(o.finishedAt)d.push(` ${te.yellow("Finished")}: ${Y.display(o.finishedAt)} (took ${te.gray(rr.format(o.stats?.durationMillis??0))})`);else{let f=Date.now()-o.startedAt.getTime();d.push(` ${te.yellow("Finished")}: ${te.gray(`Running for ${rr.format(f)}`)}`)}o.stats?.computeUnits&&d.push(` ${te.yellow("Compute Units")}: ${o.stats.computeUnits.toFixed(3)}`);let u=Reflect.get(o.stats??{},"imageSizeBytes");u&&d.push(` ${te.yellow("Docker Image Size")}: ${ee({bytes:u})}`),d.push(` ${te.yellow("Origin")}: ${o.meta.origin??"UNKNOWN"}`),d.push("");let p=`https://console.apify.com/actors/${o.actId}/builds/${o.buildNumber}`;d.push(`${te.blue("View in Apify Console")}: ${p}`),$({message:d.join(`
153
- `),stdout:!0})}};var Do=class extends h{static name="log";static description="Prints the log of a specific build.";static examples=[{description:"Print the build log.",command:"apify builds log <buildId>"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-builds-log";static args={buildId:A.string({required:!0,description:"The build ID to get the log from."})};async run(){let{buildId:e}=this.args,t=await I(),o=await t.build(e).get();if(!o){g({message:`Build with ID "${e}" was not found on your account.`,stdout:!0});return}b({message:`Log for build with ID "${e}":
154
- `});try{await ke({job:o,apifyClient:t})}catch(s){g({message:`Failed to get log for build with ID "${e}": ${s.message}`,stdout:!0})}}};import ve from"chalk";var Mu=m(()=>new B({allColumns:["Number","ID","Status","Took"],mandatoryColumns:["Number","ID","Status","Took"],columnAlignments:{Took:"right"}}),"tableFactory"),Fo=class extends h{static name="ls";static description="Lists all builds of the Actor.";static examples=[{description:"List builds of the Actor in the current directory.",command:"apify builds ls"},{description:"List builds of a specific Actor.",command:"apify builds ls apify/hello-world"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-builds-ls";static flags={offset:w.integer({description:"Number of builds that will be skipped.",default:0}),limit:w.integer({description:"Number of builds that will be listed.",default:10}),desc:w.boolean({description:"Sort builds in descending order.",default:!1}),compact:w.boolean({description:"Display a compact table.",default:!1,char:"c"})};static args={actorId:A.string({description:"Optional Actor ID or Name to list runs for. By default, it will use the Actor from the current directory."})};static enableJsonFlag=!0;async run(){let{desc:e,limit:t,offset:o,compact:s,json:i}=this.flags,{actorId:n}=this.args,a=await I(),c=await Je({providedActorNameOrId:n,client:a});if(!c.valid){g({message:`${c.reason}. Please run this command in an Actor directory, or specify the Actor ID.`,stdout:!0});return}let l=await a.actor(c.id).builds().list({desc:e,limit:t,offset:o}),d=await a.actor(c.id).get(),u=Vr(l.items,y=>{let v=Reflect.get(y,"buildNumber"),[S,E]=v.split(".");return`${S}.${E}`}),p=Object.entries(d.taggedBuilds??{}).reduce((y,[v,S])=>(y[S.buildNumber]=v,y),{});if(i){for(let y of l.items){let v=Reflect.get(y,"buildNumber"),S=p[v];S&&Reflect.set(y,"buildTag",S)}L(l);return}$({message:`${ve.reset("Showing")} ${ve.yellow(l.items.length)} out of ${ve.yellow(l.total)} builds for Actor ${ve.yellow(c.userFriendlyId)} (${ve.gray(c.id)})
153
+ `),stdout:!0})}};var Do=class extends h{static name="log";static description="Prints the log of a specific build.";static examples=[{description:"Print the build log.",command:"apify builds log <buildId>"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-builds-log";static args={buildId:A.string({required:!0,description:"The build ID to get the log from."})};async run(){let{buildId:e}=this.args,t=await I(),o=await t.build(e).get();if(!o)throw new Error(`Build with ID "${e}" was not found on your account.`);b({message:`Log for build with ID "${e}":
154
+ `}),await ke({job:o,apifyClient:t})}};import ve from"chalk";var Mu=m(()=>new B({allColumns:["Number","ID","Status","Took"],mandatoryColumns:["Number","ID","Status","Took"],columnAlignments:{Took:"right"}}),"tableFactory"),Fo=class extends h{static name="ls";static description="Lists all builds of the Actor.";static examples=[{description:"List builds of the Actor in the current directory.",command:"apify builds ls"},{description:"List builds of a specific Actor.",command:"apify builds ls apify/hello-world"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-builds-ls";static flags={offset:w.integer({description:"Number of builds that will be skipped.",default:0}),limit:w.integer({description:"Number of builds that will be listed.",default:10}),desc:w.boolean({description:"Sort builds in descending order.",default:!1}),compact:w.boolean({description:"Display a compact table.",default:!1,char:"c"})};static args={actorId:A.string({description:"Optional Actor ID or Name to list runs for. By default, it will use the Actor from the current directory."})};static enableJsonFlag=!0;async run(){let{desc:e,limit:t,offset:o,compact:s,json:i}=this.flags,{actorId:n}=this.args,a=await I(),c=await Je({providedActorNameOrId:n,client:a});if(!c.valid){g({message:`${c.reason}. Please run this command in an Actor directory, or specify the Actor ID.`,stdout:!0});return}let l=await a.actor(c.id).builds().list({desc:e,limit:t,offset:o}),d=await a.actor(c.id).get(),u=Vr(l.items,y=>{let v=Reflect.get(y,"buildNumber"),[S,E]=v.split(".");return`${S}.${E}`}),p=Object.entries(d.taggedBuilds??{}).reduce((y,[v,S])=>(y[S.buildNumber]=v,y),{});if(i){for(let y of l.items){let v=Reflect.get(y,"buildNumber"),S=p[v];S&&Reflect.set(y,"buildTag",S)}L(l);return}$({message:`${ve.reset("Showing")} ${ve.yellow(l.items.length)} out of ${ve.yellow(l.total)} builds for Actor ${ve.yellow(c.userFriendlyId)} (${ve.gray(c.id)})
155
155
  `,stdout:!0});let f=Object.entries(u).sort((y,v)=>y[0].localeCompare(v[0]));for(let[y,v]of f){if(!v?.length){$({message:`No builds for version ${y}`,stdout:!0});continue}let S=d.versions.find(N=>N.versionNumber===y)?.buildTag,E=this.generateTableForActorVersion({buildsForVersion:v,buildTagToActorVersion:p}),C=S?` (latest build gets tagged with ${ve.yellow(S)})`:"",P=[ve.reset(`Builds for Actor Version ${ve.yellow(y)}${C}`),E.render(s?0:-1),""];$({message:P.join(`
156
156
  `),stdout:!0})}}generateTableForActorVersion({buildsForVersion:e,buildTagToActorVersion:t}){let o=Mu();for(let s of e){let i=Reflect.get(s,"buildNumber"),n=t[i]?` (${ve.yellow(t[i])})`:"",a;if(s.finishedAt){let c=s.finishedAt.getTime()-s.startedAt.getTime();a=ve.gray(`${me.format(c,void 0,{left:""})}`)}else{let c=Date.now()-s.startedAt.getTime();a=ve.gray(`Running for ${me.format(c,void 0,{left:""})}`)}o.pushRow({Number:`${i}${n}`,ID:ve.gray(s.id),Status:Pe(s.status),Took:a})}return o}};import hr from"chalk";var Uo=class extends h{static name="remove-tag";static description="Removes a tag from a specific Actor build.";static examples=[{description:"Remove a tag from a build (prompts for confirmation).",command:"apify builds remove-tag --build <buildId> --tag beta"},{description:"Remove a tag non-interactively.",command:"apify builds remove-tag --build <buildId> --tag beta --yes"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-builds-remove-tag";static flags={build:w.string({char:"b",description:"The build ID to remove the tag from.",required:!0}),tag:w.string({char:"t",description:"The tag to remove from the build.",required:!0}),...ie()};async run(){let{build:e,tag:t,yes:o}=this.flags,s=await I(),i=await s.build(e).get();if(!i){g({message:`Build with ID "${e}" was not found on your account.`,stdout:!0});return}let n=await s.actor(i.actId).get();if(!n){g({message:`Actor with ID "${i.actId}" was not found.`,stdout:!0});return}let c=(n.taggedBuilds??{})[t];if(!c){g({message:`Tag "${t}" does not exist on Actor "${n.name}".`,stdout:!0});return}if(c.buildId!==e){g({message:`Tag "${t}" is not associated with build "${e}". It points to build "${c.buildNumber}" (${c.buildId}).`,stdout:!0});return}if(!await Z({message:`Are you sure you want to remove tag "${hr.yellow(t)}" from build ${hr.gray(i.buildNumber)}?`,providedConfirmFromStdin:o||void 0})){b({message:"Tag removal was canceled.",stdout:!0});return}try{await s.actor(i.actId).update({taggedBuilds:{[t]:null}}),R({message:`Tag "${hr.yellow(t)}" removed from build ${hr.gray(i.buildNumber)} (${hr.gray(e)})`,stdout:!0})}catch(d){let u=d;g({message:`Failed to remove tag "${t}" from build "${e}".
157
- ${u.message||u}`,stdout:!0})}}};import ju from"@inquirer/input";var ec=Oe(async({message:r,expectedValue:e,failureMessage:t})=>await ju({message:r,validate(s){return s===e?!0:t??"That is not the correct input!"}}));var Mo=class extends h{static name="rm";static description="Permanently removes an Actor build from the Apify platform.";static interactive=!0;static interactiveNote="Prompts for confirmation before deleting. Tagged builds additionally require typing the tag name.";static examples=[{description:"Delete a build (prompts for confirmation).",command:"apify builds rm <buildId>"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-builds-rm";static args={buildId:A.string({description:"The build ID to delete.",required:!0})};static flags={...ie()};async run(){let{buildId:e}=this.args,{yes:t}=this.flags,o=await I(),s=await o.build(e).get();if(!s){g({message:`Build with ID "${e}" was not found on your account.`,stdout:!0});return}let i=await o.actor(s.actId).get(),n;if(i?.taggedBuilds){for(let[c,l]of Object.entries(i.taggedBuilds))if(e===l.buildId){n=c;break}}let a;if(n?a=await ec({message:`Are you sure you want to delete this Actor Build? If so, please type in "${n}":`,expectedValue:n,failureMessage:"Your provided value does not match the build tag.",providedConfirmFromStdin:t?n:void 0}):a=await Z({message:"Are you sure you want to delete this Actor Build?",providedConfirmFromStdin:t||void 0}),!a){b({message:`Deletion of build "${e}" was canceled.`,stdout:!0});return}try{await o.build(e).delete(),R({message:`Build with ID "${e}" was deleted.`,stdout:!0})}catch(c){let l=c;g({message:`Failed to delete build "${e}".
158
- ${l.message||l}`,stdout:!0})}}};var jo=class extends h{static name="builds";static description="Create, inspect, tag, and delete Actor builds on the Apify platform.";static group="Apify Console";static docsUrl="https://docs.apify.com/cli/docs/reference#apify-builds";static subcommands=[No,Uo,Mo,Fo,Do,Lo,Nt];async run(){this.printHelp()}};var Bo=class extends Ke{static name="call"};import Bu from"assert";import{existsSync as tc,openSync as Vu}from"fs";import{mkdir as rc,readFile as Gu,symlink as Yu,unlink as Hu,writeFile as oc}from"fs/promises";import{homedir as Ju}from"os";import{dirname as qu,join as Xe}from"path";import{ReadStream as Ku}from"tty";import H from"chalk";import sc from"which";var Wu=m(r=>Xe(r,".install-marker"),"pathToInstallMarker"),ic=m(()=>process.env.HOME??Ju(),"HOMEDIR"),yr=class extends h{static name="install";static description="Finalizes the first-time setup of Apify and Actor CLI.";static hidden=!0;async run(){let{installMethod:e,installPath:t,version:o}=z();if(e!=="bundle"){b({message:"Apify and Actor CLI are already fully configured! \u{1F44D}"});return}Bu(t,"When CLI is installed via bundles, the install path must be set");let s=Wu(t);if(tc(s)){b({message:"Apify and Actor CLI are already fully configured! \u{1F44D}"});return}if(process.platform!=="win32"){await this.symlinkToLocalBin(t);try{await this.promptAddToShell()}catch(i){g({message:i.message||"Failed to automatically handle shell integration"})}$({message:""})}await oc(s,o),T("[install] install marker written to",s),$({message:["",H.green("Apify and Actor CLI were installed successfully!"),"",H.gray(` Version: ${H.green(o)}`),H.gray(` Location: ${H.bold.white(le(Xe(t,"apify")))} and ${H.bold.white(le(Xe(t,"actor")))}`)].join(`
157
+ ${u.message||u}`,stdout:!0})}}};import ju from"@inquirer/input";var ec=Oe(async({message:r,expectedValue:e,failureMessage:t})=>await ju({message:r,validate(s){return s===e?!0:t??"That is not the correct input!"}}));var Mo=class extends h{static name="rm";static description="Permanently removes an Actor build from the Apify platform.";static interactive=!0;static interactiveNote="Prompts for confirmation before deleting. Tagged builds additionally require typing the tag name.";static examples=[{description:"Delete a build (prompts for confirmation).",command:"apify builds rm <buildId>"}];static docsUrl="https://docs.apify.com/cli/docs/reference#apify-builds-rm";static args={buildId:A.string({description:"The build ID to delete.",required:!0})};static flags={...ie()};async run(){let{buildId:e}=this.args,{yes:t}=this.flags,o=await I(),s=await o.build(e).get();if(!s)throw new Error(`Build with ID "${e}" was not found on your account.`);let i=await o.actor(s.actId).get(),n;if(i?.taggedBuilds){for(let[c,l]of Object.entries(i.taggedBuilds))if(e===l.buildId){n=c;break}}let a;if(n?a=await ec({message:`Are you sure you want to delete this Actor Build? If so, please type in "${n}":`,expectedValue:n,failureMessage:"Your provided value does not match the build tag.",providedConfirmFromStdin:t?n:void 0}):a=await Z({message:"Are you sure you want to delete this Actor Build?",providedConfirmFromStdin:t||void 0}),!a){b({message:`Deletion of build "${e}" was canceled.`,stdout:!0});return}await o.build(e).delete(),R({message:`Build with ID "${e}" was deleted.`,stdout:!0})}};var jo=class extends h{static name="builds";static description="Create, inspect, tag, and delete Actor builds on the Apify platform.";static group="Apify Console";static docsUrl="https://docs.apify.com/cli/docs/reference#apify-builds";static subcommands=[No,Uo,Mo,Fo,Do,Lo,Nt];async run(){this.printHelp()}};var Bo=class extends Ke{static name="call"};import Bu from"assert";import{existsSync as tc,openSync as Vu}from"fs";import{mkdir as rc,readFile as Gu,symlink as Yu,unlink as Hu,writeFile as oc}from"fs/promises";import{homedir as Ju}from"os";import{dirname as qu,join as Xe}from"path";import{ReadStream as Ku}from"tty";import H from"chalk";import sc from"which";var Wu=m(r=>Xe(r,".install-marker"),"pathToInstallMarker"),ic=m(()=>process.env.HOME??Ju(),"HOMEDIR"),yr=class extends h{static name="install";static description="Finalizes the first-time setup of Apify and Actor CLI.";static hidden=!0;async run(){let{installMethod:e,installPath:t,version:o}=z();if(e!=="bundle"){b({message:"Apify and Actor CLI are already fully configured! \u{1F44D}"});return}Bu(t,"When CLI is installed via bundles, the install path must be set");let s=Wu(t);if(tc(s)){b({message:"Apify and Actor CLI are already fully configured! \u{1F44D}"});return}if(process.platform!=="win32"){await this.symlinkToLocalBin(t);try{await this.promptAddToShell()}catch(i){g({message:i.message||"Failed to automatically handle shell integration"})}$({message:""})}await oc(s,o),T("[install] install marker written to",s),$({message:["",H.green("Apify and Actor CLI were installed successfully!"),"",H.gray(` Version: ${H.green(o)}`),H.gray(` Location: ${H.bold.white(le(Xe(t,"apify")))} and ${H.bold.white(le(Xe(t,"actor")))}`)].join(`
159
158
  `)}),$({message:""}),R({message:"To get started, run:"}),$({message:H.white.bold(` apify --help
160
159
  actor --help`)})}async symlinkToLocalBin(e){let t=ic();if(T("[install -> symlinkToLocalBin] user home directory",t),!t){T("[install -> symlinkToLocalBin] user home directory not found"),x({message:H.gray("User home directory not found, cannot symlink to ~/.local/bin")});return}let o=Xe(t,".local","bin");await rc(o,{recursive:!0});let s=["apify","actor","apify-cli"];for(let i of s){let n=Xe(e,i);if(!tc(n)){T("[install] file not found for symlinking",i,n),x({message:H.gray(`Bundle not found for symlinking: ${i}`)});continue}let a=Xe(o,i);await Hu(a).catch(()=>{}),await Yu(n,a),T("[install] symlink created for item",i,a)}b({message:H.gray(`Symlinked apify, actor, and apify-cli to ${le(o)}`)})}async confirmFromTty(e){let t,o,s=`${H.green("?")} ${H.bold(e)} ${H.dim("(Y/n)")} `,i=m(n=>{process.stdout.write(`\r\x1B[2K${H.green("?")} ${H.bold(e)} ${H.cyan(n)}
161
160
  `)},"writeDone");try{return T("[install] opening /dev/tty for raw mode"),t=Vu("/dev/tty","r"),o=new Ku(t),process.stdout.write(s),o.setRawMode(!0),o.resume(),await new Promise(a=>{let c=m(l=>{let d=l.toString();d==="y"||d==="Y"||d==="\r"||d===`
@@ -304,4 +303,4 @@ Customize with --memory and --timeout flags.
304
303
  4. INPUT_SCHEMA.json
305
304
 
306
305
  Optionally specify custom schema path to validate.`;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:A.string({required:!1,description:"Optional path to your INPUT_SCHEMA.json file. If not provided ./INPUT_SCHEMA.json is used."})};static hiddenAliases=["vis"];async run(){await po({forcePath:this.args.path,cwd:nf.cwd(),getMessage:m(e=>e?`Validating input schema at ${e}`:`Validating input schema embedded in '${D}'`,"getMessage")}),R({message:"Input schema is valid."})}};var lN=[wo,xo,ko,jo,Qo,hs,bs,Ds,js,Vs,Tr,_o,Bo,wr,yr,Go,es,rs,ns,is,ys,ws,As,vs,Es,Hs,Ar],dN=[Ot,kt,Pt,_t,xt,Tt,St,Rt,Ar,wr,yr,Tr];export{xw as a,_w as b,lN as c,dN as d};
307
- //# sourceMappingURL=chunk-XLY3B6IF.js.map
306
+ //# sourceMappingURL=chunk-DAGVJNAI.js.map