Skip to content

Commit

Permalink
feat #1273 Removing the need for a build step after changing files
Browse files Browse the repository at this point in the history
Before the migration to noder-js, it was possible to run Aria Templates
directly from its src folder.

With the migration to noder-js, this was not possible any more for two
reasons:

1) files in the src folder were using the old syntax (with $dependencies)
and were converted at build time to the new syntax (with require)

-> now, starting with commit b0ae188,
files in the repository are using the new syntax and it is no longer
needed to convert them at build time.

2) the entry point file of Aria Templates needs to be generated (as it
is built on top of noder-js, overriding one of its modules) and was
generated in the build/target/bootstrap folder.

-> this commit is changing the location where the entry point file is
generated. It is now generated in the src foilder so that it is possible
to fully execute Aria Templates directly from its src folder.

The generation of files in the src folder is now part of the full build
and can also be run independently with: grunt src

The following files are generated in the src folder:
src/aria/bootstrap.js
src/aria/bootstrap-node.js
src/aria/noderError/*.js

After running "grunt src", it is possible to use the src folder directly
to serve the Aria Templates files, and then changing most of the framework
files can be done without requiring a build step. Running again "grunt src"
is needed after changing noder-js itself or files in the src/noder-modules
folder.

Close #1273
  • Loading branch information
divdavem committed Sep 1, 2014
1 parent c5b6323 commit a12ab4b
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 95 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -9,3 +9,6 @@ node_modules
/src/aria/jsunit/robot-applet*

/build/target/
/src/aria/bootstrap.js
/src/aria/bootstrap-node.js
/src/aria/noderError/
87 changes: 87 additions & 0 deletions build/grunt-config/config-atpackager-bootstrap-src.js
@@ -0,0 +1,87 @@
/*
* Copyright 2012 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Aria Templates bootstrap build file for files generated in the source folder directly.
*/
module.exports = function (grunt) {
var packagingSettings = require('./config-packaging')(grunt);

var getNoderPackage = function (packageFile, mainFile, environment) {
return {
name : packageFile,
builder : {
type : 'NoderBootstrapPackage',
cfg : {
header : packagingSettings.license,
noderModules : ['src/noder-modules/*'],
noderEnvironment : environment,
noderConfigOptions : {
main : mainFile,
failFast : false,
resolver : {
"default" : {
ariatemplates : "aria"
}
},
packaging : {
ariatemplates : true
}
}
}
},
files : [mainFile]
};
};

grunt.config.set('atpackager.bootstrapSrc', {
options : {
sourceDirectories : ['src'],
sourceFiles : [],
outputDirectory : 'src',
visitors : [{
type : 'NoderPlugins',
cfg : {
targetBaseLogicalPath : "aria",
targetFiles : "aria/noderError/**"
}
}, {
type : 'NoderRequiresGenerator',
cfg : {
requireFunction : "syncRequire",
wrapper : "<%= grunt.file.read('src/aria/bootstrap.tpl.js') %>",
targetLogicalPath : 'aria/bootstrap.js',
requires : packagingSettings.bootstrap.files
}
}, {
type : 'NoderRequiresGenerator',
cfg : {
requireFunction : "syncRequire",
wrapper : "<%= grunt.file.read('src/aria/bootstrap.tpl.js') %>",
targetLogicalPath : 'aria/bootstrap-node.js',
requires : packagingSettings.bootstrap.files
}
}],
packages : [getNoderPackage("aria/bootstrap.js", "aria/bootstrap.js", "browser"),
getNoderPackage("aria/bootstrap-node.js", "aria/bootstrap-node.js", "node")]
}
});

grunt.config.set('removedirs.bootstrapSrc', {
folders : ['src/aria/noderError']
});

grunt.registerTask('src', ['removedirs:bootstrapSrc', 'atpackager:bootstrapSrc']);
};
126 changes: 43 additions & 83 deletions build/grunt-config/config-atpackager-bootstrap.js
Expand Up @@ -27,106 +27,66 @@

module.exports = function (grunt) {
var packagingSettings = require('./config-packaging')(grunt);

var getNoderPackage = function (packageFile, mainFile, environment) {
return {
name : packageFile,
builder : {
type : 'NoderBootstrapPackage',
cfg : {
header : packagingSettings.license,
noderModules : ['src/noder-modules/*'],
noderEnvironment : environment,
noderConfigOptions : {
main : mainFile,
failFast : false,
resolver : {
"default" : {
ariatemplates : "aria"
}
},
packaging : {
ariatemplates : true
}
}
}
},
files : [mainFile]
};
var builder = {
type : 'Concat',
cfg : {
header : packagingSettings.license
}
};
var stripBannerFiles = packagingSettings.atExtensions.concat("!aria/noderError/**");

grunt.config.set('atpackager.bootstrap', {
options : {
sourceDirectories : ['src'],
sourceFiles : ['aria/**/*', '!aria/node.js', '!aria/bootstrap.tpl.js', '!aria/css/**'],
outputDirectory : packagingSettings.bootstrap.outputDirectory,
defaultBuilder : builder,
visitors : [{
type : 'NoderPlugins',
cfg : {
targetBaseLogicalPath : "aria",
targetFiles : "aria/noderError/**"
}
}, {
type : 'NoderRequiresGenerator',
cfg : {
requireFunction : "syncRequire",
wrapper : "<%= grunt.file.read('src/aria/bootstrap.tpl.js') %>",
targetLogicalPath : 'aria/bootstrap.js',
requires : packagingSettings.bootstrap.files
}
}, {
type : 'NoderRequiresGenerator',
cfg : {
requireFunction : "syncRequire",
wrapper : "<%= grunt.file.read('src/aria/bootstrap.tpl.js') %>",
targetLogicalPath : 'aria/bootstrap-node.js',
requires : packagingSettings.bootstrap.files
}
}, {
type : 'CheckGlobals',
cfg : {
files : packagingSettings.bootstrap.checkGlobalsFiles,
allowCommonJSGlobals : true,
allowedGlobals : ["aria", "Aria", "setTimeout", "clearTimeout", "setInterval",
"clearInterval", "global"]
}
}, {
type : 'JSStripBanner',
cfg : {
files : packagingSettings.atExtensions.concat("!aria/noderError/**")
}
}, {
type : "TextReplace",
cfg : {
files : ['aria/Aria.js'],
replacements : [{
find : "ARIA-SNAPSHOT",
replace : packagingSettings.pkg.version
}]
}
type : 'CheckGlobals',
cfg : {
files : packagingSettings.bootstrap.checkGlobalsFiles,
allowCommonJSGlobals : true,
allowedGlobals : ["aria", "Aria", "setTimeout", "clearTimeout", "setInterval", "clearInterval",
"global"]
}
}, {
type : 'JSStripBanner',
cfg : {
files : stripBannerFiles
}
}, {
type : "TextReplace",
cfg : {
files : ['aria/Aria.js'],
replacements : [{
find : "ARIA-SNAPSHOT",
replace : packagingSettings.pkg.version
}]
}
}, {
type : 'CopyUnpackaged',
cfg : {
files : stripBannerFiles,
builder : builder
}
}, 'CopyUnpackaged'],
packages : [{
name : packagingSettings.bootstrap.bootstrapFileName,
files : ["aria/bootstrap.js"]
}, {
type : 'CopyUnpackaged',
cfg : {
files : packagingSettings.atExtensions,
builder : {
type : 'Concat',
cfg : {
header : packagingSettings.license_min
}
}
}
}, 'CopyUnpackaged'],
packages : [getNoderPackage(packagingSettings.bootstrap.bootstrapFileName, "aria/bootstrap.js", "browser"),
getNoderPackage("aria/node.js", "aria/bootstrap-node.js", "node")]
name : "aria/node.js",
files : ["aria/bootstrap-node.js"]
}]
}
});

grunt.config.set('removedirs.bootstrap', {
folders : [packagingSettings.bootstrap.outputDirectory]
});

require('./config-atpackager-bootstrap-src')(grunt);
require('./config-atpackager-bootstrap-skin')(grunt);

grunt.registerTask('bootstrap', ['atpackager:bootstrap', 'atpackager:bootstrapSkin']);
grunt.registerTask('bootstrap', ['src', 'atpackager:bootstrap', 'atpackager:bootstrapSkin']);

};
4 changes: 4 additions & 0 deletions build/grunt-config/config-checkStyle.js
Expand Up @@ -27,6 +27,10 @@ module.exports = function (grunt) {
source : {
src : [
'src/aria/**/*.js',
// Excludes generated files:
'!src/aria/bootstrap.js',
'!src/aria/bootstrap-node.js',
'!src/aria/noderError/**',
// Using node.js globals
'!src/aria/node.js',
// Resource and skin definitions use the global Aria without require
Expand Down
2 changes: 1 addition & 1 deletion build/grunt-config/config-packaging.js
Expand Up @@ -30,7 +30,7 @@ module.exports = function (grunt) {
bootstrap : {
outputDirectory : getPath('../target/bootstrap'),
files : require('../config/files-bootstrap.json'),
checkGlobalsFiles : ['**/*.js', '!aria/noderError/**'],
checkGlobalsFiles : ['**/*.js', '!aria/noderError/**', '!aria/bootstrap.js', '!aria/bootstrap-node.js'],
bootstrapFileName : 'aria/' + pkg.name + '-' + pkg.version + '.js'
},
prod : {
Expand Down
10 changes: 4 additions & 6 deletions scripts/server.js
Expand Up @@ -77,16 +77,14 @@ app.get("/playground/dev", function (req, res) {
model : req.query.model
});
});
// Rename bootstrap prefixing with ariatemplates- this fixes runIsolated in dev mode
app.get("/aria-templates/dev/aria/ariatemplates-bootstrap.js", function (req, res) {
res.sendfile(path.normalize(__dirname + "/../build/target/bootstrap/aria/ariatemplates-" + pkg.version + ".js"));
});
app.get("/aria-templates/dev/aria/css/atskin.js", function (req, res) {
res.sendfile(path.normalize(__dirname + "/../build/target/bootstrap/aria/css/atskin-" + pkg.version + ".js"));
res.sendfile(path.normalize(__dirname + "/../src/aria/bootstrap.js"));
});
// Static CSS files for views and tools
app.use("/css", express.static(__dirname + "/assets/css"));
// Non minified version points to bootstrap folder
app.use("/aria-templates/dev", express.static(__dirname + "/../build/target/bootstrap"));
// Non minified version points to src folder
app.use("/aria-templates/dev", express.static(__dirname + "/../src"));
// Minified version points to standard build (npm install)
app.use("/aria-templates", express.static(__dirname + "/../build/target/production"));
// Test classpath redirects to test folder
Expand Down
4 changes: 2 additions & 2 deletions src/aria/node.js
@@ -1,6 +1,6 @@
/* global Aria:true, aria:true */
var vm = require("vm"), fs = require("fs"), path = require("path");
var ariaRootFolderPath = path.normalize(__dirname + "/../../build/target/bootstrap/");
var ariaRootFolderPath = path.normalize(__dirname + "/../");

/* aria and Aria are going to be global */
aria = {};
Expand All @@ -19,7 +19,7 @@ global.load = function (filePath) {
};

try {
require(ariaRootFolderPath + "aria/node.js");
require(ariaRootFolderPath + "aria/bootstrap-node.js");

// For all the other classes we use IO, define our node transport
Aria.classDefinition({
Expand Down
8 changes: 5 additions & 3 deletions test/test.htm
Expand Up @@ -32,6 +32,8 @@
isAmaBuild = !!(document.location.pathname.match(/\/aria\-templates(-\w+)?\/test\//));
if (isAmaBuild) {
atversion = "1.1-SNAPSHOT";
} else if (devFiles) {
atversion = "bootstrap"; // atversion is not used in this case
} else {
alert("Need an 'atversion=x.y.z' in the query string.");
}
Expand All @@ -58,9 +60,9 @@
}
} else {
if (devFiles) {
ariaRootPath = "../build/target/bootstrap/";
bootstrapFile = "aria/ariatemplates-" + atversion + ".js";
skinFile = "aria/css/" + skinName + "-" + atversion + ".js";
ariaRootPath = "../src/";
bootstrapFile = "aria/bootstrap.js";
skinFile = "aria/css/" + skinName + ".js";
} else {
ariaRootPath = "../build/target/production/";
bootstrapFile = "aria/ariatemplates-" + atversion + ".js";
Expand Down

0 comments on commit a12ab4b

Please sign in to comment.