@junobuild/cli-tools
Version:
A collection of tools for Juno CLIs and Plugins.
94 lines (93 loc) • 4.46 kB
TypeScript
import type { CliConfig } from '@junobuild/config';
import type { DeployParams, DeployResult, DeployResultWithProposal, UploadFilesWithProposal, UploadFileWithProposal, UploadIndividually, UploadWithBatch } from '../types/deploy';
import type { ProposeChangesParams } from '../types/proposal';
/**
* Executes all configured pre-deploy hooks defined in the Juno configuration.
*
* This function is typically run before uploading or deploying any assets to
* perform validations, code generation, or other preparatory tasks.
*
* @param {Object} options - The function parameters.
* @param {CliConfig} options.config - The full configuration object containing hook definitions.
* @returns {Promise<void>} Resolves once all predeploy hooks have been executed.
*/
export declare const preDeploy: ({ config: { predeploy } }: {
config: CliConfig;
}) => Promise<void>;
/**
* Executes all configured post-deploy hooks defined in the Juno configuration.
*
* This function is typically run after a successful deployment to perform cleanup,
* logging, or integration tasks (e.g., sending Slack notifications).
*
* @param {Object} options - The function parameters.
* @param {CliConfig} options.config - The full configuration object containing hook definitions.
* @returns {Promise<void>} Resolves once all postdeploy hooks have been executed.
*/
export declare const postDeploy: ({ config: { postdeploy } }: {
config: CliConfig;
}) => Promise<void>;
/**
* Prepares and uploads dapp assets to a satellite.
*
* Steps:
* 1) Resolve source files to upload.
* 2) Ensure enough memory is available (via internal checks).
* 3) Upload files using the provided upload function:
* - `UploadWithBatch`: one init+commit for all files (batched).
* - `UploadIndividually`: init+commit per file (unbatched).
*
* Notes:
* - Chunk uploading logic is identical in both modes; only init/commit differ.
* - If no files are detected (e.g. unchanged), the deploy is skipped.
*
* @param {Object} options
* @param {DeployParams} options.params - Deployment parameters (paths, config, etc.).
* @param {UploadIndividually | UploadWithBatch} options.upload - Upload strategy function.
* Pass a function that either uploads files **with batch** (single init/commit)
* or **individually** (per-file init/commit).
* @returns {Promise<DeployResult>}
* - `{ result: 'skipped' }` when there are no files to upload.
* - `{ result: 'deployed', files }` when the upload completes.
*/
export declare const deploy: ({ params, upload }: {
params: DeployParams;
upload: UploadIndividually | UploadWithBatch;
}) => Promise<DeployResult>;
/**
* Prepares and uploads assets through a proposal workflow.
*
* Steps:
* 1) Prepare the list of files to upload.
* 2) If no files are found, skip.
* 3) Upload using the selected strategy (batched or per-file).
* 4) Submit a proposal for the asset upgrade and, if `autoCommit` is true, apply it.
*
* Notes:
* - Chunk uploading is the same across strategies; only init/commit batching differs.
* - Set `clearAssets` to remove existing assets before upload (proposal field).
*
* @param {Object} options
* @param {Object} options.deploy
* @param {DeployParams} options.deploy.params - Deployment parameters.
* @param {UploadIndividually<UploadFileWithProposal> | UploadWithBatch<UploadFilesWithProposal>} options.deploy.upload
* Upload strategy function used *within the proposal flow*.
* @param {Object} options.proposal
* @param {CdnParameters} options.proposal.cdn - Governance/CDN params.
* @param {boolean} options.proposal.autoCommit - Apply the proposal automatically after submission.
* @param {boolean} [options.proposal.clearAssets] - Clear existing assets before upload.
*
* @returns {Promise<DeployResultWithProposal>}
* - `{ result: 'skipped' }` when there are no files.
* - `{ result: 'submitted', files, proposalId }` when proposed but not applied.
* - `{ result: 'deployed', files, proposalId }` when proposed and auto-applied.
*/
export declare const deployWithProposal: ({ deploy: { params, upload }, proposal: { clearAssets, ...restProposal } }: {
deploy: {
params: DeployParams;
upload: UploadIndividually<UploadFileWithProposal> | UploadWithBatch<UploadFilesWithProposal>;
};
proposal: Pick<ProposeChangesParams, "cdn" | "autoCommit"> & {
clearAssets?: boolean;
};
}) => Promise<DeployResultWithProposal>;