apify-cli 1.10.1-beta.15 → 1.10.1-beta.16
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 ee,realpathSync as M,renameSync as N,rmSync as P,statSync as te,unlinkSync as ne,writeFileSync as F}from"node:fs";import re from"string-width";import ie from"strip-ansi";import{once as ae}from"node:events";import{homedir as oe,platform as se}from"node:os";import ce,{isCI as le}from"ci-info";import{ACTOR_ENV_VARS as I,ACTOR_JOB_STATUSES as L,ACTOR_JOB_TERMINAL_STATUSES as ue,ACTOR_NAME as de,ACTOR_SOURCE_TYPES as fe,APIFY_ENV_VARS as R,KEY_VALUE_STORE_KEYS as pe,LOCAL_ACTOR_ENV_VARS as me,LOCAL_STORAGE_SUBDIRS as he,MAX_MULTIFILE_BYTES as ge,META_ORIGINS as _e,SOURCE_FILE_FORMATS as ve}from"@apify/consts";import{jaroWinkler as ye}from"@skyra/jaro-winkler";import be from"js-levenshtein";import{Result as xe,err as Se,none as Ce,ok as we,some as Te}from"@sapphire/result";import{execa as Ee}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=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 zt=null;function useCLIMetadata(){if(zt)return zt;let e=detectInstallMethod(),t=getRuntimeInfo();return zt={version:`1.10.1-beta.
|
|
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 ee,realpathSync as M,renameSync as N,rmSync as P,statSync as te,unlinkSync as ne,writeFileSync as F}from"node:fs";import re from"string-width";import ie from"strip-ansi";import{once as ae}from"node:events";import{homedir as oe,platform as se}from"node:os";import ce,{isCI as le}from"ci-info";import{ACTOR_ENV_VARS as I,ACTOR_JOB_STATUSES as L,ACTOR_JOB_TERMINAL_STATUSES as ue,ACTOR_NAME as de,ACTOR_SOURCE_TYPES as fe,APIFY_ENV_VARS as R,KEY_VALUE_STORE_KEYS as pe,LOCAL_ACTOR_ENV_VARS as me,LOCAL_STORAGE_SUBDIRS as he,MAX_MULTIFILE_BYTES as ge,META_ORIGINS as _e,SOURCE_FILE_FORMATS as ve}from"@apify/consts";import{jaroWinkler as ye}from"@skyra/jaro-winkler";import be from"js-levenshtein";import{Result as xe,err as Se,none as Ce,ok as we,some as Te}from"@sapphire/result";import{execa as Ee}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=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 zt=null;function useCLIMetadata(){if(zt)return zt;let e=detectInstallMethod(),t=getRuntimeInfo();return zt={version:`1.10.1-beta.16`,hash:`4e9f83de3a13d00f36ecc8c9821f60a73261d1bf`,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{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 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{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`||!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)?(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 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(`
|
|
@@ -106,9 +106,9 @@ If you want to skip missing secrets, run the command with the --allow-missing-se
|
|
|
106
106
|
If you want to skip missing secrets, run the command with the --allow-missing-secrets flag.`)}return r},pr=`temp_file.zip`,mr={build:`latest`,memoryMbytes:4096,timeoutSecs:3600};function resolvePushOutcome(e){switch(e){case L.SUCCEEDED:return{resultLabel:`SUCCEEDED`,exitCode:0,ok:!0};case L.READY:return{resultLabel:`PENDING`,ok:!0};case L.RUNNING:return{resultLabel:`RUNNING`,ok:!0};case L.ABORTING:return{resultLabel:`ABORTING`,exitCode:3,ok:!1,errorMessage:`Build is aborting`};case L.ABORTED:return{resultLabel:`ABORTED`,exitCode:3,ok:!1,errorMessage:`Build aborted`};case L.TIMING_OUT:return{resultLabel:`TIMING_OUT`,exitCode:2,ok:!1,errorMessage:`Build is timing out`};case L.TIMED_OUT:return{resultLabel:`TIMED_OUT`,exitCode:2,ok:!1,errorMessage:`Build timed out`};case L.FAILED:return{resultLabel:`FAILED`,exitCode:1,ok:!1,errorMessage:`Build failed`};default:return{resultLabel:`UNKNOWN`,exitCode:1,ok:!1,errorMessage:`Build finished with unexpected status "${e}"`}}}const confirmGitSourceSwitch=async({actorName:e,gitRepoUrl:t,force:n})=>(warning({message:[`Actor ${e} builds from a Git repository: ${t}`,`A push replaces that source with the local files and drops the Git connection.`,`To build from the repository, run git push instead. The platform builds on push when automated builds are on.`].join(`
|
|
107
107
|
`)}),n?!0:X({message:`Switch the source to the local files?`,default:!1,errorMessageForStdin:`Actor ${e} builds from a Git repository. To switch the source to the local files, use --force.`}));var ActorsPushCommand=class extends ApifyCommand{static name=`push`;static description=`Deploys Actor to Apify platform using settings from '${G}'.\nFiles under '${ge/1024**2}' MB upload as "Multiple source files"; larger projects upload as ZIP file.
|
|
108
108
|
Files matched by .gitignore and .actorignore are excluded. Use negation patterns (e.g. !dist/) in .actorignore to force-include git-ignored files.
|
|
109
|
-
Use --force to override newer remote versions.`;static group=`Local Actor Development`;static examples=[{description:`Deploy the current Actor to the Apify platform.`,command:`apify push`},{description:`Deploy to a specific Actor by ID, overriding newer remote versions.`,command:`apify push E2jjCZBezvAZnX8Rb --force`},{description:`Deploy without waiting for the build to finish.`,command:`apify push --no-wait-for-finish`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-push`;static enableJsonFlag=!0;static flags={version:Y.string({char:`v`,description:`Actor version number to which the files should be pushed. By default, it is taken from the '${G}' file.`,required:!1}),"build-tag":Y.string({char:`b`,description:`Build tag to be applied to the successful Actor build. By default, it is taken from the '${G}' file.`,required:!1}),"wait-for-finish":Y.string({char:`w`,description:`In seconds, how long to wait for the build to finish. If no value passed, it waits forever. To return as soon as the build is queued (fire-and-forget), pass 0. The exit code reflects the build outcome only — if the wait elapses with the build still running, the command exits 0; check status via the printed link or --json output.`,required:!1}),open:Y.boolean({description:`Whether to open the browser automatically to the Actor details page.`,default:!1,required:!1}),force:Y.boolean({char:`f`,description:`Push an Actor even when the local files are older than the Actor on the platform, or when the Actor builds from a Git repository.`,default:!1,required:!1}),dir:Y.string({description:`Directory where the Actor is located.`,required:!1}),"allow-missing-secrets":Y.boolean({description:`Allow the command to continue even when secret values are not found in the local secrets storage.`,required:!1,default:!1}),"apply-env-vars-to-build":Y.boolean({description:`Make the environment variables also available to the Actor build process. Use --no-apply-env-vars-to-build to turn the setting off. When omitted, the setting currently stored on the platform is kept.`,required:!1})};static args={actorId:Z.string({required:!1,description:`Name or ID of the Actor to push (e.g. "apify/hello-world" or "E2jjCZBezvAZnX8Rb"). If not provided, the command will create or modify the Actor with the name specified in '${G}' file.`})};async run(){try{var t=_usingCtx();let n=p(e.cwd(),this.flags.dir??`.`),r=await getActorLocalFilePaths(n);if(!r.length){error({message:`You need to call this command from a folder that has an Actor in it!`}),e.exitCode=4;return}if(![`apify.json`,`actor.json`,`.actor/actor.json`,`.actor`].some(e=>r.some(t=>t===e||t.startsWith(e)))){error({message:[`A valid Actor could not be found in the current directory. Please make sure you are in the correct directory.`,"You can also turn this directory into an Actor by running `apify init`."].join(`
|
|
109
|
+
Use --force to override newer remote versions.`;static group=`Local Actor Development`;static examples=[{description:`Deploy the current Actor to the Apify platform.`,command:`apify push`},{description:`Deploy to a specific Actor by ID, overriding newer remote versions.`,command:`apify push E2jjCZBezvAZnX8Rb --force`},{description:`Deploy without waiting for the build to finish.`,command:`apify push --no-wait-for-finish`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-push`;static enableJsonFlag=!0;static flags={version:Y.string({char:`v`,description:`Actor version number to which the files should be pushed. By default, it is taken from the '${G}' file.`,required:!1}),"build-tag":Y.string({char:`b`,description:`Build tag to be applied to the successful Actor build. By default, it is taken from the '${G}' file.`,required:!1}),"wait-for-finish":Y.string({char:`w`,description:`In seconds, how long to wait for the build to finish. If no value passed, it waits forever. To return as soon as the build is queued (fire-and-forget), pass 0. The exit code reflects the build outcome only — if the wait elapses with the build still running, the command exits 0; check status via the printed link or --json output.`,required:!1}),open:Y.boolean({description:`Whether to open the browser automatically to the Actor details page.`,default:!1,required:!1}),force:Y.boolean({char:`f`,description:`Push an Actor even when the local files are older than the Actor on the platform, or when the Actor builds from a Git repository.`,default:!1,required:!1}),dir:Y.string({description:`Directory where the Actor is located.`,required:!1}),"allow-missing-secrets":Y.boolean({description:`Allow the command to continue even when secret values are not found in the local secrets storage.`,required:!1,default:!1}),"apply-env-vars-to-build":Y.boolean({description:`Make the environment variables also available to the Actor build process. Use --no-apply-env-vars-to-build to turn the setting off. Overrides the value of the 'applyEnvVarsToBuild' field in the '${G}' file. When both the field and the flag are omitted, the setting currently stored on the platform is kept.`,required:!1})};static args={actorId:Z.string({required:!1,description:`Name or ID of the Actor to push (e.g. "apify/hello-world" or "E2jjCZBezvAZnX8Rb"). If not provided, the command will create or modify the Actor with the name specified in '${G}' file.`})};async run(){try{var t=_usingCtx();let n=p(e.cwd(),this.flags.dir??`.`),r=await getActorLocalFilePaths(n);if(!r.length){error({message:`You need to call this command from a folder that has an Actor in it!`}),e.exitCode=4;return}if(![`apify.json`,`actor.json`,`.actor/actor.json`,`.actor`].some(e=>r.some(t=>t===e||t.startsWith(e)))){error({message:[`A valid Actor could not be found in the current directory. Please make sure you are in the correct directory.`,"You can also turn this directory into an Actor by running `apify init`."].join(`
|
|
110
110
|
`)}),e.exitCode=4;return}let i=await getLoggedClientOrThrow(),a=await useActorConfig({cwd:n});if(a.isErr()){error({message:a.unwrapErr().message}),e.exitCode=5;return}let{config:s}=a.unwrap(),c=await getLocalUserInfo(),l=c.organizationOwnerUserId?`/organization/${c.id}`:``,f,m,h=!1,g=this.flags.version||s?.version||`0.0`,_=this.flags.buildTag||s?.buildTag;!_&&g===`0.0`&&(_=`latest`);let v=parseWaitForFinishMillis(this.flags.waitForFinish),y=this.args.actorId;if(y){if(m=await i.actor(y).get(),!m)throw Error(`Cannot find Actor with ID '${y}' in your account.`);f=m.id}else{let e=c.username||c.id;if(m=await i.actor(`${e}/${s.name}`).get(),m)f=m.id;else{let{templates:e}=await Tt(),t=e.find(e=>e.name===s.template)?.defaultRunOptions||mr,n={name:s.name,title:s.title,description:s.description,defaultRunOptions:t,versions:[{versionNumber:g,buildTag:_,sourceType:fe.SOURCE_FILES,sourceFiles:[]}]};s.usesStandbyMode&&(n.actorStandby={isEnabled:!0}),m=await i.actors().create(n),f=m.id,h=!0,info({message:`Created Actor with name ${s.name} on Apify.`})}}this.telemetryData.push={actorId:f,wasCreated:h};let b=i.actor(f);info({message:`Deploying Actor '${s.name}' to Apify.`});let x=await sumFilesSizeInBytes(r,n);if(x<ge&&!h){let e=await b.get(),t=r.reduce((e,t)=>{let{mtimeMs:r,ctimeMs:i}=te(u(n,t)),a=r>i?r:i;return e>a?e:a},0),i=e?.modifiedAt.valueOf();if(!this.flags.force&&i&&t<i&&(s?.name||y))throw Error(`Actor with identifier "${s?.name||y}" already exists on the platform and has newer changes than your local copy.
|
|
111
|
-
Skipping push. Use --force to override.`)}let S=await b.version(g).get();if(S?.sourceType===fe.GIT_REPO&&!await confirmGitSourceSwitch({actorName:m.name,gitRepoUrl:S.gitRepoUrl,force:this.flags.force})){info({message:`Push aborted. Actor ${m.name} still builds from its Git repository.`});return}let C,w,T;if(x<ge)w=await createSourceFiles(r,n),C=fe.SOURCE_FILES;else{run({message:`Zipping Actor files`}),await createActZip(pr,r,n);let e=await i.keyValueStores().getOrCreate(`actor-${f}-source`),t=`version-${g}.zip`,a=j(pr);await i.keyValueStore(e.id).setRecord({key:t,value:a,contentType:`application/zip`}),ne(pr);let s=new URL(`${i.baseUrl}/key-value-stores/${e.id}/records/${t}?disableRedirect=true`);if(e?.urlSigningSecretKey){let n=Le(e.urlSigningSecretKey,t);s.searchParams.set(`signature`,n)}T=s.toString(),C=fe.TARBALL}let E=s.environmentVariables?transformEnvToEnvVars(s.environmentVariables,void 0,{allowMissing:this.flags.allowMissingSecrets}):void 0,
|
|
111
|
+
Skipping push. Use --force to override.`)}let S=await b.version(g).get();if(S?.sourceType===fe.GIT_REPO&&!await confirmGitSourceSwitch({actorName:m.name,gitRepoUrl:S.gitRepoUrl,force:this.flags.force})){info({message:`Push aborted. Actor ${m.name} still builds from its Git repository.`});return}let C,w,T;if(x<ge)w=await createSourceFiles(r,n),C=fe.SOURCE_FILES;else{run({message:`Zipping Actor files`}),await createActZip(pr,r,n);let e=await i.keyValueStores().getOrCreate(`actor-${f}-source`),t=`version-${g}.zip`,a=j(pr);await i.keyValueStore(e.id).setRecord({key:t,value:a,contentType:`application/zip`}),ne(pr);let s=new URL(`${i.baseUrl}/key-value-stores/${e.id}/records/${t}?disableRedirect=true`);if(e?.urlSigningSecretKey){let n=Le(e.urlSigningSecretKey,t);s.searchParams.set(`signature`,n)}T=s.toString(),C=fe.TARBALL}let E=s.environmentVariables?transformEnvToEnvVars(s.environmentVariables,void 0,{allowMissing:this.flags.allowMissingSecrets}):void 0,D=this.flags.applyEnvVarsToBuild??s.applyEnvVarsToBuild;if(S){let e={tarballUrl:T,sourceFiles:w,buildTag:_,sourceType:C,envVars:E,applyEnvVarsToBuild:D};await b.version(g).update(e),run({message:`Updated version ${g} for Actor ${m.name}.`})}else{let e={versionNumber:g,tarballUrl:T,sourceFiles:w,buildTag:_,sourceType:C,envVars:E,applyEnvVarsToBuild:D};await b.versions().create({...e}),run({message:`Created version ${g} for Actor ${m.name}.`})}if(!h&&!!s.usesStandbyMode!=!!m.actorStandby?.isEnabled){let e=!!s.usesStandbyMode;await b.update({actorStandby:{isEnabled:e}}),info({message:`${e?`Enabled`:`Disabled`} standby mode for Actor ${m.name}.`})}run({message:`Building Actor ${m.name}`});let O=v===void 0?1/0:Date.now()+v,k=await b.build(g,{useCache:!0,waitForFinish:2});t.u(useAbortJobOnSignal({apifyClient:i,kind:`build`,jobId:k.id}));try{let e=Number.isFinite(O)?Math.max(0,O-Date.now()):void 0;await outputJobLog({job:k,timeoutMillis:e,apifyClient:i})}catch(e){warning({message:`Can not get log:`}),console.error(e)}let A=await i.build(k.id).get();if(!A){error({message:`Could not fetch build with ID "${k.id}" after deployment.`}),e.exitCode=1;return}for(k=A;!ue.includes(k.status)&&Date.now()<O;)await new Promise(e=>setTimeout(e,1e3)),k=await i.build(k.id).get();if(k.status===L.SUCCEEDED&&_&&v!==0){run({message:`Applying build tag "${_}"...`});let e=Date.now()+5e3,t=!1;for(;Date.now()<e;){if((await b.get())?.taggedBuilds?.[_]?.buildId===k.id){t=!0;break}await new Promise(e=>setTimeout(e,1e3))}t||warning({message:`Build succeeded but tag "${_}" was not set after 5 seconds; subsequent calls referencing this tag may not find it.`})}let ee=k.status,M=resolvePushOutcome(ee),N=`${getConsoleUrl()}${l}/actors/${k.actId}`,P=`${N}#/builds/${k.buildNumber}`,F=[];if(M.errorMessage)try{let e=await i.log(k.id).get();e&&(F=e.split(`
|
|
112
112
|
`).map(e=>e.trimEnd()).filter(e=>e.length>0).slice(-10))}catch{}M.exitCode&&(e.exitCode=M.exitCode);let re={ok:M.ok,operation:`push`,actor:{id:k.actId,url:N},build:{id:k.id,number:k.buildNumber,status:ee,url:P}};if(M.exitCode!==void 0&&(re.exitCode=M.exitCode),M.errorMessage&&(re.error={phase:`build`,message:M.errorMessage,logTail:F}),this.flags.json){printJsonToStdout(re);return}simpleLog({stdout:!0,message:[`Apify push result: ${M.resultLabel}`,``,`Upload: SUCCEEDED`,`Build: ${ee}`,`Actor ID: ${k.actId}`,`Build ID: ${k.id}`,`Build number: ${k.buildNumber}`,...M.exitCode?[`Exit code: ${M.exitCode}`]:[],``,`Actor URL: ${N}`,`Build URL: ${P}`,...M.errorMessage&&F.length?[``,`Reason:`,...F]:[]].join(`
|
|
113
113
|
`)}),this.flags.open&&await wt(N)}catch(e){t.e=e}finally{t.d()}}},ActorsRmCommand=class extends ApifyCommand{static name=`rm`;static description=`Permanently removes an Actor from your account.`;static interactive=!0;static interactiveNote=`Prompts for confirmation before deleting. Cannot be bypassed; deletion is irreversible.`;static examples=[{description:`Delete an Actor by its full name (prompts for confirmation).`,command:`apify actors rm my-username/my-actor`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-actors-rm`;static args={actorId:Z.string({description:`The Actor ID to delete.`,required:!0})};static flags={...YesFlag()};async run(){let{actorId:e}=this.args,{yes:t}=this.flags,n=await getLoggedClientOrThrow();if(!await n.actor(e).get()){error({message:`Actor with ID "${e}" was not found on your account.`});return}if(!await X({message:`Are you sure you want to delete this Actor?`,providedConfirmFromStdin:t||void 0})){info({message:`Deletion of Actor "${e}" was canceled.`});return}try{await n.actor(e).delete(),success({message:`Actor with ID "${e}" was deleted.`})}catch(t){let n=t;error({message:`Failed to delete Actor "${e}".\n ${n.message||n}`})}}};const hr={FREE:`Free`,FLAT_PRICE_PER_MONTH:`Subscription`,PRICE_PER_DATASET_ITEM:`Pay per result`,PAY_PER_EVENT:`Pay per event`};function formatPricingModel(e){return e?hr[e]??e:t.gray(`Unknown`)}function truncateDescription(e,t=60){return e?e.length<=t?e:`${e.slice(0,t-1)}…`:``}var ActorsSearchCommand=class extends ApifyCommand{static name=`search`;static description=`Searches Actors in the Apify Store.
|
|
114
114
|
|
|
@@ -241,4 +241,4 @@ When no path is provided, validates all schemas found in '${G}':
|
|
|
241
241
|
- Dataset schema (from "storages.dataset")
|
|
242
242
|
- Output schema (from "output")
|
|
243
243
|
- 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 Nn({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 mi=[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],hi=[ActorSetValueCommand,ActorPushDataCommand,ActorGetValueCommand,ActorGetPublicUrlCommand,ActorGetInputCommand,ActorChargeCommand,ActorCalculateMemoryCommand,ActorGenerateSchemaTypesCommand,HelpCommand,UpgradeCommand,InstallCommand,TelemetryIndexCommand];export{runCLI as i,mi as n,processVersionCheck as r,hi as t};
|
|
244
|
-
//# sourceMappingURL=_register-
|
|
244
|
+
//# sourceMappingURL=_register-BghhUO53.js.map
|