Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update Azle templates to 0.25.0 #4040

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions src/dfx/assets/project_templates/any_js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"compilerOptions": {
"strict": true,
"target": "ES2020",
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"module": "ES2020",
"moduleResolution": "node",
"allowJs": true,
"outDir": "HACK_BECAUSE_OF_ALLOW_JS"
Expand Down
17 changes: 2 additions & 15 deletions src/dfx/assets/project_templates/azle/dfx.json-patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,8 @@
"path": "/canisters/__backend_name__",
"op": "add",
"value": {
"type": "custom",
"main": "src/__backend_name__/src/index.ts",
"candid": "src/__backend_name__/__backend_name__.did",
"build": "npx azle __backend_name__",
"wasm": ".azle/__backend_name__/__backend_name__.wasm",
"gzip": true,
"tech_stack": {
"language": {
"javascript": {},
"typescript": {}
},
"cdk": {
"azle": {}
}
}
"type": "azle",
"main": "src/__backend_name__/src/index.ts"
}
}
]

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"private": true,
"type": "module",
"dependencies": {
"azle": "^0.19.0"
"azle": "^0.25.0"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { Canister, query, text } from 'azle';
import { IDL, query, update } from 'azle';

export default Canister({
greet: query([text], text, (name) => {
return `Hello, ${name}!`;
})
})
export default class {
message: string = 'Hello world!';

@query([], IDL.Text)
getMessage(): string {
return this.message;
}

@update([IDL.Text])
setMessage(message: string): void {
this.message = message;
}
}
30 changes: 15 additions & 15 deletions src/dfx/src/lib/project/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ pub fn builtin_templates() -> Vec<ProjectTemplate> {
get_archive_fn: assets::new_project_svelte_files,
},
category: ProjectTemplateCategory::Frontend,
post_create: vec![NPM_INSTALL.to_string()],
post_create_failure_warning: Some(NPM_INSTALL_FAILURE_WARNING.to_string()),
post_create_spinner_message: Some(NPM_INSTALL_SPINNER_MESSAGE.to_string()),
post_create: vec![],
post_create_failure_warning: None,
post_create_spinner_message: None,
requirements: vec![ProjectTemplateName("dfx_js_base".to_string())],
sort_order: 0,
};
Expand All @@ -86,9 +86,9 @@ pub fn builtin_templates() -> Vec<ProjectTemplate> {
get_archive_fn: assets::new_project_react_files,
},
category: ProjectTemplateCategory::Frontend,
post_create: vec![NPM_INSTALL.to_string()],
post_create_failure_warning: Some(NPM_INSTALL_FAILURE_WARNING.to_string()),
post_create_spinner_message: Some(NPM_INSTALL_SPINNER_MESSAGE.to_string()),
post_create: vec![],
post_create_failure_warning: None,
post_create_spinner_message: None,
requirements: vec![ProjectTemplateName("dfx_js_base".to_string())],
sort_order: 1,
};
Expand All @@ -100,9 +100,9 @@ pub fn builtin_templates() -> Vec<ProjectTemplate> {
get_archive_fn: assets::new_project_vue_files,
},
category: ProjectTemplateCategory::Frontend,
post_create: vec![NPM_INSTALL.to_string()],
post_create_failure_warning: Some(NPM_INSTALL_FAILURE_WARNING.to_string()),
post_create_spinner_message: Some(NPM_INSTALL_SPINNER_MESSAGE.to_string()),
post_create: vec![],
post_create_failure_warning: None,
post_create_spinner_message: None,
requirements: vec![ProjectTemplateName("dfx_js_base".to_string())],
sort_order: 2,
};
Expand All @@ -114,9 +114,9 @@ pub fn builtin_templates() -> Vec<ProjectTemplate> {
get_archive_fn: assets::new_project_vanillajs_files,
},
category: ProjectTemplateCategory::Frontend,
post_create: vec![NPM_INSTALL.to_string()],
post_create_failure_warning: Some(NPM_INSTALL_FAILURE_WARNING.to_string()),
post_create_spinner_message: Some(NPM_INSTALL_SPINNER_MESSAGE.to_string()),
post_create: vec![],
post_create_failure_warning: None,
post_create_spinner_message: None,
requirements: vec![ProjectTemplateName("dfx_js_base".to_string())],
sort_order: 3,
};
Expand Down Expand Up @@ -226,9 +226,9 @@ pub fn builtin_templates() -> Vec<ProjectTemplate> {
get_archive_fn: assets::new_project_js_files,
},
category: ProjectTemplateCategory::Support,
post_create: vec![],
post_create_failure_warning: None,
post_create_spinner_message: None,
post_create: vec![NPM_INSTALL.to_string()],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should remove the post create fields from the templates that require dfx_js_base, and add them here.

Copy link
Author

@lastmjs lastmjs Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I have done this correctly now

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

post_create_failure_warning: Some(NPM_INSTALL_FAILURE_WARNING.to_string()),
post_create_spinner_message: Some(NPM_INSTALL_SPINNER_MESSAGE.to_string()),
requirements: vec![],
sort_order: 2,
};
Expand Down
Loading