Skip to content

Commit

Permalink
Changed default view engine to pug
Browse files Browse the repository at this point in the history
  • Loading branch information
DDRAGON committed Nov 8, 2020
1 parent d1f3fcc commit 3374407
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 31 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
language: node_js
node_js:
- "0.10"
- "0.12"
- "1.8"
- "2.5"
- "3.3"
- "4.9"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ This generator can also be further configured with the following command line fl
--pug add pug engine support
--hbs add handlebars engine support
-H, --hogan add hogan.js engine support
-v, --view <engine> add view <engine> support (dust|ejs|hbs|hjs|jade|pug|twig|vash) (defaults to jade)
-v, --view <engine> add view <engine> support (dust|ejs|hbs|hjs|jade|pug|twig|vash) (defaults to pug)
--no-view use static html instead of view engine
-c, --css <engine> add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain css)
--git add .gitignore
Expand Down
3 changes: 0 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
environment:
matrix:
- nodejs_version: "0.10"
- nodejs_version: "0.12"
- nodejs_version: "1.8"
- nodejs_version: "2.5"
- nodejs_version: "3.3"
- nodejs_version: "4.9"
Expand Down
12 changes: 6 additions & 6 deletions bin/express-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ program
.option(' --pug', 'add pug engine support', renamedOption('--pug', '--view=pug'))
.option(' --hbs', 'add handlebars engine support', renamedOption('--hbs', '--view=hbs'))
.option('-H, --hogan', 'add hogan.js engine support', renamedOption('--hogan', '--view=hogan'))
.option('-v, --view <engine>', 'add view <engine> support (dust|ejs|hbs|hjs|jade|pug|twig|vash) (defaults to jade)')
.option('-v, --view <engine>', 'add view <engine> support (dust|ejs|hbs|hjs|jade|pug|twig|vash) (defaults to pug)')
.option(' --no-view', 'use static html instead of view engine')
.option('-c, --css <engine>', 'add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain css)')
.option(' --git', 'add .gitignore')
Expand Down Expand Up @@ -304,7 +304,7 @@ function createApplication (name, dir) {
break
case 'pug':
app.locals.view = { engine: 'pug' }
pkg.dependencies.pug = '2.0.0-beta11'
pkg.dependencies.pug = '~2.0.4'
break
case 'twig':
app.locals.view = { engine: 'twig' }
Expand Down Expand Up @@ -456,14 +456,14 @@ function main () {
if (program.ejs) program.view = 'ejs'
if (program.hbs) program.view = 'hbs'
if (program.hogan) program.view = 'hjs'
if (program.pug) program.view = 'pug'
if (program.jade) program.view = 'jade'
}

// Default view engine
if (program.view === true) {
warning('the default view engine will not be jade in future releases\n' +
"use `--view=jade' or `--help' for additional options")
program.view = 'jade'
warning('the default view engine is pug now\n' +
"use `--view=jade' if you want to use jade or `--help' for additional options")
program.view = 'pug'
}

// Generate application
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "express-generator",
"description": "Express' application generator",
"version": "4.16.1",
"version": "5.0.0",
"author": "TJ Holowaychuk <tj@vision-media.ca>",
"contributors": [
"Aaron Heckmann <aaron.heckmann+github@gmail.com>",
Expand Down Expand Up @@ -51,7 +51,7 @@
"validate-npm-package-name": "3.0.0"
},
"engines": {
"node": ">= 0.10"
"node": ">= 2.5"
},
"files": [
"LICENSE",
Expand Down
97 changes: 81 additions & 16 deletions test/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ describe('express(1)', function () {
})
})

it('should print jade view warning', function () {
assert.strictEqual(ctx.stderr, "\n warning: the default view engine will not be jade in future releases\n warning: use `--view=jade' or `--help' for additional options\n\n")
it('should print pug view warning', function () {
assert.strictEqual(ctx.stderr, "\n warning: the default view engine is pug now\n warning: use `--view=jade' if you want to use jade or `--help' for additional options\n\n")
})

it('should provide debug instructions', function () {
Expand All @@ -51,10 +51,10 @@ describe('express(1)', function () {
assert.notStrictEqual(ctx.files.indexOf('package.json'), -1)
})

it('should have jade templates', function () {
assert.notStrictEqual(ctx.files.indexOf('views/error.jade'), -1)
assert.notStrictEqual(ctx.files.indexOf('views/index.jade'), -1)
assert.notStrictEqual(ctx.files.indexOf('views/layout.jade'), -1)
it('should have pug templates', function () {
assert.notStrictEqual(ctx.files.indexOf('views/error.pug'), -1)
assert.notStrictEqual(ctx.files.indexOf('views/index.pug'), -1)
assert.notStrictEqual(ctx.files.indexOf('views/layout.pug'), -1)
})

it('should have a package.json file', function () {
Expand All @@ -72,8 +72,8 @@ describe('express(1)', function () {
' "debug": "~2.6.9",\n' +
' "express": "~4.16.1",\n' +
' "http-errors": "~1.6.3",\n' +
' "jade": "~1.11.0",\n' +
' "morgan": "~1.9.1"\n' +
' "morgan": "~1.9.1",\n' +
' "pug": "~2.0.4"\n' +
' }\n' +
'}\n')
})
Expand Down Expand Up @@ -222,10 +222,10 @@ describe('express(1)', function () {
assert.notStrictEqual(ctx.files.indexOf('foo/package.json'), -1)
})

it('should have jade templates', function () {
assert.notStrictEqual(ctx.files.indexOf('foo/views/error.jade'), -1)
assert.notStrictEqual(ctx.files.indexOf('foo/views/index.jade'), -1)
assert.notStrictEqual(ctx.files.indexOf('foo/views/layout.jade'), -1)
it('should have pug templates', function () {
assert.notStrictEqual(ctx.files.indexOf('foo/views/error.pug'), -1)
assert.notStrictEqual(ctx.files.indexOf('foo/views/index.pug'), -1)
assert.notStrictEqual(ctx.files.indexOf('foo/views/layout.pug'), -1)
})
})

Expand Down Expand Up @@ -475,10 +475,10 @@ describe('express(1)', function () {
assert.notStrictEqual(ctx.files.indexOf('.gitignore'), -1, 'should have .gitignore file')
})

it('should have jade templates', function () {
assert.notStrictEqual(ctx.files.indexOf('views/error.jade'), -1)
assert.notStrictEqual(ctx.files.indexOf('views/index.jade'), -1)
assert.notStrictEqual(ctx.files.indexOf('views/layout.jade'), -1)
it('should have pug templates', function () {
assert.notStrictEqual(ctx.files.indexOf('views/error.pug'), -1)
assert.notStrictEqual(ctx.files.indexOf('views/index.pug'), -1)
assert.notStrictEqual(ctx.files.indexOf('views/layout.pug'), -1)
})
})

Expand Down Expand Up @@ -1004,6 +1004,71 @@ describe('express(1)', function () {
})
})

describe('jade', function () {
var ctx = setupTestEnvironment(this.fullTitle())

it('should create basic app with jade templates', function (done) {
run(ctx.dir, ['--view', 'jade'], function (err, stdout) {
if (err) return done(err)
ctx.files = utils.parseCreatedFiles(stdout, ctx.dir)
assert.strictEqual(ctx.files.length, 16)
done()
})
})

it('should have basic files', function () {
assert.notStrictEqual(ctx.files.indexOf('bin/www'), -1)
assert.notStrictEqual(ctx.files.indexOf('app.js'), -1)
assert.notStrictEqual(ctx.files.indexOf('package.json'), -1)
})

it('should have jade in package dependencies', function () {
var file = path.resolve(ctx.dir, 'package.json')
var contents = fs.readFileSync(file, 'utf8')
var dependencies = JSON.parse(contents).dependencies
assert.ok(typeof dependencies.jade === 'string')
})

it('should have jade templates', function () {
assert.notStrictEqual(ctx.files.indexOf('views/error.jade'), -1)
assert.notStrictEqual(ctx.files.indexOf('views/index.jade'), -1)
assert.notStrictEqual(ctx.files.indexOf('views/layout.jade'), -1)
})

it('should have installable dependencies', function (done) {
this.timeout(NPM_INSTALL_TIMEOUT)
npmInstall(ctx.dir, done)
})

describe('npm start', function () {
before('start app', function () {
this.app = new AppRunner(ctx.dir)
})

after('stop app', function (done) {
this.timeout(APP_START_STOP_TIMEOUT)
this.app.stop(done)
})

it('should start app', function (done) {
this.timeout(APP_START_STOP_TIMEOUT)
this.app.start(done)
})

it('should respond to HTTP request', function (done) {
request(this.app)
.get('/')
.expect(200, /<title>Express<\/title>/, done)
})

it('should generate a 404', function (done) {
request(this.app)
.get('/does_not_exist')
.expect(404, /<h1>Not Found<\/h1>/, done)
})
})
})

describe('twig', function () {
var ctx = setupTestEnvironment(this.fullTitle())

Expand Down

0 comments on commit 3374407

Please sign in to comment.