From 4faee2e043b54a4d4d48085b3c50871497d388a0 Mon Sep 17 00:00:00 2001 From: Abdelrahman Omran Date: Tue, 1 Jan 2019 08:30:55 +0200 Subject: [PATCH] Commit first draft --- .codeclimate.yml | 43 +++++++ .editorconfig | 18 +++ .gitattributes | 9 ++ .gitignore | 6 + .scrutinizer.yml | 307 +++++++++++++++++++++++++++++++++++++++++++++ .styleci.yml | 44 +++++++ .travis.yml | 32 +++++ CHANGELOG.md | 9 ++ CODE_OF_CONDUCT.md | 74 +++++++++++ CONTRIBUTING.md | 47 +++++++ LICENSE | 21 ++++ README.md | 187 +++++++++++++++++++++++++++ composer.json | 60 +++++++++ laravel | 13 ++ phpunit.xml.dist | 44 +++++++ src/NewCommand.php | 228 +++++++++++++++++++++++++++++++++ zipper.sh | 10 ++ 17 files changed, 1152 insertions(+) create mode 100644 .codeclimate.yml create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .scrutinizer.yml create mode 100644 .styleci.yml create mode 100644 .travis.yml create mode 100644 CHANGELOG.md create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 README.md create mode 100755 composer.json create mode 100755 laravel create mode 100644 phpunit.xml.dist create mode 100755 src/NewCommand.php create mode 100755 zipper.sh diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 0000000..2f1f83d --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,43 @@ +--- +engines: + duplication: + enabled: true + config: + languages: + - ruby + - javascript + - python + - php + eslint: + enabled: true + fixme: + enabled: true + phpmd: + enabled: true + checks: + Design/TooManyPublicMethods: + enabled: false + Naming/ShortVariable: + enabled: false + CleanCode/ElseExpression: + enabled: false + CleanCode/BooleanArgumentFlag: + enabled: false + CleanCode/StaticAccess: + enabled: false + Naming/ShortMethodName: + enabled: false +ratings: + paths: + - "**.inc" + - "**.js" + - "**.jsx" + - "**.module" + - "**.php" + - "**.py" + - "**.rb" +exclude_paths: +- "resources/*" +- "build/*" +- "tests/*" +- "vendor/*" diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..326ade8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +# http://editorconfig.org +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +max_line_length = 80 +trim_trailing_whitespace = true + +[*.md] +max_line_length = 0 +trim_trailing_whitespace = false + +[COMMIT_EDITMSG] +max_line_length = 0 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2a2a4ab --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +* text=auto +*.js linguist-vendored +*.css linguist-vendored +*.scss linguist-vendored + +/phpunit.* export-ignore +/phpcs.* export-ignore +/tests export-ignore +/.* export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..33c5001 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/build +/vendor +/node_modules +composer.lock +composer.phar +phpunit.xml diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..51ec781 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,307 @@ +inherit: true + +checks: + php: + verify_property_names: true + verify_argument_usable_as_reference: true + verify_access_scope_valid: true + variable_existence: true + useless_calls: true + use_statement_alias_conflict: true + fix_doc_comments: false + avoid_corrupting_byteorder_marks: true + unused_variables: true + argument_type_checks: true + assignment_of_null_return: true + avoid_aliased_php_functions: true + avoid_closing_tag: true + avoid_conflicting_incrementers: true + avoid_duplicate_types: true + avoid_entity_manager_injection: true + avoid_fixme_comments: true + avoid_length_functions_in_loops: true + avoid_multiple_statements_on_same_line: true + avoid_perl_style_comments: true + avoid_superglobals: true + avoid_todo_comments: true + avoid_usage_of_logical_operators: true + avoid_useless_overridden_methods: true + blank_line_after_namespace_declaration: true + catch_class_exists: true + classes_in_camel_caps: true + closure_use_modifiable: true + closure_use_not_conflicting: true + code_rating: true + deadlock_detection_in_loops: true + deprecated_code_usage: true + duplication: true + encourage_shallow_comparison: true + encourage_single_quotes: true + foreach_traversable: true + foreach_usable_as_reference: true + function_in_camel_caps: true + instanceof_class_exists: true + line_length: + max_length: '120' + method_calls_on_non_object: true + missing_arguments: true + more_specific_types_in_doc_comments: true + newline_at_end_of_file: true + no_commented_out_code: true + no_debug_code: true + no_duplicate_arguments: true + no_empty_statements: true + no_error_suppression: true + no_eval: true + no_exit: true + no_global_keyword: true + no_goto: true + no_long_variable_names: + maximum: '20' + no_non_implemented_abstract_methods: true + no_property_on_interface: true + no_short_method_names: + minimum: '0' + no_short_open_tag: true + no_short_variable_names: + minimum: '0' + no_trailing_whitespace: true + no_trait_type_hints: true + no_underscore_prefix_in_methods: true + no_underscore_prefix_in_properties: true + no_unnecessary_final_modifier: true + no_unnecessary_if: true + non_commented_empty_catch_block: true + one_class_per_file: true + overriding_private_members: true + parameter_non_unique: true + parse_doc_comments: true + optional_parameters_at_the_end: true + param_doc_comment_if_not_inferrable: true + parameter_doc_comments: true + parameters_in_camelcaps: true + php5_style_constructor: true + precedence_in_conditions: true + precedence_mistakes: true + prefer_while_loop_over_for_loop: true + properties_in_camelcaps: true + property_assignments: true + psr2_class_declaration: true + psr2_switch_declaration: true + require_php_tag_first: true + require_scope_for_methods: true + require_scope_for_properties: true + return_doc_comment_if_not_inferrable: true + return_doc_comments: true + security_vulnerabilities: true + side_effects_or_types: true + simplify_boolean_return: true + single_namespace_per_use: true + sql_injection_vulnerabilities: true + symfony_request_injection: true + switch_fallthrough_commented: true + too_many_arguments: true + unreachable_code: true + unused_methods: true + unused_parameters: true + unused_properties: true + uppercase_constants: true + use_self_instead_of_fqcn: true + + +filter: + excluded_paths: + - 'build/*' + - 'resources/*' + - 'tests/*' + - 'vendor/*' + +tools: + + # PHP Code Similarity Analyzer (https://scrutinizer-ci.com/docs/tools/php/code-similarity-analyzer/) + php_sim: + min_mass: 30 # Defaults to 16 + + + # SensioLabs Security Checker (https://scrutinizer-ci.com/docs/tools/php/security-advisory-checker/) + sensiolabs_security_checker: + enabled: true + + + # PHP Code Sniffer (https://scrutinizer-ci.com/docs/tools/php/code-sniffer/) + php_code_sniffer: + enabled: true + config: + standard: PSR2 + filter: + excluded_paths: + - 'build/*' + - 'resources/*' + - 'tests/*' + - 'vendor/*' + + + # PHP Copy/Paste Detector + php_cpd: + enabled: true + excluded_dirs: + - 'build' + - 'resources' + - 'tests' + - 'vendor' + + + # Analyzes the size and structure of a PHP project. + php_loc: + enabled: true + excluded_dirs: + - 'build' + - 'resources' + - 'tests' + - 'vendor' + + + # PHP Mess Detector + php_mess_detector: + enabled: true + config: + rulesets: + - codesize + - unusedcode + - naming + - design + - controversial + filter: + excluded_paths: + - 'build/*' + - 'tests/*' + - 'resources/*' + - 'vendor/*' + + + # PHP PDepend (https://scrutinizer-ci.com/docs/tools/php/pdepend/) + php_pdepend: + enabled: true + excluded_dirs: + - 'build' + - 'resources' + - 'tests' + - 'vendor' + + + # PHP Analyzer (https://scrutinizer-ci.com/docs/tools/php/php-analyzer/) + php_analyzer: + enabled: true + config: + parameter_reference_check: + enabled: true + checkstyle: + enabled: true + no_trailing_whitespace: true + naming: + enabled: true + local_variable: ^[a-z][a-zA-Z0-9]*$ + abstract_class_name: ^Abstract|Factory$ + utility_class_name: Utils?$ + constant_name: ^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$ + property_name: ^[a-z][a-zA-Z0-9]*$ + method_name: ^(?:[a-z]|__)[a-zA-Z0-9]*$ + parameter_name: ^[a-z][a-zA-Z0-9]*$ + interface_name: ^[A-Z][a-zA-Z0-9]*Interface$ + type_name: ^[A-Z][a-zA-Z0-9]*$ + exception_name: ^[A-Z][a-zA-Z0-9]*Exception$ + isser_method_name: ^(?:is|has|should|may|supports) + unreachable_code: + enabled: true + check_access_control: + enabled: true + typo_checks: + enabled: true + check_variables: + enabled: true + check_calls: + enabled: true + method_call_validity: true + too_many_arguments: true + missing_argument: true + argument_type_checks: lenient # Allowed Values: "disabled", "lenient", "strict" + check_debug_code: + enabled: true + check_property_assignments: + enabled: true + method_contract_checks: + enabled: true + verify_interface_like_constraints: true + verify_documented_constraints: true + verify_parent_constraints: true + check_request_data_usage: + enabled: true + suspicious_code: + enabled: true + overriding_parameter: false + overriding_closure_use: true + parameter_closure_use_conflict: true + parameter_multiple_times: true + non_existent_class_in_instanceof_check: true + non_existent_class_in_catch_clause: true + assignment_of_null_return: true + non_commented_switch_fallthrough: true + non_commented_empty_catch_block: true + overriding_private_members: true + use_statement_alias_conflict: true + precedence_in_condition_assignment: true + dead_assignments: + enabled: true + deadlock_detection: + enabled: true + verify_php_doc_comments: + enabled: true + parsable: true + traits_are_not_type_hinted: true + parameters: true + return: true + suggest_more_specific_types: true + ask_for_return_if_not_inferrable: true + ask_for_param_type_annotation: ~ + loops_must_use_braces: + enabled: true + check_usage_context: + enabled: true + foreach: + value_as_reference: true + traversable: true + missing_argument: ~ + argument_type_checks: ~ + simplify_boolean_return: + enabled: true + phpunit_checks: + enabled: false + reflection_checks: + enabled: true + + # Checks Common Precedence Mistakes + precedence_checks: + enabled: true + assignment_in_condition: true + comparison_of_bit_result: true + basic_semantic_checks: + enabled: true + property_on_interface: true + missing_abstract_methods: true + unused_code: + enabled: true + methods: true + parameters: true + deprecation_checks: + enabled: true + useless_function_calls: + enabled: true + metrics_lack_of_cohesion_methods: + enabled: true + metrics_coupling: + enabled: true + stable_code: + namespace_prefixes: [] + classes: [] + symfony_request_injection: + enabled: true diff --git a/.styleci.yml b/.styleci.yml new file mode 100644 index 0000000..336e5c3 --- /dev/null +++ b/.styleci.yml @@ -0,0 +1,44 @@ +preset: recommended + +enabled: + - dir_constant + - ereg_to_preg + - no_useless_else + - mb_str_functions + - short_list_syntax + - no_short_echo_tag + - strict_comparison + - phpdoc_link_to_see + - property_separation + - no_php4_constructor + - php_unit_namespaced + - random_api_migration + - declare_strict_types + - unalign_double_arrow + - no_alternative_syntax + - standardize_increment + - length_ordered_imports + - modernize_types_casting + - non_printable_character + - return_type_declaration + - explicit_string_variable + - no_unneeded_final_method + - no_unneeded_curly_braces + - blank_line_before_declare + - compact_nullable_typehint + - combine_consecutive_issets + - combine_consecutive_unsets + - explicit_indirect_variable + - ternary_to_null_coalescing + - escape_implicit_backslashes + - fully_qualified_strict_types + - phpdoc_return_self_reference + - no_null_property_initialization + - multiline_comment_opening_closing + - not_operator_with_successor_space + - phpdoc_add_missing_param_annotation + - php_unit_set_up_tear_down_visibility + +disabled: + - align_double_arrow + - alpha_ordered_imports diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..387de20 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,32 @@ +language: php + +php: + - 7.1 + - 7.2 + - 7.3 + +env: + matrix: + - COMPOSER_FLAGS="--prefer-lowest" + - COMPOSER_FLAGS="" + +cache: + directories: + - $HOME/.composer/cache + +before_script: + - travis_retry composer self-update + - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source + +script: + - vendor/phpunit/phpunit/phpunit --coverage-text --coverage-clover=coverage.clover + +after_script: + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover coverage.clover + +notifications: + email: false + slack: + rooms: + - secure: TmpxlLe34dhg7HJw6yqmdWR2B4CGUEiuiUzx3UJJG9l2hl+a9/x9NKw/UhaUCEe8hB6n9++eBJftjKw5MWfbkkPWft9dkhRDuCApP5ATTxhY2J0jo4Hr5aWR+5rl+1FZdLg5svPi1mioUsG0M+uTPkfBO897bk0MU53ewDpQfSt2baRRcWKncYXvoTesS604BRCrXOW68Js9+mgXG75hbefgldHxjL8vQNVgFdeMHw4fIBaRnET21qOcPBhgzCqg1kc4DFxSkbk0mLu9FvdZM0dMPrpE4JxneAZEP3kWIrzxv57APgTbMjzaCORjhAcQFtDp6/ZWBEtjoM1t8QnPFch6AEZ42otZpOXvKkvXDZ5UXcGWlY2VRItyoYtL74/l7n5mthlrvHw4scj7ukbUBFIlyRjyAEAt9cCYt+fmuDVc+TexRKd+LvJsDRa79O+vaVnvReaebVPrPgC4yhzT/DQD5f3MAfwvqCi5idI7i0v08TS/uPTojSl49PrAHkO/oUXI0qENt553i59yDazyR+3UDkgQa8dLNG5CoX//xyiYrAYz8PYFSJSZ2K+eVLjl816zA3woDrIpeotCc2o/kvVT/b+H6hQrQyjMYam8u0DxXBBzS4irxSmFzEbjt2QlaCw63jkqo6phC9omlrcZqD/RzyFxayl5R4PsZzUU3A8= diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..17cfe63 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Cortex Installer Change Log + +All notable changes to this project will be documented in this file. + +This project adheres to [Semantic Versioning](CONTRIBUTING.md). + + +## [v0.0.1] - 2019-01-01 +- Tag first release diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..b32e2f6 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# 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, gender identity and expression, level of experience, +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 [help@rinvex.com](mailto:help@rinvex.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 [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..bb56811 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,47 @@ +# Contribution Guide + +This project adheres to the following standards and practices. + + +## Versioning + +This project is versioned under the [Semantic Versioning](http://semver.org/) guidelines as much as possible. + +Releases will be numbered with the following format: + +- `..` +- `..` + +And constructed with the following guidelines: + +- Breaking backward compatibility bumps the major and resets the minor and patch. +- New additions without breaking backward compatibility bump the minor and reset the patch. +- Bug fixes and misc changes bump the patch. + + +## Pull Requests + +The pull request process differs for new features and bugs. + +Pull requests for bugs may be sent without creating any proposal issue. If you believe that you know of a solution for a bug that has been filed, please leave a comment detailing your proposed fix or create a pull request with the fix mentioning that issue id. + + +## Coding Standards + +This project follows the FIG PHP Standards Recommendations compliant with the [PSR-1: Basic Coding Standard](http://www.php-fig.org/psr/psr-1/), [PSR-2: Coding Style Guide](http://www.php-fig.org/psr/psr-2/) and [PSR-4: Autoloader](http://www.php-fig.org/psr/psr-4/) to ensure a high level of interoperability between shared PHP code. If you notice any compliance oversights, please send a patch via pull request. + + +## Feature Requests + +If you have a proposal or a feature request, you may create an issue with `[Proposal]` in the title. + +The proposal should also describe the new feature, as well as implementation ideas. The proposal will then be reviewed and either approved or denied. Once a proposal is approved, a pull request may be created implementing the new feature. + + +## Git Flow + +This project follows [Git-Flow](http://nvie.com/posts/a-successful-git-branching-model/), and as such has `master` (latest stable releases), `develop` (latest WIP development) and X.Y support branches (when there's multiple major versions). + +Accordingly all pull requests MUST be sent to the `develop` branch. + +> **Note:** Pull requests which do not follow these guidelines will be closed without any further notice. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b334e8e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016-2019, Rinvex LLC, + +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/README.md b/README.md new file mode 100644 index 0000000..31cb0a9 --- /dev/null +++ b/README.md @@ -0,0 +1,187 @@ +# Cortex Installer + +**Cortex Installer** is a command line tool that depends on composer to install the Cortex project seamlessly. + +[![Packagist](https://img.shields.io/packagist/v/cortex/installer.svg?label=Packagist&style=flat-square)](https://packagist.org/packages/cortex/installer) +[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/rinvex/cortex-installer.svg?label=Scrutinizer&style=flat-square)](https://scrutinizer-ci.com/g/rinvex/cortex-installer/) +[![Code Climate](https://img.shields.io/codeclimate/github/rinvex/cortex-installer.svg?label=CodeClimate&style=flat-square)](https://codeclimate.com/github/rinvex/cortex-installer) +[![Travis](https://img.shields.io/travis/rinvex/cortex-installer.svg?label=TravisCI&style=flat-square)](https://travis-ci.org/rinvex/cortex-installer) +[![StyleCI](https://styleci.io/repos/90121903/shield)](https://styleci.io/repos/90121903) +[![License](https://img.shields.io/packagist/l/cortex/installer.svg?label=License&style=flat-square)](https://github.com/rinvex/cortex-installer/blob/develop/LICENSE) + + +# Installation + +- [Installation](#installation) + - [Server Requirements](#server-requirements) + - [Installing Laravel](#installing-laravel) + - [Configuration](#configuration) +- [Web Server Configuration](#web-server-configuration) + - [Pretty URLs](#pretty-urls) + +## Installation + +### Server Requirements + +The Cortex application has a few system requirements. Of course, all of these requirements are satisfied by the [Punnet](https://github.com/rinvex/punnet) docker environment, so it's highly recommended that you use Punnet as your local Cortex development environment. + +However, if you are not using Punnet, you will need to make sure your server meets the following requirements: + +- PHP >= 7.1.3 +- OpenSSL PHP Extension +- PDO PHP Extension +- Mbstring PHP Extension +- Tokenizer PHP Extension +- XML PHP Extension +- Ctype PHP Extension +- JSON PHP Extension +- BCMath PHP Extension + +### Installing Cortex + +Cortex utilizes [Composer](https://getcomposer.org) to manage its dependencies. So, before using Laravel, make sure you have Composer installed on your machine. + +#### Via Cortex Installer + +First, download the Cortex installer using Composer: + +```shell +composer global require cortex/installer +``` + +Make sure to place composer's system-wide vendor bin directory in your `$PATH` so the cortex executable can be located by your system. This directory exists in different locations based on your operating system; however, some common locations include: + +- macOS: `$HOME/.composer/vendor/bin` +- GNU / Linux Distributions: `$HOME/.config/composer/vendor/bin` + +Once installed, the `cortex new` command will create a fresh Cortex installation in the directory you specify. For instance, `cortex new blog` will create a directory named `blog` containing a fresh Cortex installation with all of Cortex's dependencies already installed: + +```shell +cortex new blog +``` + +#### Via Composer Create-Project + +Alternatively, you may also install Cortex by issuing the Composer `create-project` command in your terminal: + +```shell +composer create-project --prefer-dist rinvex/cortex blog +``` + +#### Local Development Server + +If you have PHP installed locally and you would like to use PHP's built-in development server to serve your application, you may use the `serve` Artisan command. This command will start a development server at `http://localhost:8000`: + +```shell +php artisan serve +``` + +Of course, more robust local development options are available via [Punnet](https://github.com/rinvex/punnet). + +### Configuration + +#### Public Directory + +After installing Cortex, you should configure your web server's document / web root to be the `public` directory. The `index.php` in this directory serves as the front controller for all HTTP requests entering your application. + +#### Configuration Files + +All of the configuration files for the Cortex application are stored in the `config` directory. Each option is documented, so feel free to look through the files and get familiar with the options available to you. + +#### Directory Permissions + +After installing Cortex, you may need to configure some permissions. Directories within the `storage` and the `bootstrap/cache` directories should be writable by your web server or Cortex will not run. If you are using the [Punnet](https://github.com/rinvex/punnet) docker environment, these permissions should already be set. + +#### Application Key + +The next thing you should do after installing Cortex is set your application key to a random string. If you installed Cortex via Composer or the Cortex installer, this key has already been set for you by the `php artisan key:generate` command. + +Typically, this string should be 32 characters long. The key can be set in the `.env` environment file. If you have not renamed the `.env.example` file to `.env`, you should do that now. **If the application key is not set, your user sessions and other encrypted data will not be secure!** + +#### Additional Configuration + +Cortex needs almost no other configuration out of the box. You are free to get started developing! However, you may wish to review the `config/app.php` file and its documentation. It contains several options such as `timezone` and `locale` that you may wish to change according to your application. + +You may also want to configure a few additional components of Cortex, such as: + +- Cache +- Database +- Session + +## Web Server Configuration + +### Pretty URLs + +#### Apache + +Cortex includes a `public/.htaccess` file that is used to provide URLs without the `index.php` front controller in the path. Before serving Cortex with Apache, be sure to enable the `mod_rewrite` module so the `.htaccess` file will be honored by the server. + +If the `.htaccess` file that ships with Cortex does not work with your Apache installation, try this alternative: + +```shell +Options +FollowSymLinks -Indexes +RewriteEngine On + +RewriteCond %{HTTP:Authorization} . +RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^ index.php [L] +``` + +#### Nginx + +If you are using Nginx, the following directive in your site configuration will direct all requests to the `index.php` front controller: + +```shell +location / { + try_files $uri $uri/ /index.php?$query_string; +} +``` + +Of course, when using [Punnet](https://github.com/rinvex/punnet), pretty URLs will be automatically configured. + + +## Changelog + +Refer to the [Changelog](CHANGELOG.md) for a full history of the project. + + +## Support + +The following support channels are available at your fingertips: + +- [Chat on Slack](http://chat.rinvex.com) +- [Help on Email](mailto:help@rinvex.com) +- [Follow on Twitter](https://twitter.com/rinvex) + + +## Contributing & Protocols + +Thank you for considering contributing to this project! The contribution guide can be found in [CONTRIBUTING.md](CONTRIBUTING.md). + +Bug reports, feature requests, and pull requests are very welcome. + +- [Versioning](CONTRIBUTING.md#versioning) +- [Pull Requests](CONTRIBUTING.md#pull-requests) +- [Coding Standards](CONTRIBUTING.md#coding-standards) +- [Feature Requests](CONTRIBUTING.md#feature-requests) +- [Git Flow](CONTRIBUTING.md#git-flow) + + +## Security Vulnerabilities + +If you discover a security vulnerability within this project, please send an e-mail to [security@rinvex.com](security@rinvex.com). All security vulnerabilities will be promptly addressed. + + +## About Rinvex + +Rinvex is a software solutions startup, specialized in integrated enterprise solutions for SMEs established in Alexandria, Egypt since June 2016. We believe that our drive The Value, The Reach, and The Impact is what differentiates us and unleash the endless possibilities of our philosophy through the power of software. We like to call it Innovation At The Speed Of Life. That’s how we do our share of advancing humanity. + + +## License + +This software is released under [The MIT License (MIT)](LICENSE). + +(c) 2016-2019 Rinvex LLC, Some rights reserved. diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..22a8d63 --- /dev/null +++ b/composer.json @@ -0,0 +1,60 @@ +{ + "name": "cortex/installer", + "description": "Cortex Installer is a command line tool that depends on composer to install the Cortex project seamlessly.", + "keywords": [ + "rinvex", + "cortex", + "flexible", + "framework", + "laravel", + "themes", + "solution", + "extension", + "enterprise", + "application", + "multi-lingual", + "multi-tenant", + "bootstrap", + "module" + ], + "license": "MIT", + "homepage": "https://rinvex.com", + "support": { + "email": "help@rinvex.com", + "issues": "https://github.com/rinvex/cortex/issues", + "source": "https://github.com/rinvex/cortex", + "docs": "https://github.com/rinvex/cortex/blob/master/README.md" + }, + "authors": [ + { + "name": "Rinvex LLC", + "homepage": "https://rinvex.com", + "email": "help@rinvex.com" + }, + { + "name": "Abdelrahman Omran", + "homepage": "https://omranic.com", + "email": "me@omranic.com", + "role": "Project Lead" + }, + { + "name": "The Generous Laravel Community", + "homepage": "https://github.com/rinvex/cortex/contributors" + } + ], + "autoload": { + "psr-4": { + "Cortex\\Installer\\Console\\": "src/" + } + }, + "require": { + "ext-zip": "*", + "guzzlehttp/guzzle": "~6.0", + "symfony/console": "~3.0|~4.0", + "symfony/filesystem": "~3.0|~4.0", + "symfony/process": "~3.0|~4.0" + }, + "bin": [ + "cortex" + ] +} diff --git a/laravel b/laravel new file mode 100755 index 0000000..a720696 --- /dev/null +++ b/laravel @@ -0,0 +1,13 @@ +#!/usr/bin/env php +add(new Cortex\Installer\Console\NewCommand); + +$app->run(); diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..f30e3f8 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,44 @@ + + + + + ./tests/Unit + + + ./tests/Feature + + + + + ./src + + + + + + + + + + + + + + + + + + diff --git a/src/NewCommand.php b/src/NewCommand.php new file mode 100755 index 0000000..e273eed --- /dev/null +++ b/src/NewCommand.php @@ -0,0 +1,228 @@ +setName('new') + ->setDescription('Create a new Cortex application') + ->addArgument('name', InputArgument::OPTIONAL) + ->addOption('dev', null, InputOption::VALUE_NONE, 'Installs the latest "development" release') + ->addOption('force', 'f', InputOption::VALUE_NONE, 'Forces install even if the directory already exists'); + } + + /** + * Execute the command. + * + * @param \Symfony\Component\Console\Input\InputInterface $input + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @return void + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + if (! class_exists('ZipArchive')) { + throw new RuntimeException('The Zip PHP extension is not installed. Please install it and try again.'); + } + + $directory = ($input->getArgument('name')) ? getcwd().'/'.$input->getArgument('name') : getcwd(); + + if (! $input->getOption('force')) { + $this->verifyApplicationDoesntExist($directory); + } + + $output->writeln('Crafting application...'); + + $version = $this->getVersion($input); + + $this->download($zipFile = $this->makeFilename(), $version) + ->extract($zipFile, $directory) + ->prepareWritableDirectories($directory, $output) + ->cleanUp($zipFile); + + $composer = $this->findComposer(); + + $commands = [ + $composer.' install --no-scripts', + $composer.' run-script post-root-package-install', + $composer.' run-script post-create-project-cmd', + $composer.' run-script post-autoload-dump', + ]; + + if ($input->getOption('no-ansi')) { + $commands = array_map(function ($value) { + return $value.' --no-ansi'; + }, $commands); + } + + if ($input->getOption('quiet')) { + $commands = array_map(function ($value) { + return $value.' --quiet'; + }, $commands); + } + + $process = new Process(implode(' && ', $commands), $directory, null, null, null); + + if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) { + $process->setTty(true); + } + + $process->run(function ($type, $line) use ($output) { + $output->write($line); + }); + + $output->writeln('Application ready! Build something amazing.'); + } + + /** + * Verify that the application does not already exist. + * + * @param string $directory + * @return void + */ + protected function verifyApplicationDoesntExist($directory) + { + if ((is_dir($directory) || is_file($directory)) && $directory != getcwd()) { + throw new RuntimeException('Application already exists!'); + } + } + + /** + * Generate a random temporary filename. + * + * @return string + */ + protected function makeFilename() + { + return getcwd().'/cortex_'.md5(time().uniqid()).'.zip'; + } + + /** + * Download the temporary Zip to the given file. + * + * @param string $zipFile + * @param string $version + * @return $this + */ + protected function download($zipFile, $version = 'master') + { + switch ($version) { + case 'develop': + $filename = 'develop.zip'; + break; + case 'master': + $filename = 'master.zip'; + break; + } + + $response = (new Client)->get('https://github.com/rinvex/cortex/archive/'.$filename); + + file_put_contents($zipFile, $response->getBody()); + + return $this; + } + + /** + * Extract the Zip file into the given directory. + * + * @param string $zipFile + * @param string $directory + * @return $this + */ + protected function extract($zipFile, $directory) + { + $archive = new ZipArchive; + + $archive->open($zipFile); + + $archive->extractTo($directory); + + $archive->close(); + + return $this; + } + + /** + * Clean-up the Zip file. + * + * @param string $zipFile + * @return $this + */ + protected function cleanUp($zipFile) + { + @chmod($zipFile, 0777); + + @unlink($zipFile); + + return $this; + } + + /** + * Make sure the storage and bootstrap cache directories are writable. + * + * @param string $appDirectory + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @return $this + */ + protected function prepareWritableDirectories($appDirectory, OutputInterface $output) + { + $filesystem = new Filesystem; + + try { + $filesystem->chmod($appDirectory.DIRECTORY_SEPARATOR."bootstrap/cache", 0755, 0000, true); + $filesystem->chmod($appDirectory.DIRECTORY_SEPARATOR."storage", 0755, 0000, true); + } catch (IOExceptionInterface $e) { + $output->writeln('You should verify that the "storage" and "bootstrap/cache" directories are writable.'); + } + + return $this; + } + + /** + * Get the version that should be downloaded. + * + * @param \Symfony\Component\Console\Input\InputInterface $input + * @return string + */ + protected function getVersion(InputInterface $input) + { + if ($input->getOption('dev')) { + return 'develop'; + } + + return 'master'; + } + + /** + * Get the composer command for the environment. + * + * @return string + */ + protected function findComposer() + { + if (file_exists(getcwd().'/composer.phar')) { + return '"'.PHP_BINARY.'" composer.phar'; + } + + return 'composer'; + } +} diff --git a/zipper.sh b/zipper.sh new file mode 100755 index 0000000..c3809f1 --- /dev/null +++ b/zipper.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +wget https://github.com/rinvex/cortex-installer/archive/master.zip +unzip master.zip -d working +cd working/cortex-master +composer install +zip -ry ../../cortex-craft.zip . +cd ../.. +mv cortex-craft.zip public/cortex-craft.zip +rm -rf working +rm master.zip