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
70 changes: 35 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
"@dfinity/ic-management": "^6.1.1",
"@dfinity/identity": "^2.3.0",
"@dfinity/principal": "^2.3.0",
"@junobuild/admin": "^0.5.0-next-2025-06-01",
"@junobuild/cdn": "^0.1.0-next-2025-06-01",
"@junobuild/cli-tools": "^0.2.0-next-2025-06-01",
"@junobuild/admin": "^0.5.0-next-2025-06-02.1",
"@junobuild/cdn": "^0.1.0-next-2025-06-02.1",
"@junobuild/cli-tools": "^0.2.0-next-2025-06-02.1",
"@junobuild/config": "^0.1.8",
"@junobuild/config-loader": "^0.2.1",
"@junobuild/core": "^0.1.15-next-2025-06-01",
"@junobuild/core": "^0.1.15-next-2025-06-02.1",
"@junobuild/did-tools": "^0.2.1",
"@junobuild/storage": "^0.2.0-next-2025-06-01",
"@junobuild/storage": "^0.2.0-next-2025-06-02.1",
"@junobuild/utils": "^0.1.3",
"chokidar": "^4.0.3",
"conf": "^13.1.0",
Expand Down
8 changes: 8 additions & 0 deletions src/commands/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import {red} from 'kleur';
import {logHelpFunctionsBuild} from '../help/functions.build.help';
import {logHelpFunctionsEject} from '../help/functions.eject.help';
import {logHelpFunctions} from '../help/functions.help';
import {logHelpFunctionsUpgrade} from '../help/functions.upgrade.help';
import {build} from '../services/functions/build/build.services';
import {eject} from '../services/functions/eject/eject.services';
import {upgradeFunctions} from '../services/functions/upgrade/upgrade.services';

export const functions = async (args?: string[]) => {
const [subCommand] = args ?? [];
Expand All @@ -15,6 +17,9 @@ export const functions = async (args?: string[]) => {
case 'build':
await build(args);
break;
case 'upgrade':
await upgradeFunctions(args);
break;
default:
console.log(red('Unknown subcommand.'));
logHelpFunctions(args);
Expand All @@ -31,6 +36,9 @@ export const helpFunctions = (args?: string[]) => {
case 'eject':
logHelpFunctionsEject(args);
break;
case 'upgrade':
logHelpFunctionsUpgrade(args);
break;
default:
logHelpFunctions(args);
}
Expand Down
2 changes: 2 additions & 0 deletions src/constants/dev.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ export const PACKAGE_JSON_PATH = join(process.cwd(), 'package.json');

export const SPUTNIK_INDEX_MJS = 'sputnik.index.mjs';
export const DEPLOY_SPUTNIK_PATH = join(DEPLOY_LOCAL_REPLICA_PATH, SPUTNIK_INDEX_MJS);

export const SATELLITE_OUTPUT = join(DEPLOY_LOCAL_REPLICA_PATH, 'satellite.wasm');
1 change: 1 addition & 0 deletions src/constants/functions.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const CDN_RELEASES_FULL_PATH = '/_juno/releases';
7 changes: 7 additions & 0 deletions src/constants/help.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const WHOAMI_DESCRIPTION =

export const DEV_START_DESCRIPTION = 'Start a local Internet Computer network in a container.';

export const FUNCTIONS_UPGRADE_DESCRIPTION = 'Upgrade your serverless functions.';
export const FUNCTIONS_BUILD_DESCRIPTION = 'Build your serverless functions.';
export const FUNCTIONS_EJECT_DESCRIPTION =
'Generate the required files to begin developing serverless functions in your project.';
Expand All @@ -41,3 +42,9 @@ export const CHANGES_REJECT_DESCRIPTION = 'Reject a change.';
export const OPTION_KEEP_STAGED = `${yellow('-k, --keep-staged')} Keep staged assets in memory after applying the change.`;
export const OPTION_HASH = `${yellow('-s, --hash')} The expected hash of all included changes (for verification).`;
export const OPTION_HELP = `${yellow('-h, --help')} Output usage information.`;

export const OPTIONS_UPGRADE = `${yellow('-r, --reset')} Reset to the initial state.
${yellow('-cc, --clear-chunks')} Clear any previously uploaded WASM chunks (applies if the WASM size is greater than 2MB).
${yellow('-ns, --no-snapshot')} Skip creating a snapshot before upgrading.`;

export const NOTE_KEEP_STAGED = `The option ${yellow('--keep-staged')} only applies when ${yellow('--no-apply')} is NOT used (i.e. the change is applied immediately).`;
9 changes: 7 additions & 2 deletions src/help/deploy.help.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import {cyan, green, yellow} from 'kleur';
import {DEPLOY_DESCRIPTION, OPTION_HELP, OPTION_KEEP_STAGED} from '../constants/help.constants';
import {
DEPLOY_DESCRIPTION,
NOTE_KEEP_STAGED,
OPTION_HELP,
OPTION_KEEP_STAGED
} from '../constants/help.constants';
import {helpMode, helpOutput} from './common.help';
import {TITLE} from './help';

Expand All @@ -15,7 +20,7 @@ Options:

Notes:

- The option ${yellow('--keep-staged')} only applies when ${yellow('--no-apply')} is NOT used (i.e. the change is applied immediately).`;
- ${NOTE_KEEP_STAGED}`;

const doc = `${DEPLOY_DESCRIPTION}

Expand Down
1 change: 1 addition & 0 deletions src/help/functions.help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const usage = `Usage: ${green('juno')} ${cyan('functions')} ${magenta('<subcomma
Subcommands:
${magenta('build')} Build your functions.
${magenta('eject')} Scaffold the necessary files for developing your serverless functions.
${magenta('upgrade')} Upgrade your satellite's serverless functions.

Notes:

Expand Down
44 changes: 44 additions & 0 deletions src/help/functions.upgrade.help.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {cyan, green, magenta, yellow} from 'kleur';
import {
FUNCTIONS_UPGRADE_DESCRIPTION,
NOTE_KEEP_STAGED,
OPTION_HELP,
OPTION_KEEP_STAGED,
OPTIONS_UPGRADE
} from '../constants/help.constants';
import {helpOutput} from './common.help';
import {TITLE} from './help';

const usage = `Usage: ${green('juno')} ${cyan('functions')} ${magenta('upgrade')} ${yellow('[options]')}

Options:
${yellow('-na, --no-apply')} Submit the upgrade as a change but do not apply it yet.
${OPTION_KEEP_STAGED}
${yellow('-i, --immediate')} Push the upgrade immediately (bypasses the change workflow).
${OPTION_HELP}

Upgrade options:
${yellow('-s, --src')} An optional local gzipped WASM file for the upgrade.
${OPTIONS_UPGRADE}

Notes:

- ${NOTE_KEEP_STAGED}`;

const doc = `${FUNCTIONS_UPGRADE_DESCRIPTION}

\`\`\`
${usage}
\`\`\`
`;

const help = `${TITLE}

${FUNCTIONS_UPGRADE_DESCRIPTION}

${usage}
`;

export const logHelpFunctionsUpgrade = (args?: string[]) => {
console.log(helpOutput(args) === 'doc' ? doc : help);
};
6 changes: 2 additions & 4 deletions src/help/upgrade.help.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {cyan, green, yellow} from 'kleur';
import {OPTION_HELP, UPGRADE_DESCRIPTION} from '../constants/help.constants';
import {OPTION_HELP, OPTIONS_UPGRADE, UPGRADE_DESCRIPTION} from '../constants/help.constants';
import {helpMode, helpOutput} from './common.help';
import {TITLE} from './help';
import {TARGET_OPTION_NOTE, targetOption} from './target.help';
Expand All @@ -9,9 +9,7 @@ const usage = `Usage: ${green('juno')} ${cyan('upgrade')} ${yellow('[options]')}
Options:
${targetOption('upgrade')}
${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('-cc, --clear-chunks')} Clear any previously uploaded WASM chunks (applies if the WASM size is greater than 2MB).
${yellow('-ns, --no-snapshot')} Skip creating a snapshot before upgrading.
${OPTIONS_UPGRADE}
${helpMode}
${OPTION_HELP}

Expand Down
2 changes: 1 addition & 1 deletion src/services/functions/build/build.rust.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
DEVELOPER_PROJECT_SATELLITE_PATH,
IC_WASM_MIN_VERSION,
JUNO_PACKAGE_JSON_PATH,
SATELLITE_OUTPUT,
TARGET_PATH
} from '../../../constants/dev.constants';
import type {BuildArgs} from '../../../types/build';
Expand All @@ -29,7 +30,6 @@ import {readPackageJson} from '../../../utils/pkg.utils';
import {confirmAndExit} from '../../../utils/prompt.utils';

const CARGO_RELEASE_DIR = join(process.cwd(), 'target', 'wasm32-unknown-unknown', 'release');
const SATELLITE_OUTPUT = join(DEPLOY_LOCAL_REPLICA_PATH, 'satellite.wasm');
const SATELLITE_PROJECT_NAME = 'satellite';

export const buildRust = async ({path}: Pick<BuildArgs, 'path'> = {}) => {
Expand Down
34 changes: 34 additions & 0 deletions src/services/functions/upgrade/upgrade.services.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {hasArgs, nextArg} from '@junobuild/cli-tools';
import {SATELLITE_OUTPUT} from '../../../constants/dev.constants';
import {type UpgradeFunctionsParams} from '../../../types/functions';
import {assertConfigAndLoadSatelliteContext} from '../../../utils/satellite.utils';
import {upgradeSatelliteWithSrc} from '../../modules/upgrade/upgrade.satellite.services';
import {upgradeFunctionsWithProposal} from './upgrade.with-proposal.services';

export const upgradeFunctions = async (args?: string[]) => {
const {satellite} = await assertConfigAndLoadSatelliteContext(args);

const srcArgs = nextArg({args, option: '-s'}) ?? nextArg({args, option: '--src'});
const src = srcArgs ?? `${SATELLITE_OUTPUT}.gz`;

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

if (immediate) {
await upgradeImmediate({
args,
src,
satellite
});
return;
}

await upgradeFunctionsWithProposal({
args,
src,
satellite
});
};

const upgradeImmediate = async (params: UpgradeFunctionsParams) => {
await upgradeSatelliteWithSrc(params);
};
Loading