Permalink
Browse files

Bumped version to 1.8.0. Updated changelog. Fixed bug with merging no…

…n-xml i18n files. Added legacy /i18n and /platform directory detection which will break the build if found. Updated .gitignore with generated /i18n and /platform. Fixed regex in Alloy hook's log message handling.
  • Loading branch information...
1 parent a0ad6f3 commit 977a2c147e809ccd1c05d197d54828c3e7660150 @cb1kenobi cb1kenobi committed Mar 15, 2016
@@ -683,6 +683,10 @@ exports.mergeI18N = function mergeI18N(src, dest, opts) {
return walk(srcFile, destFile);
}
+ if (!/\.xml$/.test(srcFile)) {
+ return;
+ }
+
if (!fs.existsSync(destFile)) {
logger.debug('Writing ' + destFile.yellow);
return U.copyFileSync(srcFile, destFile);
@@ -695,6 +699,14 @@ exports.mergeI18N = function mergeI18N(src, dest, opts) {
var srcXml = U.XML.parseFromFile(srcFile);
var srcDoc = srcXml.documentElement;
+ if (!destDoc) {
+ U.die('Error processing "' + destFile + '"');
+ }
+
+ if (!srcDoc) {
+ U.die('Error processing "' + srcFile + '"');
+ }
+
_.each(destDoc.getElementsByTagName('string'), function (node) {
var name = node.getAttribute('name');
existing[name] = node;
@@ -98,6 +98,50 @@ module.exports = function(args, program) {
titaniumFolder = platforms[buildPlatform].titaniumFolder;
otherPlatforms = _.without(CONST.PLATFORM_FOLDERS, titaniumFolder);
+ // check the platform and i18n to see if it was generated by us last time
+ var destI18NDir = path.join(paths.project, 'i18n');
+ var destPlatformDir = path.join(paths.project, 'platform', buildPlatform === 'iphone' ? 'ios' : buildPlatform);
+ if (fs.existsSync(destI18NDir) && !fs.existsSync(path.join(destI18NDir, 'alloy_generated'))) {
+ U.die([
+ 'Detected legacy "/i18n" directory in project directory.',
+ 'Please move the "/i18n" directory to "/app/i18n" for Alloy 1.8.0 or later.'
+ ]);
+ }
+ if (fs.existsSync(destPlatformDir) && !fs.existsSync(path.join(destPlatformDir, 'alloy_generated'))) {
+ U.die([
+ 'Detected legacy "/platform" directory in project directory.',
+ 'Please move the "/platform" directory to "/app/platform" for Alloy 1.8.0 or later.'
+ ]);
+ }
+
+ // check that the .gitignore is looking good
+ var gitignoreFile = path.join(paths.project, '.gitignore');
+ if (fs.existsSync(gitignoreFile)) {
+ var folders = {
+ '/i18n': false,
+ '/platform': false,
+ '/Resources': false
+ };
+ fs.readFileSync(gitignoreFile).toString().split('\n').forEach(function (line) {
+ line = line.trim();
+ if (/^\/?i18n(\/.*)?$/.test(line)) {
+ folders['/i18n'] = true;
+ } else if (/^\/?platform(\/.*)?$/.test(line)) {
+ folders['/platform'] = true;
+ } else if (/^\/?Resources(\/.*)?$/.test(line)) {
+ folders['/Resources'] = true;
+ }
+ });
+ var warned = false;
+ Object.keys(folders).some(function (dir) {
+ if (!folders[dir]) {
+ logger.warn('Generated "' + dir + '" folder is not in ignored by Git, please add it to your .gitignore');
+ warned = true;
+ }
+ });
+ warned && logger.debug();
+ }
+
// allow to filter the file to compile
if (!alloyConfig.file) {
restrictionPath = null;
@@ -254,11 +298,15 @@ module.exports = function(args, program) {
});
}
+ function generateMessage(dir) {
+ return 'This directory is generated from the "/app/' + dir + '" and "/app/theme/<name>/' + dir + '" directories.\n\n' +
+ 'Do not modify any files in this directory. Your changes will be lost on next build.\n\n' +
+ 'Please make sure "/' + dir + '" is added to your version control\'s ignore list (i.e. .gitignore).';
+ }
+
// copy the platform and theme platform directories
var sourcePlatformDirs;
- var destPlatformDir = path.join(paths.project, 'platform', buildPlatform);
if (buildPlatform === 'ios' || buildPlatform === 'iphone') {
- destPlatformDir = path.join(paths.project, 'platform', 'ios');
sourcePlatformDirs = [ 'platform/iphone', 'platform/ios' ];
var iPhonePlatformDir = path.join(paths.project, 'platform', 'iphone');
if (fs.existsSync(iPhonePlatformDir)) {
@@ -272,37 +320,34 @@ module.exports = function(args, program) {
logger.debug('Resetting ' + destPlatformDir.yellow);
wrench.rmdirSyncRecursive(destPlatformDir);
}
+ wrench.mkdirSyncRecursive(destPlatformDir, 0755);
+ fs.writeFileSync(path.join(destPlatformDir, 'alloy_generated'), generateMessage('platform'));
sourcePlatformDirs.forEach(function (dir) {
var dirs = [ dir ];
theme && dirs.push('themes/' + theme + '/' + dir);
dirs.forEach(function (dir) {
dir = path.join(paths.app, dir);
if (fs.existsSync(dir)) {
- fs.existsSync(destPlatformDir) || wrench.mkdirSyncRecursive(destPlatformDir, 0755);
logger.debug('Copying ' + dir.yellow + ' --> ' + destPlatformDir.yellow);
- wrench.copyDirSyncRecursive(dir, destPlatformDir);
+ wrench.copyDirSyncRecursive(dir, destPlatformDir, { preserve: true });
}
});
});
logger.debug('');
// copy the i18n and i18n platform directories
- // init i18n search paths
var sourceI18NPaths = [ path.join(paths.app, 'i18n') ];
if (theme) {
sourceI18NPaths.push(path.join(paths.app, 'themes', theme, 'i18n'));
}
- // widgetDirs.forEach(function (widget) {
- // sourceI18NPaths.push(path.join(widget.dir, 'i18n'));
- // });
- var destI18NDir = path.join(paths.project, 'i18n');
if (fs.existsSync(destI18NDir)) {
logger.debug('Resetting ' + destI18NDir.yellow);
wrench.rmdirSyncRecursive(destI18NDir);
}
+ wrench.mkdirSyncRecursive(destI18NDir, 0755);
+ fs.writeFileSync(path.join(destI18NDir, 'alloy_generated'), generateMessage('i18n'));
sourceI18NPaths.forEach(function (dir) {
if (fs.existsSync(dir)) {
- fs.existsSync(destI18NDir) || wrench.mkdirSyncRecursive(destI18NDir, 0755);
CU.mergeI18N(dir, destI18NDir, { override: true });
}
});
View
@@ -82,4 +82,4 @@ var printMessage = function(msg, level, color) {
}
}
printLine(msg);
-};
+};
View
@@ -331,7 +331,6 @@ exports.getWidgetDirectories = function(appDir) {
}
function findWidgetAsNodeModule(id) {
-
var wFile;
try {
wFile = resolve.sync(path.join(CONST.NPM_WIDGET_PREFIX + id, 'widget'), { basedir: path.join(appDir,'..'), extensions: [ '.json' ], paths: paths() });
View
@@ -1,5 +1,12 @@
## Alloy Release Notes
+### Release 1.8.0
+
+#### Fixed
+ * [ALOY-1365](https://jira.appcelerator.org/browse/ALOY-1365): Added support
+ for Alloy-specific i18n and platform folders for both the whole Alloy app
+ and overridable at the theme level. Improved widget i18n support.
+
### Release 1.7.6 - (08/26/2015)
#### Fixed
View
@@ -126,7 +126,7 @@ exports.init = function (logger, config, cli, appc) {
// process each line of output from alloy
function checkLine(line) {
var re = new RegExp(
- '(?:\u001b\\[\\d+m)?\\[?(' +
+ '^(?:\u001b\\[\\d+m)?\\[?(' +
logger.getLevels().join('|') +
')\\]?\s*(?:\u001b\\[\\d+m)?(.*)', 'i'
);
View
@@ -14,7 +14,7 @@
"mobileweb",
"appc-client"
],
- "version": "1.7.35",
+ "version": "1.8.0",
"author": "Appcelerator, Inc. <info@appcelerator.com>",
"maintainers": [
{
@@ -1,10 +1,12 @@
.DS_Store
-Resources
+/Resources
+/platform
+/i18n
build.log
build
npm-debug.log
tmp
.map
.project
.settings
-Thumbs.db
+Thumbs.db
@@ -1,10 +1,12 @@
.DS_Store
-Resources
+/Resources
+/platform
+/i18n
build.log
build
npm-debug.log
tmp
.map
.project
.settings
-Thumbs.db
+Thumbs.db

0 comments on commit 977a2c1

Please sign in to comment.