@junobuild/cli-tools 0.12.2 → 0.12.3

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.
@@ -0,0 +1,17 @@
1
+ import type { PruneFilesFn, PruneParams, PruneResult } from '../types/prune';
2
+ /**
3
+ * Identifies and removes stale assets from a satellite's storage.
4
+ *
5
+ * @param {Object} options
6
+ * @param {PruneParams} options.params - Prune parameters including `dryRun` and `batchSize`.
7
+ * @param {PruneFilesFn} options.pruneFn - Function used to delete the resolved stale assets.
8
+ *
9
+ * @returns {Promise<PruneResult>}
10
+ * - `{ result: 'skipped' }` when no stale assets are found.
11
+ * - `{ result: 'simulated', files }` when `dryRun` is true; no files are deleted.
12
+ * - `{ result: 'pruned', files }` when stale assets are successfully deleted.
13
+ */
14
+ export declare const prune: ({ params: { dryRun, batchSize, ...rest }, pruneFn }: {
15
+ params: PruneParams;
16
+ pruneFn: PruneFilesFn;
17
+ }) => Promise<PruneResult>;
@@ -5,5 +5,3 @@ export declare const DEPLOY_DEFAULT_ENCODING: never[];
5
5
  export declare const DEPLOY_DEFAULT_PRECOMPRESS: Required<Precompress>;
6
6
  export declare const IGNORE_OS_FILES: string[];
7
7
  export declare const UPLOAD_DEFAULT_BATCH_SIZE = 50;
8
- export declare const COLLECTION_DAPP = "#dapp";
9
- export declare const COLLECTION_CDN_RELEASES = "#_juno/releases";
@@ -0,0 +1 @@
1
+ export declare const PRUNE_DEFAULT_BATCH_SIZE = 100;
@@ -0,0 +1,2 @@
1
+ export declare const COLLECTION_DAPP = "#dapp";
2
+ export declare const COLLECTION_CDN_RELEASES = "#_juno/releases";
@@ -1,11 +1,15 @@
1
1
  export * from './commands/build';
2
2
  export * from './commands/deploy';
3
3
  export * from './commands/generate';
4
+ export * from './commands/prune';
4
5
  export * from './commands/publish';
5
6
  export * from './constants/deploy.constants';
7
+ export * from './constants/storage.constants';
8
+ export { ListAssets } from './types/assets';
6
9
  export type * from './types/deploy';
7
10
  export type * from './types/pkg';
8
11
  export type * from './types/proposal';
12
+ export type * from './types/prune';
9
13
  export type * from './types/publish';
10
14
  export * from './utils/args.utils';
11
15
  export * from './utils/cmd.utils';
@@ -1,5 +1,6 @@
1
1
  import type { CliConfig } from '@junobuild/config';
2
- import type { FileDetails, ListAssets, PrepareDeployOptions } from '../types/deploy';
2
+ import type { ListAssets } from '../types/assets';
3
+ import type { FileDetails, PrepareDeployOptions } from '../types/deploy';
3
4
  export declare const prepareDeploy: ({ config, listAssets, assertSourceDirExists, includeAllFiles }: {
4
5
  config: CliConfig;
5
6
  listAssets: ListAssets;
@@ -0,0 +1,9 @@
1
+ import type { CliConfig } from '@junobuild/config';
2
+ import type { ListAssets } from '../types/assets';
3
+ import type { PreparePruneOptions, PruneFileStorage } from '../types/prune';
4
+ export declare const preparePrune: ({ config, listAssets, assertSourceDirExists }: {
5
+ config: CliConfig;
6
+ listAssets: ListAssets;
7
+ } & PreparePruneOptions) => Promise<{
8
+ files: PruneFileStorage[];
9
+ }>;
@@ -0,0 +1,5 @@
1
+ import type { PruneFilesFn, PruneFileStorage, PruneParams } from '../types/prune';
2
+ export declare const prune: ({ files: groupFiles, pruneFn, batchSize }: {
3
+ files: PruneFileStorage[];
4
+ pruneFn: PruneFilesFn;
5
+ } & Required<Pick<PruneParams, "batchSize">>) => Promise<void>;
@@ -0,0 +1,12 @@
1
+ import type { CliConfig } from '@junobuild/config';
2
+ import type { Asset } from '@junobuild/storage';
3
+ export interface PrepareAssetsOptions {
4
+ assertSourceDirExists?: (source: string) => void;
5
+ }
6
+ export type ListAssets = ({ startAfter }: {
7
+ startAfter?: string;
8
+ }) => Promise<Asset[]>;
9
+ export interface AssetsParams {
10
+ config: CliConfig;
11
+ listAssets: ListAssets;
12
+ }
@@ -1,5 +1,6 @@
1
- import type { CliConfig, EncodingType } from '@junobuild/config';
2
- import type { Asset, OnUploadProgress } from '@junobuild/storage';
1
+ import type { EncodingType } from '@junobuild/config';
2
+ import type { OnUploadProgress } from '@junobuild/storage';
3
+ import type { AssetsParams, PrepareAssetsOptions } from './assets';
3
4
  export type MimeType = string;
4
5
  export type FileExtension = string;
5
6
  export interface FileDetails {
@@ -15,9 +16,6 @@ export interface FileAndPaths {
15
16
  file: FileDetails;
16
17
  paths: FilePaths;
17
18
  }
18
- export type ListAssets = ({ startAfter }: {
19
- startAfter?: string;
20
- }) => Promise<Asset[]>;
21
19
  export interface UploadFileStorage {
22
20
  filename: string;
23
21
  data: Blob;
@@ -58,13 +56,10 @@ export type DeployResultWithProposal = {
58
56
  files: Pick<FileDetails, 'file'>[];
59
57
  proposalId: bigint;
60
58
  };
61
- export interface PrepareDeployOptions {
62
- assertSourceDirExists?: (source: string) => void;
59
+ export interface PrepareDeployOptions extends PrepareAssetsOptions {
63
60
  includeAllFiles?: boolean;
64
61
  }
65
- export type DeployParams = PrepareDeployOptions & {
66
- config: CliConfig;
67
- listAssets: ListAssets;
62
+ export type DeployParams = PrepareDeployOptions & AssetsParams & {
68
63
  assertMemory: () => Promise<void>;
69
64
  uploadBatchSize?: number;
70
65
  };
@@ -0,0 +1,18 @@
1
+ import type { AssetsParams, PrepareAssetsOptions } from './assets';
2
+ export type PreparePruneOptions = PrepareAssetsOptions;
3
+ export type PruneParams = PrepareAssetsOptions & AssetsParams & {
4
+ dryRun?: boolean;
5
+ batchSize?: number;
6
+ };
7
+ export interface PruneFileStorage {
8
+ fullPath: string;
9
+ }
10
+ export type PruneFilesFn = (params: {
11
+ files: PruneFileStorage[];
12
+ }) => Promise<void>;
13
+ export type PruneResult = {
14
+ result: 'pruned' | 'simulated';
15
+ files: PruneFileStorage[];
16
+ } | {
17
+ result: 'skipped';
18
+ };
@@ -1,5 +1,5 @@
1
1
  import type { OnUploadProgress } from '@junobuild/storage';
2
- import type { COLLECTION_CDN_RELEASES, COLLECTION_DAPP } from '../constants/deploy.constants';
2
+ import type { COLLECTION_CDN_RELEASES, COLLECTION_DAPP } from '../constants/storage.constants';
3
3
  import type { FileAndPaths } from './deploy';
4
4
  export interface UploadFilesParams {
5
5
  files: FileAndPaths[];
@@ -0,0 +1,4 @@
1
+ export declare const fullPath: ({ file, sourceAbsolutePath }: {
2
+ file: string;
3
+ sourceAbsolutePath: string;
4
+ }) => string;
@@ -1,8 +1,4 @@
1
1
  import type { SatelliteConfig } from '@junobuild/config';
2
- export declare const fullPath: ({ file, sourceAbsolutePath }: {
3
- file: string;
4
- sourceAbsolutePath: string;
5
- }) => string;
6
- export declare const listSourceFiles: ({ sourceAbsolutePath, ignore }: {
2
+ export declare const listSourceFilesForDeploy: ({ sourceAbsolutePath, ignore }: {
7
3
  sourceAbsolutePath: string;
8
4
  } & Required<Pick<SatelliteConfig, "ignore">>) => string[];
@@ -0,0 +1,8 @@
1
+ import type { SatelliteConfig } from '@junobuild/config';
2
+ /**
3
+ * Scans the local source directory and returns a Set of fullPaths that are present.
4
+ * Throws if the directory cannot be read.
5
+ */
6
+ export declare const listSourceFilesForPrune: ({ sourceAbsolutePath, ignore }: {
7
+ sourceAbsolutePath: string;
8
+ } & Required<Pick<SatelliteConfig, "ignore">>) => Set<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junobuild/cli-tools",
3
- "version": "0.12.2",
3
+ "version": "0.12.3",
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",
@@ -55,10 +55,10 @@
55
55
  "ora": "^9"
56
56
  },
57
57
  "dependencies": {
58
- "file-type": "^21.1.1",
59
- "listr2": "^9.0.5",
58
+ "file-type": "^21.3.2",
59
+ "listr2": "^10.2.1",
60
60
  "mime-types": "^3.0.2",
61
- "minimatch": "^10.1.2"
61
+ "minimatch": "^10.2.4"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@types/mime-types": "^3.0.1",