Skip to content
Permalink
Browse files
updated paths, added config handling, cordova-lib tests passing, uses…
… events to log
  • Loading branch information
purplecabbage committed Apr 6, 2017
1 parent 28040f0 commit 0ffe8a53439196f8f938340f875765e7c11bde25
Showing 4 changed files with 67 additions and 21 deletions.
@@ -2,8 +2,8 @@
"name": "cordova-platform-test",
"version": "0.0.2",
"description": "Platform that simply stubs the platformAPI for testing and education",
"create": "src/create",
"main": "src/Api.js",
"create": "src/bin/create",
"main": "src/cordova/Api.js",
"scripts": {
"cover": "istanbul cover --root bin/templates/cordova --print detail jasmine",
"jshint": "jshint src && jshint spec",
@@ -33,13 +33,15 @@ var path = require('path');
var ConfigParser = require('cordova-common').ConfigParser;
var Api = require('../cordova/Api');


var argv = require('nopt')({
'help' : Boolean,
'cli' : Boolean,
'shared' : Boolean, // alias for --link
'link' : Boolean
}, { 'd' : '--verbose' });


var projectPath = argv.argv.remain[0];

if (argv.help || !projectPath) {
@@ -53,15 +55,15 @@ if (argv.help || !projectPath) {
process.exit(0);
}
else {
var config = {};
var config = new ConfigParser(path.resolve(__dirname, '../config.xml'));

// apply overrides (package and project names
// if (argv.argv.remain[1]) {
// config.setPackageName(argv.argv.remain[1]);
// }
// if (argv.argv.remain[2]) {
// config.setName(argv.argv.remain[2]);
// }
if (argv.argv.remain[1]) {
config.setPackageName(argv.argv.remain[1]);
}
if (argv.argv.remain[2]) {
config.setName(argv.argv.remain[2]);
}

var options = {
cli: argv.cli,
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<widget xmlns = "http://www.w3.org/ns/widgets"
id = "io.cordova.helloCordova"
version = "2.0.0">
<name>Hello Cordova</name>

<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>

<author href="http://cordova.io" email="dev@cordova.apache.org">
Apache Cordova Team
</author>

<!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
<content src="index.html" />

</widget>
@@ -8,6 +8,9 @@
var shell = require('shelljs');
var path = require('path');

var CordovaLogger = require('cordova-common').CordovaLogger;
var selfEvents = require('cordova-common').events;

var PLATFORM_NAME = 'testplatform';

function setupEvents(externalEventEmitter) {
@@ -46,25 +49,32 @@ function Api(platform, platformRootDir, events) {

Api.createPlatform = function (destination, config, options, events) {

events = setupEvents(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
var apiSrcPath = __dirname; // default value
// does options contain the info we desire?
if(options && options.platformDetails) {
apiPath = path.join(options.platformDetails.libDir, '**');
}

var projectName = config ? config.name() : "HelloCordova";

events.emit('log', 'Creating Cordova project for cordova-platform-test:');
events.emit('log', '\tPath: ' + destination);
events.emit('log', '\tName: ' + projectName);

shell.mkdir(destination);

// move a copy of our api to the new project
shell.cp(apiPath, path.join(destination, 'cordova'));
shell.cp('-r',apiSrcPath, destination);

// move our node_modules
var srcModulePath = path.join(__dirname,'../../node_modules');
shell.cp('-r',srcModulePath,destination);

// I promise I will return
return Promise.resolve(new Api(PLATFORM_NAME,destination,events));

var result = Promise.resolve();
result.then(function(){
return new Api(PLATFORM_NAME,destination,events);
});
return result;
};


0 comments on commit 0ffe8a5

Please sign in to comment.