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

Add offline mode #2483

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RossComputerGuy
Copy link

  • Adds an --offline flag which is useful for sandbox/networkless build systems such as Nix.

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

@bkonyi
Copy link
Collaborator

bkonyi commented Oct 7, 2024

Sorry for the delay on this @RossComputerGuy! Overall, this change looks good to me, but we should add some tests before landing.

@RossComputerGuy
Copy link
Author

I've gone ahead and rebased it. I will look into getting tests in shortly.

@RossComputerGuy
Copy link
Author

Can't figure out how the test should be done, I see there's configuration tests but none invoke read.

@bkonyi
Copy link
Collaborator

bkonyi commented Oct 8, 2024

Can't figure out how the test should be done, I see there's configuration tests but none invoke read.

I think you can either add a test like this or something similar to what's done in this file.

Basically, you'll just want a test that runs webdev serve --no-pub on a project that hasn't had dart pub get invoked to pull down the dependencies. The webdev serve --no-pub should fail to serve the project since there will be unresolved dependencies.

@RossComputerGuy
Copy link
Author

Ok, I added the test.

@@ -30,6 +30,14 @@ void main() {
Process? serveProcess;
Directory? tempDir0;

final testScript =
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not really sure what's going on with these lines. Could we not get the package directory simply by doing p.dirname(p.dirname(Platform.script.toFilePath())?

Copy link
Author

Choose a reason for hiding this comment

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

That gives me /tmp

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah right, because the test runner generates an entrypoint...

In that case, I think we should continue to activate webdev from pub instead of using --source path. This test should still work as long as we don't run dart pub get on the created project before running webdev serve --offline.

Copy link
Author

Choose a reason for hiding this comment

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

Oh ok, I was assuming we would do it the way I did so new updates would actually work. I was getting an error saying --offline wasn't a recognized flag even if I did activate it outside the test.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right, that's a great point. Given that, I think we should move the test to webdev/test/integration_test.dart. The tests there run webdev from source so we won't have to worry about publishing before this new test will pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants