@junobuild/cli-tools 0.1.9 → 0.2.0-next-2025-05-23
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 +12 -10
- package/dist/node/index.mjs.map +4 -4
- package/dist/types/commands/build.d.ts +23 -0
- package/dist/types/commands/deploy.d.ts +43 -5
- package/dist/types/commands/proposals.d.ts +32 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types/deploy.d.ts +6 -0
- package/package.json +5 -4
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import type { Message, Metafile } from 'esbuild';
|
|
2
|
+
/**
|
|
3
|
+
* Builds an ECMAScript module (ESM) bundle for browser use using `esbuild`.
|
|
4
|
+
*
|
|
5
|
+
* This function:
|
|
6
|
+
* - Ensures `esbuild` is available.
|
|
7
|
+
* - Deletes the existing output file if it exists.
|
|
8
|
+
* - Builds the input file with optimizations: minification, tree-shaking, etc.
|
|
9
|
+
* - Returns the esbuild `metafile`, version, and any build errors or warnings.
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} options - Build configuration.
|
|
12
|
+
* @param {string} options.infile - The path to the input file to be bundled.
|
|
13
|
+
* @param {string} options.outfile - The path where the output bundle should be written.
|
|
14
|
+
* @param {Object<string, string>} [options.banner] - Optional banner to prepend to the generated file.
|
|
15
|
+
*
|
|
16
|
+
* @returns {Promise<{
|
|
17
|
+
* metafile: Metafile,
|
|
18
|
+
* errors: Message[],
|
|
19
|
+
* warnings: Message[],
|
|
20
|
+
* version: string
|
|
21
|
+
* }>} An object containing the esbuild metafile, build errors/warnings, and the version of esbuild used.
|
|
22
|
+
*
|
|
23
|
+
* @throws Will exit the process if `esbuild` is not installed.
|
|
24
|
+
*/
|
|
2
25
|
export declare const buildEsm: ({ infile, outfile, banner }: {
|
|
3
26
|
infile: string;
|
|
4
27
|
outfile: string;
|
|
@@ -1,18 +1,56 @@
|
|
|
1
1
|
import type { CliConfig } from '@junobuild/config';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DeployResult, ListAssets, UploadFile } from '../types/deploy';
|
|
3
|
+
/**
|
|
4
|
+
* Executes all configured pre-deploy hooks defined in the Juno configuration.
|
|
5
|
+
*
|
|
6
|
+
* This function is typically run before uploading or deploying any assets to
|
|
7
|
+
* perform validations, code generation, or other preparatory tasks.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} options - The function parameters.
|
|
10
|
+
* @param {CliConfig} options.config - The full configuration object containing hook definitions.
|
|
11
|
+
* @returns {Promise<void>} Resolves once all predeploy hooks have been executed.
|
|
12
|
+
*/
|
|
3
13
|
export declare const preDeploy: ({ config: { predeploy } }: {
|
|
4
14
|
config: CliConfig;
|
|
5
15
|
}) => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Executes all configured post-deploy hooks defined in the Juno configuration.
|
|
18
|
+
*
|
|
19
|
+
* This function is typically run after a successful deployment to perform cleanup,
|
|
20
|
+
* logging, or integration tasks (e.g., sending Slack notifications).
|
|
21
|
+
*
|
|
22
|
+
* @param {Object} options - The function parameters.
|
|
23
|
+
* @param {CliConfig} options.config - The full configuration object containing hook definitions.
|
|
24
|
+
* @returns {Promise<void>} Resolves once all postdeploy hooks have been executed.
|
|
25
|
+
*/
|
|
6
26
|
export declare const postDeploy: ({ config: { postdeploy } }: {
|
|
7
27
|
config: CliConfig;
|
|
8
28
|
}) => Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Prepares and uploads dapp assets to a satellite.
|
|
31
|
+
*
|
|
32
|
+
* This function handles:
|
|
33
|
+
* 1. Resolving source files to upload.
|
|
34
|
+
* 2. Verifying that enough memory is available (via `assertMemory`).
|
|
35
|
+
* 3. Uploading all valid files using the provided `uploadFile` function.
|
|
36
|
+
*
|
|
37
|
+
* If no files are detected (e.g., all files are unchanged), the deploy is skipped.
|
|
38
|
+
*
|
|
39
|
+
* @param {Object} options - Deployment options.
|
|
40
|
+
* @param {CliConfig} options.config - The CLI configuration object.
|
|
41
|
+
* @param {ListAssets} options.listAssets - A function to list existing files on the target.
|
|
42
|
+
* @param {Function} [options.assertSourceDirExists] - Optional check to ensure source directory exists.
|
|
43
|
+
* @param {Function} options.assertMemory - A function to ensure enough memory is available.
|
|
44
|
+
* @param {UploadFile} options.uploadFile - A function responsible for uploading a single file.
|
|
45
|
+
*
|
|
46
|
+
* @returns {Promise<DeployResult>} An object containing the result of the deploy:
|
|
47
|
+
* - `skipped` if no files were found.
|
|
48
|
+
* - `deployed` and a list of uploaded files if the deploy succeeded.
|
|
49
|
+
*/
|
|
9
50
|
export declare const deploy: ({ assertMemory, uploadFile, ...rest }: {
|
|
10
51
|
config: CliConfig;
|
|
11
52
|
listAssets: ListAssets;
|
|
12
53
|
assertSourceDirExists?: (source: string) => void;
|
|
13
54
|
assertMemory: () => Promise<void>;
|
|
14
55
|
uploadFile: UploadFile;
|
|
15
|
-
}) => Promise<
|
|
16
|
-
sourceFiles: FileDetails[];
|
|
17
|
-
sourceAbsolutePath: string;
|
|
18
|
-
}>;
|
|
56
|
+
}) => Promise<DeployResult>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type CdnParameters, type ProposalType } from '@junobuild/cdn';
|
|
2
|
+
import type { DeployResult } from '../types/deploy';
|
|
3
|
+
/**
|
|
4
|
+
* Deploys changes using a proposal-based workflow, optionally try auto-committing the proposal.
|
|
5
|
+
*
|
|
6
|
+
* This function:
|
|
7
|
+
* 1. Initializes a new change (proposal) in the CDN.
|
|
8
|
+
* 2. Executes the provided `deploy` function to upload assets or WASM.
|
|
9
|
+
* 3. If changes were uploaded, submits the proposal.
|
|
10
|
+
* 4. Logs metadata (ID, status, hash).
|
|
11
|
+
* 5. Optionally commits the change if `autoCommit` is `true`.
|
|
12
|
+
*
|
|
13
|
+
* If no changes are detected during deploy, the function exits early.
|
|
14
|
+
*
|
|
15
|
+
* @param {Object} options - The deployment options.
|
|
16
|
+
* @param {ProposalType} options.proposalType - The type of change being proposed (e.g., deploy, upgrade).
|
|
17
|
+
* @param {CdnParameters} options.cdn - Parameters for interacting with the CDN and associated governance.
|
|
18
|
+
* @param {Function} options.deploy - A function that performs the actual upload and returns a `DeployResult`.
|
|
19
|
+
* Receives the generated proposal ID as input.
|
|
20
|
+
* @param {boolean} options.autoCommit - If `true`, the function will also commit the change after submission.
|
|
21
|
+
*
|
|
22
|
+
* @returns {Promise<void>} Resolves once the deployment and optional commit are complete.
|
|
23
|
+
* Exits the process early if no changes were detected.
|
|
24
|
+
*
|
|
25
|
+
* @throws {Error} If the SHA256 hash returned from `submitProposal` is `null` or `undefined`.
|
|
26
|
+
*/
|
|
27
|
+
export declare const deployWithProposal: ({ proposalType, cdn, deploy, autoCommit }: {
|
|
28
|
+
proposalType: ProposalType;
|
|
29
|
+
autoCommit: boolean;
|
|
30
|
+
cdn: CdnParameters;
|
|
31
|
+
deploy: (proposalId: bigint) => Promise<DeployResult>;
|
|
32
|
+
}) => Promise<void>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -29,3 +29,9 @@ export interface UploadFileStorage {
|
|
|
29
29
|
description?: string;
|
|
30
30
|
}
|
|
31
31
|
export type UploadFile = (params: UploadFileStorage) => Promise<void>;
|
|
32
|
+
export type DeployResult = {
|
|
33
|
+
result: 'deployed';
|
|
34
|
+
files: Pick<FileDetails, 'file'>[];
|
|
35
|
+
} | {
|
|
36
|
+
result: 'skipped';
|
|
37
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junobuild/cli-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-next-2025-05-23",
|
|
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,9 +53,10 @@
|
|
|
53
53
|
],
|
|
54
54
|
"homepage": "https://juno.build",
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@dfinity/utils": "
|
|
56
|
+
"@dfinity/utils": "*",
|
|
57
|
+
"@junobuild/cdn": "*",
|
|
57
58
|
"@junobuild/config": "*",
|
|
58
|
-
"esbuild": "
|
|
59
|
+
"esbuild": "*"
|
|
59
60
|
},
|
|
60
61
|
"dependencies": {
|
|
61
62
|
"file-type": "^20.4.1",
|
|
@@ -68,4 +69,4 @@
|
|
|
68
69
|
"@types/mime-types": "^2.1.4",
|
|
69
70
|
"@types/minimatch": "^5.1.2"
|
|
70
71
|
}
|
|
71
|
-
}
|
|
72
|
+
}
|