cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [7/7] git commit: moving to a .cordova directory
Date Thu, 04 Oct 2012 07:41:40 GMT
moving to a .cordova directory


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/commit/0605f051
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/0605f051
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/0605f051

Branch: refs/heads/cordova-client
Commit: 0605f051620126141a58ed9ecbca6ba8fc2d0d72
Parents: c6d3886
Author: Fil Maj <maj.fil@gmail.com>
Authored: Wed Oct 3 16:18:36 2012 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Wed Oct 3 16:18:36 2012 -0700

----------------------------------------------------------------------
 spec/build.spec.js                      |   19 ++++++++++++++-
 spec/create.spec.js                     |   33 ++++++++++++++++++--------
 spec/metadata/blackberry_parser.spec.js |   12 ++++----
 src/create.js                           |   27 +++++++++++++++++++-
 src/metadata/blackberry_parser.js       |   12 ++++----
 5 files changed, 78 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/0605f051/spec/build.spec.js
----------------------------------------------------------------------
diff --git a/spec/build.spec.js b/spec/build.spec.js
index db360cd..b36861e 100644
--- a/spec/build.spec.js
+++ b/spec/build.spec.js
@@ -7,6 +7,8 @@ var cordova = require('../cordova'),
     android_parser = require('../src/metadata/android_parser'),
     ios_parser = require('../src/metadata/ios_parser'),
     blackberry_parser = require('../src/metadata/blackberry_parser'),
+    fixtures = path.join(__dirname, 'fixtures'),
+    hooks = path.join(fixtures, 'hooks'),
     tempDir = path.join(__dirname, '..', 'temp');
 
 var cwd = process.cwd();
@@ -147,7 +149,7 @@ describe('build command', function() {
             });
             it('should call blackberry_parser\'s update_project', function() {
                 var cb = jasmine.createSpy();
-                fs.writeFileSync(path.join(tempDir, '.cordova'), JSON.stringify({
+                fs.writeFileSync(path.join(tempDir, '.cordova', 'config.json'), JSON.stringify({
                     blackberry:{
                         qnx:{}
                     }
@@ -235,4 +237,19 @@ describe('build command', function() {
             });
         });
     });
+
+    describe('hooks', function() {
+        beforeEach(function() {
+            cordova.create(tempDir);
+            process.chdir(tempDir);
+            cordova.platform('add', 'android');
+        });
+
+        afterEach(function() {
+            process.chdir(cwd);
+        });
+
+        it('should delegate before hooks to the hooker module');
+        it('should delegate after hooks to the hooker module');
+    });
 });

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/0605f051/spec/create.spec.js
----------------------------------------------------------------------
diff --git a/spec/create.spec.js b/spec/create.spec.js
index cb3bd03..33f8651 100644
--- a/spec/create.spec.js
+++ b/spec/create.spec.js
@@ -6,24 +6,37 @@ var cordova = require('../cordova'),
 
 describe('create command', function () {
     beforeEach(function() {
-        // Make a temp directory
         shell.rm('-rf', tempDir);
-        shell.mkdir('-p', tempDir);
     });
 
     it('should print out help txt if no directory is provided', function() {
-        var cwd = process.cwd();
-        this.after(function() {
-            process.chdir(cwd);
-        });
-        process.chdir(tempDir);
         expect(cordova.create()).toMatch(/synopsis/i);
     });
     it('should create a cordova project in the specified directory if parameter is provided',
function() {
         cordova.create(tempDir);
-        var dotc = path.join(tempDir, '.cordova');
+        var dotc = path.join(tempDir, '.cordova', 'config.json');
         expect(fs.lstatSync(dotc).isFile()).toBe(true);
         expect(JSON.parse(fs.readFileSync(dotc, 'utf8')).name).toBe("Hello Cordova");
+        var hooks = path.join(tempDir, '.cordova', 'hooks');
+        expect(fs.existsSync(hooks)).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'before_platform_add'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'after_platform_add'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'before_platform_rm'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'after_platform_rm'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'before_platform_ls'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'after_platform_ls'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'before_plugin_add'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'after_plugin_add'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'before_plugin_rm'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'after_plugin_rm'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'before_plugin_ls'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'after_plugin_ls'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'before_build'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'after_build'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'before_emulate'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'after_emulate'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'before_docs'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'after_docs'))).toBe(true);
     });
     it('should throw if the directory is already a cordova project', function() {
         shell.mkdir('-p', path.join(tempDir, '.cordova'));
@@ -35,14 +48,14 @@ describe('create command', function () {
     it('should create a cordova project in the specified dir with specified name if provided',
function() {
         cordova.create(tempDir, "balls");
 
-        expect(fs.lstatSync(path.join(tempDir, '.cordova')).isFile()).toBe(true);
+        expect(fs.lstatSync(path.join(tempDir, '.cordova', 'config.json')).isFile()).toBe(true);
 
         expect(fs.readFileSync(path.join(tempDir, 'www', 'config.xml')).toString('utf8')).toMatch(/<name>balls<\/name>/);
     });
     it('should create a cordova project in the specified dir with specified name and id if
provided', function() {
         cordova.create(tempDir, "birdy.nam.nam", "numnum");
 
-        expect(fs.lstatSync(path.join(tempDir, '.cordova')).isFile()).toBe(true);
+        expect(fs.lstatSync(path.join(tempDir, '.cordova', 'config.json')).isFile()).toBe(true);
 
         var config = fs.readFileSync(path.join(tempDir, 'www', 'config.xml')).toString('utf8');
         expect(config).toMatch(/<name>numnum<\/name>/);

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/0605f051/spec/metadata/blackberry_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/blackberry_parser.spec.js b/spec/metadata/blackberry_parser.spec.js
index 7526df2..9f2c4b4 100644
--- a/spec/metadata/blackberry_parser.spec.js
+++ b/spec/metadata/blackberry_parser.spec.js
@@ -115,14 +115,14 @@ describe('blackberry project parser', function() {
             ioFake();
             expect(spyConfig).toHaveBeenCalled();
         });
-        it('should invoke get_blackberry_environment if .cordova file has no BB config',
function() {
+        it('should invoke get_blackberry_environment if .cordova/config.json file has no
BB config', function() {
             var spyEnv = spyOn(parser, 'get_blackberry_environment');
             parser.update_project(cfg);
             expect(spyEnv).toHaveBeenCalled();
         });
-        it('should not invoke get_blackberry_environment if .cordova file has BB config',
function() {
+        it('should not invoke get_blackberry_environment if .cordova/config.json file has
BB config', function() {
             var spyEnv = spyOn(parser, 'get_blackberry_environment');
-            fs.writeFileSync(path.join(tempDir, '.cordova'), JSON.stringify({
+            fs.writeFileSync(path.join(tempDir, '.cordova', 'config.json'), JSON.stringify({
                 blackberry:{
                     qnx:{
                     }
@@ -131,7 +131,7 @@ describe('blackberry project parser', function() {
             parser.update_project(cfg);
             expect(spyEnv).not.toHaveBeenCalled();
         });
-        it('should write out project properties with no BB config in .cordova', function()
{
+        it('should write out project properties with no BB config in .cordova/config.json',
function() {
             var spyProps = spyOn(parser, 'write_project_properties');
             var cb = jasmine.createSpy();
             runs(function() {
@@ -143,10 +143,10 @@ describe('blackberry project parser', function() {
                 expect(spyProps).toHaveBeenCalled();
             });
         });
-        it('should write out project properties with BB config in .cordova', function() {
+        it('should write out project properties with BB config in .cordova/config.json',
function() {
             var spyProps = spyOn(parser, 'write_project_properties');
             var cb = jasmine.createSpy();
-            fs.writeFileSync(path.join(tempDir, '.cordova'), JSON.stringify({
+            fs.writeFileSync(path.join(tempDir, '.cordova/config.json'), JSON.stringify({
                 blackberry:{
                     qnx:{
                     }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/0605f051/src/create.js
----------------------------------------------------------------------
diff --git a/src/create.js b/src/create.js
index 0b33ecf..d99b04c 100644
--- a/src/create.js
+++ b/src/create.js
@@ -38,11 +38,34 @@ module.exports = function create (dir, id, name) {
     }
 
     // Create basic project structure.
+    shell.mkdir('-p', dotCordova);
     shell.mkdir('-p', path.join(dir, 'platforms'));
     shell.mkdir('-p', path.join(dir, 'plugins'));
+    var hooks = path.join(dotCordova, 'hooks');
+    shell.mkdir('-p', hooks);
 
-    // Write out .cordova file with a simple json manifest
-    fs.writeFileSync(dotCordova, JSON.stringify({
+    // Add directories for hooks
+    shell.mkdir(path.join(hooks, 'after_build'));
+    shell.mkdir(path.join(hooks, 'after_docs'));
+    shell.mkdir(path.join(hooks, 'after_emulate'));
+    shell.mkdir(path.join(hooks, 'after_platform_add'));
+    shell.mkdir(path.join(hooks, 'after_platform_rm'));
+    shell.mkdir(path.join(hooks, 'after_platform_ls'));
+    shell.mkdir(path.join(hooks, 'after_plugin_add'));
+    shell.mkdir(path.join(hooks, 'after_plugin_ls'));
+    shell.mkdir(path.join(hooks, 'after_plugin_rm'));
+    shell.mkdir(path.join(hooks, 'before_build'));
+    shell.mkdir(path.join(hooks, 'before_docs'));
+    shell.mkdir(path.join(hooks, 'before_emulate'));
+    shell.mkdir(path.join(hooks, 'before_platform_add'));
+    shell.mkdir(path.join(hooks, 'before_platform_rm'));
+    shell.mkdir(path.join(hooks, 'before_platform_ls'));
+    shell.mkdir(path.join(hooks, 'before_plugin_add'));
+    shell.mkdir(path.join(hooks, 'before_plugin_ls'));
+    shell.mkdir(path.join(hooks, 'before_plugin_rm'));
+
+    // Write out .cordova/config.json file with a simple json manifest
+    fs.writeFileSync(path.join(dotCordova, 'config.json'), JSON.stringify({
         id:id,
         name:name
     }));

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/0605f051/src/metadata/blackberry_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/blackberry_parser.js b/src/metadata/blackberry_parser.js
index b5ae45d..6728c05 100644
--- a/src/metadata/blackberry_parser.js
+++ b/src/metadata/blackberry_parser.js
@@ -28,7 +28,7 @@ module.exports.prototype = {
 
         // Do we have BB config?
         var projectRoot = util.isCordova(this.path);
-        var dotFile = path.join(projectRoot, '.cordova');
+        var dotFile = path.join(projectRoot, '.cordova', 'config.json');
         var dot = JSON.parse(fs.readFileSync(dotFile, 'utf-8'));
         if (dot.blackberry === undefined || dot.blackberry.qnx === undefined) {
             this.get_blackberry_environment(function() {
@@ -73,7 +73,7 @@ module.exports.prototype = {
         var projFile = path.join(this.path, 'project.properties');
         var props = fs.readFileSync(projFile, 'utf-8');
 
-        var dotFile = path.join(projectRoot, '.cordova');
+        var dotFile = path.join(projectRoot, '.cordova', 'config.json');
         var dot = JSON.parse(fs.readFileSync(dotFile, 'utf-8'));
 
         props = props.replace(/qnx\.bbwp\.dir=.*\n/, 'qnx.bbwp.dir=' + dot.blackberry.qnx.bbwp
+ '\n');
@@ -87,9 +87,9 @@ module.exports.prototype = {
     get_blackberry_environment:function(callback) {
         // TODO: add other blackberry sub-platforms
         var projectRoot = util.isCordova(this.path);
-        var dotFile = path.join(projectRoot, '.cordova');
+        var dotFile = path.join(projectRoot, '.cordova', 'config.json');
         var dot = JSON.parse(fs.readFileSync(dotFile, 'utf-8'));
-        // Let's save relevant BB SDK + signing info to .cordova
+        // Let's save relevant BB SDK + signing info to .cordova/config.json
         console.log('Looks like we need some of your BlackBerry development environment information.
We\'ll just ask you a few questions and we\'ll be on our way to building.');
         prompt.start();
         prompt.get([{
@@ -116,7 +116,7 @@ module.exports.prototype = {
         }
         ], function(err, results) {
             if (err) throw 'Error during BlackBerry environment config retrieval';
-            // Write out .cordova file
+            // Write out .cordova/config.json file
             if (dot.blackberry === undefined) dot.blackberry = {};
             if (dot.blackberry.qnx === undefined) dot.blackberry.qnx = {};
             dot.blackberry.qnx.bbwp = results.bbwp;
@@ -126,7 +126,7 @@ module.exports.prototype = {
             dot.blackberry.qnx.sim_ip = results.sim_ip;
             dot.blackberry.qnx.sim_password = results.sim_password;
             fs.writeFileSync(dotFile, JSON.stringify(dot), 'utf-8');
-            console.log('Perfect! If you need to change any of these properties, just edit
the .cordova file in the root of your cordova project (it\'s just JSON, you\'ll be OK).');
+            console.log('Perfect! If you need to change any of these properties, just edit
the .cordova/config.json file in the root of your cordova project.');
             if (callback) callback();
         });
     }


Mime
View raw message