From 92bb2d005cd691b1d766f00a15ba1fceaa0d8058 Mon Sep 17 00:00:00 2001 From: chokyf Date: Tue, 26 Mar 2024 17:26:25 +0800 Subject: [PATCH] chok: init commit --- .editorconfig | 26 ++++ .gitignore | 6 + .jshintrc | 6 + .npmignore | 6 + CODE_OF_CONDUCT.md | 76 ++++++++++ LICENSE | 21 +++ Makefile | 31 ++++ README-github.md | 47 ++++++ README.md | 92 ------------ build.gradle | 13 ++ package-lock.json | 259 ++++++++++++++++++++++++++++++++ package.json | 33 ++++ plugin.xml | 11 ++ proguard-custom.txt | 110 ++++++++++++++ readme.md | 19 +++ renovate.json | 5 + scripts/androidBeforeInstall.js | 22 +++ test/run.sh | 106 +++++++++++++ test/txt/proguard-custom.txt | 1 + 19 files changed, 798 insertions(+), 92 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 .jshintrc create mode 100644 .npmignore create mode 100644 CODE_OF_CONDUCT.md create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README-github.md delete mode 100644 README.md create mode 100644 build.gradle create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 plugin.xml create mode 100644 proguard-custom.txt create mode 100644 readme.md create mode 100644 renovate.json create mode 100644 scripts/androidBeforeInstall.js create mode 100755 test/run.sh create mode 100644 test/txt/proguard-custom.txt diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c383d2c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,26 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +# Matches multiple files with brace expansion notation +# Set default charset +[*.{js}] +charset = utf-8 +indent_style = space +indent_size = 2 + +# Tab indentation (no size specified) +[Makefile] +indent_style = tab + +[*.{json,yml}] +indent_style = space +indent_size = 2 + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..90b246a --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Folder view configuration files +.DS_Store +._* +node_modules +npm-debug.log +cSpell.json \ No newline at end of file diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..149dc48 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,6 @@ +{ + "node": true, + "browser": true, + "undef": true, + "esversion": 6 +} diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..90b246a --- /dev/null +++ b/.npmignore @@ -0,0 +1,6 @@ +# Folder view configuration files +.DS_Store +._* +node_modules +npm-debug.log +cSpell.json \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..18ee6e0 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at greybax@gmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e770453 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Aleksandr Filatov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c355c27 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +NODE_MODULES?=node_modules +help: + @echo "" + @echo "Usage: make " + @echo "" + @echo "available targets:" + @echo " tests ............. Run all tests." + @echo " test-js ........... Test javascript files for errors." + @echo " test-install ...... Test plugin installation Android." + @echo "" + @echo "" + +test-js: jshint + +jshint: check-jshint + @echo "- JSHint" + @${NODE_MODULES}/.bin/jshint --config .jshintrc scripts/*.js + @echo " Done" + @echo "" + +test-install: + @./test/run.sh com.graybax.progplugintest progplugintest + +tests: jshint test-install + @echo 'ok' + +check-jshint: + @test -e "${NODE_MODULES}/.bin/jshint" || ( echo "${NODE_MODULES} not found."; echo 'Please install dependencies: npm install'; exit 1 ) + +clean: + @find . -name '*~' -exec rm '{}' ';' diff --git a/README-github.md b/README-github.md new file mode 100644 index 0000000..b52c8b8 --- /dev/null +++ b/README-github.md @@ -0,0 +1,47 @@ +# cordova-plugin-proguard + +[![NPM version][npm-image]][npm-url] +[![npm](https://img.shields.io/npm/dm/cordova-plugin-proguard.svg)](https://www.npmjs.com/package/cordova-plugin-proguard) + +> Cordova plugin which activates ProGuard and minification for debug and release builds in your cordova mobile application. + +## What is ProGuard? + +> ProGuard is the open source optimizer for Java bytecode + +You can read more about it on [ProGuard official website](https://www.guardsquare.com/en/proguard) and on [android developer portal](https://developer.android.com/studio/build/shrink-code.html) + +## How to use + +- If you already have installed [Android Studio](https://developer.android.com/studio/index.html) then seems you already have installed ProGuard on your machine. If no, then you should download and install it manually from [ProGuard official website](https://www.guardsquare.com/en/proguard). +- ```cordova plugin add cordova-plugin-proguard``` - this command will configure your `build.gradle` file and copy `proguard-custom.txt` to `${androidPlatformDirectory}/assets/www/proguard-custom.txt` + +## Customization + +`proguard-custom.txt` file contains some basic rules for your cordova mobile app. Feel free to [fork this repo](https://github.com/greybax/cordova-plugin-proguard/fork) and modify it as you want. + +You can also to check out some [Android ProGuard snippets](https://github.com/krschultz/android-proguard-snippets) + +If you want to add rules to this `proguard-custom.txt`, please create your own `proguard-custom.txt` and add this to your projectroot folder. +Upon installing the proguard-plugin, the rules will be added to your project. +Example rules for various situations will be in the commented section in the plugin `proguard-custom.txt`. + +``` +ionic cordova platform rm android +ionic cordova platform add android +``` + +## History + - v1.0.0 - supports Cordova version <7 + - v2.0.0 - supports Cordova version 7+ (thanks to @SujitSingh) + +## Why I've done this plugin? + +https://alfilatov.com/posts/how-to-setup-proguard-in-cordova-application/ + +## License + +MIT © [Aleksandr Filatov](https://alfilatov.com) + +[npm-url]: https://npmjs.org/package/cordova-plugin-proguard +[npm-image]: https://img.shields.io/npm/v/cordova-plugin-proguard.svg diff --git a/README.md b/README.md deleted file mode 100644 index ff2f45d..0000000 --- a/README.md +++ /dev/null @@ -1,92 +0,0 @@ -# Cordova Plugin Proguard - - - -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin http://dev.silverlakemobility.com/gitlab/cordova-custom/cordova-plugin-proguard.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](http://dev.silverlakemobility.com/gitlab/cordova-custom/cordova-plugin-proguard/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..75b88f3 --- /dev/null +++ b/build.gradle @@ -0,0 +1,13 @@ +android { + buildTypes { + debug { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'src/main/assets/www/proguard-custom.txt' + } + release { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'src/main/assets/www/proguard-custom.txt' + } + } +} + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..e37c513 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,259 @@ +{ + "name": "cordova-plugin-proguard", + "version": "2.2.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "cli": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", + "integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=", + "dev": true, + "requires": { + "exit": "0.1.2", + "glob": "^7.1.1" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "console-browserify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", + "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", + "dev": true, + "requires": { + "date-now": "^0.1.4" + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "date-now": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", + "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", + "dev": true + }, + "dom-serializer": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz", + "integrity": "sha512-2/xPb3ORsQ42nHYiSunXkDjPLBaEj/xTwUO4B7XCZQTRk7EBtTOPaygh10YAAh2OI1Qrp6NWfpAhzswj0ydt9g==", + "dev": true, + "requires": { + "domelementtype": "^2.0.1", + "entities": "^2.0.0" + }, + "dependencies": { + "domelementtype": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.0.1.tgz", + "integrity": "sha512-5HOHUDsYZWV8FGWN0Njbr/Rn7f/eWSQi1v7+HsUVwXgn8nWWlL64zKDkS0n8ZmQ3mlWOMuXOnR+7Nx/5tMO5AQ==", + "dev": true + }, + "entities": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz", + "integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==", + "dev": true + } + } + }, + "domelementtype": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", + "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==", + "dev": true + }, + "domhandler": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", + "integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=", + "dev": true, + "requires": { + "domelementtype": "1" + } + }, + "domutils": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", + "dev": true, + "requires": { + "dom-serializer": "0", + "domelementtype": "1" + } + }, + "entities": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", + "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", + "dev": true + }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "htmlparser2": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", + "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", + "dev": true, + "requires": { + "domelementtype": "1", + "domhandler": "2.3", + "domutils": "1.5", + "entities": "1.0", + "readable-stream": "1.1" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "jshint": { + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.12.0.tgz", + "integrity": "sha512-TwuuaUDmra0JMkuqvqy+WGo2xGHSNjv1BA1nTIgtH2K5z1jHuAEeAgp7laaR+hLRmajRjcrM71+vByBDanCyYA==", + "dev": true, + "requires": { + "cli": "~1.0.0", + "console-browserify": "1.1.x", + "exit": "0.1.x", + "htmlparser2": "3.8.x", + "lodash": "~4.17.19", + "minimatch": "~3.0.2", + "shelljs": "0.3.x", + "strip-json-comments": "1.0.x" + } + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "shelljs": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", + "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", + "dev": true + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "strip-json-comments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", + "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..cdc0682 --- /dev/null +++ b/package.json @@ -0,0 +1,33 @@ +{ + "name": "cordova-plugin-proguard", + "version": "2.2.0", + "description": "Cordova plugin for ProGuard", + "repository": { + "type": "git", + "url": "git+https://github.com/greybax/cordova-plugin-proguard.git" + }, + "keywords": [ + "proguard", + "android", + "optimize", + "shrink", + "minify", + "obfuscate", + "tool", + "cordova", + "plugin" + ], + "author": { + "name": "Aleksandr Filatov", + "email": "greybax@gmail.com", + "url": "https://alfilatov.com" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/greybax/cordova-plugin-proguard/issues" + }, + "homepage": "https://github.com/greybax/cordova-plugin-proguard#readme", + "devDependencies": { + "jshint": "2.12.0" + } +} diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..744094a --- /dev/null +++ b/plugin.xml @@ -0,0 +1,11 @@ + + + Cordova plugin ProGuard + Activated ProGuard for Android + + + + + + + diff --git a/proguard-custom.txt b/proguard-custom.txt new file mode 100644 index 0000000..be597a3 --- /dev/null +++ b/proguard-custom.txt @@ -0,0 +1,110 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: +#-dontshrink +#-dontoptimize +#-dontobfuscate + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class android.webkit.WebView { +# public *; +#} + +#-injars bin/classes +#-injars libs +#-outjars bin/classes-processed.jar + +# Using Google's License Verification Library +-keep class com.android.vending.licensing.ILicensingService + +# Specifies to write out some more information during processing. +# If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message. +-verbose + +# Annotations are represented by attributes that have no direct effect on the execution of the code. +-keepattributes *Annotation* + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keepattributes InnerClasses +-keep class **.R +-keep class **.R$* { + ; +} + +# These options let obfuscated applications or libraries produce stack traces that can still be deciphered later on +-renamesourcefileattribute SourceFile +-keepattributes SourceFile,LineNumberTable + +# Enable proguard with Cordova +-keep class org.apache.cordova.** { *; } +-keep public class * extends org.apache.cordova.CordovaPlugin + +-keep class com.google.android.gms.dynamite.DynamiteModule$DynamiteLoaderClassLoader { java.lang.ClassLoader sClassLoader; } + +-keep class org.apache.cordova.CordovaBridge { org.apache.cordova.PluginManager pluginManager; } +-keep class org.apache.cordova.CordovaInterfaceImpl { org.apache.cordova.PluginManager pluginManager; } +-keep class org.apache.cordova.CordovaResourceApi { org.apache.cordova.PluginManager pluginManager; } +-keep class org.apache.cordova.CordovaWebViewImpl { org.apache.cordova.PluginManager pluginManager; } +-keep class org.apache.cordova.ResumeCallback { org.apache.cordova.PluginManager pluginManager; } +-keep class org.apache.cordova.engine.SystemWebViewEngine { org.apache.cordova.PluginManager pluginManager; } + +-dontnote org.apache.harmony.xnet.provider.jsse.NativeCrypto +-dontnote sun.misc.Unsafe + +-keep class com.worklight.androidgap.push.** { *; } +-keep class com.worklight.wlclient.push.** { *; } + +# Enable proguard with Google libs +-keep class com.google.** { *; } +-dontwarn com.google.common.** +-dontwarn com.google.ads.** +-dontwarn com.google.android.gms.** + +# apache.http +-optimizations !class/merging/vertical*,!class/merging/horizontal*,!code/simplification/arithmetic,!field/*,!code/allocation/variable + +-keep class net.sqlcipher.** { *; } +-dontwarn net.sqlcipher.** + +-keep class org.codehaus.** { *; } +-keepattributes *Annotation*,EnclosingMethod + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +# Remove debug logs in release build +-assumenosideeffects class android.util.Log { + public static *** d(...); +} + +# These classes contain references to external jars which are not included in the default MobileFirst project. +-dontwarn com.worklight.common.internal.WLTrusteerInternal* +-dontwarn com.worklight.jsonstore.** +-dontwarn org.codehaus.jackson.map.ext.* +-dontwarn com.worklight.androidgap.push.GCMIntentService +-dontwarn com.worklight.androidgap.plugin.WLInitializationPlugin + +-dontwarn android.support.v4.** +-dontwarn android.net.SSLCertificateSocketFactory +-dontwarn android.net.http.* + +# These clases contain references to cordova webView +-keep class com.ionicframework.cordova.webview.** {*; } +-keep class com.ionicframework.cordova.webview.* diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e4ed1b0 --- /dev/null +++ b/readme.md @@ -0,0 +1,19 @@ +# Customized + +local_plugins\cordova-plugin-proguard\1.0.0\cordova-plugin-proguard\build.gradle + +- added shrinkResources true for release mode + +local_plugins\cordova-plugin-proguard\1.0.0\cordova-plugin-proguard\proguard-custom.txt + +- added customized script to bypass certain files + +# Installation + +If your platforms having the existing plugin, remove it first. Make sure platforms & plugins do not have the plugins. + +- Remove plugin + cordova plugin rm cordova-plugin-proguard + +- Add plugin + cordova plugin add ./apps/showroom-mb/local_plugins/cordova-plugin-proguard/2.2.0/cordova-plugin-proguard diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..f45d8f1 --- /dev/null +++ b/renovate.json @@ -0,0 +1,5 @@ +{ + "extends": [ + "config:base" + ] +} diff --git a/scripts/androidBeforeInstall.js b/scripts/androidBeforeInstall.js new file mode 100644 index 0000000..76eee66 --- /dev/null +++ b/scripts/androidBeforeInstall.js @@ -0,0 +1,22 @@ +// adding options from project-custom file in platformpath to default proguard-custom file in pluginpath +let fs = require('fs'); +let path = require('path'); + +module.exports = function (ctx) { + const projectRoot = ctx.opts.projectRoot; + const pluginDir = ctx.opts.plugin.dir; + const targetProguardFile = path.join(pluginDir, 'proguard-custom.txt'); + const projectProguardFile = path.join(projectRoot, 'proguard-custom.txt'); + + try { + if (fs.existsSync(projectProguardFile)) { + const data = fs.readFileSync(projectProguardFile, 'utf8'); + fs.appendFileSync(targetProguardFile, data); + console.log('Added optional proguard-rules to proguardFile.'); + } else { + console.log('No optional proguard-custom.txt found in projectRoot: ' + projectRoot); + } + } catch(err) { + console.error(err); + } +}; \ No newline at end of file diff --git a/test/run.sh b/test/run.sh new file mode 100755 index 0000000..81d06d6 --- /dev/null +++ b/test/run.sh @@ -0,0 +1,106 @@ +#!/bin/bash +set -e +set -o xtrace + +# Set variables: PLUGIN_DIR, TEST_DIR, BUILD_DIR +cd "$(dirname "$0")/.." +ROOT_DIR="$(pwd)" +TEST_DIR="$ROOT_DIR/test" +BUILD_DIR="${BUILD_DIR:-/tmp/build-$RANDOM}" + +# Create and enter the build directory +rm -fr "$BUILD_DIR" +cd "$TEST_DIR" + +# Command line parameters +BUNDLE_ID="$1" +IAP_ID="$2" + +#PLUGIN_URL="git://github.com/j3k0/PhoneGap-InAppPurchase-iOS.git#unified" +PLUGIN_URL="$ROOT_DIR" + +if [ "x$IAP_ID" = "x" ] || [ "x$1" = "x--help" ]; then + echo + echo "usage: $0 " + echo + echo "This will generate a cordova project using Cordova $TEST_VERSION (required)." + echo + echo "example:" + echo " \$ $0 com.greybax.progplugintest progplugintest" + echo + exit 1 +fi + +# Add cordova to PATH +export PATH="$ROOT_DIR/node_modules/.bin:$PATH" + +# Create a project +cordova create "$BUILD_DIR" "$BUNDLE_ID" Test + +cd "$BUILD_DIR" + +echo Prepare platforms +cordova platform add android || exit 1 + +# copy dummy +echo Copy customrules +CUSTOM_RULES="$TEST_DIR/txt/proguard-custom.txt" +cp "$CUSTOM_RULES" "$BUILD_DIR/" + +echo Add Proguard plugin +cordova plugin add "$PLUGIN_URL" || exit 1 + +# Add console debug +# cordova plugin add https://github.com/apache/cordova-plugin-console.git || exit 1 + +# Check existance of the plugins files +function hasFile() { + if test -e "$1"; then + echo "File $1 installed." + else + echo "ERROR: File $1 is missing." + echo + echo " => it can be found at the following locations:" + find "$BUILD_DIR" -name "$(basename "$1")" + echo + EXIT=1 + fi +} + +# Compile for Android +echo "Android build..." +if ! cordova build android 2>&1 > $BUILD_DIR/build-android.txt; then + tail -500 $BUILD_DIR/build-android.txt + exit 1 +fi +tail -20 $BUILD_DIR/build-android.txt + +echo "Check Android installation" + +# check Proguard custom file has been installed +PROGUARD_CUSTOM_FILE="$BUILD_DIR/platforms/android/app/src/main/assets/www/proguard-custom.txt" +if test ! -e "$PROGUARD_CUSTOM_FILE"; then + echo "ERROR: Proguard-custom file not found." + EXIT=1 +fi + +hasFile "$PROGUARD_CUSTOM_FILE" + +# finally test if the extra rules are in place in the default proguard-custom.txt file +EXTRA_RULES=$(<$CUSTOM_RULES) + +echo "Extra rules in proguard check" +echo "$EXTRA_RULES" + +if grep "$EXTRA_RULES" "$PROGUARD_CUSTOM_FILE" > /dev/null; then + echo "CUSTOM RULES successfully added has been setup." +else + echo "ERROR: SOMETHING WENT WRONG." + EXIT=1 +fi + +if [ "x$EXIT" != "x1" ]; then + echo "Great! Everything looks good."; +fi + +exit $EXIT diff --git a/test/txt/proguard-custom.txt b/test/txt/proguard-custom.txt new file mode 100644 index 0000000..6af7958 --- /dev/null +++ b/test/txt/proguard-custom.txt @@ -0,0 +1 @@ +# This is the rule file that goes into the root -- GitLab