Skip to content

Commit 46d3385

Browse files
authored
Merge pull request #565 from kethinov/0.30.0
0.30.0
2 parents 280857e + 315e701 commit 46d3385

File tree

18 files changed

+399
-325
lines changed

18 files changed

+399
-325
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ This project's versioning tracks Roosevelt's versioning. When some version numbe
66

77
- Put your changes here...
88

9+
## 0.30.0
10+
11+
- Added `standard-mpa-install`, `standard-static-install`, and `standard-spa-install` CLI flags.
12+
- Added a demonstration of a global model for static sites.
13+
- Added more favicon PNG files.
14+
- Fixed a bug that caused favicon.ico to be placed in the wrong folder in static site generator mode.
15+
- Updated dependencies.
16+
917
## 0.29.4
1018

1119
- Fixed a bug with the default helpers CSS file.

generators/app/index.js

Lines changed: 83 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,23 @@ module.exports = class extends Generator {
1010
super(args, opts)
1111

1212
// if this is executed like `yo roosevelt --standard-install custom-app-name`, cache that name so it can override appName later
13-
if (opts.standardInstall && typeof opts.standardInstall === 'string') cache.standardInstall = opts.standardInstall
14-
else if (args[0] === '--standard-install') cache.standardInstall = args[1] // if mkroosevelt is being used, type of installation in args[0] and the project name will be in args[1]
13+
if (opts.standardInstall && typeof opts.standardInstall === 'string') {
14+
cache.standardInstall = opts.standardInstall
15+
cache.standardMpaInstall = opts.standardInstall
16+
}
17+
if (opts.standardMpaInstall && typeof opts.standardMpaInstall === 'string') {
18+
cache.standardInstall = opts.standardMpaInstall
19+
cache.standardMpaInstall = opts.standardMpaInstall
20+
}
21+
if (opts.standardStaticInstall && typeof opts.standardStaticInstall === 'string') cache.standardStaticInstall = opts.standardStaticInstall
22+
if (opts.standardSpaInstall && typeof opts.standardSpaInstall === 'string') cache.standardSpaInstall = opts.standardSpaInstall
23+
24+
if (args[0] === '--standard-install' || args[0] === '--standard-mpa-install') {
25+
cache.standardInstall = args[1] // if mkroosevelt is being used, type of installation in args[0] and the project name will be in args[1]
26+
cache.standardMpaInstall = args[1] // if mkroosevelt is being used, type of installation in args[0] and the project name will be in args[1]
27+
}
28+
if (args[0] === '--standard-static-install') cache.standardStaticInstall = args[1] // if mkroosevelt is being used, type of installation in args[0] and the project name will be in args[1]
29+
if (args[0] === '--standard-spa-install') cache.standardSpaInstall = args[1] // if mkroosevelt is being used, type of installation in args[0] and the project name will be in args[1]
1530

1631
this.option('standard-install', {
1732
alias: 's',
@@ -20,6 +35,24 @@ module.exports = class extends Generator {
2035
desc: 'Skips all prompts and creates a Roosevelt app with all defaults.'
2136
})
2237

38+
this.option('standard-mpa-install', {
39+
type: String,
40+
required: false,
41+
desc: 'Skips all prompts and creates a Roosevelt multi-page app with all defaults.'
42+
})
43+
44+
this.option('standard-static-install', {
45+
type: String,
46+
required: false,
47+
desc: 'Skips all prompts and creates a Roosevelt static site generator with all defaults.'
48+
})
49+
50+
this.option('standard-spa-install', {
51+
type: String,
52+
required: false,
53+
desc: 'Skips all prompts and creates a Roosevelt single page app with all defaults.'
54+
})
55+
2356
this.option('skip-closing-message', {
2457
type: Boolean,
2558
required: false,
@@ -29,9 +62,11 @@ module.exports = class extends Generator {
2962
}
3063

3164
start () {
32-
if (this.options['standard-install']) {
65+
if (this.options['standard-install'] || this.options['standard-mpa-install'] || this.options['standard-static-install'] || this.options['standard-spa-install']) {
3366
this.appName = defaults.appName
34-
if (cache.standardInstall) this.appName = cache.standardInstall
67+
if (cache.standardMpaInstall) this.appName = cache.standardMpaInstall
68+
else if (cache.standardStaticInstall) this.appName = cache.standardStaticInstall
69+
else if (cache.standardSpaInstall) this.appName = cache.standardSpaInstall
3570
this.packageName = helper.sanitizePackageName(this.appName)
3671
return true
3772
}
@@ -80,7 +115,7 @@ module.exports = class extends Generator {
80115
}
81116

82117
chooseAppVariant () {
83-
if (this.options['standard-install']) return true
118+
if (this.options['standard-install'] || this.options['standard-mpa-install'] || this.options['standard-static-install'] || this.options['standard-spa-install']) return true
84119

85120
return this.prompt(
86121
[
@@ -102,16 +137,24 @@ module.exports = class extends Generator {
102137
})
103138
}
104139

105-
setSpaModeIfSelected () {
106-
if (this.configMode !== 'SPA — single page app (advanced users only)') return true
107-
this.spaMode = true
108-
}
109-
110140
setStaticSiteModeIfSelected () {
141+
if (this.options['standard-static-install']) {
142+
this.staticSiteMode = true
143+
return true
144+
}
111145
if (this.configMode !== 'Static site generator (easiest to use, but fewer features available)') return true
112146
this.staticSiteMode = true
113147
}
114148

149+
setSpaModeIfSelected () {
150+
if (this.options['standard-spa-install']) {
151+
this.spaMode = true
152+
return true
153+
}
154+
if (this.configMode !== 'SPA — single page app (advanced users only)') return true
155+
this.spaMode = true
156+
}
157+
115158
chooseAppVariantToCustomize () {
116159
if (this.configMode !== 'Custom app') return true
117160

@@ -291,7 +334,7 @@ module.exports = class extends Generator {
291334
}
292335

293336
async makeApp () {
294-
const standardInstall = this.options['standard-install']
337+
const standardInstall = this.options['standard-install'] || this.options['standard-mpa-install'] || this.options['standard-static-install'] || this.options['standard-spa-install']
295338
let destination
296339
if (standardInstall === 'true') destination = this.packageName
297340
else if (standardInstall || this.createDir) destination = standardInstall || this.dirname
@@ -326,6 +369,15 @@ module.exports = class extends Generator {
326369
}
327370
]
328371

372+
if (this.staticSiteMode) {
373+
this.symlinks.push(
374+
{
375+
source: '${staticsRoot}/images/favicon.ico', // eslint-disable-line
376+
dest: '${publicFolder}/favicon.ico' // eslint-disable-line
377+
}
378+
)
379+
}
380+
329381
this.cssCompiler = this.cssCompiler || 'default'
330382
if (this.cssCompiler !== 'none') {
331383
if (this.cssCompiler === 'default') {
@@ -641,6 +693,26 @@ module.exports = class extends Generator {
641693
this.templatePath('statics/images/favicon.ico'),
642694
this.destinationPath('statics/images/favicon.ico')
643695
)
696+
this.fs.copy(
697+
this.templatePath('statics/images/favicon-16x16.png'),
698+
this.destinationPath('statics/images/favicon-16x16.png')
699+
)
700+
this.fs.copy(
701+
this.templatePath('statics/images/favicon-32x32.png'),
702+
this.destinationPath('statics/images/favicon-32x32.png')
703+
)
704+
this.fs.copy(
705+
this.templatePath('statics/images/favicon-48x48.png'),
706+
this.destinationPath('statics/images/favicon-48x48.png')
707+
)
708+
this.fs.copy(
709+
this.templatePath('statics/images/favicon-64x64.png'),
710+
this.destinationPath('statics/images/favicon-64x64.png')
711+
)
712+
this.fs.copy(
713+
this.templatePath('statics/images/favicon-128x128.png'),
714+
this.destinationPath('statics/images/favicon-128x128.png')
715+
)
644716

645717
this.fs.copy(
646718
this.templatePath(`statics/js/main${appVariant}.js`),

generators/app/templates/build.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
(async () => {
2-
await require('roosevelt')().init()
2+
await require('roosevelt')({
3+
onBeforeMiddleware: (app) => {
4+
// this defines a model used on all static pages, unless overridden by a page-specific model
5+
app.get('htmlModels')['*'] = {
6+
global: {
7+
hello: 'world!'
8+
}
9+
}
10+
}
11+
}).init()
312
})()

generators/app/templates/defaults.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"dependencies": {
33
"check-if-css-is-disabled": "~2.0.0",
4-
"roosevelt": "~0.29.0",
4+
"roosevelt": "~0.30.0",
55
"webpack": "~5.98.0"
66
},
77
"appName": "My Roosevelt Sample App",
@@ -101,7 +101,7 @@
101101
"semantic-forms": "~5.0.0"
102102
},
103103
"single-page-express": {
104-
"single-page-express": "~1.2.0"
104+
"single-page-express": "~2.0.0"
105105
},
106106
"clientControllers": {
107107
"enable": true,

generators/app/templates/mvc/controllers/teddy/404.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = (router, app) => {
2-
router.route('*').all(async (req, res) => {
2+
router.route('*all').all(async (req, res) => {
33
const model = await require('models/server')(req, res)
44
model.content.pageTitle = 'Not Found'
55
res.status(404)

generators/app/templates/mvc/views/teddy/layouts/main.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
<script>window.addEventListener('error', (event) => { if (event?.target?.tagName === 'LINK') { window.linkTagError = true } }, true)</script>
1111
<link rel="preload" href="/css/styles.css" as="style">
1212
<link rel="preload" href="/js/main.js" as="script">
13+
<link rel="icon" type="image/png" href="/images/favicon-16x16.png" sizes="16x16">
14+
<link rel="icon" type="image/png" href="/images/favicon-32x32.png" sizes="32x32">
15+
<link rel="icon" type="image/png" href="/images/favicon-48x48.png" sizes="48x48">
16+
<link rel="icon" type="image/png" href="/images/favicon-64x64.png" sizes="64x64">
17+
<link rel="icon" type="image/png" href="/images/favicon-128x128.png" sizes="128x128">
1318
<link rel="stylesheet" href="/css/styles.css">
1419
<script src="/js/main.js" defer></script>
1520
</head>

generators/app/templates/mvc/views/teddy/layouts/main.spa.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
<script>window.addEventListener('error', (event) => { if (event?.target?.tagName === 'LINK') { window.linkTagError = true } }, true)</script>
1111
<link rel="preload" href="/css/styles.css" as="style">
1212
<link rel="preload" href="/js/main.js" as="script">
13+
<link rel="icon" type="image/png" href="/images/favicon-16x16.png" sizes="16x16">
14+
<link rel="icon" type="image/png" href="/images/favicon-32x32.png" sizes="32x32">
15+
<link rel="icon" type="image/png" href="/images/favicon-48x48.png" sizes="48x48">
16+
<link rel="icon" type="image/png" href="/images/favicon-64x64.png" sizes="64x64">
17+
<link rel="icon" type="image/png" href="/images/favicon-128x128.png" sizes="128x128">
1318
<link rel="stylesheet" href="/css/styles.css">
1419
<script src="/js/main.js" defer></script>
1520
</head>

generators/app/templates/mvc/views/vanilla/homepage.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
<script>window.addEventListener('error', (event) => { if (event?.target?.tagName === 'LINK') { window.linkTagError = true } }, true)</script>
1111
<link rel="preload" href="/css/styles.css" as="style">
1212
<link rel="preload" href="/js/main.js" as="script">
13+
<link rel="icon" type="image/png" href="/images/favicon-16x16.png" sizes="16x16">
14+
<link rel="icon" type="image/png" href="/images/favicon-32x32.png" sizes="32x32">
15+
<link rel="icon" type="image/png" href="/images/favicon-48x48.png" sizes="48x48">
16+
<link rel="icon" type="image/png" href="/images/favicon-64x64.png" sizes="64x64">
17+
<link rel="icon" type="image/png" href="/images/favicon-128x128.png" sizes="128x128">
1318
<link rel="stylesheet" href="/css/styles.css">
1419
<script src="/js/main.js" defer></script>
1520
</head>

generators/app/templates/package.json.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<% } %>
1717
"nodemon": "~3.1.0",
1818
"standard": "~17.1.0",
19-
"stylelint": "~16.16.0",
19+
"stylelint": "~16.17.0",
2020
<%- stylelintPostCssModule -%>
2121
<%- stylelintConfigModule %>
2222
},
Loading
Loading
Loading
Loading
Loading

generators/app/templates/statics/pages/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<article id="homepage">
44
<p>{content.hello}</p>
55
<p>{content.picLabel}</p>
6+
<p>hello {global.hello}</p>
67
<p><img src="{teddyPath}" alt="Sample image"></p>
78
</article>
89
</arg>

generators/app/templates/statics/pages/layouts/main.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
<script>window.addEventListener('error', (event) => { if (event?.target?.tagName === 'LINK') { window.linkTagError = true } }, true)</script>
1111
<link rel="preload" href="/css/styles.css" as="style">
1212
<link rel="preload" href="/js/main.js" as="script">
13+
<link rel="icon" type="image/png" href="/images/favicon-16x16.png" sizes="16x16">
14+
<link rel="icon" type="image/png" href="/images/favicon-32x32.png" sizes="32x32">
15+
<link rel="icon" type="image/png" href="/images/favicon-48x48.png" sizes="48x48">
16+
<link rel="icon" type="image/png" href="/images/favicon-64x64.png" sizes="64x64">
17+
<link rel="icon" type="image/png" href="/images/favicon-128x128.png" sizes="128x128">
1318
<link rel="stylesheet" href="/css/styles.css">
1419
<script src="/js/main.js" defer></script>
1520
</head>

0 commit comments

Comments
 (0)