You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by benkeen <gi...@git.apache.org> on 2014/12/05 20:35:47 UTC
[GitHub] couchdb-fauxton pull request: Rename index.css and require.js with...
GitHub user benkeen opened a pull request:
https://github.com/apache/couchdb-fauxton/pull/190
Rename index.css and require.js with md5 hash
- removes obsolete "cache buster" setting
- replaces hardcoded require.js and index.cs filenames in settings
files with for non-dev build processes with variables.
- release and couchapp_deploy tasks now rename those two files to
include their hashes, and reference them in the generated index.html
file
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/benkeen/couchdb-fauxton md5-requirejs-file
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/couchdb-fauxton/pull/190.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #190
----
commit 10c5a853d1c345bf6a0755aef690a36cb35613b4
Author: Benjamin Keen <be...@gmail.com>
Date: 2014-12-05T19:33:22Z
Rename index.css and require.js with md5 hash
- removes obsolete "cache buster" setting
- replaces hardcoded require.js and index.cs filenames in settings
files with for non-dev build processes with variables.
- release and couchapp_deploy tasks now rename those two files to
include their hashes, and reference them in the generated index.html
file
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Rename index.css and require.js with...
Posted by benkeen <gi...@git.apache.org>.
Github user benkeen commented on the pull request:
https://github.com/apache/couchdb-fauxton/pull/190#issuecomment-66175058
Thanks! Merged as ef5264d
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Rename index.css and require.js with...
Posted by benkeen <gi...@git.apache.org>.
Github user benkeen commented on the pull request:
https://github.com/apache/couchdb-fauxton/pull/190#issuecomment-65842815
To clarify this one a bit, this ticket updates the Grunt process for production builds so that the main resource files are renamed. If you check the generated `index.html` file source you'll see something like this:
```html
<html lang="en">
...
<!-- Application styles. -->
<link rel="stylesheet" href="./css/index-d4f1c5a7bfd9b7d9fefd3833152f83e8.css">
</head>
<body id="home">
...
<!-- Application source. -->
<script data-main="/config" src="./js/require-3118ebce709edc3e4365a002d2531cee.js"></script>
</body>
</html>
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Rename index.css and require.js with...
Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the pull request:
https://github.com/apache/couchdb-fauxton/pull/190#issuecomment-66041364
+1 works nicely. Great work.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Rename index.css and require.js with...
Posted by benkeen <gi...@git.apache.org>.
Github user benkeen commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/190#discussion_r21395779
--- Diff: Gruntfile.js ---
@@ -139,13 +139,18 @@ module.exports = function(grunt) {
return helper.readSettingsFile().couchserver || defaults;
}();
- grunt.initConfig({
+ var config = {
// The clean task ensures all files are removed from the dist/ directory so
// that no files linger from previous builds.
clean: {
release: cleanable,
- watch: cleanableAddons
+ watch: cleanableAddons,
+
+ // used during release and couchapp_deploy steps to remove unnecessary un-md5-ified files
+ oldResources: {
--- End diff --
That's true... I actually had that originally, but didn't like having the clean task ran in both of the md5 targets (requireJS + css). Now it just runs a single task to do both. But that said, it didn't require hardcoding the paths like it does now. I'm fine with either approach, to be honest.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Rename index.css and require.js with...
Posted by benkeen <gi...@git.apache.org>.
Github user benkeen closed the pull request at:
https://github.com/apache/couchdb-fauxton/pull/190
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Rename index.css and require.js with...
Posted by benkeen <gi...@git.apache.org>.
Github user benkeen commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/190#discussion_r21410934
--- Diff: Gruntfile.js ---
@@ -423,8 +424,43 @@ module.exports = function(grunt) {
template: 'test/nightwatch_tests/nightwatch.json.underscore',
dest: 'test/nightwatch_tests/nightwatch.json'
}
+ },
+
+ // these rename the already-bundled, minified requireJS and CSS files to include their hash
+ md5: {
+ requireJS: {
+ files: { "dist/release/js/" : "dist/release/js/require.js" },
+ options: {
+ afterEach: function (fileChanges) {
+ // replace the REQUIREJS_FILE placeholder with the actual filename
+ var newFilename = fileChanges.newPath.match(/[^\/]+$/)[0];
+ config.template.release.variables.requirejs = config.template.release.variables.requirejs.replace(/REQUIREJS_FILE/, newFilename);
+
+ // remove the original requireJS file, we don't need it anymore
+ config.clean.removeRequireJS = { src: [fileChanges.oldPath] };
+ grunt.task.run("clean:removeRequireJS");
--- End diff --
Nice, thanks @robertkowalski! Will do.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Rename index.css and require.js with...
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/190#discussion_r21395535
--- Diff: Gruntfile.js ---
@@ -139,13 +139,18 @@ module.exports = function(grunt) {
return helper.readSettingsFile().couchserver || defaults;
}();
- grunt.initConfig({
+ var config = {
// The clean task ensures all files are removed from the dist/ directory so
// that no files linger from previous builds.
clean: {
release: cleanable,
- watch: cleanableAddons
+ watch: cleanableAddons,
+
+ // used during release and couchapp_deploy steps to remove unnecessary un-md5-ified files
+ oldResources: {
--- End diff --
You can delete the processed files in the callback of the grunt task, so the grunt task for md5 sums is self-contained. You get the path of the old file passed via `fileChange.oldPath` I think.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Rename index.css and require.js with...
Posted by benkeen <gi...@git.apache.org>.
Github user benkeen commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/190#discussion_r21396572
--- Diff: Gruntfile.js ---
@@ -139,13 +139,18 @@ module.exports = function(grunt) {
return helper.readSettingsFile().couchserver || defaults;
}();
- grunt.initConfig({
+ var config = {
// The clean task ensures all files are removed from the dist/ directory so
// that no files linger from previous builds.
clean: {
release: cleanable,
- watch: cleanableAddons
+ watch: cleanableAddons,
+
+ // used during release and couchapp_deploy steps to remove unnecessary un-md5-ified files
+ oldResources: {
--- End diff --
I changed my mind: I agree. Making it self-contained trumps the duplication. I'll change it!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Rename index.css and require.js with...
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/190#discussion_r21409750
--- Diff: Gruntfile.js ---
@@ -423,8 +424,43 @@ module.exports = function(grunt) {
template: 'test/nightwatch_tests/nightwatch.json.underscore',
dest: 'test/nightwatch_tests/nightwatch.json'
}
+ },
+
+ // these rename the already-bundled, minified requireJS and CSS files to include their hash
+ md5: {
+ requireJS: {
+ files: { "dist/release/js/" : "dist/release/js/require.js" },
+ options: {
+ afterEach: function (fileChanges) {
+ // replace the REQUIREJS_FILE placeholder with the actual filename
+ var newFilename = fileChanges.newPath.match(/[^\/]+$/)[0];
+ config.template.release.variables.requirejs = config.template.release.variables.requirejs.replace(/REQUIREJS_FILE/, newFilename);
+
+ // remove the original requireJS file, we don't need it anymore
+ config.clean.removeRequireJS = { src: [fileChanges.oldPath] };
+ grunt.task.run("clean:removeRequireJS");
--- End diff --
You can just use node's `fs.unlinkSync()` here - no need to rely on the clean task:
```
fs.unlinkSync(fileChanges.oldPath)
```
http://nodejs.org/api/fs.html#fs_fs_unlinksync_path
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---