UNPKG

2.54 kBPlain TextView Raw
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
22var path = require('path');
23var ConfigParser = require('cordova-common').ConfigParser;
24var Api = require('../template/cordova/Api');
25
26var argv = require('nopt')({
27 'help' : Boolean,
28 'guid': String,
29 'silent': Boolean,
30 'verbose': Boolean
31}, { 'd' : '--verbose' });
32
33if (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
47var config = new ConfigParser(path.resolve(__dirname, '../template/config.xml'));
48
49if (argv.argv.remain[1]) config.setPackageName(argv.argv.remain[1]);
50if (argv.argv.remain[2]) config.setName(argv.argv.remain[2]);
51
52var options = {
53 guid: argv.guid,
54 customTemplate: argv.argv.remain[3]
55};
56
57require('../template/cordova/lib/loggingHelper').adjustLoggerLevel(options);
58
59Api.createPlatform(argv.argv.remain[0], config, options).done();