feat: missing pages directory warning (#4054)

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (a non-breaking change which fixes an issue)
- [x] New feature (a non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)


## Description
Resolves #3920 by adding a warning during the build process and a small disclaimer into the default page component.


## Checklist:
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly. (PR: #)
- [x] I have added tests to cover my changes (if not applicable, please state why)
- [x] All new and existing tests are passing.
This commit is contained in:
Felipe Lübe de Bragança 2018-10-05 09:37:55 -03:00 committed by Clark Du
parent 004f383315
commit 232bc0196f
4 changed files with 37 additions and 0 deletions

View File

@ -14,6 +14,7 @@
<a href="https://nuxtjs.org/guide/installation#starting-from-scratch" target="_blank" class="button"> <a href="https://nuxtjs.org/guide/installation#starting-from-scratch" target="_blank" class="button">
Get Started Get Started
</a> </a>
<p class="Landscape__Page__Explanation">Please create <a href="https://nuxtjs.org/guide/directory-structure#the-pages-directory" target="_blank">the pages directory</a> to suppress this default page.</p>
</section> </section>
</div> </div>
</template> </template>
@ -66,6 +67,18 @@
word-spacing: 5px; word-spacing: 5px;
} }
.Landscape__Page__Explanation {
font-family: "Quicksand", "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
color: #35495e;
margin: 16px 0 0;
font-size: 16px;
}
.Landscape__Page__Explanation > a {
color: #3b8070;
text-decoration: underline;
}
@media (min-width: 992px) { @media (min-width: 992px) {
.Landscape__Title { .Landscape__Title {
font-size: 60px; font-size: 60px;

View File

@ -133,6 +133,12 @@ export default class Builder {
) )
} else { } else {
this._defaultPage = true this._defaultPage = true
consola.warn({
message: `No \`${this.options.dir.pages}\` directory found in ${dir}.`,
additional: 'Using the default built-in page.\n',
additionalStyle: 'yellowBright',
badge: true
})
} }
} }
} }

View File

@ -0,0 +1,17 @@
import consola from 'consola'
import { buildFixture } from '../../utils/build'
describe('missing-pages-dir', () => {
buildFixture('missing-pages-dir', (builder) => {
const options = builder.nuxt.options
expect(consola.warn).toHaveBeenCalledTimes(1)
expect(consola.warn.mock.calls).toMatchObject([
[{
message: `No \`${options.dir.pages}\` directory found in ${options.srcDir}.`,
additional: 'Using the default built-in page.\n',
additionalStyle: 'yellowBright',
badge: true
}]
])
})
})

View File

@ -40,6 +40,7 @@ describe('nuxt', () => {
const { html } = await nuxt.renderRoute('/') const { html } = await nuxt.renderRoute('/')
expect(html.includes('Universal Vue.js Applications')).toBe(true) expect(html.includes('Universal Vue.js Applications')).toBe(true)
expect(/Landscape__Page__Explanation/.test(html)).toBe(true)
await nuxt.close() await nuxt.close()
}) })