From e75bb239e647ea1729e51d73dd2ae70ac75a04bf Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Fri, 30 May 2025 09:11:58 +0200 Subject: [PATCH 1/3] feat: deploy with proposals --- src/commands/deploy.ts | 43 +++++++++++++++++-- src/help/deploy.help.ts | 2 + .../deploy/deploy.execute.services.ts | 18 ++++---- 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/src/commands/deploy.ts b/src/commands/deploy.ts index d59be8af..9d1282ff 100644 --- a/src/commands/deploy.ts +++ b/src/commands/deploy.ts @@ -1,4 +1,4 @@ -import {hasArgs} from '@junobuild/cli-tools'; +import {deploy as cliDeploy, deployWithProposal as cliDeployWithProposal, type DeployParams, type DeployResult, hasArgs} from '@junobuild/cli-tools'; import {junoConfigExist} from '../configs/juno.config'; import {clear} from '../services/clear.services'; import {executeDeploy} from '../services/deploy/deploy.execute.services'; @@ -10,11 +10,48 @@ export const deploy = async (args?: string[]) => { await init(); } - if (hasArgs({args, options: ['-c', '--clear']})) { + const clearOption = hasArgs({args, options: ['-c', '--clear']}); + const immediate = hasArgs({args, options: ['-i', '--immediate']}); + + if (immediate) { + await deployImmediate({args, clearOption}); + return; + } + + await deployWithProposal({args, clearOption}); +}; + +const deployWithProposal = async ({args, clearOption}: {args?: string[]; clearOption: boolean}) => { + const noCommit = hasArgs({args, options: ['-n', '--no-commit']}); + + const cliDeploy = (params: DeployParams): Promise => { + await cliDeployWithProposal({ + deploy: params, + proposal: { + clearAssets: clearOption, + autoCommit: !noCommit, + cdn + } + }) + } + + await executeDeploy({ + args, + deployFn: cliDeploy + }); + + await links(args); +}; + +const deployImmediate = async ({args, clearOption}: {args?: string[]; clearOption: boolean}) => { + if (clearOption) { await clear(args); } - await executeDeploy(args); + await executeDeploy({ + args, + deployFn: cliDeploy + }); await links(args); }; diff --git a/src/help/deploy.help.ts b/src/help/deploy.help.ts index 1be071d3..c66ef431 100644 --- a/src/help/deploy.help.ts +++ b/src/help/deploy.help.ts @@ -7,6 +7,8 @@ const usage = `Usage: ${green('juno')} ${cyan('deploy')} ${yellow('[options]')} Options: ${yellow('-c, --clear')} Clear existing app files before proceeding with deployment. + ${yellow('-n, --no-commit')} Submit the deployment as a change but do not apply it yet. + ${yellow('-i, --immediate')} Deploy files instantly (bypasses the change workflow). ${helpMode} ${yellow('-h, --help')} Output usage information.`; diff --git a/src/services/deploy/deploy.execute.services.ts b/src/services/deploy/deploy.execute.services.ts index 1e29b67b..51f65b80 100644 --- a/src/services/deploy/deploy.execute.services.ts +++ b/src/services/deploy/deploy.execute.services.ts @@ -1,9 +1,5 @@ -import type {UploadFileStorage} from '@junobuild/cli-tools'; -import { - deploy as cliDeploy, - postDeploy as cliPostDeploy, - preDeploy as cliPreDeploy -} from '@junobuild/cli-tools'; +import type {DeployParams, DeployResult, UploadFileStorage} from '@junobuild/cli-tools'; +import {postDeploy as cliPostDeploy, preDeploy as cliPreDeploy} from '@junobuild/cli-tools'; import {type Asset, uploadBlob} from '@junobuild/core'; import {red} from 'kleur'; import {lstatSync} from 'node:fs'; @@ -13,7 +9,13 @@ import {satelliteParameters} from '../../utils/satellite.utils'; import {assertSatelliteMemorySize} from './deploy.assert.services'; import {listAssets} from './deploy.assets.services'; -export const executeDeploy = async (args?: string[]) => { +export const executeDeploy = async ({ + args, + deployFn +}: { + args?: string[]; + deployFn: (params: DeployParams) => Promise; +}) => { const env = configEnv(args); const {satellite: satelliteConfig} = await readJunoConfig(env); @@ -54,7 +56,7 @@ export const executeDeploy = async (args?: string[]) => { await cliPreDeploy({config: satelliteConfig}); - const {result} = await cliDeploy({ + const {result} = await deployFn({ config: satelliteConfig, listAssets: listExistingAssets, assertSourceDirExists, From 267a64adcc1735b56c04ad63b37256076f2e4af9 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Fri, 30 May 2025 09:24:43 +0200 Subject: [PATCH 2/3] feat: deploy with proposals and cdn --- src/commands/deploy.ts | 34 ++++++++++++------- .../deploy/deploy.execute.services.ts | 21 ++++++++---- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/commands/deploy.ts b/src/commands/deploy.ts index 9d1282ff..282f83f9 100644 --- a/src/commands/deploy.ts +++ b/src/commands/deploy.ts @@ -1,7 +1,12 @@ -import {deploy as cliDeploy, deployWithProposal as cliDeployWithProposal, type DeployParams, type DeployResult, hasArgs} from '@junobuild/cli-tools'; +import { + deploy as cliDeploy, + deployWithProposal as cliDeployWithProposal, + type DeployResult, + hasArgs +} from '@junobuild/cli-tools'; import {junoConfigExist} from '../configs/juno.config'; import {clear} from '../services/clear.services'; -import {executeDeploy} from '../services/deploy/deploy.execute.services'; +import {type DeployFnParams, executeDeploy} from '../services/deploy/deploy.execute.services'; import {links} from '../services/links.services'; import {init} from './init'; @@ -24,20 +29,21 @@ export const deploy = async (args?: string[]) => { const deployWithProposal = async ({args, clearOption}: {args?: string[]; clearOption: boolean}) => { const noCommit = hasArgs({args, options: ['-n', '--no-commit']}); - const cliDeploy = (params: DeployParams): Promise => { - await cliDeployWithProposal({ - deploy: params, - proposal: { - clearAssets: clearOption, - autoCommit: !noCommit, - cdn + const deployFn = async ({deploy, satellite}: DeployFnParams): Promise => + await cliDeployWithProposal({ + deploy, + proposal: { + clearAssets: clearOption, + autoCommit: !noCommit, + cdn: { + satellite } - }) - } + } + }); await executeDeploy({ args, - deployFn: cliDeploy + deployFn }); await links(args); @@ -48,9 +54,11 @@ const deployImmediate = async ({args, clearOption}: {args?: string[]; clearOptio await clear(args); } + const deployFn = async ({deploy}: DeployFnParams): Promise => await cliDeploy(deploy); + await executeDeploy({ args, - deployFn: cliDeploy + deployFn }); await links(args); diff --git a/src/services/deploy/deploy.execute.services.ts b/src/services/deploy/deploy.execute.services.ts index 51f65b80..5bad6ef9 100644 --- a/src/services/deploy/deploy.execute.services.ts +++ b/src/services/deploy/deploy.execute.services.ts @@ -4,17 +4,23 @@ import {type Asset, uploadBlob} from '@junobuild/core'; import {red} from 'kleur'; import {lstatSync} from 'node:fs'; import {readJunoConfig} from '../../configs/juno.config'; +import {type SatelliteParametersWithId} from '../../types/satellite'; import {configEnv} from '../../utils/config.utils'; import {satelliteParameters} from '../../utils/satellite.utils'; import {assertSatelliteMemorySize} from './deploy.assert.services'; import {listAssets} from './deploy.assets.services'; +export interface DeployFnParams { + deploy: DeployParams; + satellite: SatelliteParametersWithId; +} + export const executeDeploy = async ({ args, deployFn }: { args?: string[]; - deployFn: (params: DeployParams) => Promise; + deployFn: (params: DeployFnParams) => Promise; }) => { const env = configEnv(args); const {satellite: satelliteConfig} = await readJunoConfig(env); @@ -57,11 +63,14 @@ export const executeDeploy = async ({ await cliPreDeploy({config: satelliteConfig}); const {result} = await deployFn({ - config: satelliteConfig, - listAssets: listExistingAssets, - assertSourceDirExists, - assertMemory, - uploadFile + deploy: { + config: satelliteConfig, + listAssets: listExistingAssets, + assertSourceDirExists, + assertMemory, + uploadFile + }, + satellite }); if (result === 'skipped') { From 20418672b4e969c2699a8873fdcd8d11e7310f8f Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Fri, 30 May 2025 09:25:45 +0200 Subject: [PATCH 3/3] chore: fmt --- src/commands/deploy.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commands/deploy.ts b/src/commands/deploy.ts index 282f83f9..ac9728ae 100644 --- a/src/commands/deploy.ts +++ b/src/commands/deploy.ts @@ -54,7 +54,8 @@ const deployImmediate = async ({args, clearOption}: {args?: string[]; clearOptio await clear(args); } - const deployFn = async ({deploy}: DeployFnParams): Promise => await cliDeploy(deploy); + const deployFn = async ({deploy}: DeployFnParams): Promise => + await cliDeploy(deploy); await executeDeploy({ args,