You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2013/12/11 22:54:29 UTC
[10/15] js commit: fixing deps
fixing deps
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/31aa7519
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/31aa7519
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/31aa7519
Branch: refs/heads/master
Commit: 31aa751930dcce0e648b85af9ad556f8a0b234c8
Parents: e3e40f5
Author: brianleroux <b...@brian.io>
Authored: Wed Dec 11 12:12:25 2013 +1000
Committer: brianleroux <b...@brian.io>
Committed: Wed Dec 11 12:12:25 2013 +1000
----------------------------------------------------------------------
tasks/lib/bundle.js | 35 +++++++++++++++++++++++++++++++----
tasks/lib/collect-file.js | 3 ++-
tasks/lib/collect-files.js | 34 +++++++++++++++++++++++++++++++---
tasks/lib/compute-commit-id.js | 21 +++++++++++++++++++++
tasks/lib/copy-props.js | 20 +++++++++++++++++++-
tasks/lib/get-module-id.js | 18 ++++++++++++++++++
tasks/lib/packager.js | 13 +------------
tasks/lib/process-white-space.js | 19 +++++++++++++++++++
tasks/lib/strip-header.js | 21 ++++++++++++++++++++-
tasks/lib/write-contents.js | 22 ++++++++++++++++++----
tasks/lib/write-module.js | 22 ++++++++++++++++++++++
tasks/lib/write-script.js | 23 +++++++++++++++++++++--
12 files changed, 223 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/31aa7519/tasks/lib/bundle.js
----------------------------------------------------------------------
diff --git a/tasks/lib/bundle.js b/tasks/lib/bundle.js
index cd4e4af..a8371e3 100644
--- a/tasks/lib/bundle.js
+++ b/tasks/lib/bundle.js
@@ -1,3 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements. See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership. The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License. You may obtain a copy of the
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied. See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
+var fs = require('fs');
+var collectFiles = require('./collect-files');
+var copyProps = require('./copy-props');
+var writeModule = require('./write-module');
+var writeScript = require('./write-script');
+
module.exports = function bundle(platform, debug, commitId) {
var modules = collectFiles('lib/common')
@@ -7,7 +31,9 @@ module.exports = function bundle(platform, debug, commitId) {
copyProps(modules, collectFiles(path.join('lib', platform)));
if (platform === 'test') {
- copyProps(modules, collectFiles(path.join('lib', 'android', 'android'), 'android/'));
+ // FIXME why does 'test' resolve a bunch of android stuff?!
+ var testFilesPath = path.join('lib', 'android', 'android');
+ copyProps(modules, collectFiles(testFilesPath, 'android/'));
}
var output = [];
@@ -16,8 +42,9 @@ module.exports = function bundle(platform, debug, commitId) {
output.push("// " + commitId);
// write header
- output.push('/*', fs.readFileSync('LICENSE-for-js-file.txt', 'utf8'), '*/')
- output.push(';(function() {')
+ var licensePath = path.join(__dirname, 'tasks', 'lib', 'LICENSE-for-js-file.txt');
+ output.push('/*', fs.readFileSync(licensePath, 'utf8'), '*/');
+ output.push(';(function() {');
output.push("var CORDOVA_JS_BUILD_LABEL = '" + commitId + "';");
// write initial scripts
@@ -33,7 +60,7 @@ module.exports = function bundle(platform, debug, commitId) {
for (var i=0; i<moduleIds.length; i++) {
var moduleId = moduleIds[i]
-
+
writeModule(output, modules[moduleId], moduleId, debug)
}
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/31aa7519/tasks/lib/collect-file.js
----------------------------------------------------------------------
diff --git a/tasks/lib/collect-file.js b/tasks/lib/collect-file.js
index 6f62885..849d4e2 100644
--- a/tasks/lib/collect-file.js
+++ b/tasks/lib/collect-file.js
@@ -1,4 +1,5 @@
-
+// FIXME I think this is unused
+// smh
module.exports = function collectFile(dir, id, entry) {
if (!id) id = ''
var moduleId = path.join(id, entry)
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/31aa7519/tasks/lib/collect-files.js
----------------------------------------------------------------------
diff --git a/tasks/lib/collect-files.js b/tasks/lib/collect-files.js
index 13bee5b..f58a208 100644
--- a/tasks/lib/collect-files.js
+++ b/tasks/lib/collect-files.js
@@ -1,14 +1,40 @@
-module.exports = function collectFiles(dir, id) {
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements. See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership. The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License. You may obtain a copy of the
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied. See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
+var fs = require('fs');
+var path = require('path');
+var copyProps = require('./copy-props');
+
+
+function collectFiles(dir, id) {
if (!id) id = ''
var result = {}
var entries = fs.readdirSync(dir)
entries = entries.filter(function(entry) {
- if (entry.match(/\.js$/)) return true
+ if (entry.match(/\.js$/))
+ return true
var stat = fs.statSync(path.join(dir, entry))
- if (stat.isDirectory()) return true
+
+ if (stat.isDirectory())
+ return true
})
entries.forEach(function(entry) {
@@ -26,3 +52,5 @@ module.exports = function collectFiles(dir, id) {
})
return copyProps({}, result)
}
+
+module.exports = collectFiles;
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/31aa7519/tasks/lib/compute-commit-id.js
----------------------------------------------------------------------
diff --git a/tasks/lib/compute-commit-id.js b/tasks/lib/compute-commit-id.js
index beaf418..af0cc37 100644
--- a/tasks/lib/compute-commit-id.js
+++ b/tasks/lib/compute-commit-id.js
@@ -1,3 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements. See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership. The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License. You may obtain a copy of the
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied. See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
+var fs = require('fs')
+var childProcess = require('child_process');
+
module.exports = function computeCommitId(callback, cachedGitVersion) {
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/31aa7519/tasks/lib/copy-props.js
----------------------------------------------------------------------
diff --git a/tasks/lib/copy-props.js b/tasks/lib/copy-props.js
index 8335bc8..e8d1e35 100644
--- a/tasks/lib/copy-props.js
+++ b/tasks/lib/copy-props.js
@@ -1,4 +1,22 @@
-
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements. See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership. The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License. You may obtain a copy of the
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied. See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
+// FIXME should just use underscore or lodash for this
module.exports = function copyProps(target, source) {
for (var key in source) {
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/31aa7519/tasks/lib/get-module-id.js
----------------------------------------------------------------------
diff --git a/tasks/lib/get-module-id.js b/tasks/lib/get-module-id.js
index 4d3cf75..7599f17 100644
--- a/tasks/lib/get-module-id.js
+++ b/tasks/lib/get-module-id.js
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements. See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership. The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License. You may obtain a copy of the
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied. See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
module.exports = function getModuleId(fileName) {
return fileName.match(/(.*)\.js$/)[1]
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/31aa7519/tasks/lib/packager.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager.js b/tasks/lib/packager.js
index 6d0f5ef..3380768 100644
--- a/tasks/lib/packager.js
+++ b/tasks/lib/packager.js
@@ -20,18 +20,7 @@ var fs = require('fs');
var path = require('path');
var bundle = require('./bundle');
var computeCommitId = require('./compute-commit-id');
-/*
-var childProcess = require('child_process');
-var util = require('util');
-var stripHeader = require('./strip-header');
-var copyProps = require('./copy-props');
-var getModuleId = require('./get-module-id');
-var writeContents = require('./write-contents');
-var writeModule = require('./write-module');
-var writeScript = require('./write-script');
-var collectFiles = require('./collect-files');
-var collectFile = require('./collect-file');
-*/
+
module.exports = function generate(platform, useWindowsLineEndings, callback) {
computeCommitId(function(commitId) {
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/31aa7519/tasks/lib/process-white-space.js
----------------------------------------------------------------------
diff --git a/tasks/lib/process-white-space.js b/tasks/lib/process-white-space.js
index f071800..11fb316 100644
--- a/tasks/lib/process-white-space.js
+++ b/tasks/lib/process-white-space.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements. See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership. The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License. You may obtain a copy of the
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied. See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
+
var fs = require('fs');
var path = require('path');
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/31aa7519/tasks/lib/strip-header.js
----------------------------------------------------------------------
diff --git a/tasks/lib/strip-header.js b/tasks/lib/strip-header.js
index de6b25e..ba60692 100644
--- a/tasks/lib/strip-header.js
+++ b/tasks/lib/strip-header.js
@@ -1,5 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements. See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership. The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License. You may obtain a copy of the
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied. See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
-// Strips the license header. Basically only the first multi-line comment up to to the closing */
+// Strips the license header.
+// Basically only the first multi-line comment up to to the closing */
module.exports = function stripHeader(contents, fileName) {
var ls = contents.split(/\r?\n/);
while (ls[0]) {
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/31aa7519/tasks/lib/write-contents.js
----------------------------------------------------------------------
diff --git a/tasks/lib/write-contents.js b/tasks/lib/write-contents.js
index 083245a..4728812 100644
--- a/tasks/lib/write-contents.js
+++ b/tasks/lib/write-contents.js
@@ -1,19 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements. See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership. The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License. You may obtain a copy of the
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied. See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
module.exports = function writeContents(oFile, fileName, contents, debug) {
if (debug) {
contents += '\n//@ sourceURL=' + fileName
-
contents = 'eval(' + JSON.stringify(contents) + ')'
-
// this bit makes it easier to identify modules
// with syntax errors in them
var handler = 'console.log("exception: in ' + fileName + ': " + e);'
handler += 'console.log(e.stack);'
-
contents = 'try {' + contents + '} catch(e) {' + handler + '}'
}
-
else {
contents = '// file: ' + fileName.split("\\").join("/") + '\n' + contents;
}
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/31aa7519/tasks/lib/write-module.js
----------------------------------------------------------------------
diff --git a/tasks/lib/write-module.js b/tasks/lib/write-module.js
index 6d8efde..04a119f 100644
--- a/tasks/lib/write-module.js
+++ b/tasks/lib/write-module.js
@@ -1,3 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements. See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership. The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License. You may obtain a copy of the
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied. See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
+var fs = require('fs');
+var stripHeader = require('./strip-header');
+var writeContents = require('./write-contents');
+
module.exports = function writeModule(oFile, fileName, moduleId, debug) {
var contents = fs.readFileSync(fileName, 'utf8')
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/31aa7519/tasks/lib/write-script.js
----------------------------------------------------------------------
diff --git a/tasks/lib/write-script.js b/tasks/lib/write-script.js
index a666bd5..81d50a6 100644
--- a/tasks/lib/write-script.js
+++ b/tasks/lib/write-script.js
@@ -1,8 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements. See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership. The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License. You may obtain a copy of the
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied. See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
+
var fs = require('fs');
+var writeContents = require('./write-contents');
module.exports = function writeScript(oFile, fileName, debug) {
- var contents = fs.readFileSync(fileName, 'utf8')
-
+ var contents = fs.readFileSync(fileName, 'utf8');
contents = stripHeader(contents, fileName);
writeContents(oFile, fileName, contents, debug);
}