You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2015/10/20 22:41:25 UTC
[1/4] cordova-lib git commit: CB-9675 OSX App Icons are not properly
copied.
Repository: cordova-lib
Updated Branches:
refs/heads/master a49e67fc1 -> d077f056e
CB-9675 OSX App Icons are not properly copied.
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/8b667d89
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/8b667d89
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/8b667d89
Branch: refs/heads/master
Commit: 8b667d89311f825f984e38d9ce35891b069ed753
Parents: a49e67f
Author: Tobias Bocanegra <tr...@adobe.com>
Authored: Wed Sep 16 20:29:29 2015 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Tue Oct 20 13:00:06 2015 -0700
----------------------------------------------------------------------
cordova-lib/src/cordova/metadata/osx_parser.js | 169 ++++++++++++++++++++
cordova-lib/src/platforms/platformsConfig.json | 2 +-
2 files changed, 170 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/8b667d89/cordova-lib/src/cordova/metadata/osx_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/osx_parser.js b/cordova-lib/src/cordova/metadata/osx_parser.js
new file mode 100644
index 0000000..f359635
--- /dev/null
+++ b/cordova-lib/src/cordova/metadata/osx_parser.js
@@ -0,0 +1,169 @@
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+/* jshint sub:true */
+
+var fs = require('fs'),
+ unorm = require('unorm'),
+ path = require('path'),
+ xcode = require('xcode'),
+ util = require('../util'),
+ events = require('../../events'),
+ shell = require('shelljs'),
+ plist = require('plist'),
+ Q = require('q'),
+ Parser = require('./Parser'),
+ ios_parser = require('./ios_parser'),
+ ConfigParser = require('../../configparser/ConfigParser'),
+ CordovaError = require('../../CordovaError');
+
+function osx_parser(project) {
+
+ try {
+ var xcodeproj_dir = fs.readdirSync(project).filter(function(e) { return e.match(/\.xcodeproj$/i); })[0];
+ if (!xcodeproj_dir) throw new CordovaError('The provided path "' + project + '" is not a Cordova OS X project.');
+
+ // Call the base class constructor
+ Parser.call(this, 'osx', project);
+
+ this.xcodeproj = path.join(project, xcodeproj_dir);
+ this.originalName = this.xcodeproj.substring(this.xcodeproj.lastIndexOf(path.sep)+1, this.xcodeproj.indexOf('.xcodeproj'));
+ this.cordovaproj = path.join(project, this.originalName);
+ } catch(e) {
+ console.error(e);
+ throw new CordovaError('The provided path "'+project+'" is not a Cordova OS X project.');
+ }
+ this.path = unorm.nfd(project);
+ this.pbxproj = path.join(this.xcodeproj, 'project.pbxproj');
+ this.config_path = path.join(this.cordovaproj, 'config.xml');
+}
+
+require('util').inherits(osx_parser, ios_parser);
+
+module.exports = osx_parser;
+
+// Returns a promise.
+osx_parser.prototype.update_from_config = function(config) {
+ if (config instanceof ConfigParser) {
+ } else {
+ return Q.reject(new Error('update_from_config requires a ConfigParser object'));
+ }
+ // CB-6992 it is necessary to normalize characters
+ // because node and shell scripts handles unicode symbols differently
+ // We need to normalize the name to NFD form since iOS uses NFD unicode form
+ var name = unorm.nfd(config.name());
+ var pkg = config.ios_CFBundleIdentifier() || config.packageName();
+ var version = config.version();
+
+ // Update package id (bundle id)
+ var plistFile = path.join(this.cordovaproj, this.originalName + '-Info.plist');
+ var infoPlist = plist.parse(fs.readFileSync(plistFile, 'utf8'));
+ infoPlist['CFBundleIdentifier'] = pkg;
+
+ // Update version (bundle version)
+ infoPlist['CFBundleShortVersionString'] = version;
+ var CFBundleVersion = config.ios_CFBundleVersion() || default_CFBundleVersion(version);
+ infoPlist['CFBundleVersion'] = CFBundleVersion;
+
+ var info_contents = plist.build(infoPlist);
+ info_contents = info_contents.replace(/<string>[\s\r\n]*<\/string>/g,'<string></string>');
+ fs.writeFileSync(plistFile, info_contents, 'utf-8');
+ events.emit('verbose', 'Wrote out OS X Bundle Identifier to "' + pkg + '"');
+ events.emit('verbose', 'Wrote out OS X Bundle Version to "' + version + '"');
+
+ // Update icons
+ var icons = config.getIcons('osx');
+ var platformRoot = this.cordovaproj;
+ var appRoot = util.isCordova(platformRoot);
+
+ // See https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/OSXHIGuidelines/Designing.html
+ // for application images sizes reference.
+ var platformIcons = [
+ {dest: 'icon-512x512.png', width: 512, height: 512},
+ {dest: 'icon-256x256.png', width: 256, height: 256},
+ {dest: 'icon-128x128.png', width: 128, height: 128},
+ {dest: 'icon-64x64.png', width: 64, height: 64},
+ {dest: 'icon-32x32.png', width: 32, height: 32},
+ {dest: 'icon-16x16.png', width: 16, height: 16}
+ ];
+
+ platformIcons.forEach(function (item) {
+ var icon = icons.getBySize(item.width, item.height) || icons.getDefault();
+ if (icon){
+ var src = path.join(appRoot, icon.src),
+ dest = path.join(platformRoot, 'Images.xcassets/AppIcon.appiconset/', item.dest);
+ events.emit('verbose', 'Copying icon from ' + src + ' to ' + dest);
+ shell.cp('-f', src, dest);
+ }
+ });
+
+ var parser = this;
+ return this.update_build_settings(config).then(function() {
+ if (name == parser.originalName) {
+ events.emit('verbose', 'OS X Product Name has not changed (still "' + parser.originalName + '")');
+ return Q();
+ }
+
+ // Update product name inside pbxproj file
+ var proj = new xcode.project(parser.pbxproj);
+ try {
+ proj.parseSync();
+ } catch (err) {
+ return Q.reject(new Error('An error occured during parsing of project.pbxproj. Start weeping. Output: ' + err));
+ }
+
+ proj.updateProductName(name);
+ fs.writeFileSync(parser.pbxproj, proj.writeSync(), 'utf-8');
+
+ // Move the xcodeproj and other name-based dirs over.
+ shell.mv(path.join(parser.cordovaproj, parser.originalName + '-Info.plist'), path.join(parser.cordovaproj, name + '-Info.plist'));
+ shell.mv(path.join(parser.cordovaproj, parser.originalName + '-Prefix.pch'), path.join(parser.cordovaproj, name + '-Prefix.pch'));
+ shell.mv(parser.xcodeproj, path.join(parser.path, name + '.xcodeproj'));
+ shell.mv(parser.cordovaproj, path.join(parser.path, name));
+
+ // Update self object with new paths
+ var old_name = parser.originalName;
+ parser = new module.exports(parser.path);
+
+ // Hack this shi*t
+ var pbx_contents = fs.readFileSync(parser.pbxproj, 'utf-8');
+ pbx_contents = pbx_contents.split(old_name).join(name);
+ fs.writeFileSync(parser.pbxproj, pbx_contents, 'utf-8');
+ events.emit('verbose', 'Wrote out OS X Product Name and updated XCode project file names from "'+old_name+'" to "' + name + '".');
+
+ return Q();
+ });
+};
+
+// Construct a default value for CFBundleVersion as the version with any
+// -rclabel stripped=.
+function default_CFBundleVersion(version) {
+ return version.split('-')[0];
+}
+
+// Converts cordova specific representation of target device to XCode value
+function parseTargetDevicePreference(value) {
+ if (!value) return null;
+ var map = { 'universal': '"1,2"', 'handset': '"1"', 'tablet': '"2"'};
+ if (map[value.toLowerCase()]) {
+ return map[value.toLowerCase()];
+ }
+ events.emit('warn', 'Unknown target-device preference value: "' + value + '".');
+ return null;
+}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/8b667d89/cordova-lib/src/platforms/platformsConfig.json
----------------------------------------------------------------------
diff --git a/cordova-lib/src/platforms/platformsConfig.json b/cordova-lib/src/platforms/platformsConfig.json
index 0a3f1e4..461bb8e 100644
--- a/cordova-lib/src/platforms/platformsConfig.json
+++ b/cordova-lib/src/platforms/platformsConfig.json
@@ -8,7 +8,7 @@
},
"osx": {
"hostos": ["darwin"],
- "parser_file": "../cordova/metadata/ios_parser",
+ "parser_file": "../cordova/metadata/osx_parser",
"handler_file": "../plugman/platforms/ios",
"url": "https://git-wip-us.apache.org/repos/asf?p=cordova-osx.git",
"version": "~4.0.0"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[2/4] cordova-lib git commit: CB-9675 OSX App Icons are not properly
copied.
Posted by st...@apache.org.
CB-9675 OSX App Icons are not properly copied.
- removing unused function
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/34bfac7c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/34bfac7c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/34bfac7c
Branch: refs/heads/master
Commit: 34bfac7cf53ed2b85dc49a184c8fa8548cb564b0
Parents: 8b667d8
Author: Tobias Bocanegra <tr...@adobe.com>
Authored: Wed Sep 16 20:34:49 2015 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Tue Oct 20 13:00:07 2015 -0700
----------------------------------------------------------------------
cordova-lib/src/cordova/metadata/osx_parser.js | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/34bfac7c/cordova-lib/src/cordova/metadata/osx_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/osx_parser.js b/cordova-lib/src/cordova/metadata/osx_parser.js
index f359635..c87993d 100644
--- a/cordova-lib/src/cordova/metadata/osx_parser.js
+++ b/cordova-lib/src/cordova/metadata/osx_parser.js
@@ -155,15 +155,4 @@ osx_parser.prototype.update_from_config = function(config) {
// -rclabel stripped=.
function default_CFBundleVersion(version) {
return version.split('-')[0];
-}
-
-// Converts cordova specific representation of target device to XCode value
-function parseTargetDevicePreference(value) {
- if (!value) return null;
- var map = { 'universal': '"1,2"', 'handset': '"1"', 'tablet': '"2"'};
- if (map[value.toLowerCase()]) {
- return map[value.toLowerCase()];
- }
- events.emit('warn', 'Unknown target-device preference value: "' + value + '".');
- return null;
-}
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[4/4] cordova-lib git commit: @trivial fix test errors. This closes
#310
Posted by st...@apache.org.
@trivial fix test errors. This closes #310
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/d077f056
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/d077f056
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/d077f056
Branch: refs/heads/master
Commit: d077f056eb5d12720a95142aeceaecfa16addb69
Parents: 4670dd6
Author: Tobias Bocanegra <tr...@adobe.com>
Authored: Tue Oct 13 20:54:28 2015 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Tue Oct 20 13:00:08 2015 -0700
----------------------------------------------------------------------
cordova-lib/src/cordova/metadata/osx_parser.js | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/d077f056/cordova-lib/src/cordova/metadata/osx_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/osx_parser.js b/cordova-lib/src/cordova/metadata/osx_parser.js
index ddbb327..87744cf 100644
--- a/cordova-lib/src/cordova/metadata/osx_parser.js
+++ b/cordova-lib/src/cordova/metadata/osx_parser.js
@@ -31,7 +31,6 @@ var fs = require('fs'),
Parser = require('./parser'),
ios_parser = require('./ios_parser'),
ConfigParser = require('cordova-common').ConfigParser,
- URL = require('url'),
CordovaError = require('cordova-common').CordovaError;
function osx_parser(project) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[3/4] cordova-lib git commit: @trivial update to latest structural
changes
Posted by st...@apache.org.
@trivial update to latest structural changes
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/4670dd6e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/4670dd6e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/4670dd6e
Branch: refs/heads/master
Commit: 4670dd6ee90dff3ff4e2897d09b51c97cece7290
Parents: 34bfac7
Author: Tobias Bocanegra <tr...@adobe.com>
Authored: Tue Oct 13 20:48:47 2015 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Tue Oct 20 13:00:07 2015 -0700
----------------------------------------------------------------------
cordova-lib/src/cordova/metadata/osx_parser.js | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4670dd6e/cordova-lib/src/cordova/metadata/osx_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/osx_parser.js b/cordova-lib/src/cordova/metadata/osx_parser.js
index c87993d..ddbb327 100644
--- a/cordova-lib/src/cordova/metadata/osx_parser.js
+++ b/cordova-lib/src/cordova/metadata/osx_parser.js
@@ -24,14 +24,15 @@ var fs = require('fs'),
path = require('path'),
xcode = require('xcode'),
util = require('../util'),
- events = require('../../events'),
+ events = require('cordova-common').events,
shell = require('shelljs'),
plist = require('plist'),
Q = require('q'),
- Parser = require('./Parser'),
+ Parser = require('./parser'),
ios_parser = require('./ios_parser'),
- ConfigParser = require('../../configparser/ConfigParser'),
- CordovaError = require('../../CordovaError');
+ ConfigParser = require('cordova-common').ConfigParser,
+ URL = require('url'),
+ CordovaError = require('cordova-common').CordovaError;
function osx_parser(project) {
@@ -134,6 +135,8 @@ osx_parser.prototype.update_from_config = function(config) {
// Move the xcodeproj and other name-based dirs over.
shell.mv(path.join(parser.cordovaproj, parser.originalName + '-Info.plist'), path.join(parser.cordovaproj, name + '-Info.plist'));
shell.mv(path.join(parser.cordovaproj, parser.originalName + '-Prefix.pch'), path.join(parser.cordovaproj, name + '-Prefix.pch'));
+ // CB-8914 remove userdata otherwise project is un-usable in xcode
+ shell.rm('-rf',path.join(parser.xcodeproj,'xcuserdata/'));
shell.mv(parser.xcodeproj, path.join(parser.path, name + '.xcodeproj'));
shell.mv(parser.cordovaproj, path.join(parser.path, name));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org