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

feat: dfx new templates #3499

Merged
merged 32 commits into from
Feb 9, 2024
Merged

feat: dfx new templates #3499

merged 32 commits into from
Feb 9, 2024

Conversation

adamspofford-dfinity
Copy link
Contributor

Also closes #2771.

@adamspofford-dfinity adamspofford-dfinity marked this pull request as ready for review January 12, 2024 22:10
src/dfx-core/src/config/model/dfinity.rs Show resolved Hide resolved
Comment on lines 53 to 54
// redirect all requests from .raw.icp0.io to .icp0.io (this redirection is the default)
"allow_raw_access": false

Choose a reason for hiding this comment

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

dfx 0.14.4 changed this default to true, and made it so we no longer specify the default for this field in these new-project .ic-assets.json5 files. Is it intended to change that behavior here?

Copy link
Contributor Author

@adamspofford-dfinity adamspofford-dfinity Jan 16, 2024

Choose a reason for hiding this comment

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

The others came from @krpeacock's templates, and then the empty one I was just making consistent with those. If we changed it away from this default for a reason I won't gainsay it.

Choose a reason for hiding this comment

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

Yes. The new templates should use the new default (and not specify the default in .ic_assets.json5)

Copy link
Member

Choose a reason for hiding this comment

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

These changes to defaults are the only reason I still have changes requested on this PR

CHANGELOG.md Outdated Show resolved Hide resolved
@krpeacock
Copy link
Contributor

I think it's a problem that these templates won't run correctly with dfx up to the latest release version. I think we should add a "build" script to the root package.json that's compatible with dfx <0.15.3

@adamspofford-dfinity
Copy link
Contributor Author

Is it? I don't picture a user generating a project with a newer version of dfx, then switching to an older one.

@krpeacock
Copy link
Contributor

Is it? I don't picture a user generating a project with a newer version of dfx, then switching to an older one.

Someone might share their code, generated from a new version, and then someone could have trouble running it if the version isn't pinned or indicated. Probably an edge case though.

Still, having access to "test", "start", and "build" scripts is probably a nice thing to have, so that people don't have to cd or use the --workspaces flag for everything. (feedback from testing all the frontends manually)

@krpeacock

This comment was marked as resolved.

@letmejustputthishere
Copy link
Member

i know this is still WIP, but when attempting to create a new project, my frontend wasn't generated with the following output.

❯ sdk/target/debug/dfx new new_template
✔ Select a backend language: · Motoko
✔ Select a frontend framework: · Svelte
✔ Add extra features (space to select, enter to confirm) · Internet Identity, Frontend tests
Fetching manifest https://sdk.dfinity.org/manifest.json
  Version v0.16.0+rev30.f7b611f1 installed successfully.
Creating new project "new_template"...
CREATE       new_template/dfx.json (179B)...
CREATE       new_template/.gitignore (260B)...
CREATE       new_template/README.md (2.47KiB)...
CREATE       new_template/tsconfig.json (280B)...
CREATE       new_template/package.json (477B)...
CREATE       new_template/src/new_template_backend/main.mo (105B)...
WARN: Node could not be found. Skipping installing the frontend example code.
WARN: You can bypass this check by using the --frontend flag.
CREATE       new_template/src/new_template_frontend/assets/sample-asset.txt (24B)...
CREATE       new_template/src/new_template_frontend/assets/.ic-assets.json5 (5.37KiB)...
Creating git repository...

i can confirm that node indeed wasn't available in this shell, but if node is needed to install dfx we should add a prerequisites section here.

@letmejustputthishere
Copy link
Member

PS: i think this is amazing, it would be even cooler if templates with II would integrate with the frontend code as well.


#[derive(ValueEnum, Debug, Copy, Clone, PartialEq, Eq)]
enum FrontendType {
Svelte,

Choose a reason for hiding this comment

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

to be more accurate, can we use sveltekit instead of svelte here?

Copy link
Member

Choose a reason for hiding this comment

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

@krpeacock do you have an opinion on this?

Copy link
Member

@ericswanson-dfinity ericswanson-dfinity Feb 8, 2024

Choose a reason for hiding this comment

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

@adamspofford-dfinity In the absence of an opinion from anyone with a better handle on the ecosystem, I think we should change this to SvelteKit (and the cli option to --type sveltekit), since there is a distinction between the two.

@letmejustputthishere
Copy link
Member

support for e2e tests using pocket-ic would be amazing as well 🤩

@krpeacock krpeacock self-requested a review February 1, 2024 21:40
Copy link
Contributor

@krpeacock krpeacock left a comment

Choose a reason for hiding this comment

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

From my perspective, this is ready to go out (once all the checks pass)

@krpeacock
Copy link
Contributor

krpeacock commented Feb 2, 2024

it would be even cooler if templates with II would integrate with the frontend code as well.

I do plan to do this, but it'll be a follow-up


#[derive(ValueEnum, Debug, Copy, Clone, PartialEq, Eq)]
enum FrontendType {
Svelte,
Copy link
Member

@ericswanson-dfinity ericswanson-dfinity Feb 8, 2024

Choose a reason for hiding this comment

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

@adamspofford-dfinity In the absence of an opinion from anyone with a better handle on the ecosystem, I think we should change this to SvelteKit (and the cli option to --type sveltekit), since there is a distinction between the two.

assert_command dfx new e2e_no_frontend --no-frontend
assert_file_exists e2e_no_frontend/src/e2e_no_frontend_frontend/assets/sample-asset.txt
@test "frontend templates apply successfully" {
for frontend in sveltekit vue react vanilla simple-assets none; do
Copy link
Member

@ericswanson-dfinity ericswanson-dfinity Feb 8, 2024

Choose a reason for hiding this comment

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

This may be what is breaking

Suggested change
for frontend in sveltekit vue react vanilla simple-assets none; do
for frontend in svelte-kit vue react vanilla simple-assets none; do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I renamed it in the same commit.

@mergify mergify bot merged commit bd13729 into master Feb 9, 2024
171 checks passed
@mergify mergify bot deleted the spofford/new-templates branch February 9, 2024 00:16
@mergify mergify bot removed the automerge-squash label Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--no-frontend flag
6 participants