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

refactor(common): nuxt.config.js and dynamic server options (latest process.env) #4208

Merged
merged 27 commits into from Oct 27, 2018

Conversation

galvez
Copy link

@galvez galvez commented Oct 26, 2018

Shouldn't be needed after #4207 (comment)

@galvez galvez requested a review from pi0 October 26, 2018 20:02
@galvez
Copy link
Author

galvez commented Oct 26, 2018

@pi0 or maybe not? will check later, gtg now :)

@galvez galvez added the WIP label Oct 26, 2018
@sibbng
Copy link

sibbng commented Oct 26, 2018

I think they are needed for start your application from command line.

@aldarund
Copy link

aldarund commented Oct 26, 2018

Tests failing so not so easy :) But not a good that it repeats

@pi0
Copy link
Member

pi0 commented Oct 27, 2018

@pimlie is our cli hero :D

@galvez galvez closed this Oct 27, 2018
@pimlie
Copy link

pimlie commented Oct 27, 2018

It seems to me this could be merged after changing the test. The failing test is a direct result of the expectation that ./utils.js set a default for host/port. If we want to improve that by moving it to nuxt.config.js like all other defaults then we just cant test for that here.

-- edit --
And isnt the whole getLatestHost function redundant? Except for argv. everything is already set in nuxt.config.js. I think we could remove that and change it just to

if (argv.port) {
  options.server.port = argv.port
}

Then if no port is supplied on the commandline the same defaults as now are already set in nuxt.config.js and applied to the running config with defaultsDeep.

@galvez galvez reopened this Oct 27, 2018
@galvez
Copy link
Author

galvez commented Oct 27, 2018

@pimlie ha, you're totally right!

I had a feeling about this too but couldn't look into it at the time. Will update.

@galvez
Copy link
Author

galvez commented Oct 27, 2018

So I've stopped at trying to load a fresh version of NuxtConfig because we need to pick up fresh process.env values. Suggestions welcome :)

@galvez
Copy link
Author

galvez commented Oct 27, 2018

Back later!

@pimlie
Copy link

pimlie commented Oct 27, 2018

Why and where is the fresh config needed? Its a bit hard to follow your thought process with all the fix descriptions, but if you are trying to fix the failing test which checks env-host then you will never succeed in that ;)

These are all strict unit tests which (try) to only test one (class) method at the time (and only stuff from this package). As setting the host from env is now moved from this package to nuxt/common the env-host test can be removed here I guess (and it should be added to a nuxt/common test).

@galvez
Copy link
Author

galvez commented Oct 27, 2018

Why and where is the fresh config needed?

Because we introduce new environment variables dynamically in a test. But I guess you're right, following this approach this test doesn't make sense anymore, as there's no real-world scenario where process.env would be actually modified right before loadNuxtConfig().

@pimlie
Copy link

pimlie commented Oct 27, 2018

Ah ok, thanks. If we have that problem in nuxt/common then its probably easier to just call jest.resetModules() or (sometimes that doesnt work) delete require.cache[...path.to.nuxt-config] as it seems it'd only be a test issue and not a real world issue.

@codecov-io
Copy link

codecov-io commented Oct 27, 2018

Codecov Report

Merging #4208 into dev will decrease coverage by 0.16%.
The diff coverage is 16.66%.

Impacted file tree graph

@@           Coverage Diff            @@
##            dev    #4208      +/-   ##
========================================
- Coverage    89%   88.83%   -0.17%     
========================================
  Files        39       42       +3     
  Lines      1691     1684       -7     
  Branches    443      436       -7     
========================================
- Hits       1505     1496       -9     
- Misses      159      161       +2     
  Partials     27       27
Impacted Files Coverage Δ
packages/common/src/config/render.js 0% <0%> (ø)
packages/common/src/config/build.js 0% <0%> (ø)
packages/common/src/config/server.js 100% <100%> (ø)
packages/common/src/config/index.js 14.28% <14.28%> (ø)
packages/cli/src/utils.js 83.72% <33.33%> (-6.48%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 00e83e3...dca26a6. Read the comment docs.

@galvez galvez changed the title chore: remove unneeded defaults refactor(common): nuxt.config.js and dynamic server options (latest process.env) Oct 27, 2018
@galvez galvez self-assigned this Oct 27, 2018
@galvez galvez removed the WIP label Oct 27, 2018
@lock
Copy link

lock bot commented Nov 26, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 26, 2018
@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants