forked from meteor/meteor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from meteor/devel
Boilerplate refactor (meteor#8820)
- Loading branch information
Showing
15 changed files
with
420 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
This directory and the files immediately inside it are automatically generated | ||
when you change this package's NPM dependencies. Commit the files in this | ||
directory (npm-shrinkwrap.json, .gitignore, and this README) to source control | ||
so that others run the same versions of sub-dependencies. | ||
|
||
You should NOT check in the node_modules directory that Meteor automatically | ||
creates; if you are using git, the .gitignore file tells git to ignore it. |
9 changes: 9 additions & 0 deletions
9
packages/boilerplate-generator-tests/.npm/package/npm-shrinkwrap.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Npm.depends({'parse5': '3.0.2'}); | ||
Package.describe({ | ||
// These tests are in a separate package so that we can Npm.depend on parse5, a html parsing library | ||
summary: "Tests for the boilerplate-generator package", | ||
version: '1.0.0' | ||
}); | ||
|
||
Package.onTest(function (api) { | ||
api.use('ecmascript'); | ||
api.use(['tinytest', 'boilerplate-generator'], 'server'); | ||
api.addFiles('web.browser-tests.js', 'server'); | ||
api.addFiles('web.cordova-tests.js', 'server'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
export function generateHTMLForArch(arch) { | ||
// Use a dummy manifest. None of these paths will be read from the filesystem, but css / js should be handled differently | ||
const manifest = [ | ||
{ | ||
path: 'packages/bootstrap/css/bootstrap-responsive.css', | ||
where: 'client', | ||
type: 'css', | ||
cacheable: true, | ||
url: '/packages/bootstrap/css/bootstrap-responsive.css?hash=785760fc5ad665d7b54d56a3c2522797bb2cc150&v="1"', | ||
size: 22111, | ||
hash: '785760fc5ad665d7b54d56a3c2522797bb2cc150' | ||
}, | ||
{ | ||
path: 'packages/templating-runtime.js', | ||
where: 'client', | ||
type: 'js', | ||
cacheable: true, | ||
url: '/packages/templating-runtime.js?hash=c18de19afda6e9f0db7faf3d4382a4c953cabe18&v="1"', | ||
size: 24132, | ||
hash: 'c18de19afda6e9f0db7faf3d4382a4c953cabe18' | ||
}, | ||
]; | ||
|
||
// Set some extra options for boilerplate data. | ||
// webapp_server usually constructs a Boilerplate object similarly | ||
const inline = true; | ||
const inlineScriptsAllowed = true; | ||
const additionalStaticJs = []; | ||
const meteorRuntimeConfig = 'config123'; | ||
const rootUrlPathPrefix = 'rootUrlPathPrefix'; | ||
const htmlAttributes = { | ||
foo: 'foobar', | ||
gems: '&"', | ||
}; | ||
|
||
// A dummy rewrite hook to test ampersands | ||
function bundledJsCssUrlRewriteHook(url) { | ||
return url + '+rewritten_url=true'; | ||
} | ||
|
||
const boilerplate = new Boilerplate(arch, manifest, { | ||
baseDataExtension: { | ||
htmlAttributes, | ||
additionalStaticJs, | ||
meteorRuntimeConfig, | ||
rootUrlPathPrefix, | ||
bundledJsCssUrlRewriteHook, | ||
inlineScriptsAllowed, | ||
inline | ||
}, | ||
}); | ||
|
||
return boilerplate.toHTML(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { parse, serialize } from 'parse5'; | ||
import { generateHTMLForArch } from './test-lib'; | ||
|
||
const html = generateHTMLForArch('web.browser'); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.browser - well-formed html", function (test) { | ||
const formatted = serialize(parse(html)); | ||
test.isTrue(formatted.replace(/\s/g, '') === html.replace(/\s/g, '')); | ||
}); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.browser - include htmlAttributes", function (test) { | ||
test.matches(html, /foo="foobar"/); | ||
}); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.browser - escape htmlAttributes", function (test) { | ||
test.matches(html, /gems="&""/); | ||
}); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.browser - include js", function (test) { | ||
test.matches(html, /<script[^<>]*src="[^<>]*templating[^<>]*">/); | ||
}); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.browser - escape js", function (test) { | ||
test.matches(html, /<script[^<>]*src="[^<>]*templating[^<>]*&v="1"[^<>]*">/); | ||
}); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.browser - include css", function (test) { | ||
test.matches(html, /<link[^<>]*href="[^<>]*bootstrap[^<>]*">/); | ||
}); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.browser - escape css", function (test) { | ||
test.matches(html, /<link[^<>]*href="[^<>]*bootstrap[^<>]*&v="1"[^<>]*">/); | ||
}); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.browser - call rewriteHook", function (test) { | ||
test.matches(html, /\+rewritten_url=true/); | ||
}); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.browser - include runtime config", function (test) { | ||
test.matches(html, /<script[^<>]*>[^<>]*__meteor_runtime_config__ =.*decodeURIComponent\(config123\)/); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { parse, serialize } from 'parse5'; | ||
import { generateHTMLForArch } from './test-lib'; | ||
|
||
const html = generateHTMLForArch('web.cordova'); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.cordova - well-formed html", function (test) { | ||
const formatted = serialize(parse(html)); | ||
test.isTrue(formatted.replace(/\s/g, '') === html.replace(/\s/g, '')); | ||
}); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.cordova - include js", function (test) { | ||
test.matches(html, /<script[^<>]*src="[^<>]*templating[^<>]*">/); | ||
}); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.cordova - escape js", function (test) { | ||
test.matches(html, /<script[^<>]*src="[^<>]*templating[^<>]*&v="1"[^<>]*">/); | ||
}); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.cordova - include css", function (test) { | ||
test.matches(html, /<link[^<>]*href="[^<>]*bootstrap[^<>]*">/); | ||
}); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.cordova - escape css", function (test) { | ||
test.matches(html, /<link[^<>]*href="[^<>]*bootstrap[^<>]*&v="1"[^<>]*">/); | ||
}); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.cordova - do not call rewriteHook", function (test) { | ||
test.notMatches(html, /\+rewritten_url=true/); | ||
}); | ||
|
||
Tinytest.add("boilerplate-generator-tests - web.cordova - include runtime config", function (test) { | ||
test.matches(html, /<script[^<>]*>[^<>]*\n[^<>]*__meteor_runtime_config__ =[^<>]*decodeURIComponent\(config123\)\)/); | ||
}); |
106 changes: 0 additions & 106 deletions
106
packages/boilerplate-generator/boilerplate-generator.js
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
packages/boilerplate-generator/boilerplate_web.browser.html
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
packages/boilerplate-generator/boilerplate_web.cordova.html
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.