diff --git a/README.md b/README.md index e787ff29..b0ae9095 100644 --- a/README.md +++ b/README.md @@ -37,21 +37,7 @@ Cordova Android is an Android application library that allows for Cordova-based ## Cordova Android Developer Tools -We recommend using the [Cordova command-line tool](https://www.npmjs.com/package/cordova) to create projects and be able to easily install plugins. - -However, the following scripts can be used instead: - - ./bin/create [path package activity] ... creates the ./example app or a cordova android project - ./bin/check_reqs ....................... checks that your environment is set up for cordova-android development - ./bin/update [path] .................... updates an existing cordova-android project to the version of the framework - -These commands live in a generated Cordova Android project. Any interactions with the emulator require you to have an AVD defined. - - ./cordova/clean ........................ cleans the project - ./cordova/build ........................ calls `clean` then compiles the project - ./cordova/log ........................ streams device or emulator logs to STDOUT - ./cordova/run ........................ calls `build` then deploys to a connected Android device. If no Android device is detected, will launch an emulator and deploy to it. - ./cordova/version ...................... returns the cordova-android version of the current project +Use the [Cordova command-line tool](https://www.npmjs.com/package/cordova) to create projects and install plugins. ## Using Android Studio diff --git a/bin/android_sdk_version.bat b/bin/android_sdk_version.bat deleted file mode 100644 index 65173a8f..00000000 --- a/bin/android_sdk_version.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0android_sdk_version" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'android_sdk_version' script in 'bin' folder, aborting...>&2 - EXIT /B 1 -) diff --git a/bin/check_reqs b/bin/check_reqs deleted file mode 100755 index 1e349cd3..00000000 --- a/bin/check_reqs +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env node - -/* - 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. -*/ - -var check_reqs = require('./templates/cordova/lib/check_reqs'); - -check_reqs.run().then( - function success () { - console.log('Looks like your environment fully supports cordova-android development!'); - }, - function fail (err) { - console.log(err); - process.exit(2); - } -); diff --git a/bin/check_reqs.bat b/bin/check_reqs.bat deleted file mode 100644 index 84d66ad2..00000000 --- a/bin/check_reqs.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0check_reqs" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'check_reqs' script in 'bin' folder, aborting...>&2 - EXIT /B 1 -) diff --git a/bin/create b/bin/create deleted file mode 100755 index 65f239cb..00000000 --- a/bin/create +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env node - -/* - 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. -*/ -var path = require('path'); -var ConfigParser = require('cordova-common').ConfigParser; -var Api = require('./templates/cordova/Api'); - -var argv = require('nopt')({ - help: Boolean, - cli: Boolean, - shared: Boolean, - link: Boolean, - 'activity-name': [String, undefined] -}, { d: '--verbose' }); - -if (argv.help || argv.argv.remain.length === 0) { - console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'create')) + ' [] [--activity-name ] [--link]'); - console.log(' : Path to your new Cordova Android project'); - console.log(' : Package name, following reverse-domain style convention'); - console.log(' : Project name'); - console.log(' : Path to a custom application template to use'); - console.log(' --activity-name : Activity name'); - console.log(' --link will use the CordovaLib project directly instead of making a copy.'); - process.exit(1); -} - -var config = new ConfigParser(path.resolve(__dirname, 'templates/project/res/xml/config.xml')); - -if (argv.argv.remain[1]) config.setPackageName(argv.argv.remain[1]); -if (argv.argv.remain[2]) config.setName(argv.argv.remain[2]); -if (argv['activity-name']) config.setName(argv['activity-name']); - -var options = { - link: argv.link || argv.shared, - customTemplate: argv.argv.remain[3], - activityName: argv['activity-name'] -}; - -require('./templates/cordova/loggingHelper').adjustLoggerLevel(argv); - -Api.createPlatform(argv.argv.remain[0], config, options).catch(err => { - console.error(err); - process.exitCode = 1; -}); diff --git a/bin/create.bat b/bin/create.bat deleted file mode 100644 index 308fbccf..00000000 --- a/bin/create.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0create" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'create' script in 'bin' folder, aborting...>&2 - EXIT /B 1 -) diff --git a/bin/lib/create.js b/bin/lib/create.js index 93be1114..84a1ef30 100755 --- a/bin/lib/create.js +++ b/bin/lib/create.js @@ -144,23 +144,6 @@ function copyScripts (projectPath) { const nodeModulesDir = path.join(ROOT, 'node_modules'); if (fs.existsSync(nodeModulesDir)) fs.copySync(nodeModulesDir, path.join(destScriptsDir, 'node_modules')); - - fs.copySync(path.join(bin, 'check_reqs'), path.join(destScriptsDir, 'check_reqs')); - fs.copySync(path.join(bin, 'check_reqs.bat'), path.join(destScriptsDir, 'check_reqs.bat')); - fs.copySync(path.join(bin, 'android_sdk_version'), path.join(destScriptsDir, 'android_sdk_version')); - fs.copySync(path.join(bin, 'android_sdk_version.bat'), path.join(destScriptsDir, 'android_sdk_version.bat')); - - var check_reqs = path.join(destScriptsDir, 'check_reqs'); - var android_sdk_version = path.join(destScriptsDir, 'android_sdk_version'); - - // TODO: the two files being edited on-the-fly here are shared between - // platform and project-level commands. the below is updating the - // `require` path for the two libraries. if there's a better way to share - // modules across both the repo and generated projects, we should make sure - // to remove/update this. - const templatesCordovaRegex = /templates\/cordova\//; - utils.replaceFileContents(android_sdk_version, templatesCordovaRegex, ''); - utils.replaceFileContents(check_reqs, templatesCordovaRegex, ''); } /** diff --git a/bin/android_sdk_version b/bin/templates/cordova/android_sdk_version similarity index 93% rename from bin/android_sdk_version rename to bin/templates/cordova/android_sdk_version index 764a19f4..c4aa8b86 100755 --- a/bin/android_sdk_version +++ b/bin/templates/cordova/android_sdk_version @@ -19,7 +19,7 @@ under the License. */ -var android_sdk = require('./templates/cordova/lib/android_sdk'); +var android_sdk = require('./lib/android_sdk'); android_sdk.print_newest_available_sdk_target().catch(err => { console.error(err); diff --git a/bin/templates/cordova/build b/bin/templates/cordova/build deleted file mode 100755 index b4e160eb..00000000 --- a/bin/templates/cordova/build +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env node - -/* - 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. -*/ - -var args = process.argv; -var Api = require('./Api'); -var nopt = require('nopt'); -var path = require('path'); - -// Support basic help commands -if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(args[2]) >= 0) { - require('./lib/build').help(); -} - -// Do some basic argument parsing -var buildOpts = nopt({ - verbose: Boolean, - silent: Boolean, - debug: Boolean, - release: Boolean, - nobuild: Boolean, - buildConfig: path -}, { d: '--verbose' }); - -// Make buildOptions compatible with PlatformApi build method spec -buildOpts.argv = buildOpts.argv.original; - -require('./loggingHelper').adjustLoggerLevel(buildOpts); - -new Api().build(buildOpts) - .catch(function (err) { - console.error(err.stack); - process.exit(2); - }); diff --git a/bin/templates/cordova/build.bat b/bin/templates/cordova/build.bat deleted file mode 100644 index 46e966af..00000000 --- a/bin/templates/cordova/build.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0build" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'build' script in 'cordova' folder, aborting...>&2 - EXIT /B 1 -) \ No newline at end of file diff --git a/bin/templates/cordova/clean b/bin/templates/cordova/clean deleted file mode 100755 index 5173d14b..00000000 --- a/bin/templates/cordova/clean +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env node - -/* - 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. -*/ - -var Api = require('./Api'); -var path = require('path'); -var nopt = require('nopt'); - -// Support basic help commands -if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) { - console.log('Usage: ' + path.relative(process.cwd(), process.argv[1])); - console.log('Cleans the project directory.'); - process.exit(0); -} - -// Do some basic argument parsing -var opts = nopt({ - verbose: Boolean, - silent: Boolean -}, { d: '--verbose' }); - -// Make buildOptions compatible with PlatformApi clean method spec -opts.argv = opts.argv.original; - -// Skip cleaning prepared files when not invoking via cordova CLI. -opts.noPrepare = true; - -require('./loggingHelper').adjustLoggerLevel(opts); - -new Api().clean(opts) - .catch(function (err) { - console.error(err.stack); - process.exit(2); - }); diff --git a/bin/templates/cordova/clean.bat b/bin/templates/cordova/clean.bat deleted file mode 100644 index 445ef6e1..00000000 --- a/bin/templates/cordova/clean.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0clean" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'clean' script in 'cordova' folder, aborting...>&2 - EXIT /B 1 -) \ No newline at end of file diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js index 71b93cc5..40c93355 100644 --- a/bin/templates/cordova/lib/build.js +++ b/bin/templates/cordova/lib/build.js @@ -241,26 +241,3 @@ PackageInfo.prototype = { propertiesParser.save(); } }; - -module.exports.help = function () { - console.log('Usage: ' + path.relative(process.cwd(), path.join('../build')) + ' [flags] [Signed APK flags]'); - console.log('Flags:'); - console.log(' \'--debug\': will build project in debug mode (default)'); - console.log(' \'--release\': will build project for release'); - console.log(' \'--nobuild\': will skip build process (useful when using run command)'); - console.log(' \'--prepenv\': don\'t build, but copy in build scripts where necessary'); - console.log(' \'--versionCode=#\': Override versionCode for this build. Useful for uploading multiple APKs.'); - console.log(' \'--minSdkVersion=#\': Override minSdkVersion for this build.'); - console.log(' \'--maxSdkVersion=#\': Override maxSdkVersion for this build. (Not Recommended)'); - console.log(' \'--targetSdkVersion=#\': Override targetSdkVersion for this build.'); - console.log(' \'--gradleArg=\': Extra args to pass to the gradle command. Use one flag per arg. Ex. --gradleArg=-PcdvBuildMultipleApks=true'); - console.log(' \'--packageType=\': Builds an APK or a bundle'); - console.log(''); - console.log('Signed APK flags (overwrites debug/release-signing.proprties) :'); - console.log(' \'--keystore=\': Key store used to build a signed archive. (Required)'); - console.log(' \'--alias=\': Alias for the key store. (Required)'); - console.log(' \'--storePassword=\': Password for the key store. (Optional - prompted)'); - console.log(' \'--password=\': Password for the key. (Optional - prompted)'); - console.log(' \'--keystoreType\': Type of the keystore. (Optional)'); - process.exit(0); -}; diff --git a/bin/templates/cordova/lib/install-device b/bin/templates/cordova/lib/install-device deleted file mode 100755 index 1340a4d5..00000000 --- a/bin/templates/cordova/lib/install-device +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env node - -/* - 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. -*/ - -const { resolve, install } = require('./target'); - -var args = process.argv; -const targetSpec = { type: 'device' }; - -if (args.length > 2) { - if (args[2].substring(0, 9) === '--target=') { - targetSpec.id = args[2].substring(9, args[2].length); - } else { - console.error('ERROR : argument \'' + args[2] + '\' not recognized.'); - process.exit(2); - } -} - -resolve(targetSpec).then(install).catch(err => { - console.error('ERROR: ' + err); - process.exit(2); -}); diff --git a/bin/templates/cordova/lib/install-device.bat b/bin/templates/cordova/lib/install-device.bat deleted file mode 100644 index 0be9ebd0..00000000 --- a/bin/templates/cordova/lib/install-device.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0install-device" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'install-device' script in 'cordova\lib' folder, aborting...>&2 - EXIT /B 1 -) \ No newline at end of file diff --git a/bin/templates/cordova/lib/install-emulator b/bin/templates/cordova/lib/install-emulator deleted file mode 100755 index f73cd050..00000000 --- a/bin/templates/cordova/lib/install-emulator +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env node - -/* - 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. -*/ - -const { resolve, install } = require('./target'); - -var args = process.argv; -const targetSpec = { type: 'emulator' }; - -if (args.length > 2) { - if (args[2].substring(0, 9) === '--target=') { - targetSpec.id = args[2].substring(9, args[2].length); - } else { - console.error('ERROR : argument \'' + args[2] + '\' not recognized.'); - process.exit(2); - } -} - -resolve(targetSpec).then(install).catch(err => { - console.error('ERROR: ' + err); - process.exit(2); -}); diff --git a/bin/templates/cordova/lib/install-emulator.bat b/bin/templates/cordova/lib/install-emulator.bat deleted file mode 100644 index 21e88c53..00000000 --- a/bin/templates/cordova/lib/install-emulator.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0install-emulator" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'install-emulator' script in 'cordova\lib' folder, aborting...>&2 - EXIT /B 1 -) \ No newline at end of file diff --git a/bin/templates/cordova/lib/list-devices.bat b/bin/templates/cordova/lib/list-devices.bat deleted file mode 100644 index 7e04cf94..00000000 --- a/bin/templates/cordova/lib/list-devices.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0list-devices" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'list-devices' script in 'cordova\lib' folder, aborting...>&2 - EXIT /B 1 -) \ No newline at end of file diff --git a/bin/templates/cordova/lib/list-emulator-images.bat b/bin/templates/cordova/lib/list-emulator-images.bat deleted file mode 100644 index 55c399d7..00000000 --- a/bin/templates/cordova/lib/list-emulator-images.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0list-emulator-images" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'list-emulator-images' script in 'cordova\lib' folder, aborting...>&2 - EXIT /B 1 -) diff --git a/bin/templates/cordova/lib/list-started-emulators b/bin/templates/cordova/lib/list-started-emulators deleted file mode 100755 index 2a83e03a..00000000 --- a/bin/templates/cordova/lib/list-started-emulators +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env node - -/* - 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. -*/ - -var emulators = require('./emulator'); - -// Usage support for when args are given -require('./check_reqs').check_android().then(function () { - emulators.list_started().then(function (emulator_list) { - emulator_list && emulator_list.forEach(function (emu) { - console.log(emu); - }); - }, function (err) { - console.error('ERROR: ' + err); - process.exit(2); - }); -}); diff --git a/bin/templates/cordova/lib/list-started-emulators.bat b/bin/templates/cordova/lib/list-started-emulators.bat deleted file mode 100644 index 99547aa4..00000000 --- a/bin/templates/cordova/lib/list-started-emulators.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0list-started-emulators" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'list-started-emulators' script in 'cordova\lib' folder, aborting...>&2 - EXIT /B 1 -) \ No newline at end of file diff --git a/bin/templates/cordova/lib/log.js b/bin/templates/cordova/lib/log.js deleted file mode 100644 index 4e087651..00000000 --- a/bin/templates/cordova/lib/log.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - 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. -*/ - -var path = require('path'); -var os = require('os'); -var execa = require('execa'); -var ROOT = path.join(__dirname, '..', '..'); - -/* - * Starts running logcat in the shell. - * Returns a promise. - */ -module.exports.run = function () { - var adb = execa('adb', ['logcat'], { cwd: os.tmpdir(), stderr: 'inherit' }); - - adb.stdout.on('data', function (data) { - var lines = data ? data.toString().split('\n') : []; - var out = lines.filter(function (x) { return x.indexOf('nativeGetEnabledTags') < 0; }); - console.log(out.join('\n')); - }); - - return adb; -}; - -module.exports.help = function () { - console.log('Usage: ' + path.relative(process.cwd(), path.join(ROOT, 'cordova', 'log'))); - console.log('Gives the logcat output on the command line.'); - process.exit(0); -}; diff --git a/bin/templates/cordova/lib/run.js b/bin/templates/cordova/lib/run.js index 17416592..89de076e 100644 --- a/bin/templates/cordova/lib/run.js +++ b/bin/templates/cordova/lib/run.js @@ -17,7 +17,6 @@ under the License. */ -var path = require('path'); var emulator = require('./emulator'); const target = require('./target'); var PackageType = require('./PackageType'); @@ -84,16 +83,3 @@ module.exports.run = function (runOptions) { }); }); }; - -module.exports.help = function () { - console.log('Usage: ' + path.relative(process.cwd(), process.argv[1]) + ' [options]'); - console.log('Build options :'); - console.log(' --debug : Builds project in debug mode'); - console.log(' --release : Builds project in release mode'); - console.log(' --nobuild : Runs the currently built project without recompiling'); - console.log('Deploy options :'); - console.log(' --device : Will deploy the built project to a device'); - console.log(' --emulator : Will deploy the built project to an emulator if one exists'); - console.log(' --target= : Installs to the target with the specified id.'); - process.exit(0); -}; diff --git a/bin/templates/cordova/lib/start-emulator b/bin/templates/cordova/lib/start-emulator deleted file mode 100755 index 20c92b70..00000000 --- a/bin/templates/cordova/lib/start-emulator +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env node - -/* - 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. -*/ - -var emulator = require('./emulator'); -var args = process.argv; - -var install_target; -if (args.length > 2) { - if (args[2].substring(0, 9) === '--target=') { - install_target = args[2].substring(9, args[2].length); - } else { - console.error('ERROR : argument \'' + args[2] + '\' not recognized.'); - process.exit(2); - } -} - -emulator.start(install_target).catch(function (err) { - console.error('ERROR: ' + err); - process.exit(2); -}); diff --git a/bin/templates/cordova/lib/start-emulator.bat b/bin/templates/cordova/lib/start-emulator.bat deleted file mode 100644 index 82c6f890..00000000 --- a/bin/templates/cordova/lib/start-emulator.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0start-emulator" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'start-emulator' script in 'cordova\lib' folder, aborting...>&2 - EXIT /B 1 -) \ No newline at end of file diff --git a/bin/templates/cordova/log b/bin/templates/cordova/log deleted file mode 100755 index 216c8d76..00000000 --- a/bin/templates/cordova/log +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env node - -/* - 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. -*/ - -var log = require('./lib/log'); -var reqs = require('./lib/check_reqs'); -var args = process.argv; - -// Usage support for when args are given -if (args.length > 2) { - log.help(); -} else { - reqs.run().then(function () { - return log.run(); - }, function (err) { - console.error('ERROR: ' + err); - process.exit(2); - }); -} diff --git a/bin/templates/cordova/log.bat b/bin/templates/cordova/log.bat deleted file mode 100644 index 4b2b434e..00000000 --- a/bin/templates/cordova/log.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0log" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'log' script in 'cordova' folder, aborting...>&2 - EXIT /B 1 -) \ No newline at end of file diff --git a/bin/templates/cordova/loggingHelper.js b/bin/templates/cordova/loggingHelper.js deleted file mode 100644 index 32b2ee0a..00000000 --- a/bin/templates/cordova/loggingHelper.js +++ /dev/null @@ -1,18 +0,0 @@ -var CordovaLogger = require('cordova-common').CordovaLogger; - -module.exports = { - adjustLoggerLevel: function (opts) { - if (opts instanceof Array) { - opts.silent = opts.indexOf('--silent') !== -1; - opts.verbose = opts.indexOf('--verbose') !== -1; - } - - if (opts.silent) { - CordovaLogger.get().setLevel('error'); - } - - if (opts.verbose) { - CordovaLogger.get().setLevel('verbose'); - } - } -}; diff --git a/bin/templates/cordova/run b/bin/templates/cordova/run deleted file mode 100755 index 2e7efe26..00000000 --- a/bin/templates/cordova/run +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env node - -/* - 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. -*/ - -var Api = require('./Api'); -var nopt = require('nopt'); -var path = require('path'); - -// Support basic help commands -if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) { - require('./lib/run').help(); -} - -// Do some basic argument parsing -var runOpts = nopt({ - verbose: Boolean, - silent: Boolean, - debug: Boolean, - release: Boolean, - nobuild: Boolean, - buildConfig: path, - archs: String, - device: Boolean, - emulator: Boolean, - target: String -}, { d: '--verbose' }); - -// Make runOptions compatible with PlatformApi run method spec -runOpts.argv = runOpts.argv.remain; - -require('./loggingHelper').adjustLoggerLevel(runOpts); - -new Api().run(runOpts) - .catch(function (err) { - console.error(err, err.stack); - process.exit(2); - }); diff --git a/bin/templates/cordova/run.bat b/bin/templates/cordova/run.bat deleted file mode 100644 index b0bc28b2..00000000 --- a/bin/templates/cordova/run.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0run" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'run' script in 'cordova' folder, aborting...>&2 - EXIT /B 1 -) \ No newline at end of file diff --git a/bin/templates/cordova/version.bat b/bin/templates/cordova/version.bat deleted file mode 100644 index 3610c17b..00000000 --- a/bin/templates/cordova/version.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0version" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'version' script in 'cordova' folder, aborting...>&2 - EXIT /B 1 -) diff --git a/bin/update b/bin/update deleted file mode 100755 index f5a5de1a..00000000 --- a/bin/update +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env node - -/* - 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. -*/ -var path = require('path'); -var Api = require('./templates/cordova/Api'); -var args = require('nopt')({ - link: Boolean, - shared: Boolean, - help: Boolean -}, { d: '--verbose' }); - -if (args.help || args.argv.remain.length === 0) { - console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'update')) + ' [--link]'); - console.log(' --link will use the CordovaLib project directly instead of making a copy.'); - process.exit(1); -} - -require('./templates/cordova/loggingHelper').adjustLoggerLevel(args); - -Api.updatePlatform(args.argv.remain[0], { link: (args.link || args.shared) }).catch(err => { - console.error(err); - process.exitCode = 1; -}); diff --git a/bin/update.bat b/bin/update.bat deleted file mode 100644 index 824d9af8..00000000 --- a/bin/update.bat +++ /dev/null @@ -1,26 +0,0 @@ -:: 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. - -@ECHO OFF -SET script_path="%~dp0update" -IF EXIST %script_path% ( - node %script_path% %* -) ELSE ( - ECHO. - ECHO ERROR: Could not find 'update' script in 'bin' folder, aborting...>&2 - EXIT /B 1 -) diff --git a/package.json b/package.json index e5017a62..00c0eb79 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,6 @@ "name": "cordova-android", "version": "10.0.0-dev", "description": "cordova-android release", - "bin": { - "create": "bin/create" - }, "main": "bin/templates/cordova/Api.js", "repository": "github:apache/cordova-android", "bugs": "https://github.com/apache/cordova-android/issues", diff --git a/spec/e2e/plugin.spec.js b/spec/e2e/plugin.spec.js index 7debf887..dae97d3b 100644 --- a/spec/e2e/plugin.spec.js +++ b/spec/e2e/plugin.spec.js @@ -20,11 +20,13 @@ const os = require('os'); const fs = require('fs-extra'); const path = require('path'); -const execa = require('execa'); -const { PluginInfoProvider } = require('cordova-common'); +const { EventEmitter } = require('events'); +const { ConfigParser, PluginInfoProvider } = require('cordova-common'); + +const Api = require('../../bin/templates/cordova/Api'); -const createBin = path.join(__dirname, '../../bin/create'); const fakePluginPath = path.join(__dirname, 'fixtures/cordova-plugin-fake'); +const configXmlPath = path.join(__dirname, '../../bin/templates/project/res/xml/config.xml'); describe('plugin add', function () { let tmpDir; @@ -40,11 +42,16 @@ describe('plugin add', function () { const projectname = 'testpluginframework'; const projectid = 'com.test.plugin.framework'; + const config = new ConfigParser(configXmlPath); + config.setPackageName(projectid); + config.setName(projectname); + const projectPath = path.join(tmpDir, projectname); const pluginInfo = new PluginInfoProvider().get(fakePluginPath); + const noopEvents = new EventEmitter(); return Promise.resolve() - .then(() => execa(createBin, [projectPath, projectid, projectname])) + .then(() => Api.createPlatform(projectPath, config, {}, noopEvents)) .then(() => { // Allow test project to find the `cordova-android` module fs.ensureSymlinkSync( @@ -53,8 +60,13 @@ describe('plugin add', function () { 'junction' ); + // We need to use the API from the project or some paths break + // TODO remove this and use the API instance returned from + // createPlatform once we fixed the platform const Api = require(path.join(projectPath, 'cordova/Api.js')); - return new Api('android', projectPath).addPlugin(pluginInfo); + const api = new Api('android', projectPath, noopEvents); + + return api.addPlugin(pluginInfo); }); }, 90000); }); diff --git a/spec/unit/run.spec.js b/spec/unit/run.spec.js index e780e684..5bd4e017 100644 --- a/spec/unit/run.spec.js +++ b/spec/unit/run.spec.js @@ -80,14 +80,4 @@ describe('run', () => { .toBeRejectedWith(jasmine.stringMatching(/Package type "bundle" is not supported/)); }); }); - - describe('help', () => { - it('should print out usage and help', () => { - spyOn(console, 'log'); - spyOn(process, 'exit'); - - run.help(); - expect(console.log).toHaveBeenCalledWith(jasmine.stringMatching(/^Usage:/)); - }); - }); });