cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [06/13] cordova-test-platform git commit: added platform level scripts
Date Fri, 07 Apr 2017 19:40:55 GMT
added platform level scripts


Project: http://git-wip-us.apache.org/repos/asf/cordova-test-platform/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-test-platform/commit/8303894d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-test-platform/tree/8303894d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-test-platform/diff/8303894d

Branch: refs/heads/master
Commit: 8303894d470483e9a23a166a4be8d3e595fe947b
Parents: c28cfc1
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Tue Apr 4 18:00:53 2017 -0700
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Tue Apr 4 18:00:53 2017 -0700

----------------------------------------------------------------------
 spec/create.spec.js     |  98 ++++++++++++++++++---------------
 spec/projectApi.spec.js |   2 +-
 src/Api.js              | 123 ------------------------------------------
 src/bin/create          |   2 +-
 src/cordova/Api.js      | 125 +++++++++++++++++++++++++++++++++++++++++++
 src/cordova/build       |  20 +++++++
 src/cordova/clean       |  20 +++++++
 src/cordova/log         |  20 +++++++
 src/cordova/run         |  20 +++++++
 src/cordova/version     |  26 +++++++++
 10 files changed, 289 insertions(+), 167 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-test-platform/blob/8303894d/spec/create.spec.js
----------------------------------------------------------------------
diff --git a/spec/create.spec.js b/spec/create.spec.js
index b59b8c6..f4eb1c3 100644
--- a/spec/create.spec.js
+++ b/spec/create.spec.js
@@ -17,12 +17,12 @@
  under the License.
  */
 
-var shell = require('shelljs'),
-    spec = __dirname,
-    path = require('path'),
-    util = require('util');
+var shell = require('shelljs');
+var fs = require('fs');
+var path = require('path');
+var util = require('util');
 
-var cordova_bin = path.join(spec, '../src/bin');
+var cordova_bin = path.join(__dirname, '../src/bin');// is this the same on all platforms?
 var tmpDir = path.join(__dirname, '../temp');
 
 function createAndBuild(projectname, projectid) {
@@ -30,34 +30,48 @@ function createAndBuild(projectname, projectid) {
     var command;
 
     // remove existing folder
-    //command =  path.join(tmpDir, projectname);
     shell.rm('-rf', tmpDir);
     shell.mkdir(tmpDir);
 
+    var createScriptPath = path.join(cordova_bin,'create');
 
     // create the project
-    command = util.format('"%s/create" "%s/%s" "%s" "%s"', cordova_bin, tmpDir, projectname,
projectid, projectname);
-
-    //console.log("command = " + command);
-
-    // shell.echo(command);
+    command = util.format('"%s" "%s/%s" "%s" "%s"', createScriptPath, tmpDir, projectname,
projectid, projectname);
+    shell.echo(command);
     return_code = shell.exec(command).code;
     expect(return_code).toBe(0);
 
+
+    var tempCordovaScriptsPath = path.join(tmpDir,projectname,"cordova");
+
+    // created project has scripts in the cordova folder
+    // build, clean, log, run, version
+    expect(fs.existsSync(path.join(tempCordovaScriptsPath,'build'))).toBe(true);
+    expect(fs.existsSync(path.join(tempCordovaScriptsPath,'clean'))).toBe(true);
+    expect(fs.existsSync(path.join(tempCordovaScriptsPath,'log'))).toBe(true);
+    expect(fs.existsSync(path.join(tempCordovaScriptsPath,'run'))).toBe(true);
+    expect(fs.existsSync(path.join(tempCordovaScriptsPath,'version'))).toBe(true);
+
+
     // // build the project
-    // command = util.format('"%s/cordova/build"', path.join(tmpDir, projectname));
-    // //shell.echo(command);
-    // return_code = shell.exec(command, { silent: true }).code;
-    // expect(return_code).toBe(0);
+    command = util.format('"%s/cordova/build"', path.join(tmpDir, projectname));
+    shell.echo(command);
+    return_code = shell.exec(command, { silent: true }).code;
+    expect(return_code).toBe(0);
 
     // clean-up
-    command =  path.join(tmpDir, projectname);
-    shell.rm('-rf', command);
+    shell.rm('-rf', tmpDir);
 }
 
 
 describe('create', function() {
 
+    it('has a create script in bin/cordova',function(){
+        var createScriptPath = path.join(cordova_bin,'create');
+        expect(fs.existsSync(createScriptPath)).toBe(true);
+    });
+
+
     it('create project with ascii name, no spaces', function() {
         var projectname = 'testcreate';
         var projectid = 'com.test.app1';
@@ -65,40 +79,40 @@ describe('create', function() {
         createAndBuild(projectname, projectid);
     });
 
-    it('create project with ascii name, and spaces', function() {
-        var projectname = 'test create';
-        var projectid = 'com.test.app2';
+    // it('create project with ascii name, and spaces', function() {
+    //     var projectname = 'test create';
+    //     var projectid = 'com.test.app2';
 
-        createAndBuild(projectname, projectid);
-    });
+    //     createAndBuild(projectname, projectid);
+    // });
 
-    it('create project with unicode name, no spaces', function() {
-        var projectname = '応応応応用用用用';
-        var projectid = 'com.test.app3';
+    // it('create project with unicode name, no spaces', function() {
+    //     var projectname = '応応応応用用用用';
+    //     var projectid = 'com.test.app3';
 
-        createAndBuild(projectname, projectid);
-    });
+    //     createAndBuild(projectname, projectid);
+    // });
 
-    it('create project with unicode name, and spaces', function() {
-        var projectname = '応応応応 用用用用';
-        var projectid = 'com.test.app4';
+    // it('create project with unicode name, and spaces', function() {
+    //     var projectname = '応応応応 用用用用';
+    //     var projectid = 'com.test.app4';
 
-        createAndBuild(projectname, projectid);
-    });
+    //     createAndBuild(projectname, projectid);
+    // });
 
-    it('create project with ascii+unicode name, no spaces', function() {
-        var projectname = '応応応応hello用用用用';
-        var projectid = 'com.test.app5';
+    // it('create project with ascii+unicode name, no spaces', function() {
+    //     var projectname = '応応応応hello用用用用';
+    //     var projectid = 'com.test.app5';
 
-        createAndBuild(projectname, projectid);
-    });
+    //     createAndBuild(projectname, projectid);
+    // });
 
-    it('create project with ascii+unicode name, and spaces', function() {
-        var projectname = '応応応応 hello 用用用用';
-        var projectid = 'com.test.app6';
+    // it('create project with ascii+unicode name, and spaces', function() {
+    //     var projectname = '応応応応 hello 用用用用';
+    //     var projectid = 'com.test.app6';
 
-        createAndBuild(projectname, projectid);
-    });
+    //     createAndBuild(projectname, projectid);
+    // });
 
 });
 

http://git-wip-us.apache.org/repos/asf/cordova-test-platform/blob/8303894d/spec/projectApi.spec.js
----------------------------------------------------------------------
diff --git a/spec/projectApi.spec.js b/spec/projectApi.spec.js
index f05475e..1f19eeb 100644
--- a/spec/projectApi.spec.js
+++ b/spec/projectApi.spec.js
@@ -30,7 +30,7 @@ describe('can get the Api', function() {
         expect(typeof Api.createPlatform).toBe('function');
 
 // TODO: make this do something real
-        var promise = Api.createPlatform("../tmp");
+        var promise = Api.createPlatform("../fixtures/tmp");
         expect(promise).toBeDefined();
         expect(promise.then).toBeDefined();
         promise.then(function(res) {

http://git-wip-us.apache.org/repos/asf/cordova-test-platform/blob/8303894d/src/Api.js
----------------------------------------------------------------------
diff --git a/src/Api.js b/src/Api.js
deleted file mode 100644
index bbafde7..0000000
--- a/src/Api.js
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
-    this file is found by cordova-lib when you attempt to
-    'cordova platform add PATH' where path is this repo.
-*/
-
-/*jslint node: true */
-
-var shell = require('shelljs');
-var path = require('path');
-
-var PLATFORM_NAME = 'testplatform';
-
-function setupEvents(externalEventEmitter) {
-    if (externalEventEmitter) {
-        // This will make the platform internal events visible outside
-        selfEvents.forwardEventsTo(externalEventEmitter);
-        return externalEventEmitter;
-    }
-
-    // There is no logger if external emitter is not present,
-    // so attach a console logger
-    CordovaLogger.get().subscribe(selfEvents);
-    return selfEvents;
-}
-
-function Api(platform, platformRootDir, events) {
-
-    this.platform = platform || PLATFORM_NAME;
-    this.root = path.resolve(__dirname, '..');
-
-    this.locations = {
-        platformRootDir: platformRootDir,
-        root: this.root,
-        www: path.join(this.root, 'assets/www'),
-        res: path.join(this.root, 'res'),
-        platformWww: path.join(this.root, 'platform_www'),
-        configXml: path.join(this.root, 'res/xml/config.xml'),
-        defaultConfigXml: path.join(this.root, 'cordova/defaults.xml'),
-        build: path.join(this.root, 'build'),
-        // NOTE: Due to platformApi spec we need to return relative paths here
-        cordovaJs: 'bin/templates/project/assets/www/cordova.js',
-        cordovaJsSrc: 'cordova-js-src'
-    };
-
-}
-
-Api.createPlatform = function (destination, config, options, events) {
-
-    // create the destination and the standard place for our api to live
-    // platforms/platformName/cordova/Api.js
-    shell.mkdir(destination);
-    shell.mkdir(path.join(destination,'cordova'));
-
-    var apiPath = path.join(__dirname, 'Api.js'); // default value
-    // does options contain the info we desire?
-    if(options && options.platformDetails) {
-        apiPath = path.join(options.platformDetails.libDir, 'src/Api.js');
-    }
-    // move a copy of our api to the new project
-    shell.cp(apiPath, path.join(destination, 'cordova/Api.js'));
-
-    var result = Promise.resolve();
-    result.then(function(){
-       return new Api(PLATFORM_NAME,destination,events);
-    });
-    return result;
-};
-
-
-Api.updatePlatform = function (destination, options, events) {
-    // console.log("test-platform:Api:updatePlatform");
-    // todo?: create projectInstance and fulfill promise with it.
-    return Promise.resolve();
-};
-
-Api.prototype.getPlatformInfo = function () {
-    console.log("test-platform:Api:getPlatformInfo");
-    // return PlatformInfo object
-
-    return {
-        "locations":this.locations,
-        "root": this.root,
-        "name": this.platform,
-        "version": { "version" : "1.0.0" },
-        "projectConfig": this._config
-    };
-};
-
-Api.prototype.prepare = function (cordovaProject) {
-    console.log("test-platform:Api:prepare");
-    return Promise.resolve();
-};
-
-Api.prototype.addPlugin = function (plugin, installOptions) {
-    console.log("test-platform:Api:addPlugin");
-    return Promise.resolve();
-};
-
-Api.prototype.removePlugin = function (plugin, uninstallOptions) {
-    console.log("test-platform:Api:removePlugin");
-    return Promise.resolve();
-};
-
-Api.prototype.build = function (buildOptions) {
-    console.log("test-platform:Api:build");
-    return Promise.resolve();
-};
-
-Api.prototype.run = function(runOptions) {
-    console.log("test-platform:Api:run");
-};
-
-Api.prototype.clean = function(cleanOptions) {
-    console.log("test-platform:Api:clean");
-    return Promise.resolve();
-};
-
-Api.prototype.requirements = function() {
-    console.log("test-platform:Api:requirements");
-    return true;
-};
-
-module.exports = Api;

http://git-wip-us.apache.org/repos/asf/cordova-test-platform/blob/8303894d/src/bin/create
----------------------------------------------------------------------
diff --git a/src/bin/create b/src/bin/create
index 77bc7e2..ad18549 100755
--- a/src/bin/create
+++ b/src/bin/create
@@ -31,7 +31,7 @@
 
 var path = require('path');
 var ConfigParser = require('cordova-common').ConfigParser;
-var Api = require('../Api');
+var Api = require('../cordova/Api');
 
 var argv = require('nopt')({
     'help' : Boolean,

http://git-wip-us.apache.org/repos/asf/cordova-test-platform/blob/8303894d/src/cordova/Api.js
----------------------------------------------------------------------
diff --git a/src/cordova/Api.js b/src/cordova/Api.js
new file mode 100644
index 0000000..a49193f
--- /dev/null
+++ b/src/cordova/Api.js
@@ -0,0 +1,125 @@
+/*
+    this file is found by cordova-lib when you attempt to
+    'cordova platform add PATH' where path is this repo.
+*/
+
+/*jslint node: true */
+
+var shell = require('shelljs');
+var path = require('path');
+
+var PLATFORM_NAME = 'testplatform';
+
+function setupEvents(externalEventEmitter) {
+    if (externalEventEmitter) {
+        // This will make the platform internal events visible outside
+        selfEvents.forwardEventsTo(externalEventEmitter);
+        return externalEventEmitter;
+    }
+
+    // There is no logger if external emitter is not present,
+    // so attach a console logger
+    CordovaLogger.get().subscribe(selfEvents);
+    return selfEvents;
+}
+
+function Api(platform, platformRootDir, events) {
+
+    this.platform = platform || PLATFORM_NAME;
+    this.root = path.resolve(__dirname, '..');
+
+    this.locations = {
+        platformRootDir: platformRootDir,
+        root: this.root,
+        www: path.join(this.root, 'assets/www'),
+        res: path.join(this.root, 'res'),
+        platformWww: path.join(this.root, 'platform_www'),
+        configXml: path.join(this.root, 'res/xml/config.xml'),
+        defaultConfigXml: path.join(this.root, 'cordova/defaults.xml'),
+        build: path.join(this.root, 'build'),
+        // NOTE: Due to platformApi spec we need to return relative paths here
+        cordovaJs: 'bin/templates/project/assets/www/cordova.js',
+        cordovaJsSrc: 'cordova-js-src'
+    };
+
+}
+
+Api.createPlatform = function (destination, config, options, events) {
+
+    // create the destination and the standard place for our api to live
+    // platforms/platformName/cordova/Api.js
+    shell.mkdir(destination);
+    shell.mkdir(path.join(destination,'cordova'));
+
+    var apiPath = path.join(__dirname, '**'); // default value
+    console.log("apiPath = " + apiPath);
+    // does options contain the info we desire?
+    if(options && options.platformDetails) {
+        apiPath = path.join(options.platformDetails.libDir, '**');
+    }
+
+    // move a copy of our api to the new project
+    shell.cp(apiPath, path.join(destination, 'cordova'));
+
+    var result = Promise.resolve();
+    result.then(function(){
+       return new Api(PLATFORM_NAME,destination,events);
+    });
+    return result;
+};
+
+
+Api.updatePlatform = function (destination, options, events) {
+    // console.log("test-platform:Api:updatePlatform");
+    // todo?: create projectInstance and fulfill promise with it.
+    return Promise.resolve();
+};
+
+Api.prototype.getPlatformInfo = function () {
+    console.log("test-platform:Api:getPlatformInfo");
+    // return PlatformInfo object
+
+    return {
+        "locations":this.locations,
+        "root": this.root,
+        "name": this.platform,
+        "version": { "version" : "1.0.0" },
+        "projectConfig": this._config
+    };
+};
+
+Api.prototype.prepare = function (cordovaProject) {
+    console.log("test-platform:Api:prepare");
+    return Promise.resolve();
+};
+
+Api.prototype.addPlugin = function (plugin, installOptions) {
+    console.log("test-platform:Api:addPlugin");
+    return Promise.resolve();
+};
+
+Api.prototype.removePlugin = function (plugin, uninstallOptions) {
+    console.log("test-platform:Api:removePlugin");
+    return Promise.resolve();
+};
+
+Api.prototype.build = function (buildOptions) {
+    console.log("test-platform:Api:build");
+    return Promise.resolve();
+};
+
+Api.prototype.run = function(runOptions) {
+    console.log("test-platform:Api:run");
+};
+
+Api.prototype.clean = function(cleanOptions) {
+    console.log("test-platform:Api:clean");
+    return Promise.resolve();
+};
+
+Api.prototype.requirements = function() {
+    console.log("test-platform:Api:requirements");
+    return true;
+};
+
+module.exports = Api;

http://git-wip-us.apache.org/repos/asf/cordova-test-platform/blob/8303894d/src/cordova/build
----------------------------------------------------------------------
diff --git a/src/cordova/build b/src/cordova/build
new file mode 100755
index 0000000..86aa8c1
--- /dev/null
+++ b/src/cordova/build
@@ -0,0 +1,20 @@
+#!/usr/bin/env node
+
+/*
+       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.
+*/
+
+console.log("cordova/build");
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-test-platform/blob/8303894d/src/cordova/clean
----------------------------------------------------------------------
diff --git a/src/cordova/clean b/src/cordova/clean
new file mode 100755
index 0000000..1c51169
--- /dev/null
+++ b/src/cordova/clean
@@ -0,0 +1,20 @@
+#!/usr/bin/env node
+
+/*
+       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.
+*/
+
+console.log("cordova/clean");
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-test-platform/blob/8303894d/src/cordova/log
----------------------------------------------------------------------
diff --git a/src/cordova/log b/src/cordova/log
new file mode 100755
index 0000000..bb6fb8c
--- /dev/null
+++ b/src/cordova/log
@@ -0,0 +1,20 @@
+#!/usr/bin/env node
+
+/*
+       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.
+*/
+
+console.log("cordova/log");
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-test-platform/blob/8303894d/src/cordova/run
----------------------------------------------------------------------
diff --git a/src/cordova/run b/src/cordova/run
new file mode 100755
index 0000000..3d37345
--- /dev/null
+++ b/src/cordova/run
@@ -0,0 +1,20 @@
+#!/usr/bin/env node
+
+/*
+       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.
+*/
+
+console.log("cordova/run");
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-test-platform/blob/8303894d/src/cordova/version
----------------------------------------------------------------------
diff --git a/src/cordova/version b/src/cordova/version
new file mode 100755
index 0000000..c68eec1
--- /dev/null
+++ b/src/cordova/version
@@ -0,0 +1,26 @@
+#!/usr/bin/env node
+
+/*
+       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.
+*/
+
+var VERSION = "1.0.1-dev";
+
+module.exports.version = VERSION;
+
+if (!module.parent) {
+    console.log(VERSION);
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message