Skip to content

Commit

Permalink
feat: remove option --nocheck (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker authored Nov 29, 2024
1 parent 105f14d commit cc66370
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 24 deletions.
1 change: 0 additions & 1 deletion src/help/upgrade.help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Options:
${yellow('-t, --target')} Which module type should be upgraded? Valid targets are ${magenta('satellite')}, ${magenta('mission-control')} or ${magenta('orbiter')}.
${yellow('-s, --src')} An optional local gzipped WASM file for the upgrade. By default, the CDN will be used.
${yellow('-r, --reset')} Reset to the initial state.
${yellow('-n, --nocheck')} Skip assertions and execute upgrade without prompts.
${yellow('-c, --clear-chunks')} Clear any previously uploaded WASM chunks (applies if the WASM size is greater than 2MB).
${helpMode}
${yellow('-h, --help')} Output usage information.
Expand Down
4 changes: 0 additions & 4 deletions src/services/upgrade/upgrade.mission-control.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ const updateMissionControlRelease = async ({
return {success: false};
}

const nocheck = hasArgs({args, options: ['-n', '--nocheck']});
const preClearChunks = hasArgs({args, options: ['-c', '--clear-chunks']});

const upgradeMissionControlWasm = async (params: UpgradeWasmModule) => {
Expand All @@ -90,7 +89,6 @@ const updateMissionControlRelease = async ({

return await upgradeWasmCdn({
version,
nocheck,
assetKey: 'mission_control',
upgrade: upgradeMissionControlWasm
});
Expand All @@ -110,7 +108,6 @@ const upgradeMissionControlCustom = async ({
return {success: false};
}

const nocheck = hasArgs({args, options: ['-n', '--nocheck']});
const preClearChunks = hasArgs({args, options: ['-c', '--clear-chunks']});

const upgradeMissionControlWasm = async (params: UpgradeWasmModule) => {
Expand All @@ -123,7 +120,6 @@ const upgradeMissionControlCustom = async ({

return await upgradeWasmLocal({
src,
nocheck,
assetKey: 'mission_control',
upgrade: upgradeMissionControlWasm
});
Expand Down
6 changes: 1 addition & 5 deletions src/services/upgrade/upgrade.orbiter.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ const upgradeOrbiterCustom = async ({

const reset = await confirmReset({args, assetKey: 'orbiter'});

const nocheck = hasArgs({args, options: ['-n', '--nocheck']});
const preClearChunks = hasArgs({args, options: ['-c', '--clear-chunks']});

const upgradeOrbiterWasm = async (params: UpgradeWasmModule) => {
Expand All @@ -85,7 +84,6 @@ const upgradeOrbiterCustom = async ({

return await upgradeWasmLocal({
src,
nocheck,
assetKey: 'orbiter',
upgrade: upgradeOrbiterWasm,
reset
Expand Down Expand Up @@ -117,7 +115,6 @@ const updateOrbiterRelease = async ({

const reset = await confirmReset({args, assetKey: 'orbiter'});

const nocheck = hasArgs({args, options: ['-n', '--nocheck']});
const preClearChunks = hasArgs({args, options: ['-c', '--clear-chunks']});

const upgradeOrbiterWasm = async (params: UpgradeWasmModule) => {
Expand All @@ -133,7 +130,6 @@ const updateOrbiterRelease = async ({
version,
assetKey: 'orbiter',
upgrade: upgradeOrbiterWasm,
reset,
nocheck
reset
});
};
6 changes: 2 additions & 4 deletions src/services/upgrade/upgrade.satellite.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,12 @@ const upgradeSatelliteCustom = async ({
satellite
});

const nocheck = hasArgs({args, options: ['-n', '--nocheck']});
const preClearChunks = hasArgs({args, options: ['-c', '--clear-chunks']});

const upgrade = async (
params: Pick<UpgradeWasm, 'upgrade' | 'reset' | 'assert'>
): Promise<{success: boolean; err?: unknown}> => {
return await upgradeWasmLocal({src, assetKey: 'satellite', nocheck, ...params});
return await upgradeWasmLocal({src, assetKey: 'satellite', ...params});
};

return await executeUpgradeSatellite({
Expand Down Expand Up @@ -112,13 +111,12 @@ const upgradeSatelliteRelease = async ({
return {success: false};
}

const nocheck = hasArgs({args, options: ['-n', '--nocheck']});
const preClearChunks = hasArgs({args, options: ['-c', '--clear-chunks']});

const upgrade = async (
params: Pick<UpgradeWasm, 'upgrade' | 'reset' | 'assert'>
): Promise<{success: boolean; err?: unknown}> => {
return await upgradeWasmCdn({version, assetKey: 'satellite', nocheck, ...params});
return await upgradeWasmCdn({version, assetKey: 'satellite', ...params});
};

return await executeUpgradeSatellite({
Expand Down
16 changes: 7 additions & 9 deletions src/services/upgrade/upgrade.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {JUNO_CDN_URL} from '../../constants/constants';
import type {AssetKey} from '../../types/asset-key';
import type {UpgradeWasm} from '../../types/upgrade';
import {toAssetKeys} from '../../utils/asset-key.utils';
import {isNotHeadless} from '../../utils/process.utils';
import {confirmAndExit} from '../../utils/prompt.utils';
import {newerReleases as newerReleasesUtils} from '../../utils/upgrade.utils';
import {assertUpgradeHash} from './upgrade-assert.services';
Expand All @@ -28,10 +29,9 @@ const executeUpgradeWasm = async ({
hash,
assert,
reset = false,
nocheck,
assetKey
}: {assetKey: AssetKey} & UpgradeWasm) => {
if (!nocheck) {
if (isNotHeadless()) {
await assert?.({wasmModule: wasm});
await assertUpgradeHash({hash, reset});
}
Expand Down Expand Up @@ -70,12 +70,11 @@ export const upgradeWasmLocal = async ({
upgrade,
reset,
assert,
nocheck,
assetKey
}: {
src: string;
assetKey: AssetKey;
} & Pick<UpgradeWasm, 'reset' | 'upgrade' | 'assert' | 'nocheck'>): Promise<{
} & Pick<UpgradeWasm, 'reset' | 'upgrade' | 'assert'>): Promise<{
success: boolean;
err?: unknown;
}> => {
Expand All @@ -95,7 +94,7 @@ export const upgradeWasmLocal = async ({

spinner.stop();

await executeUpgradeWasm({upgrade, wasm, hash, reset, assert, nocheck, assetKey});
await executeUpgradeWasm({upgrade, wasm, hash, reset, assert, assetKey});

return {success: true};
} catch (err: unknown) {
Expand All @@ -110,12 +109,11 @@ export const upgradeWasmCdn = async ({
assetKey,
upgrade,
assert,
reset,
nocheck
reset
}: {
version: string;
assetKey: AssetKey;
} & Pick<UpgradeWasm, 'reset' | 'upgrade' | 'assert' | 'nocheck'>): Promise<{
} & Pick<UpgradeWasm, 'reset' | 'upgrade' | 'assert'>): Promise<{
success: boolean;
err?: unknown;
}> => {
Expand Down Expand Up @@ -143,7 +141,7 @@ export const upgradeWasmCdn = async ({

spinner.stop();

await executeUpgradeWasm({upgrade, wasm, hash, reset, assert, nocheck, assetKey});
await executeUpgradeWasm({upgrade, wasm, hash, reset, assert, assetKey});

return {success: true};
} catch (err: unknown) {
Expand Down
1 change: 0 additions & 1 deletion src/types/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ export interface UpgradeWasm {
upgrade: (params: UpgradeWasmModule) => Promise<void>;
assert?: (params: AssertWasmModule) => Promise<void>;
reset?: boolean;
nocheck: boolean;
}
2 changes: 2 additions & 0 deletions src/utils/process.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ export const isHeadless = (): boolean => {
const [_, ...args] = process.argv.slice(2);
return hasArgs({args, options: ['--headless']});
};

export const isNotHeadless = (): boolean => !isHeadless();

0 comments on commit cc66370

Please sign in to comment.