Skip to content
Permalink
Browse files
Merge pull request #1 from stevengill/master
updated tests, added readme
  • Loading branch information
carynbear committed Jul 20, 2016
2 parents 2e36fd6 + fa5e348 commit da2e8567a12a0be7208df389b375f72e5f33aa33
Showing 9 changed files with 204 additions and 117 deletions.
@@ -0,0 +1,12 @@
language: node_js
sudo: false
node_js:
- "0.10"
- "0.12"
- "4.2"
- "5.4"
- "6.0"
install:
- npm install
script:
- npm test
@@ -0,0 +1,41 @@
<!--
#
# 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.
#
-->

[![Build status](https://ci.appveyor.com/api/projects/status/pejqbhscb3mlnt74)](https://ci.appveyor.com/project/stevengill/cordova-create)
[![Build Status](https://travis-ci.org/stevengill/cordova-create.svg?branch=master)](https://travis-ci.org/stevengill/cordova-create)

# cordova-create

This module is used for creating cordova style projects.

## Usage:
:
```
var create = require('cordova-create');
create(dir, id, name, cfg, extEvents);
```

`dir` - directory where the project will be created. Required.
`id` - app id. Required (but can be "undefined").
`name` - app name. Required (but can be "undefined").
`cfg` - extra config to be saved in .cordova/config.json Required (but can be "{}").
`extEvents` - An EventEmitter instance that will be used for logging purposes. Required (but can be "undefined").
@@ -0,0 +1,23 @@
<!--
#
# 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.
#
-->
# Cordova-create Release Notes


@@ -0,0 +1,12 @@
# appveyor file
# http://www.appveyor.com/docs/appveyor-yml

install:
- npm install

build: off

test_script:
- node --version
- npm --version
- npm test
@@ -211,6 +211,8 @@ module.exports = function(dir, optionalId, optionalName, cfg, extEvents) {
//handle when input wants to specify sub-directory (specified in index.js as "dirname" export);
var isSubDir = false;
try {
// Delete cached require incase one exists
delete require.cache[require.resolve(input_directory)];
var templatePkg = require(input_directory);
if (templatePkg && templatePkg.dirname){
import_from_path = templatePkg.dirname;
@@ -407,4 +409,4 @@ function writeToConfigJson(project_root, opts, autoPersist) {
} else {
return json;
}
}
}
@@ -33,13 +33,13 @@
"valid-identifier": "0.0.1"
},
"devDependencies": {
"jasmine-node": "1.14.5",
"jasmine": "^2.4.1",
"jshint": "2.5.8"
},
"scripts": {
"test": "npm run jshint && npm run jasmine",
"jshint": "jshint index.js spec/create.spec.js",
"jasmine": "node node_modules/jasmine-node/bin/jasmine-node --color spec"
"jasmine": "jasmine spec/create.spec.js"
},
"contributors": [
{
@@ -20,7 +20,6 @@
var helpers = require('./helpers'),
path = require('path'),
shell = require('shelljs'),
Q = require('q'),
events = require('cordova-common').events,
ConfigParser = require('cordova-common').ConfigParser,
create = require('../index'),
@@ -71,22 +70,22 @@ var configNPM = {
}
};

describe('cordova create checks for valid-identifier', function(done) {
describe('cordova create checks for valid-identifier', function() {
it('should reject reserved words from start of id', function(done) {
create('projectPath', 'int.bob', 'appName')
.fail(function(err) {
expect(err.message).toBe('App id contains a reserved word, or is not a valid identifier.');
})
.fin(done);
});
}, 60000);

it('should reject reserved words from end of id', function(done) {
create('projectPath', 'bob.class', 'appName')
.fail(function(err) {
expect(err.message).toBe('App id contains a reserved word, or is not a valid identifier.');
})
.fin(done);
});
}, 60000);
});


@@ -186,34 +185,29 @@ describe('create end-to-end', function() {
events.on('results', function(res) { results = res; });

it('should successfully run with Git URL', function(done) {
// Call cordova create with no args, should return help.
Q()
.then(function() {
// Create a real project
return create(project, appId, appName, configGit);
})
.then(checkProject)
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
// Call cordova create with no args, should return help.)
// Create a real project
return create(project, appId, appName, configGit)
.then(checkProject)
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
}, 60000);

it('should successfully run with NPM package', function(done) {
// Call cordova create with no args, should return help.
Q()
.then(function() {
// Create a real project
return create(project, appId, appName, configNPM);
})
.then(checkProject)
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
});

// Create a real project
return create(project, appId, appName, configNPM)
.then(checkProject)
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
}, 60000);

it('should successfully run with template not having a package.json at toplevel', function(done) {
// Call cordova create with no args, should return help.
@@ -226,23 +220,20 @@ describe('create end-to-end', function() {
}
}
};
Q()
.then(function() {
// Create a real project
return create(project, appId, appName, config);
})
.then(checkProject)
.then(function(){
// Check that we got the right config.xml
var configXml = new ConfigParser(path.join(project, 'config.xml'));
expect(configXml.description()).toEqual('this is the very correct config.xml');
})
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
});
// Create a real project
return create(project, appId, appName, config)
.then(checkProject)
.then(function(){
// Check that we got the right config.xml
var configXml = new ConfigParser(path.join(project, 'config.xml'));
expect(configXml.description()).toEqual('this is the very correct config.xml');
})
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
}, 60000);

it('should successfully run with template having package.json and no sub directory', function(done) {
// Call cordova create with no args, should return help.
@@ -255,18 +246,15 @@ describe('create end-to-end', function() {
}
}
};
Q()
.then(function() {
// Create a real project
return create(project, appId, appName, config);
})
.then(checkProject)
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
});
// Create a real project
return create(project, appId, appName, config)
.then(checkProject)
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
}, 60000);

it('should successfully run with template having package.json, and subdirectory, and no package.json in subdirectory', function(done) {
// Call cordova create with no args, should return help.
@@ -279,53 +267,46 @@ describe('create end-to-end', function() {
}
}
};
Q()
.then(function() {
// Create a real project
return create(project, appId, appName, config);
})
.then(checkProject)
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
});

// Create a real project
return create(project, appId, appName, config)
.then(checkProject)
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
}, 60000);


it('should successfully run with template having package.json, and subdirectory, and package.json in subdirectory', function(done) {
// Call cordova create with no args, should return help.
var config = configSubDirPkgJson;
Q()
.then(function() {
// Create a real project
project = project + '1';
return create(project, appId, appName, config);
})
.then(checkSubDir)
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
});
// Create a real project
project = project + '1';
return create(project, appId, appName, config)
.then(checkSubDir)
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
}, 60000);

it('should successfully run config.xml in the www folder and move it outside', function(done) {
// Call cordova create with no args, should return help.
var config = configConfigInWww;
Q()
.then(function() {
// Create a real project
project = project + '2';
return create(project, appId, appName, config);
})
.then(checkConfigXml)
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
});

project = project + '2';
// Create a real project
return create(project, appId, appName, config)
.then(checkConfigXml)
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
}, 60000);

it('should successfully run with www folder as the template', function(done) {
var config = {
@@ -337,17 +318,14 @@ describe('create end-to-end', function() {
}
}
};
Q()
.then(function() {
project = project + '3';
return create(project, appId, appName, config);
})
.then(checkConfigXml)
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
});
project = project + '3';
return create(project, appId, appName, config)
.then(checkConfigXml)
.fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
}, 60000);

});

0 comments on commit da2e856

Please sign in to comment.