apify-cli 1.10.1-runtime.7 → 1.10.1-runtime.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from"node:process";import t from"chalk";import n from"indent-string";import r from"widest-line";import i from"wrap-ansi";import a,{basename as s,dirname as c,isAbsolute as l,join as u,relative as f,resolve as p,sep as m}from"node:path";import{inspect as h,parseArgs as g,promisify as _}from"node:util";import{gt as v,gte as y,minVersion as b,satisfies as x}from"semver";import{appendFileSync as S,chmodSync as C,constants as w,copyFileSync as T,createWriteStream as E,existsSync as D,fstat as ee,lstatSync as O,mkdirSync as k,openSync as A,readFileSync as j,readdirSync as te,readlinkSync as ne,realpathSync as M,renameSync as N,rmSync as P,statSync as re,unlinkSync as ie,writeFileSync as F}from"node:fs";import ae from"string-width";import oe from"strip-ansi";import{once as se}from"node:events";import{homedir as ce,platform as le,tmpdir as ue}from"node:os";import de,{isCI as fe}from"ci-info";import{ACTOR_ENV_VARS as I,ACTOR_JOB_STATUSES as L,ACTOR_JOB_TERMINAL_STATUSES as pe,ACTOR_NAME as me,ACTOR_SOURCE_TYPES as he,APIFY_ENV_VARS as R,KEY_VALUE_STORE_KEYS as ge,LOCAL_ACTOR_ENV_VARS as _e,LOCAL_STORAGE_SUBDIRS as ve,MAX_MULTIFILE_BYTES as ye,META_ORIGINS as be,SOURCE_FILE_FORMATS as xe}from"@apify/consts";import{jaroWinkler as Se}from"@skyra/jaro-winkler";import Ce from"js-levenshtein";import{Result as we,err as Te,none as z,ok as Ee,some as De}from"@sapphire/result";import{execa as B}from"execa";import{access as Oe,appendFile as ke,mkdir as V,mkdtemp as Ae,readFile as H,readdir as je,rename as Me,rm as Ne,stat as U,symlink as Pe,unlink as Fe,writeFile as W}from"node:fs/promises";import Ie from"configparser";import Le from"@inquirer/input";import Re from"which";import{createHmacSignature as ze,cryptoRandomObjectId as Be}from"@apify/utilities";import{execFileSync as Ve,execSync as He,spawn as Ue}from"node:child_process";import{DurationFormatter as We,Time as Ge,TimeTypes as Ke}from"@sapphire/duration";import{Timestamp as qe}from"@sapphire/timestamp";import Je from"adm-zip";import Ye from"ajv/dist/2019.js";import{ApifyClient as Xe,DownloadItemsFormat as G}from"apify-client";import{TarArchive as Ze,ZipArchive as Qe}from"archiver";import $e,{AxiosHeaders as et}from"axios";import tt from"escape-string-regexp";import nt from"ignore";import{getEncoding as rt}from"istextorbinary";import it,{Mime as at}from"mime";import ot from"mime/types/other.js";import st from"mime/types/standard.js";import{glob as ct}from"tinyglobby";import{calculateRunDynamicMemory as lt}from"@apify/actor-memory-expression";import{Separator as ut,createPrompt as dt,isEnterKey as ft,makeTheme as pt,useKeypress as mt,usePrefix as ht,useState as gt}from"@inquirer/core";import{pipeline as _t}from"node:stream/promises";import{MemoryStorage as vt}from"@crawlee/memory-storage";import{compile as yt}from"json-schema-to-typescript";import{validateInputSchema as bt,validateInputUsingValidator as xt}from"@apify/input_schema";import{getDatasetSchemaValidator as St,getKeyValueStoreSchemaValidator as Ct,getOutputSchemaValidator as wt}from"@apify/json_schemas";import Tt from"cli-table3";import{downloadTemplate as Et}from"giget";import Dt from"jju";import Ot from"open";import{fetchManifest as kt,manifestUrl as At,wrapperManifestUrl as jt}from"@apify/actor-templates";import Mt from"computer-name";import Nt from"@inquirer/password";import Pt from"@inquirer/select";import{createServer as Ft}from"node:http";import It from"node:assert";import{ReadStream as Lt}from"node:tty";import{setTimeout as Rt}from"node:timers/promises";import zt from"detect-indent";import{fileURLToPath as Bt}from"node:url";import Vt from"@root/walk";import Ht from"handlebars";function internalLog(e){e.stdoutOutput&&console.log(...e.stdoutOutput),e.stderrOutput&&console.error(...e.stderrOutput)}function simpleLog(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[e.message]})}function error(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.red(`Error:`),e.message]})}function warning(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.yellow.bold(`Warning:`),e.message]})}function success(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.green(`Success:`),e.message]})}function run(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.gray(`Run:`),e.message]})}function info(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.white(`Info:`),e.message]})}function detectInstallMethod(){if(process.env.APIFY_CLI_BUNDLE)return`bundle`;let e=process.argv[1];if(!e)return warning({message:`Failed to detect install method of CLI, assuming npm`}),`npm`;let t=M(e);return process.env.VOLTA_HOME&&t.includes(process.env.VOLTA_HOME)?`volta`:t.includes(`homebrew/Cellar`)||t.includes(`linuxbrew/Cellar`)?`homebrew`:process.env.PNPM_HOME&&t.includes(process.env.PNPM_HOME)?`pnpm`:process.env.BUN_INSTALL&&t.includes(process.env.BUN_INSTALL)?`bun`:`npm`}function getRuntimeInfo(){return process.versions.bun?{runtime:`bun`,version:process.versions.bun,nodeVersion:process.versions.node}:process.versions.deno?{runtime:`deno`,version:process.versions.deno,nodeVersion:process.versions.node}:{runtime:`node`,version:process.versions.node}}let Ut=null;function useCLIMetadata(){if(Ut)return Ut;let e=detectInstallMethod(),t=getRuntimeInfo();return Ut={version:`1.10.1-runtime.
|
|
1
|
+
import e from"node:process";import t from"chalk";import n from"indent-string";import r from"widest-line";import i from"wrap-ansi";import a,{basename as s,dirname as c,isAbsolute as l,join as u,relative as f,resolve as p,sep as m}from"node:path";import{inspect as h,parseArgs as g,promisify as _}from"node:util";import{gt as v,gte as y,minVersion as b,satisfies as x}from"semver";import{appendFileSync as S,chmodSync as C,constants as w,copyFileSync as T,createWriteStream as E,existsSync as D,fstat as ee,lstatSync as O,mkdirSync as k,openSync as A,readFileSync as j,readdirSync as te,readlinkSync as ne,realpathSync as M,renameSync as N,rmSync as P,statSync as re,unlinkSync as ie,writeFileSync as F}from"node:fs";import ae from"string-width";import oe from"strip-ansi";import{once as se}from"node:events";import{homedir as ce,platform as le,tmpdir as ue}from"node:os";import de,{isCI as fe}from"ci-info";import{ACTOR_ENV_VARS as I,ACTOR_JOB_STATUSES as L,ACTOR_JOB_TERMINAL_STATUSES as pe,ACTOR_NAME as me,ACTOR_SOURCE_TYPES as he,APIFY_ENV_VARS as R,KEY_VALUE_STORE_KEYS as ge,LOCAL_ACTOR_ENV_VARS as _e,LOCAL_STORAGE_SUBDIRS as ve,MAX_MULTIFILE_BYTES as ye,META_ORIGINS as be,SOURCE_FILE_FORMATS as xe}from"@apify/consts";import{jaroWinkler as Se}from"@skyra/jaro-winkler";import Ce from"js-levenshtein";import{Result as we,err as Te,none as z,ok as Ee,some as De}from"@sapphire/result";import{execa as B}from"execa";import{access as Oe,appendFile as ke,mkdir as V,mkdtemp as Ae,readFile as H,readdir as je,rename as Me,rm as Ne,stat as U,symlink as Pe,unlink as Fe,writeFile as W}from"node:fs/promises";import Ie from"configparser";import Le from"@inquirer/input";import Re from"which";import{createHmacSignature as ze,cryptoRandomObjectId as Be}from"@apify/utilities";import{execFileSync as Ve,execSync as He,spawn as Ue}from"node:child_process";import{DurationFormatter as We,Time as Ge,TimeTypes as Ke}from"@sapphire/duration";import{Timestamp as qe}from"@sapphire/timestamp";import Je from"adm-zip";import Ye from"ajv/dist/2019.js";import{ApifyClient as Xe,DownloadItemsFormat as G}from"apify-client";import{TarArchive as Ze,ZipArchive as Qe}from"archiver";import $e,{AxiosHeaders as et}from"axios";import tt from"escape-string-regexp";import nt from"ignore";import{getEncoding as rt}from"istextorbinary";import it,{Mime as at}from"mime";import ot from"mime/types/other.js";import st from"mime/types/standard.js";import{glob as ct}from"tinyglobby";import{calculateRunDynamicMemory as lt}from"@apify/actor-memory-expression";import{Separator as ut,createPrompt as dt,isEnterKey as ft,makeTheme as pt,useKeypress as mt,usePrefix as ht,useState as gt}from"@inquirer/core";import{pipeline as _t}from"node:stream/promises";import{MemoryStorage as vt}from"@crawlee/memory-storage";import{compile as yt}from"json-schema-to-typescript";import{validateInputSchema as bt,validateInputUsingValidator as xt}from"@apify/input_schema";import{getDatasetSchemaValidator as St,getKeyValueStoreSchemaValidator as Ct,getOutputSchemaValidator as wt}from"@apify/json_schemas";import Tt from"cli-table3";import{downloadTemplate as Et}from"giget";import Dt from"jju";import Ot from"open";import{fetchManifest as kt,manifestUrl as At,wrapperManifestUrl as jt}from"@apify/actor-templates";import Mt from"computer-name";import Nt from"@inquirer/password";import Pt from"@inquirer/select";import{createServer as Ft}from"node:http";import It from"node:assert";import{ReadStream as Lt}from"node:tty";import{setTimeout as Rt}from"node:timers/promises";import zt from"detect-indent";import{fileURLToPath as Bt}from"node:url";import Vt from"@root/walk";import Ht from"handlebars";function internalLog(e){e.stdoutOutput&&console.log(...e.stdoutOutput),e.stderrOutput&&console.error(...e.stderrOutput)}function simpleLog(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[e.message]})}function error(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.red(`Error:`),e.message]})}function warning(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.yellow.bold(`Warning:`),e.message]})}function success(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.green(`Success:`),e.message]})}function run(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.gray(`Run:`),e.message]})}function info(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.white(`Info:`),e.message]})}function detectInstallMethod(){if(process.env.APIFY_CLI_BUNDLE)return`bundle`;let e=process.argv[1];if(!e)return warning({message:`Failed to detect install method of CLI, assuming npm`}),`npm`;let t=M(e);return process.env.VOLTA_HOME&&t.includes(process.env.VOLTA_HOME)?`volta`:t.includes(`homebrew/Cellar`)||t.includes(`linuxbrew/Cellar`)?`homebrew`:process.env.PNPM_HOME&&t.includes(process.env.PNPM_HOME)?`pnpm`:process.env.BUN_INSTALL&&t.includes(process.env.BUN_INSTALL)?`bun`:`npm`}function getRuntimeInfo(){return process.versions.bun?{runtime:`bun`,version:process.versions.bun,nodeVersion:process.versions.node}:process.versions.deno?{runtime:`deno`,version:process.versions.deno,nodeVersion:process.versions.node}:{runtime:`node`,version:process.versions.node}}let Ut=null;function useCLIMetadata(){if(Ut)return Ut;let e=detectInstallMethod(),t=getRuntimeInfo();return Ut={version:`1.10.1-runtime.8`,hash:`70d1a2f3f479bb18de4f7364527161be232f5dfd`,arch:process.env.APIFY_BUNDLE_ARCH??process.arch,platform:process.platform===`win32`?`windows`:process.platform,runtime:t,extraRuntimeData:t.nodeVersion?`(emulating node ${t.nodeVersion})`:``,installMethod:e,get fullVersionString(){return`apify-cli/${this.version} (${this.hash.slice(0,7)}) running on ${this.platform}-${this.arch} with ${this.runtime.runtime}-${t.version}${this.extraRuntimeData?` ${this.extraRuntimeData}`:``}, installed via ${this.installMethod}`},get isBeta(){return this.version.includes(`beta`)||this.version===`0.0.0`}},e===`bundle`&&(Ut.installPath=c(process.execPath)),Ut}function cliDebugPrint(e,...n){process.env.APIFY_CLI_DEBUG&&console.error(t.gray(`[${e}]`),...n)}const Wt=[`apify`,`actor`];function unixWrapperScript(e){return[`#!/bin/sh`,`DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"`,`APIFY_CLI_ENTRYPOINT=${e} exec "$DIR/apify-cli" "$@"`,``].join(`
|
|
2
2
|
`)}function windowsCmdWrapperScript(e){return[`@echo off`,`setlocal`,`set "APIFY_CLI_ENTRYPOINT=${e}"`,`"%~dp0apify-cli.exe" %*`,``].join(`\r
|
|
3
3
|
`)}function windowsPowershellWrapperScript(e){return[`#!/usr/bin/env pwsh`,`$prev = $env:APIFY_CLI_ENTRYPOINT`,`$env:APIFY_CLI_ENTRYPOINT = "${e}"`,`try {`,` & "$PSScriptRoot\\apify-cli.exe" @args`,`} finally {`,` $env:APIFY_CLI_ENTRYPOINT = $prev`,`}`,`exit $LASTEXITCODE`,``].join(`\r
|
|
4
4
|
`)}function atomicWriteSync(t,n,r){let i=`${t}.${e.pid}.tmp`;try{F(i,n),r!==void 0&&C(i,r),N(i,t)}catch(e){try{P(i,{force:!0})}catch{}throw e}}function atomicCopySync(t,n,r){let i=`${n}.${e.pid}.tmp`;try{T(t,i),r!==void 0&&C(i,r),N(i,n)}catch(e){try{P(i,{force:!0})}catch{}throw e}}function writeEntrypointShims(e,t){for(let n of Wt)atomicWriteSync(u(e,n),unixWrapperScript(n),493),t&&(atomicWriteSync(u(e,`${n}.cmd`),windowsCmdWrapperScript(n)),atomicWriteSync(u(e,`${n}.ps1`),windowsPowershellWrapperScript(n)))}function migrateLegacyBundleInstallIfNeeded(){let t=useCLIMetadata();if(t.installMethod!==`bundle`)return;let n=t.platform===`windows`,r=c(e.execPath),i=s(e.execPath).replace(/\.exe$/i,``).toLowerCase();if(n)for(let e of Wt){let t=u(r,`${e}.exe.old`);if(D(t))try{P(t,{force:!0}),cliDebugPrint(`[migration] removed stale legacy binary`,t)}catch(e){cliDebugPrint(`[migration] failed to remove stale legacy binary`,{stalePath:t,err:e})}}if(i===`apify-cli`||!Wt.includes(i))return;cliDebugPrint(`[migration] legacy multi-bundle install detected, migrating to single bundle`,{binDir:r,selfName:i});let a=u(r,`apify-cli${n?`.exe`:``}`);try{atomicCopySync(e.execPath,a,n?void 0:493),cliDebugPrint(`[migration] copied current bundle to`,a)}catch(e){cliDebugPrint(`[migration] failed to copy current bundle, will retry on next run`,{err:e});return}try{writeEntrypointShims(r,n),cliDebugPrint(`[migration] wrote entrypoint shims`)}catch(e){cliDebugPrint(`[migration] failed to write entrypoint shims, will retry on next run`,{err:e})}if(n){for(let t of Wt){let n=u(r,`${t}.exe`);if(D(n))try{p(n)===p(e.execPath)?(N(n,`${n}.old`),cliDebugPrint(`[migration] renamed running legacy binary`,n)):P(n,{force:!0})}catch(e){try{N(n,`${n}.old`)}catch{}cliDebugPrint(`[migration] failed to remove legacy binary`,{legacyBinaryPath:n,err:e})}}let t=u(r,`upgrade.ps1`);try{P(t,{force:!0}),cliDebugPrint(`[migration] removed upgrade script, it will be re-downloaded on the next upgrade`)}catch(e){cliDebugPrint(`[migration] failed to remove upgrade script`,{upgradeScriptPath:t,err:e})}}cliDebugPrint(`[migration] migration to single bundle complete`)}let Gt;function getMaxLineWidth(){if(Gt)return Gt;let e=Number(process.env.APIFY_CLI_MAX_LINE_WIDTH);if(!Number.isNaN(e))Gt=e;else if(!process.stdout.isTTY)Gt=80;else{let e=process.stdout.getWindowSize?.()[0]??-1;Gt=e<1?80:e<40?40:e}return Gt}var BaseCommandRenderer=class{command;entrypoint;constructor(e,t){this.entrypoint=e,this.command=t}pushShortDescription(e){let n=this.command.interactive?`${t.yellow(`[INTERACTIVE]`)} `:``;this.command.shortDescription?e.push(`${n}${this.command.shortDescription}`,``):this.command.description&&e.push(`${n}${this.command.description.split(`
|
|
@@ -45,7 +45,7 @@ Common package structures:
|
|
|
45
45
|
src/
|
|
46
46
|
my_package/
|
|
47
47
|
__init__.py
|
|
48
|
-
main.py`);return null}async function checkScrapyProject(e){return ScrapyProjectAnalyzer.isApplicable(e)}function normalizeExecutablePath(e){return e?e.startsWith(`"`)?e:l(e)&&e.includes(` `)?`"${e}"`:e:null}async function getInstallCommandSuggestion(e){let t=null;return await(await useCwdProject({cwd:e})).inspectAsync(async n=>{if(n.type===0){let[r,i,a,s]=await Promise.all([U(u(e,`yarn.lock`)).then(()=>!0).catch(()=>!1),U(u(e,`pnpm-lock.yaml`)).then(()=>!0).catch(()=>!1),U(u(e,`bun.lockb`)).then(()=>!0).catch(()=>!1),U(u(e,`bun.lock`)).then(()=>!0).catch(()=>!1)]);t=r?`yarn install`:i?`pnpm install`:a||s||n.runtime?.pmName===`bun`?`bun install`:n.runtime?.pmName===`deno`?`deno install --node-modules-dir`:`npm install`}else(n.type===1||n.type===2)&&(t=n.packageManager===`uv`?`uv sync`:`python -m pip install -r requirements.txt`)}),t}let Dn=`inherit`;function keepStdoutClean(){Dn=e.stderr}const spawnPromised=async(t,n,r,{forwardSignals:i}={})=>{let a=normalizeExecutablePath(t);cliDebugPrint(`spawnPromised`,{escapedCommand:a,args:n,opts:r,forwardSignals:i});let s=B(a,n,{shell:!0,windowsHide:!0,env:r.env,cwd:r.cwd,stdout:e.env.APIFY_NO_LOGS_IN_TESTS?[`pipe`]:[`pipe`,Dn],stderr:e.env.APIFY_NO_LOGS_IN_TESTS?[`pipe`]:[`pipe`,`inherit`],verbose:e.env.APIFY_CLI_DEBUG?`full`:void 0}),c=[];if(i?.length)for(let t of i){let handler=()=>{s.kill(t)};e.on(t,handler),c.push(()=>e.off(t,handler))}try{return await we.fromAsync(s.catch(e=>{let n;throw n=e.exitCode==null?e.signal?`${t} exited due to signal ${e.signal}`:e.shortMessage:`${t} exited with code ${e.exitCode}`,Error(n,{cause:e})}))}finally{for(let e of c)e()}};async function execWithLog({cmd:e,args:t=[],opts:n={},overrideCommand:r,forwardSignals:i}){run({message:`${r||e} ${t.join(` `)}`});let a=await spawnPromised(e,t,n,{forwardSignals:i});if(a.isErr()){let e=a.unwrapErr();if(error({message:e.message}),e.cause)throw e.cause}}const On=[[`CLAUDECODE`,`claude_code`],[`CLAUDE_CODE_ENTRYPOINT`,`claude_code`],[`CURSOR_AGENT`,`cursor`],[`CLINE_ACTIVE`,`cline`],[`CODEX_SANDBOX`,`codex_cli`],[`CODEX_THREAD_ID`,`codex_cli`],[`GEMINI_CLI`,`gemini_cli`],[`OPENCODE`,`open_code`],[`OPENCLAW_SHELL`,`openclaw`]];function detectAiAgent(){for(let[e,t]of On)if(process.env[e])return t}function detectCi(){return de.isCI?{isCi:!0,ciProvider:de.id?.toLowerCase()??`unknown`}:{isCi:!1,ciProvider:void 0}}function detectIsInteractive(){return!!process.stdin.isTTY&&!!process.stdout.isTTY}const updateLocalJson=async(e,t={},n=null)=>{let r=await H(e,`utf-8`),i=JSON.parse(r),a;n?(a=i,a[n]={...i[n],...t}):a={...i,...t},await W(e,JSON.stringify(a,null,` `))},ensureFolderExistsSync=(e,t)=>{t||(t=e,e=`.`),t.split(m).reduce((e,t)=>(e=u(e,t),D(e)||k(e),e),e)},rimrafPromised=async e=>{let t=Array.isArray(e)?e:[e];await Promise.all(t.map(async e=>Ne(e,{recursive:!0,force:!0})))},deleteFile=async e=>{(await U(e)).isFile()&&await Fe(e)};function ensureApifyDirectory(e){let t=c(e);k(t,{recursive:!0})}const sumFilesSizeInBytes=async(e,t)=>(await Promise.all(e.map(async e=>U(u(t,e))))).map(e=>e.size).reduce((e,t)=>e+t,0),kn=`token`,An=`proxy-password`;let jn,Mn,Nn;async function loadKeyringModule(){return jn===void 0&&(jn=await importKeyringModule()),jn}async function importKeyringModule(){if(useCLIMetadata().installMethod===`bundle`)try{let e=await import(`__APIFY_KEYRING_NATIVE_SUBPACKAGE__`),t=e.Entry??e.default?.Entry;return t?{Entry:t}:null}catch(e){return cliDebugPrint(`credentials`,`failed to load bundled keyring`,e),null}try{return await import(`@napi-rs/keyring`)}catch(e){return cliDebugPrint(`credentials`,`failed to load @napi-rs/keyring`,e),null}}async function getBackend(){return Mn||(Mn=(async()=>e.env.APIFY_DISABLE_KEYRING===`1`||readAuthFile().secretsBackend===`file`?`file`:await loadKeyringModule()?`keyring`:`file`)(),Mn)}function downgradeBackendToFile(){Mn=Promise.resolve(`file`)}function readAuthFile(){if(!D(AUTH_FILE_PATH()))return{};try{let e=j(AUTH_FILE_PATH(),`utf-8`);return JSON.parse(e)}catch{return{}}}function writeAuthFile(e){ensureApifyDirectory(AUTH_FILE_PATH()),F(AUTH_FILE_PATH(),JSON.stringify(e,null,` `),{mode:384})}async function getKeyringEntry(e){let t=await loadKeyringModule();return t?new t.Entry(`com.apify.cli`,e):null}async function readKeyring(e){try{let t=await getKeyringEntry(e);return t?t.getPassword()??void 0:void 0}catch(t){cliDebugPrint(`credentials`,`failed to read ${e} from keyring`,t);return}}async function writeKeyring(e,t){let n=await getKeyringEntry(e);if(!n)throw Error(`OS keyring is not available.`);n.setPassword(t)}async function deleteKeyring(e){try{let t=await getKeyringEntry(e);if(!t)return;t.deletePassword()}catch(t){cliDebugPrint(`credentials`,`failed to delete ${e} from keyring`,t)}}async function getToken(){return await getBackend()===`keyring`?readKeyring(kn):readAuthFile().token}async function getProxyPassword(){return await getBackend()===`keyring`?readKeyring(An):readAuthFile().proxy?.password}async function setToken(e,t={}){let n=await getBackend();if(t.skipIfUnchanged&&(n===`keyring`?await readKeyring(kn):readAuthFile().token)===e)return;if(n===`keyring`)try{await writeKeyring(kn,e);return}catch(e){cliDebugPrint(`credentials`,`keyring write failed; falling back to file`,e),downgradeBackendToFile()}let r=readAuthFile();r.token=e,r.secretsBackend=`file`,writeAuthFile(r)}async function setProxyPassword(e,t={}){let n=await getBackend();if(t.skipIfUnchanged&&(n===`keyring`?await readKeyring(An):readAuthFile().proxy?.password)===e)return;if(n===`keyring`)try{await writeKeyring(An,e);return}catch(e){cliDebugPrint(`credentials`,`keyring write failed; falling back to file`,e),downgradeBackendToFile()}let r=readAuthFile();r.proxy={...r.proxy,password:e},r.secretsBackend=`file`,writeAuthFile(r)}async function clearKeyringSecrets(){await deleteKeyring(kn),await deleteKeyring(An)}async function ensureMigrated(){return Nn||(Nn=(async()=>{try{let e=readAuthFile();if(e.secretsBackend||!e.token&&!e.proxy?.password)return;if(await getBackend()===`file`){e.secretsBackend=`file`,writeAuthFile(e);return}try{e.token&&await writeKeyring(kn,e.token),e.proxy?.password&&await writeKeyring(An,e.proxy.password)}catch(t){cliDebugPrint(`credentials`,`keyring write failed during migration; falling back to file`,t),downgradeBackendToFile(),e.secretsBackend=`file`,writeAuthFile(e);return}delete e.token,e.proxy&&(delete e.proxy.password,Object.keys(e.proxy).length===0&&delete e.proxy),e.secretsBackend=`keyring`,writeAuthFile(e)}catch(e){cliDebugPrint(`credentials`,`migration failed`,e)}})(),Nn)}const Pn=`__CLI_`;function resolveInputKey(){return process.env[I.INPUT_KEY]||process.env[R.INPUT_KEY]||process.env.CRAWLEE_INPUT_KEY||`INPUT`}function inputFileRegExp(e){return RegExp(`(^${tt(e)}(?:\\.[^.]+)?$)`)}function readActorRuntimeConfig(){try{let e=JSON.parse(j(ACTOR_RUNTIME_CONFIG_FILE_PATH(),`utf-8`));return e&&typeof e==`object`?e:{}}catch{return{}}}function updateActorRuntimeConfig(e){ensureApifyDirectory(ACTOR_RUNTIME_CONFIG_FILE_PATH()),F(ACTOR_RUNTIME_CONFIG_FILE_PATH(),JSON.stringify({...readActorRuntimeConfig(),...e},null,` `))}const Fn=`apify/actor-runtime:latest`,In=`apify-actor-runtime`,Ln=`https://docs.docker.com/get-started/get-docker/`,Rn=`https://podman.io/docs/installation`,zn=3333,Bn=3e3,Vn={api:zn,console:Bn},runtimeApiUrl=e=>`http://localhost:${e}`,runtimeConsoleUrl=e=>`http://localhost:${e}`,Hn=runtimeApiUrl(zn),Un=runtimeConsoleUrl(Bn),Wn={APIFY_CLIENT_BASE_URL:Hn,APIFY_CONSOLE_URL:Un},Gn=[`docker`,`podman`],Kn=`APIFY_CONTAINER_ENGINE`,qn=`/data`;function runtimeEnvExportLines(e=Vn){return[`export APIFY_CLIENT_BASE_URL=${runtimeApiUrl(e.api)}`,`export APIFY_CONSOLE_URL=${runtimeConsoleUrl(e.console)}`]}function requestedContainerEngine(t=e.env){let n=t[Kn]?.trim().toLowerCase();return Gn.find(e=>e===n)}async function installedContainerEngines(t=e.env){let n=requestedContainerEngine(t),r=n?[n]:Gn,i=[];for(let e of r)await Re(e,{nothrow:!0})&&i.push(e);return i}async function findContainerEngine(t=e.env){let n=await installedContainerEngines(t);for(let e of n)if(await isEngineReady(e))return{engine:e,ready:!0};return n[0]?{engine:n[0],ready:!1}:null}async function findRunningRuntimeEngine(t=e.env){for(let e of await installedContainerEngines(t))if(await isRuntimeContainerRunning(e))return e;return null}function engineInstallHint(t,n=e.platform){if(t===`podman`)return`Install Podman: ${Rn}`;switch(n){case`darwin`:return`Install Docker Desktop for Mac: https://docs.docker.com/desktop/setup/install/mac-install/`;case`win32`:return`Install Docker Desktop for Windows (WSL 2 backend): https://docs.docker.com/desktop/setup/install/windows-install/`;default:return`Install Docker Engine: https://docs.docker.com/engine/install/`}}function engineDaemonHint(t,n=e.platform){if(t===`podman`)switch(n){case`darwin`:case`win32`:return`Start the Podman machine: 'podman machine start'.`;default:return`Serve Podman's API socket: 'systemctl --user enable --now podman.socket' (rootless) or 'sudo systemctl enable --now podman.socket' (rootful); without systemd, 'podman system service --time=0 &'.`}switch(n){case`darwin`:case`win32`:return`Start Docker Desktop and wait until it reports "Docker Desktop is running".`;default:return`Start the Docker daemon, e.g. 'sudo systemctl start docker'.`}}async function isEngineReady(e){try{if(e===`podman`){let{stdout:e}=await B(`podman`,[`info`,`--format`,`{{.Host.RemoteSocket.Exists}}`]);return e.trim()===`true`}return await B(`docker`,[`info`,`--format`,`{{.ServerVersion}}`]),!0}catch{return!1}}function isDigestPinned(e){return e.includes(`@`)}async function imageExistsLocally(e,t){try{return await B(e,[`image`,`inspect`,t]),!0}catch{return!1}}async function isRuntimeContainerRunning(e){try{let{stdout:t}=await B(e,[`ps`,`--filter`,`name=^${In}$`,`--format`,`{{.Names}}`]);return t.trim().length>0}catch{return!1}}function parsePublishedPorts(e){let t=e.NetworkSettings?.Ports??e.HostConfig?.PortBindings??{},n=[];for(let[e,r]of Object.entries(t)){let[t,i=`tcp`]=e.split(`/`),a=Number(t);if(Number.isInteger(a))for(let e of r??[])e?.HostPort&&n.push({containerPort:a,protocol:i,hostAddress:`${e.HostIp||`0.0.0.0`}:${e.HostPort}`})}return n.sort((e,t)=>e.containerPort-t.containerPort)}function parseRuntimeContainerInfo(e,t){let n;try{n=JSON.parse(t)}catch{return null}return!n||typeof n!=`object`?null:{engine:e,image:n.Config?.Image??n.ImageName,status:n.State?.Status,startedAt:n.State?.StartedAt,dataDir:n.Mounts?.find(e=>e.Destination===qn)?.Source,ports:parsePublishedPorts(n)}}async function inspectRuntimeContainer(e){try{let{stdout:t}=await B(e,[`inspect`,In,`--format`,`{{json .}}`]);return parseRuntimeContainerInfo(e,t)}catch{return null}}function unixSocketPath(e){return e?.startsWith(`unix://`)?e.slice(7):void 0}async function resolveEngineSocketPath(t,n=e.env){if(t===`docker`)return unixSocketPath(n.DOCKER_HOST)??`/var/run/docker.sock`;try{let{stdout:e}=await B(`podman`,[`info`,`--format`,`{{.Host.RemoteSocket.Path}}`]),t=e.trim();return unixSocketPath(t)??t}catch{return`/run/podman/podman.sock`}}function socketMountArg(t,n=e.platform){return`${n===`win32`&&t.startsWith(`/`)?`/${t}`:t}:/var/run/docker.sock`}function buildRuntimeRunArgs({image:t,dataDir:n,detach:r,hostSocketPath:i,ports:a=Vn,platform:s=e.platform}){let c=[`run`,`--rm`,`--init`,`--name`,In];return r&&c.push(`--detach`),a.api!==3333&&c.push(`-e`,`ACTOR_RUNTIME_API_PORT=${a.api}`),a.console!==3e3&&c.push(`-e`,`ACTOR_RUNTIME_CONSOLE_PORT=${a.console}`),c.push(`-p`,`${a.api}:${a.api}`,`-p`,`${a.console}:${a.console}`,`-v`,socketMountArg(i,s),`-v`,`${n}:${qn}`,t),c}function runtimeSkillHintLines(){return[`Agents: run 'apify runtime skill --install' to install this runtime's Agent Skill,`,` or 'apify runtime skill' to read it now.`]}function isConnectedToActorRuntime(){return readActorRuntimeConfig().connected===!0}function setConnectedToActorRuntime(e){updateActorRuntimeConfig({connected:e})}function configuredRuntimePorts(){let{apiPort:e,consolePort:t}=readActorRuntimeConfig();return{api:e??Vn.api,console:t??Vn.console}}function overridingRuntimeEnvVars(t=e.env){return Object.keys(Wn).filter(e=>t[e]).map(e=>[e,t[e]])}function resolveApiBaseUrl(t=e.env){return t.APIFY_CLIENT_BASE_URL||(isConnectedToActorRuntime()?runtimeApiUrl(configuredRuntimePorts().api):void 0)}function resolveConsoleUrl(t=e.env){return t.APIFY_CONSOLE_URL||(isConnectedToActorRuntime()?runtimeConsoleUrl(configuredRuntimePorts().console):void 0)}const Jn=nt,Yn=Ye,getLocalStorageDir=()=>{let t=R.LOCAL_STORAGE_DIR;return e.env[t]||e.env.CRAWLEE_STORAGE_DIR||`storage`},getLocalKeyValueStorePath=t=>{let n=I.DEFAULT_KEY_VALUE_STORE_ID,r=t||e.env[n]||_e[n];return u(getLocalStorageDir(),ve.keyValueStores,r)},getLocalDatasetPath=t=>{let n=I.DEFAULT_DATASET_ID,r=t||e.env[n]||_e[n];return u(getLocalStorageDir(),ve.datasets,r)},getLocalRequestQueuePath=t=>{let n=I.DEFAULT_REQUEST_QUEUE_ID,r=t||e.env[n]||_e[n];return u(getLocalStorageDir(),ve.requestQueues,r)},getLocalUserInfo=async()=>{await ensureMigrated();let e={};try{let t=await H(AUTH_FILE_PATH(),`utf-8`);e=JSON.parse(t)}catch{}if(await getBackend()===`keyring`){let t=await getToken();t&&(e.token=t);let n=await getProxyPassword();n&&(e.proxy={...e.proxy,password:n})}let t=!!(e.username||e.id);if(!(t||e.token))return{};if(!t)throw Error(`Stale credentials found without user metadata. Please run "apify login" again.`);return e};async function getLoggedClientOrThrow(){let t=await getLoggedClient();if(!t)throw e.exitCode=1,Error(`You are not logged in with your Apify account. Call "apify login" to fix that.`);return t}const resolveToken=async e=>e||(await ensureMigrated(),getToken()),getApifyClientOptions=async(e,t)=>({token:await resolveToken(e),baseUrl:t||resolveApiBaseUrl(),requestInterceptors:[e=>{e.headers??=new et;for(let[t,n]of Object.entries(un))e.headers[t]=n;return e}]});async function getLoggedClient(e,t){let n=await resolveToken(e),r=new Xe(await getApifyClientOptions(n,t)),i;try{i=await r.user(`me`).get()}catch(e){return cliDebugPrint(`[getLoggedClient] error getting user info`,{error:e,apiBaseUrl:t}),null}r.token&&await setToken(r.token,{skipIfUnchanged:!0});let a=i.proxy?.password;a&&await setProxyPassword(a,{skipIfUnchanged:!0}),ensureApifyDirectory(AUTH_FILE_PATH());let s=(()=>{try{return JSON.parse(j(AUTH_FILE_PATH(),`utf-8`))}catch{return{}}})(),c=await getBackend(),l={...s,...i,secretsBackend:c};if(c===`keyring`&&(delete l.token,l.proxy&&typeof l.proxy==`object`)){let{password:e,...t}=l.proxy;Object.keys(t).length>0?l.proxy=t:delete l.proxy}return F(AUTH_FILE_PATH(),JSON.stringify(l,null,` `),{mode:384}),r}const getLocalConfigPath=e=>u(e,K),getJsonFileContent=e=>{if(D(e))return JSON.parse(j(e,{encoding:`utf-8`}))},getLocalConfig=e=>getJsonFileContent(getLocalConfigPath(e)),setLocalConfig=async(t,n)=>{let r=u(n||e.cwd(),K);await V(c(r),{recursive:!0}),F(r,JSON.stringify(t,null,` `))},Xn=[getLocalStorageDir(),`node_modules`,`.venv`],setLocalEnv=async e=>{let t=getLocalKeyValueStorePath();ensureFolderExistsSync(e,getLocalDatasetPath()),ensureFolderExistsSync(e,getLocalRequestQueuePath()),ensureFolderExistsSync(e,t);let n=u(e,`.gitignore`),r=``;D(n)&&(r=j(n,{encoding:`utf-8`}));let i=[];for(let e of Xn)RegExp(`^${tt(e)}$`,`mg`).test(r)||i.push(e);i.length>0&&(r.length>0?(i.unshift(`# Added by Apify CLI`),F(n,`\n${i.join(`
|
|
48
|
+
main.py`);return null}async function checkScrapyProject(e){return ScrapyProjectAnalyzer.isApplicable(e)}function normalizeExecutablePath(e){return e?e.startsWith(`"`)?e:l(e)&&e.includes(` `)?`"${e}"`:e:null}async function getInstallCommandSuggestion(e){let t=null;return await(await useCwdProject({cwd:e})).inspectAsync(async n=>{if(n.type===0){let[r,i,a,s]=await Promise.all([U(u(e,`yarn.lock`)).then(()=>!0).catch(()=>!1),U(u(e,`pnpm-lock.yaml`)).then(()=>!0).catch(()=>!1),U(u(e,`bun.lockb`)).then(()=>!0).catch(()=>!1),U(u(e,`bun.lock`)).then(()=>!0).catch(()=>!1)]);t=r?`yarn install`:i?`pnpm install`:a||s||n.runtime?.pmName===`bun`?`bun install`:n.runtime?.pmName===`deno`?`deno install --node-modules-dir`:`npm install`}else(n.type===1||n.type===2)&&(t=n.packageManager===`uv`?`uv sync`:`python -m pip install -r requirements.txt`)}),t}let Dn=`inherit`;function keepStdoutClean(){Dn=e.stderr}const spawnPromised=async(t,n,r,{forwardSignals:i}={})=>{let a=normalizeExecutablePath(t);cliDebugPrint(`spawnPromised`,{escapedCommand:a,args:n,opts:r,forwardSignals:i});let s=B(a,n,{shell:!0,windowsHide:!0,env:r.env,cwd:r.cwd,stdout:e.env.APIFY_NO_LOGS_IN_TESTS?[`pipe`]:[`pipe`,Dn],stderr:e.env.APIFY_NO_LOGS_IN_TESTS?[`pipe`]:[`pipe`,`inherit`],verbose:e.env.APIFY_CLI_DEBUG?`full`:void 0}),c=[];if(i?.length)for(let t of i){let handler=()=>{s.kill(t)};e.on(t,handler),c.push(()=>e.off(t,handler))}try{return await we.fromAsync(s.catch(e=>{let n;throw n=e.exitCode==null?e.signal?`${t} exited due to signal ${e.signal}`:e.shortMessage:`${t} exited with code ${e.exitCode}`,Error(n,{cause:e})}))}finally{for(let e of c)e()}};async function execWithLog({cmd:e,args:t=[],opts:n={},overrideCommand:r,forwardSignals:i}){run({message:`${r||e} ${t.join(` `)}`});let a=await spawnPromised(e,t,n,{forwardSignals:i});if(a.isErr()){let e=a.unwrapErr();if(error({message:e.message}),e.cause)throw e.cause}}const On=[[`CLAUDECODE`,`claude_code`],[`CLAUDE_CODE_ENTRYPOINT`,`claude_code`],[`CURSOR_AGENT`,`cursor`],[`CLINE_ACTIVE`,`cline`],[`CODEX_SANDBOX`,`codex_cli`],[`CODEX_THREAD_ID`,`codex_cli`],[`GEMINI_CLI`,`gemini_cli`],[`OPENCODE`,`open_code`],[`OPENCLAW_SHELL`,`openclaw`]];function detectAiAgent(){for(let[e,t]of On)if(process.env[e])return t}function detectCi(){return de.isCI?{isCi:!0,ciProvider:de.id?.toLowerCase()??`unknown`}:{isCi:!1,ciProvider:void 0}}function detectIsInteractive(){return!!process.stdin.isTTY&&!!process.stdout.isTTY}const updateLocalJson=async(e,t={},n=null)=>{let r=await H(e,`utf-8`),i=JSON.parse(r),a;n?(a=i,a[n]={...i[n],...t}):a={...i,...t},await W(e,JSON.stringify(a,null,` `))},ensureFolderExistsSync=(e,t)=>{t||(t=e,e=`.`),t.split(m).reduce((e,t)=>(e=u(e,t),D(e)||k(e),e),e)},rimrafPromised=async e=>{let t=Array.isArray(e)?e:[e];await Promise.all(t.map(async e=>Ne(e,{recursive:!0,force:!0})))},deleteFile=async e=>{(await U(e)).isFile()&&await Fe(e)};function ensureApifyDirectory(e){let t=c(e);k(t,{recursive:!0})}const sumFilesSizeInBytes=async(e,t)=>(await Promise.all(e.map(async e=>U(u(t,e))))).map(e=>e.size).reduce((e,t)=>e+t,0),kn=`token`,An=`proxy-password`;let jn,Mn,Nn;async function loadKeyringModule(){return jn===void 0&&(jn=await importKeyringModule()),jn}async function importKeyringModule(){if(useCLIMetadata().installMethod===`bundle`)try{let e=await import(`__APIFY_KEYRING_NATIVE_SUBPACKAGE__`),t=e.Entry??e.default?.Entry;return t?{Entry:t}:null}catch(e){return cliDebugPrint(`credentials`,`failed to load bundled keyring`,e),null}try{return await import(`@napi-rs/keyring`)}catch(e){return cliDebugPrint(`credentials`,`failed to load @napi-rs/keyring`,e),null}}async function getBackend(){return Mn||(Mn=(async()=>e.env.APIFY_DISABLE_KEYRING===`1`||readAuthFile().secretsBackend===`file`?`file`:await loadKeyringModule()?`keyring`:`file`)(),Mn)}function downgradeBackendToFile(){Mn=Promise.resolve(`file`)}function readAuthFile(){if(!D(AUTH_FILE_PATH()))return{};try{let e=j(AUTH_FILE_PATH(),`utf-8`);return JSON.parse(e)}catch{return{}}}function writeAuthFile(e){ensureApifyDirectory(AUTH_FILE_PATH()),F(AUTH_FILE_PATH(),JSON.stringify(e,null,` `),{mode:384})}async function getKeyringEntry(e){let t=await loadKeyringModule();return t?new t.Entry(`com.apify.cli`,e):null}async function readKeyring(e){try{let t=await getKeyringEntry(e);return t?t.getPassword()??void 0:void 0}catch(t){cliDebugPrint(`credentials`,`failed to read ${e} from keyring`,t);return}}async function writeKeyring(e,t){let n=await getKeyringEntry(e);if(!n)throw Error(`OS keyring is not available.`);n.setPassword(t)}async function deleteKeyring(e){try{let t=await getKeyringEntry(e);if(!t)return;t.deletePassword()}catch(t){cliDebugPrint(`credentials`,`failed to delete ${e} from keyring`,t)}}async function getToken(){return await getBackend()===`keyring`?readKeyring(kn):readAuthFile().token}async function getProxyPassword(){return await getBackend()===`keyring`?readKeyring(An):readAuthFile().proxy?.password}async function setToken(e,t={}){let n=await getBackend();if(t.skipIfUnchanged&&(n===`keyring`?await readKeyring(kn):readAuthFile().token)===e)return;if(n===`keyring`)try{await writeKeyring(kn,e);return}catch(e){cliDebugPrint(`credentials`,`keyring write failed; falling back to file`,e),downgradeBackendToFile()}let r=readAuthFile();r.token=e,r.secretsBackend=`file`,writeAuthFile(r)}async function setProxyPassword(e,t={}){let n=await getBackend();if(t.skipIfUnchanged&&(n===`keyring`?await readKeyring(An):readAuthFile().proxy?.password)===e)return;if(n===`keyring`)try{await writeKeyring(An,e);return}catch(e){cliDebugPrint(`credentials`,`keyring write failed; falling back to file`,e),downgradeBackendToFile()}let r=readAuthFile();r.proxy={...r.proxy,password:e},r.secretsBackend=`file`,writeAuthFile(r)}async function clearKeyringSecrets(){await deleteKeyring(kn),await deleteKeyring(An)}async function ensureMigrated(){return Nn||(Nn=(async()=>{try{let e=readAuthFile();if(e.secretsBackend||!e.token&&!e.proxy?.password)return;if(await getBackend()===`file`){e.secretsBackend=`file`,writeAuthFile(e);return}try{e.token&&await writeKeyring(kn,e.token),e.proxy?.password&&await writeKeyring(An,e.proxy.password)}catch(t){cliDebugPrint(`credentials`,`keyring write failed during migration; falling back to file`,t),downgradeBackendToFile(),e.secretsBackend=`file`,writeAuthFile(e);return}delete e.token,e.proxy&&(delete e.proxy.password,Object.keys(e.proxy).length===0&&delete e.proxy),e.secretsBackend=`keyring`,writeAuthFile(e)}catch(e){cliDebugPrint(`credentials`,`migration failed`,e)}})(),Nn)}const Pn=`__CLI_`;function resolveInputKey(){return process.env[I.INPUT_KEY]||process.env[R.INPUT_KEY]||process.env.CRAWLEE_INPUT_KEY||`INPUT`}function inputFileRegExp(e){return RegExp(`(^${tt(e)}(?:\\.[^.]+)?$)`)}function readActorRuntimeConfig(){try{let e=JSON.parse(j(ACTOR_RUNTIME_CONFIG_FILE_PATH(),`utf-8`));return e&&typeof e==`object`?e:{}}catch{return{}}}function updateActorRuntimeConfig(e){ensureApifyDirectory(ACTOR_RUNTIME_CONFIG_FILE_PATH()),F(ACTOR_RUNTIME_CONFIG_FILE_PATH(),JSON.stringify({...readActorRuntimeConfig(),...e},null,` `))}const Fn=`apify/actor-runtime:latest`,In=`apify-actor-runtime`,Ln=`https://docs.docker.com/get-started/get-docker/`,Rn=`https://podman.io/docs/installation`,zn=3333,Bn=3e3,Vn={api:zn,console:Bn},runtimeApiUrl=e=>`http://localhost:${e}`,runtimeConsoleUrl=e=>`http://localhost:${e}`,Hn=runtimeApiUrl(zn),Un=runtimeConsoleUrl(Bn),Wn={APIFY_CLIENT_BASE_URL:Hn,APIFY_CONSOLE_URL:Un},Gn=[`docker`,`podman`],Kn=`APIFY_CONTAINER_ENGINE`,qn=`/data`;function runtimeEnvExportLines(e=Vn){return[`export APIFY_CLIENT_BASE_URL=${runtimeApiUrl(e.api)}`,`export APIFY_CONSOLE_URL=${runtimeConsoleUrl(e.console)}`]}function requestedContainerEngine(t=e.env){let n=t[Kn]?.trim().toLowerCase();return Gn.find(e=>e===n)}async function installedContainerEngines(t=e.env){let n=requestedContainerEngine(t),r=n?[n]:Gn,i=[];for(let e of r)await Re(e,{nothrow:!0})&&i.push(e);return i}async function findContainerEngine(t=e.env){let n=await installedContainerEngines(t);for(let e of n)if(await isEngineReady(e))return{engine:e,ready:!0};return n[0]?{engine:n[0],ready:!1}:null}async function findRunningRuntimeEngine(t=e.env){for(let e of await installedContainerEngines(t))if(await isRuntimeContainerRunning(e))return e;return null}function engineInstallHint(t,n=e.platform){if(t===`podman`)return`Install Podman: ${Rn}`;switch(n){case`darwin`:return`Install Docker Desktop for Mac: https://docs.docker.com/desktop/setup/install/mac-install/`;case`win32`:return`Install Docker Desktop for Windows (WSL 2 backend): https://docs.docker.com/desktop/setup/install/windows-install/`;default:return`Install Docker Engine: https://docs.docker.com/engine/install/`}}function engineDaemonHint(t,n=e.platform){if(t===`podman`)switch(n){case`darwin`:case`win32`:return`Start the Podman machine: 'podman machine start'.`;default:return`Serve Podman's API socket: 'systemctl --user enable --now podman.socket' (rootless) or 'sudo systemctl enable --now podman.socket' (rootful); without systemd, 'podman system service --time=0 &'.`}switch(n){case`darwin`:case`win32`:return`Start Docker Desktop and wait until it reports "Docker Desktop is running".`;default:return`Start the Docker daemon, e.g. 'sudo systemctl start docker'.`}}async function isEngineReady(e){try{if(e===`podman`){let{stdout:e}=await B(`podman`,[`info`,`--format`,`{{.Host.RemoteSocket.Exists}}`]);return e.trim()===`true`}return await B(`docker`,[`info`,`--format`,`{{.ServerVersion}}`]),!0}catch{return!1}}function isDigestPinned(e){return e.includes(`@`)}async function imageExistsLocally(e,t){try{return await B(e,[`image`,`inspect`,t]),!0}catch{return!1}}async function isRuntimeContainerRunning(e){try{let{stdout:t}=await B(e,[`ps`,`--filter`,`name=^${In}$`,`--format`,`{{.Names}}`]);return t.trim().length>0}catch{return!1}}function parsePublishedPorts(e){let t=e.NetworkSettings?.Ports??e.HostConfig?.PortBindings??{},n=[];for(let[e,r]of Object.entries(t)){let[t,i=`tcp`]=e.split(`/`),a=Number(t);if(Number.isInteger(a))for(let e of r??[])e?.HostPort&&n.push({containerPort:a,protocol:i,hostAddress:`${e.HostIp||`0.0.0.0`}:${e.HostPort}`})}return n.sort((e,t)=>e.containerPort-t.containerPort)}function parseRuntimeContainerInfo(e,t){let n;try{n=JSON.parse(t)}catch{return null}return!n||typeof n!=`object`?null:{engine:e,image:n.Config?.Image??n.ImageName,status:n.State?.Status,startedAt:n.State?.StartedAt,dataDir:n.Mounts?.find(e=>e.Destination===qn)?.Source,ports:parsePublishedPorts(n)}}async function inspectRuntimeContainer(e){try{let{stdout:t}=await B(e,[`inspect`,In,`--format`,`{{json .}}`]);return parseRuntimeContainerInfo(e,t)}catch{return null}}function unixSocketPath(e){return e?.startsWith(`unix://`)?e.slice(7):void 0}async function resolveEngineSocketPath(t,n=e.env){if(t===`docker`)return unixSocketPath(n.DOCKER_HOST)??`/var/run/docker.sock`;try{let{stdout:e}=await B(`podman`,[`info`,`--format`,`{{.Host.RemoteSocket.Path}}`]),t=e.trim();return unixSocketPath(t)??t}catch{return`/run/podman/podman.sock`}}function parsePodmanInfo(e){let[t,n]=e.trim().split(/\s+/),r=Number(n?.match(/^(\d+)\./)?.[1]);return{rootless:t===`true`,...Number.isInteger(r)?{majorVersion:r}:{}}}async function podmanInfo(){try{let{stdout:e}=await B(`podman`,[`info`,`--format`,`{{.Host.Security.Rootless}} {{.Version.Version}}`]);return parsePodmanInfo(e)}catch{return}}function runtimeNetworkMode(e,t){if(!(e!==`podman`||!t?.rootless||t.majorVersion!==3))return`slirp4netns:allow_host_loopback=true`}function socketMountArg(t,n=e.platform){return`${n===`win32`&&t.startsWith(`/`)?`/${t}`:t}:/var/run/docker.sock`}function buildRuntimeRunArgs({image:t,dataDir:n,detach:r,hostSocketPath:i,ports:a=Vn,platform:s=e.platform,networkMode:c}){let l=[`run`,`--rm`,`--init`,`--name`,In];return r&&l.push(`--detach`),a.api!==3333&&l.push(`-e`,`ACTOR_RUNTIME_API_PORT=${a.api}`),a.console!==3e3&&l.push(`-e`,`ACTOR_RUNTIME_CONSOLE_PORT=${a.console}`),c&&l.push(`--network`,c),l.push(`-p`,`${a.api}:${a.api}`,`-p`,`${a.console}:${a.console}`,`-v`,socketMountArg(i,s),`-v`,`${n}:${qn}`,t),l}function runtimeSkillHintLines(){return[`Agents: run 'apify runtime skill --install' to install this runtime's Agent Skill,`,` or 'apify runtime skill' to read it now.`]}function isConnectedToActorRuntime(){return readActorRuntimeConfig().connected===!0}function setConnectedToActorRuntime(e){updateActorRuntimeConfig({connected:e})}function configuredRuntimePorts(){let{apiPort:e,consolePort:t}=readActorRuntimeConfig();return{api:e??Vn.api,console:t??Vn.console}}function overridingRuntimeEnvVars(t=e.env){return Object.keys(Wn).filter(e=>t[e]).map(e=>[e,t[e]])}function resolveApiBaseUrl(t=e.env){return t.APIFY_CLIENT_BASE_URL||(isConnectedToActorRuntime()?runtimeApiUrl(configuredRuntimePorts().api):void 0)}function resolveConsoleUrl(t=e.env){return t.APIFY_CONSOLE_URL||(isConnectedToActorRuntime()?runtimeConsoleUrl(configuredRuntimePorts().console):void 0)}const Jn=nt,Yn=Ye,getLocalStorageDir=()=>{let t=R.LOCAL_STORAGE_DIR;return e.env[t]||e.env.CRAWLEE_STORAGE_DIR||`storage`},getLocalKeyValueStorePath=t=>{let n=I.DEFAULT_KEY_VALUE_STORE_ID,r=t||e.env[n]||_e[n];return u(getLocalStorageDir(),ve.keyValueStores,r)},getLocalDatasetPath=t=>{let n=I.DEFAULT_DATASET_ID,r=t||e.env[n]||_e[n];return u(getLocalStorageDir(),ve.datasets,r)},getLocalRequestQueuePath=t=>{let n=I.DEFAULT_REQUEST_QUEUE_ID,r=t||e.env[n]||_e[n];return u(getLocalStorageDir(),ve.requestQueues,r)},getLocalUserInfo=async()=>{await ensureMigrated();let e={};try{let t=await H(AUTH_FILE_PATH(),`utf-8`);e=JSON.parse(t)}catch{}if(await getBackend()===`keyring`){let t=await getToken();t&&(e.token=t);let n=await getProxyPassword();n&&(e.proxy={...e.proxy,password:n})}let t=!!(e.username||e.id);if(!(t||e.token))return{};if(!t)throw Error(`Stale credentials found without user metadata. Please run "apify login" again.`);return e};async function getLoggedClientOrThrow(){let t=await getLoggedClient();if(!t)throw e.exitCode=1,Error(`You are not logged in with your Apify account. Call "apify login" to fix that.`);return t}const resolveToken=async e=>e||(await ensureMigrated(),getToken()),getApifyClientOptions=async(e,t)=>({token:await resolveToken(e),baseUrl:t||resolveApiBaseUrl(),requestInterceptors:[e=>{e.headers??=new et;for(let[t,n]of Object.entries(un))e.headers[t]=n;return e}]});async function getLoggedClient(e,t){let n=await resolveToken(e),r=new Xe(await getApifyClientOptions(n,t)),i;try{i=await r.user(`me`).get()}catch(e){return cliDebugPrint(`[getLoggedClient] error getting user info`,{error:e,apiBaseUrl:t}),null}r.token&&await setToken(r.token,{skipIfUnchanged:!0});let a=i.proxy?.password;a&&await setProxyPassword(a,{skipIfUnchanged:!0}),ensureApifyDirectory(AUTH_FILE_PATH());let s=(()=>{try{return JSON.parse(j(AUTH_FILE_PATH(),`utf-8`))}catch{return{}}})(),c=await getBackend(),l={...s,...i,secretsBackend:c};if(c===`keyring`&&(delete l.token,l.proxy&&typeof l.proxy==`object`)){let{password:e,...t}=l.proxy;Object.keys(t).length>0?l.proxy=t:delete l.proxy}return F(AUTH_FILE_PATH(),JSON.stringify(l,null,` `),{mode:384}),r}const getLocalConfigPath=e=>u(e,K),getJsonFileContent=e=>{if(D(e))return JSON.parse(j(e,{encoding:`utf-8`}))},getLocalConfig=e=>getJsonFileContent(getLocalConfigPath(e)),setLocalConfig=async(t,n)=>{let r=u(n||e.cwd(),K);await V(c(r),{recursive:!0}),F(r,JSON.stringify(t,null,` `))},Xn=[getLocalStorageDir(),`node_modules`,`.venv`],setLocalEnv=async e=>{let t=getLocalKeyValueStorePath();ensureFolderExistsSync(e,getLocalDatasetPath()),ensureFolderExistsSync(e,getLocalRequestQueuePath()),ensureFolderExistsSync(e,t);let n=u(e,`.gitignore`),r=``;D(n)&&(r=j(n,{encoding:`utf-8`}));let i=[];for(let e of Xn)RegExp(`^${tt(e)}$`,`mg`).test(r)||i.push(e);i.length>0&&(r.length>0?(i.unshift(`# Added by Apify CLI`),F(n,`\n${i.join(`
|
|
49
49
|
`)}\n`,{flag:`a`})):F(n,`${i.join(`
|
|
50
50
|
`)}\n`,{flag:`w`}))},Zn=new at(st,ot).define({"application/gzip":[`tgz`],"text/typescript":[`ts`,`tsx`,`mts`]},!0),getSourceFileFormat=(e,t)=>{let n=Zn.getType(e);return n?n.startsWith(`text/`)||n.includes(`javascript`)||n.includes(`json`)||n.includes(`xml`)||n.includes(`application/node`)||n.includes(`application/toml`)||n.includes(`application/x-sh`)||n.includes(`application/x-httpd-php`)?xe.TEXT:xe.BASE64:rt(t)===`binary`?xe.BASE64:xe.TEXT},createSourceFiles=async(e,t)=>e.map(e=>{let n=j(u(t,e)),r=getSourceFileFormat(e,n);return{name:e,format:r,content:r===xe.TEXT?n.toString(`utf8`):n.toString(`base64`)}}),getGitignoreFallbackFilter=async e=>{let t=await ct(`**/.gitignore`,{dot:!0,cwd:e,ignore:[`.git/**`],expandDirectories:!1}),n=[];for(let r of t){let t=c(r),i=await H(u(e,r),`utf-8`);n.push({dir:t===`.`?``:t,ig:Jn().add(i)})}let r=c(e);for(;r!==c(r)&&!D(u(r,`.git`));){let t=u(r,`.gitignore`);if(D(t))try{let i=await H(t,`utf-8`),a=f(r,e);n.push({dir:``,ig:Jn().add(i),ancestorPrefix:a})}catch{}r=c(r)}return n.length===0?e=>e:e=>e.filter(e=>{for(let{dir:t,ig:r,ancestorPrefix:i}of n){let n;if(n=t?e.startsWith(`${t}/`)?e.slice(t.length+1):null:i?`${i}/${e}`:e,n!==null&&r.ignores(n))return!1}return!0})},parseActorIgnore=async e=>{let t=u(e,`.actorignore`);if(!D(t))return{excludeFilter:null,forceIncludePatterns:[]};let n=(await H(t,`utf-8`)).split(`
|
|
51
51
|
`),r=[],i=[];for(let e of n){let t=e.trim();!t||t.startsWith(`#`)||(t.startsWith(`!`)?i.push(t.slice(1)):r.push(t))}return{excludeFilter:r.length>0?e=>{let t=Jn().add(r);return e.filter(e=>!t.ignores(e))}:null,forceIncludePatterns:i}},getActorLocalFilePaths=async t=>{let n=t??e.cwd(),r=[`.git/**`,`apify_storage`,`node_modules`,`storage`,`crawlee_storage`],{excludeFilter:i,forceIncludePatterns:a}=await parseActorIgnore(n),gitIgnoreFilter=null;try{let e=He(`git ls-files --others --ignored --exclude-standard --directory`,{cwd:n,encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).split(`
|
|
@@ -248,8 +248,8 @@ Use --install to put it in your agent's skills directory, where it loads on dema
|
|
|
248
248
|
`)}),e.exitCode=1;return}let{content:r,source:i}=n;if(!this.flags.install){simpleLog({stdout:!0,message:(this.flags.raw?r:frameSkillForReading(r,i)).trimEnd()});return}let a=stampSkill(r,i),s=[];for(let e of skillTargets())try{await writeSkillTo(e,a),s.push(` ${tildify(e.directory)} ${t.gray(`(${e.label})`)}`)}catch(n){info({message:t.gray(`Skipped ${tildify(e.directory)}: ${n.message}`)})}if(!s.length){error({message:`Could not write the skill to any agent skills directory.`}),e.exitCode=1;return}success({message:`Installed the Actor runtime skill from ${describeSkillSource(i)}:`}),simpleLog({message:s.join(`
|
|
249
249
|
`)}),simpleLog({message:t.gray(`
|
|
250
250
|
Agents pick it up on their next start. Re-run this after upgrading the runtime image.`)})}};const isValidPort=e=>Number.isInteger(e)&&e>=1&&e<=65535,defaultDataDir=()=>u(GLOBAL_CONFIGS_FOLDER(),`actor-runtime`,`data`);var RuntimeStartCommand=class extends ApifyCommand{static name=`start`;static description=`Starts the Actor runtime, a local Apify platform running as a container on Docker or Podman.
|
|
251
|
-
Installs the runtime first when needed (like 'apify runtime install'). The runtime API listens on ${Hn} and the console on ${Un} unless moved with --api-port and --console-port, which are remembered for later starts and for 'apify runtime connect'. Run 'apify runtime -h' for the environment variables that point the CLI at it.`;static group=`Local Actor Development`;static examples=[{description:`Start the Actor runtime in the foreground (Ctrl+C stops it).`,command:`apify runtime start`},{description:`Start the Actor runtime in the background.`,command:`apify runtime start --detach`},{description:`Start with runtime data stored in a custom directory.`,command:`apify runtime start --data-dir ./data`},{description:`Start on other ports when 3333 or 3000 is already taken.`,command:`apify runtime start --api-port 4333 --console-port 4000`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-runtime-start`;static flags={"data-dir":Y.string({description:`Host directory mounted as the runtime data directory (storages, builds and run records). Defaults to ~/.apify/actor-runtime/data.`}),detach:Y.boolean({char:`d`,description:`Run the runtime container in the background. Stop it with 'apify runtime stop'.`,default:!1}),"api-port":Y.integer({description:`Host port for the runtime API. Defaults to the port of the previous start, else ${zn}.`}),"console-port":Y.integer({description:`Host port for the runtime console. Defaults to the port of the previous start, else ${Bn}.`})};async run(){if(await findRunningRuntimeEngine()){error({message:`The Actor runtime is already running (container '${In}'). Stop it with 'apify runtime stop' first.`}),e.exitCode=1;return}let n=configuredRuntimePorts(),r={api:this.flags.apiPort??n.api,console:this.flags.consolePort??n.console};if(!isValidPort(r.api)||!isValidPort(r.console)){error({message:`Ports must be integers between 1 and 65535.`}),e.exitCode=1;return}if(r.api===r.console){error({message:`The API and console need different ports, both are ${r.api}.`}),e.exitCode=1;return}let i=installedActorRuntimeImage(),a=await ensureActorRuntimeImage({image:i});if(!a)return;let s=await resolveEngineSocketPath(a),c=p(this.flags.dataDir??defaultDataDir());await V(
|
|
252
|
-
`)});let
|
|
251
|
+
Installs the runtime first when needed (like 'apify runtime install'). The runtime API listens on ${Hn} and the console on ${Un} unless moved with --api-port and --console-port, which are remembered for later starts and for 'apify runtime connect'. Run 'apify runtime -h' for the environment variables that point the CLI at it.`;static group=`Local Actor Development`;static examples=[{description:`Start the Actor runtime in the foreground (Ctrl+C stops it).`,command:`apify runtime start`},{description:`Start the Actor runtime in the background.`,command:`apify runtime start --detach`},{description:`Start with runtime data stored in a custom directory.`,command:`apify runtime start --data-dir ./data`},{description:`Start on other ports when 3333 or 3000 is already taken.`,command:`apify runtime start --api-port 4333 --console-port 4000`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-runtime-start`;static flags={"data-dir":Y.string({description:`Host directory mounted as the runtime data directory (storages, builds and run records). Defaults to ~/.apify/actor-runtime/data.`}),detach:Y.boolean({char:`d`,description:`Run the runtime container in the background. Stop it with 'apify runtime stop'.`,default:!1}),"api-port":Y.integer({description:`Host port for the runtime API. Defaults to the port of the previous start, else ${zn}.`}),"console-port":Y.integer({description:`Host port for the runtime console. Defaults to the port of the previous start, else ${Bn}.`})};async run(){if(await findRunningRuntimeEngine()){error({message:`The Actor runtime is already running (container '${In}'). Stop it with 'apify runtime stop' first.`}),e.exitCode=1;return}let n=configuredRuntimePorts(),r={api:this.flags.apiPort??n.api,console:this.flags.consolePort??n.console};if(!isValidPort(r.api)||!isValidPort(r.console)){error({message:`Ports must be integers between 1 and 65535.`}),e.exitCode=1;return}if(r.api===r.console){error({message:`The API and console need different ports, both are ${r.api}.`}),e.exitCode=1;return}let i=installedActorRuntimeImage(),a=await ensureActorRuntimeImage({image:i});if(!a)return;let s=await resolveEngineSocketPath(a),c=runtimeNetworkMode(a,a===`podman`?await podmanInfo():void 0),l=p(this.flags.dataDir??defaultDataDir());await V(l,{recursive:!0}),updateActorRuntimeConfig({apiPort:r.api,consolePort:r.console}),info({message:[`Starting the Actor runtime (data directory: ${l})...`,``,` API: ${runtimeApiUrl(r.api)}`,` Console: ${runtimeConsoleUrl(r.console)}`,``,`Point the Apify CLI at the runtime with:`,...runtimeEnvExportLines(r).map(e=>t.white.bold(` ${e}`)),``,...runtimeSkillHintLines()].join(`
|
|
252
|
+
`)});let u=buildRuntimeRunArgs({image:i,dataDir:l,detach:this.flags.detach,hostSocketPath:s,ports:r,networkMode:c});run({message:`${a} ${u.join(` `)}`});let f=B(a,u,{stdio:`inherit`}),m=!1,h=on.map(t=>{let handler=()=>{m=!0,f.kill(t)};return e.on(t,handler),()=>e.off(t,handler)});try{await f}catch(t){if(!m){error({message:`The Actor runtime exited with an error: ${t.shortMessage??t}`}),e.exitCode=1;return}}finally{for(let e of h)e()}this.flags.detach&&info({message:`The Actor runtime is running in the background. Stop it with 'apify runtime stop'.`})}};function portRole(e,t){return e===t.api?`API`:e===t.console?`Console`:``}function portLine({containerPort:e,protocol:t,hostAddress:n},r){let i=portRole(e,r);return` ${`${e}/${t}`.padEnd(10)} -> ${n}${i?` (${i})`:``}`}var RuntimeStatusCommand=class extends ApifyCommand{static name=`status`;static description=`Prints whether the Actor runtime is running, the ports it publishes, the host directory it keeps its data in, and which API the Apify CLI currently talks to.
|
|
253
253
|
Exits with code 1 when the runtime is not running, so scripts can test for it.`;static group=`Local Actor Development`;static examples=[{description:`Show what the Actor runtime is doing.`,command:`apify runtime status`},{description:`Read the status as JSON.`,command:`apify runtime status --json`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-runtime-status`;static enableJsonFlag=!0;async run(){let n=await findRunningRuntimeEngine(),r=n?await inspectRuntimeContainer(n):null,i=isConnectedToActorRuntime(),a=overridingRuntimeEnvVars();if(this.flags.json){n||(e.exitCode=1),printJsonToStdout({running:!!n,engine:n,container:n?In:void 0,image:r?.image??(n?void 0:installedActorRuntimeImage()),status:r?.status,startedAt:r?.startedAt,dataDir:r?.dataDir,ports:r?.ports??[],connected:i,apiBaseUrl:resolveApiBaseUrl()??null,envOverrides:Object.fromEntries(a)});return}let s=[];if(!n)s.push(`Actor runtime: ${t.yellow(`not running`)}`,``,` Installed image: ${installedActorRuntimeImage()}`,``,`Start it with ${t.white.bold(`apify runtime start --detach`)}.`);else{s.push(`Actor runtime: ${t.green(r?.status??`running`)} on ${n} (container '${In}')`,``,` Image: ${r?.image??installedActorRuntimeImage()}`,` Data directory: ${r?.dataDir??`unknown`}`),r?.startedAt&&s.push(` Started at: ${r.startedAt}`),s.push(``,r?.ports.length?`Published ports:`:`Published ports: none`);let e=configuredRuntimePorts();s.push(...(r?.ports??[]).map(t=>portLine(t,e)))}s.push(``,`Apify CLI target:`),s.push(` ${i?`the Actor runtime (${t.white.bold(`apify runtime connect`)})`:`the Apify platform (connect with ${t.white.bold(`apify runtime connect`)})`}`),s.push(` API base URL: ${resolveApiBaseUrl()??`https://api.apify.com (default)`}`),a.length&&s.push(``,`Set in this shell, taking precedence over the connection above:`,...a.map(([e,t])=>` ${e}=${t}`)),n&&s.push(``,...runtimeSkillHintLines()),simpleLog({message:s.join(`
|
|
254
254
|
`)}),n||(e.exitCode=1)}},RuntimeStopCommand=class extends ApifyCommand{static name=`stop`;static description=`Stops the Actor runtime container started with 'apify runtime start --detach'.`;static group=`Local Actor Development`;static examples=[{description:`Stop the running Actor runtime.`,command:`apify runtime stop`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-runtime-stop`;async run(){let t=await findRunningRuntimeEngine();if(!t){info({message:`The Actor runtime is not running.`});return}try{await execWithLog({cmd:t,args:[`stop`,In]})}catch{e.exitCode=1;return}success({message:`The Actor runtime was stopped.`})}},RuntimeIndexCommand=class extends ApifyCommand{static name=`runtime`;static description=[`Manages the Actor runtime, a self-contained local Apify platform running as a container on Docker or Podman.`,``,`Prerequisite: Docker or Podman must be installed and running. Follow the official documentation to set one up:`,``,` Docker Desktop (macOS, Windows, Linux desktop):`,` ${Ln}`,` Docker Engine (Linux servers, headless):`,` https://docs.docker.com/engine/install/`,` Podman (rootful or rootless; its API socket must be served, e.g. via the podman.socket systemd unit):`,` ${Rn}`,``,`The first engine found on PATH is used, Docker before Podman. Set ${Kn}=docker or =podman to choose.`,``,`'apify runtime install' checks that the engine is available and pulls the runtime image, 'apify runtime start' runs it, and 'apify runtime status' says whether it is up.`,``,`The runtime publishes two ports on localhost, by default (move them with 'apify runtime start --api-port <port> --console-port <port>'):`,``,` ${`3333`.padEnd(5)} API ${Hn} (Apify API compatible endpoint)`,` ${`3000`.padEnd(5)} Console ${Un} (web UI)`,``,`Run 'apify runtime connect' to send every Apify CLI command to the runtime instead of the Apify cloud, and 'apify runtime disconnect' to go back. The connection is remembered across terminals and does not touch your login.`,``,`These environment variables point the CLI (and the Apify SDKs and API clients that honour them) at the runtime for one shell only, and take precedence over the connection wherever they are set (shown for the default ports):`,``,...runtimeEnvExportLines().map(e=>` ${e}`),``,`Unset them to let 'apify runtime connect' decide where commands go.`,``,`Pointed at the runtime, 'apify push' also registers the pushed directory as the Actor's live dev folder, so runs pick up local edits without another push; 'apify call --no-dev-folder' runs from the built image alone.`].join(`
|
|
255
255
|
`);static group=`Local Actor Development`;static examples=[{description:`Start the runtime in the background.`,command:`apify runtime start --detach`},{description:`Point the CLI at the runtime and list the Actors it knows about.`,command:`apify runtime connect && apify actors ls`},{description:`Point the CLI at the runtime for a single command instead.`,command:`APIFY_CLIENT_BASE_URL=${Hn} apify actors ls`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-runtime`;static subcommands=[RuntimeInstallCommand,RuntimeStartCommand,RuntimeStopCommand,RuntimeStatusCommand,RuntimeConnectCommand,RuntimeDisconnectCommand,RuntimeSkillCommand];async run(){this.printHelp()}},SecretsAddCommand=class extends ApifyCommand{static name=`add`;static description=`Adds a new secret to '~/.apify' for use in Actor environment variables.`;static examples=[{description:`Add a secret named "mySecret". Reference it in .actor/actor.json as "@mySecret".`,command:`apify secrets add mySecret TopSecretValue123`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-secrets-add`;static args={name:Z.string({required:!0,description:`Name of the secret.`}),value:Z.string({required:!0,description:`Value of the secret.`})};async run(){let{name:e,value:t}=this.args;addSecret(e,t)}};const Ni=new Q({allColumns:[`Secret Name`],mandatoryColumns:[`Secret Name`],columnAlignments:{"Secret Name":`left`}});var SecretsLsCommand=class extends ApifyCommand{static name=`ls`;static description=`Lists all secret keys stored in your local configuration.`;static examples=[{description:`List the names of all locally stored secrets.`,command:`apify secrets ls`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-secrets-ls`;static enableJsonFlag=!0;async run(){let{json:e}=this.flags,n=getSecretsFile(),r=Object.keys(n);if(e){printJsonToStdout({keys:r});return}if(r.length===0){info({message:`You don't have any secrets stored locally. Use 'apify secrets add' to add a secret.`,stdout:!0});return}for(let e of r)Ni.pushRow({"Secret Name":t.cyan(e)});simpleLog({message:Ni.render(1),stdout:!0})}},SecretsRmCommand=class extends ApifyCommand{static name=`rm`;static description=`Permanently deletes a secret from your stored credentials.`;static examples=[{description:`Delete a locally stored secret by name.`,command:`apify secrets rm mySecret`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-secrets-rm`;static args={name:Z.string({required:!0,description:`Name of the secret.`})};async run(){let{name:e}=this.args;removeSecret(e)}},SecretsIndexCommand=class extends ApifyCommand{static name=`secrets`;static description=`Manage locally stored secrets that can be referenced from '${K}' environment variables using the "@" prefix (e.g. "@mySecret"). Secrets are uploaded alongside the Actor and stored encrypted on the Apify platform.`;static group=`Authentication`;static examples=[{description:`Store a secret called "mySecret".`,command:`apify secrets add mySecret TopSecretValue123`},{description:`Reference the secret from .actor/actor.json using the "@" prefix, e.g. "environmentVariables": { "SECRET_ENV_VAR": "@mySecret" }, then push as usual.`,command:`apify push`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-secrets`;static subcommands=[SecretsAddCommand,SecretsLsCommand,SecretsRmCommand];async run(){this.printHelp()}},TaskPublishCommand=class extends ApifyCommand{static name=`publish`;static description=`Publishes the task on its public landing page.
|
|
@@ -265,4 +265,4 @@ When no path is provided, validates all schemas found in '${K}':
|
|
|
265
265
|
- Dataset schema (from "storages.dataset")
|
|
266
266
|
- Output schema (from "output")
|
|
267
267
|
- Key-Value Store schema (from "storages.keyValueStore")`;static group=`Local Actor Development`;static examples=[{description:`Validate the input schema discovered from the default locations.`,command:`apify validate-schema`},{description:`Validate a specific INPUT_SCHEMA.json file.`,command:`apify validate-schema ./my-schema.json`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-validate-schema`;static args={path:Z.string({required:!1,description:`Optional path to your INPUT_SCHEMA.json file. If not provided, validates all schemas in '${K}'.`})};static hiddenAliases=[`vis`];async run(){if(this.args.path){await this.validateInputSchemaAtPath(this.args.path);return}await this.validateAllSchemas()}async validateInputSchemaAtPath(t){await readAndValidateInputSchema({forcePath:t,cwd:e.cwd(),getMessage:e=>`Validating input schema at ${e??t}`}),success({message:`Input schema is valid.`})}async validateAllSchemas(){let t=e.cwd(),n=!1,r=!1;try{let{inputSchema:e,inputSchemaPath:r}=await readInputSchema({cwd:t,throwOnMissing:!0});if(e){n=!0,info({message:`Validating input schema ${r?`at ${r}`:`embedded in '${K}'`}`});let t=new Yn({strict:!1});bt(t,e),success({message:`Input schema is valid.`})}}catch(e){n=!0,r=!0,error({message:e.message})}let i=[{label:`Dataset`,read:()=>readStorageSchema({cwd:t,key:`dataset`,label:`Dataset`,throwOnMissing:!0}),validate:validateDatasetSchema},{label:`Output`,read:()=>readStorageSchema({cwd:t,key:`output`,label:`Output`,getRef:e=>e?.output,throwOnMissing:!0}),validate:validateOutputSchema},{label:`Key-Value Store`,read:()=>readStorageSchema({cwd:t,key:`keyValueStore`,label:`Key-Value Store`,throwOnMissing:!0}),validate:validateKvsSchema}];for(let{label:e,read:t,validate:a}of i)try{let r=t();r&&(n=!0,info({message:`Validating ${e} schema ${r.schemaPath?`at ${r.schemaPath}`:`embedded in '${K}'`}`}),a(r.schema),success({message:`${e} schema is valid.`}))}catch(e){n=!0,r=!0,error({message:e.message})}if(!n)throw Error(`No schemas found. Make sure '${K}' exists and defines at least one schema.`);r&&(e.exitCode=5)}};const Fi=[ActorIndexCommand,ActorsIndexCommand,AuthIndexCommand,BuildsIndexCommand,DatasetsIndexCommand,KeyValueStoresIndexCommand,MCPIndexCommand,RequestQueuesIndexCommand,RunsIndexCommand,RuntimeIndexCommand,SecretsIndexCommand,TasksIndexCommand,TelemetryIndexCommand,TemplatesIndexCommand,ApiCommand,TopLevelCallCommand,UpgradeCommand,InstallCommand,CreateCommand,EditInputSchemaCommand,InfoCommand,WrapScrapyCommand,InitCommand,LoginCommand,LogoutCommand,TopLevelPullCommand,ToplevelPushCommand,RunCommand,ValidateSchemaCommand,HelpCommand],Ii=[ActorSetValueCommand,ActorPushDataCommand,ActorGetValueCommand,ActorGetPublicUrlCommand,ActorGetInputCommand,ActorChargeCommand,ActorCalculateMemoryCommand,ActorGenerateSchemaTypesCommand,HelpCommand,UpgradeCommand,InstallCommand,TelemetryIndexCommand];export{runCLI as i,Fi as n,processVersionCheck as r,Ii as t};
|
|
268
|
-
//# sourceMappingURL=_register-
|
|
268
|
+
//# sourceMappingURL=_register-COKPf8wS.js.map
|