1 | #!/usr/bin/env node
|
2 |
|
3 | /*
|
4 | Licensed to the Apache Software Foundation (ASF) under one
|
5 | or more contributor license agreements. See the NOTICE file
|
6 | distributed with this work for additional information
|
7 | regarding copyright ownership. The ASF licenses this file
|
8 | to you under the Apache License, Version 2.0 (the
|
9 | "License"); you may not use this file except in compliance
|
10 | with the License. You may obtain a copy of the License at
|
11 |
|
12 | http://www.apache.org/licenses/LICENSE-2.0
|
13 |
|
14 | Unless required by applicable law or agreed to in writing,
|
15 | software distributed under the License is distributed on an
|
16 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
17 | KIND, either express or implied. See the License for the
|
18 | specific language governing permissions and limitations
|
19 | under the License.
|
20 | */
|
21 |
|
22 | var path = require('path');
|
23 | var ConfigParser = require('cordova-common').ConfigParser;
|
24 | var Api = require('../template/cordova/Api');
|
25 |
|
26 | var argv = require('nopt')({
|
27 | 'help' : Boolean,
|
28 | 'guid': String,
|
29 | 'silent': Boolean,
|
30 | 'verbose': Boolean
|
31 | }, { 'd' : '--verbose' });
|
32 |
|
33 | if (argv.help || argv.argv.remain.length === 0) {
|
34 | console.log('Usage: create PathToProject [ PackageName [ AppName [ CustomTemplate ] ] ] [--guid=<GUID string>]');
|
35 | console.log(' PathToProject : The path to where you wish to create the project');
|
36 | console.log(' PackageName : The namespace for the project (default is Cordova.Example)');
|
37 | console.log(' AppName : The name of the application (default is CordovaAppProj)');
|
38 | console.log(' CustomTemplate: The path to project template overrides');
|
39 | console.log(' (will be copied over default platform template files)');
|
40 | console.log(' --guid : The App\'s GUID (default is random generated)');
|
41 | console.log('examples:');
|
42 | console.log(' create C:\\Users\\anonymous\\Desktop\\MyProject');
|
43 | console.log(' create C:\\Users\\anonymous\\Desktop\\MyProject io.Cordova.Example AnApp');
|
44 | process.exit(1);
|
45 | }
|
46 |
|
47 | var config = new ConfigParser(path.resolve(__dirname, '../template/config.xml'));
|
48 |
|
49 | if (argv.argv.remain[1]) config.setPackageName(argv.argv.remain[1]);
|
50 | if (argv.argv.remain[2]) config.setName(argv.argv.remain[2]);
|
51 |
|
52 | var options = {
|
53 | guid: argv.guid,
|
54 | customTemplate: argv.argv.remain[3]
|
55 | };
|
56 |
|
57 | require('../template/cordova/lib/loggingHelper').adjustLoggerLevel(options);
|
58 |
|
59 | Api.createPlatform(argv.argv.remain[0], config, options).done();
|