apify-cli 1.1.1-beta.2 → 1.1.1-beta.3
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-
|
|
2
|
+
import{a as o,b as r,d as m}from"./chunk-7TLAU6MJ.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-
|
|
2
|
+
import{a as o,b as r,c as i}from"./chunk-7TLAU6MJ.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 La=Object.defineProperty;var c=(r,e)=>La(r,"name",{value:e,configurable:!0});import Te from"process";import{parseArgs as fn}from"util";import Dr from"chalk";import{satisfies as Rc}from"semver";import Os from"chalk";import lc from"indent-string";import cc from"widest-line";import uc from"wrap-ansi";import Da from"chalk";function I(r,...e){process.env.APIFY_CLI_DEBUG&&console.error(Da.gray(`[${r}]`),...e)}c(I,"cliDebugPrint");import{realpathSync as Fa}from"fs";import{dirname as ka}from"path";import ut from"chalk";function Xe(r){r.stdoutOutput&&console.log(...r.stdoutOutput),r.stderrOutput&&console.error(...r.stderrOutput)}c(Xe,"internalLog");function _(r){Xe({[r.stdout?"stdoutOutput":"stderrOutput"]:[r.message]})}c(_,"simpleLog");function p(r){Xe({[r.stdout?"stdoutOutput":"stderrOutput"]:[ut.red("Error:"),r.message]})}c(p,"error");function x(r){Xe({[r.stdout?"stdoutOutput":"stderrOutput"]:[ut.yellow.bold("Warning:"),r.message]})}c(x,"warning");function $(r){Xe({[r.stdout?"stdoutOutput":"stderrOutput"]:[ut.green("Success:"),r.message]})}c($,"success");function ye(r){Xe({[r.stdout?"stdoutOutput":"stderrOutput"]:[ut.gray("Run:"),r.message]})}c(ye,"run");function v(r){Xe({[r.stdout?"stdoutOutput":"stderrOutput"]:[ut.white("Info:"),r.message]})}c(v,"info");function us(r){Xe({[r.stdout?"stdoutOutput":"stderrOutput"]:[ut.blue(r.message),r.url]})}c(us,"link");var ms="0.0.0";var Ua="1.1.1-beta.2",Ma="c0e1572a8c5ba0b74eab5cea66a58fa2a5f1f434";function ja(){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=Fa(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"}c(ja,"detectInstallMethod");function Va(){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}}c(Va,"getRuntimeInfo");var Rt=null;function K(){if(Rt)return Rt;let r=ja(),e=Va();return Rt={version:Ua,hash:Ma,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===ms}},r==="bundle"&&(Rt.installPath=ka(process.execPath)),Rt}c(K,"useCLIMetadata");import{existsSync as vl,mkdirSync as Tl,readFileSync as Il,writeFileSync as Cl}from"fs";import{dirname as El}from"path";import{cryptoRandomObjectId as $l}from"@apify/utilities";import{homedir as Ga}from"os";import{join as Ze}from"path";import{KEY_VALUE_STORE_KEYS as Ya,META_ORIGINS as Ha}from"@apify/consts";var ii={name:"apify-cli",version:"1.1.1-beta.2",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:">=20"},dependencies:{"@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":"^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.14.0",archiver:"~7.0.1",axios:"^1.11.0",chalk:"~5.6.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",open:"~10.2.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 Qe="storage",ds="apify_storage",ps=1,or={actorSpecification:ps,name:null,version:"0.0",buildTag:"latest",environmentVariables:{}},ni=1440*60*1e3,mt=c(()=>{let r=Ze(Ga(),".apify");return process.env.__APIFY_INTERNAL_TEST_AUTH_PATH__?Ze(r,process.env.__APIFY_INTERNAL_TEST_AUTH_PATH__):r},"GLOBAL_CONFIGS_FOLDER"),ne=c(()=>Ze(mt(),"auth.json"),"AUTH_FILE_PATH"),sr=c(()=>Ze(mt(),"secrets.json"),"SECRETS_FILE_PATH"),ir=c(()=>Ze(mt(),"state.json"),"STATE_FILE_PATH"),nr=c(()=>Ze(mt(),"telemetry.json"),"TELEMETRY_FILE_PATH"),ar="apify.json",fs=".actor",Ja="actor.json",j=Ze(fs,Ja),gs=new RegExp(`^${Ya.INPUT}\\..*`),we=ii.engines.node,ai={"X-Apify-Request-Origin":Ha.CLI},et="3.9.0",li=".venv";import{createWriteStream as el,existsSync as le,mkdirSync as tl,readdirSync as gi,readFileSync as Pt,writeFileSync as cr}from"fs";import{mkdir as rl,readFile as ol}from"fs/promises";import{get as sl}from"https";import{homedir as pi}from"os";import{dirname as hi,join as Ae}from"path";import ae from"process";import{finished as il}from"stream/promises";import{DurationFormatter as yi,TimeTypes as tt}from"@sapphire/duration";import{Timestamp as hs}from"@sapphire/timestamp";import nl from"adm-zip";import al from"ajv/dist/2019.js";import{ApifyClient as wi}from"apify-client";import ll from"archiver";import{AxiosHeaders as cl}from"axios";import ul from"escape-string-regexp";import{globby as Ai}from"globby";import{getEncoding as ml}from"istextorbinary";import{Mime as dl}from"mime";import pl from"mime/types/other.js";import fl from"mime/types/standard.js";import{gte as gl,minVersion as hl,satisfies as yl}from"semver";import{ACTOR_ENV_VARS as ys,ACTOR_JOB_TERMINAL_STATUSES as wl,ACTOR_NAME as Nt,APIFY_ENV_VARS as Al,KEY_VALUE_STORE_KEYS as fi,LOCAL_ACTOR_ENV_VARS as ws,LOCAL_STORAGE_SUBDIRS as As,SOURCE_FILE_FORMATS as Ot}from"@apify/consts";import{existsSync as Ka,mkdirSync as qa}from"fs";import{readFile as Wa,stat as ci,unlink as za,writeFile as Xa}from"fs/promises";import{join as ui,sep as Za}from"path";import{rimraf as Qa}from"rimraf";var mi=c(async(r,e={},t=null)=>{let o=await Wa(r,"utf-8"),s=JSON.parse(o),i;t?(i=s,i[t]={...s[t],...e}):i={...s,...e},await Xa(r,JSON.stringify(i,null," "))},"updateLocalJson"),lr=c((r,e)=>{e||(e=r,r="."),e.split(Za).reduce((o,s)=>(o=ui(o,s),Ka(o)||qa(o),o),r)},"ensureFolderExistsSync"),_t=c(async r=>{await Qa(r)},"rimrafPromised"),xt=c(async r=>{(await ci(r)).isFile()&&await za(r)},"deleteFile"),di=c(async(r,e)=>(await Promise.all(r.map(async s=>ci(ui(e,s))))).map(s=>s.size).reduce((s,i)=>s+i,0),"sumFilesSizeInBytes");var dt=al,ur=c(async r=>new Promise((e,t)=>{sl(r,o=>{o.statusCode===301||o.statusCode===302?(e(ur(o.headers.location)),o.destroy()):e(o)}).on("error",t)}),"httpsGet"),ce=c(()=>{let r=Al.LOCAL_STORAGE_DIR;return ae.env[r]||ae.env.CRAWLEE_STORAGE_DIR||Qe},"getLocalStorageDir"),Ce=c(r=>{let e=ys.DEFAULT_KEY_VALUE_STORE_ID,t=r||ae.env[e]||ws[e];return Ae(ce(),As.keyValueStores,t)},"getLocalKeyValueStorePath"),Si=c(r=>{let e=ys.DEFAULT_DATASET_ID,t=r||ae.env[e]||ws[e];return Ae(ce(),As.datasets,t)},"getLocalDatasetPath"),bi=c(r=>{let e=ys.DEFAULT_REQUEST_QUEUE_ID,t=r||ae.env[e]||ws[e];return Ae(ce(),As.requestQueues,t)},"getLocalRequestQueuePath"),F=c(async()=>{let r={};try{let e=await ol(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 Lt();if(!r)throw new Error('You are not logged in with your Apify account. Call "apify login" to fix that.');return r}c(C,"getLoggedClientOrThrow");var vi=c(r=>{if(!r&&le(mt())&&le(ne())){let e=Pt(ne(),"utf-8");return JSON.parse(e).token}return r},"getTokenWithAuthFileFallback"),Ss=c((r,e)=>(r=vi(r),{token:r,baseUrl:e||ae.env.APIFY_CLIENT_BASE_URL,requestInterceptors:[t=>{t.headers??=new cl;for(let[o,s]of Object.entries(ai))t.headers[o]=s;return t}]}),"getApifyClientOptions");async function Lt(r,e){r=vi(r);let t=new wi(Ss(r,e)),o;try{o=await t.user("me").get()}catch{return null}return vs(ne()),cr(ne(),JSON.stringify({token:t.token,...o},null," ")),t}c(Lt,"getLoggedClient");var bs=c(r=>Ae(r,j),"getLocalConfigPath"),Ee=c(r=>{if(le(r))return JSON.parse(Pt(r,{encoding:"utf-8"}))},"getJsonFileContent"),Fe=c(r=>Ee(bs(r)),"getLocalConfig"),mr=c(async(r,e)=>{let t=Ae(e||ae.cwd(),j);await rl(hi(t),{recursive:!0}),cr(t,JSON.stringify(r,null," "))},"setLocalConfig"),Sl=[ce(),"node_modules",".venv"],dr=c(async r=>{let e=Ce();lr(r,Si()),lr(r,bi()),lr(r,e);let t=Ae(r,".gitignore"),o="";le(t)&&(o=Pt(t,{encoding:"utf-8"}));let s=[];for(let i of Sl)RegExp(`^${ul(i)}$`,"mg").test(o)||s.push(i);s.length>0&&(o.length>0?(s.unshift("# Added by Apify CLI"),cr(t,`
|
|
1
|
+
var La=Object.defineProperty;var c=(r,e)=>La(r,"name",{value:e,configurable:!0});import Te from"process";import{parseArgs as fn}from"util";import Dr from"chalk";import{satisfies as Rc}from"semver";import Os from"chalk";import lc from"indent-string";import cc from"widest-line";import uc from"wrap-ansi";import Da from"chalk";function I(r,...e){process.env.APIFY_CLI_DEBUG&&console.error(Da.gray(`[${r}]`),...e)}c(I,"cliDebugPrint");import{realpathSync as Fa}from"fs";import{dirname as ka}from"path";import ut from"chalk";function Xe(r){r.stdoutOutput&&console.log(...r.stdoutOutput),r.stderrOutput&&console.error(...r.stderrOutput)}c(Xe,"internalLog");function _(r){Xe({[r.stdout?"stdoutOutput":"stderrOutput"]:[r.message]})}c(_,"simpleLog");function p(r){Xe({[r.stdout?"stdoutOutput":"stderrOutput"]:[ut.red("Error:"),r.message]})}c(p,"error");function x(r){Xe({[r.stdout?"stdoutOutput":"stderrOutput"]:[ut.yellow.bold("Warning:"),r.message]})}c(x,"warning");function $(r){Xe({[r.stdout?"stdoutOutput":"stderrOutput"]:[ut.green("Success:"),r.message]})}c($,"success");function ye(r){Xe({[r.stdout?"stdoutOutput":"stderrOutput"]:[ut.gray("Run:"),r.message]})}c(ye,"run");function v(r){Xe({[r.stdout?"stdoutOutput":"stderrOutput"]:[ut.white("Info:"),r.message]})}c(v,"info");function us(r){Xe({[r.stdout?"stdoutOutput":"stderrOutput"]:[ut.blue(r.message),r.url]})}c(us,"link");var ms="0.0.0";var Ua="1.1.1-beta.3",Ma="8458ccf38443efff848484ca3a441172f81710bd";function ja(){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=Fa(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"}c(ja,"detectInstallMethod");function Va(){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}}c(Va,"getRuntimeInfo");var Rt=null;function K(){if(Rt)return Rt;let r=ja(),e=Va();return Rt={version:Ua,hash:Ma,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===ms}},r==="bundle"&&(Rt.installPath=ka(process.execPath)),Rt}c(K,"useCLIMetadata");import{existsSync as vl,mkdirSync as Tl,readFileSync as Il,writeFileSync as Cl}from"fs";import{dirname as El}from"path";import{cryptoRandomObjectId as $l}from"@apify/utilities";import{homedir as Ga}from"os";import{join as Ze}from"path";import{KEY_VALUE_STORE_KEYS as Ya,META_ORIGINS as Ha}from"@apify/consts";var ii={name:"apify-cli",version:"1.1.1-beta.3",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:">=20"},dependencies:{"@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":"^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.14.0",archiver:"~7.0.1",axios:"^1.11.0",chalk:"~5.6.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",open:"~10.2.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 Qe="storage",ds="apify_storage",ps=1,or={actorSpecification:ps,name:null,version:"0.0",buildTag:"latest",environmentVariables:{}},ni=1440*60*1e3,mt=c(()=>{let r=Ze(Ga(),".apify");return process.env.__APIFY_INTERNAL_TEST_AUTH_PATH__?Ze(r,process.env.__APIFY_INTERNAL_TEST_AUTH_PATH__):r},"GLOBAL_CONFIGS_FOLDER"),ne=c(()=>Ze(mt(),"auth.json"),"AUTH_FILE_PATH"),sr=c(()=>Ze(mt(),"secrets.json"),"SECRETS_FILE_PATH"),ir=c(()=>Ze(mt(),"state.json"),"STATE_FILE_PATH"),nr=c(()=>Ze(mt(),"telemetry.json"),"TELEMETRY_FILE_PATH"),ar="apify.json",fs=".actor",Ja="actor.json",j=Ze(fs,Ja),gs=new RegExp(`^${Ya.INPUT}\\..*`),we=ii.engines.node,ai={"X-Apify-Request-Origin":Ha.CLI},et="3.9.0",li=".venv";import{createWriteStream as el,existsSync as le,mkdirSync as tl,readdirSync as gi,readFileSync as Pt,writeFileSync as cr}from"fs";import{mkdir as rl,readFile as ol}from"fs/promises";import{get as sl}from"https";import{homedir as pi}from"os";import{dirname as hi,join as Ae}from"path";import ae from"process";import{finished as il}from"stream/promises";import{DurationFormatter as yi,TimeTypes as tt}from"@sapphire/duration";import{Timestamp as hs}from"@sapphire/timestamp";import nl from"adm-zip";import al from"ajv/dist/2019.js";import{ApifyClient as wi}from"apify-client";import ll from"archiver";import{AxiosHeaders as cl}from"axios";import ul from"escape-string-regexp";import{globby as Ai}from"globby";import{getEncoding as ml}from"istextorbinary";import{Mime as dl}from"mime";import pl from"mime/types/other.js";import fl from"mime/types/standard.js";import{gte as gl,minVersion as hl,satisfies as yl}from"semver";import{ACTOR_ENV_VARS as ys,ACTOR_JOB_TERMINAL_STATUSES as wl,ACTOR_NAME as Nt,APIFY_ENV_VARS as Al,KEY_VALUE_STORE_KEYS as fi,LOCAL_ACTOR_ENV_VARS as ws,LOCAL_STORAGE_SUBDIRS as As,SOURCE_FILE_FORMATS as Ot}from"@apify/consts";import{existsSync as Ka,mkdirSync as qa}from"fs";import{readFile as Wa,stat as ci,unlink as za,writeFile as Xa}from"fs/promises";import{join as ui,sep as Za}from"path";import{rimraf as Qa}from"rimraf";var mi=c(async(r,e={},t=null)=>{let o=await Wa(r,"utf-8"),s=JSON.parse(o),i;t?(i=s,i[t]={...s[t],...e}):i={...s,...e},await Xa(r,JSON.stringify(i,null," "))},"updateLocalJson"),lr=c((r,e)=>{e||(e=r,r="."),e.split(Za).reduce((o,s)=>(o=ui(o,s),Ka(o)||qa(o),o),r)},"ensureFolderExistsSync"),_t=c(async r=>{await Qa(r)},"rimrafPromised"),xt=c(async r=>{(await ci(r)).isFile()&&await za(r)},"deleteFile"),di=c(async(r,e)=>(await Promise.all(r.map(async s=>ci(ui(e,s))))).map(s=>s.size).reduce((s,i)=>s+i,0),"sumFilesSizeInBytes");var dt=al,ur=c(async r=>new Promise((e,t)=>{sl(r,o=>{o.statusCode===301||o.statusCode===302?(e(ur(o.headers.location)),o.destroy()):e(o)}).on("error",t)}),"httpsGet"),ce=c(()=>{let r=Al.LOCAL_STORAGE_DIR;return ae.env[r]||ae.env.CRAWLEE_STORAGE_DIR||Qe},"getLocalStorageDir"),Ce=c(r=>{let e=ys.DEFAULT_KEY_VALUE_STORE_ID,t=r||ae.env[e]||ws[e];return Ae(ce(),As.keyValueStores,t)},"getLocalKeyValueStorePath"),Si=c(r=>{let e=ys.DEFAULT_DATASET_ID,t=r||ae.env[e]||ws[e];return Ae(ce(),As.datasets,t)},"getLocalDatasetPath"),bi=c(r=>{let e=ys.DEFAULT_REQUEST_QUEUE_ID,t=r||ae.env[e]||ws[e];return Ae(ce(),As.requestQueues,t)},"getLocalRequestQueuePath"),F=c(async()=>{let r={};try{let e=await ol(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 Lt();if(!r)throw new Error('You are not logged in with your Apify account. Call "apify login" to fix that.');return r}c(C,"getLoggedClientOrThrow");var vi=c(r=>{if(!r&&le(mt())&&le(ne())){let e=Pt(ne(),"utf-8");return JSON.parse(e).token}return r},"getTokenWithAuthFileFallback"),Ss=c((r,e)=>(r=vi(r),{token:r,baseUrl:e||ae.env.APIFY_CLIENT_BASE_URL,requestInterceptors:[t=>{t.headers??=new cl;for(let[o,s]of Object.entries(ai))t.headers[o]=s;return t}]}),"getApifyClientOptions");async function Lt(r,e){r=vi(r);let t=new wi(Ss(r,e)),o;try{o=await t.user("me").get()}catch{return null}return vs(ne()),cr(ne(),JSON.stringify({token:t.token,...o},null," ")),t}c(Lt,"getLoggedClient");var bs=c(r=>Ae(r,j),"getLocalConfigPath"),Ee=c(r=>{if(le(r))return JSON.parse(Pt(r,{encoding:"utf-8"}))},"getJsonFileContent"),Fe=c(r=>Ee(bs(r)),"getLocalConfig"),mr=c(async(r,e)=>{let t=Ae(e||ae.cwd(),j);await rl(hi(t),{recursive:!0}),cr(t,JSON.stringify(r,null," "))},"setLocalConfig"),Sl=[ce(),"node_modules",".venv"],dr=c(async r=>{let e=Ce();lr(r,Si()),lr(r,bi()),lr(r,e);let t=Ae(r,".gitignore"),o="";le(t)&&(o=Pt(t,{encoding:"utf-8"}));let s=[];for(let i of Sl)RegExp(`^${ul(i)}$`,"mg").test(o)||s.push(i);s.length>0&&(o.length>0?(s.unshift("# Added by Apify CLI"),cr(t,`
|
|
2
2
|
${s.join(`
|
|
3
3
|
`)}
|
|
4
4
|
`,{flag:"a"})):cr(t,`${s.join(`
|
|
@@ -36,10 +36,10 @@ ${this.stack}`,"","- Arguments (!!!only provide these as is if there is no sensi
|
|
|
36
36
|
`)}}}static buildMessageFromFlagData(e){let t=[`Flag ${Y.white.bold(`--${e.name}`)}`];return e.ambiguousFlag?(t.push("is ambiguous (meaning the provided value could be interpreted as a flag too)."),e.ambiguousMessage?t.push(`
|
|
37
37
|
${e.ambiguousMessage.split(`
|
|
38
38
|
`).map(o=>` ${o}`).join(`
|
|
39
|
-
`)}`):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 ln(r){return r.replace(/[-_\s](.)/g,(e,t)=>t.toUpperCase())}c(ln,"camelCaseString");function Se(r){return r.replace(/[\s_]+/g,"-")}c(Se,"kebabCaseString");function be(r){return r.replace(/([A-Z])/g,"-$1").toLowerCase()}c(be,"camelCaseToKebabCase");var mc={type:"boolean",multiple:!1,short:"h"},dc={type:"boolean",multiple:!1},q=new Map,pc=["init","run","push","actors push","pull","actors pull","call","actors call","actors start"],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;commandString;skipTelemetry=!1;constructor(e,t){this.entrypoint=e,this.commandString=t;let
|
|
39
|
+
`)}`):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 ln(r){return r.replace(/[-_\s](.)/g,(e,t)=>t.toUpperCase())}c(ln,"camelCaseString");function Se(r){return r.replace(/[\s_]+/g,"-")}c(Se,"kebabCaseString");function be(r){return r.replace(/([A-Z])/g,"-$1").toLowerCase()}c(be,"camelCaseToKebabCase");var mc={type:"boolean",multiple:!1,short:"h"},dc={type:"boolean",multiple:!1},q=new Map,pc=["init","run","push","actors push","pull","actors pull","call","actors call","actors start"],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;commandString;aliasUsed;subcommandAliasUsed;skipTelemetry=!1;constructor(e,t,o,s){this.entrypoint=e,this.commandString=t,this.aliasUsed=o,this.subcommandAliasUsed=s;let i=K();this.telemetryData.installMethod=i.installMethod,this.telemetryData.osArch=i.arch,this.telemetryData.runtime=i.runtime.runtime,this.telemetryData.runtimeVersion=i.runtime.version,this.telemetryData.runtimeNodeVersion=i.runtime.nodeVersion??i.runtime.version,this.telemetryData.commandString=t,this.telemetryData.entrypoint=e}get ctor(){return this.constructor}pluralString(e,t,o){return e===1?t:o}static printHelp(){console.log(Rr(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,l]of Object.entries(this.ctor.args)){if(typeof l=="string")throw new RangeError("Do not provide the string for the json arg! It is a type level assertion!");let m=ln(a),u=o[n++];if(u)switch(l.argTag){case"string":default:this.args[m]=String(u),u==="-"&&l.stdin&&(this.args[m]=this._handleStdin(l.stdin)),l.catchAll&&(this.args[m]=o.slice(n-1).join(" "));break}else l.required&&i.set(a,l)}}if(i.size){this._printMissingRequiredArgs(i);return}this._parseFlags(t,s);try{await this.run()}catch(n){p({message:n.message})}finally{!this.telemetryData.actorLanguage&&pc.includes(this.commandString)&&(await je()).inspect(a=>{a.type===0?(this.telemetryData.actorLanguage="javascript",this.telemetryData.actorRuntime=a.runtime.runtimeShorthand||"node",this.telemetryData.actorRuntimeVersion=a.runtime.version):(a.type===1||a.type===2)&&(this.telemetryData.actorLanguage="python",this.telemetryData.actorRuntime="python",this.telemetryData.actorRuntimeVersion=a.runtime.version)}),this.telemetryData.flagsUsed=Object.keys(this.flags),this.skipTelemetry||await ki(`cli_command_${this.commandString.replaceAll(" ","_").toLowerCase()}`,this.telemetryData)}}_userFlagNameToRegisteredName(e,t){let o=Se(be(e)).toLowerCase(),s=o;o.startsWith("no-")&&(s=o.slice(3));let i=new Set;for(let n of t.aliases??[])i.add(Se(be(n)).toLowerCase());return{baseFlagName:s,rawBaseFlagName:o,allMatchers:[s,...i]}}_commandFlagKeyToKebabCaseRegisteredName(e){let t=Se(be(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:l,baseFlagName:m,rawBaseFlagName:u}=this._userFlagNameToRegisteredName(n,a),f=ln(u),d=t.some(S=>S.kind==="option"&&S.name===m);if(a.exclusive?.length){let S=o.get(m)??new Set;for(let b of a.exclusive)S.add(this._commandFlagKeyToKebabCaseRegisteredName(b));o.set(m,S);for(let b of a.exclusive){let T=this._commandFlagKeyToKebabCaseRegisteredName(b),E=o.get(T)??new Set;E.add(m),o.set(T,E)}}let g=l.filter(S=>e[S]);if(g.length>1)throw new ie({code:3,command:this.ctor,metadata:{flag:m}});let h=e[g[0]];if(!h&&a.required)throw new ie({code:6,command:this.ctor,metadata:{flag:m,matcher:g[0]}});if(Array.isArray(h)){if(h.length>1)throw new ie({code:3,command:this.ctor,metadata:{flag:m}});h=h[0]}if(d&&typeof h=="string"&&h.startsWith("=")&&(h=h.slice(1)),typeof h<"u")switch(a.flagTag){case"boolean":{this.flags[f]=u.startsWith("no-")?!h:h;break}case"integer":{let S=Number(h);if(Number.isNaN(S)||!Number.isInteger(S))throw new ie({code:4,command:this.ctor,metadata:{flag:m,value:String(h)}});this.flags[f]=S;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:m}});s=m,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:m,choices:a.choices.map(S=>Os.white.bold(S)).join(", ")}});if(this.flags[f]==null&&(a.required||h!=null))throw new ie({code:6,command:this.ctor,metadata:{flag:m,matcher:g[0],providedButReceivedNoValue:!!h}})}let i=[];for(let[n,a]of o)if(e[n]!=null)for(let l of a){if(e[l]==null)continue;let m=e[n][0],u=e[l][0],f=c((d,g)=>typeof g=="boolean"?g?`--${d}`:`--no-${d}`:`--${d}=${g}`,"flagRepresentation");i.push([f(n,m),f(l,u)]);break}if(i.length)throw new ie({code:7,command:this.ctor,metadata:{flagPairs:i}})}_printMissingRequiredArgs(e){let t=_r(this.ctor,{showUsageString:!0}),o=cc([...e.keys()].join(`
|
|
40
40
|
`)),s=[];for(let[i,n]of e){let a=`${i.padEnd(o)} ${n.description}`,l=uc(a,oe()-o-2),m=lc(l,o+2+2).trim();s.push(` ${Os.red(">")} ${m}`)}p({message:[`Missing ${e.size} required ${this.pluralString(e.size,"argument","arguments")}:`,...s,Os.gray(" See more help with --help"),"",t].join(`
|
|
41
|
-
`)})}_handleStdin(e){switch(e){case 2:return(ve?.toString("utf8")??"").trim();default:return ve}}_buildParseArgsOption(){let e={allowNegative:!0,allowPositionals:!0,strict:!0,tokens:!0,options:{help:mc}};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=Se(be(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=dc),e}static registerCommand(e){if(xs(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 cn(r,e,t){let o={positionals:[],values:{},tokens:[]},s=0;for(let[n,a]of Object.entries(t)){let[l,m]=n.split("_");if(l==="args")o.positionals[s++]=a;else{let u=Se(be(m)).toLowerCase();u.startsWith("no-")?o.values[u.slice(3)]=!a:o.values[u]=a}}let i=new e(r,e.name);i.skipTelemetry=!0,await i._run(o)}c(cn,"internalRunCommand");import{once as fc}from"events";async function un(){let r=await Sr(),{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",l=>{s.push(l),n&&(clearTimeout(n),n=null)});try{await fc(o,"end",{signal:i.signal})}catch(l){if(l.name==="AbortError")return}n&&clearTimeout(n),r.hasData=!1;let a=Buffer.concat(s);if(a.length)return a}c(un,"readStdin");import{gt as vc}from"semver";import{existsSync as gc,mkdirSync as hc,readFileSync as yc,writeFileSync as wc}from"fs";import{dirname as Ac}from"path";function Sc(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;I("LocalStateV0ToV1","Migrating state from v0 to v1",{oldState:r,newState:{versionCheck:{lastChecked:t,lastVersion:o}}}),Ps({version:1},s=>{s.versionCheck={lastChecked:t,lastVersion:o}})}return!0}c(Sc,"migrateStateV0ToV1");var bc={version:1};function Ns(){let r=ir();if(!gc(r))return bc;let t=JSON.parse(yc(r,"utf-8"));return Sc(t)?Ns():t}c(Ns,"useLocalState");function Ps(r,e){let t={...r};e(t);let o=ir(),s=Ac(o);hc(s,{recursive:!0}),wc(ir(),JSON.stringify(t,null," "))}c(Ps,"updateLocalState");var Pr=K(),mn=`Apify CLI/${Pr.version} (https://github.com/apify/apify-cli)`,Tc=["https://1.1.1.1","https://8.8.8.8"];async function Ic(r=500){let e=new AbortController,t=setTimeout(()=>{e.abort()},r),o=await Promise.any(Tc.map(async s=>fetch(s,{signal:e.signal,headers:{"User-Agent":mn},keepalive:!1}))).catch(()=>null);return clearTimeout(t),o?o.ok?(I("isOnline",{state:"online",site:o.url}),!0):(I("isOnline",{state:"offline"}),!1):(I("isOnline",{state:"timeout"}),!1)}c(Ic,"isOnline");async function Cc(r){let e=await fetch("https://api.github.com/repos/apify/apify-cli/releases/latest",{headers:{"User-Agent":mn}});if(!e.ok)return I("useCLIVersionCheck","Failed to fetch latest version",{statusCode:e.status,body:await e.text()}),x({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 I("useCLIVersionCheck","Fetched latest version",{version:o}),Ps(r,s=>{s.versionCheck={lastChecked:Date.now(),lastVersion:o}}),o}c(Cc,"getLatestVersion");function dn(){return!!(process.env.APIFY_CLI_SKIP_UPDATE_CHECK&&!["0","false"].includes(process.env.APIFY_CLI_SKIP_UPDATE_CHECK))}c(dn,"shouldSkipVersionCheck");async function pn(r=!1){let e=Ns(),t=!e.versionCheck||Date.now()-e.versionCheck.lastChecked>ni,o=r||t&&await Ic(),s=o?await Cc(e):e.versionCheck?.lastVersion;if(!s)return{currentVersion:Pr.version,latestVersion:"unknown",shouldUpdate:!1,cacheHit:!1};let i=vc(s,Pr.version);return{currentVersion:Pr.version,latestVersion:s,shouldUpdate:i,cacheHit:!o}}c(pn,"useCLIVersionCheck");import{jaroWinkler as Ec}from"@skyra/jaro-winkler";import $c from"js-levenshtein";function Lr(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(" "),l=a[a.length-1].toLowerCase(),m=i.aliases?.includes(l)||i.hiddenAliases?.includes(l)||!1,u=$c(t,n),f=Ec(t,n),d=u<=2||f>=.975;return d?(I("useCommandSuggestions",{inputString:t,lowercased:n,matches:d,levenshtein:u,jaroWinkler:f}),m?{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)}c(Lr,"useCommandSuggestions");var ve=await un(),Yt=K(),rt=`Apify CLI/${Yt.version} (https://github.com/apify/apify-cli)`;function Dh(r){Yt.installMethod!=="bundle"&&(Rc(Te.version,we)||(p({message:`${r} CLI requires Node.js version ${we}. Your current version is ${Te.version}.`}),Te.exit(1)))}c(Dh,"processVersionCheck");function _c(r){r.values.version===!0&&r.positionals.length===0&&(console.log(Yt.fullVersionString),Te.exit(0))}c(_c,"printCLIVersionAndExitIfFlagUsed");function xc(r,e){(r.values.help===!0&&r.positionals.length===0||r.positionals.length===0)&&(console.log(xr(e)),Te.exit(0))}c(xc,"printHelpAndExitIfFlagUsedOrNoCommandPassed");function gn(r){let e=Lr(String(r)),t=Dr.gray(`Command ${Dr.whiteBright(r)} not found`);e.length&&(t+=`
|
|
42
|
-
`,t+=Dr.gray(`Did you mean: ${e.map(o=>Dr.whiteBright(o)).join(", ")}?`)),p({message:t}),Te.exit(1)}c(gn,"handleCommandNotFound");async function Oc(r,e){let t=q.get("upgrade");if([t.name,...t.aliases??[]].some(s=>e===s)){I("[VersionCheckMiddleware]","upgrade command detected, skipping version check");return}if(dn()){I("[VersionCheckMiddleware]","skipping version check because APIFY_CLI_SKIP_UPDATE_CHECK is set");return}await cn(r,t,{flags_internalAutomaticCall:!0})}c(Oc,"runVersionCheck");async function Fh(r){I("CLIMetadata",{...Yt,fullVersionString:Yt.fullVersionString,argv:Te.argv,cwd:Te.cwd(),execPath:Te.execPath});let e=Te.argv.slice(2);I("ProcessArgv",e);let t=fn({allowPositionals:!0,strict:!1,options:{help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}},args:e});_c(t),xc(t,r),await Oc(r,t.positionals[0]),I("TopLevelOptions",t);let[o,s]=t.positionals,i=!1,n=q.get(o);if(!n)return gn(o);let a=n;if(n.subcommands?.length){if(!s)return n.printHelp();i=!0,a=q.get(`${o} ${s}`)}if(!a)return gn(`${o} ${s}`);let l=[...e],m=l.indexOf(o);if(I("CommandNameIndex",m),l.splice(m,1),i){let d=l.indexOf(s);I("SubcommandNameIndex",d),l.splice(d,1)}I("RebuiltArgs",l),I("CommandToRun",a);let u=new a(r,i?`${n.name} ${s}`:n.name),f=u._buildParseArgsOption();I("ParserOptionsForCommand",f);try{let d=fn({...f,args:l});await u._run(d),I("CommandArgsResult",d)}catch(d){let g=ie.into(d,a);p({message:g.getPrettyMessage()}),Te.exit(1)}}c(Fh,"runCLI");import{APIFY_ENV_VARS as Vc}from"@apify/consts";import Ht from"process";import{pipeline as Nc}from"stream/promises";import{MemoryStorage as Pc}from"@crawlee/memory-storage";import{ApifyClient as Lc}from"apify-client";import{ACTOR_ENV_VARS as hn,APIFY_ENV_VARS as yn,KEY_VALUE_STORE_KEYS as Dc,LOCAL_ACTOR_ENV_VARS as Fc}from"@apify/consts";var Jt={KEY_VALUE_STORE:"KEY_VALUE_STORE",DATASET:"DATASET",REQUEST_QUEUE:"REQUEST_QUEUE"},Ls=c(async()=>{let r=Ht.env[yn.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"),it=c(async(r={},e=Reflect.has(Ht.env,yn.IS_AT_HOME))=>{let t=ce();if(t&&!e)return new Pc({localDataDirectory:t,...r});let o=await Ls();return new Lc({...Ss(o),...r})},"getApifyStorageClient"),Kt=c(r=>{let e=hn[`DEFAULT_${r}_ID`];return Ht.env[e]||Fc[e]},"getDefaultStorageId"),Ds=c(async r=>{let e=await it(),t=Kt(Jt.KEY_VALUE_STORE),o=await e.keyValueStore(t).getRecord(r,{stream:!0});o&&await Nc(o.value,Ht.stdout,{end:!1})},"outputRecordFromDefaultStore"),wn=c(async()=>Ds(Ht.env[hn.INPUT_KEY]||Dc.INPUT),"outputInputFromDefaultStore");function kc(r){return{argTag:"string",required:r.required??!1,stdin:r.stdin??1,description:r.description,aliases:r.aliases,catchAll:r.catchAll??!1}}c(kc,"stringArg");var w={string:kc};var A={string:Uc,boolean:Mc,integer:jc};function Uc(r){return{flagTag:"string",builder:c(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:Se(be(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}}c(Uc,"stringFlag");function Mc(r){return{flagTag:"boolean",builder:c(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:Se(be(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}}c(Mc,"booleanFlag");function jc(r){return{flagTag:"integer",builder:c(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:Se(be(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}}c(jc,"integerFlag");var ft=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 Ls(),a=await Lt(n);if(!a)throw new Error("Apify token is not set. Please set it using the environment variable APIFY_TOKEN.");let l=process.env[Vc.ACTOR_RUN_ID];if(!l)throw new Error("Charge command must be executed in a running Actor. Run ID not found.");if((await a.run(l).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: ${l}).`,stdout:!0}),await a.run(l).charge({eventName:e,count:t,idempotencyKey:s})}};var gt=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 wn()}};import{ACTOR_ENV_VARS as Fs,APIFY_ENV_VARS as Bc}from"@apify/consts";var ht=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[Bc.IS_AT_HOME])){p({message:"get-public-url is not yet implemented for local development"}),process.exitCode=255;return}let t=process.env[Fs.DEFAULT_KEY_VALUE_STORE_ID];if(!t){p({message:`Missing environment variable: ${Fs.DEFAULT_KEY_VALUE_STORE_ID}. Please set it before running the command.`}),process.exitCode=5;return}let o=await it();if(!await o.keyValueStore(t).get()){p({message:`Key-Value store with ID '${t}' was not found. Ensure the store exists and that the correct ID is set in ${Fs.DEFAULT_KEY_VALUE_STORE_ID}.`}),process.exitCode=250;return}let i=await o.keyValueStore(t).getRecordPublicUrl(e);console.log(i)}};var yt=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 Ds(e)}};var wt=class extends y{static name="push-data";static description=`Saves data to Actor's run default dataset.
|
|
41
|
+
`)})}_handleStdin(e){switch(e){case 2:return(ve?.toString("utf8")??"").trim();default:return ve}}_buildParseArgsOption(){let e={allowNegative:!0,allowPositionals:!0,strict:!0,tokens:!0,options:{help:mc}};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=Se(be(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=dc),e}static registerCommand(e){if(xs(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 cn(r,e,t){let o={positionals:[],values:{},tokens:[]},s=0;for(let[n,a]of Object.entries(t)){let[l,m]=n.split("_");if(l==="args")o.positionals[s++]=a;else{let u=Se(be(m)).toLowerCase();u.startsWith("no-")?o.values[u.slice(3)]=!a:o.values[u]=a}}let i=new e(r,e.name,e.name);i.skipTelemetry=!0,await i._run(o)}c(cn,"internalRunCommand");import{once as fc}from"events";async function un(){let r=await Sr(),{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",l=>{s.push(l),n&&(clearTimeout(n),n=null)});try{await fc(o,"end",{signal:i.signal})}catch(l){if(l.name==="AbortError")return}n&&clearTimeout(n),r.hasData=!1;let a=Buffer.concat(s);if(a.length)return a}c(un,"readStdin");import{gt as vc}from"semver";import{existsSync as gc,mkdirSync as hc,readFileSync as yc,writeFileSync as wc}from"fs";import{dirname as Ac}from"path";function Sc(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;I("LocalStateV0ToV1","Migrating state from v0 to v1",{oldState:r,newState:{versionCheck:{lastChecked:t,lastVersion:o}}}),Ps({version:1},s=>{s.versionCheck={lastChecked:t,lastVersion:o}})}return!0}c(Sc,"migrateStateV0ToV1");var bc={version:1};function Ns(){let r=ir();if(!gc(r))return bc;let t=JSON.parse(yc(r,"utf-8"));return Sc(t)?Ns():t}c(Ns,"useLocalState");function Ps(r,e){let t={...r};e(t);let o=ir(),s=Ac(o);hc(s,{recursive:!0}),wc(ir(),JSON.stringify(t,null," "))}c(Ps,"updateLocalState");var Pr=K(),mn=`Apify CLI/${Pr.version} (https://github.com/apify/apify-cli)`,Tc=["https://1.1.1.1","https://8.8.8.8"];async function Ic(r=500){let e=new AbortController,t=setTimeout(()=>{e.abort()},r),o=await Promise.any(Tc.map(async s=>fetch(s,{signal:e.signal,headers:{"User-Agent":mn},keepalive:!1}))).catch(()=>null);return clearTimeout(t),o?o.ok?(I("isOnline",{state:"online",site:o.url}),!0):(I("isOnline",{state:"offline"}),!1):(I("isOnline",{state:"timeout"}),!1)}c(Ic,"isOnline");async function Cc(r){let e=await fetch("https://api.github.com/repos/apify/apify-cli/releases/latest",{headers:{"User-Agent":mn}});if(!e.ok)return I("useCLIVersionCheck","Failed to fetch latest version",{statusCode:e.status,body:await e.text()}),x({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 I("useCLIVersionCheck","Fetched latest version",{version:o}),Ps(r,s=>{s.versionCheck={lastChecked:Date.now(),lastVersion:o}}),o}c(Cc,"getLatestVersion");function dn(){return!!(process.env.APIFY_CLI_SKIP_UPDATE_CHECK&&!["0","false"].includes(process.env.APIFY_CLI_SKIP_UPDATE_CHECK))}c(dn,"shouldSkipVersionCheck");async function pn(r=!1){let e=Ns(),t=!e.versionCheck||Date.now()-e.versionCheck.lastChecked>ni,o=r||t&&await Ic(),s=o?await Cc(e):e.versionCheck?.lastVersion;if(!s)return{currentVersion:Pr.version,latestVersion:"unknown",shouldUpdate:!1,cacheHit:!1};let i=vc(s,Pr.version);return{currentVersion:Pr.version,latestVersion:s,shouldUpdate:i,cacheHit:!o}}c(pn,"useCLIVersionCheck");import{jaroWinkler as Ec}from"@skyra/jaro-winkler";import $c from"js-levenshtein";function Lr(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(" "),l=a[a.length-1].toLowerCase(),m=i.aliases?.includes(l)||i.hiddenAliases?.includes(l)||!1,u=$c(t,n),f=Ec(t,n),d=u<=2||f>=.975;return d?(I("useCommandSuggestions",{inputString:t,lowercased:n,matches:d,levenshtein:u,jaroWinkler:f}),m?{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)}c(Lr,"useCommandSuggestions");var ve=await un(),Yt=K(),rt=`Apify CLI/${Yt.version} (https://github.com/apify/apify-cli)`;function Dh(r){Yt.installMethod!=="bundle"&&(Rc(Te.version,we)||(p({message:`${r} CLI requires Node.js version ${we}. Your current version is ${Te.version}.`}),Te.exit(1)))}c(Dh,"processVersionCheck");function _c(r){r.values.version===!0&&r.positionals.length===0&&(console.log(Yt.fullVersionString),Te.exit(0))}c(_c,"printCLIVersionAndExitIfFlagUsed");function xc(r,e){(r.values.help===!0&&r.positionals.length===0||r.positionals.length===0)&&(console.log(xr(e)),Te.exit(0))}c(xc,"printHelpAndExitIfFlagUsedOrNoCommandPassed");function gn(r){let e=Lr(String(r)),t=Dr.gray(`Command ${Dr.whiteBright(r)} not found`);e.length&&(t+=`
|
|
42
|
+
`,t+=Dr.gray(`Did you mean: ${e.map(o=>Dr.whiteBright(o)).join(", ")}?`)),p({message:t}),Te.exit(1)}c(gn,"handleCommandNotFound");async function Oc(r,e){let t=q.get("upgrade");if([t.name,...t.aliases??[]].some(s=>e===s)){I("[VersionCheckMiddleware]","upgrade command detected, skipping version check");return}if(dn()){I("[VersionCheckMiddleware]","skipping version check because APIFY_CLI_SKIP_UPDATE_CHECK is set");return}await cn(r,t,{flags_internalAutomaticCall:!0})}c(Oc,"runVersionCheck");async function Fh(r){I("CLIMetadata",{...Yt,fullVersionString:Yt.fullVersionString,argv:Te.argv,cwd:Te.cwd(),execPath:Te.execPath});let e=Te.argv.slice(2);I("ProcessArgv",e);let t=fn({allowPositionals:!0,strict:!1,options:{help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}},args:e});_c(t),xc(t,r),await Oc(r,t.positionals[0]),I("TopLevelOptions",t);let[o,s]=t.positionals,i=!1,n=q.get(o);if(!n)return gn(o);let a=n;if(n.subcommands?.length){if(!s)return n.printHelp();i=!0,a=q.get(`${o} ${s}`)}if(!a)return gn(`${o} ${s}`);let l=[...e],m=l.indexOf(o);if(I("CommandNameIndex",m),l.splice(m,1),i){let d=l.indexOf(s);I("SubcommandNameIndex",d),l.splice(d,1)}I("RebuiltArgs",l),I("CommandToRun",a);let u=new a(r,i?`${n.name} ${s}`:n.name,o,i?s:void 0),f=u._buildParseArgsOption();I("ParserOptionsForCommand",f);try{let d=fn({...f,args:l});await u._run(d),I("CommandArgsResult",d)}catch(d){let g=ie.into(d,a);p({message:g.getPrettyMessage()}),Te.exit(1)}}c(Fh,"runCLI");import{APIFY_ENV_VARS as Vc}from"@apify/consts";import Ht from"process";import{pipeline as Nc}from"stream/promises";import{MemoryStorage as Pc}from"@crawlee/memory-storage";import{ApifyClient as Lc}from"apify-client";import{ACTOR_ENV_VARS as hn,APIFY_ENV_VARS as yn,KEY_VALUE_STORE_KEYS as Dc,LOCAL_ACTOR_ENV_VARS as Fc}from"@apify/consts";var Jt={KEY_VALUE_STORE:"KEY_VALUE_STORE",DATASET:"DATASET",REQUEST_QUEUE:"REQUEST_QUEUE"},Ls=c(async()=>{let r=Ht.env[yn.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"),it=c(async(r={},e=Reflect.has(Ht.env,yn.IS_AT_HOME))=>{let t=ce();if(t&&!e)return new Pc({localDataDirectory:t,...r});let o=await Ls();return new Lc({...Ss(o),...r})},"getApifyStorageClient"),Kt=c(r=>{let e=hn[`DEFAULT_${r}_ID`];return Ht.env[e]||Fc[e]},"getDefaultStorageId"),Ds=c(async r=>{let e=await it(),t=Kt(Jt.KEY_VALUE_STORE),o=await e.keyValueStore(t).getRecord(r,{stream:!0});o&&await Nc(o.value,Ht.stdout,{end:!1})},"outputRecordFromDefaultStore"),wn=c(async()=>Ds(Ht.env[hn.INPUT_KEY]||Dc.INPUT),"outputInputFromDefaultStore");function kc(r){return{argTag:"string",required:r.required??!1,stdin:r.stdin??1,description:r.description,aliases:r.aliases,catchAll:r.catchAll??!1}}c(kc,"stringArg");var w={string:kc};var A={string:Uc,boolean:Mc,integer:jc};function Uc(r){return{flagTag:"string",builder:c(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:Se(be(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}}c(Uc,"stringFlag");function Mc(r){return{flagTag:"boolean",builder:c(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:Se(be(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}}c(Mc,"booleanFlag");function jc(r){return{flagTag:"integer",builder:c(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:Se(be(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}}c(jc,"integerFlag");var ft=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 Ls(),a=await Lt(n);if(!a)throw new Error("Apify token is not set. Please set it using the environment variable APIFY_TOKEN.");let l=process.env[Vc.ACTOR_RUN_ID];if(!l)throw new Error("Charge command must be executed in a running Actor. Run ID not found.");if((await a.run(l).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: ${l}).`,stdout:!0}),await a.run(l).charge({eventName:e,count:t,idempotencyKey:s})}};var gt=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 wn()}};import{ACTOR_ENV_VARS as Fs,APIFY_ENV_VARS as Bc}from"@apify/consts";var ht=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[Bc.IS_AT_HOME])){p({message:"get-public-url is not yet implemented for local development"}),process.exitCode=255;return}let t=process.env[Fs.DEFAULT_KEY_VALUE_STORE_ID];if(!t){p({message:`Missing environment variable: ${Fs.DEFAULT_KEY_VALUE_STORE_ID}. Please set it before running the command.`}),process.exitCode=5;return}let o=await it();if(!await o.keyValueStore(t).get()){p({message:`Key-Value store with ID '${t}' was not found. Ensure the store exists and that the correct ID is set in ${Fs.DEFAULT_KEY_VALUE_STORE_ID}.`}),process.exitCode=250;return}let i=await o.keyValueStore(t).getRecordPublicUrl(e);console.log(i)}};var yt=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 Ds(e)}};var wt=class extends y{static name="push-data";static description=`Saves data to Actor's run default dataset.
|
|
43
43
|
|
|
44
44
|
Accept input as:
|
|
45
45
|
- JSON argument:
|
|
@@ -97,7 +97,7 @@ Uses authenticated account and local key-value store for input.`;static flags={.
|
|
|
97
97
|
# apify cli
|
|
98
98
|
${n.join(`
|
|
99
99
|
`)}`;await Hn(a,m),v({message:Je.gray(`Added "${ke(t)}" to $PATH in ${ke(a)}`)})}else v({message:[Je.gray(`Manually add the following lines to your shell config file (${ke(a)} or similar):`),...n.map(l=>Je.white.bold(` ${l}`))].join(`
|
|
100
|
-
`)})}};import{spawn as om}from"child_process";import{existsSync as sm}from"fs";import{lstat as im,readdir as nm,writeFile as qn}from"fs/promises";import{dirname as am,join as Bs}from"path";import Gs from"chalk";import{gte as Wn}from"semver";import{Result as zu}from"@sapphire/result";import{execa as Xu}from"execa";var Zu=c(async(r,e,t)=>{let o=Ue(r);I("spawnPromised",{escapedCommand:o,args:e,opts:t});let s=Xu(o,e,{shell:!0,windowsHide:!0,env:t.env,cwd:t.cwd,stdout:process.env.APIFY_NO_LOGS_IN_TESTS?["pipe"]:["pipe","inherit"],stderr:process.env.APIFY_NO_LOGS_IN_TESTS?["pipe"]:["pipe","inherit"],verbose:process.env.APIFY_CLI_DEBUG?"full":void 0});return zu.fromAsync(s.catch(i=>{throw new Error(`${r} exited with code ${i.exitCode}`,{cause:i})}))},"spawnPromised");async function pe({cmd:r,args:e=[],opts:t={},overrideCommand:o}){ye({message:`${o||r} ${e.join(" ")}`});let s=await Zu(r,e,t);if(s.isErr()){let i=s.unwrapErr();if(p({message:i.message}),i.cause)throw i.cause}}c(pe,"execWithLog");import{execSync as Jn}from"child_process";import{existsSync as Qu,readFileSync as em}from"fs";var Le=K();function tm(){return Le.platform==="linux"?Qu("/etc/alpine-release"):!1}c(tm,"isInstalledOnMusl");function rm(){return Le.platform==="darwin"&&Le.arch==="x64"?!Jn("sysctl -a",{encoding:"utf-8"}).includes("AVX2"):Le.platform==="linux"&&Le.arch==="x64"?!em("/proc/cpuinfo","utf-8").includes("avx2"):Le.platform==="windows"?Le.arch==="arm64"?!0:Jn(`pwsh -c "!(Add-Type -MemberDefinition '[DllImport(\\"kernel32.dll\\")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);' -Name 'Kernel32' -Namespace 'Win32' -PassThru)::IsProcessorFeaturePresent(40)"`,{encoding:"utf-8",windowsHide:!0}).trim().toLowerCase()==="true":!1}c(rm,"isInstalledOnBaseline");async function Kn(r){let e=r.replace(/^v(\d+)/,"$1"),t=e==="latest"?"latest":`tags/v${e}`,o=await fetch(`https://api.github.com/repos/apify/apify-cli/releases/${t}`,{headers:{"User-Agent":rt}});if(!o.ok)return I("useCLIVersionAssets","Failed to fetch release",{statusCode:o.status,body:await o.text(),version:r,tag:t}),null;let s=await o.json(),i=tm(),n=rm(),a=s.assets.filter(l=>{let[m,u,f,d,g,h]=l.name.replace(e,"version").replace(".exe","").split("-");return f!==Le.platform||d!==Le.arch?!1:i?g==="musl":n?h==="baseline"||g==="baseline":!g&&!h});return I("useCLIVersionAssets","Fetched release",{version:s.tag_name,filteredAssets:a}),{assets:a,version:s.tag_name.replace(/^v(\d+)/,"$1")}}c(Kn,"useCLIVersionAssets");var zn={bundle:c((r,e)=>[`${e}`,"upgrade"],"bundle"),npm:c(r=>["npm","install","-g",`apify-cli@${r}`],"npm"),pnpm:c(r=>["pnpm","install","-g",`apify-cli@${r}`],"pnpm"),bun:c(r=>["bun","install","-g",`apify-cli@${r}`],"bun"),homebrew:c(()=>["brew","upgrade","apify-cli"],"homebrew"),volta:c(r=>["volta","install",`apify-cli@${r}`],"volta")},so="0.
|
|
100
|
+
`)})}};import{spawn as om}from"child_process";import{existsSync as sm}from"fs";import{lstat as im,readdir as nm,writeFile as qn}from"fs/promises";import{dirname as am,join as Bs}from"path";import Gs from"chalk";import{gte as Wn}from"semver";import{Result as zu}from"@sapphire/result";import{execa as Xu}from"execa";var Zu=c(async(r,e,t)=>{let o=Ue(r);I("spawnPromised",{escapedCommand:o,args:e,opts:t});let s=Xu(o,e,{shell:!0,windowsHide:!0,env:t.env,cwd:t.cwd,stdout:process.env.APIFY_NO_LOGS_IN_TESTS?["pipe"]:["pipe","inherit"],stderr:process.env.APIFY_NO_LOGS_IN_TESTS?["pipe"]:["pipe","inherit"],verbose:process.env.APIFY_CLI_DEBUG?"full":void 0});return zu.fromAsync(s.catch(i=>{throw new Error(`${r} exited with code ${i.exitCode}`,{cause:i})}))},"spawnPromised");async function pe({cmd:r,args:e=[],opts:t={},overrideCommand:o}){ye({message:`${o||r} ${e.join(" ")}`});let s=await Zu(r,e,t);if(s.isErr()){let i=s.unwrapErr();if(p({message:i.message}),i.cause)throw i.cause}}c(pe,"execWithLog");import{execSync as Jn}from"child_process";import{existsSync as Qu,readFileSync as em}from"fs";var Le=K();function tm(){return Le.platform==="linux"?Qu("/etc/alpine-release"):!1}c(tm,"isInstalledOnMusl");function rm(){return Le.platform==="darwin"&&Le.arch==="x64"?!Jn("sysctl -a",{encoding:"utf-8"}).includes("AVX2"):Le.platform==="linux"&&Le.arch==="x64"?!em("/proc/cpuinfo","utf-8").includes("avx2"):Le.platform==="windows"?Le.arch==="arm64"?!0:Jn(`pwsh -c "!(Add-Type -MemberDefinition '[DllImport(\\"kernel32.dll\\")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);' -Name 'Kernel32' -Namespace 'Win32' -PassThru)::IsProcessorFeaturePresent(40)"`,{encoding:"utf-8",windowsHide:!0}).trim().toLowerCase()==="true":!1}c(rm,"isInstalledOnBaseline");async function Kn(r){let e=r.replace(/^v(\d+)/,"$1"),t=e==="latest"?"latest":`tags/v${e}`,o=await fetch(`https://api.github.com/repos/apify/apify-cli/releases/${t}`,{headers:{"User-Agent":rt}});if(!o.ok)return I("useCLIVersionAssets","Failed to fetch release",{statusCode:o.status,body:await o.text(),version:r,tag:t}),null;let s=await o.json(),i=tm(),n=rm(),a=s.assets.filter(l=>{let[m,u,f,d,g,h]=l.name.replace(e,"version").replace(".exe","").split("-");return f!==Le.platform||d!==Le.arch?!1:i?g==="musl":n?h==="baseline"||g==="baseline":!g&&!h});return I("useCLIVersionAssets","Fetched release",{version:s.tag_name,filteredAssets:a}),{assets:a,version:s.tag_name.replace(/^v(\d+)/,"$1")}}c(Kn,"useCLIVersionAssets");var zn={bundle:c((r,e)=>[`${e}`,"upgrade"],"bundle"),npm:c(r=>["npm","install","-g",`apify-cli@${r}`],"npm"),pnpm:c(r=>["pnpm","install","-g",`apify-cli@${r}`],"pnpm"),bun:c(r=>["bun","install","-g",`apify-cli@${r}`],"bun"),homebrew:c(()=>["brew","upgrade","apify-cli"],"homebrew"),volta:c(r=>["volta","install",`apify-cli@${r}`],"volta")},so="1.0.1",Xn="https://raw.githubusercontent.com/apify/apify-cli/main/scripts/install/upgrade.ps1",zt=class extends y{static name="upgrade";static description="Checks that installed Apify CLI version is up to date.";static hidden=!0;static aliases=["cv","check-version"];static flags={force:A.boolean({description:"[DEPRECATED] This flag is now ignored, as running the command manually will always check for the latest version.",required:!1,char:"f"}),version:A.string({description:"The version of the CLI to upgrade to. If not provided, the latest version will be used.",required:!1}),"internal-automatic-call":A.boolean({description:"Whether the command was called automatically by the CLI for a version check.",hidden:!0,default:!1})};get cliName(){return this.entrypoint==="apify"?"Apify CLI":"Actor CLI"}async run(){if(this.flags.version){await this.handleInstallSpecificVersion(this.flags.version);return}let e=await pn(!this.flags.internalAutomaticCall),{installMethod:t}=K();if(!e.shouldUpdate||e.currentVersion===ms){I("[upgrade] no update needed",{shouldUpdate:e.shouldUpdate,currentVersion:e.currentVersion}),this.flags.internalAutomaticCall||v({message:`${this.cliName} is up to date \u{1F44D}
|
|
101
101
|
`});return}if(!this.flags.internalAutomaticCall){await this.handleInstallSpecificVersion("latest");return}let o=zn[t]("latest",this.entrypoint).join(" ");_({message:""});let s=[`You are using an old version of ${this.cliName}. We strongly recommend you always use the latest available version.`,` \u21AA Run ${Gs.bgWhite(Gs.black(o))} to update! \u{1F44D}
|
|
102
102
|
`].join(`
|
|
103
103
|
`);x({message:s})}async handleInstallSpecificVersion(e){if(e!=="latest"&&!Wn(e,so)){p({message:`The minimum version of the CLI you can manually downgrade/upgrade to is ${so}.`});return}let t=await Kn(e);if(!t){p({message:"The provided version does not exist. Please check the version number and try again."});return}let{assets:o,version:s}=t;if(!Wn(s,so)){p({message:`The minimum version of the CLI you can manually downgrade/upgrade to is ${so}.`});return}let i=K();if(i.installMethod==="bundle"){if(!o.length){p({message:["Failed to find the assets for your system and the provided version. Please open an issue on https://github.com/apify/apify-cli/issues/new and provide the following information:",`- The version you are trying to upgrade to: ${s}`,`- The system you are running on: ${i.platform} ${i.arch}`].join(`
|
|
@@ -239,4 +239,4 @@ Read more: https://docs.apify.com/cli/docs/telemetry`;static subcommands=[ls,as]
|
|
|
239
239
|
4. INPUT_SCHEMA.json
|
|
240
240
|
|
|
241
241
|
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 ct({forcePath:this.args.path,cwd:Sd.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 dt({strict:!1});bd(o,e),$({message:"Input schema is valid."})}};var Ex=[kr,zr,to,wo,Do,jo,ts,ss,ns,tr,ro,zt,Wt,ao,Ao,bo,Co,Io,Fo,ko,Uo,Mo,Ho,cs,Xt],$x=[At,wt,yt,ht,gt,ft,Xt,zt,Wt,tr];export{Dh as a,Fh as b,Ex as c,$x as d};
|
|
242
|
-
//# sourceMappingURL=chunk-
|
|
242
|
+
//# sourceMappingURL=chunk-7TLAU6MJ.js.map
|