apify-cli 0.21.10-beta.14 → 0.21.10-beta.15

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-ZRI7FEJN.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-VTIADQJA.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-ZRI7FEJN.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-VTIADQJA.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 Na=Object.defineProperty;var u=(r,e)=>Na(r,"name",{value:e,configurable:!0});import Se from"process";import{parseArgs as Vi}from"util";import vr from"chalk";import{satisfies as Xc}from"semver";import fs from"chalk";import _c from"indent-string";import Rc from"widest-line";import Oc from"wrap-ansi";import ct from"chalk";function We(r){r.stdoutOutput&&console.log(...r.stdoutOutput),r.stderrOutput&&console.error(...r.stderrOutput)}u(We,"internalLog");function R(r){We({[r.stdout?"stdoutOutput":"stderrOutput"]:[r.message]})}u(R,"simpleLog");function p(r){We({[r.stdout?"stdoutOutput":"stderrOutput"]:[ct.red("Error:"),r.message]})}u(p,"error");function O(r){We({[r.stdout?"stdoutOutput":"stderrOutput"]:[ct.yellow.bold("Warning:"),r.message]})}u(O,"warning");function _(r){We({[r.stdout?"stdoutOutput":"stderrOutput"]:[ct.green("Success:"),r.message]})}u(_,"success");function ge(r){We({[r.stdout?"stdoutOutput":"stderrOutput"]:[ct.gray("Run:"),r.message]})}u(ge,"run");function v(r){We({[r.stdout?"stdoutOutput":"stderrOutput"]:[ct.white("Info:"),r.message]})}u(v,"info");function zs(r){We({[r.stdout?"stdoutOutput":"stderrOutput"]:[ct.blue(r.message),r.url]})}u(zs,"link");import Y from"chalk";import{realpathSync as Pa}from"fs";import{dirname as La}from"path";var Xs="0.0.0";var Da="0.21.10-beta.14",Fa="a57ae506f02dbf16dc6d8ea768ba12de765d763a";function ka(){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 O({message:"Failed to detect install method of CLI, assuming npm"}),"npm";let e=Pa(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"}u(ka,"detectInstallMethod");function Ua(){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}}u(Ua,"getRuntimeInfo");var Et=null;function X(){if(Et)return Et;let r=ka(),e=Ua();return Et={version:Da,hash:Fa,arch:process.env.APIFY_BUNDLE_ARCH??process.arch,platform:process.platform==="win32"?"windows":process.platform,runtime:e.runtime,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}-${e.version}${this.extraRuntimeData?` ${this.extraRuntimeData}`:""}, installed via ${this.installMethod}`}},r==="bundle"&&(Et.installPath=La(process.execPath)),Et}u(X,"useCLIMetadata");import Ut from"chalk";import Oi from"indent-string";import xi from"widest-line";import Ni from"wrap-ansi";import{createWriteStream as Xa,existsSync as ce,mkdirSync as Za,readdirSync as li,readFileSync as xt,writeFileSync as ir}from"fs";import{mkdir as Qa,readFile as ec}from"fs/promises";import{get as tc}from"https";import{dirname as ui,join as ye}from"path";import ae from"process";import{finished as rc}from"stream/promises";import{DurationFormatter as di,TimeTypes as Qe}from"@sapphire/duration";import{Timestamp as is}from"@sapphire/timestamp";import oc from"adm-zip";import sc from"ajv/dist/2019.js";import{ApifyClient as mi}from"apify-client";import ic from"archiver";import{AxiosHeaders as nc}from"axios";import ac from"escape-string-regexp";import{globby as pi}from"globby";import{getEncoding as cc}from"istextorbinary";import{Mime as lc}from"mime";import uc from"mime/types/other.js";import dc from"mime/types/standard.js";import{gte as mc,minVersion as pc,satisfies as fc}from"semver";import{ACTOR_ENV_VARS as ns,ACTOR_JOB_TERMINAL_STATUSES as gc,ACTOR_NAME as Ot,APIFY_ENV_VARS as hc,KEY_VALUE_STORE_KEYS as ci,LOCAL_ACTOR_ENV_VARS as as,LOCAL_STORAGE_SUBDIRS as cs,SOURCE_FILE_FORMATS as Rt}from"@apify/consts";import{homedir as ja}from"os";import{join as ze}from"path";import{KEY_VALUE_STORE_KEYS as Ba,META_ORIGINS as Va}from"@apify/consts";var Zs={name:"apify-cli",version:"0.21.10-beta.14",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","test:api":"vitest run --testNamePattern '\\[api\\]'","test:python":"vitest run --testNamePattern '\\[python\\]'","test:cucumber":'cross-env NODE_OPTIONS="--import tsx" cucumber-js',lint:"eslint src test scripts features --ext .ts,.cjs,.mjs","lint:fix":"eslint src test scripts features --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.');"`},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:">=18"},dependencies:{"@apify/actor-templates":"^0.1.5","@apify/consts":"^2.36.0","@apify/input_schema":"^3.17.0","@apify/utilities":"^2.15.1","@crawlee/memory-storage":"^3.12.0","@inquirer/core":"^10.1.15","@inquirer/input":"^4.2.1","@inquirer/password":"^4.0.17","@inquirer/select":"^4.3.1","@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.17.1","apify-client":"^2.12.6",archiver:"~7.0.1",axios:"^1.11.0",chalk:"~5.5.0","cli-table3":"^0.6.5","computer-name":"~0.1.0",configparser:"~0.3.10",cors:"~2.8.5","detect-indent":"~7.0.1","escape-string-regexp":"~5.0.0",execa:"^9.5.2",express:"~5.1.0",globby:"~14.1.0",handlebars:"~4.7.8","indent-string":"^5.0.0","is-ci":"~4.1.0",istextorbinary:"~9.5.0",jju:"~1.4.0","js-levenshtein":"^1.1.6","lodash.clonedeep":"^4.5.0",mime:"~4.0.4",mixpanel:"~0.18.0",open:"~10.2.0",ow:"~2.0.0",rimraf:"~6.0.1",semver:"~7.7.0","string-width":"^7.2.0","strip-ansi":"^7.1.0",tiged:"~2.12.7",which:"^5.0.0","widest-line":"^5.0.0","wrap-ansi":"^9.0.0"},devDependencies:{"@apify/eslint-config":"^1.0.0","@apify/tsconfig":"^0.1.1","@biomejs/biome":"^2.0.0","@crawlee/types":"^3.11.1","@cucumber/cucumber":"^12.0.0","@types/adm-zip":"^0.5.5","@types/archiver":"^6.0.2","@types/bun":"^1.2.5","@types/chai":"^4.3.17","@types/cors":"^2.8.17","@types/execa":"^2.0.2","@types/express":"^5.0.0","@types/fs-extra":"^11","@types/is-ci":"^3.0.4","@types/jju":"^1.4.5","@types/js-levenshtein":"^1","@types/lodash.clonedeep":"^4","@types/mime":"^4.0.0","@types/node":"^22.0.0","@types/semver":"^7.5.8","@types/which":"^3.0.4","@yarnpkg/core":"^4.1.2",apify:"^3.2.4",chai:"^4.4.1","cross-env":"^10.0.0",eslint:"^9.25.1","eslint-config-prettier":"^10.1.2","lint-staged":"^16.0.0","mdast-util-from-markdown":"^2.0.2","mock-stdin":"^1.0.0",prettier:"^3.5.3",tsup:"^8.5.0",tsx:"^4.16.5",typescript:"^5.8.3","typescript-eslint":"^8.31.0",vitest:"^3.0.0"},volta:{node:"22.18.0",yarn:"4.9.2"},packageManager:"yarn@4.9.2",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"}};var Xe="storage",ts="apify_storage",rs=1,er={actorSpecification:rs,name:null,version:"0.0",buildTag:"latest",environmentVariables:{}},Qs={SCRAPY:"scrapy",CRAWLEE:"crawlee",PRE_CRAWLEE_APIFY_SDK:"apify",UNKNOWN:"unknown"},ei=1440*60*1e3,lt=u(()=>{let r=ze(ja(),".apify");return process.env.__APIFY_INTERNAL_TEST_AUTH_PATH__?ze(r,process.env.__APIFY_INTERNAL_TEST_AUTH_PATH__):r},"GLOBAL_CONFIGS_FOLDER"),ne=u(()=>ze(lt(),"auth.json"),"AUTH_FILE_PATH"),tr=u(()=>ze(lt(),"secrets.json"),"SECRETS_FILE_PATH"),rr=u(()=>ze(lt(),"state.json"),"STATE_FILE_PATH"),De=u(()=>ze(lt(),"telemetry.json"),"TELEMETRY_FILE_PATH"),or="apify.json",os=".actor",Ya="actor.json",j=ze(os,Ya),ss=new RegExp(`^${Ba.INPUT}\\..*`),he=Zs.engines.node,ti={"X-Apify-Request-Origin":Va.CLI},Ze="3.9.0",ri=".venv",oi="ea75e434d4b4d2405d79ed9d14bfc93b";import{existsSync as Ga,mkdirSync as Ha}from"fs";import{readFile as Ja,stat as si,unlink as Ka,writeFile as qa}from"fs/promises";import{join as ii,sep as Wa}from"path";import{rimraf as za}from"rimraf";var ni=u(async(r,e={},t=null)=>{let o=await Ja(r,"utf-8"),s=JSON.parse(o),i;t?(i=s,i[t]={...s[t],...e}):i={...s,...e},await qa(r,JSON.stringify(i,null," "))},"updateLocalJson"),sr=u((r,e)=>{e||(e=r,r="."),e.split(Wa).reduce((o,s)=>(o=ii(o,s),Ga(o)||Ha(o),o),r)},"ensureFolderExistsSync"),$t=u(async r=>{await za(r)},"rimrafPromised"),_t=u(async r=>{(await si(r)).isFile()&&await Ka(r)},"deleteFile"),ai=u(async(r,e)=>(await Promise.all(r.map(async s=>si(ii(e,s))))).map(s=>s.size).reduce((s,i)=>s+i,0),"sumFilesSizeInBytes");var ut=sc,nr=u(async r=>new Promise((e,t)=>{tc(r,o=>{o.statusCode===301||o.statusCode===302?(e(nr(o.headers.location)),o.destroy()):e(o)}).on("error",t)}),"httpsGet"),le=u(()=>{let r=hc.LOCAL_STORAGE_DIR;return ae.env[r]||ae.env.CRAWLEE_STORAGE_DIR||Xe},"getLocalStorageDir"),Te=u(r=>{let e=ns.DEFAULT_KEY_VALUE_STORE_ID,t=r||ae.env[e]||as[e];return ye(le(),cs.keyValueStores,t)},"getLocalKeyValueStorePath"),fi=u(r=>{let e=ns.DEFAULT_DATASET_ID,t=r||ae.env[e]||as[e];return ye(le(),cs.datasets,t)},"getLocalDatasetPath"),gi=u(r=>{let e=ns.DEFAULT_REQUEST_QUEUE_ID,t=r||ae.env[e]||as[e];return ye(le(),cs.requestQueues,t)},"getLocalRequestQueuePath"),F=u(async()=>{let r={};try{let e=await ec(ne(),"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 C(){let r=await Nt();if(!r)throw new Error('You are not logged in with your Apify account. Call "apify login" to fix that.');return r}u(C,"getLoggedClientOrThrow");var hi=u(r=>{if(!r&&ce(lt())&&ce(ne())){let e=xt(ne(),"utf-8");return JSON.parse(e).token}return r},"getTokenWithAuthFileFallback"),ls=u((r,e)=>(r=hi(r),{token:r,baseUrl:e||ae.env.APIFY_CLIENT_BASE_URL,requestInterceptors:[t=>{t.headers??=new nc;for(let[o,s]of Object.entries(ti))t.headers[o]=s;return t}]}),"getApifyClientOptions");async function Nt(r,e){r=hi(r);let t=new mi(ls(r,e)),o;try{o=await t.user("me").get()}catch{return null}return et(ne()),ir(ne(),JSON.stringify({token:t.token,...o},null," ")),t}u(Nt,"getLoggedClient");var us=u(r=>ye(r,j),"getLocalConfigPath"),Ce=u(r=>{if(ce(r))return JSON.parse(xt(r,{encoding:"utf-8"}))},"getJsonFileContent"),Fe=u(r=>Ce(us(r)),"getLocalConfig"),ar=u(async(r,e)=>{let t=ye(e||ae.cwd(),j);await Qa(ui(t),{recursive:!0}),ir(t,JSON.stringify(r,null," "))},"setLocalConfig"),yc=[le(),"node_modules",".venv"],cr=u(async r=>{let e=Te();sr(r,fi()),sr(r,gi()),sr(r,e);let t=ye(r,".gitignore"),o="";ce(t)&&(o=xt(t,{encoding:"utf-8"}));let s=[];for(let i of yc)RegExp(`^${ac(i)}$`,"mg").test(o)||s.push(i);s.length>0&&(o.length>0?(s.unshift("# Added by Apify CLI"),ir(t,`
1
+ var Na=Object.defineProperty;var u=(r,e)=>Na(r,"name",{value:e,configurable:!0});import Se from"process";import{parseArgs as Vi}from"util";import vr from"chalk";import{satisfies as Xc}from"semver";import fs from"chalk";import _c from"indent-string";import Rc from"widest-line";import Oc from"wrap-ansi";import ct from"chalk";function We(r){r.stdoutOutput&&console.log(...r.stdoutOutput),r.stderrOutput&&console.error(...r.stderrOutput)}u(We,"internalLog");function R(r){We({[r.stdout?"stdoutOutput":"stderrOutput"]:[r.message]})}u(R,"simpleLog");function p(r){We({[r.stdout?"stdoutOutput":"stderrOutput"]:[ct.red("Error:"),r.message]})}u(p,"error");function O(r){We({[r.stdout?"stdoutOutput":"stderrOutput"]:[ct.yellow.bold("Warning:"),r.message]})}u(O,"warning");function _(r){We({[r.stdout?"stdoutOutput":"stderrOutput"]:[ct.green("Success:"),r.message]})}u(_,"success");function ge(r){We({[r.stdout?"stdoutOutput":"stderrOutput"]:[ct.gray("Run:"),r.message]})}u(ge,"run");function v(r){We({[r.stdout?"stdoutOutput":"stderrOutput"]:[ct.white("Info:"),r.message]})}u(v,"info");function zs(r){We({[r.stdout?"stdoutOutput":"stderrOutput"]:[ct.blue(r.message),r.url]})}u(zs,"link");import Y from"chalk";import{realpathSync as Pa}from"fs";import{dirname as La}from"path";var Xs="0.0.0";var Da="0.21.10-beta.15",Fa="c29140ccf53be47f6f06dac82edcdf01b9a0c812";function ka(){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 O({message:"Failed to detect install method of CLI, assuming npm"}),"npm";let e=Pa(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"}u(ka,"detectInstallMethod");function Ua(){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}}u(Ua,"getRuntimeInfo");var Et=null;function X(){if(Et)return Et;let r=ka(),e=Ua();return Et={version:Da,hash:Fa,arch:process.env.APIFY_BUNDLE_ARCH??process.arch,platform:process.platform==="win32"?"windows":process.platform,runtime:e.runtime,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}-${e.version}${this.extraRuntimeData?` ${this.extraRuntimeData}`:""}, installed via ${this.installMethod}`}},r==="bundle"&&(Et.installPath=La(process.execPath)),Et}u(X,"useCLIMetadata");import Ut from"chalk";import Oi from"indent-string";import xi from"widest-line";import Ni from"wrap-ansi";import{createWriteStream as Xa,existsSync as ce,mkdirSync as Za,readdirSync as li,readFileSync as xt,writeFileSync as ir}from"fs";import{mkdir as Qa,readFile as ec}from"fs/promises";import{get as tc}from"https";import{dirname as ui,join as ye}from"path";import ae from"process";import{finished as rc}from"stream/promises";import{DurationFormatter as di,TimeTypes as Qe}from"@sapphire/duration";import{Timestamp as is}from"@sapphire/timestamp";import oc from"adm-zip";import sc from"ajv/dist/2019.js";import{ApifyClient as mi}from"apify-client";import ic from"archiver";import{AxiosHeaders as nc}from"axios";import ac from"escape-string-regexp";import{globby as pi}from"globby";import{getEncoding as cc}from"istextorbinary";import{Mime as lc}from"mime";import uc from"mime/types/other.js";import dc from"mime/types/standard.js";import{gte as mc,minVersion as pc,satisfies as fc}from"semver";import{ACTOR_ENV_VARS as ns,ACTOR_JOB_TERMINAL_STATUSES as gc,ACTOR_NAME as Ot,APIFY_ENV_VARS as hc,KEY_VALUE_STORE_KEYS as ci,LOCAL_ACTOR_ENV_VARS as as,LOCAL_STORAGE_SUBDIRS as cs,SOURCE_FILE_FORMATS as Rt}from"@apify/consts";import{homedir as ja}from"os";import{join as ze}from"path";import{KEY_VALUE_STORE_KEYS as Ba,META_ORIGINS as Va}from"@apify/consts";var Zs={name:"apify-cli",version:"0.21.10-beta.15",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","test:api":"vitest run --testNamePattern '\\[api\\]'","test:python":"vitest run --testNamePattern '\\[python\\]'","test:cucumber":'cross-env NODE_OPTIONS="--import tsx" cucumber-js',lint:"eslint src test scripts features --ext .ts,.cjs,.mjs","lint:fix":"eslint src test scripts features --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.');"`},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:">=18"},dependencies:{"@apify/actor-templates":"^0.1.5","@apify/consts":"^2.36.0","@apify/input_schema":"^3.17.0","@apify/utilities":"^2.15.1","@crawlee/memory-storage":"^3.12.0","@inquirer/core":"^10.1.15","@inquirer/input":"^4.2.1","@inquirer/password":"^4.0.17","@inquirer/select":"^4.3.1","@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.17.1","apify-client":"^2.12.6",archiver:"~7.0.1",axios:"^1.11.0",chalk:"~5.5.0","cli-table3":"^0.6.5","computer-name":"~0.1.0",configparser:"~0.3.10",cors:"~2.8.5","detect-indent":"~7.0.1","escape-string-regexp":"~5.0.0",execa:"^9.5.2",express:"~5.1.0",globby:"~14.1.0",handlebars:"~4.7.8","indent-string":"^5.0.0","is-ci":"~4.1.0",istextorbinary:"~9.5.0",jju:"~1.4.0","js-levenshtein":"^1.1.6","lodash.clonedeep":"^4.5.0",mime:"~4.0.4",mixpanel:"~0.18.0",open:"~10.2.0",ow:"~2.0.0",rimraf:"~6.0.1",semver:"~7.7.0","string-width":"^7.2.0","strip-ansi":"^7.1.0",tiged:"~2.12.7",which:"^5.0.0","widest-line":"^5.0.0","wrap-ansi":"^9.0.0"},devDependencies:{"@apify/eslint-config":"^1.0.0","@apify/tsconfig":"^0.1.1","@biomejs/biome":"^2.0.0","@crawlee/types":"^3.11.1","@cucumber/cucumber":"^12.0.0","@types/adm-zip":"^0.5.5","@types/archiver":"^6.0.2","@types/bun":"^1.2.5","@types/chai":"^4.3.17","@types/cors":"^2.8.17","@types/execa":"^2.0.2","@types/express":"^5.0.0","@types/fs-extra":"^11","@types/is-ci":"^3.0.4","@types/jju":"^1.4.5","@types/js-levenshtein":"^1","@types/lodash.clonedeep":"^4","@types/mime":"^4.0.0","@types/node":"^22.0.0","@types/semver":"^7.5.8","@types/which":"^3.0.4","@yarnpkg/core":"^4.1.2",apify:"^3.2.4",chai:"^4.4.1","cross-env":"^10.0.0",eslint:"^9.25.1","eslint-config-prettier":"^10.1.2","lint-staged":"^16.0.0","mdast-util-from-markdown":"^2.0.2","mock-stdin":"^1.0.0",prettier:"^3.5.3",tsup:"^8.5.0",tsx:"^4.16.5",typescript:"^5.8.3","typescript-eslint":"^8.31.0",vitest:"^3.0.0"},volta:{node:"22.18.0",yarn:"4.9.2"},packageManager:"yarn@4.9.2",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"}};var Xe="storage",ts="apify_storage",rs=1,er={actorSpecification:rs,name:null,version:"0.0",buildTag:"latest",environmentVariables:{}},Qs={SCRAPY:"scrapy",CRAWLEE:"crawlee",PRE_CRAWLEE_APIFY_SDK:"apify",UNKNOWN:"unknown"},ei=1440*60*1e3,lt=u(()=>{let r=ze(ja(),".apify");return process.env.__APIFY_INTERNAL_TEST_AUTH_PATH__?ze(r,process.env.__APIFY_INTERNAL_TEST_AUTH_PATH__):r},"GLOBAL_CONFIGS_FOLDER"),ne=u(()=>ze(lt(),"auth.json"),"AUTH_FILE_PATH"),tr=u(()=>ze(lt(),"secrets.json"),"SECRETS_FILE_PATH"),rr=u(()=>ze(lt(),"state.json"),"STATE_FILE_PATH"),De=u(()=>ze(lt(),"telemetry.json"),"TELEMETRY_FILE_PATH"),or="apify.json",os=".actor",Ya="actor.json",j=ze(os,Ya),ss=new RegExp(`^${Ba.INPUT}\\..*`),he=Zs.engines.node,ti={"X-Apify-Request-Origin":Va.CLI},Ze="3.9.0",ri=".venv",oi="ea75e434d4b4d2405d79ed9d14bfc93b";import{existsSync as Ga,mkdirSync as Ha}from"fs";import{readFile as Ja,stat as si,unlink as Ka,writeFile as qa}from"fs/promises";import{join as ii,sep as Wa}from"path";import{rimraf as za}from"rimraf";var ni=u(async(r,e={},t=null)=>{let o=await Ja(r,"utf-8"),s=JSON.parse(o),i;t?(i=s,i[t]={...s[t],...e}):i={...s,...e},await qa(r,JSON.stringify(i,null," "))},"updateLocalJson"),sr=u((r,e)=>{e||(e=r,r="."),e.split(Wa).reduce((o,s)=>(o=ii(o,s),Ga(o)||Ha(o),o),r)},"ensureFolderExistsSync"),$t=u(async r=>{await za(r)},"rimrafPromised"),_t=u(async r=>{(await si(r)).isFile()&&await Ka(r)},"deleteFile"),ai=u(async(r,e)=>(await Promise.all(r.map(async s=>si(ii(e,s))))).map(s=>s.size).reduce((s,i)=>s+i,0),"sumFilesSizeInBytes");var ut=sc,nr=u(async r=>new Promise((e,t)=>{tc(r,o=>{o.statusCode===301||o.statusCode===302?(e(nr(o.headers.location)),o.destroy()):e(o)}).on("error",t)}),"httpsGet"),le=u(()=>{let r=hc.LOCAL_STORAGE_DIR;return ae.env[r]||ae.env.CRAWLEE_STORAGE_DIR||Xe},"getLocalStorageDir"),Te=u(r=>{let e=ns.DEFAULT_KEY_VALUE_STORE_ID,t=r||ae.env[e]||as[e];return ye(le(),cs.keyValueStores,t)},"getLocalKeyValueStorePath"),fi=u(r=>{let e=ns.DEFAULT_DATASET_ID,t=r||ae.env[e]||as[e];return ye(le(),cs.datasets,t)},"getLocalDatasetPath"),gi=u(r=>{let e=ns.DEFAULT_REQUEST_QUEUE_ID,t=r||ae.env[e]||as[e];return ye(le(),cs.requestQueues,t)},"getLocalRequestQueuePath"),F=u(async()=>{let r={};try{let e=await ec(ne(),"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 C(){let r=await Nt();if(!r)throw new Error('You are not logged in with your Apify account. Call "apify login" to fix that.');return r}u(C,"getLoggedClientOrThrow");var hi=u(r=>{if(!r&&ce(lt())&&ce(ne())){let e=xt(ne(),"utf-8");return JSON.parse(e).token}return r},"getTokenWithAuthFileFallback"),ls=u((r,e)=>(r=hi(r),{token:r,baseUrl:e||ae.env.APIFY_CLIENT_BASE_URL,requestInterceptors:[t=>{t.headers??=new nc;for(let[o,s]of Object.entries(ti))t.headers[o]=s;return t}]}),"getApifyClientOptions");async function Nt(r,e){r=hi(r);let t=new mi(ls(r,e)),o;try{o=await t.user("me").get()}catch{return null}return et(ne()),ir(ne(),JSON.stringify({token:t.token,...o},null," ")),t}u(Nt,"getLoggedClient");var us=u(r=>ye(r,j),"getLocalConfigPath"),Ce=u(r=>{if(ce(r))return JSON.parse(xt(r,{encoding:"utf-8"}))},"getJsonFileContent"),Fe=u(r=>Ce(us(r)),"getLocalConfig"),ar=u(async(r,e)=>{let t=ye(e||ae.cwd(),j);await Qa(ui(t),{recursive:!0}),ir(t,JSON.stringify(r,null," "))},"setLocalConfig"),yc=[le(),"node_modules",".venv"],cr=u(async r=>{let e=Te();sr(r,fi()),sr(r,gi()),sr(r,e);let t=ye(r,".gitignore"),o="";ce(t)&&(o=xt(t,{encoding:"utf-8"}));let s=[];for(let i of yc)RegExp(`^${ac(i)}$`,"mg").test(o)||s.push(i);s.length>0&&(o.length>0?(s.unshift("# Added by Apify CLI"),ir(t,`
2
2
  ${s.join(`
3
3
  `)}
4
4
  `,{flag:"a"})):ir(t,`${s.join(`
@@ -37,7 +37,7 @@ ${e.ambiguousMessage.split(`
37
37
  `)}`):t.push(`To solve this, provide the flag like this: --${e.name}=<value>`)):e.expectsValue?t.push("expects a value"):t.push("does not take an argument"),t.map(o=>Y.gray(o)).join(" ")}static into(e,t){if(e instanceof r)return e;if(e instanceof Error&&"code"in e){let o=e;switch(o.code){case"ERR_PARSE_ARGS_INVALID_OPTION_VALUE":return new r({code:0,message:o.message,command:t});case"ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL":return new r({code:1,message:o.message,command:t});case"ERR_PARSE_ARGS_UNKNOWN_OPTION":return new r({code:2,message:o.message,command:t});default:return new r({code:9,message:`Unknown error: ${e instanceof Error?e.message:String(e)}`,command:t})}}return new r({code:9,message:`Unknown error: ${e instanceof Error?e.message:String(e)}`,command:t})}};function Li(r){return r.replace(/[-_\s](.)/g,(e,t)=>t.toUpperCase())}u(Li,"camelCaseString");function we(r){return r.replace(/[\s_]+/g,"-")}u(we,"kebabCaseString");function Ae(r){return r.replace(/([A-Z])/g,"-$1").toLowerCase()}u(Ae,"camelCaseToKebabCase");var xc={type:"boolean",multiple:!1,short:"h"},Nc={type:"boolean",multiple:!1},q=new Map,y=class{static args;static flags;static subcommands;static enableJsonFlag=!1;static name;static shortDescription;static description;static aliases;static hidden;static hiddenAliases;telemetryData={};flags;args;entrypoint;constructor(e){this.entrypoint=e}get ctor(){return this.constructor}pluralString(e,t,o){return e===1?t:o}static printHelp(){console.log(gr(this)),process.exit(0)}printHelp(){return this.ctor.printHelp()}async _run(e){let{values:t,positionals:o,tokens:s}=e;t.help&&this.ctor.printHelp(),this.args={},this.flags={},this.ctor.enableJsonFlag&&(typeof t.json=="boolean"?this.flags.json=t.json:this.flags.json=!1);let i=new Map;if(this.ctor.args){let n=0;for(let[a,c]of Object.entries(this.ctor.args)){if(typeof c=="string")throw new RangeError("Do not provide the string for the json arg! It is a type level assertion!");let d=Li(a),l=o[n++];if(l)switch(c.argTag){case"string":default:this.args[d]=String(l),l==="-"&&c.stdin&&(this.args[d]=this._handleStdin(c.stdin)),c.catchAll&&(this.args[d]=o.slice(n-1).join(" "));break}else c.required&&i.set(a,c)}}if(i.size){this._printMissingRequiredArgs(i);return}this._parseFlags(t,s);try{await this.run()}catch(n){p({message:n.message})}finally{}}_userFlagNameToRegisteredName(e,t){let o=we(Ae(e)).toLowerCase(),s=o;o.startsWith("no-")&&(s=o.slice(3));let i=new Set;for(let n of t.aliases??[])i.add(we(Ae(n)).toLowerCase());return{baseFlagName:s,rawBaseFlagName:o,allMatchers:[s,...i]}}_commandFlagKeyToKebabCaseRegisteredName(e){let t=we(Ae(e)).toLowerCase();return t.startsWith("no-")&&(t=t.slice(3)),t}_parseFlags(e,t){if(!this.ctor.flags)return;let o=new Map,s;for(let[n,a]of Object.entries(this.ctor.flags)){if(typeof a=="string")throw new RangeError("Do not provide the string for the json arg! It is a type level assertion!");let{allMatchers:c,baseFlagName:d,rawBaseFlagName:l}=this._userFlagNameToRegisteredName(n,a),f=Li(l),m=t.some(b=>b.kind==="option"&&b.name===d);if(a.exclusive?.length){let b=o.get(d)??new Set;for(let T of a.exclusive)b.add(this._commandFlagKeyToKebabCaseRegisteredName(T));o.set(d,b);for(let T of a.exclusive){let S=this._commandFlagKeyToKebabCaseRegisteredName(T),I=o.get(S)??new Set;I.add(d),o.set(S,I)}}let g=c.filter(b=>e[b]);if(g.length>1)throw new ie({code:3,command:this.ctor,metadata:{flag:d}});let h=e[g[0]];if(!h&&a.required)throw new ie({code:6,command:this.ctor,metadata:{flag:d,matcher:g[0]}});if(Array.isArray(h)){if(h.length>1)throw new ie({code:3,command:this.ctor,metadata:{flag:d}});h=h[0]}if(m&&typeof h=="string"&&h.startsWith("=")&&(h=h.slice(1)),typeof h<"u")switch(a.flagTag){case"boolean":{this.flags[f]=l.startsWith("no-")?!h:h;break}case"integer":{let b=Number(h);if(Number.isNaN(b)||!Number.isInteger(b))throw new ie({code:4,command:this.ctor,metadata:{flag:d,value:String(h)}});this.flags[f]=b;break}case"string":default:{if(this.flags[f]=h,h==="-"&&a.stdin){if(s)throw new ie({code:8,command:this.ctor,metadata:{firstUse:s,secondUse:d}});s=d,this.flags[f]=this._handleStdin(a.stdin)}break}}else typeof a.hasDefault<"u"&&(this.flags[f]=a.hasDefault);if(this.flags[f]&&a.choices&&!a.choices.includes(this.flags[f]))throw new ie({code:5,command:this.ctor,metadata:{flag:d,choices:a.choices.map(b=>fs.white.bold(b)).join(", ")}});if(this.flags[f]==null&&(a.required||h!=null))throw new ie({code:6,command:this.ctor,metadata:{flag:d,matcher:g[0],providedButReceivedNoValue:!!h}})}let i=[];for(let[n,a]of o)if(e[n]!=null)for(let c of a){if(e[c]==null)continue;let d=e[n][0],l=e[c][0],f=u((m,g)=>typeof g=="boolean"?g?`--${m}`:`--no-${m}`:`--${m}=${g}`,"flagRepresentation");i.push([f(n,d),f(c,l)]);break}if(i.length)throw new ie({code:7,command:this.ctor,metadata:{flagPairs:i}})}_printMissingRequiredArgs(e){let t=hr(this.ctor,{showUsageString:!0}),o=Rc([...e.keys()].join(`
38
38
  `)),s=[];for(let[i,n]of e){let a=`${i.padEnd(o)} ${n.description}`,c=Oc(a,oe()-o-2),d=_c(c,o+2+2).trim();s.push(` ${fs.red(">")} ${d}`)}p({message:[`Missing ${e.size} required ${this.pluralString(e.size,"argument","arguments")}:`,...s,fs.gray(" See more help with --help"),"",t].join(`
39
39
  `)})}_handleStdin(e){switch(e){case 2:return(be?.toString("utf8")??"").trim();default:return be}}_buildParseArgsOption(){let e={allowNegative:!0,allowPositionals:!0,strict:!0,tokens:!0,options:{help:xc}};if(this.ctor.flags)for(let[t,o]of Object.entries(this.ctor.flags)){if(typeof o=="string")throw new RangeError("Do not provide the string for the json flag! It is a type level assertion!");if(t.toLowerCase()==="json")continue;let s=we(Ae(t)).toLowerCase();s.startsWith("no-")&&(s=s.slice(3));let i=o.builder(s);for(let{flagName:n,option:a}of i)e.options[n]=a}return this.ctor.enableJsonFlag&&(e.options.json=Nc),e}static registerCommand(e){if(ps(e,this),q.set(this.name,this),this.aliases?.length)for(let t of this.aliases)q.set(t,this);if(this.hiddenAliases?.length)for(let t of this.hiddenAliases)q.set(t,this);if(this.subcommands?.length)for(let t of this.subcommands){if(q.set(`${this.name} ${t.name}`,t),this.aliases?.length)for(let o of this.aliases)q.set(`${o} ${t.name}`,t);if(this.hiddenAliases?.length)for(let o of this.hiddenAliases)q.set(`${o} ${t.name}`,t);if(t.aliases?.length)for(let o of t.aliases){if(q.set(`${this.name} ${o}`,t),this.aliases?.length)for(let s of this.aliases)q.set(`${s} ${o}`,t);if(this.hiddenAliases?.length)for(let s of this.hiddenAliases)q.set(`${s} ${o}`,t)}if(t.hiddenAliases?.length)for(let o of t.hiddenAliases){if(q.set(`${this.name} ${o}`,t),this.aliases?.length)for(let s of this.aliases)q.set(`${s} ${o}`,t);if(this.hiddenAliases?.length)for(let s of this.hiddenAliases)q.set(`${s} ${o}`,t)}}}};async function Di(r,e,t){let o={positionals:[],values:{},tokens:[]},s=0;for(let[n,a]of Object.entries(t)){let[c,d]=n.split("_");if(c==="args")o.positionals[s++]=a;else{let l=we(Ae(d)).toLowerCase();l.startsWith("no-")?o.values[l.slice(3)]=!a:o.values[l]=a}}await new e(r)._run(o)}u(Di,"internalRunCommand");import{once as kc}from"events";import{constants as Fi,fstat as Lc}from"fs";import ki from"process";import{promisify as Dc}from"util";import Pc from"chalk";function E(r,...e){process.env.APIFY_CLI_DEBUG&&console.error(Pc.gray(`[${r}]`),...e)}u(E,"cliDebugPrint");var Fc=Dc(Lc),gs;async function Ar(){if(gs)return gs;let r=ki.stdin,e={isTTY:r.isTTY,hasData:!1,waitDelay:0,stream:r},t=await Fc(0).then(o=>{if(E("useStdin",{stat:o,isRegularFile:o.isFile(),isDirectory:o.isDirectory(),isBlockDevice:o.isBlockDevice(),isCharDevice:o.isCharacterDevice(),isSymbolicLink:o.isSymbolicLink(),isFIFO:o.isFIFO(),isSocket:o.isSocket()}),ki.platform==="win32"){if((o.mode&Fi.S_IFIFO)===Fi.S_IFIFO)return 100;if(o.isFile())return 50}return o.isFIFO()||o.isFile()||(o.isSocket()?50:!1)}).catch(()=>!1);return E("useStdin",{hasData:e.hasData,waitDelay:e.waitDelay,isTTY:e.isTTY,pipedIn:t,readableEnded:r.readableEnded}),(!r.isTTY||t!==!1&&(r.isTTY!==void 0||!r.readableEnded))&&(e.hasData=!0),typeof t=="number"&&(e.waitDelay=t),gs=e,e}u(Ar,"useStdin");async function Ui(){let r=await Ar(),{hasData:e,waitDelay:t,stream:o}=r;if(!e)return;let s=[],i=new AbortController,n=null;t&&(n=setTimeout(()=>{i.abort()},t).unref()),o.on("data",c=>{s.push(c),n&&(clearTimeout(n),n=null)});try{await kc(o,"end",{signal:i.signal})}catch(c){if(c.name==="AbortError")return}n&&clearTimeout(n),r.hasData=!1;let a=Buffer.concat(s);if(a.length)return a}u(Ui,"readStdin");import{gt as Hc}from"semver";import{existsSync as Uc,mkdirSync as Mc,readFileSync as jc,writeFileSync as Bc}from"fs";import{dirname as Vc}from"path";function Yc(r){if(r.version&&r.version>=1)return!1;let e=r;if(e.latestNpmVersionCheckedAt){let t=new Date(e.latestNpmVersionCheckedAt).getTime(),o=e.latestNpmVersion;E("LocalStateV0ToV1","Migrating state from v0 to v1",{oldState:r,newState:{versionCheck:{lastChecked:t,lastVersion:o}}}),ys({version:1},s=>{s.versionCheck={lastChecked:t,lastVersion:o}})}return!0}u(Yc,"migrateStateV0ToV1");var Gc={version:1};function hs(){let r=rr();if(!Uc(r))return Gc;let t=JSON.parse(jc(r,"utf-8"));return Yc(t)?hs():t}u(hs,"useLocalState");function ys(r,e){let t={...r};e(t);let o=rr(),s=Vc(o);Mc(s,{recursive:!0}),Bc(rr(),JSON.stringify(t,null," "))}u(ys,"updateLocalState");var br=X(),Mi=`Apify CLI/${br.version} (https://github.com/apify/apify-cli)`,Jc=["https://1.1.1.1","https://8.8.8.8"];async function Kc(r=500){let e=new AbortController,t=setTimeout(()=>{e.abort()},r),o=await Promise.any(Jc.map(async s=>fetch(s,{signal:e.signal,headers:{"User-Agent":Mi},keepalive:!1}))).catch(()=>null);return clearTimeout(t),o?o.ok?(E("isOnline",{state:"online",site:o.url}),!0):(E("isOnline",{state:"offline"}),!1):(E("isOnline",{state:"timeout"}),!1)}u(Kc,"isOnline");async function qc(r){let e=await fetch("https://api.github.com/repos/apify/apify-cli/releases/latest",{headers:{"User-Agent":Mi}});if(!e.ok)return E("useCLIVersionCheck","Failed to fetch latest version",{statusCode:e.status,body:await e.text()}),O({message:"Failed to fetch latest version of Apify CLI, using the cached version instead."}),null;let o=(await e.json()).tag_name.replace(/^v/,"");return E("useCLIVersionCheck","Fetched latest version",{version:o}),ys(r,s=>{s.versionCheck={lastChecked:Date.now(),lastVersion:o}}),o}u(qc,"getLatestVersion");function ji(){return!!(process.env.APIFY_CLI_SKIP_UPDATE_CHECK&&!["0","false"].includes(process.env.APIFY_CLI_SKIP_UPDATE_CHECK))}u(ji,"shouldSkipVersionCheck");async function Bi(r=!1){let e=hs(),t=!e.versionCheck||Date.now()-e.versionCheck.lastChecked>ei,o=r||t&&await Kc(),s=o?await qc(e):e.versionCheck?.lastVersion;if(!s)return{currentVersion:br.version,latestVersion:"unknown",shouldUpdate:!1,cacheHit:!1};let i=Hc(s,br.version);return{currentVersion:br.version,latestVersion:s,shouldUpdate:i,cacheHit:!o}}u(Bi,"useCLIVersionCheck");import{jaroWinkler as Wc}from"@skyra/jaro-winkler";import zc from"js-levenshtein";function Sr(r){let e=[...q.entries()].sort(([s],[i])=>s.localeCompare(i)),t=r.toLowerCase();return e.map(([s,i])=>{let n=s.toLowerCase(),a=s.split(" "),c=a[a.length-1].toLowerCase(),d=i.aliases?.includes(c)||i.hiddenAliases?.includes(c)||!1,l=zc(t,n),f=Wc(t,n),m=l<=2||f>=.975;return m?(E("useCommandSuggestions",{inputString:t,lowercased:n,matches:m,levenshtein:l,jaroWinkler:f}),d?{string:`${n} (alias for ${i.name})`,distance:f}:{string:`${n}`,distance:f}):null}).filter(s=>s!==null).sort((s,i)=>i.distance-s.distance).map(s=>s.string)}u(Sr,"useCommandSuggestions");var be=await Ui(),jt=X(),Bt=`Apify CLI/${jt.version} (https://github.com/apify/apify-cli)`;function ng(r){jt.installMethod!=="bundle"&&(Xc(Se.version,he)||(p({message:`${r} CLI requires Node.js version ${he}. Your current version is ${Se.version}.`}),Se.exit(1)))}u(ng,"processVersionCheck");function Zc(r){r.values.version===!0&&r.positionals.length===0&&(console.log(jt.fullVersionString),Se.exit(0))}u(Zc,"printCLIVersionAndExitIfFlagUsed");function Qc(r,e){(r.values.help===!0&&r.positionals.length===0||r.positionals.length===0)&&(console.log(yr(e)),Se.exit(0))}u(Qc,"printHelpAndExitIfFlagUsedOrNoCommandPassed");function Yi(r){let e=Sr(String(r)),t=vr.gray(`Command ${vr.whiteBright(r)} not found`);e.length&&(t+=`
40
- `,t+=vr.gray(`Did you mean: ${e.map(o=>vr.whiteBright(o)).join(", ")}?`)),p({message:t}),Se.exit(1)}u(Yi,"handleCommandNotFound");async function el(r,e){let t=q.get("upgrade");if([t.name,...t.aliases??[]].some(s=>e===s)){E("[VersionCheckMiddleware]","upgrade command detected, skipping version check");return}if(ji()){E("[VersionCheckMiddleware]","skipping version check because APIFY_CLI_SKIP_UPDATE_CHECK is set");return}await Di(r,t,{flags_internalAutomaticCall:!0})}u(el,"runVersionCheck");async function ag(r){E("CLIMetadata",{...jt,fullVersionString:jt.fullVersionString,argv:Se.argv,cwd:Se.cwd(),execPath:Se.execPath});let e=Se.argv.slice(2),t=Vi({allowPositionals:!0,strict:!1,options:{help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}},args:e});Zc(t),Qc(t,r),await el(r,t.positionals[0]),E("StartingArgs",t);let[o,s]=t.positionals,i=!1,n=q.get(o);if(!n)return Yi(o);let a=n;if(n.subcommands?.length){if(!s)return n.printHelp();i=!0,a=q.get(`${o} ${s}`)}if(!a)return Yi(`${o} ${s}`);let c=[...e],d=e.indexOf(o);if(c.splice(d,1),i){let m=e.indexOf(s);c.splice(m,1)}E("RebuiltArgs",c),E("CommandToRun",a);let l=new a(r),f=l._buildParseArgsOption();E("ParserOptionsForCommand",f);try{let m=Vi({...f,args:c});await l._run(m),E("CommandArgsResult",m)}catch(m){let g=ie.into(m,a);p({message:g.getPrettyMessage()}),Se.exit(1)}}u(ag,"runCLI");import{APIFY_ENV_VARS as ul}from"@apify/consts";import Vt from"process";import{pipeline as tl}from"stream/promises";import{MemoryStorage as rl}from"@crawlee/memory-storage";import{ApifyClient as ol}from"apify-client";import Gi from"ow";import{ACTOR_ENV_VARS as Hi,APIFY_ENV_VARS as Ji,KEY_VALUE_STORE_KEYS as sl,LOCAL_ACTOR_ENV_VARS as il}from"@apify/consts";var Yt={KEY_VALUE_STORE:"KEY_VALUE_STORE",DATASET:"DATASET",REQUEST_QUEUE:"REQUEST_QUEUE"},ws=u(async()=>{let r=Vt.env[Ji.TOKEN];if(r)return r;let e=await F();if(!e||!e.token)throw new Error("Apify token is not set. Please set it using the environment variable APIFY_TOKEN or apify login command.");return e.token},"getApifyTokenFromEnvOrAuthFile"),tt=u(async(r={},e=Reflect.has(Vt.env,Ji.IS_AT_HOME))=>{let t=le();if(t&&!e)return new rl({localDataDirectory:t,...r});let o=await ws();return new ol({...ls(o),...r})},"getApifyStorageClient"),Gt=u(r=>{let e=Hi[`DEFAULT_${r}_ID`];return Vt.env[e]||il[e]},"getDefaultStorageId"),As=u(async r=>{Gi(r,Gi.string);let e=await tt(),t=Gt(Yt.KEY_VALUE_STORE),o=await e.keyValueStore(t).getRecord(r,{stream:!0});o&&await tl(o.value,Vt.stdout,{end:!1})},"outputRecordFromDefaultStore"),Ki=u(async()=>As(Vt.env[Hi.INPUT_KEY]||sl.INPUT),"outputInputFromDefaultStore");function nl(r){return{argTag:"string",required:r.required??!1,stdin:r.stdin??1,description:r.description,aliases:r.aliases,catchAll:r.catchAll??!1}}u(nl,"stringArg");var w={string:nl};var A={string:al,boolean:cl,integer:ll};function al(r){return{flagTag:"string",builder:u(e=>{let t=new Set([...r.aliases??[]]);t.delete(e);let o=[{flagName:e,option:{type:"string",multiple:!0}}];r.char&&(o[0].option.short=r.char);for(let s of t)o.push({flagName:we(Ae(s)).toLowerCase(),option:{type:"string",multiple:!0}});return o},"builder"),choices:r.choices,required:r.required??!1,hasDefault:r.default,stdin:r.stdin??2,description:r.description,aliases:r.aliases,char:r.char,hidden:r.hidden,exclusive:r.exclusive}}u(al,"stringFlag");function cl(r){return{flagTag:"boolean",builder:u(e=>{let t=new Set([...r.aliases??[]]);t.delete(e);let o=[{flagName:e,option:{type:"boolean",multiple:!0}}];r.char&&(o[0].option.short=r.char);for(let s of t)o.push({flagName:we(Ae(s)).toLowerCase(),option:{type:"boolean",multiple:!0}});return o},"builder"),choices:null,required:r.required??!1,hasDefault:r.default,stdin:r.stdin??1,description:r.description,aliases:r.aliases,char:r.char,hidden:r.hidden,exclusive:r.exclusive}}u(cl,"booleanFlag");function ll(r){return{flagTag:"integer",builder:u(e=>{let t=new Set([...r.aliases??[]]);t.delete(e);let o=[{flagName:e,option:{type:"string",multiple:!0}}];r.char&&(o[0].option.short=r.char);for(let s of t)o.push({flagName:we(Ae(s)).toLowerCase(),option:{type:"string",multiple:!0}});return o},"builder"),choices:null,required:r.required??!1,hasDefault:r.default,stdin:r.stdin??1,description:r.description,aliases:r.aliases,char:r.char,hidden:r.hidden,exclusive:r.exclusive}}u(ll,"integerFlag");var mt=class extends y{static name="charge";static description="Charge for a specific event in the pay-per-event Actor run.";static args={eventName:w.string({description:"Name of the event to charge for",required:!0})};static flags={count:A.integer({description:"Number of events to charge",required:!1,default:1}),"idempotency-key":A.string({description:"Idempotency key for the charge request",required:!1}),"test-pay-per-event":A.boolean({description:"Test pay-per-event charging without actually charging",required:!1,default:!1})};async run(){let{eventName:e}=this.args,{count:t,testPayPerEvent:o,idempotencyKey:s}=this.flags;if(!!!process.env.APIFY_IS_AT_HOME){v({message:`No platform detected: would charge ${t} events of type "${e}" with idempotency key "${s??"not-provided"}".`,stdout:!0});return}if(o){v({message:`PPE test mode: would charge ${t} events of type "${e}" with idempotency key "${s??"not-provided"}".`,stdout:!0});return}let n=await ws(),a=await Nt(n);if(!a)throw new Error("Apify token is not set. Please set it using the environment variable APIFY_TOKEN.");let c=process.env[ul.ACTOR_RUN_ID];if(!c)throw new Error("Charge command must be executed in a running Actor. Run ID not found.");if((await a.run(c).get())?.pricingInfo?.pricingModel!=="PAY_PER_EVENT")throw new Error("Charge command can only be used with pay-per-event pricing model.");v({message:`Charging ${t} events of type "${e}" with idempotency key "${s??"not-provided"}" (runId: ${c}).`,stdout:!0}),await a.run(c).charge({eventName:e,count:t,idempotencyKey:s})}};var pt=class extends y{static name="get-input";static description="Gets the Actor input value from the default key-value store associated with the Actor run.";async run(){await Ki()}};import{ACTOR_ENV_VARS as bs,APIFY_ENV_VARS as qi}from"@apify/consts";import{createHmacSignature as dl}from"@apify/utilities";var ft=class extends y{static name="get-public-url";static description="Get an HTTP URL that allows public access to a key-value store item.";static args={key:w.string({required:!0,description:"Key of the record in key-value store"})};async run(){let{key:e}=this.args;if([void 0,"false",""].includes(process.env[qi.IS_AT_HOME])){p({message:"get-public-url is not yet implemented for local development"}),process.exitCode=255;return}let t=process.env[qi.API_PUBLIC_BASE_URL],o=process.env[bs.DEFAULT_KEY_VALUE_STORE_ID];if(!o){p({message:`Missing environment variable: ${bs.DEFAULT_KEY_VALUE_STORE_ID}. Please set it before running the command.`}),process.exitCode=5;return}let i=await(await tt()).keyValueStore(o).get(),n=new URL(`${t}/v2/key-value-stores/${o}/records/${e}`);if(!i){p({message:`Key-Value store with ID '${o}' was not found. Ensure the store exists and that the correct ID is set in ${bs.DEFAULT_KEY_VALUE_STORE_ID}.`}),process.exitCode=250;return}let{urlSigningSecretKey:a}=i;a&&n.searchParams.append("signature",dl(a,e)),console.log(n.toString())}};var gt=class extends y{static name="get-value";static description="Gets a value from the default key-value store associated with the Actor run.";static args={key:w.string({required:!0,description:"Key of the record in key-value store"})};async run(){let{key:e}=this.args;await As(e)}};var ht=class extends y{static name="push-data";static description=`Saves data to Actor's run default dataset.
40
+ `,t+=vr.gray(`Did you mean: ${e.map(o=>vr.whiteBright(o)).join(", ")}?`)),p({message:t}),Se.exit(1)}u(Yi,"handleCommandNotFound");async function el(r,e){let t=q.get("upgrade");if([t.name,...t.aliases??[]].some(s=>e===s)){E("[VersionCheckMiddleware]","upgrade command detected, skipping version check");return}if(ji()){E("[VersionCheckMiddleware]","skipping version check because APIFY_CLI_SKIP_UPDATE_CHECK is set");return}await Di(r,t,{flags_internalAutomaticCall:!0})}u(el,"runVersionCheck");async function ag(r){E("CLIMetadata",{...jt,fullVersionString:jt.fullVersionString,argv:Se.argv,cwd:Se.cwd(),execPath:Se.execPath});let e=Se.argv.slice(2);E("ProcessArgv",e);let t=Vi({allowPositionals:!0,strict:!1,options:{help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}},args:e});Zc(t),Qc(t,r),await el(r,t.positionals[0]),E("TopLevelOptions",t);let[o,s]=t.positionals,i=!1,n=q.get(o);if(!n)return Yi(o);let a=n;if(n.subcommands?.length){if(!s)return n.printHelp();i=!0,a=q.get(`${o} ${s}`)}if(!a)return Yi(`${o} ${s}`);let c=[...e],d=c.indexOf(o);if(E("CommandNameIndex",d),c.splice(d,1),i){let m=c.indexOf(s);E("SubcommandNameIndex",m),c.splice(m,1)}E("RebuiltArgs",c),E("CommandToRun",a);let l=new a(r),f=l._buildParseArgsOption();E("ParserOptionsForCommand",f);try{let m=Vi({...f,args:c});await l._run(m),E("CommandArgsResult",m)}catch(m){let g=ie.into(m,a);p({message:g.getPrettyMessage()}),Se.exit(1)}}u(ag,"runCLI");import{APIFY_ENV_VARS as ul}from"@apify/consts";import Vt from"process";import{pipeline as tl}from"stream/promises";import{MemoryStorage as rl}from"@crawlee/memory-storage";import{ApifyClient as ol}from"apify-client";import Gi from"ow";import{ACTOR_ENV_VARS as Hi,APIFY_ENV_VARS as Ji,KEY_VALUE_STORE_KEYS as sl,LOCAL_ACTOR_ENV_VARS as il}from"@apify/consts";var Yt={KEY_VALUE_STORE:"KEY_VALUE_STORE",DATASET:"DATASET",REQUEST_QUEUE:"REQUEST_QUEUE"},ws=u(async()=>{let r=Vt.env[Ji.TOKEN];if(r)return r;let e=await F();if(!e||!e.token)throw new Error("Apify token is not set. Please set it using the environment variable APIFY_TOKEN or apify login command.");return e.token},"getApifyTokenFromEnvOrAuthFile"),tt=u(async(r={},e=Reflect.has(Vt.env,Ji.IS_AT_HOME))=>{let t=le();if(t&&!e)return new rl({localDataDirectory:t,...r});let o=await ws();return new ol({...ls(o),...r})},"getApifyStorageClient"),Gt=u(r=>{let e=Hi[`DEFAULT_${r}_ID`];return Vt.env[e]||il[e]},"getDefaultStorageId"),As=u(async r=>{Gi(r,Gi.string);let e=await tt(),t=Gt(Yt.KEY_VALUE_STORE),o=await e.keyValueStore(t).getRecord(r,{stream:!0});o&&await tl(o.value,Vt.stdout,{end:!1})},"outputRecordFromDefaultStore"),Ki=u(async()=>As(Vt.env[Hi.INPUT_KEY]||sl.INPUT),"outputInputFromDefaultStore");function nl(r){return{argTag:"string",required:r.required??!1,stdin:r.stdin??1,description:r.description,aliases:r.aliases,catchAll:r.catchAll??!1}}u(nl,"stringArg");var w={string:nl};var A={string:al,boolean:cl,integer:ll};function al(r){return{flagTag:"string",builder:u(e=>{let t=new Set([...r.aliases??[]]);t.delete(e);let o=[{flagName:e,option:{type:"string",multiple:!0}}];r.char&&(o[0].option.short=r.char);for(let s of t)o.push({flagName:we(Ae(s)).toLowerCase(),option:{type:"string",multiple:!0}});return o},"builder"),choices:r.choices,required:r.required??!1,hasDefault:r.default,stdin:r.stdin??2,description:r.description,aliases:r.aliases,char:r.char,hidden:r.hidden,exclusive:r.exclusive}}u(al,"stringFlag");function cl(r){return{flagTag:"boolean",builder:u(e=>{let t=new Set([...r.aliases??[]]);t.delete(e);let o=[{flagName:e,option:{type:"boolean",multiple:!0}}];r.char&&(o[0].option.short=r.char);for(let s of t)o.push({flagName:we(Ae(s)).toLowerCase(),option:{type:"boolean",multiple:!0}});return o},"builder"),choices:null,required:r.required??!1,hasDefault:r.default,stdin:r.stdin??1,description:r.description,aliases:r.aliases,char:r.char,hidden:r.hidden,exclusive:r.exclusive}}u(cl,"booleanFlag");function ll(r){return{flagTag:"integer",builder:u(e=>{let t=new Set([...r.aliases??[]]);t.delete(e);let o=[{flagName:e,option:{type:"string",multiple:!0}}];r.char&&(o[0].option.short=r.char);for(let s of t)o.push({flagName:we(Ae(s)).toLowerCase(),option:{type:"string",multiple:!0}});return o},"builder"),choices:null,required:r.required??!1,hasDefault:r.default,stdin:r.stdin??1,description:r.description,aliases:r.aliases,char:r.char,hidden:r.hidden,exclusive:r.exclusive}}u(ll,"integerFlag");var mt=class extends y{static name="charge";static description="Charge for a specific event in the pay-per-event Actor run.";static args={eventName:w.string({description:"Name of the event to charge for",required:!0})};static flags={count:A.integer({description:"Number of events to charge",required:!1,default:1}),"idempotency-key":A.string({description:"Idempotency key for the charge request",required:!1}),"test-pay-per-event":A.boolean({description:"Test pay-per-event charging without actually charging",required:!1,default:!1})};async run(){let{eventName:e}=this.args,{count:t,testPayPerEvent:o,idempotencyKey:s}=this.flags;if(!!!process.env.APIFY_IS_AT_HOME){v({message:`No platform detected: would charge ${t} events of type "${e}" with idempotency key "${s??"not-provided"}".`,stdout:!0});return}if(o){v({message:`PPE test mode: would charge ${t} events of type "${e}" with idempotency key "${s??"not-provided"}".`,stdout:!0});return}let n=await ws(),a=await Nt(n);if(!a)throw new Error("Apify token is not set. Please set it using the environment variable APIFY_TOKEN.");let c=process.env[ul.ACTOR_RUN_ID];if(!c)throw new Error("Charge command must be executed in a running Actor. Run ID not found.");if((await a.run(c).get())?.pricingInfo?.pricingModel!=="PAY_PER_EVENT")throw new Error("Charge command can only be used with pay-per-event pricing model.");v({message:`Charging ${t} events of type "${e}" with idempotency key "${s??"not-provided"}" (runId: ${c}).`,stdout:!0}),await a.run(c).charge({eventName:e,count:t,idempotencyKey:s})}};var pt=class extends y{static name="get-input";static description="Gets the Actor input value from the default key-value store associated with the Actor run.";async run(){await Ki()}};import{ACTOR_ENV_VARS as bs,APIFY_ENV_VARS as qi}from"@apify/consts";import{createHmacSignature as dl}from"@apify/utilities";var ft=class extends y{static name="get-public-url";static description="Get an HTTP URL that allows public access to a key-value store item.";static args={key:w.string({required:!0,description:"Key of the record in key-value store"})};async run(){let{key:e}=this.args;if([void 0,"false",""].includes(process.env[qi.IS_AT_HOME])){p({message:"get-public-url is not yet implemented for local development"}),process.exitCode=255;return}let t=process.env[qi.API_PUBLIC_BASE_URL],o=process.env[bs.DEFAULT_KEY_VALUE_STORE_ID];if(!o){p({message:`Missing environment variable: ${bs.DEFAULT_KEY_VALUE_STORE_ID}. Please set it before running the command.`}),process.exitCode=5;return}let i=await(await tt()).keyValueStore(o).get(),n=new URL(`${t}/v2/key-value-stores/${o}/records/${e}`);if(!i){p({message:`Key-Value store with ID '${o}' was not found. Ensure the store exists and that the correct ID is set in ${bs.DEFAULT_KEY_VALUE_STORE_ID}.`}),process.exitCode=250;return}let{urlSigningSecretKey:a}=i;a&&n.searchParams.append("signature",dl(a,e)),console.log(n.toString())}};var gt=class extends y{static name="get-value";static description="Gets a value from the default key-value store associated with the Actor run.";static args={key:w.string({required:!0,description:"Key of the record in key-value store"})};async run(){let{key:e}=this.args;await As(e)}};var ht=class extends y{static name="push-data";static description=`Saves data to Actor's run default dataset.
41
41
 
42
42
  Accept input as:
43
43
  - JSON argument:
@@ -89,9 +89,7 @@ Uses authenticated account and local key-value store for input.`;static flags={.
89
89
  `});try{await Ie({job:o,apifyClient:t})}catch(s){p({message:`Failed to get log for build with ID "${e}": ${s.message}`,stdout:!0})}}};import ue from"chalk";var du=u(()=>new V({allColumns:["Number","ID","Status","Took"],mandatoryColumns:["Number","ID","Status","Took"],columnAlignments:{Took:"right"}}),"tableFactory"),jr=class extends y{static name="ls";static description="Lists all builds of the Actor.";static flags={offset:A.integer({description:"Number of builds that will be skipped.",default:0}),limit:A.integer({description:"Number of builds that will be listed.",default:10}),desc:A.boolean({description:"Sort builds in descending order.",default:!1}),compact:A.boolean({description:"Display a compact table.",default:!1,char:"c"})};static args={actorId:w.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 C(),c=await Ue({providedActorNameOrId:n,client:a});if(!c.valid){p({message:`${c.reason}. Please run this command in an Actor directory, or specify the Actor ID.`,stdout:!0});return}let d=await a.actor(c.id).builds().list({desc:e,limit:t,offset:o}),l=await a.actor(c.id).get(),f=mr(d.items,h=>{let b=Reflect.get(h,"buildNumber"),[T,S]=b.split(".");return`${T}.${S}`}),m=Object.entries(l.taggedBuilds??{}).reduce((h,[b,T])=>(h[T.buildNumber]=b,h),{});if(i){for(let h of d.items){let b=Reflect.get(h,"buildNumber"),T=m[b];T&&Reflect.set(h,"buildTag",T)}N(d);return}R({message:`${ue.reset("Showing")} ${ue.yellow(d.items.length)} out of ${ue.yellow(d.total)} builds for Actor ${ue.yellow(c.userFriendlyId)} (${ue.gray(c.id)})
90
90
  `,stdout:!0});let g=Object.entries(f).sort((h,b)=>h[0].localeCompare(b[0]));for(let[h,b]of g){if(!b?.length){R({message:`No builds for version ${h}`,stdout:!0});continue}let T=l.versions.find(L=>L.versionNumber===h)?.buildTag,S=this.generateTableForActorVersion({buildsForVersion:b,buildTagToActorVersion:m}),I=T?` (latest build gets tagged with ${ue.yellow(T)})`:"",P=[ue.reset(`Builds for Actor Version ${ue.yellow(h)}${I}`),S.render(s?0:-1),""];R({message:P.join(`
91
91
  `),stdout:!0})}}generateTableForActorVersion({buildsForVersion:e,buildTagToActorVersion:t}){let o=du();for(let s of e){let i=Reflect.get(s,"buildNumber"),n=t[i]?` (${ue.yellow(t[i])})`:"",a;if(s.finishedAt){let c=s.finishedAt.getTime()-s.startedAt.getTime();a=ue.gray(`${se.format(c,void 0,{left:""})}`)}else{let c=Date.now()-s.startedAt.getTime();a=ue.gray(`Running for ${se.format(c,void 0,{left:""})}`)}o.pushRow({Number:`${i}${n}`,ID:ue.gray(s.id),Status:ve(s.status),Took:a})}return o}};import mu from"@inquirer/input";var vn=_e(async({message:r,expectedValue:e,failureMessage:t})=>await mu({message:r,validate(s){return s===e?!0:t??"That is not the correct input!"}}));var Br=class extends y{static name="rm";static description="Permanently removes an Actor build from the Apify platform.";static args={buildId:w.string({description:"The build ID to delete.",required:!0})};async run(){let{buildId:e}=this.args,t=await C(),o=await t.build(e).get();if(!o){p({message:`Build with ID "${e}" was not found on your account.`,stdout:!0});return}let s=await t.actor(o.actId).get(),i;if(s?.taggedBuilds){for(let[a,c]of Object.entries(s.taggedBuilds))if(e===c.buildId){i=a;break}}if(!await(i?vn:J)({message:`Are you sure you want to delete this Actor Build?${i?` If so, please type in "${i}":`:""}`,expectedValue:i??"",failureMessage:"Your provided value does not match the build tag."})){v({message:`Deletion of build "${e}" was canceled.`,stdout:!0});return}try{await t.build(e).delete(),_({message:`Build with ID "${e}" was deleted.`,stdout:!0})}catch(a){let c=a;p({message:`Failed to delete build "${e}".
92
- ${c.message||c}`,stdout:!0})}}};var Vr=class extends y{static name="builds";static description="Manages Actor build processes and versioning.";static subcommands=[Br,jr,Mr,Ur,wt];async run(){this.printHelp()}};var Yr=class extends je{static name="call"};import pu from"assert";import{existsSync as Gr}from"fs";import{mkdir as fu,readFile as gu,symlink as hu,unlink as yu,writeFile as Tn}from"fs/promises";import{basename as wu,join as de}from"path";import Ve from"chalk";var Au=u(r=>de(r,".install-marker"),"pathToInstallMarker"),$s=u(r=>r.startsWith(process.env.HOME)?r.replace(process.env.HOME,"~"):r,"tildify"),Jt=class extends y{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}=X();if(e!=="bundle"){v({message:`Apify and Actor CLI are already fully configured! \u{1F44D}
93
- `});return}pu(t,"When CLI is installed via bundles, the install path must be set");let s=Au(t);if(Gr(s)){v({message:`Apify and Actor CLI are already fully configured! \u{1F44D}
94
- `});return}await this.symlinkToLocalBin(t),await this.promptAddToShell(),await Tn(s,o),E("[install] install marker written to",s),R({message:""}),_({message:"To get started, run:"}),R({message:Ve.white.bold(` apify --help
92
+ ${c.message||c}`,stdout:!0})}}};var Vr=class extends y{static name="builds";static description="Manages Actor build processes and versioning.";static subcommands=[Br,jr,Mr,Ur,wt];async run(){this.printHelp()}};var Yr=class extends je{static name="call"};import pu from"assert";import{existsSync as Gr}from"fs";import{mkdir as fu,readFile as gu,symlink as hu,unlink as yu,writeFile as Tn}from"fs/promises";import{basename as wu,join as de}from"path";import Ve from"chalk";var Au=u(r=>de(r,".install-marker"),"pathToInstallMarker"),$s=u(r=>r.startsWith(process.env.HOME)?r.replace(process.env.HOME,"~"):r,"tildify"),Jt=class extends y{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}=X();if(e!=="bundle"){v({message:"Apify and Actor CLI are already fully configured! \u{1F44D}"});return}pu(t,"When CLI is installed via bundles, the install path must be set");let s=Au(t);if(Gr(s)){v({message:"Apify and Actor CLI are already fully configured! \u{1F44D}"});return}await this.symlinkToLocalBin(t),await this.promptAddToShell(),await Tn(s,o),E("[install] install marker written to",s),R({message:""}),_({message:"To get started, run:"}),R({message:Ve.white.bold(` apify --help
95
93
  actor --help`)})}async symlinkToLocalBin(e){let t=process.env.HOME;if(E("[install] user home directory",t),!t){E("[install] user home directory not found"),O({message:Ve.gray("User home directory not found, cannot symlink to ~/.local/bin")});return}let o=de(t,".local","bin");Gr(o)||await fu(o,{recursive:!0});let s=["apify","actor","apify-cli"];for(let i of s){let n=de(e,i);if(!Gr(n)){E("[install] file not found for symlinking",i,n),O({message:Ve.gray(`Bundle not found for symlinking: ${i}`)});continue}let a=de(o,i);await yu(a),await hu(n,a),E("[install] symlink created for item",i,a)}v({message:Ve.gray(`Symlinked apify, actor, and apify-cli to ${o}`)})}async promptAddToShell(){let e=process.env.PROVIDED_INSTALL_DIR;if(!e){O({message:Ve.gray("Install directory not found, cannot add to shell")});return}let t=process.env.FINAL_BIN_DIR;R({message:""});let o=await J({message:"Should the CLI handle adding itself to your shell automatically? (If you say no, you will receive the lines to add to your shell config file)",providedConfirmFromStdin:!1}),s=wu(process.env.SHELL??"sh"),i=`"${e.replaceAll('"','\\"')}"`,n=[],a="";switch(s){case"bash":{n.push(`export APIFY_CLI_INSTALL=${i}`),n.push('export PATH="$APIFY_CLI_INSTALL/bin:$PATH"');let c=[de(process.env.HOME,".bashrc"),de(process.env.HOME,".bash_profile")];process.env.XDG_CONFIG_HOME&&c.push(de(process.env.XDG_CONFIG_HOME,".bashrc"),de(process.env.XDG_CONFIG_HOME,".bash_profile"),de(process.env.XDG_CONFIG_HOME,"bashrc"),de(process.env.XDG_CONFIG_HOME,"bash_profile"));for(let d of c)if(Gr(d)){a=d;break}break}case"zsh":n.push(`export APIFY_CLI_INSTALL=${i}`),n.push('export PATH="$APIFY_CLI_INSTALL/bin:$PATH"'),a=de(process.env.HOME,".zshrc");break;case"fish":{n.push(`set --export APIFY_CLI_INSTALL ${i}`),n.push(`set --export PATH ${t} $PATH`),a=de(process.env.HOME,".config","fish","config.fish");break}default:n.push(`export APIFY_CLI_INSTALL=${i}`),n.push('export PATH="$APIFY_CLI_INSTALL/bin:$PATH"'),a="~/.bashrc";break}if(R({message:""}),o&&a){let d=`${await gu(a,"utf-8")}
96
94
 
97
95
  # apify cli
@@ -239,4 +237,4 @@ Customize with --memory and --timeout flags.
239
237
  4. INPUT_SCHEMA.json
240
238
 
241
239
  Optionally specify custom schema path to validate.`;static args={path:w.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(){let{inputSchema:e,inputSchemaPath:t}=await at({forcePath:this.args.path,cwd:fm.cwd()});if(!e)throw new Error(`Input schema has not been found at ${t}.`);t?v({message:`Validating input schema stored at ${t}`}):v({message:`Validating input schema embedded in '${j}'`});let o=new ut({strict:!1});gm(o,e),_({message:"Input schema is valid."})}};var HR=[Cr,kr,Vr,lo,$o,No,Ko,zo,Zo,Yr,Kt,Jt,Qr,uo,po,yo,ho,_o,Ro,Oo,xo,ko,Qo,Wt],JR=[yt,ht,gt,ft,pt,mt,Wt,Kt,Jt];export{ng as a,ag as b,HR as c,JR as d};
242
- //# sourceMappingURL=chunk-ZRI7FEJN.js.map
240
+ //# sourceMappingURL=chunk-VTIADQJA.js.map