@junobuild/cli-tools 0.5.0 → 0.6.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.
- package/dist/node/index.mjs +24 -33
- package/dist/node/index.mjs.map +4 -4
- package/dist/types/commands/deploy.d.ts +50 -35
- package/dist/types/commands/publish.d.ts +11 -5
- package/dist/types/constants/deploy.constants.d.ts +3 -2
- package/dist/types/services/deploy.proposal.services.d.ts +6 -8
- package/dist/types/services/upload/_upload.services.d.ts +13 -0
- package/dist/types/services/upload/upload.batch.services.d.ts +5 -0
- package/dist/types/services/upload/upload.individual.services.d.ts +5 -0
- package/dist/types/services/upload.services.d.ts +4 -7
- package/dist/types/types/deploy.d.ts +17 -3
- package/dist/types/types/publish.d.ts +4 -2
- package/dist/types/types/upload.d.ts +10 -0
- package/dist/types/utils/compress.utils.d.ts +7 -3
- package/dist/types/utils/upload.utils.d.ts +2 -0
- package/package.json +7 -7
|
@@ -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, DeployResult, DeployResultWithProposal, UploadFilesWithProposal, UploadFileWithProposal, UploadIndividually, UploadWithBatch } 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.
|
|
@@ -30,48 +30,63 @@ export declare const postDeploy: ({ config: { postdeploy } }: {
|
|
|
30
30
|
/**
|
|
31
31
|
* Prepares and uploads dapp assets to a satellite.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
* 1
|
|
35
|
-
* 2
|
|
36
|
-
* 3
|
|
33
|
+
* Steps:
|
|
34
|
+
* 1) Resolve source files to upload.
|
|
35
|
+
* 2) Ensure enough memory is available (via internal checks).
|
|
36
|
+
* 3) Upload files using the provided upload function:
|
|
37
|
+
* - `UploadWithBatch`: one init+commit for all files (batched).
|
|
38
|
+
* - `UploadIndividually`: init+commit per file (unbatched).
|
|
37
39
|
*
|
|
38
|
-
*
|
|
40
|
+
* Notes:
|
|
41
|
+
* - Chunk uploading logic is identical in both modes; only init/commit differ.
|
|
42
|
+
* - If no files are detected (e.g. unchanged), the deploy is skipped.
|
|
39
43
|
*
|
|
40
|
-
* @param {Object} options
|
|
41
|
-
* @param {
|
|
42
|
-
* @param {
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* @
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* - `skipped` if no files were found.
|
|
49
|
-
* - `deployed` and a list of uploaded files if the deploy succeeded.
|
|
44
|
+
* @param {Object} options
|
|
45
|
+
* @param {DeployParams} options.params - Deployment parameters (paths, config, etc.).
|
|
46
|
+
* @param {UploadIndividually | UploadWithBatch} options.upload - Upload strategy function.
|
|
47
|
+
* Pass a function that either uploads files **with batch** (single init/commit)
|
|
48
|
+
* or **individually** (per-file init/commit).
|
|
49
|
+
* @returns {Promise<DeployResult>}
|
|
50
|
+
* - `{ result: 'skipped' }` when there are no files to upload.
|
|
51
|
+
* - `{ result: 'deployed', files }` when the upload completes.
|
|
50
52
|
*/
|
|
51
|
-
export declare const deploy: ({
|
|
53
|
+
export declare const deploy: ({ params, upload }: {
|
|
54
|
+
params: DeployParams;
|
|
55
|
+
upload: UploadIndividually | UploadWithBatch;
|
|
56
|
+
}) => Promise<DeployResult>;
|
|
52
57
|
/**
|
|
53
|
-
* Prepares and uploads assets
|
|
58
|
+
* Prepares and uploads assets through a proposal workflow.
|
|
59
|
+
*
|
|
60
|
+
* Steps:
|
|
61
|
+
* 1) Prepare the list of files to upload.
|
|
62
|
+
* 2) If no files are found, skip.
|
|
63
|
+
* 3) Upload using the selected strategy (batched or per-file).
|
|
64
|
+
* 4) Submit a proposal for the asset upgrade and, if `autoCommit` is true, apply it.
|
|
54
65
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* 3. If files exist, uploads them a proposal flow.
|
|
59
|
-
* 4. Optionally commits - apply - the proposal if `autoCommit` is `true`.
|
|
66
|
+
* Notes:
|
|
67
|
+
* - Chunk uploading is the same across strategies; only init/commit batching differs.
|
|
68
|
+
* - Set `clearAssets` to remove existing assets before upload (proposal field).
|
|
60
69
|
*
|
|
61
|
-
* @param {Object} options
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {
|
|
64
|
-
* @param {
|
|
65
|
-
*
|
|
66
|
-
* @param {
|
|
70
|
+
* @param {Object} options
|
|
71
|
+
* @param {Object} options.deploy
|
|
72
|
+
* @param {DeployParams} options.deploy.params - Deployment parameters.
|
|
73
|
+
* @param {UploadIndividually<UploadFileWithProposal> | UploadWithBatch<UploadFilesWithProposal>} options.deploy.upload
|
|
74
|
+
* Upload strategy function used *within the proposal flow*.
|
|
75
|
+
* @param {Object} options.proposal
|
|
76
|
+
* @param {CdnParameters} options.proposal.cdn - Governance/CDN params.
|
|
77
|
+
* @param {boolean} options.proposal.autoCommit - Apply the proposal automatically after submission.
|
|
78
|
+
* @param {boolean} [options.proposal.clearAssets] - Clear existing assets before upload.
|
|
67
79
|
*
|
|
68
|
-
* @returns {Promise<DeployResultWithProposal>}
|
|
69
|
-
* - `{result: 'skipped'}`
|
|
70
|
-
* - `{result: 'submitted', files, proposalId}`
|
|
71
|
-
* - `{result: 'deployed', files, proposalId}`
|
|
80
|
+
* @returns {Promise<DeployResultWithProposal>}
|
|
81
|
+
* - `{ result: 'skipped' }` when there are no files.
|
|
82
|
+
* - `{ result: 'submitted', files, proposalId }` when proposed but not applied.
|
|
83
|
+
* - `{ result: 'deployed', files, proposalId }` when proposed and auto-applied.
|
|
72
84
|
*/
|
|
73
|
-
export declare const deployWithProposal: ({ deploy: {
|
|
74
|
-
deploy:
|
|
85
|
+
export declare const deployWithProposal: ({ deploy: { params, upload }, proposal: { clearAssets, ...restProposal } }: {
|
|
86
|
+
deploy: {
|
|
87
|
+
params: DeployParams;
|
|
88
|
+
upload: UploadIndividually<UploadFileWithProposal> | UploadWithBatch<UploadFilesWithProposal>;
|
|
89
|
+
};
|
|
75
90
|
proposal: Pick<ProposeChangesParams, "cdn" | "autoCommit"> & {
|
|
76
91
|
clearAssets?: boolean;
|
|
77
92
|
};
|
|
@@ -4,12 +4,18 @@ import type { PublishSatelliteWasmParams } from '../types/publish';
|
|
|
4
4
|
/**
|
|
5
5
|
* Uploads a Satellite WASM file to the CDN as part of a proposal-based deployment.
|
|
6
6
|
*
|
|
7
|
-
* This function
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* This function:
|
|
8
|
+
* 1. Optionally performs a memory check (via `assertMemory`).
|
|
9
|
+
* 2. Packages the WASM file into the required format.
|
|
10
|
+
* 3. Uploads the file(s) using the provided upload function — which may
|
|
11
|
+
* perform a batched proposal flow or an individual file flow, depending
|
|
12
|
+
* on the `upload` implementation.
|
|
13
|
+
* 4. Submits a proposal to deploy the uploaded Satellite WASM.
|
|
14
|
+
* 5. Optionally commits (applies) the proposal if `autoCommit` is `true`.
|
|
10
15
|
*
|
|
11
16
|
* @param {Object} options - The deployment and proposal configuration.
|
|
12
|
-
* @param {PublishSatelliteWasmParams} options.
|
|
17
|
+
* @param {PublishSatelliteWasmParams} options.publish - Publication parameters including the upload function,
|
|
18
|
+
* memory assertion, and file paths.
|
|
13
19
|
* @param {Object} options.proposal - Proposal options.
|
|
14
20
|
* @param {CdnParameters} options.proposal.cdn - CDN and governance configuration.
|
|
15
21
|
* @param {boolean} options.proposal.autoCommit - If `true`, the proposal is automatically committed after submission.
|
|
@@ -20,7 +26,7 @@ import type { PublishSatelliteWasmParams } from '../types/publish';
|
|
|
20
26
|
* - `{ result: 'submitted', files, proposalId }` – Upload and proposal submission succeeded.
|
|
21
27
|
* - `{ result: 'deployed', files, proposalId }` – Upload succeeded and proposal was auto-committed.
|
|
22
28
|
*/
|
|
23
|
-
export declare const publishSatelliteWasmWithProposal: ({ publish: { assertMemory, filePath, fullPath, ...restDeploy }, proposal: { version, ...restProposal } }: {
|
|
29
|
+
export declare const publishSatelliteWasmWithProposal: ({ publish: { assertMemory, filePath, fullPath, upload, ...restDeploy }, proposal: { version, ...restProposal } }: {
|
|
24
30
|
publish: PublishSatelliteWasmParams;
|
|
25
31
|
proposal: Pick<ProposeChangesParams, "cdn" | "autoCommit"> & {
|
|
26
32
|
version: string;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { Precompress } from '@junobuild/config';
|
|
1
2
|
export declare const DEPLOY_DEFAULT_SOURCE = "build";
|
|
2
3
|
export declare const DEPLOY_DEFAULT_IGNORE: never[];
|
|
3
4
|
export declare const DEPLOY_DEFAULT_ENCODING: never[];
|
|
4
|
-
export declare const
|
|
5
|
+
export declare const DEPLOY_DEFAULT_PRECOMPRESS: Required<Precompress>;
|
|
5
6
|
export declare const IGNORE_OS_FILES: string[];
|
|
6
|
-
export declare const
|
|
7
|
+
export declare const UPLOAD_DEFAULT_BATCH_SIZE = 20;
|
|
7
8
|
export declare const COLLECTION_DAPP = "#dapp";
|
|
8
9
|
export declare const COLLECTION_CDN_RELEASES = "#_juno/releases";
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { DeployParams, DeployResultWithProposal, FileAndPaths, UploadFileWithProposal } from '../types/deploy';
|
|
1
|
+
import type { DeployResultWithProposal, UploadFilesWithProposal, UploadFileWithProposal, UploadIndividually, UploadWithBatch } from '../types/deploy';
|
|
3
2
|
import type { ProposeChangesParams } from '../types/proposal';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
3
|
+
import type { UploadFilesParams } from '../types/upload';
|
|
4
|
+
export declare const deployAndProposeChanges: ({ deploy: { upload, files, sourceAbsolutePath, collection, batchSize }, proposal: { proposalType, autoCommit, ...proposalRest } }: {
|
|
5
|
+
deploy: {
|
|
6
|
+
upload: UploadIndividually<UploadFileWithProposal> | UploadWithBatch<UploadFilesWithProposal>;
|
|
7
|
+
} & UploadFilesParams;
|
|
10
8
|
proposal: Omit<ProposeChangesParams, "executeChanges">;
|
|
11
9
|
}) => Promise<DeployResultWithProposal>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FileAndPaths, FileDetails, UploadFileStorage } from '../../types/deploy';
|
|
2
|
+
import type { UploadFilesParams } from '../../types/upload';
|
|
3
|
+
export declare const prepareFileForUpload: ({ file, fullPath, collection, filePath, token, description }: {
|
|
4
|
+
file: FileDetails;
|
|
5
|
+
filePath: string;
|
|
6
|
+
} & Pick<UploadFileStorage, "fullPath" | "collection" | "token" | "description">) => Promise<UploadFileStorage>;
|
|
7
|
+
export type ExecuteUploadFiles = (params: {
|
|
8
|
+
groupFiles: FileAndPaths[];
|
|
9
|
+
step: 'alternate' | 'source';
|
|
10
|
+
}) => Promise<void>;
|
|
11
|
+
export declare const executeUploadFiles: ({ files, uploadFiles }: {
|
|
12
|
+
uploadFiles: ExecuteUploadFiles;
|
|
13
|
+
} & Pick<UploadFilesParams, "files">) => Promise<void>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UploadFiles } from '../../types/deploy';
|
|
2
|
+
import type { UploadFilesParams } from '../../types/upload';
|
|
3
|
+
export declare const uploadFilesWithBatch: ({ uploadFiles, collection, ...rest }: {
|
|
4
|
+
uploadFiles: UploadFiles;
|
|
5
|
+
} & UploadFilesParams) => Promise<void>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UploadFile } from '../../types/deploy';
|
|
2
|
+
import type { UploadFilesParams } from '../../types/upload';
|
|
3
|
+
export declare const uploadFilesIndividually: ({ uploadFile, collection, ...rest }: {
|
|
4
|
+
uploadFile: UploadFile;
|
|
5
|
+
} & UploadFilesParams) => Promise<void>;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
export declare const uploadFiles: ({
|
|
4
|
-
|
|
5
|
-
uploadFile: UploadFile;
|
|
6
|
-
sourceAbsolutePath: string;
|
|
7
|
-
collection: typeof COLLECTION_DAPP | typeof COLLECTION_CDN_RELEASES;
|
|
1
|
+
import type { UploadIndividually, UploadWithBatch } from '../types/deploy';
|
|
2
|
+
import type { UploadFilesParams } from '../types/upload';
|
|
3
|
+
export declare const uploadFiles: ({ upload, files, ...rest }: UploadFilesParams & {
|
|
4
|
+
upload: UploadIndividually | UploadWithBatch;
|
|
8
5
|
}) => Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CliConfig, EncodingType } from '@junobuild/config';
|
|
2
|
-
import type { Asset } from '@junobuild/storage';
|
|
2
|
+
import type { Asset, OnUploadProgress } from '@junobuild/storage';
|
|
3
3
|
export type MimeType = string;
|
|
4
4
|
export type FileExtension = string;
|
|
5
5
|
export interface FileDetails {
|
|
@@ -33,6 +33,14 @@ export type UploadFileStorageWithProposal = UploadFileStorage & {
|
|
|
33
33
|
};
|
|
34
34
|
export type UploadFile = (params: UploadFileStorage) => Promise<void>;
|
|
35
35
|
export type UploadFileWithProposal = (params: UploadFileStorageWithProposal) => Promise<void>;
|
|
36
|
+
export interface UploadFilesStorageWithProposal {
|
|
37
|
+
files: UploadFileStorage[];
|
|
38
|
+
proposalId: bigint;
|
|
39
|
+
}
|
|
40
|
+
export type UploadFiles = (params: {
|
|
41
|
+
files: UploadFileStorage[];
|
|
42
|
+
} & OnUploadProgress) => Promise<void>;
|
|
43
|
+
export type UploadFilesWithProposal = (params: UploadFilesStorageWithProposal) => Promise<void>;
|
|
36
44
|
export type DeployResult = {
|
|
37
45
|
result: 'deployed';
|
|
38
46
|
files: Pick<FileDetails, 'file'>[];
|
|
@@ -54,9 +62,15 @@ export interface PrepareDeployOptions {
|
|
|
54
62
|
assertSourceDirExists?: (source: string) => void;
|
|
55
63
|
includeAllFiles?: boolean;
|
|
56
64
|
}
|
|
57
|
-
export type DeployParams
|
|
65
|
+
export type DeployParams = PrepareDeployOptions & {
|
|
58
66
|
config: CliConfig;
|
|
59
67
|
listAssets: ListAssets;
|
|
60
68
|
assertMemory: () => Promise<void>;
|
|
61
|
-
|
|
69
|
+
uploadBatchSize?: number;
|
|
62
70
|
};
|
|
71
|
+
export interface UploadIndividually<T = UploadFile> {
|
|
72
|
+
uploadFile: T;
|
|
73
|
+
}
|
|
74
|
+
export interface UploadWithBatch<T = UploadFiles> {
|
|
75
|
+
uploadFiles: T;
|
|
76
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { DeployParams, FilePaths, UploadFileWithProposal } from './deploy';
|
|
2
|
-
export type PublishSatelliteWasmParams =
|
|
1
|
+
import type { DeployParams, FilePaths, UploadFileWithProposal, UploadIndividually } from './deploy';
|
|
2
|
+
export type PublishSatelliteWasmParams = {
|
|
3
|
+
upload: UploadIndividually<UploadFileWithProposal>;
|
|
4
|
+
} & Pick<DeployParams, 'assertMemory'> & FilePaths & {
|
|
3
5
|
sourceAbsolutePath: string;
|
|
4
6
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OnUploadProgress } from '@junobuild/storage';
|
|
2
|
+
import type { COLLECTION_CDN_RELEASES, COLLECTION_DAPP } from '../constants/deploy.constants';
|
|
3
|
+
import type { FileAndPaths } from './deploy';
|
|
4
|
+
export interface UploadFilesParams {
|
|
5
|
+
files: FileAndPaths[];
|
|
6
|
+
sourceAbsolutePath: string;
|
|
7
|
+
collection: typeof COLLECTION_DAPP | typeof COLLECTION_CDN_RELEASES;
|
|
8
|
+
batchSize: number;
|
|
9
|
+
}
|
|
10
|
+
export type UploadFilesParamsWithProgress = UploadFilesParams & Required<OnUploadProgress>;
|
|
@@ -2,10 +2,14 @@ import type { SatelliteConfig } from '@junobuild/config';
|
|
|
2
2
|
export declare const gunzipFile: ({ source }: {
|
|
3
3
|
source: Buffer;
|
|
4
4
|
}) => Promise<Buffer>;
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const compressFiles: ({ sourceFiles, precompress }: {
|
|
6
6
|
sourceFiles: string[];
|
|
7
|
-
} & Required<Pick<SatelliteConfig, "
|
|
8
|
-
export declare const gzipFile: (
|
|
7
|
+
} & Required<Pick<SatelliteConfig, "precompress">>) => Promise<string[]>;
|
|
8
|
+
export declare const gzipFile: (params: {
|
|
9
|
+
source: string;
|
|
10
|
+
destination?: string;
|
|
11
|
+
}) => Promise<string>;
|
|
12
|
+
export declare const brotliFile: (params: {
|
|
9
13
|
source: string;
|
|
10
14
|
destination?: string;
|
|
11
15
|
}) => Promise<string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junobuild/cli-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
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",
|
|
@@ -54,19 +54,19 @@
|
|
|
54
54
|
"homepage": "https://juno.build",
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@dfinity/utils": "^2",
|
|
57
|
-
"@junobuild/cdn": "^1",
|
|
58
|
-
"@junobuild/config": "
|
|
59
|
-
"@junobuild/storage": "^1",
|
|
60
|
-
"esbuild": "^0.25.1"
|
|
57
|
+
"@junobuild/cdn": "^1.1.0",
|
|
58
|
+
"@junobuild/config": "^2",
|
|
59
|
+
"@junobuild/storage": "^1.1.0",
|
|
60
|
+
"esbuild": "^0.25.1",
|
|
61
|
+
"ora": "^8"
|
|
61
62
|
},
|
|
62
63
|
"dependencies": {
|
|
63
64
|
"file-type": "^21.0.0",
|
|
64
|
-
"
|
|
65
|
+
"listr2": "^9.0.1",
|
|
65
66
|
"mime-types": "^3.0.1",
|
|
66
67
|
"minimatch": "^10.0.3"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
|
-
"@types/listr": "^0.14.9",
|
|
70
70
|
"@types/mime-types": "^3.0.1",
|
|
71
71
|
"@types/minimatch": "^6.0.0"
|
|
72
72
|
}
|