Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/help/hosting.deploy.help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Options:
${yellow('--no-apply')} Submit the deployment as a change but do not apply it yet.
${OPTION_KEEP_STAGED}
${yellow('-i, --immediate')} Deploy files instantly (bypasses the change workflow).
${yellow('--prune')} Prune stale app files after successful deployment.
${OPTIONS_ENV}
${OPTION_HELP}

Expand Down
20 changes: 16 additions & 4 deletions src/services/assets/deploy.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@ import {getSatelliteVersion} from '../version.services';
import {parseBatchSize} from './_args.services';
import {deployImmediate} from './_deploy/deploy.individual.services';
import {deployWithProposal as executeDeployWithProposal} from './_deploy/deploy.with-proposal.services';
import {executePrune} from './prune.services';

export const deploy = async (args?: string[]) => {
if (await noJunoConfig()) {
await init();
}

await executeDeploy(args);
const {value: uploadBatchSize} = parseBatchSize(args);

await executeDeploy({args, batchSize: uploadBatchSize});

const pruneOption = hasArgs({args, options: ['--prune']});
if (pruneOption) {
await executePrune({batchSize: uploadBatchSize});
}

const configOption = hasArgs({args, options: ['--config']});
if (configOption) {
Expand All @@ -28,7 +36,13 @@ export const deploy = async (args?: string[]) => {
await links();
};

const executeDeploy = async (args?: string[]) => {
const executeDeploy = async ({
args,
batchSize: uploadBatchSize
}: {
args?: string[];
batchSize?: number;
}) => {
// TODO: Remove fetching the version. We use it for backwards compatibility reasons.
const result = await getSatelliteVersion();

Expand All @@ -42,8 +56,6 @@ const executeDeploy = async (args?: string[]) => {
// wouldn't harm usage, it might prevent crawlers from properly fetching content.
const deprecatedGzip = compare(result.version, '0.1.1') < 0 ? '**/*.+(css|js|mjs)' : undefined;

const {value: uploadBatchSize} = parseBatchSize(args);

const clearOption = hasArgs({args, options: ['--clear']});
const immediate = hasArgs({args, options: ['-i', '--immediate']});

Expand Down
12 changes: 5 additions & 7 deletions src/services/assets/prune.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ export const prune = async (args?: string[]) => {
return;
}

await executePrune(args);
};

const executePrune = async (args?: string[]) => {
const dryRun = hasArgs({args, options: ['--dry-run']});

const {value: pruneBatchSize} = parseBatchSize(args);

await executePrune({dryRun, batchSize: pruneBatchSize});
};

export const executePrune = async (params: {dryRun?: boolean; batchSize?: number}) => {
const {satellite, satelliteConfig} = await assertConfigAndLoadSatelliteContext();

const listExistingAssets = async ({startAfter}: {startAfter?: string}): Promise<Asset[]> =>
Expand All @@ -46,8 +45,7 @@ const executePrune = async (args?: string[]) => {
config: satelliteConfig,
listAssets: listExistingAssets,
assertSourceDirExists,
dryRun,
batchSize: pruneBatchSize
...params
},
pruneFn
});
Expand Down
Loading