Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into paulliu/generate-re…
Browse files Browse the repository at this point in the history
…mote-canister-declarations
  • Loading branch information
ninegua committed Aug 30, 2023
2 parents 6d1d4a8 + f227ac0 commit 88f8569
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

Generate frontend declarations for remote canisters too because frontend JS code may want to call them.

### fix: dfx deploy urls printed for asset canisters

### chore: --emulator parameter is deprecated and will be discontinued soon

Added warning that the `--emulator` is deprecated and will be discontinued soon.
Expand Down
25 changes: 25 additions & 0 deletions e2e/tests-dfx/deploy.bash
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,28 @@ teardown() {
ONCHAIN_HASH="$(dfx canister info hello_backend | tail -n 1 | cut -d " " -f 3)"
assert_eq "$BUILD_HASH" "$ONCHAIN_HASH"
}

@test "prints the frontend url after deploy" {
dfx_new_frontend hello
dfx_start
assert_command dfx deploy
assert_contains "hello_frontend: http://127.0.0.1"
}

@test "prints the frontend url if 'frontend' section is not present in dfx.json" {
dfx_new_frontend hello
jq 'del(.canisters.hello_frontend.frontend)' dfx.json | sponge dfx.json
dfx_start
assert_command dfx deploy
assert_contains "hello_frontend: http://127.0.0.1"
}

@test "prints the frontend url if the frontend section has been removed after initial deployment" {
dfx_new_frontend hello
dfx_start
assert_command dfx deploy
assert_contains "hello_frontend: http://127.0.0.1"
jq 'del(.canisters.hello_frontend.frontend)' dfx.json | sponge dfx.json
assert_command dfx deploy
assert_contains "hello_frontend: http://127.0.0.1"
}
9 changes: 3 additions & 6 deletions src/dfx-core/src/extension/manager/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl ExtensionManager {

let extension_version = self.get_extension_compatible_version(extension_name)?;
let github_release_tag = get_git_release_tag(extension_name, &extension_version);
let extension_archive = get_extension_archive_name(extension_name, &extension_version)?;
let extension_archive = get_extension_archive_name(extension_name)?;
let url = get_extension_download_url(&github_release_tag, &extension_archive)?;

let temp_dir = self.download_and_unpack_extension_to_tempdir(url)?;
Expand Down Expand Up @@ -132,12 +132,9 @@ fn get_git_release_tag(extension_name: &str, extension_verion: &Version) -> Stri
format!("{extension_name}-v{extension_verion}",)
}

fn get_extension_archive_name(
extension_name: &str,
extension_version: &Version,
) -> Result<String, ExtensionError> {
fn get_extension_archive_name(extension_name: &str) -> Result<String, ExtensionError> {
Ok(format!(
"{extension_name}-v{extension_version}-{arch}-{platform}",
"{extension_name}-{arch}-{platform}",
platform = match std::env::consts::OS {
"linux" => "unknown-linux-gnu",
"macos" => "apple-darwin",
Expand Down
5 changes: 4 additions & 1 deletion src/dfx/src/commands/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ fn display_urls(env: &dyn Environment) -> DfxResult {
if let Some(canister_id) = canister_id {
let canister_info = CanisterInfo::load(&config, canister_name, Some(canister_id))?;

if canister_config.frontend.is_some() {
// If the canister is an assets canister or has a frontend section, we can display a frontend url.
let is_assets = canister_info.is_assets() || canister_config.frontend.is_some();

if is_assets {
let url = construct_frontend_url(network, &canister_id)?;
frontend_urls.insert(canister_name, url);
}
Expand Down

0 comments on commit 88f8569

Please sign in to comment.