@junobuild/cli-tools 0.3.1 → 0.4.1-next-2025-08-11

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,5 +1,5 @@
1
1
  import type { CliConfig } from '@junobuild/config';
2
- import type { DeployParams, DeployResult, DeployResultWithProposal, UploadFileWithProposal } from '../types/deploy';
2
+ import type { DeployParams, DeployParamsGrouped, DeployParamsSingle, DeployResult, DeployResultWithProposal, UploadFilesWithProposal, UploadFileWithProposal } from '../types/deploy';
3
3
  import type { ProposeChangesParams } from '../types/proposal';
4
4
  /**
5
5
  * Executes all configured pre-deploy hooks defined in the Juno configuration.
@@ -33,7 +33,7 @@ export declare const postDeploy: ({ config: { postdeploy } }: {
33
33
  * This function handles:
34
34
  * 1. Resolving source files to upload.
35
35
  * 2. Verifying that enough memory is available (via `assertMemory`).
36
- * 3. Uploading all valid files using the provided `uploadFile` function.
36
+ * 3. Uploading all valid files using the provided `uploadFile` or `uploadFiles` function.
37
37
  *
38
38
  * If no files are detected (e.g., all files are unchanged), the deploy is skipped.
39
39
  *
@@ -42,13 +42,16 @@ export declare const postDeploy: ({ config: { postdeploy } }: {
42
42
  * @param {ListAssets} options.listAssets - A function to list existing files on the target.
43
43
  * @param {Function} [options.assertSourceDirExists] - Optional check to ensure source directory exists.
44
44
  * @param {Function} options.assertMemory - A function to ensure enough memory is available.
45
- * @param {UploadFile} options.uploadFile - A function responsible for uploading a single file.
45
+ * @param {UploadFile} options.uploadFn - A function responsible for uploading a single or a batch of files.
46
46
  *
47
47
  * @returns {Promise<DeployResult>} An object containing the result of the deploy:
48
48
  * - `skipped` if no files were found.
49
49
  * - `deployed` and a list of uploaded files if the deploy succeeded.
50
50
  */
51
- export declare const deploy: ({ uploadFile, ...rest }: DeployParams) => Promise<DeployResult>;
51
+ export declare const deploy: ({ params, upload }: {
52
+ params: DeployParams;
53
+ upload: DeployParamsSingle | DeployParamsGrouped;
54
+ }) => Promise<DeployResult>;
52
55
  /**
53
56
  * Prepares and uploads assets as part of a proposal-based workflow.
54
57
  *
@@ -70,8 +73,11 @@ export declare const deploy: ({ uploadFile, ...rest }: DeployParams) => Promise<
70
73
  * - `{result: 'submitted', files, proposalId}` if the upload and proposal submission succeeded.
71
74
  * - `{result: 'deployed', files, proposalId}` if the upload and proposal was applied automatically committed.
72
75
  */
73
- export declare const deployWithProposal: ({ deploy: { uploadFile, ...rest }, proposal: { clearAssets, ...restProposal } }: {
74
- deploy: DeployParams<UploadFileWithProposal>;
76
+ export declare const deployWithProposal: ({ deploy: { params, upload }, proposal: { clearAssets, ...restProposal } }: {
77
+ deploy: {
78
+ params: DeployParams;
79
+ upload: DeployParamsSingle<UploadFileWithProposal> | DeployParamsGrouped<UploadFilesWithProposal>;
80
+ };
75
81
  proposal: Pick<ProposeChangesParams, "cdn" | "autoCommit"> & {
76
82
  clearAssets?: boolean;
77
83
  };
@@ -20,7 +20,7 @@ import type { PublishSatelliteWasmParams } from '../types/publish';
20
20
  * - `{ result: 'submitted', files, proposalId }` – Upload and proposal submission succeeded.
21
21
  * - `{ result: 'deployed', files, proposalId }` – Upload succeeded and proposal was auto-committed.
22
22
  */
23
- export declare const publishSatelliteWasmWithProposal: ({ publish: { assertMemory, filePath, fullPath, ...restDeploy }, proposal: { version, ...restProposal } }: {
23
+ export declare const publishSatelliteWasmWithProposal: ({ publish: { assertMemory, filePath, fullPath, upload, ...restDeploy }, proposal: { version, ...restProposal } }: {
24
24
  publish: PublishSatelliteWasmParams;
25
25
  proposal: Pick<ProposeChangesParams, "cdn" | "autoCommit"> & {
26
26
  version: string;
@@ -1,7 +1,7 @@
1
1
  export declare const DEPLOY_DEFAULT_SOURCE = "build";
2
2
  export declare const DEPLOY_DEFAULT_IGNORE: never[];
3
3
  export declare const DEPLOY_DEFAULT_ENCODING: never[];
4
- export declare const DEPLOY_DEFAULT_GZIP = "**/*.+(css|js|mjs)";
4
+ export declare const DEPLOY_DEFAULT_GZIP = "**/*.+(css|js|mjs|html)";
5
5
  export declare const IGNORE_OS_FILES: string[];
6
6
  export declare const UPLOAD_BATCH_SIZE = 20;
7
7
  export declare const COLLECTION_DAPP = "#dapp";
@@ -1,8 +1,9 @@
1
1
  import type { COLLECTION_CDN_RELEASES, COLLECTION_DAPP } from '../constants/deploy.constants';
2
- import type { DeployParams, DeployResultWithProposal, FileAndPaths, UploadFileWithProposal } from '../types/deploy';
2
+ import type { DeployParamsGrouped, DeployParamsSingle, DeployResultWithProposal, FileAndPaths, UploadFilesWithProposal, UploadFileWithProposal } from '../types/deploy';
3
3
  import type { ProposeChangesParams } from '../types/proposal';
4
- export declare const deployAndProposeChanges: ({ deploy: { uploadFile, files, sourceAbsolutePath, collection }, proposal: { proposalType, autoCommit, ...proposalRest } }: {
5
- deploy: Pick<DeployParams<UploadFileWithProposal>, "uploadFile"> & {
4
+ export declare const deployAndProposeChanges: ({ deploy: { upload, files, sourceAbsolutePath, collection }, proposal: { proposalType, autoCommit, ...proposalRest } }: {
5
+ deploy: {
6
+ upload: DeployParamsSingle<UploadFileWithProposal> | DeployParamsGrouped<UploadFilesWithProposal>;
6
7
  files: FileAndPaths[];
7
8
  sourceAbsolutePath: string;
8
9
  collection: typeof COLLECTION_DAPP | typeof COLLECTION_CDN_RELEASES;
@@ -0,0 +1,8 @@
1
+ import { type COLLECTION_CDN_RELEASES, type COLLECTION_DAPP } from '../constants/deploy.constants';
2
+ import type { FileAndPaths, UploadFile } from '../types/deploy';
3
+ export declare const uploadFilesSingle: ({ files: sourceFiles, uploadFile, sourceAbsolutePath, collection }: {
4
+ uploadFile: UploadFile;
5
+ files: FileAndPaths[];
6
+ sourceAbsolutePath: string;
7
+ collection: typeof COLLECTION_DAPP | typeof COLLECTION_CDN_RELEASES;
8
+ }) => Promise<void>;
@@ -0,0 +1,8 @@
1
+ import { type COLLECTION_CDN_RELEASES, type COLLECTION_DAPP } from '../constants/deploy.constants';
2
+ import type { FileAndPaths, UploadFiles } from '../types/deploy';
3
+ export declare const uploadFilesGrouped: ({ files: sourceFiles, uploadFiles, sourceAbsolutePath, collection }: {
4
+ files: FileAndPaths[];
5
+ uploadFiles: UploadFiles;
6
+ sourceAbsolutePath: string;
7
+ collection: typeof COLLECTION_DAPP | typeof COLLECTION_CDN_RELEASES;
8
+ }) => Promise<void>;
@@ -1,8 +1,14 @@
1
- import { type COLLECTION_CDN_RELEASES, type COLLECTION_DAPP } from '../constants/deploy.constants';
2
- import type { FileAndPaths, UploadFile } from '../types/deploy';
3
- export declare const uploadFiles: ({ files: sourceFiles, uploadFile, sourceAbsolutePath, collection }: {
1
+ import type { COLLECTION_CDN_RELEASES, COLLECTION_DAPP } from '../constants/deploy.constants';
2
+ import type { FileAndPaths, UploadFile, UploadFiles } from '../types/deploy';
3
+ export declare const uploadFiles: ({ files: sourceFiles, uploadFile, ...rest }: {
4
4
  files: FileAndPaths[];
5
5
  uploadFile: UploadFile;
6
6
  sourceAbsolutePath: string;
7
7
  collection: typeof COLLECTION_DAPP | typeof COLLECTION_CDN_RELEASES;
8
8
  }) => Promise<void>;
9
+ export declare const uploadManyFiles: ({ files: sourceFiles, uploadFiles, ...rest }: {
10
+ files: FileAndPaths[];
11
+ uploadFiles: UploadFiles;
12
+ sourceAbsolutePath: string;
13
+ collection: typeof COLLECTION_DAPP | typeof COLLECTION_CDN_RELEASES;
14
+ }) => Promise<void>;
@@ -35,11 +35,22 @@ export interface UploadFileStorage {
35
35
  encoding?: EncodingType;
36
36
  description?: string;
37
37
  }
38
- export type UploadFileStorageWithProposal = UploadFileStorage & {
38
+ export type UploadFile = (params: UploadFileStorage) => Promise<void>;
39
+ export type UploadFileWithProposal = (params: UploadFileStorage & {
40
+ proposalId: bigint;
41
+ }) => Promise<void>;
42
+ export type UploadFiles = (params: {
43
+ files: UploadFileStorage[];
44
+ }) => Promise<void>;
45
+ export type UploadFilesWithProposal = (params: {
46
+ files: UploadFileStorage[];
39
47
  proposalId: bigint;
48
+ }) => Promise<void>;
49
+ export type UploadFn = {
50
+ uploadFile: UploadFile;
51
+ } | {
52
+ uploadFiles: UploadFiles;
40
53
  };
41
- export type UploadFile = (params: UploadFileStorage) => Promise<void>;
42
- export type UploadFileWithProposal = (params: UploadFileStorageWithProposal) => Promise<void>;
43
54
  export type DeployResult = {
44
55
  result: 'deployed';
45
56
  files: Pick<FileDetails, 'file'>[];
@@ -61,9 +72,14 @@ export interface PrepareDeployOptions {
61
72
  assertSourceDirExists?: (source: string) => void;
62
73
  includeAllFiles?: boolean;
63
74
  }
64
- export type DeployParams<T = UploadFile> = PrepareDeployOptions & {
75
+ export type DeployParams = PrepareDeployOptions & {
65
76
  config: CliConfig;
66
77
  listAssets: ListAssets;
67
78
  assertMemory: () => Promise<void>;
79
+ };
80
+ export type DeployParamsSingle<T = UploadFile> = DeployParams & {
68
81
  uploadFile: T;
69
82
  };
83
+ export type DeployParamsGrouped<T = UploadFiles> = DeployParams & {
84
+ uploadFiles: T;
85
+ };
@@ -1,4 +1,6 @@
1
- import type { DeployParams, FilePaths, UploadFileWithProposal } from './deploy';
2
- export type PublishSatelliteWasmParams = Pick<DeployParams<UploadFileWithProposal>, 'assertMemory' | 'uploadFile'> & FilePaths & {
1
+ import type { DeployParams, DeployParamsSingle, FilePaths, UploadFileWithProposal } from './deploy';
2
+ export type PublishSatelliteWasmParams = {
3
+ upload: DeployParamsSingle<UploadFileWithProposal>;
4
+ } & Pick<DeployParams, 'assertMemory'> & FilePaths & {
3
5
  sourceAbsolutePath: string;
4
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junobuild/cli-tools",
3
- "version": "0.3.1",
3
+ "version": "0.4.1-next-2025-08-11",
4
4
  "description": "A collection of tools for Juno CLIs and Plugins.",
5
5
  "author": "David Dal Busco (https://daviddalbusco.com)",
6
6
  "license": "MIT",
@@ -53,10 +53,10 @@
53
53
  ],
54
54
  "homepage": "https://juno.build",
55
55
  "peerDependencies": {
56
- "@dfinity/utils": "^2",
56
+ "@dfinity/utils": "*",
57
57
  "@junobuild/cdn": "*",
58
58
  "@junobuild/config": "*",
59
- "esbuild": "^0.25.1"
59
+ "esbuild": "*"
60
60
  },
61
61
  "dependencies": {
62
62
  "file-type": "^21.0.0",
@@ -69,4 +69,4 @@
69
69
  "@types/mime-types": "^3.0.1",
70
70
  "@types/minimatch": "^6.0.0"
71
71
  }
72
- }
72
+ }