Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
9 changes: 4 additions & 5 deletions src/dfx/assets/project_templates/any_js/tsconfig.json
Copy link
Author

Choose a reason for hiding this comment

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

This is the tsconfig.json that we recommend for Azle projects, will this clash with your frontend code? I'm not sure what else this is used for.

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"compilerOptions": {
"strict": true,
"target": "ES2020",
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"moduleResolution": "node",
"target": "ES2024",
"module": "ES2022",
"moduleResolution": "bundler",
"allowJs": true,
"outDir": "HACK_BECAUSE_OF_ALLOW_JS"
"noEmit": true
}
}
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.29.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()],
Copy link
Contributor

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