apify-cli 1.10.1-runtime.0 → 1.10.1-runtime.1
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 O,mkdirSync as k,openSync as A,readFileSync as j,readdirSync as M,realpathSync as ee,renameSync as te,rmSync as N,statSync as ne,unlinkSync as re,writeFileSync as P}from"node:fs";import ie from"string-width";import ae from"strip-ansi";import{once as oe}from"node:events";import{homedir as se,platform as ce}from"node:os";import le,{isCI as ue}from"ci-info";import{ACTOR_ENV_VARS as F,ACTOR_JOB_STATUSES as I,ACTOR_JOB_TERMINAL_STATUSES as de,ACTOR_NAME as fe,ACTOR_SOURCE_TYPES as pe,APIFY_ENV_VARS as L,KEY_VALUE_STORE_KEYS as me,LOCAL_ACTOR_ENV_VARS as he,LOCAL_STORAGE_SUBDIRS as ge,MAX_MULTIFILE_BYTES as _e,META_ORIGINS as ve,SOURCE_FILE_FORMATS as ye}from"@apify/consts";import{jaroWinkler as be}from"@skyra/jaro-winkler";import xe from"js-levenshtein";import{Result as Se,err as Ce,none as we,ok as Te,some as Ee}from"@sapphire/result";import{execa as R}from"execa";import{access as De,appendFile as Oe,mkdir as z,readFile as B,readdir as ke,rename as Ae,rm as je,stat as V,symlink as Me,unlink as Ne,writeFile as H}from"node:fs/promises";import Pe from"configparser";import Fe from"@inquirer/input";import Ie from"which";import{createHmacSignature as Le,cryptoRandomObjectId as Re}from"@apify/utilities";import{execSync as ze,spawn as Be}from"node:child_process";import{DurationFormatter as Ve,Time as He,TimeTypes as Ue}from"@sapphire/duration";import{Timestamp as We}from"@sapphire/timestamp";import Ge from"adm-zip";import Ke from"ajv/dist/2019.js";import{ApifyClient as qe,DownloadItemsFormat as U}from"apify-client";import{ZipArchive as Je}from"archiver";import Ye,{AxiosHeaders as Xe}from"axios";import Ze from"escape-string-regexp";import Qe from"ignore";import{getEncoding as $e}from"istextorbinary";import et,{Mime as tt}from"mime";import nt from"mime/types/other.js";import rt from"mime/types/standard.js";import{glob as it}from"tinyglobby";import{calculateRunDynamicMemory as at}from"@apify/actor-memory-expression";import{Separator as ot,createPrompt as st,isEnterKey as ct,makeTheme as lt,useKeypress as ut,usePrefix as dt,useState as ft}from"@inquirer/core";import{pipeline as pt}from"node:stream/promises";import{MemoryStorage as mt}from"@crawlee/memory-storage";import{compile as ht}from"json-schema-to-typescript";import{validateInputSchema as gt,validateInputUsingValidator as _t}from"@apify/input_schema";import{getDatasetSchemaValidator as vt,getKeyValueStoreSchemaValidator as yt,getOutputSchemaValidator as bt}from"@apify/json_schemas";import xt from"cli-table3";import{downloadTemplate as St}from"giget";import Ct from"jju";import wt from"open";import{fetchManifest as Tt,manifestUrl as Et,wrapperManifestUrl as Dt}from"@apify/actor-templates";import Ot from"computer-name";import kt from"@inquirer/password";import At from"@inquirer/select";import{createServer as jt}from"node:http";import Mt from"node:assert";import{ReadStream as Nt}from"node:tty";import{setTimeout as Pt}from"node:timers/promises";import Ft from"detect-indent";import{fileURLToPath as It}from"node:url";import Lt from"@root/walk";import Rt from"handlebars";function internalLog(e){e.stdoutOutput&&console.log(...e.stdoutOutput),e.stderrOutput&&console.error(...e.stderrOutput)}function simpleLog(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[e.message]})}function error(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.red(`Error:`),e.message]})}function warning(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.yellow.bold(`Warning:`),e.message]})}function success(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.green(`Success:`),e.message]})}function run(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.gray(`Run:`),e.message]})}function info(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.white(`Info:`),e.message]})}function detectInstallMethod(){if(process.env.APIFY_CLI_BUNDLE)return`bundle`;let e=process.argv[1];if(!e)return warning({message:`Failed to detect install method of CLI, assuming npm`}),`npm`;let t=ee(e);return process.env.VOLTA_HOME&&t.includes(process.env.VOLTA_HOME)?`volta`:t.includes(`homebrew/Cellar`)||t.includes(`linuxbrew/Cellar`)?`homebrew`:process.env.PNPM_HOME&&t.includes(process.env.PNPM_HOME)?`pnpm`:process.env.BUN_INSTALL&&t.includes(process.env.BUN_INSTALL)?`bun`:`npm`}function getRuntimeInfo(){return process.versions.bun?{runtime:`bun`,version:process.versions.bun,nodeVersion:process.versions.node}:process.versions.deno?{runtime:`deno`,version:process.versions.deno,nodeVersion:process.versions.node}:{runtime:`node`,version:process.versions.node}}let zt=null;function useCLIMetadata(){if(zt)return zt;let e=detectInstallMethod(),t=getRuntimeInfo();return zt={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 O,mkdirSync as k,openSync as A,readFileSync as j,readdirSync as M,realpathSync as ee,renameSync as te,rmSync as N,statSync as ne,unlinkSync as re,writeFileSync as P}from"node:fs";import ie from"string-width";import ae from"strip-ansi";import{once as oe}from"node:events";import{homedir as se,platform as ce}from"node:os";import le,{isCI as ue}from"ci-info";import{ACTOR_ENV_VARS as F,ACTOR_JOB_STATUSES as I,ACTOR_JOB_TERMINAL_STATUSES as de,ACTOR_NAME as fe,ACTOR_SOURCE_TYPES as pe,APIFY_ENV_VARS as L,KEY_VALUE_STORE_KEYS as me,LOCAL_ACTOR_ENV_VARS as he,LOCAL_STORAGE_SUBDIRS as ge,MAX_MULTIFILE_BYTES as _e,META_ORIGINS as ve,SOURCE_FILE_FORMATS as ye}from"@apify/consts";import{jaroWinkler as be}from"@skyra/jaro-winkler";import xe from"js-levenshtein";import{Result as Se,err as Ce,none as we,ok as Te,some as Ee}from"@sapphire/result";import{execa as R}from"execa";import{access as De,appendFile as Oe,mkdir as z,readFile as B,readdir as ke,rename as Ae,rm as je,stat as V,symlink as Me,unlink as Ne,writeFile as H}from"node:fs/promises";import Pe from"configparser";import Fe from"@inquirer/input";import Ie from"which";import{createHmacSignature as Le,cryptoRandomObjectId as Re}from"@apify/utilities";import{execSync as ze,spawn as Be}from"node:child_process";import{DurationFormatter as Ve,Time as He,TimeTypes as Ue}from"@sapphire/duration";import{Timestamp as We}from"@sapphire/timestamp";import Ge from"adm-zip";import Ke from"ajv/dist/2019.js";import{ApifyClient as qe,DownloadItemsFormat as U}from"apify-client";import{ZipArchive as Je}from"archiver";import Ye,{AxiosHeaders as Xe}from"axios";import Ze from"escape-string-regexp";import Qe from"ignore";import{getEncoding as $e}from"istextorbinary";import et,{Mime as tt}from"mime";import nt from"mime/types/other.js";import rt from"mime/types/standard.js";import{glob as it}from"tinyglobby";import{calculateRunDynamicMemory as at}from"@apify/actor-memory-expression";import{Separator as ot,createPrompt as st,isEnterKey as ct,makeTheme as lt,useKeypress as ut,usePrefix as dt,useState as ft}from"@inquirer/core";import{pipeline as pt}from"node:stream/promises";import{MemoryStorage as mt}from"@crawlee/memory-storage";import{compile as ht}from"json-schema-to-typescript";import{validateInputSchema as gt,validateInputUsingValidator as _t}from"@apify/input_schema";import{getDatasetSchemaValidator as vt,getKeyValueStoreSchemaValidator as yt,getOutputSchemaValidator as bt}from"@apify/json_schemas";import xt from"cli-table3";import{downloadTemplate as St}from"giget";import Ct from"jju";import wt from"open";import{fetchManifest as Tt,manifestUrl as Et,wrapperManifestUrl as Dt}from"@apify/actor-templates";import Ot from"computer-name";import kt from"@inquirer/password";import At from"@inquirer/select";import{createServer as jt}from"node:http";import Mt from"node:assert";import{ReadStream as Nt}from"node:tty";import{setTimeout as Pt}from"node:timers/promises";import Ft from"detect-indent";import{fileURLToPath as It}from"node:url";import Lt from"@root/walk";import Rt from"handlebars";function internalLog(e){e.stdoutOutput&&console.log(...e.stdoutOutput),e.stderrOutput&&console.error(...e.stderrOutput)}function simpleLog(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[e.message]})}function error(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.red(`Error:`),e.message]})}function warning(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.yellow.bold(`Warning:`),e.message]})}function success(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.green(`Success:`),e.message]})}function run(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.gray(`Run:`),e.message]})}function info(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.white(`Info:`),e.message]})}function detectInstallMethod(){if(process.env.APIFY_CLI_BUNDLE)return`bundle`;let e=process.argv[1];if(!e)return warning({message:`Failed to detect install method of CLI, assuming npm`}),`npm`;let t=ee(e);return process.env.VOLTA_HOME&&t.includes(process.env.VOLTA_HOME)?`volta`:t.includes(`homebrew/Cellar`)||t.includes(`linuxbrew/Cellar`)?`homebrew`:process.env.PNPM_HOME&&t.includes(process.env.PNPM_HOME)?`pnpm`:process.env.BUN_INSTALL&&t.includes(process.env.BUN_INSTALL)?`bun`:`npm`}function getRuntimeInfo(){return process.versions.bun?{runtime:`bun`,version:process.versions.bun,nodeVersion:process.versions.node}:process.versions.deno?{runtime:`deno`,version:process.versions.deno,nodeVersion:process.versions.node}:{runtime:`node`,version:process.versions.node}}let zt=null;function useCLIMetadata(){if(zt)return zt;let e=detectInstallMethod(),t=getRuntimeInfo();return zt={version:`1.10.1-runtime.1`,hash:`b1bc9a1bbe220b84e2a4b2cf3b44a80f3d1a7452`,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`&&(zt.installPath=c(process.execPath)),zt}function cliDebugPrint(e,...n){process.env.APIFY_CLI_DEBUG&&console.error(t.gray(`[${e}]`),...n)}const Bt=[`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{P(i,n),r!==void 0&&C(i,r),te(i,t)}catch(e){try{N(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),te(i,n)}catch(e){try{N(i,{force:!0})}catch{}throw e}}function writeEntrypointShims(e,t){for(let n of Bt)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 Bt){let t=u(r,`${e}.exe.old`);if(D(t))try{N(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`||!Bt.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 Bt){let n=u(r,`${t}.exe`);if(D(n))try{p(n)===p(e.execPath)?(te(n,`${n}.old`),cliDebugPrint(`[migration] renamed running legacy binary`,n)):N(n,{force:!0})}catch(e){try{te(n,`${n}.old`)}catch{}cliDebugPrint(`[migration] failed to remove legacy binary`,{legacyBinaryPath:n,err:e})}}let t=u(r,`upgrade.ps1`);try{N(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 Vt;function getMaxLineWidth(){if(Vt)return Vt;let e=Number(process.env.APIFY_CLI_MAX_LINE_WIDTH);if(!Number.isNaN(e))Vt=e;else if(!process.stdout.isTTY)Vt=80;else{let e=process.stdout.getWindowSize?.()[0]??-1;Vt=e<1?80:e<40?40:e}return Vt}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(`
|
|
@@ -228,7 +228,7 @@ Use \`--no-purge\` to keep the storage folder intact.`,required:!1,default:!0,ex
|
|
|
228
228
|
`),stdout:!0})}addDetailedUsage(e){let{usage:t,usageUsd:n}=e;if(!t||!n){for(let e of Object.keys(oi))ai.pushRow({"":e,Unit:`N/A`,"USD Amount":`N/A`});return}for(let[e,r]of Object.entries(oi)){let i=t[r]??0,a=n[r]??0;switch(r){case`ACTOR_COMPUTE_UNITS`:ai.pushRow({"":e,Unit:i.toFixed(4),"USD Amount":this.formatUsd(a)});break;case`DATA_TRANSFER_INTERNAL_GBYTES`:case`DATA_TRANSFER_EXTERNAL_GBYTES`:case`PROXY_RESIDENTIAL_TRANSFER_GBYTES`:ai.pushRow({"":e,Unit:prettyPrintBytes({bytes:i*1024*1024*1024,shortBytes:!0}),"USD Amount":this.formatUsd(a)});break;default:ai.pushRow({"":e,Unit:i.toLocaleString(`en-US`),"USD Amount":this.formatUsd(a)})}}}formatUsd(e){return`$${e.toFixed(3)}`}},RunsLogCommand=class extends ApifyCommand{static name=`log`;static description=`Prints the log of a specific run.`;static examples=[{description:`Print the log of a specific run to stdout.`,command:`apify runs log <runId>`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-runs-log`;static args={runId:Z.string({required:!0,description:`The run ID to get the log from.`})};async run(){let{runId:e}=this.args,t=await getLoggedClientOrThrow(),n=await t.run(e).get();if(!n){error({message:`Run with ID "${e}" was not found on your account.`,stdout:!0});return}info({message:`Log for run with ID "${e}":\n`,stdout:!0});try{await outputJobLog({job:n,apifyClient:t})}catch(t){error({message:`Failed to get log for run with ID "${e}": ${t.message}`})}}};const si=new Q({allColumns:[`ID`,`Status`,`Results`,`Usage`,`Started At`,`Took`,`Build No.`,`Origin`],mandatoryColumns:[`ID`,`Status`,`Results`,`Usage`,`Started At`,`Took`],columnAlignments:{Results:`right`,Usage:`right`,Took:`right`,"Build No.":`right`}});var RunsLsCommand=class extends ApifyCommand{static name=`ls`;static description=`Lists all runs of the Actor.`;static examples=[{description:`List runs of the Actor in the current directory.`,command:`apify runs ls`},{description:`List runs of a specific Actor.`,command:`apify runs ls apify/hello-world`},{description:`List the 50 most recent runs in descending order.`,command:`apify runs ls --limit 50 --desc`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-runs-ls`;static flags={offset:Y.integer({description:`Number of runs that will be skipped.`,default:0}),limit:Y.integer({description:`Number of runs that will be listed.`,default:10}),desc:Y.boolean({description:`Sort runs in descending order.`,default:!1}),compact:Y.boolean({description:`Display a compact table.`,default:!1,char:`c`})};static args={actorId:Z.string({description:`Optional Actor ID or Name to list runs for. By default, it will use the Actor from the current directory.`})};static enableJsonFlag=!0;async run(){let{desc:e,limit:n,offset:r,compact:i,json:a}=this.flags,{actorId:s}=this.args,c=await getLoggedClientOrThrow(),l=await resolveActorContext({providedActorNameOrId:s,client:c});if(!l.valid){error({message:`${l.reason}. Please run this command in an Actor directory, or specify the Actor ID.`});return}let u=await c.actor(l.id).runs().list({desc:e,limit:n,offset:r});if(a){printJsonToStdout(u);return}if(!u.items.length){simpleLog({message:`There are no recent runs found for this Actor.`});return}let f=[`${t.reset(`Showing`)} ${t.yellow(u.items.length)} out of ${t.yellow(u.total)} runs for Actor ${t.yellow(l.userFriendlyId)} (${t.gray(l.id)})`],p=new Map(await Promise.all(u.items.map(async e=>c.dataset(e.defaultDatasetId).get().then(n=>[e.id,t.yellow(n?.itemCount??0)],()=>[e.id,t.gray(`N/A`)]))));for(let e of u.items){let n;if(e.finishedAt){let r=e.finishedAt.getTime()-e.startedAt.getTime();n=t.gray(`${q.format(r,void 0,{left:``})}`)}else{let r=Date.now()-e.startedAt.getTime();n=t.gray(`Running for ${q.format(r,void 0,{left:``})}`)}si.pushRow({ID:t.gray(e.id),Status:prettyPrintStatus(e.status),Results:p.get(e.id)||t.gray(`N/A`),Usage:t.cyan(`$${(e.usageTotalUsd??0).toFixed(3)}`),"Started At":Pn.display(e.startedAt),Took:n,"Build No.":e.buildNumber,Origin:e.meta.origin??`UNKNOWN`})}f.push(si.render(+!i)),simpleLog({message:f.join(`
|
|
229
229
|
`),stdout:!0})}};const ci=[I.SUCCEEDED,I.FAILED,I.ABORTED,I.TIMED_OUT];var RunsResurrectCommand=class extends ApifyCommand{static name=`resurrect`;static description=`Resurrects an aborted or finished Actor Run.`;static examples=[{description:`Resurrect a finished or aborted run.`,command:`apify runs resurrect <runId>`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-runs-resurrect`;static args={runId:Z.string({required:!0,description:`The run ID to resurrect.`})};static enableJsonFlag=!0;async run(){let{runId:e}=this.args,t=await getLoggedClientOrThrow(),n=await t.run(e).get();if(!n){error({message:`Run with ID "${e}" was not found on your account.`,stdout:!0});return}if(!ci.includes(n.status)){error({message:`Run with ID "${e}" cannot be resurrected, as it is still running or in the process of aborting.`,stdout:!0});return}try{let n=await t.run(e).resurrect();if(this.flags.json){printJsonToStdout(n);return}success({message:`Run with ID "${e}" was resurrected successfully.`,stdout:!0})}catch(t){let n=t;error({message:`Failed to resurrect run "${e}".\n ${n.message||n}`,stdout:!0})}}};const li=[I.SUCCEEDED,I.FAILED,I.ABORTED,I.TIMED_OUT];var RunsRmCommand=class extends ApifyCommand{static name=`rm`;static description=`Deletes an Actor Run.`;static interactive=!0;static interactiveNote=`Prompts for confirmation before deleting. Cannot be bypassed; deletion is irreversible.`;static examples=[{description:`Delete a finished or aborted run (prompts for confirmation).`,command:`apify runs rm <runId>`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-runs-rm`;static args={runId:Z.string({description:`The run ID to delete.`,required:!0})};static flags={...YesFlag()};async run(){let{runId:e}=this.args,{yes:t}=this.flags,n=await getLoggedClientOrThrow(),r=await n.run(e).get();if(!r){error({message:`Run with ID "${e}" was not found on your account.`});return}if(!li.includes(r.status)){error({message:`Run with ID "${e}" cannot be deleted, as it is still running or in the process of aborting.`});return}if(!await X({message:`Are you sure you want to delete this Actor Run?`,providedConfirmFromStdin:t||void 0})){info({message:`Deletion of run "${e}" was canceled.`});return}try{await n.run(e).delete(),success({message:`Run with ID "${e}" was deleted.`})}catch(t){let n=t;error({message:`Failed to delete run "${e}".\n ${n.message||n}`})}}},RunsWaitCommand=class extends ApifyCommand{static name=`wait`;static description=`Waits for an Actor run to reach a terminal status (SUCCEEDED, FAILED, ABORTED, TIMED-OUT).
|
|
230
230
|
Returns exit code 0 only when the run SUCCEEDED. Designed for CI and agentic workflows.`;static examples=[{description:`Wait for a run to finish and return a non-zero exit code on failure.`,command:`apify runs wait <runId>`},{description:`Wait for a run and emit a structured JSON result.`,command:`apify runs wait <runId> --json`},{description:`Give up waiting after 5 minutes. Reports the real current status and exits with code 6 if the run is still running.`,command:`apify runs wait <runId> --timeout 300`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-runs-wait`;static enableJsonFlag=!0;static args={runId:Z.string({required:!0,description:`The run ID to wait for.`})};static flags={timeout:Y.integer({char:`t`,description:`Maximum seconds to wait before giving up. Without this flag the command waits indefinitely.`,required:!1}),"poll-interval":Y.integer({description:`How often to poll the platform, in seconds. Defaults to 2.`,required:!1})};async run(){let{runId:t}=this.args,{timeout:n,pollInterval:r,json:i}=this.flags,a=await getLoggedClientOrThrow(),{job:s,timedOutWaiting:c}=await waitForTerminalStatus({apifyClient:a,jobId:t,kind:`run`,maxWaitMillis:n?n*1e3:void 0,pollIntervalMillis:r?r*1e3:void 0}),l=s,u=consoleRunUrl(l.actId,l.id),f=l.status===`SUCCEEDED`,p=exitCodeForWaitResult({job:s,timedOutWaiting:c},`run`),m=`Gave up waiting after ${n}s; run is still ${l.status}`,h=[];if(f||(h=await fetchLogTail(a,l.id)),i){printJsonToStdout({ok:f,operation:`runs.wait`,timedOutWaiting:c,run:{id:l.id,status:l.status,exitCode:l.exitCode??null,url:u},...f?{}:{error:{phase:`run`,message:c?m:`Actor run did not succeed`,logTail:h}},exitCode:p}),e.exitCode=p;return}let g=[{label:`Run`,value:l.status},{label:`Run ID`,value:l.id},{label:`Actor ID`,value:l.actId}];l.buildNumber&&g.push({label:`Build number`,value:l.buildNumber}),typeof l.exitCode==`number`&&g.push({label:`Exit code`,value:String(l.exitCode)});let _=[{label:`Run URL`,url:u}];simpleLog({message:formatResultSummary({resultLabel:`Apify run result`,overallStatus:l.status,lines:g,links:_,errorReason:f?void 0:h}),stdout:!0}),c?error({message:`${m}.`}):f||error({message:`Run ended with status ${l.status}.`}),e.exitCode=p}},RunsIndexCommand=class extends ApifyCommand{static name=`runs`;static description=`Inspect, abort, resurrect, or delete existing Actor runs.
|
|
231
|
-
Does not start new runs — use 'apify call' (synchronous) or 'apify actors start' (asynchronous) for that.`;static group=`Apify Console`;static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-runs`;static subcommands=[RunsAbortCommand,RunsInfoCommand,RunsLogCommand,RunsLsCommand,RunsResurrectCommand,RunsRmCommand,RunsWaitCommand];async run(){this.printHelp()}};const ui=`actor-runtime:latest`,di=`apify-actor-runtime`,fi=3333,pi=3e3;async function findDockerExecutable(){return Ie(`docker`,{nothrow:!0})}function dockerInstallHint(t=e.platform){switch(t){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 dockerDaemonHint(t=e.platform){switch(t){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 isDockerDaemonRunning(){try{return await R(`docker`,[`info`,`--format`,`{{.ServerVersion}}`]),!0}catch{return!1}}async function imageExistsLocally(e){try{return await R(`docker`,[`image`,`inspect`,e]),!0}catch{return!1}}async function isRuntimeContainerRunning(){try{let{stdout:e}=await R(`docker`,[`ps`,`--filter`,`name=^${di}$`,`--format`,`{{.Names}}`]);return e.trim().length>0}catch{return!1}}function dockerSocketMount(t=e.platform){return`${t===`win32`?`//var/run/docker.sock`:`/var/run/docker.sock`}:/var/run/docker.sock`}function buildRuntimeRunArgs({dataDir:t,detach:n,platform:r=e.platform}){let i=[`run`,`--rm`,`--init`,`--name`,di];return n&&i.push(`--detach`),i.push(`-p`,`${fi}:${fi}`,`-p`,`${pi}:${pi}`,`-v`,dockerSocketMount(r),`-v`,`${t}:/data`,ui),i}async function ensureActorRuntimeImage({forcePull:n=!1}={}){if(!await findDockerExecutable())return error({message:`Docker is required to run the Actor runtime, but the 'docker' command was not found.\n ${dockerInstallHint()}`}),e.exitCode=1,!1;if(!await isDockerDaemonRunning())return error({message:`Docker is installed, but the Docker daemon is not running or not reachable.\n ${dockerDaemonHint()}`}),e.exitCode=1,!1;if(!n&&await imageExistsLocally(`actor-runtime:latest`))return info({message:`Actor runtime image '${ui}' is already available locally.`}),!0;info({message:`Downloading the Actor runtime image '${ui}'...`});try{return await execWithLog({cmd:`docker`,args:[`pull`,ui]}),!0}catch{return error({message:[`Could not pull '${ui}'
|
|
231
|
+
Does not start new runs — use 'apify call' (synchronous) or 'apify actors start' (asynchronous) for that.`;static group=`Apify Console`;static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-runs`;static subcommands=[RunsAbortCommand,RunsInfoCommand,RunsLogCommand,RunsLsCommand,RunsResurrectCommand,RunsRmCommand,RunsWaitCommand];async run(){this.printHelp()}};const ui=`josefprochazka/actor-runtime-dev:latest`,di=`apify-actor-runtime`,fi=3333,pi=3e3;async function findDockerExecutable(){return Ie(`docker`,{nothrow:!0})}function dockerInstallHint(t=e.platform){switch(t){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 dockerDaemonHint(t=e.platform){switch(t){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 isDockerDaemonRunning(){try{return await R(`docker`,[`info`,`--format`,`{{.ServerVersion}}`]),!0}catch{return!1}}async function imageExistsLocally(e){try{return await R(`docker`,[`image`,`inspect`,e]),!0}catch{return!1}}async function isRuntimeContainerRunning(){try{let{stdout:e}=await R(`docker`,[`ps`,`--filter`,`name=^${di}$`,`--format`,`{{.Names}}`]);return e.trim().length>0}catch{return!1}}function dockerSocketMount(t=e.platform){return`${t===`win32`?`//var/run/docker.sock`:`/var/run/docker.sock`}:/var/run/docker.sock`}function buildRuntimeRunArgs({dataDir:t,detach:n,platform:r=e.platform}){let i=[`run`,`--rm`,`--init`,`--name`,di];return n&&i.push(`--detach`),i.push(`-p`,`${fi}:${fi}`,`-p`,`${pi}:${pi}`,`-v`,dockerSocketMount(r),`-v`,`${t}:/data`,ui),i}async function ensureActorRuntimeImage({forcePull:n=!1}={}){if(!await findDockerExecutable())return error({message:`Docker is required to run the Actor runtime, but the 'docker' command was not found.\n ${dockerInstallHint()}`}),e.exitCode=1,!1;if(!await isDockerDaemonRunning())return error({message:`Docker is installed, but the Docker daemon is not running or not reachable.\n ${dockerDaemonHint()}`}),e.exitCode=1,!1;if(!n&&await imageExistsLocally(`josefprochazka/actor-runtime-dev:latest`))return info({message:`Actor runtime image '${ui}' is already available locally.`}),!0;info({message:`Downloading the Actor runtime image '${ui}'...`});try{return await execWithLog({cmd:`docker`,args:[`pull`,ui]}),!0}catch{return error({message:[`Could not pull '${ui}'.`,` Check that you are online and can access the image - a private repository needs ${t.white.bold(`docker login`)} first.`,` You can also build the image locally from an actor-runtime checkout instead:`,t.white.bold(` docker build -t ${ui} .`)].join(`
|
|
232
232
|
`)}),e.exitCode=1,!1}}var RuntimeInstallCommand=class extends ApifyCommand{static name=`install`;static description=`Installs the Actor runtime: verifies this machine can run Docker images and downloads the Actor runtime Docker image ('${ui}').`;static group=`Local Actor Development`;static examples=[{description:`Install the Actor runtime.`,command:`apify runtime install`},{description:`Re-download the Actor runtime image even if it is already present.`,command:`apify runtime install --force`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-runtime-install`;static flags={force:Y.boolean({char:`f`,description:`Download the Actor runtime image even when it is already available locally.`,default:!1})};async run(){await ensureActorRuntimeImage({forcePull:this.flags.force})&&(success({message:`Actor runtime is installed.`}),simpleLog({message:`Start it with 'apify runtime start'.`}))}};const 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 Docker container.
|
|
233
233
|
Installs the runtime first when needed (like 'apify runtime install'). The runtime API listens on http://localhost:${fi} and the console on http://localhost:${pi}.`;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`}];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})};async run(){if(await isRuntimeContainerRunning()){error({message:`The Actor runtime is already running (container '${di}'). Stop it with 'apify runtime stop' first.`}),e.exitCode=1;return}if(!await ensureActorRuntimeImage())return;let n=p(this.flags.dataDir??defaultDataDir());await z(n,{recursive:!0}),info({message:[`Starting the Actor runtime (data directory: ${n})...`,``,` API: http://localhost:${fi}`,` Console: http://localhost:${pi}`,``,`Point the Apify CLI at the runtime with:`,t.white.bold(` export APIFY_CLIENT_BASE_URL=http://localhost:${fi}`),t.white.bold(` export APIFY_CONSOLE_URL=http://localhost:${pi}`)].join(`
|
|
234
234
|
`)});let r=buildRuntimeRunArgs({dataDir:n,detach:this.flags.detach});run({message:`docker ${r.join(` `)}`});let i=R(`docker`,r,{stdio:`inherit`}),a=!1,s=en.map(t=>{let handler=()=>{a=!0,i.kill(t)};return e.on(t,handler),()=>e.off(t,handler)});try{await i}catch(t){if(!a){error({message:`The Actor runtime exited with an error: ${t.shortMessage??t}`}),e.exitCode=1;return}}finally{for(let e of s)e()}this.flags.detach&&info({message:`The Actor runtime is running in the background. Stop it with 'apify runtime stop'.`})}},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(){if(!await isRuntimeContainerRunning()){info({message:`The Actor runtime is not running.`});return}try{await execWithLog({cmd:`docker`,args:[`stop`,di]})}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 Docker container.`;static group=`Local Actor Development`;static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-runtime`;static subcommands=[RuntimeInstallCommand,RuntimeStartCommand,RuntimeStopCommand];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 mi=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)mi.pushRow({"Secret Name":t.cyan(e)});simpleLog({message:mi.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 '${G}' 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.
|
|
@@ -244,4 +244,4 @@ When no path is provided, validates all schemas found in '${G}':
|
|
|
244
244
|
- Dataset schema (from "storages.dataset")
|
|
245
245
|
- Output schema (from "output")
|
|
246
246
|
- 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 '${G}'.`})};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 '${G}'`}`});let t=new jn({strict:!1});gt(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 '${G}'`}`}),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 '${G}' exists and defines at least one schema.`);r&&(e.exitCode=5)}};const gi=[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],_i=[ActorSetValueCommand,ActorPushDataCommand,ActorGetValueCommand,ActorGetPublicUrlCommand,ActorGetInputCommand,ActorChargeCommand,ActorCalculateMemoryCommand,ActorGenerateSchemaTypesCommand,HelpCommand,UpgradeCommand,InstallCommand,TelemetryIndexCommand];export{runCLI as i,gi as n,processVersionCheck as r,_i as t};
|
|
247
|
-
//# sourceMappingURL=_register-
|
|
247
|
+
//# sourceMappingURL=_register-ocjWT2_T.js.map
|