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 | /*
|
23 | * create a Cordova/iOS project
|
24 | *
|
25 | * USAGE
|
26 | * ./create <path_to_new_project> <package_name> <project_name>
|
27 | *
|
28 | * EXAMPLE
|
29 | * ./create ~/Desktop/radness org.apache.cordova.radness Radness
|
30 | */
|
31 |
|
32 | var path = require('path');
|
33 | var ConfigParser = require('cordova-common').ConfigParser;
|
34 | var Api = require('./templates/scripts/cordova/Api');
|
35 |
|
36 | var argv = require('nopt')({
|
37 | 'help' : Boolean,
|
38 | 'cli' : Boolean,
|
39 | 'shared' : Boolean, // alias for --link
|
40 | 'link' : Boolean
|
41 | }, { 'd' : '--verbose' });
|
42 |
|
43 | var projectPath = argv.argv.remain[0];
|
44 |
|
45 | if (argv.help || !projectPath) {
|
46 | console.log('Usage: $0 [--link] [--cli] <path_to_new_project> <package_name> <project_name> [<project_template_dir>]');
|
47 | console.log(' --link (optional): Link directly against the shared copy of the CordovaLib instead of a copy of it.');
|
48 | console.log(' --cli (optional): Use the CLI-project template.');
|
49 | console.log(' <path_to_new_project>: Path to your new Cordova iOS project');
|
50 | console.log(' <package_name>: Package name, following reverse-domain style convention');
|
51 | console.log(' <project_name>: Project name');
|
52 | console.log(' <project_template_dir>: Path to project template (override).');
|
53 | process.exit(0);
|
54 | }
|
55 |
|
56 | // use default configuration file from project template
|
57 | var config = new ConfigParser(path.resolve(__dirname, 'templates/project/__PROJECT_NAME__/config.xml'));
|
58 |
|
59 | // apply overrides (package and project names
|
60 | if (argv.argv.remain[1]) config.setPackageName(argv.argv.remain[1]);
|
61 | if (argv.argv.remain[2]) config.setName(argv.argv.remain[2]);
|
62 |
|
63 | var options = {
|
64 | cli: argv.cli,
|
65 | link: argv.link || argv.shared,
|
66 | customTemplate: argv.argv.remain[3],
|
67 | };
|
68 |
|
69 | require('./templates/scripts/cordova/loggingHelper').adjustLoggerLevel(argv);
|
70 |
|
71 | Api.createPlatform(projectPath, config, options).done();
|