apify-cli 1.10.1-beta.50 → 1.10.1-beta.52

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,closeSync as w,constants as T,copyFileSync as E,createWriteStream as D,existsSync as O,fstat as k,mkdirSync as A,openSync as j,readFileSync as M,readdirSync as N,realpathSync as ee,renameSync as P,rmSync as F,statSync as te,unlinkSync as ne,writeFileSync as I,writeSync as re}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 L,ACTOR_JOB_STATUSES as R,ACTOR_JOB_TERMINAL_STATUSES as de,ACTOR_JOB_TYPES as z,ACTOR_NAME as fe,ACTOR_SOURCE_TYPES as pe,APIFY_ENV_VARS as B,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{ApifyApiError as Se,ApifyClient as Ce,DownloadItemsFormat as V}from"apify-client";import we,{AxiosHeaders as Te}from"axios";import{createHmacSignature as Ee,cryptoRandomObjectId as De}from"@apify/utilities";import{access as Oe,appendFile as ke,mkdir as H,readFile as U,readdir as Ae,rename as je,rm as Me,stat as W,symlink as Ne,unlink as Pe,writeFile as G}from"node:fs/promises";import{setTimeout as Fe}from"node:timers/promises";import{Result as Ie,err as Le,none as Re,ok as ze,some as Be}from"@sapphire/result";import{execa as Ve}from"execa";import He from"configparser";import Ue from"@inquirer/input";import We from"which";import{execSync as Ge,spawn as Ke}from"node:child_process";import{DurationFormatter as qe,Time as Je,TimeTypes as Ye}from"@sapphire/duration";import{Timestamp as Xe}from"@sapphire/timestamp";import Ze from"adm-zip";import Qe from"ajv/dist/2019.js";import{ZipArchive as $e}from"archiver";import et from"escape-string-regexp";import tt from"ignore";import{getEncoding as nt}from"istextorbinary";import rt,{Mime as it}from"mime";import at from"mime/types/other.js";import ot from"mime/types/standard.js";import{glob as st}from"tinyglobby";import{calculateRunDynamicMemory as ct}from"@apify/actor-memory-expression";import{Separator as lt,createPrompt as ut,isEnterKey as dt,makeTheme as ft,useKeypress as pt,usePrefix as mt,useState as ht}from"@inquirer/core";import{compile as gt}from"json-schema-to-typescript";import{validateInputSchema as _t,validateInputUsingValidator as vt}from"@apify/input_schema";import{getDatasetSchemaValidator as yt,getKeyValueStoreSchemaValidator as bt,getOutputSchemaValidator as xt}from"@apify/json_schemas";import{pipeline as St}from"node:stream/promises";import{MemoryStorage as Ct}from"@crawlee/memory-storage";import wt from"cli-table3";import{downloadTemplate as Tt}from"giget";import Et from"jju";import Dt from"open";import{fetchManifest as Ot,manifestUrl as kt,wrapperManifestUrl as At}from"@apify/actor-templates";import jt from"computer-name";import Mt from"@inquirer/password";import{createServer as Nt}from"node:http";import{createHash as Pt,randomBytes as Ft}from"node:crypto";import It from"@inquirer/select";import Lt from"node:assert";import{ReadStream as Rt}from"node:tty";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=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 Ut=null;function useCLIMetadata(){if(Ut)return Ut;let e=detectInstallMethod(),t=getRuntimeInfo();return Ut={version:`1.10.1-beta.50`,hash:`4ccd31d4280d9d84998cb975de77d076263373dc`,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(`
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,closeSync as w,constants as T,copyFileSync as E,createWriteStream as D,existsSync as O,fstat as k,mkdirSync as A,openSync as j,readFileSync as M,readdirSync as N,realpathSync as ee,renameSync as P,rmSync as F,statSync as te,unlinkSync as ne,writeFileSync as I,writeSync as re}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 L,ACTOR_JOB_STATUSES as R,ACTOR_JOB_TERMINAL_STATUSES as de,ACTOR_JOB_TYPES as z,ACTOR_NAME as fe,ACTOR_SOURCE_TYPES as pe,APIFY_ENV_VARS as B,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{ApifyApiError as Se,ApifyClient as Ce,DownloadItemsFormat as V}from"apify-client";import we,{AxiosHeaders as Te}from"axios";import{createHmacSignature as Ee,cryptoRandomObjectId as De}from"@apify/utilities";import{access as Oe,appendFile as ke,mkdir as H,readFile as U,readdir as Ae,rename as je,rm as Me,stat as W,symlink as Ne,unlink as Pe,writeFile as G}from"node:fs/promises";import{setTimeout as Fe}from"node:timers/promises";import{Result as Ie,err as Le,none as Re,ok as ze,some as Be}from"@sapphire/result";import{execa as Ve}from"execa";import He from"configparser";import Ue from"@inquirer/input";import We from"which";import{execSync as Ge,spawn as Ke}from"node:child_process";import{DurationFormatter as qe,Time as Je,TimeTypes as Ye}from"@sapphire/duration";import{Timestamp as Xe}from"@sapphire/timestamp";import Ze from"adm-zip";import Qe from"ajv/dist/2019.js";import{ZipArchive as $e}from"archiver";import et from"escape-string-regexp";import tt from"ignore";import{getEncoding as nt}from"istextorbinary";import rt,{Mime as it}from"mime";import at from"mime/types/other.js";import ot from"mime/types/standard.js";import{glob as st}from"tinyglobby";import{calculateRunDynamicMemory as ct}from"@apify/actor-memory-expression";import{Separator as lt,createPrompt as ut,isEnterKey as dt,makeTheme as ft,useKeypress as pt,usePrefix as mt,useState as ht}from"@inquirer/core";import{compile as gt}from"json-schema-to-typescript";import{validateInputSchema as _t,validateInputUsingValidator as vt}from"@apify/input_schema";import{getDatasetSchemaValidator as yt,getKeyValueStoreSchemaValidator as bt,getOutputSchemaValidator as xt}from"@apify/json_schemas";import{pipeline as St}from"node:stream/promises";import{MemoryStorage as Ct}from"@crawlee/memory-storage";import wt from"cli-table3";import{downloadTemplate as Tt}from"giget";import Et from"jju";import Dt from"open";import{fetchManifest as Ot,manifestUrl as kt,wrapperManifestUrl as At}from"@apify/actor-templates";import jt from"computer-name";import Mt from"@inquirer/password";import{createServer as Nt}from"node:http";import{createHash as Pt,randomBytes as Ft}from"node:crypto";import It from"@inquirer/select";import Lt from"node:assert";import{ReadStream as Rt}from"node:tty";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=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 Ut=null;function useCLIMetadata(){if(Ut)return Ut;let e=detectInstallMethod(),t=getRuntimeInfo();return Ut={version:`1.10.1-beta.52`,hash:`4bafea1a20ad72a61f5d256a35c5982a4e0c3945`,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{I(i,n),r!==void 0&&C(i,r),P(i,t)}catch(e){try{F(i,{force:!0})}catch{}throw e}}function atomicCopySync(t,n,r){let i=`${n}.${e.pid}.tmp`;try{E(t,i),r!==void 0&&C(i,r),P(i,n)}catch(e){try{F(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(O(t))try{F(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(O(n))try{p(n)===p(e.execPath)?(P(n,`${n}.old`),cliDebugPrint(`[migration] renamed running legacy binary`,n)):F(n,{force:!0})}catch(e){try{P(n,`${n}.old`)}catch{}cliDebugPrint(`[migration] failed to remove legacy binary`,{legacyBinaryPath:n,err:e})}}let t=u(r,`upgrade.ps1`);try{F(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(`
@@ -140,10 +140,10 @@ Returns exit code 0 only when the build SUCCEEDED. Designed for CI and agentic w
140
140
  `)})}};const Kr=useCLIMetadata();function isInstalledOnMusl(){return Kr.platform===`linux`&&O(`/etc/alpine-release`)}function isInstalledOnBaseline(){return Kr.platform===`darwin`&&Kr.arch===`x64`?!Ge(`sysctl -a`,{encoding:`utf-8`}).includes(`AVX2`):Kr.platform===`linux`&&Kr.arch===`x64`?!M(`/proc/cpuinfo`,`utf-8`).includes(`avx2`):Kr.platform===`windows`&&Kr.arch!==`arm64`&&Ge(`pwsh -c "!(Add-Type -MemberDefinition '[DllImport(\\"kernel32.dll\\")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);' -Name 'Kernel32' -Namespace 'Win32' -PassThru)::IsProcessorFeaturePresent(40)"`,{encoding:`utf-8`,windowsHide:!0}).trim().toLowerCase()===`true`}async function useCLIVersionAssets(e){let t=e.replace(/^v(\d+)/,`$1`),n=t===`latest`?`latest`:`tags/v${t}`,r=await fetch(`https://api.github.com/repos/apify/apify-cli/releases/${n}`,{headers:{"User-Agent":vn}});if(!r.ok)return cliDebugPrint(`useCLIVersionAssets`,`Failed to fetch release`,{statusCode:r.status,body:await r.text(),version:e,tag:n}),null;let i=await r.json(),a=isInstalledOnMusl(),s=isInstalledOnBaseline(),c=i.assets.filter(e=>{if(!e.name.startsWith(`apify-cli-`))return!1;let[n,r,i,...c]=e.name.slice(10).replace(t,`version`).replace(`.exe`,``).split(`-`);return r===Kr.platform&&i===Kr.arch&&c.includes(`musl`)===a&&c.includes(`baseline`)===s});return cliDebugPrint(`useCLIVersionAssets`,`Fetched release`,{version:i.tag_name,filteredAssets:c}),{assets:c,version:i.tag_name.replace(/^v(\d+)/,`$1`)}}const qr={bundle:(e,t)=>[`${t}`,`upgrade`],npm:e=>[`npm`,`install`,`-g`,`apify-cli@${e}`],pnpm:e=>[`pnpm`,`install`,`-g`,`apify-cli@${e}`],bun:e=>[`bun`,`install`,`-g`,`apify-cli@${e}`],homebrew:()=>[`brew`,`upgrade`,`apify-cli`],volta:e=>[`volta`,`install`,`apify-cli@${e}`]},Jr=`1.0.1`,Yr=`https://raw.githubusercontent.com/apify/apify-cli/refs/heads/master/scripts/install/upgrade.ps1`;var UpgradeCommand=class extends ApifyCommand{static name=`upgrade`;static description=`Checks that installed Apify CLI version is up to date.`;static group=`Utilities`;static examples=[{description:`Check for a newer CLI version and upgrade if available.`,command:`apify upgrade`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-upgrade`;static hidden=!0;static aliases=[`cv`,`check-version`];static flags={force:Y.boolean({description:`[DEPRECATED] This flag is now ignored, as running the command manually will always check for the latest version.`,required:!1,char:`f`}),version:Y.string({description:`The version of the CLI to upgrade to. If not provided, the latest version will be used.`,required:!1}),"internal-automatic-call":Y.boolean({description:`Whether the command was called automatically by the CLI for a version check.`,hidden:!0,default:!1})};get cliName(){return this.entrypoint===`apify`?`Apify CLI`:`Actor CLI`}async run(){if(this.flags.version){await this.handleInstallSpecificVersion(this.flags.version);return}let e=await useCLIVersionCheck(!this.flags.internalAutomaticCall),{installMethod:n}=useCLIMetadata();if(!e.shouldUpdate||e.currentVersion===`0.0.0`){cliDebugPrint(`[upgrade] no update needed`,{shouldUpdate:e.shouldUpdate,currentVersion:e.currentVersion}),this.flags.internalAutomaticCall||info({message:`${this.cliName} is up to date 👍 \n`});return}if(!this.flags.internalAutomaticCall){await this.handleInstallSpecificVersion(`latest`);return}let r=qr[n](`latest`,this.entrypoint).join(` `);simpleLog({message:``}),warning({message:[`You are using an old version of ${this.cliName}. We strongly recommend you always use the latest available version.`,` ↪ Run ${t.bgWhite(t.black(r))} to update! 👍 \n`].join(`
141
141
  `)})}async handleInstallSpecificVersion(t){if(t!==`latest`&&!y(t,Jr)){error({message:`The minimum version of the CLI you can manually downgrade/upgrade to is ${Jr}.`});return}let n=await useCLIVersionAssets(t);if(!n){error({message:`The provided version does not exist. Please check the version number and try again.`});return}let{assets:r,version:i}=n;if(!y(i,Jr)){error({message:`The minimum version of the CLI you can manually downgrade/upgrade to is ${Jr}.`});return}let a=useCLIMetadata();if(a.installMethod===`bundle`){if(!r.length){error({message:[`Failed to find the assets for your system and the provided version. Please open an issue on https://github.com/apify/apify-cli/issues/new and provide the following information:`,`- The version you are trying to upgrade to: ${i}`,`- The system you are running on: ${a.platform} ${a.arch}`].join(`
142
142
  `)});return}let t=c(e.execPath);cliDebugPrint(`[upgrade] bundleDirectory`,t);let n=await Ae(t);if(!n.some(e=>e.startsWith(`apify`)||e.startsWith(`actor`))){cliDebugPrint(`[upgrade] directoryEntries`,n),error({message:[`Failed to find the currently installed ${this.cliName} bundle. Please open an issue on https://github.com/apify/apify-cli/issues/new and provide the following information:`,`- The version you are trying to upgrade to: ${i}`,`- The system you are running on: ${a.platform} ${a.arch}`,`- The directory where the ${this.cliName} bundle is installed: ${t}`].join(`
143
- `)});return}if(a.platform===`windows`)return this.startUpgradeProcess(t,i,r);await this.handleUnixUpgrade(t,i,r),this.successMessage(i);return}let s=qr[a.installMethod](t,this.entrypoint);if(e.env.APIFY_CLI_DEBUG){info({message:`Would run command: ${s.join(` `)}`});return}try{await execWithLog({cmd:s[0],args:s.slice(1)}),this.successMessage(i)}catch{error({message:`Failed to upgrade the CLI. Please run the following command manually: ${s.join(` `)}`})}}successMessage(e){success({message:`Successfully upgraded to ${e} 👍`})}async startUpgradeProcess(t,n,r){await this.upsertUpgradeScript(t);let i=[`-ExecutionPolicy`,`Bypass`,`-File`,`"${u(t,`upgrade.ps1`)}"`,`-ProcessId`,e.pid.toString(),`-InstallLocation`,`"${t}"`,`-Version`,`"${n}"`],a=r.map(e=>e.browser_download_url).join(`,`);i.push(`-AllUrls`,`"${a}"`),cliDebugPrint(`[upgrade] starting upgrade process with args`,i),info({message:`Starting upgrade process...`});let s=Ke(`powershell.exe`,i,{detached:!0,shell:!0,stdio:`inherit`,windowsHide:!1,windowsVerbatimArguments:!0});s.on(`spawn`,()=>{cliDebugPrint(`[upgrade] upgrade process spawned`),s.unref(),e.exit(0)}),s.on(`error`,e=>{error({message:`Failed to start the upgrade process: ${e.message}`})})}async upsertUpgradeScript(t){let n=u(t,`upgrade.ps1`);if(O(n))return;let r=useCLIMetadata(),i=await fetch(Yr,{headers:{"User-Agent":vn}});i.ok||(error({message:[`Failed to fetch the upgrade script. Please open an issue on https://github.com/apify/apify-cli/issues/new and provide the following information:`,`- The system you are running on: ${r.platform} ${r.arch}`,`- The URL of the asset that failed to fetch: ${Yr}`,`- The status code of the response: ${i.status}`].join(`
144
- `)}),e.exit(1));let a=await i.arrayBuffer();await G(n,Buffer.from(a)),cliDebugPrint(`[upgrade] downloaded upgrade script to`,n)}async handleUnixUpgrade(n,r,i){let a=useCLIMetadata();for(let s of i){let i=`apify-cli`,c=u(n,i);info({message:`Downloading \`${i}\` binary of the Apify CLI...`});let l=await fetch(s.browser_download_url,{headers:{"User-Agent":vn}});if(!l.ok){let e=await l.text();cliDebugPrint(`[upgrade] failed to fetch asset`,{asset:s,status:l.status,body:e}),error({message:[`Failed to fetch the ${i} bundle. Please open an issue on https://github.com/apify/apify-cli/issues/new and provide the following information:`,`- The version you are trying to upgrade to: ${r}`,`- The system you are running on: ${a.platform} ${a.arch}`,`- The URL of the asset that failed to fetch: ${s.browser_download_url}`,`- The status code of the response: ${l.status}`,`- The body of the response: ${e}`].join(`
145
- `)});return}if(e.env.APIFY_CLI_DEBUG&&!e.env.APIFY_CLI_FORCE){info({message:`Would write asset ${i} to ${c}`});continue}info({message:t.gray(`Writing ${i} to ${c}...`)});let f=await l.arrayBuffer(),p=`${c}.${e.pid}.tmp`;try{await G(p,Buffer.from(f),{mode:493}),await je(p,c),writeEntrypointShims(n,!1),cliDebugPrint(`[upgrade ${i}] wrote asset to`,c)}catch(e){await Me(p,{force:!0}).catch(()=>{}),cliDebugPrint(`[upgrade] failed to write asset`,{error:e}),error({message:[`Failed to write the ${i} bundle. Please open an issue on https://github.com/apify/apify-cli/issues/new and provide the following information:`,`- The version you are trying to upgrade to: ${r}`,`- The system you are running on: ${a.platform} ${a.arch}`,`- The URL of the asset that failed to fetch: ${s.browser_download_url}`,`- The error: ${e.message}`].join(`
146
- `)})}}}};const Xr={STARTER:`STARTER`,WEB_SCRAPING:`WEB_SCRAPING`,INTEGRATION:`INTEGRATION`,AUTOMATION:`AUTOMATION`,AI:`AI`},$={JAVASCRIPT:`javascript`,TYPESCRIPT:`typescript`,PYTHON:`python`},Zr=`any-language`,Qr=`any-use-case`,$r={[$.TYPESCRIPT]:`ts-crawlee-cheerio`,[$.JAVASCRIPT]:`js-crawlee-cheerio`,[$.PYTHON]:`python-crawlee-beautifulsoup`},ei={[$.TYPESCRIPT]:`ts-empty`,[$.JAVASCRIPT]:`js-empty`,[$.PYTHON]:`python-empty`},ti=[{cliFlag:`web-scraper`,templateTag:Xr.WEB_SCRAPING,label:`Web scraper`},{cliFlag:`ai-agent`,templateTag:Xr.AI,label:`AI agent`},{cliFlag:`data-pipeline`,templateTag:Xr.INTEGRATION,label:`API & data pipeline`},{cliFlag:`browser-automation`,templateTag:Xr.AUTOMATION,label:`Browser automation`}],ni=[{cliFlag:$.JAVASCRIPT,templateTag:$.JAVASCRIPT,label:`JavaScript`,aliases:[`js`]},{cliFlag:$.TYPESCRIPT,templateTag:$.TYPESCRIPT,label:`TypeScript`,aliases:[`ts`]},{cliFlag:$.PYTHON,templateTag:$.PYTHON,label:`Python`,aliases:[`py`]}],ri=ni.flatMap(e=>[e.cliFlag,...e.aliases]),ii=ti.map(e=>e.cliFlag);function useCaseFlagToTag(e){return ti.find(t=>t.cliFlag===e)?.templateTag}function languageFlagToTag(e){return ni.find(t=>t.cliFlag===e||t.aliases.includes(e))?.templateTag}function useCaseLabel(e){return ti.find(t=>t.templateTag===e)?.label??e}function languageLabel(e){return e===`any-language`?`any language`:ni.find(t=>t.templateTag===e)?.label??e}function getTemplateRecommendation(e,t,n){let r=n!==Zr,i=t!==Qr,matchesLanguage=e=>!r||e.category===n,matchesUseCase=e=>!i||!!e.useCases?.includes(t),isExactMatch=e=>matchesLanguage(e)&&matchesUseCase(e),a=/* @__PURE__ */ new Set,s=[],addCandidates=e=>{for(let t of e)a.has(t.id)||(a.add(t.id),s.push(t))},addCuratedTemplates=t=>{let i=r?[t[n]]:Object.values(t);addCandidates(e.filter(e=>i.includes(e.id)))};return(r||i)&&addCandidates(e.filter(isExactMatch)),addCuratedTemplates($r),addCuratedTemplates(ei),r&&addCandidates(e.filter(matchesLanguage)),i&&addCandidates(e.filter(matchesUseCase)),addCandidates(e),s.map(e=>({template:e,isExactMatch:isExactMatch(e)}))}function buildTemplateChoiceList(e,t,n){let r=e.some(e=>e.isExactMatch),i=e.map(({template:e,isExactMatch:t})=>({template:e,label:formatTemplateLabel(e,n),isExactMatch:t})),a=i.findIndex(e=>!e.isExactMatch);return{rows:i,separatorIndex:r&&a>0?a:null,noExactMatchHint:!r&&i.length>0?`No template matches ${describeSelection(t,n)} exactly — showing the closest alternatives.`:null}}function formatTemplateLabel(e,t){let n=ni.find(t=>t.templateTag===e.category)?.label,r=t===`any-language`||e.category!==t;return n&&r?`${e.label} (${n})`:e.label}function describeSelection(e,t){let n=[];return e!==`any-use-case`&&n.push(useCaseLabel(e)),n.push(languageLabel(t)),n.join(` + `)}async function ensureValidActorName(e){return e?(validateActorName(e),e):promptActorName()}async function getTemplateDefinition(e,t,n={}){let r=await t;if(r instanceof Error)throw r;if(e){let t=r.templates.find(t=>t.name===e||t.id===e);if(!t)throw Error(`Could not find the selected template: ${e} in the list of templates.`);return t}return executePrompts(r,n)}async function enhanceReadmeWithLocalSuffix(e,t){let n=await t;if(n instanceof Error)throw n;try{let t=await we.get(n.localReadmeSuffixUrl,{responseType:`text`});await ke(e,`\n\n${t.data}`)}catch(e){warning({message:`Could not append local development instructions to README.md. Cause: ${e.message}`})}}function buildNextSteps(e){let{actorName:t,dependenciesInstalled:n,installCommandSuggestion:r}=e,i=[`cd "${t}"`];return n||i.push(r||`install dependencies with your package manager`),i.push(`apify run`),i}function formatCreateSuccessMessage(e){let{actorName:t,dependenciesInstalled:n,postCreate:r,gitRepositoryInitialized:i,installCommandSuggestion:a,gitRemote:s}=e,c=`✅ Actor '${t}' created successfully!`,l=buildNextSteps({actorName:t,dependenciesInstalled:n,installCommandSuggestion:a});return c+=`\n\nNext steps:\n\n${l.join(`
143
+ `)});return}if(a.platform===`windows`)return this.startUpgradeProcess(t,i,r);await this.handleUnixUpgrade(t,i,r)&&this.successMessage(i);return}let s=qr[a.installMethod](t,this.entrypoint);if(e.env.APIFY_CLI_DEBUG){info({message:`Would run command: ${s.join(` `)}`});return}try{await execWithLog({cmd:s[0],args:s.slice(1)}),this.successMessage(i)}catch{error({message:`Failed to upgrade the CLI. Please run the following command manually: ${s.join(` `)}`})}}successMessage(e){success({message:`Successfully upgraded to ${e} 👍`})}async startUpgradeProcess(t,n,r){await this.upsertUpgradeScript(t);let i=[`-ExecutionPolicy`,`Bypass`,`-File`,`"${u(t,`upgrade.ps1`)}"`,`-ProcessId`,e.pid.toString(),`-InstallLocation`,`"${t}"`,`-Version`,`"${n}"`],a=r.map(e=>e.browser_download_url).join(`,`);i.push(`-AllUrls`,`"${a}"`),cliDebugPrint(`[upgrade] starting upgrade process with args`,i),info({message:`Starting upgrade process...`});let s=Ke(`powershell.exe`,i,{detached:!0,shell:!0,stdio:`inherit`,windowsHide:!1,windowsVerbatimArguments:!0});s.on(`spawn`,()=>{cliDebugPrint(`[upgrade] upgrade process spawned`),s.unref(),e.exit(0)}),s.on(`error`,e=>{error({message:`Failed to start the upgrade process: ${e.message}`})})}async upsertUpgradeScript(t){let n=u(t,`upgrade.ps1`);if(O(n))return;let r=useCLIMetadata(),i=await fetch(Yr,{headers:{"User-Agent":vn}});i.ok||(error({message:[`Failed to fetch the upgrade script. Please open an issue on https://github.com/apify/apify-cli/issues/new and provide the following information:`,`- The system you are running on: ${r.platform} ${r.arch}`,`- The URL of the asset that failed to fetch: ${Yr}`,`- The status code of the response: ${i.status}`].join(`
144
+ `)}),e.exit(1));let a=await i.arrayBuffer();await G(n,Buffer.from(a)),cliDebugPrint(`[upgrade] downloaded upgrade script to`,n)}async handleUnixUpgrade(n,r,i){let a=useCLIMetadata();for(let s of i){let i=`apify-cli`,c=u(n,i);info({message:`Downloading \`${i}\` binary of the Apify CLI...`});let l=await fetch(s.browser_download_url,{headers:{"User-Agent":vn}});if(!l.ok){let t=await l.text();return cliDebugPrint(`[upgrade] failed to fetch asset`,{asset:s,status:l.status,body:t}),error({message:[`Failed to fetch the ${i} bundle. Please open an issue on https://github.com/apify/apify-cli/issues/new and provide the following information:`,`- The version you are trying to upgrade to: ${r}`,`- The system you are running on: ${a.platform} ${a.arch}`,`- The URL of the asset that failed to fetch: ${s.browser_download_url}`,`- The status code of the response: ${l.status}`,`- The body of the response: ${t}`].join(`
145
+ `)}),e.exitCode=1,!1}if(e.env.APIFY_CLI_DEBUG&&!e.env.APIFY_CLI_FORCE){info({message:`Would write asset ${i} to ${c}`});continue}info({message:t.gray(`Writing ${i} to ${c}...`)});let f=await l.arrayBuffer(),p=`${c}.${e.pid}.tmp`;try{await G(p,Buffer.from(f),{mode:493}),await je(p,c),writeEntrypointShims(n,!1),cliDebugPrint(`[upgrade ${i}] wrote asset to`,c)}catch(t){return await Me(p,{force:!0}).catch(()=>{}),cliDebugPrint(`[upgrade] failed to write asset`,{error:t}),error({message:[`Failed to write the ${i} bundle. Please open an issue on https://github.com/apify/apify-cli/issues/new and provide the following information:`,`- The version you are trying to upgrade to: ${r}`,`- The system you are running on: ${a.platform} ${a.arch}`,`- The URL of the asset that failed to fetch: ${s.browser_download_url}`,`- The error: ${t.message}`].join(`
146
+ `)}),e.exitCode=1,!1}}return!0}};const Xr={STARTER:`STARTER`,WEB_SCRAPING:`WEB_SCRAPING`,INTEGRATION:`INTEGRATION`,AUTOMATION:`AUTOMATION`,AI:`AI`},$={JAVASCRIPT:`javascript`,TYPESCRIPT:`typescript`,PYTHON:`python`},Zr=`any-language`,Qr=`any-use-case`,$r={[$.TYPESCRIPT]:`ts-crawlee-cheerio`,[$.JAVASCRIPT]:`js-crawlee-cheerio`,[$.PYTHON]:`python-crawlee-beautifulsoup`},ei={[$.TYPESCRIPT]:`ts-empty`,[$.JAVASCRIPT]:`js-empty`,[$.PYTHON]:`python-empty`},ti=[{cliFlag:`web-scraper`,templateTag:Xr.WEB_SCRAPING,label:`Web scraper`},{cliFlag:`ai-agent`,templateTag:Xr.AI,label:`AI agent`},{cliFlag:`data-pipeline`,templateTag:Xr.INTEGRATION,label:`API & data pipeline`},{cliFlag:`browser-automation`,templateTag:Xr.AUTOMATION,label:`Browser automation`}],ni=[{cliFlag:$.JAVASCRIPT,templateTag:$.JAVASCRIPT,label:`JavaScript`,aliases:[`js`]},{cliFlag:$.TYPESCRIPT,templateTag:$.TYPESCRIPT,label:`TypeScript`,aliases:[`ts`]},{cliFlag:$.PYTHON,templateTag:$.PYTHON,label:`Python`,aliases:[`py`]}],ri=ni.flatMap(e=>[e.cliFlag,...e.aliases]),ii=ti.map(e=>e.cliFlag);function useCaseFlagToTag(e){return ti.find(t=>t.cliFlag===e)?.templateTag}function languageFlagToTag(e){return ni.find(t=>t.cliFlag===e||t.aliases.includes(e))?.templateTag}function useCaseLabel(e){return ti.find(t=>t.templateTag===e)?.label??e}function languageLabel(e){return e===`any-language`?`any language`:ni.find(t=>t.templateTag===e)?.label??e}function getTemplateRecommendation(e,t,n){let r=n!==Zr,i=t!==Qr,matchesLanguage=e=>!r||e.category===n,matchesUseCase=e=>!i||!!e.useCases?.includes(t),isExactMatch=e=>matchesLanguage(e)&&matchesUseCase(e),a=/* @__PURE__ */ new Set,s=[],addCandidates=e=>{for(let t of e)a.has(t.id)||(a.add(t.id),s.push(t))},addCuratedTemplates=t=>{let i=r?[t[n]]:Object.values(t);addCandidates(e.filter(e=>i.includes(e.id)))};return(r||i)&&addCandidates(e.filter(isExactMatch)),addCuratedTemplates($r),addCuratedTemplates(ei),r&&addCandidates(e.filter(matchesLanguage)),i&&addCandidates(e.filter(matchesUseCase)),addCandidates(e),s.map(e=>({template:e,isExactMatch:isExactMatch(e)}))}function buildTemplateChoiceList(e,t,n){let r=e.some(e=>e.isExactMatch),i=e.map(({template:e,isExactMatch:t})=>({template:e,label:formatTemplateLabel(e,n),isExactMatch:t})),a=i.findIndex(e=>!e.isExactMatch);return{rows:i,separatorIndex:r&&a>0?a:null,noExactMatchHint:!r&&i.length>0?`No template matches ${describeSelection(t,n)} exactly — showing the closest alternatives.`:null}}function formatTemplateLabel(e,t){let n=ni.find(t=>t.templateTag===e.category)?.label,r=t===`any-language`||e.category!==t;return n&&r?`${e.label} (${n})`:e.label}function describeSelection(e,t){let n=[];return e!==`any-use-case`&&n.push(useCaseLabel(e)),n.push(languageLabel(t)),n.join(` + `)}async function ensureValidActorName(e){return e?(validateActorName(e),e):promptActorName()}async function getTemplateDefinition(e,t,n={}){let r=await t;if(r instanceof Error)throw r;if(e){let t=r.templates.find(t=>t.name===e||t.id===e);if(!t)throw Error(`Could not find the selected template: ${e} in the list of templates.`);return t}return executePrompts(r,n)}async function enhanceReadmeWithLocalSuffix(e,t){let n=await t;if(n instanceof Error)throw n;try{let t=await we.get(n.localReadmeSuffixUrl,{responseType:`text`});await ke(e,`\n\n${t.data}`)}catch(e){warning({message:`Could not append local development instructions to README.md. Cause: ${e.message}`})}}function buildNextSteps(e){let{actorName:t,dependenciesInstalled:n,installCommandSuggestion:r}=e,i=[`cd "${t}"`];return n||i.push(r||`install dependencies with your package manager`),i.push(`apify run`),i}function formatCreateSuccessMessage(e){let{actorName:t,dependenciesInstalled:n,postCreate:r,gitRepositoryInitialized:i,installCommandSuggestion:a,gitRemote:s}=e,c=`✅ Actor '${t}' created successfully!`,l=buildNextSteps({actorName:t,dependenciesInstalled:n,installCommandSuggestion:a});return c+=`\n\nNext steps:\n\n${l.join(`
147
147
  `)}`,s?(c+=`\n\n🌱 Connected to ${s.remoteUrl} — Actor ${s.actorId} builds from this repository.`,s.automaticBuilds===`on`?c+=`
148
148
  🔁 Every push to this repository rebuilds the Actor.`:s.automaticBuilds===`failed`&&(c+=`
149
149
  💡 Tip: Turn on Automatic builds in the Actor's Source settings to rebuild on every push.`)):(c+=`
@@ -246,4 +246,4 @@ When no path is provided, validates all schemas found in '${K}':
246
246
  - Dataset schema (from "storages.dataset")
247
247
  - Output schema (from "output")
248
248
  - 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 Xn({strict:!1});_t(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 Li=[ActorIndexCommand,ActorsIndexCommand,AuthIndexCommand,BuildsIndexCommand,DatasetsIndexCommand,KeyValueStoresIndexCommand,MCPIndexCommand,RequestQueuesIndexCommand,RunsIndexCommand,SecretsIndexCommand,TasksIndexCommand,TelemetryIndexCommand,TemplatesIndexCommand,ApiCommand,TopLevelCallCommand,UpgradeCommand,InstallCommand,CreateCommand,EditInputSchemaCommand,InfoCommand,WrapScrapyCommand,InitCommand,LoginCommand,LogoutCommand,TopLevelPullCommand,ToplevelPushCommand,RunCommand,ValidateSchemaCommand,HelpCommand],Ri=[ActorSetValueCommand,ActorPushDataCommand,ActorGetValueCommand,ActorGetPublicUrlCommand,ActorGetInputCommand,ActorChargeCommand,ActorCalculateMemoryCommand,ActorGenerateSchemaTypesCommand,HelpCommand,UpgradeCommand,InstallCommand,TelemetryIndexCommand];export{runCLI as i,Li as n,processVersionCheck as r,Ri as t};
249
- //# sourceMappingURL=_register-DOAvJWWJ.js.map
249
+ //# sourceMappingURL=_register-pZJ7TsAZ.js.map