mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
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:
parent
004f383315
commit
232bc0196f
@ -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;
|
||||||
|
@ -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
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
test/fixtures/missing-pages-dir/missing-pages-dir.test.js
vendored
Normal file
17
test/fixtures/missing-pages-dir/missing-pages-dir.test.js
vendored
Normal 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
|
||||||
|
}]
|
||||||
|
])
|
||||||
|
})
|
||||||
|
})
|
@ -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()
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user