1.0.0 Alpha Release
This commit is contained in:
parent
9fb26e9aa0
commit
c2b7be0ea2
297 changed files with 13712 additions and 2517 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,6 +11,7 @@ build
|
|||
src/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php
|
||||
src/ncc/ThirdParty/jelix/version/autoload_spl.php
|
||||
src/ncc/ThirdParty/nikic/PhpParser/autoload_spl.php
|
||||
src/ncc/ThirdParty/php_parallel_lint/php_console_color/autoload_spl.php
|
||||
src/ncc/ThirdParty/Symfony/polyfill-ctype/autoload_spl.php
|
||||
src/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php
|
||||
src/ncc/ThirdParty/Symfony/polyfill-uuid/autoload_spl.php
|
||||
|
|
33
.gitlab-ci.yml
Normal file
33
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,33 @@
|
|||
image: php:8.1
|
||||
|
||||
before_script:
|
||||
# Install some stuff that the image doesn't come with
|
||||
- apt update -yqq
|
||||
- apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
||||
|
||||
# Install phive
|
||||
- wget -O phive.phar https://phar.io/releases/phive.phar
|
||||
- wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
|
||||
- gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
|
||||
- gpg --verify phive.phar.asc phive.phar
|
||||
- chmod +x phive.phar
|
||||
- mv phive.phar /usr/local/bin/phive
|
||||
|
||||
# install phpab
|
||||
- phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C
|
||||
|
||||
build:
|
||||
script:
|
||||
- make tar
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH
|
||||
|
||||
release:
|
||||
script:
|
||||
- make tar
|
||||
- mv build/build.tar.gz build/ncc_$CI_COMMIT_TAG.tar.gz
|
||||
artifacts:
|
||||
paths:
|
||||
- build/ncc_$CI_COMMIT_TAG.tar.gz
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
6
.idea/copyright/Nosial.xml
generated
Normal file
6
.idea/copyright/Nosial.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
|||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="Copyright (c) Nosial &#36;originalComment.match("Copyright \(c\) (\d+)", 1, "-", "&#36;today.year")2022-&#36;today.year, all rights reserved. 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 NON-INFRINGEMENT. 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. " />
|
||||
<option name="myName" value="Nosial" />
|
||||
</copyright>
|
||||
</component>
|
7
.idea/copyright/profiles_settings.xml
generated
Normal file
7
.idea/copyright/profiles_settings.xml
generated
Normal file
|
@ -0,0 +1,7 @@
|
|||
<component name="CopyrightManager">
|
||||
<settings default="Nosial">
|
||||
<module2copyright>
|
||||
<element module="NCC Source files" copyright="Nosial" />
|
||||
</module2copyright>
|
||||
</settings>
|
||||
</component>
|
2
.idea/ncc.iml
generated
2
.idea/ncc.iml
generated
|
@ -8,6 +8,8 @@
|
|||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/docs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tests/example_project/ncc" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.idea/httpRequests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tests/example_project/build" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
|
|
17
.idea/php.xml
generated
17
.idea/php.xml
generated
|
@ -1,11 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MessDetectorOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PHPCSFixerOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PHPCodeSnifferOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PhpIncludePathManager">
|
||||
<include_path>
|
||||
<path value="/usr/share/php" />
|
||||
</include_path>
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.1">
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.2">
|
||||
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
||||
</component>
|
||||
<component name="PhpStanOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PsalmOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
</project>
|
3
.idea/scopes/Autoloaders.xml
generated
Normal file
3
.idea/scopes/Autoloaders.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="Autoloaders" pattern="file:src/ncc/autoload.php||file:src/ncc/autoload_spl.php||file:src/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php||file:src/ncc/ThirdParty/jelix/version/autoload_spl.php||file:src/ncc/ThirdParty/nikic/PhpParser/autoload_spl.php||file:src/ncc/ThirdParty/theseer/DirectoryScanner/autoload_spl.php||file:src/ncc/ThirdParty/theseer/Autoload/autoload_spl.php||file:src/ncc/ThirdParty/Symfony/Yaml/autoload_spl.php||file:src/ncc/ThirdParty/Symfony/Uid/autoload_spl.php||file:src/ncc/ThirdParty/Symfony/Process/autoload_spl.php||file:src/ncc/ThirdParty/Symfony/polyfill-uuid/autoload_spl.php||file:src/ncc/ThirdParty/Symfony/polyfill-uuid/bootstrap.php||file:src/ncc/ThirdParty/Symfony/polyfill-uuid/bootstrap80.php||file:src/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php||file:src/ncc/ThirdParty/Symfony/polyfill-mbstring/bootstrap.php||file:src/ncc/ThirdParty/Symfony/polyfill-mbstring/bootstrap80.php||file:src/ncc/ThirdParty/Symfony/polyfill-ctype/autoload_spl.php||file:src/ncc/ThirdParty/Symfony/polyfill-ctype/bootstrap.php||file:src/ncc/ThirdParty/Symfony/polyfill-ctype/bootstrap80.php||file:src/ncc/ThirdParty/Symfony/Filesystem/autoload_spl.php" />
|
||||
</component>
|
3
.idea/scopes/Installer_Source_files.xml
generated
Normal file
3
.idea/scopes/Installer_Source_files.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="Installer Source files" pattern="file:src/installer/extension||file:src/installer/generate_build_files.php||file:src/installer/hash_check.php||file:src/installer/installer" />
|
||||
</component>
|
2
.idea/scopes/NCC_Source_files.xml
generated
2
.idea/scopes/NCC_Source_files.xml
generated
|
@ -1,3 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="NCC Source files" pattern="file[ncc]:src/ncc/Managers//*||file[ncc]:src/ncc/Abstracts//*||file[ncc]:src/ncc/Exceptions//*||file[ncc]:src/ncc/Runtime//*||file[ncc]:src/ncc/Extensions//*||file[ncc]:src/ncc/CLI//*||file[ncc]:src/ncc/Classes//*||file[ncc]:src/ncc/Objects//*||file[ncc]:src/ncc/Interfaces//*||file[ncc]:src/ncc/Utilities//*||file:src/ncc/ncc.php||file:src/ncc/ncc||file:src/ncc/banner_basic||file:src/ncc/autoload_spl.php||file:src/ncc/autoload.php" />
|
||||
<scope name="NCC Source files" pattern="file[ncc]:src/ncc/Managers//*||file[ncc]:src/ncc/Abstracts//*||file[ncc]:src/ncc/Exceptions//*||file[ncc]:src/ncc/Runtime//*||file[ncc]:src/ncc/Extensions//*||file[ncc]:src/ncc/CLI//*||file[ncc]:src/ncc/Classes//*||file[ncc]:src/ncc/Objects//*||file[ncc]:src/ncc/Interfaces//*||file[ncc]:src/ncc/Utilities//*||file:src/ncc/ncc.php||file:src/ncc/ncc||file:src/ncc/banner_basic||file:src/ncc/autoload_spl.php||file:src/ncc/autoload.php||file:src/ncc/Runtime.php" />
|
||||
</component>
|
3
.idea/scopes/Symfony_Filesystem.xml
generated
Normal file
3
.idea/scopes/Symfony_Filesystem.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="Symfony\Filesystem" pattern="file[ncc]:src/ncc/ThirdParty/Symfony/Filesystem//*" />
|
||||
</component>
|
3
.idea/scopes/Symfony_Process.xml
generated
Normal file
3
.idea/scopes/Symfony_Process.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="Symfony\Process" pattern="file[ncc]:src/ncc/ThirdParty/Symfony/Process//*" />
|
||||
</component>
|
3
.idea/scopes/Symfony_Uid.xml
generated
Normal file
3
.idea/scopes/Symfony_Uid.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="Symfony\Uid" pattern="file[ncc]:src/ncc/ThirdParty/Symfony/Uid//*" />
|
||||
</component>
|
3
.idea/scopes/Symfony_Yaml.xml
generated
Normal file
3
.idea/scopes/Symfony_Yaml.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="Symfony\Yaml" pattern="file[ncc]:src/ncc/ThirdParty/Symfony/Yaml//*" />
|
||||
</component>
|
3
.idea/scopes/Symfony_polyfill_ctype.xml
generated
Normal file
3
.idea/scopes/Symfony_polyfill_ctype.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="Symfony\polyfill-ctype" pattern="file[ncc]:src/ncc/ThirdParty/Symfony/polyfill-ctype//*" />
|
||||
</component>
|
3
.idea/scopes/Symfony_polyfill_mbstring.xml
generated
Normal file
3
.idea/scopes/Symfony_polyfill_mbstring.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="Symfony\polyfill-mbstring" pattern="file[ncc]:src/ncc/ThirdParty/Symfony/polyfill-mbstring//*" />
|
||||
</component>
|
3
.idea/scopes/Symfony_polyfill_uuid.xml
generated
Normal file
3
.idea/scopes/Symfony_polyfill_uuid.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="Symfony\polyfill-uuid" pattern="file[ncc]:src/ncc/ThirdParty/Symfony/polyfill-uuid//*" />
|
||||
</component>
|
3
.idea/scopes/defuse.xml
generated
Normal file
3
.idea/scopes/defuse.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="defuse" pattern="file[ncc]:src/ncc/ThirdParty/defuse//*" />
|
||||
</component>
|
3
.idea/scopes/defuse_php_encryption.xml
generated
Normal file
3
.idea/scopes/defuse_php_encryption.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="defuse\php-encryption" pattern="file[ncc]:src/ncc/ThirdParty/defuse/php-encryption//*" />
|
||||
</component>
|
3
.idea/scopes/jelix.xml
generated
Normal file
3
.idea/scopes/jelix.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="jelix" pattern="file[ncc]:src/ncc/ThirdParty/jelix//*" />
|
||||
</component>
|
3
.idea/scopes/jelix_version.xml
generated
Normal file
3
.idea/scopes/jelix_version.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="jelix\version" pattern="file[ncc]:src/ncc/ThirdParty/jelix/version//*" />
|
||||
</component>
|
3
.idea/scopes/nikic.xml
generated
Normal file
3
.idea/scopes/nikic.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="nikic" pattern="file[ncc]:src/ncc/ThirdParty/nikic//*" />
|
||||
</component>
|
3
.idea/scopes/nikic_PhpParser.xml
generated
Normal file
3
.idea/scopes/nikic_PhpParser.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="nikic\PhpParser" pattern="file[ncc]:src/ncc/ThirdParty/nikic/PhpParser//*" />
|
||||
</component>
|
3
.idea/scopes/theseer.xml
generated
Normal file
3
.idea/scopes/theseer.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="theseer" pattern="file[ncc]:src/ncc/ThirdParty/theseer//*" />
|
||||
</component>
|
3
.idea/scopes/theseer_Autoload.xml
generated
Normal file
3
.idea/scopes/theseer_Autoload.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="theseer\Autoload" pattern="file[ncc]:src/ncc/ThirdParty/theseer/Autoload//*" />
|
||||
</component>
|
3
.idea/scopes/theseer_DirectoryScanner.xml
generated
Normal file
3
.idea/scopes/theseer_DirectoryScanner.xml
generated
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="DependencyValidationManager">
|
||||
<scope name="theseer\DirectoryScanner" pattern="file[ncc]:src/ncc/ThirdParty/theseer/DirectoryScanner//*" />
|
||||
</component>
|
36
CODE_OF_CONDUCT.md
Normal file
36
CODE_OF_CONDUCT.md
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
# Code of Conduct
|
||||
|
||||
We are committed to maintaining a welcoming and inclusive environment for all contributors. In order to ensure that
|
||||
everyone feels safe and respected, we have established the following code of conduct.
|
||||
|
||||
## Our Standards
|
||||
|
||||
We expect all contributors to:
|
||||
|
||||
- Be respectful and considerate of others
|
||||
- Use inclusive language
|
||||
- Avoid demeaning, discriminatory, or harassing behavior
|
||||
- Respect the boundaries of others
|
||||
|
||||
We will not tolerate any behavior that does not align with these standards.
|
||||
|
||||
## Consequences of Unacceptable Behavior
|
||||
|
||||
Unacceptable behavior will not be tolerated and may result in consequences such as warning, blocking of access, or
|
||||
permanent removal from the project.
|
||||
|
||||
## Reporting Unacceptable Behavior
|
||||
|
||||
If you witness or experience any behavior that is not aligned with our code of conduct, please report it immediately by
|
||||
contacting the project maintainers. You can open an issue on the project's repository at [https://git.n64.cc/nosial/ncc](https://git.n64.cc/nosial/ncc).
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the Contributor Covenant, version 2.0, available at
|
||||
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html).
|
||||
|
||||
## License
|
||||
|
||||
This Code of Conduct is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of
|
||||
this license, visit [http://creativecommons.org/licenses/by/4.0/](http://creativecommons.org/licenses/by/4.0/).
|
25
CONTRIBUTING.md
Normal file
25
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Contributing to NCC
|
||||
|
||||
We welcome contributions to NCC! If you have an idea for how to improve the project, please don't hesitate to reach out.
|
||||
There are many ways to contribute, and we appreciate all forms of support.
|
||||
|
||||
## How to Contribute
|
||||
|
||||
- **Report a bug**: If you think you have found a bug in NCC, please open an issue and include as much detail as
|
||||
possible to help us reproduce and fix the issue.
|
||||
- **Request a feature**: Have an idea for a new feature or improvement? Open an issue to start a discussion.
|
||||
- **Submit a pull request**: If you have developed a fix for a bug or have implemented a new feature, please submit a
|
||||
pull request for review.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
We are committed to maintaining a welcoming and inclusive environment for all contributors. Please read and follow our
|
||||
[Code of Conduct](https://git.n64.cc/nosial/ncc/CODE_OF_CONDUCT.md).
|
||||
|
||||
## License
|
||||
|
||||
By contributing to NCC, you agree that your contributions will be licensed under the MIT License.
|
||||
|
||||
## Attribution
|
||||
|
||||
NCC is Copyright (c) Nosial. Please include the copyright notice in any distributed code.
|
851
DOCUMENTATION.md
851
DOCUMENTATION.md
|
@ -5,30 +5,839 @@ NCC, from basic installation, basic usage, standards and much more.
|
|||
|
||||
## Table of contents
|
||||
|
||||
- Introduction
|
||||
- What is NCC?
|
||||
- Advantages over other software
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
<!-- TOC -->
|
||||
* [NCC Documentation](#ncc-documentation)
|
||||
* [Table of contents](#table-of-contents)
|
||||
* [Introduction](#introduction)
|
||||
* [What is NCC?](#what-is-ncc)
|
||||
* [Building NCC from source](#building-ncc-from-source)
|
||||
* [Requirements to build](#requirements-to-build)
|
||||
* [Installing phpab](#installing-phpab)
|
||||
* [Building NCC](#building-ncc)
|
||||
* [Redist](#redist)
|
||||
* [Tar](#tar)
|
||||
* [Installing NCC](#installing-ncc)
|
||||
* [Command line arguments](#command-line-arguments)
|
||||
* [Uninstalling NCC](#uninstalling-ncc)
|
||||
* [NCC Command-line Interface](#ncc-command-line-interface)
|
||||
* [Management Commands](#management-commands)
|
||||
* [Utility Commands](#utility-commands)
|
||||
* [Options](#options)
|
||||
* [Projects](#projects)
|
||||
* [Creating a project](#creating-a-project)
|
||||
* [project.json structure](#projectjson-structure)
|
||||
* [project](#project)
|
||||
* [project.compiler](#projectcompiler)
|
||||
* [project.update_source](#projectupdatesource)
|
||||
* [project.update_source.repository](#projectupdatesourcerepository)
|
||||
* [assembly](#assembly)
|
||||
* [execution_policies](#executionpolicies)
|
||||
* [execution_policy](#executionpolicy)
|
||||
* [execution_policy.execute](#executionpolicyexecute)
|
||||
* [execution_policy.exit_handlers](#executionpolicyexithandlers)
|
||||
* [exit_handler](#exithandler)
|
||||
* [installer](#installer)
|
||||
* [build](#build)
|
||||
* [dependency](#dependency)
|
||||
* [Source Types](#source-types)
|
||||
* [Execution Policies](#execution-policies)
|
||||
* [Supported Runners](#supported-runners)
|
||||
* [Configuring Runners](#configuring-runners)
|
||||
* [Remote Sources](#remote-sources)
|
||||
* [Supported sources](#supported-sources)
|
||||
* [Default sources](#default-sources)
|
||||
* [Managing sources](#managing-sources)
|
||||
* [Adding a source](#adding-a-source)
|
||||
* [Removing a source](#removing-a-source)
|
||||
* [Listing sources](#listing-sources)
|
||||
* [Credential Management](#credential-management)
|
||||
* [Adding credentials](#adding-credentials)
|
||||
* [Removing credentials](#removing-credentials)
|
||||
* [Listing credentials](#listing-credentials)
|
||||
* [UUIDs](#uuids)
|
||||
* [Versioning](#versioning)
|
||||
* [Version Format](#version-format)
|
||||
* [Version Format Compatibility](#version-format-compatibility)
|
||||
* [Naming a package](#naming-a-package)
|
||||
* [Naming conventions](#naming-conventions)
|
||||
* [References](#references)
|
||||
* [Error Codes](#error-codes)
|
||||
<!-- TOC -->
|
||||
|
||||
## Introduction
|
||||
|
||||
# Introduction (May 24, 2022)
|
||||
|
||||
This section serves the basic introduction of NCC, what it's used for and how you can
|
||||
use it in your own projects or use it to run and build other projects that are designed
|
||||
to be used with NCC.
|
||||
This section serves the basic introduction of NCC, what it's used for and how you can use it in your own projects or use
|
||||
it to run and build other projects that are designed to be used with NCC.
|
||||
|
||||
## What is NCC?
|
||||
|
||||
NCC (*Acronym for **N**osial **C**ode **C**ompiler*) is a multi-purpose compiler,
|
||||
package manager and toolkit. Allowing projects to be managed and built more easily
|
||||
without having to mess with all the traditional tools that comes with your language
|
||||
of choice. Right now NCC only supports PHP as it's written in PHP but extensions
|
||||
for other languages/frameworks can be built into the software in the future when
|
||||
the need comes for it.
|
||||
NCC (*Acronym for **N**osial **C**ode **C**ompiler*) is a multi-purpose compiler, package manager and toolkit. Allowing
|
||||
projects to be managed and built more easily without having to mess with all the traditional tools that comes with your
|
||||
language of choice. Right now NCC only supports PHP as it's written in PHP but extensions for other languages/frameworks
|
||||
can be built into the software in the future when the need comes for it.
|
||||
|
||||
NCC can make the process of building your code into a redistributable package much
|
||||
more efficient by treating each building block of your project as a component that
|
||||
is interconnected in your environment instead of the more popular route taken by
|
||||
package/dependency managers such as [composer](https://getcomposer.org/),
|
||||
[npm](https://www.npmjs.com/) or [pypi (or pip)](https://pypi.org/).
|
||||
NCC can make the process of building your code into a redistributable package much more efficient by treating each
|
||||
building block of your project as a component that is interconnected in your environment instead of the more popular
|
||||
route taken by package/dependency managers such as [composer](https://getcomposer.org/),[npm](https://www.npmjs.com/) or
|
||||
[pypi (or pip)](https://pypi.org/).
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
|
||||
# Building NCC from source
|
||||
|
||||
Building NCC from source is easy with very few requirements to start building. At the moment ncc can only be debugged or
|
||||
tested by building a redistributable source and installing it.
|
||||
|
||||
## Requirements to build
|
||||
|
||||
- php8.0+
|
||||
- php-mbstring
|
||||
- php-ctype
|
||||
- php-common (covers tokenizer & posix among others)
|
||||
- make
|
||||
- phpab
|
||||
- tar *(optional)*
|
||||
|
||||
## Installing phpab
|
||||
|
||||
phpab is also known as [PHP Autoload Builder](https://github.com/theseer/Autoload), phpab is an open source tool used
|
||||
for creating autoload files, ncc needs this tool in order to generate it's autoload files whenever there's any changes
|
||||
to its source code.
|
||||
|
||||
This tool is only required for building and or creating a redistributable package of ncc. This component is not
|
||||
required to be installed to use ncc.
|
||||
|
||||
for some components that require static loading, ncc will automatically load it using its own
|
||||
[autoloader](src/autoload/autoload.php)
|
||||
|
||||
The recommended way to install phpab is by using [phive](https://phar.io/), if you don't have phive installed you can
|
||||
install it by running these commands in your terminal (from the official documentation)
|
||||
|
||||
```shell
|
||||
wget -O phive.phar https://phar.io/releases/phive.phar
|
||||
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
|
||||
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
|
||||
gpg --verify phive.phar.asc phive.phar
|
||||
chmod +x phive.phar
|
||||
sudo mv phive.phar /usr/local/bin/phive
|
||||
```
|
||||
|
||||
Once phive is installed, you can run the final command to install phpab
|
||||
|
||||
```shell
|
||||
sudo phive install phpab --global
|
||||
```
|
||||
|
||||
or you can run this command to install it locally
|
||||
|
||||
```shell
|
||||
phive install phpab
|
||||
```
|
||||
|
||||
**Note:** Optionally, you may want to have `phab` available in your `$PATH`, this can be done with this command.
|
||||
*(Replace `x.xx.x` with your version number)* this is if you installed it locally
|
||||
|
||||
```shell
|
||||
ln -s /home/user/.phive/phars/phpab-x.xx.x.phar /usr/local/bin/phpab
|
||||
```
|
||||
|
||||
## Building NCC
|
||||
|
||||
First, navigate to the main directory of NCC's source code where the [Makefile](Makefile) is present. If you
|
||||
already attempted to or had built ncc before, it's recommended to use `make clean` before building.
|
||||
|
||||
### Redist
|
||||
|
||||
Running `redist` from the Makefile will generate all the required autoloader for ncc and move all the required files
|
||||
into one redistributable source folder under a directory called `build/src`
|
||||
|
||||
```shell
|
||||
make redist
|
||||
```
|
||||
|
||||
|
||||
### Tar
|
||||
|
||||
Running `tar` will run redist before packaging the redistributable source into a tar.gz file that can be distributed to
|
||||
other machines, this process is not a requirement.
|
||||
|
||||
```shell
|
||||
make tar
|
||||
```
|
||||
|
||||
Once you have a populated `build/src` folder, you can simply run execute the `installer` file to install your build of
|
||||
ncc onto the running machine.
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
|
||||
# Installing NCC
|
||||
|
||||
Installing NCC is easy, you can either download the redistributable source from the [releases](https://git.n64.cc/nosial/ncc/-/releases)
|
||||
page or you can build it from source using the instructions above.
|
||||
|
||||
Once you have the redistributable source, you can simply run execute the `INSTALL` file to install ncc onto the running
|
||||
machine.
|
||||
|
||||
## Command line arguments
|
||||
|
||||
The installer accepts a few command line arguments that can be used to customize the installation process.
|
||||
|
||||
`--help` Displays the help message
|
||||
|
||||
`--auto` Automatically installs ncc without asking for user input.
|
||||
|
||||
**Note:** To install composer along with ncc, you must also provide the `--install-composer` argument.
|
||||
|
||||
`--install-composer` Installs composer along with ncc. By default, ncc will not install composer and during the
|
||||
installation process you will be asked if you want to install composer along-side ncc, this will not conflict
|
||||
with any existing composer installation.
|
||||
|
||||
`--install-dir` Specifies the directory where ncc will be installed to. By default, ncc will be installed to `/etc/ncc`
|
||||
|
||||
`--bypass-cli-check` Bypasses the check in the installer that checks if the installer is being run from the command
|
||||
line, this is useful if you want to install ncc from a script.
|
||||
|
||||
`--bypass-checksum` Bypasses the checksum check in the installer, this is useful if you made modifications to the
|
||||
installation files and want to install a modified version of ncc.
|
||||
|
||||
But this isn't recommended and the proper way to do this is to modify the source code and build ncc from source,
|
||||
the Makefile task will automatically rebuild the checksum file for you.
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
|
||||
# Uninstalling NCC
|
||||
|
||||
Uninstalling NCC is easy, simply delete the directory where ncc was installed to, by default this is `/etc/ncc`.
|
||||
|
||||
It's recommended to run `ncc package --uninstall-all` before uninstalling ncc, this will uninstall all the packages
|
||||
that were installed using ncc and remove any artifacts that were created by these packages.
|
||||
|
||||
**Note:**
|
||||
- To delete all the data that ncc has created, you can also delete the `/var/ncc` directory.
|
||||
- Finally, remove the symlink that was created in `/usr/local/bin`to the `ncc` entry point file.
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
|
||||
# NCC Command-line Interface
|
||||
|
||||
NCC provides a command-line interface that can be used to manage packages, create projects, compile source code, manage
|
||||
remote sources, configure ncc, and more. You can run `ncc --help` to see a list of all the available commands.
|
||||
|
||||

|
||||
|
||||
## Management Commands
|
||||
|
||||
Management commands are used to manage ncc's configuration, remote sources, and packages.
|
||||
|
||||
|
||||
`project` Manage or create a project (*see [Projects](#projects) section*)
|
||||
|
||||
`package` Manage packages
|
||||
|
||||
`source` Manage remote sources
|
||||
|
||||
`config` Manage ncc's configuration
|
||||
|
||||
## Utility Commands
|
||||
|
||||
Utility commands are used to perform tasks in the current directory or project.
|
||||
|
||||
`build` Compile source code of the project
|
||||
|
||||
`exec` Executes a package's entry point file (package must be installed)
|
||||
|
||||
## Options
|
||||
|
||||
NCC also accepts a few command line arguments that can be used to alter the behavior of the command-line interface.
|
||||
|
||||
`-l <level>, --log-level <level>` Sets the log level, this can be one of `debug`, `verbose`, `info`, `warn`, `error`, `fatal`
|
||||
|
||||
`-v, --version` Displays the version of ncc
|
||||
|
||||
`-h, --help` Displays the help message
|
||||
|
||||
`--basic-ascii` Renders some messages using basic ASCII characters instead of unicode characters
|
||||
|
||||
`--no-color` Disables colored output
|
||||
|
||||
`--no-banner` Omits displaying the NCC graphical banner
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
|
||||
# Projects
|
||||
|
||||
A project is a directory that contains all the source files to your program, it's similar to a workspace in other IDEs.
|
||||
Usually contains a `project.json` file which contains all the information about the project that ncc needs to know.
|
||||
|
||||
This can include the name of the program, the version of the program, the author of the program, the dependencies of the
|
||||
program, build configurations, and more.
|
||||
|
||||
This section will cover the basics of creating a project and managing it and the technical details of the `project.json`
|
||||
file.
|
||||
|
||||
|
||||
## Creating a project
|
||||
|
||||
This is the first step in using ncc, you must create a project before you can do anything else (*not really because you
|
||||
can install packages without needing to create a project and run them directly, but you get the point*)
|
||||
|
||||
The NCC command-line tool provides a management command called `project` that can be used to create a new project
|
||||
or to manage an existing project.
|
||||
|
||||
```shell
|
||||
ncc project create --package "com.example.program" --name "Example Program"
|
||||
```
|
||||
|
||||
This command will create a new project in the current directory, the `--package` argument specifies the package name of
|
||||
the project, this is used to identify the project and to avoid conflicts with other projects that may have the same name.
|
||||
|
||||
The `--name` argument specifies the name of the project, this is used to display the name of the project in the project
|
||||
manager and in the project settings. This doesn't have to be the same as the package name or unique.
|
||||
|
||||
**Note:** If the options are not provided, the command will prompt you for the package name and the project name.
|
||||
|
||||
For more information about the project command, you can run `ncc project --help` to display the help message.
|
||||
|
||||
## project.json structure
|
||||
|
||||
The `project.json` file is a JSON file that contains all the information about the project.
|
||||
|
||||
When a project is created, the `project.json` file is automatically created and populated with the default values, you
|
||||
can modify this file to change the default values or to add more information about the project.
|
||||
|
||||
This section will go over the structure of the `project.json` file and what each field does.
|
||||
|
||||
### project
|
||||
|
||||
The `project` field contains information about the project, such as what compiler extension to use, options to pass on
|
||||
to the compiler, and more.
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
|---------------|--------------------------------------|----------|----------------------------------------------------------------------------------------------------|
|
||||
| compiler | [project.compiler](#projectcompiler) | Yes | The compiler extension that the project uses to compile the program |
|
||||
| options | `array` | No | An array of options to pass on to the compiler, the options vary depending on the compiler and NCC |
|
||||
| update_source | `project.update_source` | No | The source for where the program can fetch updates from |
|
||||
|
||||
### project.compiler
|
||||
|
||||
The `project.compiler` field contains information about the compiler extension that the project uses to compile
|
||||
the program.
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
|-----------------|----------|----------|------------------------------------------------------------------------------------------------|
|
||||
| extension | `string` | Yes | The name of the compiler extension that the project uses to compile the program |
|
||||
| minimum_version | `string` | No | The minimum version of the compiler extension that the project requires to compile the program |
|
||||
| maximum_version | `string` | No | The maximum version of the compiler extension that the project requires to compile the program |
|
||||
|
||||
### project.update_source
|
||||
|
||||
The `project.update_source` field contains information about the source where the program can fetch updates from.
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
|------------|------------------------------------|----------|-----------------------------------------------------------------------------------------------------------------------|
|
||||
| source | `string` | Yes | The source where the program can fetch updates from, see [Remote Sources](#remote-sources) for additional information |
|
||||
| repository | `project.update_source.repository` | Yes | The source to configure in NCC when installing the package |
|
||||
|
||||
### project.update_source.repository
|
||||
|
||||
The `project.update_source.repository` field contains information about the source to configure in NCC when installing
|
||||
the package. This allows you to set up a remote source that your package can use to fetch updates from, this is useful
|
||||
if you want to distribute your program to other people.
|
||||
|
||||
It would be useful to read more about [Remote Sources](#remote-sources) before continuing.
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
|------|----------|----------|---------------------------------------------------------------------------------------|
|
||||
| name | `string` | Yes | The name of the source to configure in NCC when installing the package (eg; `github`) |
|
||||
| type | `string` | Yes | The API type to use with this source, see [Supported sources](#supported-sources) |
|
||||
| host | `string` | Yes | The host of the source, this is the domain name of the source (eg; `api.github.com`) |
|
||||
| ssl | `bool` | No | Whether to use SSL or not when connecting to this source |
|
||||
|
||||
|
||||
### assembly
|
||||
|
||||
The `assembly` field contains metadata about the program, such as the name, version, description, so on.
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
|-------------|----------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| name | `string` | Yes | The name of the package, this is used to display the name of the package (eg; `Example Program`) |
|
||||
| package | `string` | Yes | The package name of the program, this is used to identify the package and to avoid conflicts with other packages that may have the same name, see [Naming a package](#naming-a-package) for additional information |
|
||||
| description | `string` | No | The description of the package, this is used to display a description of the package when installing |
|
||||
| company | `string` | No | The company that created the package, this is used to display the company that created the package when installing |
|
||||
| product | `string` | No | The product that the package is a part of, this is used to display the product that the package is a part of when installing |
|
||||
| copyright | `string` | No | The copyright of the package |
|
||||
| trademark | `string` | No | The trademark of the package |
|
||||
| version | `string` | Yes | The version of the package, see [Versioning](#versioning) for additional information |
|
||||
| uuid | `string` | Yes | The UUID of the package, see [UUIDs](#uuids) for additional information |
|
||||
|
||||
### execution_policies
|
||||
|
||||
The `execution_policies` field contains information about the execution policies that the program uses, such as
|
||||
the execution policy that the program uses to run additional programs during different stages of the installation
|
||||
process of the package or used as the main execution policy for the program.
|
||||
|
||||
Note that this field is an array of `execution_policy` objects, see [execution_policy](#executionpolicy) for additional
|
||||
information.
|
||||
|
||||
For more information about execution policies, see [Execution Policies](#execution-policies).
|
||||
|
||||
#### execution_policy
|
||||
|
||||
The `execution_policy` object contains information about the execution policy.
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
|---------------|----------------------------------|----------|----------------------------------------------------------------------------------------------------|
|
||||
| name | `string` | Yes | The name of the execution policy, this is used to identify the execution policy |
|
||||
| runner | `string` | Yes | The name of the runner that the execution policy uses, see [Supported runners](#supported-runners) |
|
||||
| message | `string` | No | The message to display when the execution policy is being run |
|
||||
| execute | `execution_policy.execute` | Yes | The execution policy to run when the execution policy is being run |
|
||||
| exit_handlers | `execution_policy.exit_handlers` | No | The exit handlers to run when the execution policy has finished running |
|
||||
|
||||
#### execution_policy.execute
|
||||
|
||||
The `execution_policy.execute` object contains information about how to run the execution policy when triggered.
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
|-----------------------|------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| target | `string` | Yes | The target file to run when the execution policy is triggered, file path is relative to the location of your project.json file (eg; scripts/main.php) |
|
||||
| working_directory | `string` | No | The working directory to run the process in. If not specified, the working directory will be your current working directory. |
|
||||
| options | `string[]` | No | The options to pass to the process when running it. (eg; ["--foo", "bar", "-f"]) |
|
||||
| environment_variables | `string[]` | No | The environment variables to pass to the process when running it. (eg; ["FOO=bar"]) |
|
||||
| silent | `bool` | No | Whether to run the process silently or not. If not specified, the process will not be run silently. |
|
||||
| tty | `bool` | No | Whether to run the process in a TTY or not. If not specified, the process will not be run in a TTY. |
|
||||
| timeout | `int` | No | The timeout of the process in seconds. If not specified, the process will not have a timeout. |
|
||||
| idle_timeout | `int` | No | The idle timeout of the process in seconds. If not specified, the process will not have an idle timeout. |
|
||||
|
||||
#### execution_policy.exit_handlers
|
||||
|
||||
The `execution_policy.exit_handlers` object contains information about how to run the exit handlers when the execution
|
||||
policy has finished running. This is useful for running additional policies when the process has exited in a specific
|
||||
way.
|
||||
|
||||
The two handlers that can be executed automatically despite the exit code are `success` and `error`. Which means if the
|
||||
process exits with a success exit code, the `success` handler will be run, and if the process exits with an error exit
|
||||
code, the `error` handler will be run. The `warning` handler will only be run if the process exits with specified exit
|
||||
code.
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
|---------|----------------|----------|-------------------------------------------------------------------------------|
|
||||
| success | `exit_handler` | No | The exit handler to run when the process has exited successfully. |
|
||||
| warning | `exit_handler` | No | The exit handler to run when the process has exited with a warning exit code. |
|
||||
| error | `exit_handler` | No | The exit handler to run when the process has exited with an error exit code. |
|
||||
|
||||
#### exit_handler
|
||||
|
||||
The `exit_handler` object contains information about how to run the exit handler when the execution policy has finished
|
||||
running.
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
|---------------|----------|----------|---------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| message | `string` | No | The message to display when the exit handler is triggered |
|
||||
| end_execution | `bool` | No | Whether to end the execution of the program or not if this exit handler is triggered. If not specified, the program will not end execution. |
|
||||
| run | `string` | No | The name of the execution policy to run when this exit handler is triggered. |
|
||||
| exit_code | `int` | No | The exit code that the process must have exited with for this exit handler to be triggered. |
|
||||
|
||||
### installer
|
||||
|
||||
The `installer` field contains allows you to configure the execution of policies during different stages of the
|
||||
installation process of the package. Note that these files only accepts an array of strings, which are the names of
|
||||
the execution policies that you want to run during the specified stage. NCC will reject the package if the execution
|
||||
policy does not exist.
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
|----------------|------------|----------|-------------------------------------------------------------------------|
|
||||
| pre_install | `string[]` | No | The execution policies to run before the installation of the package. |
|
||||
| post_install | `string[]` | No | The execution policies to run after the installation of the package. |
|
||||
| pre_uninstall | `string[]` | No | The execution policies to run before the uninstallation of the package. |
|
||||
| post_uninstall | `string[]` | No | The execution policies to run after the uninstallation of the package. |
|
||||
| pre_update | `string[]` | No | The execution policies to run before the update of the package. |
|
||||
| post_update | `string[]` | No | The execution policies to run after the update of the package. |
|
||||
|
||||
|
||||
### build
|
||||
|
||||
The `build` field contains the configuration for the build process of the package. This field is required and must be
|
||||
configured correctly for the package to be built successfully.
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
|-----------------------|-------------------------|----------|----------------------------------------------------------------------------------------------------------------------------|
|
||||
| source_path | `string` | Yes | The path to the source directory of the package. (eg; src) |
|
||||
| default_configuration | `string` | Yes | The default build configuration to use when building the package. |
|
||||
| exclude_files | `string[]` | No | The files to exclude from the build process. |
|
||||
| options | `string[]` | No | The options to pass to the build process. |
|
||||
| main | `string` | No | The main execution policy to run when the package is executed, this is like the main entry point of the package. |
|
||||
| define_constants | `string[]` | No | Environment constants to define during the execution of your program, these values can be accessed by the NCC Runtime API. |
|
||||
| pre_build | `string[]` | No | The execution policies to run before the build process. |
|
||||
| post_build | `string[]` | No | The execution policies to run after the build process. |
|
||||
| dependencies | `dependency[]` | No | The dependencies that the package requires |
|
||||
| configurations | `build_configuration[]` | No | Predefined build configurations that can be used to produce different builds of the package |
|
||||
|
||||
### dependency
|
||||
|
||||
The `dependency` object contains information about a dependency that the package requires.
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
|-------------|----------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| name | `string` | Yes | The package name of the dependency (eg; com.example.package) |
|
||||
| source_type | `string` | No | Where NCC should get the dependency from, accepted values are `static`, `local` or `remote`. If not specified, NCC will assume `remote`. |
|
||||
| source | `string` | No | The source of the dependency, this can a remote source (see [Remote Sources](#remote-sources)) if the source is `remote` or a a local file path if the source is `static` |
|
||||
| version | `string` | No | The version of the dependency to use, if not specified, NCC will use the latest version of the dependency. (eg; 'latest') |
|
||||
|
||||
#### Source Types
|
||||
|
||||
Dependency source types are used to specify where NCC should get the dependency from, these are:
|
||||
|
||||
- `static` - This source type is used to specify that the dependency is a local file path, this is useful for dependencies
|
||||
that are not available on the remote package repository or to bundle dependencies with the package. You can only link to
|
||||
pre-compiled .ncc packages, otherwise NCC will fail to install the package.
|
||||
- `local` - This source type is used to specify that the dependency is a local package that is already installed on the
|
||||
system. This is useful for dependencies that are already installed on the system, and you want to use them in your package
|
||||
but doesn't necessarily need to pull them from a remote repository or local path. NCC expects the package to be installed
|
||||
otherwise installing the package will fail unless `--skip-dependencies` is specified.
|
||||
- `remote` - This source type is used to specify that the dependency is a remote package that is available on the remote
|
||||
repository. This is the recommended source type to use for dependencies that are available on the remote repository.
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
|
||||
# Execution Policies
|
||||
|
||||
Execution policies are the policies that are used to run additional programs during different stages of the installation
|
||||
or execution of the package. These policies are defined in your project.json `execution_policies` field with unique
|
||||
names for each policy, so that these policies can be referenced by other policies or by NCC if configured to do so.
|
||||
|
||||
## Supported Runners
|
||||
|
||||
At the moment, NCC only supports a select few "runners" that can be used to run the policies, these runners are:
|
||||
|
||||
- `php` - This runner is used to run PHP scripts, it is the default runner for NCC
|
||||
- `bash` - This runner is used to run bash scripts
|
||||
- `python` - This runner is used to run python scripts
|
||||
- `python2` - This runner is used to run python2 scripts
|
||||
- `python3` - This runner is used to run python3 scripts
|
||||
- `perl` - This runner is used to run perl scripts
|
||||
- `lua` - This runner is used to run lua scripts
|
||||
|
||||
> Note: these runners are not installed by default, you will need to install them yourself.
|
||||
|
||||
## Configuring Runners
|
||||
|
||||
If for some reason NCC cannot automatically detect the runner that you want to use, you can configure the runner yourself
|
||||
by modifying your configuration file. The configuration file is located at `/var/ncc/ncc.yaml` under the `runners` field.
|
||||
|
||||
Or you can modify the configuration file by running the following command:
|
||||
|
||||
```bash
|
||||
ncc config -p runners.bash -v /usr/bin/bash
|
||||
```
|
||||
|
||||
This will set the `bash` runner to use the `/usr/bin/bash` binary.
|
||||
|
||||
> **Note:** You must have root permissions to modify the configuration file.
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
|
||||
# Remote Sources
|
||||
|
||||
Remote Sources are the locations where packages can be downloaded from, they are similar to repositories in other package
|
||||
managers. They follow a simple syntax that allows you to specify the type of source, the location of the source, and more.
|
||||
|
||||
Examples of sources are:
|
||||
|
||||
- `symfony/process=latest@composer` - This is a package from the `symfony/process` package from the `composer` source
|
||||
- `nosial/libs.config=latest@n64` - This is a package from the `nosial/libs.config` package from the `git.n64.cc` source
|
||||
|
||||
A full example syntax may look like this:
|
||||
|
||||
```
|
||||
<vendor>/<package>:<branch>=<version>@<source name>
|
||||
```
|
||||
|
||||
This syntax is used to specify a package from a source, the syntax is split into 4 parts:
|
||||
|
||||
- The vendor of the package
|
||||
- The name of the package
|
||||
- The branch of the package (optional)
|
||||
- The version of the package (optional)
|
||||
- The name of the source (needs to be configured in ncc)
|
||||
|
||||
## Supported sources
|
||||
|
||||
NCC supports the following sources:
|
||||
|
||||
- `github` - This source uses the GitHub API to fetch packages from GitHub (Included in the default sources)
|
||||
- `gitlab` - This source uses the GitLab API to fetch packages from GitLab (Can be used with self-hosted GitLab instances)
|
||||
|
||||
Additional support for other sources will be added in the future.
|
||||
|
||||
## Default sources
|
||||
|
||||
NCC comes with a few default sources that are configured by default, these sources are:
|
||||
|
||||
- packagist.org (`composer`) **Note:** This is an internal source that uses `composer` to fetch packages from packagist.org.
|
||||
this is not configurable by the user.
|
||||
- api.github.com (`github`)
|
||||
- gitlab.com (`gitlab`)
|
||||
- git.n64.cc (`n64`)
|
||||
- gitgud.io (`gitgud`)
|
||||
|
||||
Additional sources can be added by the user. See [Adding a source](#adding-a-source) for more information.
|
||||
|
||||
## Managing sources
|
||||
|
||||
You can manage sources using the `source` command in the ncc command-line tool. This command can be used to add, remove,
|
||||
and list sources. For more information about the `source` command, you can run `ncc source --help` to display the help
|
||||
message.
|
||||
|
||||
### Adding a source
|
||||
|
||||
To add a source, you can use the `add` command in the ncc `source` command-line tool.
|
||||
|
||||
```shell
|
||||
ncc source add --name "github" --type "github" --host "github.com" --ssl
|
||||
```
|
||||
|
||||
This command will add a new source called `github` with the type `github` and the host `github.com`, the `--ssl` option
|
||||
will tell ncc to use HTTPS instead of HTTP when fetching packages from this source.
|
||||
|
||||
The reason to specify the type of source is to tell ncc what API to use when fetching packages from this source, for
|
||||
example if you specify the type as `github` then ncc will use the GitHub API to fetch packages from this source so it's
|
||||
important to specify the correct type when adding a source.
|
||||
|
||||
> **Note:** You need root permissions to add a source
|
||||
|
||||
|
||||
### Removing a source
|
||||
|
||||
To remove a source, you can use the `remove` command in the ncc `source` command-line tool.
|
||||
|
||||
```shell
|
||||
ncc source remove --name "github"
|
||||
```
|
||||
|
||||
> **Note:** You need root permissions to remove a source
|
||||
|
||||
> **Note:** Removing a source also removes the ability for some packages to be fetched or updated from this source
|
||||
|
||||
|
||||
### Listing sources
|
||||
|
||||
To list all the sources, you can use the `list` command in the ncc `source` command-line tool.
|
||||
|
||||
```shell
|
||||
ncc source list
|
||||
```
|
||||
|
||||
## Credential Management
|
||||
|
||||
Some sources require credentials to be able to fetch packages from them, for example the `gitlab` source requires
|
||||
credentials to be able to fetch packages from a self-hosted GitLab instance. NCC supports storing credentials for
|
||||
sources in a secure way using the `cred` command in the ncc command-line tool.
|
||||
|
||||
### Adding credentials
|
||||
|
||||
To add credentials for a source, you can use the `add` command in the ncc `cred` command-line tool.
|
||||
|
||||
```shell
|
||||
ncc cred add --alias "My Alias" --auth-type login --username "myusername" --password "mypassword"
|
||||
```
|
||||
|
||||
To add a private access token as a credential, you can specify the `--auth-type` as `pat` and specify the token as
|
||||
`--token` instead of providing `--username` and `--password`.
|
||||
|
||||
```shell
|
||||
ncc cred add --alias "My Alias" --auth-type pat --token="mytoken"
|
||||
```
|
||||
|
||||
By default, ncc will encrypt the entry except for the alias using the password/token that you provide.
|
||||
|
||||
However, because it's encrypted you will need to provide the password/token when using the credential since ncc will
|
||||
not be able to decrypt the entry without a password. To avoid being asked for the password/token every time you use the
|
||||
credential, you can pass on the `--no-encryption` option to the `cred` command-line tool.
|
||||
|
||||
```shell
|
||||
ncc cred add --alias "My Alias" --auth-type login --username "myusername" --password "mypassword" --no-encryption
|
||||
```
|
||||
|
||||
Encryption is applied individually to each credential, so you can have some credentials encrypted and some not encrypted.
|
||||
|
||||
> **Note:** You need root permissions to add credentials
|
||||
|
||||
|
||||
### Removing credentials
|
||||
|
||||
To remove credentials, you can use the `remove` command in the ncc `cred` command-line tool.
|
||||
|
||||
```shell
|
||||
ncc cred remove --alias "My Alias"
|
||||
```
|
||||
|
||||
> **Note:** You need root permissions to remove credentials
|
||||
|
||||
|
||||
### Listing credentials
|
||||
|
||||
To list all the credentials, you can use the `list` command in the ncc `cred` command-line tool. this will return
|
||||
a list of all the credentials that are stored in the credential store with additional information about each entry.
|
||||
|
||||
```shell
|
||||
ncc cred list
|
||||
```
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
|
||||
# UUIDs
|
||||
|
||||
UUIDs are used to uniquely identify a package, at the moment ncc doesn't do anything meaningful with UUIDs but in the
|
||||
future it will be used to identify packages and to prevent conflicts between packages with the same name.
|
||||
|
||||
The standard UUID format used is version 1, which is a time-based UUID. This means that the UUID is generated using
|
||||
the current time and the MAC address of the computer that generated the UUID.
|
||||
|
||||
``````
|
||||
xxxxxxxx-xxxx-1xxx-yxxx-xxxxxxxxxxxx
|
||||
``````
|
||||
|
||||
UUIDs are automatically generated when a package is created, you can also manually specify a UUID by editing the
|
||||
`project.json` file in the project directory, this field is found under `assembly.uuid`, see [assembly](#assembly) for
|
||||
more information.
|
||||
|
||||
> **Note:** Invalid UUIDs will cause the package to be rejected by ncc
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
|
||||
# Versioning
|
||||
|
||||
NCC uses a standard versioning system, this system is based on the [Semantic Versioning](https://semver.org/) system.
|
||||
|
||||
## Version Format
|
||||
|
||||
The version format is as follows:
|
||||
|
||||
``````
|
||||
MAJOR.MINOR.PATCH
|
||||
``````
|
||||
|
||||
- `MAJOR` is the major version of the package, this version is incremented when a major change is made to the package
|
||||
- `MINOR` is the minor version of the package, this version is incremented when a minor change is made to the package
|
||||
- `PATCH` is the patch version of the package, this version is incremented when a patch is made to the package
|
||||
|
||||
|
||||
## Version Format Compatibility
|
||||
|
||||
NCC will attempt to convert non-compatible versions to a compatible version when it comes to installing packages that
|
||||
isn't built for ncc.
|
||||
|
||||
> **Note:** NCC will reject packages with invalid version numbers, sometimes this can happen when the compatibility layer
|
||||
fails or when the version number is invalid.
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
|
||||
# Naming a package
|
||||
|
||||
NCC Follows the same naming convention as Java's naming convention. The purpose of naming a package this way is
|
||||
to easily create a "Name" of the package, this string of information contains
|
||||
|
||||
- The developer/organization behind the package
|
||||
- The package name itself
|
||||
|
||||
|
||||
## Naming conventions
|
||||
|
||||
Package names are written in all lower-case due to the fact that some operating systems treats file names
|
||||
differently, for example on Linux `Aa.txt` and `aa.txt`are two entirely different file names because of the
|
||||
capitalization and on Windows it's treated as the same file name.
|
||||
|
||||
Organizations or small developers use their domain name in reverse to begin their package names, for example
|
||||
`net.nosial.example` is a package named `example` created by a programmer at `nosial.net`
|
||||
|
||||
Just like the Java naming convention, to avoid conflicts of the same package name developers can use something
|
||||
different, for example as pointed out in Java's package naming convention developers can instead use something
|
||||
like a region to name packages, for example `net.nosial.region.example`
|
||||
|
||||
|
||||
## References
|
||||
|
||||
For Java's package naming conventions see [Naming a Package](https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html)
|
||||
from the Oracle's Java documentation resource, as the same rules apply to NCC except for *some* illegal naming
|
||||
conventions such as packages not being able to begin with `int` or numbers
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
|
||||
# Error Codes
|
||||
|
||||
NCC uses error codes to identify errors, these error codes are used to identify errors in the ncc command-line tool
|
||||
and in the ncc API.
|
||||
|
||||
| Error Code | Name |
|
||||
|:----------:|:--------------------------------------|
|
||||
| `-1700` | InvalidProjectConfigurationException |
|
||||
| `-1701` | FileNotFoundException |
|
||||
| `-1702` | DirectoryNotFoundException |
|
||||
| `-1703` | InvalidScopeException |
|
||||
| `-1704` | AccessDeniedException |
|
||||
| `-1705` | MalformedJsonException |
|
||||
| `-1706` | RuntimeException |
|
||||
| `-1707` | InvalidCredentialsEntryException |
|
||||
| `-1708` | ComponentVersionNotFoundException |
|
||||
| `-1709` | ConstantReadonlyException |
|
||||
| `-1710` | InvalidPackageNameException |
|
||||
| `-1711` | InvalidVersionNumberException |
|
||||
| `-1712` | InvalidProjectNameException |
|
||||
| `-1713` | ProjectAlreadyExistsException |
|
||||
| `-1714` | AutoloadGeneratorException |
|
||||
| `-1715` | NoUnitsFoundException |
|
||||
| `-1716` | UnsupportedPackageException |
|
||||
| `-1717` | NotImplementedException |
|
||||
| `-1718` | InvalidPackageException |
|
||||
| `-1719` | InvalidConstantNameException |
|
||||
| `-1720` | PackagePreparationFailedException |
|
||||
| `-1721` | BuildConfigurationNotFoundException |
|
||||
| `-1722` | InvalidProjectBuildConfiguration |
|
||||
| `-1723` | UnsupportedCompilerExtensionException |
|
||||
| `-1724` | InvalidPropertyValueException |
|
||||
| `-1725` | InvalidVersionConfigurationException |
|
||||
| `-1726` | UnsupportedExtensionVersionException |
|
||||
| `-1727` | BuildException |
|
||||
| `-1728` | PackageParsingException |
|
||||
| `-1729` | PackageLockException |
|
||||
| `-1730` | InstallationException |
|
||||
| `-1731` | UnsupportedComponentTypeException |
|
||||
| `-1732` | ComponentDecodeException |
|
||||
| `-1733` | ComponentChecksumException |
|
||||
| `-1734` | ResourceChecksumException |
|
||||
| `-1735` | IOException |
|
||||
| `-1736` | UnsupportedRunnerException |
|
||||
| `-1737` | VersionNotFoundException |
|
||||
| `-1738` | UndefinedExecutionPolicyException |
|
||||
| `-1739` | InvalidExecutionPolicyName |
|
||||
| `-1740` | ProjectConfigurationNotFoundException |
|
||||
| `-1741` | RunnerExecutionException |
|
||||
| `-1742` | NoAvailableUnitsException |
|
||||
| `-1743` | ExecutionUnitNotFoundException |
|
||||
| `-1744` | PackageAlreadyInstalledException |
|
||||
| `-1745` | PackageNotFoundException |
|
||||
| `-1746` | ComposerDisabledException |
|
||||
| `-1747` | InternalComposerNotAvailable |
|
||||
| `-1748` | ComposerNotAvailableException |
|
||||
| `-1749` | ComposerException |
|
||||
| `-1750` | UserAbortedOperationException |
|
||||
| `-1751` | MissingDependencyException |
|
||||
| `-1752` | HttpException |
|
||||
| `-1753` | UnsupportedRemoteSourceTypeException |
|
||||
| `-1754` | GitCloneException |
|
||||
| `-1755` | GitCheckoutException |
|
||||
| `-1756` | GitlabServiceException |
|
||||
| `-1757` | ImportException |
|
||||
| `-1758` | GitTagsException |
|
||||
| `-1759` | GithubServiceException |
|
||||
| `-1760` | AuthenticationException |
|
||||
| `-1761` | NotSupportedException |
|
||||
| `-1762` | UnsupportedProjectTypeException |
|
||||
| `-1763` | UnsupportedArchiveException |
|
||||
| `-1764` | ArchiveException |
|
||||
| `-1765` | PackageFetchException |
|
||||
| `-1766` | InvalidBuildConfigurationException |
|
||||
| `-1767` | InvalidDependencyConfiguration |
|
||||
| `-1768` | SymlinkException |
|
||||
|
|
363
LICENSE
363
LICENSE
|
@ -1,355 +1,14 @@
|
|||
------------------------
|
||||
Nosial - NCC
|
||||
Copyright 2022-2023 Nosial - All Rights Reserved.
|
||||
|
||||
Copyright (C) 2022-2022. Nosial - All Rights Reserved.
|
||||
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:
|
||||
|
||||
Unauthorized copying of this file, via any medium is strictly prohibited
|
||||
Proprietary and confidential, written by Zi Xing Narrakas <netkas@n64.cc>
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
------------------------
|
||||
Symfony - Process
|
||||
|
||||
Copyright (c) 2004-2022 Fabien Potencier
|
||||
|
||||
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.
|
||||
|
||||
------------------------
|
||||
defuse - php-encryption
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Taylor Hornby <https://defuse.ca>
|
||||
Copyright (c) 2016 Paragon Initiative Enterprises <https://paragonie.com>.
|
||||
|
||||
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.
|
||||
|
||||
------------------------
|
||||
Symfony - uid
|
||||
|
||||
Copyright (c) 2020-2022 Fabien Potencier
|
||||
|
||||
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.
|
||||
|
||||
|
||||
------------------------
|
||||
Symfony - polyfill-mbstring
|
||||
|
||||
Copyright (c) 2015-2019 Fabien Potencier
|
||||
|
||||
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.
|
||||
|
||||
|
||||
------------------------
|
||||
Symfony - polyfill-ctype
|
||||
|
||||
Copyright (c) 2018-2019 Fabien Potencier
|
||||
|
||||
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.
|
||||
|
||||
|
||||
------------------------
|
||||
Symfony - polyfill-uuid
|
||||
|
||||
Copyright (c) 2018-2019 Fabien Potencier
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
||||
------------------------
|
||||
dealnews.com, Inc. - Inline ProgressBar CLI
|
||||
|
||||
Copyright (c) 2010, dealnews.com, Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of dealnews.com, Inc. nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
------------------------
|
||||
Symfony - Filesystem
|
||||
|
||||
Copyright (c) 2004-2022 Fabien Potencier
|
||||
|
||||
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.
|
||||
|
||||
|
||||
------------------------
|
||||
Symfony - Yaml
|
||||
|
||||
Copyright (c) 2004-2022 Fabien Potencier
|
||||
|
||||
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.
|
||||
|
||||
------------------------
|
||||
theseer - Autoload
|
||||
|
||||
Autoload Builder
|
||||
|
||||
Copyright (c) 2010-2016 Arne Blankerts <arne@blankerts.de> and Contributors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Arne Blankerts nor the names of contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
------------------------
|
||||
theseer - DirectoryScanner
|
||||
|
||||
DirectoryScanner
|
||||
|
||||
Copyright (c) 2009-2014 Arne Blankerts <arne@blankerts.de>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Arne Blankerts nor the names of contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
------------------------
|
||||
nikic - PhpParser
|
||||
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2011, Nikita Popov
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
------------------------
|
||||
jelix - version
|
||||
|
||||
Copyright (C) 2009-2016 Laurent Jouanneau
|
||||
|
||||
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.
|
||||
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.
|
31
Makefile
31
Makefile
|
@ -1,5 +1,5 @@
|
|||
PHPCC=/usr/bin/php
|
||||
PHPAB=/usr/bin/phpab
|
||||
PHPCC:=$(shell which php)
|
||||
PHPAB:=$(shell which phpab)
|
||||
BUILD_PATH=build
|
||||
SRC_PATH=src
|
||||
|
||||
|
@ -80,25 +80,28 @@ $(SRC_PATH)/ncc/autoload_spl.php:
|
|||
$(SRC_PATH)/ncc/Objects \
|
||||
$(SRC_PATH)/ncc/Runtime \
|
||||
$(SRC_PATH)/ncc/Utilities \
|
||||
$(SRC_PATH)/ncc/ncc.php
|
||||
$(SRC_PATH)/ncc/ncc.php \
|
||||
$(SRC_PATH)/ncc/Runtime.php
|
||||
|
||||
redist: autoload
|
||||
rm -rf $(BUILD_PATH)/src
|
||||
mkdir -p $(BUILD_PATH)/src
|
||||
cp -rf $(SRC_PATH)/ncc/* $(BUILD_PATH)/src
|
||||
cp $(SRC_PATH)/installer/installer $(BUILD_PATH)/$(SRC_PATH)/INSTALL
|
||||
cp $(SRC_PATH)/installer/ncc.sh $(BUILD_PATH)/$(SRC_PATH)/ncc.sh
|
||||
cp $(SRC_PATH)/config/ncc.yaml $(BUILD_PATH)/$(SRC_PATH)/default_config.yaml;
|
||||
cp $(SRC_PATH)/config/ncc.yaml $(BUILD_PATH)/$(SRC_PATH)/CLI/template_config.yaml;
|
||||
cp $(SRC_PATH)/installer/extension $(BUILD_PATH)/$(SRC_PATH)/extension
|
||||
chmod +x $(BUILD_PATH)/$(SRC_PATH)/INSTALL
|
||||
cp LICENSE $(BUILD_PATH)/$(SRC_PATH)/LICENSE
|
||||
cp README.md $(BUILD_PATH)/$(SRC_PATH)/README.md
|
||||
cp $(SRC_PATH)/installer/hash_check.php $(BUILD_PATH)/$(SRC_PATH)/hash_check.php; $(PHPCC) $(BUILD_PATH)/$(SRC_PATH)/hash_check.php; rm $(BUILD_PATH)/$(SRC_PATH)/hash_check.php
|
||||
cp $(SRC_PATH)/installer/generate_build_files.php $(BUILD_PATH)/$(SRC_PATH)/generate_build_files.php; $(PHPCC) $(BUILD_PATH)/$(SRC_PATH)/generate_build_files.php; rm $(BUILD_PATH)/$(SRC_PATH)/generate_build_files.php
|
||||
cp $(SRC_PATH)/installer/installer $(BUILD_PATH)/src/INSTALL
|
||||
cp $(SRC_PATH)/installer/ncc.sh $(BUILD_PATH)/src/ncc.sh
|
||||
cp $(SRC_PATH)/config/ncc.yaml $(BUILD_PATH)/src/default_config.yaml;
|
||||
cp $(SRC_PATH)/config/ncc.yaml $(BUILD_PATH)/src/CLI/template_config.yaml;
|
||||
cp $(SRC_PATH)/installer/extension $(BUILD_PATH)/src/extension
|
||||
chmod +x $(BUILD_PATH)/src/INSTALL
|
||||
cp LICENSE $(BUILD_PATH)/src/LICENSE
|
||||
cp README.md $(BUILD_PATH)/src/README.md
|
||||
cp $(SRC_PATH)/installer/hash_check.php $(BUILD_PATH)/src/hash_check.php; $(PHPCC) $(BUILD_PATH)/src/hash_check.php; rm $(BUILD_PATH)/src/hash_check.php
|
||||
cp $(SRC_PATH)/installer/generate_build_files.php $(BUILD_PATH)/src/generate_build_files.php; $(PHPCC) $(BUILD_PATH)/src/generate_build_files.php; rm $(BUILD_PATH)/src/generate_build_files.php
|
||||
mkdir -p $(BUILD_PATH)/src/repositories
|
||||
cp -rf $(SRC_PATH)/default_repositories/*.json $(BUILD_PATH)/src/repositories
|
||||
|
||||
tar: redist
|
||||
cd $(BUILD_PATH)/src; tar -czvf ../ncc.tar.gz *
|
||||
cd $(BUILD_PATH)/src; tar -czvf ../build.tar.gz *
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_PATH)
|
||||
|
|
68
README.md
68
README.md
|
@ -4,38 +4,60 @@ Nosial Code Compiler is a program written in PHP designed to be a multi-purpose
|
|||
This program is a complete re-write of the now defunct [PHP Package Manager (PPM)](https://git.n64.cc/intellivoid/ppm)
|
||||
toolkit offering more features, security and proper code licensing and copyrighting for the components used for the project.
|
||||
|
||||
NCC Cannot compile, read or use PPM packages (.ppm) files or work with project sources designed to be built with PPM, however
|
||||
a PPM extension may be built in the future to allow for backwards compatibility.
|
||||
## Alpha Stage
|
||||
|
||||
NCC is currently in alpha stage, meaning that it's not fully functional and may not work on your system. If you find any bugs
|
||||
or issues please report them to the [GitHub Issue Tracker](https://git.n64.cc/intellivoid/ncc/issues).
|
||||
|
||||
At the moment NCC is currently being used while developing other software, this serves as a test run to
|
||||
improve on changes for the next version.
|
||||
|
||||
## Version History
|
||||
|
||||
- 1.0.0 Alpha - Initial release ([changelog](changelog/v1.0.0_alpha.md))
|
||||
|
||||
## Repository Mirrors
|
||||
|
||||
The official repository for NCC is hosted on [GitLab](https://git.n64.cc/intellivoid/ncc), however, you can also find
|
||||
mirrors of the repository mirrored on different platforms, including
|
||||
community powered mirrors. (more to come)
|
||||
|
||||
- [git.it-kuny.ch](https://git.it-kuny.ch)
|
||||
- [git.martinvlba.eu](https://git.martinvlba.eu/Nosial/ncc)
|
||||
|
||||
|
||||
## Notes
|
||||
# Contributing
|
||||
|
||||
> While NCC has windows compatibility in mind, not all compiler extensions or features will work correctly. NCC is
|
||||
> designed to be used in production in a Unix environment and Windows should only be used for development purposes.
|
||||
We welcome contributions to NCC! If you have an idea for how to improve the project, please don't hesitate to reach out.
|
||||
There are many ways to contribute, and we appreciate all forms of support.
|
||||
|
||||
> Compiler extensions requires their own set of dependencies to be met, for example Java compilers will require JDK
|
||||
For more information on how to contribute, please read the [CONTRIBUTING.md](CONTRIBUTING.md) file.
|
||||
|
||||
> NCC is designed to run only on a PHP 8.0+ environment, compiler extensions can have support for different PHP versions.
|
||||
|
||||
> Third-party dependencies and included libraries has a dedicated namespace for `ncc` to avoid user land conflicts if
|
||||
> the user wishes to install and use one of the same dependencies that NCC uses.
|
||||
# Code of Conduct
|
||||
|
||||
## Authors
|
||||
- Zi Xing Narrakas (netkas) <[netkas@n64.cc](mailto:netkas@64.cc)>
|
||||
We are committed to maintaining a welcoming and inclusive environment for all contributors. Please read and follow our
|
||||
[Code of Conduct](CODE_OF_CONDUCT.md).
|
||||
|
||||
## Special Thanks
|
||||
- Marc Gutt (mgutt) <[marc@gutt.it](mailto:marc@gutt.it)>
|
||||
- Debusschère Alexandre ([debuss](https://github.com/debuss))
|
||||
# Authors
|
||||
|
||||
- Zi Xing Narrakas (netkas) <[netkas@n64.cc](mailto:netkas@64.cc)>
|
||||
|
||||
|
||||
# Special Thanks
|
||||
|
||||
- Marc Gutt (mgutt) <[marc@gutt.it](mailto:marc@gutt.it)>
|
||||
- Debusschère Alexandre ([debuss](https://github.com/debuss))
|
||||
|
||||
|
||||
# Copyright
|
||||
|
||||
- Copyright (c) 2022-2023, Nosial - All Rights Reserved
|
||||
|
||||
## Copyright
|
||||
- Copyright (c) 2022-2022, Nosial - All Rights Reserved
|
||||
- Copyright (c) 2004-2022, Fabien Potencier
|
||||
- Copyright (c) 2010, dealnews.com, Inc. All rights reserved.
|
||||
- Copyright (c) 2013 Austin Hyde
|
||||
- Copyright (C) 2009-2016 Laurent Jouanneau
|
||||
- Copyright (c) 2011, Nikita Popov
|
||||
- Copyright (c) 2010-2016 Arne Blankerts <arne@blankerts.de> and Contributors
|
||||
|
||||
# Licenses
|
||||
|
||||
Multiple licenses can be found at [LICENSE](LICENSE)
|
||||
NCC is licensed under the MIT License, see [LICENSE](LICENSE) for more information.
|
||||
|
||||
Multiple licenses for the open source components used in this
|
||||
project can be found at [LICENSE](LICENSES)
|
BIN
assets/ncc_cli.png
Normal file
BIN
assets/ncc_cli.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 90 KiB |
18
changelog/v1.0.0_alpha.md
Normal file
18
changelog/v1.0.0_alpha.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
# v1.0.0 Alpha
|
||||
|
||||
First release of NCC (Nosial Code Compiler) in alpha stage.
|
||||
|
||||
## Alpha Stage
|
||||
|
||||
NCC is in its alpha stage, meaning that it's not fully
|
||||
functional and may not work on your system. If you find
|
||||
any bugs or issues please report them to the
|
||||
[Issue Tracker](https://git.n64.cc/intellivoid/ncc/issues).
|
||||
|
||||
At the moment NCC is currently being used while developing
|
||||
other software, this serves as a test run to improve on
|
||||
changes for the next version.
|
||||
|
||||
## Changelog
|
||||
|
||||
- Initial release
|
|
@ -1,94 +0,0 @@
|
|||
# Building NCC from source
|
||||
|
||||
Building NCC from source is easy with very few requirements
|
||||
to start building. At the moment ncc can only be debugged
|
||||
or tested by building a redistributable source and
|
||||
installing it.
|
||||
|
||||
## Requirements to build
|
||||
|
||||
- php8.0+
|
||||
- php-mbstring
|
||||
- php-ctype
|
||||
- php-tokenizer *(or php-common)*
|
||||
- make
|
||||
- phpab
|
||||
- tar *(optional)*
|
||||
|
||||
## Installing phpab
|
||||
|
||||
phpab is also known as [PHP Autoload Builder](https://github.com/theseer/Autoload),
|
||||
phpab is an open source tool used for creating autoload
|
||||
files, ncc needs this tool in order to generate it's
|
||||
autoload files whenever there's any changes to its source
|
||||
code.
|
||||
|
||||
This tool is only required for building and or creating a
|
||||
redistributable package of ncc. This component is not
|
||||
required to be installed to use ncc.
|
||||
|
||||
for some components that require static loading, ncc will
|
||||
automatically load it using it's own
|
||||
[autoloader](../src/autoload/autoload.php)
|
||||
|
||||
The recommended way to install phpab is by using [phive](https://phar.io/),
|
||||
if you don't have phive installed you can install it by
|
||||
running these commands in your terminal (from the official documentation)
|
||||
|
||||
```shell
|
||||
wget -O phive.phar https://phar.io/releases/phive.phar
|
||||
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
|
||||
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
|
||||
gpg --verify phive.phar.asc phive.phar
|
||||
chmod +x phive.phar
|
||||
sudo mv phive.phar /usr/local/bin/phive
|
||||
```
|
||||
|
||||
Once phive is installed, you can run the final command to
|
||||
install phpab
|
||||
```shell
|
||||
phive install phpab
|
||||
```
|
||||
|
||||
**Note:** Optionally, you may want to have `phab` available in your
|
||||
`$PATH`, this can be done with this command. *(Replace `x.xx.x` with your
|
||||
version number)*
|
||||
|
||||
```shell
|
||||
ln -s /home/user/.phive/phars/phpab-x.xx.x.phar /usr/bin/phpab
|
||||
```
|
||||
|
||||
## Building NCC
|
||||
|
||||
First, navigate to the main directory of NCC's source code
|
||||
where the [Makefile](../Makefile) is present. If you
|
||||
already attempted to or had built ncc before, it's
|
||||
recommended to use `make clean` before building.
|
||||
|
||||
|
||||
### Redist
|
||||
|
||||
Running `redist` from the Makefile will generate all the
|
||||
required autoloaders for ncc and move all the required
|
||||
files into one redistributable source folder under a
|
||||
directory called `build/src`
|
||||
|
||||
```shell
|
||||
make redist
|
||||
```
|
||||
|
||||
|
||||
### Tar
|
||||
|
||||
Running `tar` will run redist before packaging the
|
||||
redistributable source into a tar.gz file that can
|
||||
be distributed to other machines, this process is not
|
||||
a requirement.
|
||||
|
||||
```shell
|
||||
make tar
|
||||
```
|
||||
|
||||
Once you have a populated `build/src` folder, you can
|
||||
simply run execute the `installer` file to install your
|
||||
build of ncc onto the running machine.
|
|
@ -1,43 +0,0 @@
|
|||
# Naming a package
|
||||
|
||||
**Updated on Tuesday, July 26, 2022**
|
||||
|
||||
NCC Follows the same naming convention as Java's naming
|
||||
convention. The purpose of naming a package this way is
|
||||
to easily create a "Name" of the package, this string
|
||||
of information contains
|
||||
|
||||
- The developer/organization behind the package
|
||||
- The package name itself
|
||||
|
||||
|
||||
# Naming conventions
|
||||
|
||||
Package names are written in all lower-case due to the
|
||||
fact that some operating systems treats file names
|
||||
differently, for example on Linux `Aa.txt` and `aa.txt`
|
||||
are two entirely different file names because of the
|
||||
capitalization and on Windows it's treated as the same
|
||||
file name.
|
||||
|
||||
Organizations or small developers use their domain name
|
||||
in reverse to begin their package names, for example
|
||||
`net.nosial.example` is a package named `example`
|
||||
created by a programmer at `nosial.net`
|
||||
|
||||
Just like the Java naming convention, to avoid conflicts
|
||||
of the same package name developers can use something
|
||||
different, for example as pointed out in Java's package
|
||||
naming convention developers can instead use something
|
||||
like a region to name packages, for example
|
||||
`net.nosial.region.example`
|
||||
|
||||
|
||||
# References
|
||||
|
||||
For Java's package naming conventions see
|
||||
[Naming a Package](https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html)
|
||||
from the Oracle's Java documentation resource, as the
|
||||
same rules apply to NCC except for *some* illegal naming
|
||||
conventions such as packages not being able to begin
|
||||
with `int` or numbers
|
|
@ -1,151 +0,0 @@
|
|||
# Execution Policies
|
||||
|
||||
**Updated on Sunday, November 20, 2022**
|
||||
|
||||
An execution policy is a policy defined in the Project
|
||||
configuration file (`project.json`) that can be used
|
||||
to execute a script or program in any stage of the package
|
||||
|
||||
For instance, you can have a script that is executed before
|
||||
the build process starts, or in different installation stages
|
||||
when the user is installing your package you can have a unit
|
||||
run before or after the installation/uninstallation process
|
||||
starts.#
|
||||
|
||||
Use cases such as this allows you to properly implement
|
||||
and control your program's files & assets that are not
|
||||
handled by NCC's compiler extensions.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
<!-- TOC -->
|
||||
* [Execution Policies](#execution-policies)
|
||||
* [Table of Contents](#table-of-contents)
|
||||
* [JSON Example](#json-example)
|
||||
* [ExecutionPolicy Object](#executionpolicy-object)
|
||||
* [Object Properties](#object-properties)
|
||||
* [JSON Example](#json-example)
|
||||
* [ExecutionConfiguration Object](#executionconfiguration-object)
|
||||
* [Object Properties](#object-properties)
|
||||
* [JSON Example](#json-example)
|
||||
* [ExitHandler Object](#exithandler-object)
|
||||
* [Object Properties](#object-properties)
|
||||
* [JSON Example](#json-example)
|
||||
<!-- TOC -->
|
||||
|
||||
|
||||
## JSON Example
|
||||
|
||||
```json
|
||||
{
|
||||
"execution_policies": {
|
||||
"main": {
|
||||
"runner": "php",
|
||||
"message": "Running main %ASSEMBLY.PACKAGE%",
|
||||
"exec": {
|
||||
"target": "scripts/main.php",
|
||||
"working_directory": "%INSTALL_PATH.SRC%",
|
||||
"silent": false
|
||||
}
|
||||
},
|
||||
"hello_world": {
|
||||
"runner": "shell",
|
||||
"message": "Running HTOP",
|
||||
"options": {
|
||||
"htop": null
|
||||
},
|
||||
"exec": {
|
||||
"tty": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
------------------------------------------------------------
|
||||
|
||||
## ExecutionPolicy Object
|
||||
|
||||
Execution Policies for your project **must** have unique
|
||||
names, because they way you tell NCC to execute these
|
||||
policies is by referencing their name in the configuration.
|
||||
|
||||
Invalid names/undefined policies will raise errors when
|
||||
building the project
|
||||
|
||||
### Object Properties
|
||||
|
||||
| Property Name | Value Type | Example Value | Description |
|
||||
|-----------------|---------------------------------|----------------------|--------------------------------------------------------------------------------------------|
|
||||
| `runner` | string | bash | The name of a supported runner instance, see runners in this document |
|
||||
| `message` | string, null | Starting foo_bar ... | *Optional* the message to display before running the execution policy |
|
||||
| `exec` | ExecutionConfiguration | N/A | The configuration object that tells how the runner should execute the process |
|
||||
| `exit_handlers` | ExitHandlersConfiguration, null | N/A | *Optional* Exit Handler Configurations that tells NCC how to handle exits from the process |
|
||||
|
||||
### JSON Example
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "foo_bar",
|
||||
"runner": "bash",
|
||||
"message": "Running foo_bar ...",
|
||||
"exec": null,
|
||||
"exit_handlers": null
|
||||
}
|
||||
```
|
||||
|
||||
------------------------------------------------------------
|
||||
|
||||
## ExecutionConfiguration Object
|
||||
|
||||
### Object Properties
|
||||
|
||||
| Property Name | Value Type | Example Value | Description |
|
||||
|---------------------|-------------------|---------------------------------|------------------------------------------------------------------------|
|
||||
| `target` | `string` | scripts/foo_bar.bash | The target file to execute |
|
||||
| `working_directory` | `string`, `null` | %INSTALL_PATH.SRC% | *optional* The working directory to execute the process in |
|
||||
| `options` | `array`, `null` | {"run": null, "log": "verbose"} | Commandline Parameters to pass on to the target or process |
|
||||
| `silent` | `boolean`, `null` | False | Indicates if the target should run silently, by default this is false. |
|
||||
| `tty` | `boolean`, `null` | False | Indicates if the target should run in TTY mode |
|
||||
| `timeout` | `integer`, `null` | 60 | The amount of seconds to wait before the process is killed |
|
||||
|
||||
### JSON Example
|
||||
|
||||
```json
|
||||
{
|
||||
"target": "scripts/foo_bar.bash",
|
||||
"working_directory": "%INSTALL_PATH.SRC%",
|
||||
"options": {"run": null, "log": "verbose"},
|
||||
"silent": false,
|
||||
"tty": false,
|
||||
"timeout": 10
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
------------------------------------------------------------
|
||||
|
||||
## ExitHandler Object
|
||||
|
||||
An exit handler is executed once the specified exit code is
|
||||
returned or the process exits with an error or normally, if
|
||||
an exit handler is specified it will be executed.
|
||||
|
||||
### Object Properties
|
||||
|
||||
| Property Name | Value Type | Example Value | Description |
|
||||
|---------------|--------------------|---------------|------------------------------------------------------------------------------|
|
||||
| `message` | `string` | Hello World! | The message to display when the exit handler is triggered |
|
||||
| `end_process` | `boolean`, `null` | False | *optional* Kills the process after this exit handler is triggered |
|
||||
| `run` | `string`, `null` | `null` | *optional* A execution policy to execute once this exit handler is triggered |
|
||||
| `exit_code` | `int`, `null` | 1 | The exit code that triggers this exit handler |
|
||||
### JSON Example
|
||||
|
||||
```json
|
||||
{
|
||||
"message": "Hello World",
|
||||
"end_process": false,
|
||||
"run": null,
|
||||
"exit_code": 1
|
||||
}
|
||||
```
|
|
@ -19,12 +19,6 @@ ncc:
|
|||
php:
|
||||
# The main executable path for PHP that NCC should use
|
||||
executable_path: "/usr/bin/php"
|
||||
runtime:
|
||||
# Whether to initialize NCC when running `require('ncc');`
|
||||
initialize_on_require: true
|
||||
|
||||
# if NCC should handle fatal exceptions during execution
|
||||
handle_exceptions: true
|
||||
|
||||
git:
|
||||
# if git is enabled or not
|
||||
|
@ -55,10 +49,10 @@ composer:
|
|||
quiet: false
|
||||
|
||||
# Disable ANSI output
|
||||
no_ansi: false
|
||||
no_ansi: true
|
||||
|
||||
# Do not ask any interactive question
|
||||
no_interaction: false
|
||||
no_interaction: true
|
||||
|
||||
# Display timing and memory usage information
|
||||
profile: false
|
||||
|
|
6
src/default_repositories/custom_repositories.json
Normal file
6
src/default_repositories/custom_repositories.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
[
|
||||
"gitgud.json",
|
||||
"github.json",
|
||||
"gitlab.json",
|
||||
"n64.json"
|
||||
]
|
6
src/default_repositories/gitgud.json
Normal file
6
src/default_repositories/gitgud.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "gitgud",
|
||||
"type": "gitlab",
|
||||
"host": "gitgud.io",
|
||||
"ssl": true
|
||||
}
|
6
src/default_repositories/github.json
Normal file
6
src/default_repositories/github.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "github",
|
||||
"type": "github",
|
||||
"host": "api.github.com",
|
||||
"ssl": true
|
||||
}
|
6
src/default_repositories/gitlab.json
Normal file
6
src/default_repositories/gitlab.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "gitlab",
|
||||
"type": "gitlab",
|
||||
"host": "gitlab.com",
|
||||
"ssl": true
|
||||
}
|
6
src/default_repositories/n64.json
Normal file
6
src/default_repositories/n64.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "n64",
|
||||
"type": "gitlab",
|
||||
"host": "git.n64.cc",
|
||||
"ssl": true
|
||||
}
|
|
@ -1,8 +1,19 @@
|
|||
<?php
|
||||
|
||||
if(defined('NCC_INIT') == false)
|
||||
use ncc\Abstracts\Versions;
|
||||
use ncc\Exceptions\ConstantReadonlyException;
|
||||
use ncc\Exceptions\ImportException;
|
||||
use ncc\Exceptions\InvalidConstantNameException;
|
||||
use ncc\Exceptions\InvalidPackageNameException;
|
||||
use ncc\Exceptions\InvalidScopeException;
|
||||
use ncc\Exceptions\PackageLockException;
|
||||
use ncc\Exceptions\PackageNotFoundException;
|
||||
use ncc\ncc;
|
||||
use ncc\Runtime;
|
||||
|
||||
if(!defined('NCC_INIT'))
|
||||
{
|
||||
if(file_exists('%ncc_install' . DIRECTORY_SEPARATOR . 'autoload.php') == false)
|
||||
if(!file_exists('%ncc_install' . DIRECTORY_SEPARATOR . 'autoload.php'))
|
||||
{
|
||||
throw new RuntimeException('Cannot locate file \'%ncc_install' . DIRECTORY_SEPARATOR . 'autoload.php\'');
|
||||
}
|
||||
|
@ -10,4 +21,150 @@
|
|||
{
|
||||
require('%ncc_install' . DIRECTORY_SEPARATOR . 'autoload.php');
|
||||
}
|
||||
|
||||
|
||||
if(!function_exists('import'))
|
||||
{
|
||||
/**
|
||||
* Attempts to import a package into the current runtime
|
||||
*
|
||||
* @param string $package
|
||||
* @param string $version
|
||||
* @param array $options
|
||||
* @return void
|
||||
* @throws ImportException
|
||||
*/
|
||||
function import(string $package, string $version= Versions::Latest, array $options=[]): void
|
||||
{
|
||||
Runtime::import($package, $version, $options);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('get_imported'))
|
||||
{
|
||||
/**
|
||||
* Returns an array of all imported packages
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_imported(): array
|
||||
{
|
||||
return Runtime::getImportedPackages();
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('ncc_constants'))
|
||||
{
|
||||
/**
|
||||
* Returns an array of constants defined by NCC
|
||||
*
|
||||
* @return array
|
||||
* @throws \ncc\Exceptions\RuntimeException
|
||||
*/
|
||||
function ncc_constants(): array
|
||||
{
|
||||
return ncc::getConstants();
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('consts_get'))
|
||||
{
|
||||
/**
|
||||
* Returns the value of a constant defined in NCC's runtime environment
|
||||
*
|
||||
* @param string $package
|
||||
* @param string $name
|
||||
* @return string|null
|
||||
*/
|
||||
function consts_get(string $package, string $name): ?string
|
||||
{
|
||||
return Runtime\Constants::get($package, $name);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('consts_set'))
|
||||
{
|
||||
/**
|
||||
* Sets the value of a constant defined in NCC's runtime environment
|
||||
*
|
||||
* @param string $package
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param bool $readonly
|
||||
* @return void
|
||||
* @throws ConstantReadonlyException
|
||||
* @throws InvalidConstantNameException
|
||||
*/
|
||||
function consts_set(string $package, string $name, string $value, bool $readonly=false): void
|
||||
{
|
||||
Runtime\Constants::register($package, $name, $value, $readonly);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('consts_delete'))
|
||||
{
|
||||
/**
|
||||
* Deletes a constant defined in NCC's runtime environment
|
||||
*
|
||||
* @param string $package
|
||||
* @param string $name
|
||||
* @return void
|
||||
* @throws ConstantReadonlyException
|
||||
*/
|
||||
function consts_delete(string $package, string $name): void
|
||||
{
|
||||
Runtime\Constants::delete($package, $name);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('get_data_path'))
|
||||
{
|
||||
/**
|
||||
* Returns the data path of the package
|
||||
*
|
||||
* @param string $package
|
||||
* @return string
|
||||
* @throws InvalidPackageNameException
|
||||
* @throws InvalidScopeException
|
||||
* @throws PackageLockException
|
||||
* @throws PackageNotFoundException
|
||||
*/
|
||||
function get_data_path(string $package): string
|
||||
{
|
||||
return Runtime::getDataPath($package);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('get_constant'))
|
||||
{
|
||||
/**
|
||||
* Returns the value of a constant defined in NCC's runtime environment
|
||||
*
|
||||
* @param string $package
|
||||
* @param string $name
|
||||
* @return string|null
|
||||
*/
|
||||
function get_constant(string $package, string $name): ?string
|
||||
{
|
||||
return Runtime::getConstant($package, $name);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('set_constant'))
|
||||
{
|
||||
/**
|
||||
* Sets the value of a constant defined in NCC's runtime environment
|
||||
*
|
||||
* @param string $package
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @return void
|
||||
* @throws ConstantReadonlyException
|
||||
* @throws InvalidConstantNameException
|
||||
*/
|
||||
function set_constant(string $package, string $name, string $value): void
|
||||
{
|
||||
Runtime::setConstant($package, $name, $value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,8 +14,10 @@
|
|||
|
||||
use ncc\Abstracts\ConsoleColors;
|
||||
use ncc\Exceptions\FileNotFoundException;
|
||||
use ncc\Managers\RemoteSourcesManager;
|
||||
use ncc\ncc;
|
||||
use ncc\Objects\CliHelpSection;
|
||||
use ncc\Objects\DefinedRemoteSource;
|
||||
use ncc\ThirdParty\Symfony\Filesystem\Exception\IOException;
|
||||
use ncc\ThirdParty\Symfony\Filesystem\Filesystem;
|
||||
use ncc\ThirdParty\Symfony\Process\Exception\ProcessFailedException;
|
||||
|
@ -712,7 +714,6 @@
|
|||
$config_obj['composer']['enable_internal_composer'] = false;
|
||||
if($config_obj['composer']['executable_path'] == null)
|
||||
{
|
||||
// TODO: Implement Configuration Tools
|
||||
Console::outWarning('Cannot locate the executable path for \'composer\', run \'ncc config --composer.executable_path="composer.phar"\' as root to update the path');
|
||||
}
|
||||
}
|
||||
|
@ -724,7 +725,7 @@
|
|||
{
|
||||
if ($NCC_FILESYSTEM->exists(PathFinder::getConfigurationFile()))
|
||||
{
|
||||
$config_backup = IO::fread(PathFinder::getConfigurationFile());
|
||||
$config_backup = Yaml::parseFile(PathFinder::getConfigurationFile());
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
|
@ -736,33 +737,73 @@
|
|||
// Create/Update configuration file
|
||||
$config_obj = Yaml::parseFile(__DIR__ . DIRECTORY_SEPARATOR . 'default_config.yaml');
|
||||
|
||||
// Update the old configuration
|
||||
if($config_backup !== null)
|
||||
if(!function_exists('array_replace_recursive'))
|
||||
{
|
||||
$old_config_obj = Yaml::parse($config_backup);
|
||||
foreach($old_config_obj as $section => $value)
|
||||
/**
|
||||
* @param $array
|
||||
* @param $array1
|
||||
* @return array|mixed
|
||||
* @author <msahagian@dotink.org>
|
||||
* @noinspection PhpMissingReturnTypeInspection
|
||||
*/
|
||||
function array_replace_recursive($array, $array1)
|
||||
{
|
||||
if(isset($config_obj[$section]))
|
||||
// handle the arguments, merge one by one
|
||||
$args = func_get_args();
|
||||
$array = $args[0];
|
||||
if (!is_array($array))
|
||||
{
|
||||
foreach($value as $section_item => $section_value)
|
||||
return $array;
|
||||
}
|
||||
for ($i = 1; $i < count($args); $i++)
|
||||
{
|
||||
if (is_array($args[$i]))
|
||||
{
|
||||
if(!isset($config_obj[$section][$section_item]))
|
||||
{
|
||||
$config_obj[$section][$section_item] = $section_value;
|
||||
}
|
||||
$array = recurse($array, $args[$i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$config_obj[$section] = $value;
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('recurse'))
|
||||
{
|
||||
/**
|
||||
* @param $array
|
||||
* @param $array1
|
||||
* @return mixed
|
||||
* @author <msahagian@dotink.org>
|
||||
* @noinspection PhpMissingReturnTypeInspection
|
||||
*/
|
||||
function recurse($array, $array1)
|
||||
{
|
||||
foreach ($array1 as $key => $value)
|
||||
{
|
||||
// create new key in $array, if it is empty or not an array
|
||||
/** @noinspection PhpConditionAlreadyCheckedInspection */
|
||||
if (!isset($array[$key]) || (isset($array[$key]) && !is_array($array[$key])))
|
||||
{
|
||||
$array[$key] = array();
|
||||
}
|
||||
|
||||
// overwrite the value in the base array
|
||||
if (is_array($value))
|
||||
{
|
||||
$value = recurse($array[$key], $value);
|
||||
}
|
||||
$array[$key] = $value;
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($config_backup !== null)
|
||||
$config_obj = array_replace_recursive($config_obj, $config_backup);
|
||||
|
||||
if($config_backup == null)
|
||||
{
|
||||
Console::out('Generating ncc.yaml');
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -779,6 +820,57 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if($NCC_FILESYSTEM->exists(__DIR__ . DIRECTORY_SEPARATOR . 'repositories'))
|
||||
{
|
||||
if(!$NCC_FILESYSTEM->exists(__DIR__ . DIRECTORY_SEPARATOR . 'repositories' . DIRECTORY_SEPARATOR . 'custom_repositories.json'))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
$custom_repositories = Functions::loadJsonFile(__DIR__ . DIRECTORY_SEPARATOR . 'repositories' . DIRECTORY_SEPARATOR . 'custom_repositories.json', Functions::FORCE_ARRAY);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$custom_repositories = null;
|
||||
Console::outWarning(sprintf('Failed to load custom repositories: %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
if($custom_repositories !== null)
|
||||
{
|
||||
$source_manager = new RemoteSourcesManager();
|
||||
foreach($custom_repositories as $repository)
|
||||
{
|
||||
$repo_path = __DIR__ . DIRECTORY_SEPARATOR . 'repositories' . DIRECTORY_SEPARATOR . $repository;
|
||||
if($NCC_FILESYSTEM->exists($repo_path))
|
||||
{
|
||||
try
|
||||
{
|
||||
$definedEntry = DefinedRemoteSource::fromArray(Functions::loadJsonFile($repo_path, Functions::FORCE_ARRAY));
|
||||
if(!$source_manager->getRemoteSource($definedEntry->Name))
|
||||
$source_manager->addRemoteSource($definedEntry);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outWarning(sprintf('Failed to load custom repository %s: %s', $repository, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console::outWarning(sprintf('Failed to load custom repository %s, file does not exist', $repository));
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$source_manager->save();
|
||||
}
|
||||
catch (\ncc\Exceptions\IOException $e)
|
||||
{
|
||||
Console::outWarning(sprintf('Failed to save sources: %s', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Console::out('NCC version: ' . NCC_VERSION_NUMBER . ' has been successfully installed');
|
||||
Console::out('For licensing information see \'' . $NCC_INSTALL_PATH . DIRECTORY_SEPARATOR . 'LICENSE\' or run \'ncc help --license\'');
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class AuthenticationSource
|
||||
{
|
||||
const None = 'NONE';
|
||||
|
||||
const ServerProvided = 'SERVER_PROVIDED';
|
||||
|
||||
const UserProvided = 'USER_PROVIDED';
|
||||
}
|
36
src/ncc/Abstracts/AuthenticationType.php
Normal file
36
src/ncc/Abstracts/AuthenticationType.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class AuthenticationType
|
||||
{
|
||||
/**
|
||||
* A combination of a username and password is used for authentication
|
||||
*/
|
||||
const UsernamePassword = 1;
|
||||
|
||||
/**
|
||||
* A single private access token is used for authentication
|
||||
*/
|
||||
const AccessToken = 2;
|
||||
}
|
37
src/ncc/Abstracts/BuiltinRemoteSourceType.php
Normal file
37
src/ncc/Abstracts/BuiltinRemoteSourceType.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
class BuiltinRemoteSourceType
|
||||
{
|
||||
/**
|
||||
* The remote source indicates the package is to be
|
||||
* fetched using the composer utility.
|
||||
*/
|
||||
const Composer = 'composer';
|
||||
|
||||
|
||||
const All = [
|
||||
self::Composer
|
||||
];
|
||||
}
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class CompilerExtensionDefaultVersions
|
||||
{
|
||||
|
@ -9,5 +29,5 @@
|
|||
// [1] = MaximumVersion
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
const PHP = ['8.0', '8.1'];
|
||||
const PHP = ['8.0', '8.2'];
|
||||
}
|
|
@ -1,8 +1,28 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class CompilerExtensionSupportedVersions
|
||||
{
|
||||
const PHP = ['8.0', '8.1'];
|
||||
const PHP = ['8.0', '8.1', '8.2'];
|
||||
}
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class CompilerExtensions
|
||||
{
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class CompilerOptions
|
||||
{
|
||||
|
||||
}
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class ComponentDataType
|
||||
{
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class ComponentFileExtensions
|
||||
{
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class ComposerPackageTypes
|
||||
{
|
||||
|
@ -12,7 +32,7 @@
|
|||
/**
|
||||
* This denotes a project rather than a library. For example
|
||||
* application shells like the Symfony standard edition, CMSs
|
||||
* like the SilverStripe instlaler or full-fledged applications
|
||||
* like the SilverStripe installer or full-fledged applications
|
||||
* distributed as packages. This can for example be used by IDEs
|
||||
* to provide listings of projects to initialize when creating
|
||||
* a new workspace.
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class ComposerStabilityTypes
|
||||
{
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class ConsoleColors
|
||||
{
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class ConstantReferences
|
||||
{
|
||||
|
@ -11,4 +31,6 @@
|
|||
const DateTime = 'date_time';
|
||||
|
||||
const Install = 'install';
|
||||
|
||||
const Runtime = 'runtime';
|
||||
}
|
53
src/ncc/Abstracts/DefinedRemoteSourceType.php
Normal file
53
src/ncc/Abstracts/DefinedRemoteSourceType.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class DefinedRemoteSourceType
|
||||
{
|
||||
/**
|
||||
* THe remote source is from gitlab or a custom gitlab instance
|
||||
*
|
||||
* Will use an API wrapper to interact with the gitlab instance
|
||||
* to fetch the package and check for updates without having to
|
||||
* pull the entire repository
|
||||
*
|
||||
* Will still use git to fetch the package from the gitlab instance
|
||||
*/
|
||||
const Gitlab = 'gitlab';
|
||||
|
||||
/**
|
||||
* The remote source is from GitHub
|
||||
*
|
||||
* Will use an API wrapper to interact with the GitHub instance
|
||||
* to fetch the package and check for updates without having to
|
||||
* pull the entire repository
|
||||
*
|
||||
* Will still use git to fetch the package from the GitHub instance
|
||||
*/
|
||||
const Github = 'github';
|
||||
|
||||
const All = [
|
||||
self::Gitlab,
|
||||
self::Github
|
||||
];
|
||||
}
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class DependencySourceType
|
||||
{
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class EncoderType
|
||||
{
|
||||
|
|
|
@ -1,6 +1,28 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
use ncc\Exceptions\SymlinkException;
|
||||
|
||||
/**
|
||||
* @author Zi Xing Narrakas
|
||||
|
@ -268,6 +290,91 @@
|
|||
*/
|
||||
const MissingDependencyException = -1751;
|
||||
|
||||
/**
|
||||
* @see HttpException
|
||||
*/
|
||||
const HttpException = -1752;
|
||||
|
||||
/**
|
||||
* @see UnsupportedRemoteSourceTypeException
|
||||
*/
|
||||
const UnsupportedRemoteSourceTypeException = -1753;
|
||||
|
||||
/**
|
||||
* @see GitCloneException
|
||||
*/
|
||||
const GitCloneException = -1754;
|
||||
|
||||
/**
|
||||
* @see GitCheckoutException
|
||||
*/
|
||||
const GitCheckoutException = -1755;
|
||||
|
||||
/**
|
||||
* @see GitlabServiceException
|
||||
*/
|
||||
const GitlabServiceException = -1756;
|
||||
|
||||
/**
|
||||
* @see ImportException
|
||||
*/
|
||||
const ImportException = -1757;
|
||||
|
||||
/**
|
||||
* @see GitTagsException
|
||||
*/
|
||||
const GitTagsException = -1758;
|
||||
|
||||
/**
|
||||
* @see GithubServiceException
|
||||
*/
|
||||
const GithubServiceException = -1759;
|
||||
|
||||
/**
|
||||
* @see AuthenticationException
|
||||
*/
|
||||
const AuthenticationException = -1760;
|
||||
|
||||
/**
|
||||
* @see NotSupportedException
|
||||
*/
|
||||
const NotSupportedException = -1761;
|
||||
|
||||
/**
|
||||
* @see UnsupportedProjectTypeException
|
||||
*/
|
||||
const UnsupportedProjectTypeException = -1762;
|
||||
|
||||
/**
|
||||
* @see UnsupportedArchiveException
|
||||
*/
|
||||
const UnsupportedArchiveException = -1763;
|
||||
|
||||
/**
|
||||
* @see ArchiveException
|
||||
*/
|
||||
const ArchiveException = -1764;
|
||||
|
||||
/**
|
||||
* @see PackageFetchException
|
||||
*/
|
||||
const PackageFetchException = -1765;
|
||||
|
||||
/**
|
||||
* @see InvalidBuildConfigurationException
|
||||
*/
|
||||
const InvalidBuildConfigurationException = -1766;
|
||||
|
||||
/**
|
||||
* @see InvalidBuildConfigurationNameException
|
||||
*/
|
||||
const InvalidDependencyConfiguration = -1767;
|
||||
|
||||
/**
|
||||
* @see SymlinkException
|
||||
*/
|
||||
const SymlinkException = -1768;
|
||||
|
||||
/**
|
||||
* All the exception codes from NCC
|
||||
*/
|
||||
|
@ -322,6 +429,21 @@
|
|||
self::ComposerNotAvailableException,
|
||||
self::ComposerException,
|
||||
self::UserAbortedOperationException,
|
||||
self::MissingDependencyException
|
||||
self::MissingDependencyException,
|
||||
self::HttpException,
|
||||
self::UnsupportedRemoteSourceTypeException,
|
||||
self::GitCloneException,
|
||||
self::GitCheckoutException,
|
||||
self::GitlabServiceException,
|
||||
self::GitTagsException,
|
||||
self::AuthenticationException,
|
||||
self::NotSupportedException,
|
||||
self::UnsupportedProjectTypeException,
|
||||
self::UnsupportedArchiveException,
|
||||
self::ArchiveException,
|
||||
self::PackageFetchException,
|
||||
self::InvalidBuildConfigurationException,
|
||||
self::InvalidDependencyConfiguration,
|
||||
self::SymlinkException,
|
||||
];
|
||||
}
|
31
src/ncc/Abstracts/HttpRequestType.php
Normal file
31
src/ncc/Abstracts/HttpRequestType.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class HttpRequestType
|
||||
{
|
||||
const GET = 'GET';
|
||||
const POST = 'POST';
|
||||
const PUT = 'PUT';
|
||||
const DELETE = 'DELETE';
|
||||
}
|
124
src/ncc/Abstracts/HttpStatusCodes.php
Normal file
124
src/ncc/Abstracts/HttpStatusCodes.php
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class HttpStatusCodes
|
||||
{
|
||||
const OK = 200;
|
||||
const CREATED = 201;
|
||||
const ACCEPTED = 202;
|
||||
const NO_CONTENT = 204;
|
||||
const MOVED_PERMANENTLY = 301;
|
||||
const FOUND = 302;
|
||||
const SEE_OTHER = 303;
|
||||
const NOT_MODIFIED = 304;
|
||||
const TEMPORARY_REDIRECT = 307;
|
||||
const PERMANENT_REDIRECT = 308;
|
||||
const BAD_REQUEST = 400;
|
||||
const UNAUTHORIZED = 401;
|
||||
const FORBIDDEN = 403;
|
||||
const NOT_FOUND = 404;
|
||||
const METHOD_NOT_ALLOWED = 405;
|
||||
const NOT_ACCEPTABLE = 406;
|
||||
const REQUEST_TIMEOUT = 408;
|
||||
const CONFLICT = 409;
|
||||
const GONE = 410;
|
||||
const LENGTH_REQUIRED = 411;
|
||||
const PRECONDITION_FAILED = 412;
|
||||
const PAYLOAD_TOO_LARGE = 413;
|
||||
const URI_TOO_LONG = 414;
|
||||
const UNSUPPORTED_MEDIA_TYPE = 415;
|
||||
const RANGE_NOT_SATISFIABLE = 416;
|
||||
const EXPECTATION_FAILED = 417;
|
||||
const IM_A_TEAPOT = 418;
|
||||
const MISDIRECTED_REQUEST = 421;
|
||||
const UNPROCESSABLE_ENTITY = 422;
|
||||
const LOCKED = 423;
|
||||
const FAILED_DEPENDENCY = 424;
|
||||
const UPGRADE_REQUIRED = 426;
|
||||
const PRECONDITION_REQUIRED = 428;
|
||||
const TOO_MANY_REQUESTS = 429;
|
||||
const REQUEST_HEADER_FIELDS_TOO_LARGE = 431;
|
||||
const UNAVAILABLE_FOR_LEGAL_REASONS = 451;
|
||||
const INTERNAL_SERVER_ERROR = 500;
|
||||
const NOT_IMPLEMENTED = 501;
|
||||
const BAD_GATEWAY = 502;
|
||||
const SERVICE_UNAVAILABLE = 503;
|
||||
const GATEWAY_TIMEOUT = 504;
|
||||
const HTTP_VERSION_NOT_SUPPORTED = 505;
|
||||
const VARIANT_ALSO_NEGOTIATES = 506;
|
||||
const INSUFFICIENT_STORAGE = 507;
|
||||
const LOOP_DETECTED = 508;
|
||||
const NOT_EXTENDED = 510;
|
||||
const NETWORK_AUTHENTICATION_REQUIRED = 511;
|
||||
|
||||
const All = [
|
||||
self::OK,
|
||||
self::CREATED,
|
||||
self::ACCEPTED,
|
||||
self::NO_CONTENT,
|
||||
self::MOVED_PERMANENTLY,
|
||||
self::FOUND,
|
||||
self::SEE_OTHER,
|
||||
self::NOT_MODIFIED,
|
||||
self::TEMPORARY_REDIRECT,
|
||||
self::PERMANENT_REDIRECT,
|
||||
self::BAD_REQUEST,
|
||||
self::UNAUTHORIZED,
|
||||
self::FORBIDDEN,
|
||||
self::NOT_FOUND,
|
||||
self::METHOD_NOT_ALLOWED,
|
||||
self::NOT_ACCEPTABLE,
|
||||
self::REQUEST_TIMEOUT,
|
||||
self::CONFLICT,
|
||||
self::GONE,
|
||||
self::LENGTH_REQUIRED,
|
||||
self::PRECONDITION_FAILED,
|
||||
self::PAYLOAD_TOO_LARGE,
|
||||
self::URI_TOO_LONG,
|
||||
self::UNSUPPORTED_MEDIA_TYPE,
|
||||
self::RANGE_NOT_SATISFIABLE,
|
||||
self::EXPECTATION_FAILED,
|
||||
self::IM_A_TEAPOT,
|
||||
self::MISDIRECTED_REQUEST,
|
||||
self::UNPROCESSABLE_ENTITY,
|
||||
self::LOCKED,
|
||||
self::FAILED_DEPENDENCY,
|
||||
self::UPGRADE_REQUIRED,
|
||||
self::PRECONDITION_REQUIRED,
|
||||
self::TOO_MANY_REQUESTS,
|
||||
self::REQUEST_HEADER_FIELDS_TOO_LARGE,
|
||||
self::UNAVAILABLE_FOR_LEGAL_REASONS,
|
||||
self::INTERNAL_SERVER_ERROR,
|
||||
self::NOT_IMPLEMENTED,
|
||||
self::BAD_GATEWAY,
|
||||
self::SERVICE_UNAVAILABLE,
|
||||
self::GATEWAY_TIMEOUT,
|
||||
self::HTTP_VERSION_NOT_SUPPORTED,
|
||||
self::VARIANT_ALSO_NEGOTIATES,
|
||||
self::INSUFFICIENT_STORAGE,
|
||||
self::LOOP_DETECTED,
|
||||
self::NOT_EXTENDED,
|
||||
self::NETWORK_AUTHENTICATION_REQUIRED
|
||||
];
|
||||
}
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class LogLevel
|
||||
{
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class NccBuildFlags
|
||||
{
|
||||
|
@ -8,5 +28,5 @@
|
|||
* Indicates if the build is currently unstable and some features may not work correctly
|
||||
* and can cause errors
|
||||
*/
|
||||
const Unstable = 'UNSTABLE';
|
||||
const Unstable = 'unstable';
|
||||
}
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts\Options;
|
||||
namespace ncc\Abstracts\Options;
|
||||
|
||||
abstract class BuildConfigurationValues
|
||||
{
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts\Options;
|
||||
namespace ncc\Abstracts\Options;
|
||||
|
||||
abstract class InitializeProjectOptions
|
||||
{
|
||||
|
|
40
src/ncc/Abstracts/Options/InstallPackageOptions.php
Normal file
40
src/ncc/Abstracts/Options/InstallPackageOptions.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts\Options;
|
||||
|
||||
abstract class InstallPackageOptions
|
||||
{
|
||||
/**
|
||||
* Skips the installation of dependencies of the package
|
||||
*
|
||||
* @warning This will cause the package to fail to import of
|
||||
* the dependencies are not met
|
||||
*/
|
||||
const SkipDependencies = 'skip_dependencies';
|
||||
|
||||
/**
|
||||
* Reinstall all packages if they are already installed
|
||||
* Including dependencies if they are being processed.
|
||||
*/
|
||||
const Reinstall = 'reinstall';
|
||||
}
|
38
src/ncc/Abstracts/Options/RuntimeImportOptions.php
Normal file
38
src/ncc/Abstracts/Options/RuntimeImportOptions.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts\Options;
|
||||
|
||||
abstract class RuntimeImportOptions
|
||||
{
|
||||
/**
|
||||
* Indicates if the import should require PHP's autoload.php file
|
||||
* for the package (Only applies to PHP packages)
|
||||
*/
|
||||
const ImportAutoloader = 'import_autoloader';
|
||||
|
||||
/**
|
||||
* Indicates if the import should require all static files
|
||||
* for the package (Only applies to PHP packages)
|
||||
*/
|
||||
const ImportStaticFiles = 'import_static_files';
|
||||
}
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class PackageStandardVersions
|
||||
{
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class PackageStructureVersions
|
||||
{
|
||||
|
|
32
src/ncc/Abstracts/ProjectType.php
Normal file
32
src/ncc/Abstracts/ProjectType.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class ProjectType
|
||||
{
|
||||
const Composer = 'composer';
|
||||
|
||||
const Ncc = 'ncc';
|
||||
|
||||
const Unknown = 'unknown';
|
||||
}
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
/**
|
||||
* @author Zi Xing Narrakas
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class RemoteAuthenticationType
|
||||
{
|
||||
/**
|
||||
* A combination of a username and password is used for authentication
|
||||
*/
|
||||
const UsernamePassword = 'USERNAME_PASSWORD';
|
||||
|
||||
/**
|
||||
* A single private access token is used for authentication
|
||||
*/
|
||||
const PrivateAccessToken = 'PRIVATE_ACCESS_TOKEN';
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class RemoteSource
|
||||
{
|
||||
/**
|
||||
* The remote source is from composer
|
||||
*/
|
||||
const Composer = 'composer';
|
||||
|
||||
/**
|
||||
* The remote source is from a git repository
|
||||
*/
|
||||
const Git = 'git';
|
||||
}
|
50
src/ncc/Abstracts/RemoteSourceType.php
Normal file
50
src/ncc/Abstracts/RemoteSourceType.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class RemoteSourceType
|
||||
{
|
||||
/**
|
||||
* A builtin source type is not defined by the user but handled by
|
||||
* an extension built into NCC
|
||||
*/
|
||||
const Builtin = 'builtin';
|
||||
|
||||
/**
|
||||
* A defined source type is defined by the user in the remote sources file
|
||||
* and handled by an extension designed by passing on the information of
|
||||
* the source to the extension
|
||||
*/
|
||||
const Defined = 'defined';
|
||||
|
||||
/**
|
||||
* Unsupported or invalid source type
|
||||
*/
|
||||
const Unknown = 'unknown';
|
||||
|
||||
const All = [
|
||||
self::Builtin,
|
||||
self::Defined,
|
||||
self::Unknown
|
||||
];
|
||||
}
|
|
@ -1,8 +1,51 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class Runners
|
||||
{
|
||||
const php = 'php';
|
||||
|
||||
const bash = 'bash';
|
||||
|
||||
const python = 'python';
|
||||
|
||||
const python3 = 'python3';
|
||||
|
||||
const python2 = 'python2';
|
||||
|
||||
const perl = 'perl';
|
||||
|
||||
const lua = 'lua';
|
||||
|
||||
|
||||
const All = [
|
||||
self::php,
|
||||
self::bash,
|
||||
self::python,
|
||||
self::python3,
|
||||
self::python2,
|
||||
self::perl,
|
||||
self::lua
|
||||
];
|
||||
}
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class Scopes
|
||||
{
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts\SpecialConstants;
|
||||
namespace ncc\Abstracts\SpecialConstants;
|
||||
|
||||
abstract class AssemblyConstants
|
||||
{
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts\SpecialConstants;
|
||||
namespace ncc\Abstracts\SpecialConstants;
|
||||
|
||||
abstract class BuildConstants
|
||||
{
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts\SpecialConstants;
|
||||
namespace ncc\Abstracts\SpecialConstants;
|
||||
|
||||
abstract class DateTimeConstants
|
||||
{
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts\SpecialConstants;
|
||||
namespace ncc\Abstracts\SpecialConstants;
|
||||
|
||||
abstract class InstallConstants
|
||||
{
|
||||
|
|
|
@ -1,8 +1,33 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts\SpecialConstants;
|
||||
namespace ncc\Abstracts\SpecialConstants;
|
||||
|
||||
abstract class RuntimeConstants
|
||||
{
|
||||
const CWD = '%CWD%';
|
||||
|
||||
const PID = '%PID%';
|
||||
const UID = '%UID%';
|
||||
const GID = '%GID%';
|
||||
const User = '%USER%';
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class StringPaddingMethod
|
||||
{
|
||||
const LEFT = 'LEFT';
|
||||
|
||||
const RIGHT = 'RIGHT';
|
||||
|
||||
const BOTH = 'BOTH';
|
||||
}
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Abstracts;
|
||||
namespace ncc\Abstracts;
|
||||
|
||||
abstract class Versions
|
||||
{
|
||||
|
@ -18,4 +38,9 @@
|
|||
* The current version of the package lock structure file format
|
||||
*/
|
||||
const PackageLockVersion = '1.0.0';
|
||||
|
||||
/**
|
||||
* Generic version of the package structure file format (latest)
|
||||
*/
|
||||
const Latest = 'latest';
|
||||
}
|
|
@ -1,14 +1,35 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\CLI;
|
||||
namespace ncc\CLI\Commands;
|
||||
|
||||
use Exception;
|
||||
use ncc\Abstracts\Options\BuildConfigurationValues;
|
||||
use ncc\Managers\ProjectManager;
|
||||
use ncc\Objects\CliHelpSection;
|
||||
use ncc\Utilities\Console;
|
||||
use ncc\Utilities\Functions;
|
||||
|
||||
class BuildMenu
|
||||
class BuildCommand
|
||||
{
|
||||
/**
|
||||
* Displays the main help menu
|
||||
|
@ -103,7 +124,7 @@
|
|||
new CliHelpSection(['build', '--config'], 'Builds the current project with a specified build configuration')
|
||||
];
|
||||
|
||||
$options_padding = \ncc\Utilities\Functions::detectParametersPadding($options) + 4;
|
||||
$options_padding = Functions::detectParametersPadding($options) + 4;
|
||||
|
||||
Console::out('Usage: ncc build [options]');
|
||||
Console::out('Options:' . PHP_EOL);
|
144
src/ncc/CLI/Commands/ExecCommand.php
Normal file
144
src/ncc/CLI/Commands/ExecCommand.php
Normal file
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\CLI\Commands;
|
||||
|
||||
use Exception;
|
||||
use ncc\Managers\ExecutionPointerManager;
|
||||
use ncc\Managers\PackageLockManager;
|
||||
use ncc\Objects\CliHelpSection;
|
||||
use ncc\Utilities\Console;
|
||||
use ncc\Utilities\Functions;
|
||||
|
||||
class ExecCommand
|
||||
{
|
||||
/**
|
||||
* Displays the main help menu
|
||||
*
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
public static function start($args): void
|
||||
{
|
||||
$package = $args['package'] ?? null;
|
||||
$version = $args['exec-version'] ?? 'latest';
|
||||
$unit_name = $args['exec-unit'] ?? 'main';
|
||||
$set_args = $args['exec-args'] ?? null;
|
||||
|
||||
if($package == null)
|
||||
{
|
||||
self::displayOptions();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$package_lock_manager = new PackageLockManager();
|
||||
$execution_pointer_manager = new ExecutionPointerManager();
|
||||
|
||||
try
|
||||
{
|
||||
$package_entry = $package_lock_manager->getPackageLock()->getPackage($package);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException('Package ' . $package . ' is not installed', $e, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$version_entry = $package_entry->getVersion($version);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException('Version ' . $version . ' is not installed', $e, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$units = $execution_pointer_manager->getUnits($package_entry->Name, $version_entry->Version);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException(sprintf('Cannot load execution units for package \'%s\'', $package), $e, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!in_array($unit_name, $units))
|
||||
{
|
||||
Console::outError(sprintf('Unit \'%s\' is not configured for package \'%s\'', $unit_name, $package), true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
$options = [];
|
||||
|
||||
if($set_args != null)
|
||||
{
|
||||
global $argv;
|
||||
$args_index = array_search('--exec-args', $argv);
|
||||
$options = array_slice($argv, $args_index + 1);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
exit($execution_pointer_manager->executeUnit($package_entry->Name, $version_entry->Version, $unit_name, $options));
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException(sprintf('Cannot execute execution point \'%s\' in package \'%s\'', $unit_name, $package), $e, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the main options section
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function displayOptions(): void
|
||||
{
|
||||
$options = [
|
||||
new CliHelpSection(['help'], 'Displays this help menu about the value command'),
|
||||
new CliHelpSection(['exec', '--package'], '(Required) The package to execute'),
|
||||
new CliHelpSection(['--exec-version'], '(default: latest) The version of the package to execute'),
|
||||
new CliHelpSection(['--exec-unit'], '(default: main) The unit point of the package to execute'),
|
||||
new CliHelpSection(['--exec-args'], '(optional) Anything past this point will be passed to the execution unit'),
|
||||
];
|
||||
|
||||
$options_padding = Functions::detectParametersPadding($options) + 4;
|
||||
|
||||
Console::out('Usage: ncc exec --package <package> [options] [arguments]');
|
||||
Console::out('Options:' . PHP_EOL);
|
||||
foreach($options as $option)
|
||||
{
|
||||
Console::out(' ' . $option->toString($options_padding));
|
||||
}
|
||||
|
||||
Console::out(PHP_EOL . 'Arguments:' . PHP_EOL);
|
||||
Console::out(' <arguments> The arguments to pass to the program');
|
||||
Console::out(PHP_EOL . 'Example Usage:' . PHP_EOL);
|
||||
Console::out(' ncc exec --package com.example.program');
|
||||
Console::out(' ncc exec --package com.example.program --exec-version 1.0.0');
|
||||
Console::out(' ncc exec --package com.example.program --exec-version 1.0.0 --exec-unit setup');
|
||||
Console::out(' ncc exec --package com.example.program --exec-args --foo --bar --extra=test');
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ncc\CLI;
|
||||
|
||||
use ncc\Abstracts\Scopes;
|
||||
use ncc\Exceptions\AccessDeniedException;
|
||||
use ncc\Objects\CliHelpSection;
|
||||
use ncc\Utilities\Resolver;
|
||||
|
||||
class CredentialMenu
|
||||
{
|
||||
/**
|
||||
* Displays the main help menu
|
||||
*
|
||||
* @param $args
|
||||
* @return void
|
||||
* @throws AccessDeniedException
|
||||
*/
|
||||
public static function start($args): void
|
||||
{
|
||||
if(isset($args['add']))
|
||||
{
|
||||
self::addCredential($args);
|
||||
}
|
||||
|
||||
self::displayOptions();
|
||||
exit(0);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $args
|
||||
* @return void
|
||||
* @throws AccessDeniedException
|
||||
*/
|
||||
public static function addCredential($args): void
|
||||
{
|
||||
$ResolvedScope = Resolver::resolveScope();
|
||||
|
||||
if($ResolvedScope !== Scopes::System)
|
||||
{
|
||||
throw new AccessDeniedException('Root permissions are required to manage the vault');
|
||||
}
|
||||
|
||||
print('end' . PHP_EOL);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the main options section
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function displayOptions(): void
|
||||
{
|
||||
$options = [
|
||||
new CliHelpSection(['help'], 'Displays this help menu about the value command'),
|
||||
new CliHelpSection(['add'], 'Adds a new credential to the vault'),
|
||||
new CliHelpSection(['remove'], 'Adds a new credential to the vault'),
|
||||
];
|
||||
|
||||
$options_padding = \ncc\Utilities\Functions::detectParametersPadding($options) + 4;
|
||||
|
||||
print('Usage: ncc vault {command} [options]' . PHP_EOL);
|
||||
print('Options:' . PHP_EOL);
|
||||
foreach($options as $option)
|
||||
{
|
||||
print(' ' . $option->toString($options_padding) . PHP_EOL);
|
||||
}
|
||||
print(PHP_EOL);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,33 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\CLI;
|
||||
namespace ncc\CLI;
|
||||
|
||||
use ncc\Exceptions\AccessDeniedException;
|
||||
use ncc\Exceptions\FileNotFoundException;
|
||||
use ncc\Exceptions\IOException;
|
||||
use ncc\Objects\CliHelpSection;
|
||||
use ncc\Utilities\Console;
|
||||
use ncc\Utilities\Functions;
|
||||
|
||||
class HelpMenu
|
||||
{
|
||||
|
@ -12,8 +36,11 @@
|
|||
*
|
||||
* @param $args
|
||||
* @return void
|
||||
* @throws AccessDeniedException
|
||||
* @throws FileNotFoundException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static function start($args)
|
||||
public static function start($args): void
|
||||
{
|
||||
$basic_ascii = false;
|
||||
|
||||
|
@ -23,7 +50,7 @@
|
|||
}
|
||||
|
||||
// TODO: Make copyright not hard-coded.
|
||||
print(\ncc\Utilities\Functions::getBanner(NCC_VERSION_BRANCH . ' ' . NCC_VERSION_NUMBER, 'Copyright (c) 2022-2022 Nosial', $basic_ascii) . PHP_EOL);
|
||||
print(Functions::getBanner(NCC_VERSION_BRANCH . ' ' . NCC_VERSION_NUMBER, 'Copyright (c) 2022-2022 Nosial', $basic_ascii) . PHP_EOL);
|
||||
|
||||
Console::out('Usage: ncc COMMAND [options]');
|
||||
Console::out('Alternative Usage: ncc.php --ncc-cli=COMMAND [options]' . PHP_EOL);
|
||||
|
@ -32,7 +59,6 @@
|
|||
self::displayMainOptions();
|
||||
self::displayManagementCommands();
|
||||
self::displayMainCommands();
|
||||
self::displayExtensions();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,22 +68,15 @@
|
|||
*/
|
||||
private static function displayMainOptions(): void
|
||||
{
|
||||
$options = [
|
||||
Console::out('Options:');
|
||||
Console::outHelpSections([
|
||||
new CliHelpSection(['{command} --help'], 'Displays help information about a specific command'),
|
||||
new CliHelpSection(['-v', '--version'], 'Display NCC version information'),
|
||||
new CliHelpSection(['-D', '--debug'], 'Enables debug mode'),
|
||||
new CliHelpSection(['-l', '--log-level={debug|info|warn|error|fatal}'], 'Set the logging level', 'info'),
|
||||
new CliHelpSection(['-l', '--log-level={silent|debug|verbose|info|warn|error|fatal}'], 'Set the logging level', 'info'),
|
||||
new CliHelpSection(['--basic-ascii'], 'Uses basic ascii characters'),
|
||||
new CliHelpSection(['--no-color'], 'Omits the use of colors'),
|
||||
new CliHelpSection(['--no-banner'], 'Omits displaying the NCC ascii banner')
|
||||
];
|
||||
$options_padding = \ncc\Utilities\Functions::detectParametersPadding($options) + 4;
|
||||
|
||||
Console::out('Options:');
|
||||
foreach($options as $option)
|
||||
{
|
||||
Console::out(' ' . $option->toString($options_padding));
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,20 +86,14 @@
|
|||
*/
|
||||
private static function displayManagementCommands(): void
|
||||
{
|
||||
$commands = [
|
||||
Console::out('Management Commands:');
|
||||
Console::outHelpSections([
|
||||
new CliHelpSection(['project'], 'Manages the current project'),
|
||||
new CliHelpSection(['package'], 'Manages the package system'),
|
||||
new CliHelpSection(['cache'], 'Manages the system cache'),
|
||||
new CliHelpSection(['credential'], 'Manages credentials'),
|
||||
new CliHelpSection(['cred'], 'Manages credentials'),
|
||||
new CliHelpSection(['config'], 'Changes NCC configuration values'),
|
||||
];
|
||||
$commands_padding = \ncc\Utilities\Functions::detectParametersPadding($commands) + 2;
|
||||
|
||||
Console::out('Management Commands:');
|
||||
foreach($commands as $command)
|
||||
{
|
||||
Console::out(' ' . $command->toString($commands_padding));
|
||||
}
|
||||
new CliHelpSection(['source'], 'Manages remote sources'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,35 +103,10 @@
|
|||
*/
|
||||
private static function displayMainCommands(): void
|
||||
{
|
||||
$commands = [
|
||||
new CliHelpSection(['build'], 'Builds the current project'),
|
||||
new CliHelpSection(['main'], 'Executes the main entrypoint of a package')
|
||||
];
|
||||
$commands_padding = \ncc\Utilities\Functions::detectParametersPadding($commands) + 2;
|
||||
|
||||
Console::out('Commands:');
|
||||
foreach($commands as $command)
|
||||
{
|
||||
Console::out(' ' . $command->toString($commands_padding));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the main commands section
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function displayExtensions(): void
|
||||
{
|
||||
$extensions = [
|
||||
new CliHelpSection(['exphp'], 'The PHP compiler extension')
|
||||
];
|
||||
$extensions_padding = \ncc\Utilities\Functions::detectParametersPadding($extensions) + 2;
|
||||
|
||||
Console::out('Extensions:');
|
||||
foreach($extensions as $command)
|
||||
{
|
||||
Console::out(' ' . $command->toString($extensions_padding));
|
||||
}
|
||||
Console::outHelpSections([
|
||||
new CliHelpSection(['build'], 'Builds the current project'),
|
||||
new CliHelpSection(['exec'], 'Executes the main entrypoint of a package')
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,24 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
|
@ -7,11 +27,22 @@
|
|||
use Exception;
|
||||
use ncc\Abstracts\LogLevel;
|
||||
use ncc\Abstracts\NccBuildFlags;
|
||||
use ncc\CLI\Commands\BuildCommand;
|
||||
use ncc\CLI\Commands\ExecCommand;
|
||||
use ncc\CLI\Management\ConfigMenu;
|
||||
use ncc\CLI\Management\CredentialMenu;
|
||||
use ncc\CLI\Management\PackageManagerMenu;
|
||||
use ncc\CLI\Management\ProjectMenu;
|
||||
use ncc\CLI\Management\SourcesMenu;
|
||||
use ncc\Exceptions\AccessDeniedException;
|
||||
use ncc\Exceptions\FileNotFoundException;
|
||||
use ncc\Exceptions\IOException;
|
||||
use ncc\Exceptions\RuntimeException;
|
||||
use ncc\ncc;
|
||||
use ncc\Utilities\Console;
|
||||
use ncc\Utilities\Functions;
|
||||
use ncc\Utilities\Resolver;
|
||||
use ncc\Utilities\RuntimeCache;
|
||||
|
||||
class Main
|
||||
{
|
||||
|
@ -24,12 +55,15 @@
|
|||
* @var string|null
|
||||
*/
|
||||
private static $log_level;
|
||||
|
||||
|
||||
/**
|
||||
* Executes the main CLI process
|
||||
*
|
||||
* @param $argv
|
||||
* @return void
|
||||
* @throws RuntimeException
|
||||
* @throws AccessDeniedException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static function start($argv): void
|
||||
{
|
||||
|
@ -51,8 +85,8 @@
|
|||
Console::outException('Cannot initialize NCC due to a runtime error.', $e, 1);
|
||||
}
|
||||
|
||||
// Define CLI stuff
|
||||
define('NCC_CLI_MODE', 1);
|
||||
register_shutdown_function('ncc\CLI\Main::shutdown');
|
||||
|
||||
if(isset(self::$args['l']) || isset(self::$args['log-level']))
|
||||
{
|
||||
|
@ -82,13 +116,13 @@
|
|||
if(Resolver::checkLogLevel(self::$log_level, LogLevel::Debug))
|
||||
{
|
||||
Console::outDebug('Debug logging enabled');
|
||||
Console::outDebug(sprintf('consts: %s', json_encode(ncc::getConstants(), JSON_UNESCAPED_SLASHES)));
|
||||
Console::outDebug(sprintf('const: %s', json_encode(ncc::getConstants(), JSON_UNESCAPED_SLASHES)));
|
||||
Console::outDebug(sprintf('args: %s', json_encode(self::$args, JSON_UNESCAPED_SLASHES)));
|
||||
}
|
||||
|
||||
if(in_array(NccBuildFlags::Unstable, NCC_VERSION_FLAGS))
|
||||
{
|
||||
//Console::outWarning('This is an unstable build of NCC, expect some features to not work as expected');
|
||||
Console::outWarning('This is an unstable build of NCC, expect some features to not work as expected');
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -97,32 +131,44 @@
|
|||
{
|
||||
default:
|
||||
Console::out('Unknown command ' . strtolower(self::$args['ncc-cli']));
|
||||
exit(1);
|
||||
break;
|
||||
|
||||
case 'project':
|
||||
ProjectMenu::start(self::$args);
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
case 'build':
|
||||
BuildMenu::start(self::$args);
|
||||
exit(0);
|
||||
BuildCommand::start(self::$args);
|
||||
break;
|
||||
|
||||
case 'credential':
|
||||
case 'exec':
|
||||
ExecCommand::start(self::$args);
|
||||
break;
|
||||
|
||||
case 'cred':
|
||||
CredentialMenu::start(self::$args);
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
case 'package':
|
||||
PackageManagerMenu::start(self::$args);
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
case 'config':
|
||||
ConfigMenu::start(self::$args);
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
case 'source':
|
||||
SourcesMenu::start(self::$args);
|
||||
break;
|
||||
|
||||
case 'version':
|
||||
Console::out(sprintf('NCC version %s (%s)', NCC_VERSION_NUMBER, NCC_VERSION_BRANCH));
|
||||
break;
|
||||
|
||||
case '1':
|
||||
case 'help':
|
||||
HelpMenu::start(self::$args);
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
|
@ -131,14 +177,27 @@
|
|||
exit(1);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return array
|
||||
*/
|
||||
public static function getArgs()
|
||||
public static function getArgs(): array
|
||||
{
|
||||
if (self::$args == null)
|
||||
{
|
||||
if(isset($argv))
|
||||
{
|
||||
self::$args = Resolver::parseArguments(implode(' ', $argv));
|
||||
}
|
||||
else
|
||||
{
|
||||
self::$args = [];
|
||||
}
|
||||
}
|
||||
|
||||
return self::$args;
|
||||
}
|
||||
|
||||
|
@ -152,4 +211,20 @@
|
|||
return self::$log_level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function shutdown(): void
|
||||
{
|
||||
try
|
||||
{
|
||||
RuntimeCache::clearCache();
|
||||
Functions::finalizePermissions();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
Console::outWarning('An error occurred while shutting down NCC, ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\CLI;
|
||||
namespace ncc\CLI\Management;
|
||||
|
||||
use ncc\Abstracts\Scopes;
|
||||
use ncc\Exceptions\AccessDeniedException;
|
||||
|
@ -83,7 +103,7 @@
|
|||
{
|
||||
if(Resolver::resolveScope() !== Scopes::System)
|
||||
{
|
||||
Console::outError('Insufficent permissions, cannot modify configuration values', true, 1);
|
||||
Console::outError('Insufficient permissions, cannot modify configuration values', true, 1);
|
||||
return;
|
||||
}
|
||||
|
397
src/ncc/CLI/Management/CredentialMenu.php
Normal file
397
src/ncc/CLI/Management/CredentialMenu.php
Normal file
|
@ -0,0 +1,397 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\CLI\Management;
|
||||
|
||||
use Exception;
|
||||
use ncc\Abstracts\Scopes;
|
||||
use ncc\Exceptions\RuntimeException;
|
||||
use ncc\Managers\CredentialManager;
|
||||
use ncc\Objects\CliHelpSection;
|
||||
use ncc\Objects\Vault\Password\AccessToken;
|
||||
use ncc\Objects\Vault\Password\UsernamePassword;
|
||||
use ncc\Utilities\Console;
|
||||
use ncc\Utilities\Functions;
|
||||
use ncc\Utilities\Resolver;
|
||||
|
||||
class CredentialMenu
|
||||
{
|
||||
/**
|
||||
* Displays the main help menu
|
||||
*
|
||||
* @param $args
|
||||
* @return void
|
||||
* @noinspection DuplicatedCode
|
||||
*/
|
||||
public static function start($args): void
|
||||
{
|
||||
if(isset($args['add']))
|
||||
{
|
||||
try
|
||||
{
|
||||
self::addEntry($args);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException('Error while adding entry.', $e, 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset($args['remove']))
|
||||
{
|
||||
try
|
||||
{
|
||||
self::removeEntry($args);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException('Cannot remove entry.', $e, 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset($args['list']))
|
||||
{
|
||||
try
|
||||
{
|
||||
self::listEntries();
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException('Cannot list entries.', $e, 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset($args['test']))
|
||||
{
|
||||
try
|
||||
{
|
||||
self::testEntry($args);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException('Cannot test entry.', $e, 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
self::displayOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests an entry authentication
|
||||
*
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
public static function testEntry($args): void
|
||||
{
|
||||
$name = $args['name'] ?? $args['alias'] ?? null;
|
||||
|
||||
if($name === null)
|
||||
{
|
||||
Console::outError('Please specify a name or alias for the entry.', true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
$credential_manager = new CredentialManager();
|
||||
$entry = $credential_manager->getVault()->getEntry($name);
|
||||
|
||||
if($entry === null)
|
||||
{
|
||||
Console::out('Entry not found.', true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if($entry->isEncrypted())
|
||||
{
|
||||
$tries = 0;
|
||||
|
||||
while(true)
|
||||
{
|
||||
try
|
||||
{
|
||||
$password = Console::passwordInput('Password/Secret: ');
|
||||
if (!$entry->unlock($password))
|
||||
{
|
||||
$tries++;
|
||||
if ($tries >= 3)
|
||||
{
|
||||
Console::outError('Too many failed attempts.', true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
Console::outError('Invalid password.', true, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console::out('Authentication successful.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
Console::outException('Cannot unlock entry.', $e, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Console::out('Authentication always successful, entry is not encrypted.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the list of entries in the vault
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function listEntries(): void
|
||||
{
|
||||
$credential_manager = new CredentialManager();
|
||||
$entries = $credential_manager->getVault()->getEntries();
|
||||
|
||||
if(count($entries) === 0)
|
||||
{
|
||||
Console::out('No entries found.');
|
||||
return;
|
||||
}
|
||||
|
||||
Console::out('Entries:');
|
||||
foreach($entries as $entry)
|
||||
{
|
||||
Console::out(sprintf(' - %s (%s)', $entry->getName(), $entry->isEncrypted() ? ' (encrypted)' : ''));
|
||||
}
|
||||
|
||||
Console::out('Total: ' . count($entries));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
public static function addEntry($args): void
|
||||
{
|
||||
$ResolvedScope = Resolver::resolveScope();
|
||||
|
||||
if($ResolvedScope !== Scopes::System)
|
||||
Console::outError('Insufficient permissions to add entries');
|
||||
|
||||
// Really dumb-proofing this
|
||||
$name = $args['alias'] ?? $args['name'] ?? null;
|
||||
$auth_type = $args['auth-type'] ?? $args['auth'] ?? null;
|
||||
$username = $args['username'] ?? $args['usr'] ?? null;
|
||||
$password = $args['password'] ?? $args['pwd'] ?? null;
|
||||
$token = $args['token'] ?? $args['pat'] ?? $args['private-token'] ?? null;
|
||||
$encrypt = !isset($args['no-encryption']);
|
||||
|
||||
if($name === null)
|
||||
$name = Console::getInput('Enter a name for the entry: ');
|
||||
|
||||
if($auth_type === null)
|
||||
$auth_type = Console::getInput('Enter the authentication type (login or pat): ');
|
||||
|
||||
if($auth_type === 'login')
|
||||
{
|
||||
if($username === null)
|
||||
$username = Console::getInput('Username: ');
|
||||
|
||||
if($password === null)
|
||||
$password = Console::passwordInput('Password: ');
|
||||
}
|
||||
elseif($auth_type === 'pat')
|
||||
{
|
||||
if($token === null)
|
||||
$token = Console::passwordInput('Token: ');
|
||||
}
|
||||
else
|
||||
{
|
||||
Console::outError('Invalid authentication type');
|
||||
}
|
||||
|
||||
if($name === null)
|
||||
{
|
||||
Console::outError('You must specify a name for the entry (alias, name)', true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if($auth_type === null)
|
||||
{
|
||||
Console::outError('You must specify an authentication type for the entry (auth-type, auth)', true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
$encrypt = Functions::cbool($encrypt);
|
||||
|
||||
switch($auth_type)
|
||||
{
|
||||
case 'login':
|
||||
|
||||
if($username === null)
|
||||
{
|
||||
Console::outError('You must specify a username for the entry (username, usr)', true, 1);
|
||||
return;
|
||||
}
|
||||
if($password === null)
|
||||
{
|
||||
Console::outError('You must specify a password for the entry (password, pwd)', true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
$pass_object = new UsernamePassword();
|
||||
$pass_object->setUsername($username);
|
||||
$pass_object->setPassword($password);
|
||||
|
||||
break;
|
||||
|
||||
case 'pat':
|
||||
|
||||
if($token === null)
|
||||
{
|
||||
Console::outError('You must specify a token for the entry (token, pat, private-token)', true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
$pass_object = new AccessToken();
|
||||
$pass_object->setAccessToken($token);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
Console::outError('Invalid authentication type specified', true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
$credential_manager = new CredentialManager();
|
||||
if(!$credential_manager->getVault()->addEntry($name, $pass_object, $encrypt))
|
||||
{
|
||||
Console::outError('Failed to add entry, entry already exists.', true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$credential_manager->saveVault();
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException('Failed to save vault', $e, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
Console::out('Successfully added entry', true, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an existing entry from the vault.
|
||||
*
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
private static function removeEntry($args): void
|
||||
{
|
||||
$ResolvedScope = Resolver::resolveScope();
|
||||
|
||||
if($ResolvedScope !== Scopes::System)
|
||||
Console::outError('Insufficient permissions to remove entries');
|
||||
|
||||
$name = $args['alias'] ?? $args['name'] ?? null;
|
||||
|
||||
if($name === null)
|
||||
$name = Console::getInput('Enter the name of the entry to remove: ');
|
||||
|
||||
$credential_manager = new CredentialManager();
|
||||
if(!$credential_manager->getVault()->deleteEntry($name))
|
||||
{
|
||||
Console::outError('Failed to remove entry, entry does not exist.', true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$credential_manager->saveVault();
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException('Failed to save vault', $e, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
Console::out('Successfully removed entry', true, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the main options section
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function displayOptions(): void
|
||||
{
|
||||
Console::out('Usage: ncc cred {command} [options]');
|
||||
Console::out('Options:');
|
||||
Console::outHelpSections([
|
||||
new CliHelpSection(['help'], 'Displays this help menu about the value command'),
|
||||
new CliHelpSection(['add'], 'Adds a new entry to the vault (See below)'),
|
||||
new CliHelpSection(['remove', '--name'], 'Removes an entry from the vault'),
|
||||
new CliHelpSection(['list'], 'Lists all entries in the vault'),
|
||||
]);
|
||||
Console::out((string)null);
|
||||
|
||||
Console::out('If you are adding a new entry, you can run the add command in interactive mode');
|
||||
Console::out('or you can specify the options below' . PHP_EOL);
|
||||
|
||||
Console::out('Add Options:');
|
||||
Console::outHelpSections([
|
||||
new CliHelpSection(['--name'], 'The name of the entry'),
|
||||
new CliHelpSection(['--auth-type', '--auth'], 'The type of authentication (login, pat)'),
|
||||
new CliHelpSection(['--no-encryption'], 'Omit encryption to the entry (By default it\'s encrypted)', true),
|
||||
]);
|
||||
|
||||
Console::out(' login authentication type options:');
|
||||
Console::outHelpSections([
|
||||
new CliHelpSection(['--username', '--usr'], 'The username for the entry'),
|
||||
new CliHelpSection(['--password', '--pwd'], 'The password for the entry'),
|
||||
]);
|
||||
|
||||
Console::out(' pat authentication type options:');
|
||||
Console::outHelpSections([
|
||||
new CliHelpSection(['--token', '--pat',], 'The private access token for the entry', true),
|
||||
]);
|
||||
|
||||
Console::out('Authentication Types:');
|
||||
Console::out(' login');
|
||||
Console::out(' pat' . PHP_EOL);
|
||||
|
||||
Console::out('Examples:');
|
||||
Console::out(' ncc cred add --alias "My Alias" --auth-type login --username "myusername" --password "mypassword"');
|
||||
Console::out(' ncc cred add --alias "My Alias" --auth-type pat --token "mytoken" --no-encryption');
|
||||
Console::out(' ncc cred remove --alias "My Alias"');
|
||||
}
|
||||
}
|
|
@ -1,15 +1,36 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\CLI;
|
||||
namespace ncc\CLI\Management;
|
||||
|
||||
use Exception;
|
||||
use ncc\Abstracts\ConsoleColors;
|
||||
use ncc\Abstracts\RemoteSource;
|
||||
use ncc\Abstracts\Options\InstallPackageOptions;
|
||||
use ncc\Abstracts\Scopes;
|
||||
use ncc\Classes\ComposerExtension\ComposerSource;
|
||||
use ncc\Exceptions\FileNotFoundException;
|
||||
use ncc\Exceptions\PackageLockException;
|
||||
use ncc\Exceptions\RuntimeException;
|
||||
use ncc\Exceptions\VersionNotFoundException;
|
||||
use ncc\Managers\CredentialManager;
|
||||
use ncc\Managers\PackageManager;
|
||||
use ncc\Objects\CliHelpSection;
|
||||
use ncc\Objects\Package;
|
||||
|
@ -84,6 +105,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
if(isset($args['sdc']))
|
||||
{
|
||||
try
|
||||
{
|
||||
self::semiDecompile($args);
|
||||
return;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException('List Failed', $e, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
self::displayOptions();
|
||||
exit(0);
|
||||
}
|
||||
|
@ -116,6 +151,91 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Semi-Decompiles a package and prints it to the console
|
||||
*
|
||||
* @param $args
|
||||
* @return void
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
private static function semiDecompile($args): void
|
||||
{
|
||||
$path = ($args['package'] ?? $args['p']);
|
||||
|
||||
if(!file_exists($path) || !is_file($path) || !is_readable($path))
|
||||
throw new FileNotFoundException('The specified file \'' . $path .' \' does not exist or is not readable.');
|
||||
|
||||
try
|
||||
{
|
||||
$package = Package::load($path);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException('Error while loading package', $e, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
Console::out('magic_bytes: ' . json_encode(($package->MagicBytes?->toArray() ?? []), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||
Console::out('header: ' . json_encode(($package->Header?->toArray() ?? []), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||
Console::out('assembly: ' . json_encode(($package->Assembly?->toArray() ?? []), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||
Console::out('main: ' . ($package->MainExecutionPolicy ?? 'N/A'));
|
||||
Console::out('installer: ' . ($package->Installer?->toArray() ?? 'N/A'));
|
||||
|
||||
if($package->Dependencies !== null && count($package->Dependencies) > 0)
|
||||
{
|
||||
Console::out('dependencies:');
|
||||
foreach($package->Dependencies as $dependency)
|
||||
{
|
||||
Console::out(' - ' . json_encode($dependency->toArray(), JSON_UNESCAPED_SLASHES));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console::out('dependencies: N/A');
|
||||
}
|
||||
|
||||
if($package->ExecutionUnits !== null && count($package->ExecutionUnits) > 0)
|
||||
{
|
||||
Console::out('execution_units:');
|
||||
foreach($package->ExecutionUnits as $unit)
|
||||
{
|
||||
Console::out(' - ' . json_encode($unit->toArray(), JSON_UNESCAPED_SLASHES));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console::out('execution_units: N/A');
|
||||
}
|
||||
|
||||
if($package->Resources !== null && count($package->Resources) > 0)
|
||||
{
|
||||
Console::out('resources:');
|
||||
foreach($package->Resources as $resource)
|
||||
{
|
||||
Console::out(' - ' . sprintf('%s - (%s)', $resource->Name, Functions::b2u(strlen($resource->Data))));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console::out('resources: N/A');
|
||||
}
|
||||
|
||||
if($package->Components !== null && count($package->Components) > 0)
|
||||
{
|
||||
Console::out('components:');
|
||||
foreach($package->Components as $component)
|
||||
{
|
||||
Console::out(' - ' . sprintf('#%s %s - %s', $component->DataType, $component->Name, json_encode(($component->Flags ?? []), JSON_UNESCAPED_SLASHES)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console::out('components: N/A');
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays all installed packages
|
||||
*
|
||||
|
@ -156,6 +276,7 @@
|
|||
$package_version = $package_manager->getPackageVersion($package, $version);
|
||||
if($package_version == null)
|
||||
continue;
|
||||
|
||||
Console::out(sprintf('%s=%s (%s)',
|
||||
Console::formatColor($package, ConsoleColors::LightGreen),
|
||||
Console::formatColor($version, ConsoleColors::LightMagenta),
|
||||
|
@ -165,9 +286,10 @@
|
|||
catch(Exception $e)
|
||||
{
|
||||
unset($e);
|
||||
Console::out(sprintf('%s=%s',
|
||||
Console::out(sprintf('%s=%s (%s)',
|
||||
Console::formatColor($package, ConsoleColors::LightGreen),
|
||||
Console::formatColor($version, ConsoleColors::LightMagenta)
|
||||
Console::formatColor($version, ConsoleColors::LightMagenta),
|
||||
Console::formatColor('N/A', ConsoleColors::LightRed)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -191,33 +313,66 @@
|
|||
return;
|
||||
}
|
||||
|
||||
$path = $package;
|
||||
$parsed_source = new RemotePackageInput($path);
|
||||
if($parsed_source->Vendor !== null && $parsed_source->Package !== null)
|
||||
// check if authentication is provided
|
||||
$entry_arg = ($args['auth'] ?? null);
|
||||
$credential_manager = new CredentialManager();
|
||||
|
||||
if($entry_arg !== null)
|
||||
{
|
||||
if($parsed_source->Source == null)
|
||||
$credential = $credential_manager->getVault()->getEntry($entry_arg);
|
||||
|
||||
if($credential == null)
|
||||
{
|
||||
Console::outError('No source specified', true, 1);
|
||||
Console::outError(sprintf('Unknown credential entry \'%s\'', $entry_arg), true, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$credential = null;
|
||||
}
|
||||
|
||||
switch($parsed_source->Source)
|
||||
if($credential !== null && !$credential->isCurrentlyDecrypted())
|
||||
{
|
||||
// Try 3 times
|
||||
for($i = 0; $i < 3; $i++)
|
||||
{
|
||||
case RemoteSource::Composer:
|
||||
try
|
||||
{
|
||||
$path = ComposerSource::fetch($parsed_source);
|
||||
break;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException(sprintf('Failed to fetch package %s', $package), $e, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
Console::outError('Cannot install package from source: ' . $parsed_source->Source, true, 1);
|
||||
try
|
||||
{
|
||||
$credential->unlock(Console::passwordInput(sprintf('Enter Password for %s: ', $credential->getName())));
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
Console::outException(sprintf('Failed to unlock credential %s', $credential->getName()), $e, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if($credential->isCurrentlyDecrypted())
|
||||
break;
|
||||
|
||||
Console::outWarning(sprintf('Invalid password, %d attempts remaining', 2 - $i));
|
||||
}
|
||||
|
||||
if(!$credential->isCurrentlyDecrypted())
|
||||
{
|
||||
Console::outError('Failed to unlock credential', true, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$path = $package;
|
||||
$parsed_source = new RemotePackageInput($path);
|
||||
|
||||
if($parsed_source->Vendor !== null && $parsed_source->Package !== null && $parsed_source->Source !== null)
|
||||
{
|
||||
try
|
||||
{
|
||||
$path = $package_manager->fetchFromSource($parsed_source->toString(), $credential);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
Console::outException('Failed to fetch package from source', $e, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,6 +385,18 @@
|
|||
$user_confirmation = (bool)($args['y'] ?? $args['Y']);
|
||||
}
|
||||
|
||||
$installer_options = [];
|
||||
|
||||
if((Functions::cbool($args['skip-dependencies'] ?? false)))
|
||||
{
|
||||
$installer_options[] = InstallPackageOptions::SkipDependencies;
|
||||
}
|
||||
|
||||
if(Functions::cbool($args['reinstall'] ?? false))
|
||||
{
|
||||
$installer_options[] = InstallPackageOptions::Reinstall;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$package = Package::load($path);
|
||||
|
@ -261,38 +428,39 @@
|
|||
Console::out(' Trademark: ' . Console::formatColor($package->Assembly->Trademark, ConsoleColors::LightGreen));
|
||||
Console::out((string)null);
|
||||
|
||||
if(count($package->Dependencies) > 0)
|
||||
if(count($package->Dependencies) > 0 && !in_array(InstallPackageOptions::Reinstall, $installer_options))
|
||||
{
|
||||
$dependencies = [];
|
||||
foreach($package->Dependencies as $dependency)
|
||||
{
|
||||
$require_dependency = true;
|
||||
$require_dependency = false;
|
||||
|
||||
try
|
||||
{
|
||||
$dependency_package = $package_manager->getPackage($dependency->Name);
|
||||
}
|
||||
catch (PackageLockException $e)
|
||||
{
|
||||
unset($e);
|
||||
$dependency_package = null;
|
||||
}
|
||||
|
||||
if($dependency_package !== null)
|
||||
if(!in_array(InstallPackageOptions::SkipDependencies, $installer_options))
|
||||
{
|
||||
try
|
||||
{
|
||||
$dependency_version = $dependency_package->getVersion($dependency->Version);
|
||||
$dependency_package = $package_manager->getPackage($dependency->Name);
|
||||
}
|
||||
catch (VersionNotFoundException $e)
|
||||
catch (PackageLockException $e)
|
||||
{
|
||||
unset($e);
|
||||
$dependency_version = null;
|
||||
$dependency_package = null;
|
||||
}
|
||||
|
||||
if($dependency_version !== null)
|
||||
if($dependency_package !== null)
|
||||
{
|
||||
$require_dependency = false;
|
||||
try
|
||||
{
|
||||
$dependency_version = $dependency_package->getVersion($dependency->Version);
|
||||
}
|
||||
catch (VersionNotFoundException $e)
|
||||
{
|
||||
unset($e);
|
||||
$dependency_version = null;
|
||||
}
|
||||
|
||||
if($dependency_version == null)
|
||||
$require_dependency = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,8 +473,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
Console::out('The following dependencies will be installed:');
|
||||
Console::out(sprintf('%s', implode(PHP_EOL, $dependencies)));
|
||||
if($dependencies !== null && count($dependencies) > 0)
|
||||
{
|
||||
Console::out('The package requires the following dependencies:');
|
||||
Console::out(sprintf('%s', implode(PHP_EOL, $dependencies)));
|
||||
}
|
||||
}
|
||||
|
||||
Console::out(sprintf('Extension: %s',
|
||||
|
@ -326,11 +497,13 @@
|
|||
if(!$user_confirmation)
|
||||
$user_confirmation = Console::getBooleanInput(sprintf('Do you want to install %s', $package->Assembly->Package));
|
||||
|
||||
|
||||
|
||||
if($user_confirmation)
|
||||
{
|
||||
try
|
||||
{
|
||||
$package_manager->install($path);
|
||||
$package_manager->install($path, $credential, $installer_options);
|
||||
Console::out(sprintf('Package %s installed successfully', $package->Assembly->Package));
|
||||
}
|
||||
catch(Exception $e)
|
||||
|
@ -382,7 +555,6 @@
|
|||
|
||||
$version_entry = null;
|
||||
if($version_entry !== null && $package_entry !== null)
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
/** @noinspection PhpRedundantOptionalArgumentInspection */
|
||||
$version_entry = $package_entry->getVersion($version_entry, false);
|
||||
|
||||
|
@ -490,9 +662,12 @@
|
|||
new CliHelpSection(['list'], 'Lists all installed packages on the system'),
|
||||
new CliHelpSection(['install', '--package', '-p'], 'Installs a specified NCC package'),
|
||||
new CliHelpSection(['install', '--package', '-p', '--version', '-v'], 'Installs a specified NCC package version'),
|
||||
new CliHelpSection(['install', '-p', '--skip-dependencies'], 'Installs a specified NCC package but skips the installation of dependencies'),
|
||||
new CliHelpSection(['install', '-p', '--reinstall'], 'Installs a specified NCC package, reinstall if already installed'),
|
||||
new CliHelpSection(['uninstall', '--package', '-p'], 'Uninstalls a specified NCC package'),
|
||||
new CliHelpSection(['uninstall', '--package', '-p', '--version', '-v'], 'Uninstalls a specified NCC package version'),
|
||||
new CliHelpSection(['uninstall-all'], 'Uninstalls all packages'),
|
||||
new CliHelpSection(['sdc', '--package', '-p'], '(Debug) Semi-decompiles a specified NCC package and prints the result to the console'),
|
||||
];
|
||||
|
||||
$options_padding = Functions::detectParametersPadding($options) + 4;
|
|
@ -1,18 +1,45 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\CLI;
|
||||
namespace ncc\CLI\Management;
|
||||
|
||||
use Exception;
|
||||
use ncc\Abstracts\CompilerExtensionDefaultVersions;
|
||||
use ncc\Abstracts\CompilerExtensions;
|
||||
use ncc\Abstracts\CompilerExtensionSupportedVersions;
|
||||
use ncc\Exceptions\AccessDeniedException;
|
||||
use ncc\Exceptions\DirectoryNotFoundException;
|
||||
use ncc\Exceptions\FileNotFoundException;
|
||||
use ncc\Exceptions\InvalidPackageNameException;
|
||||
use ncc\Exceptions\InvalidProjectNameException;
|
||||
use ncc\Exceptions\IOException;
|
||||
use ncc\Exceptions\MalformedJsonException;
|
||||
use ncc\Exceptions\ProjectAlreadyExistsException;
|
||||
use ncc\Exceptions\ProjectConfigurationNotFoundException;
|
||||
use ncc\Managers\ProjectManager;
|
||||
use ncc\Objects\CliHelpSection;
|
||||
use ncc\Objects\ProjectConfiguration\Compiler;
|
||||
use ncc\Utilities\Console;
|
||||
use ncc\Utilities\Functions;
|
||||
|
||||
class ProjectMenu
|
||||
{
|
||||
|
@ -21,6 +48,12 @@
|
|||
*
|
||||
* @param $args
|
||||
* @return void
|
||||
* @throws AccessDeniedException
|
||||
* @throws DirectoryNotFoundException
|
||||
* @throws FileNotFoundException
|
||||
* @throws IOException
|
||||
* @throws MalformedJsonException
|
||||
* @throws ProjectConfigurationNotFoundException
|
||||
*/
|
||||
public static function start($args): void
|
||||
{
|
||||
|
@ -30,13 +63,17 @@
|
|||
}
|
||||
|
||||
self::displayOptions();
|
||||
exit(0);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $args
|
||||
* @return void
|
||||
* @throws AccessDeniedException
|
||||
* @throws DirectoryNotFoundException
|
||||
* @throws FileNotFoundException
|
||||
* @throws IOException
|
||||
* @throws MalformedJsonException
|
||||
* @throws ProjectConfigurationNotFoundException
|
||||
*/
|
||||
public static function createProject($args): void
|
||||
{
|
||||
|
@ -64,6 +101,7 @@
|
|||
else
|
||||
{
|
||||
Console::outError('The selected source directory \'' . $full_path . '\' was not found or is not a directory', true, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -72,7 +110,7 @@
|
|||
}
|
||||
|
||||
// Remove basename from real_src
|
||||
$real_src = \ncc\Utilities\Functions::removeBasename($real_src, $current_directory);
|
||||
$real_src = Functions::removeBasename($real_src, $current_directory);
|
||||
|
||||
// Fetch the rest of the information needed for the project
|
||||
//$compiler_extension = Console::getOptionInput($args, 'ce', 'Compiler Extension (php, java): ');
|
||||
|
@ -221,7 +259,7 @@
|
|||
new CliHelpSection(['create-makefile'], 'Generates a Makefile for the project'),
|
||||
];
|
||||
|
||||
$options_padding = \ncc\Utilities\Functions::detectParametersPadding($options) + 4;
|
||||
$options_padding = Functions::detectParametersPadding($options) + 4;
|
||||
|
||||
Console::out('Usage: ncc project {command} [options]');
|
||||
Console::out('Options:' . PHP_EOL);
|
240
src/ncc/CLI/Management/SourcesMenu.php
Normal file
240
src/ncc/CLI/Management/SourcesMenu.php
Normal file
|
@ -0,0 +1,240 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\CLI\Management;
|
||||
|
||||
use Exception;
|
||||
use ncc\Abstracts\Scopes;
|
||||
use ncc\Exceptions\IOException;
|
||||
use ncc\Managers\RemoteSourcesManager;
|
||||
use ncc\Objects\CliHelpSection;
|
||||
use ncc\Objects\DefinedRemoteSource;
|
||||
use ncc\Utilities\Console;
|
||||
use ncc\Utilities\Functions;
|
||||
use ncc\Utilities\Resolver;
|
||||
|
||||
class SourcesMenu
|
||||
{
|
||||
/**
|
||||
* Displays the main help menu
|
||||
*
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
public static function start($args): void
|
||||
{
|
||||
if(isset($args['add']))
|
||||
{
|
||||
try
|
||||
{
|
||||
self::addEntry($args);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException('Error while adding entry.', $e, 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset($args['remove']))
|
||||
{
|
||||
try
|
||||
{
|
||||
self::removeEntry($args);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException('Cannot remove entry.', $e, 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset($args['list']))
|
||||
{
|
||||
try
|
||||
{
|
||||
self::listEntries();
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
Console::outException('Cannot list entries.', $e, 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
self::displayOptions();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function listEntries(): void
|
||||
{
|
||||
$source_manager = new RemoteSourcesManager();
|
||||
$sources = $source_manager->getSources();
|
||||
|
||||
if(count($sources) == 0)
|
||||
{
|
||||
Console::out('No remote sources defined.', 1);
|
||||
return;
|
||||
}
|
||||
|
||||
Console::out('Remote sources:', 1);
|
||||
foreach($sources as $source)
|
||||
{
|
||||
Console::out(' - ' . $source->Name . ' (' . $source->Host . ')', 1);
|
||||
}
|
||||
|
||||
Console::out('Total: ' . count($sources), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
public static function addEntry($args): void
|
||||
{
|
||||
if(Resolver::resolveScope() !== Scopes::System)
|
||||
{
|
||||
Console::outError('Insufficient permissions to add entry.', true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
$name = $args['name'] ?? null;
|
||||
$type = $args['type'] ?? null;
|
||||
$host = $args['host'] ?? null;
|
||||
$ssl = $args['ssl'] ?? null;
|
||||
|
||||
if($name == null)
|
||||
{
|
||||
Console::outError(sprintf('Missing required argument \'%s\'.', 'name'), true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if($type == null)
|
||||
{
|
||||
Console::outError(sprintf('Missing required argument \'%s\'.', 'type'), true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if($host == null)
|
||||
{
|
||||
Console::outError(sprintf('Missing required argument \'%s\'.', 'host'), true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if($ssl !== null)
|
||||
{
|
||||
$ssl = Functions::cbool($ssl);
|
||||
}
|
||||
|
||||
$source_manager = new RemoteSourcesManager();
|
||||
$source = new DefinedRemoteSource();
|
||||
$source->Name = $name;
|
||||
$source->Type = $type;
|
||||
$source->Host = $host;
|
||||
$source->SSL = $ssl;
|
||||
|
||||
if(!$source_manager->addRemoteSource($source))
|
||||
{
|
||||
Console::outError(sprintf('Cannot add entry \'%s\', it already exists', $name), true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$source_manager->save();
|
||||
}
|
||||
catch (IOException $e)
|
||||
{
|
||||
Console::outException('Cannot save remote sources file.', $e, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
Console::out(sprintf('Entry \'%s\' added successfully.', $name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an existing entry from the vault.
|
||||
*
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
private static function removeEntry($args): void
|
||||
{
|
||||
$ResolvedScope = Resolver::resolveScope();
|
||||
|
||||
if($ResolvedScope !== Scopes::System)
|
||||
Console::outError('Insufficient permissions to remove entries');
|
||||
|
||||
$name = $args['name'] ?? null;
|
||||
|
||||
if($name == null)
|
||||
{
|
||||
Console::outError(sprintf('Missing required argument \'%s\'.', 'name'), true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
$source_manager = new RemoteSourcesManager();
|
||||
|
||||
if(!$source_manager->deleteRemoteSource($name))
|
||||
{
|
||||
Console::outError(sprintf('Cannot remove entry \'%s\', it does not exist', $name), true, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$source_manager->save();
|
||||
}
|
||||
catch (IOException $e)
|
||||
{
|
||||
Console::outException('Cannot save remote sources file.', $e, 1);
|
||||
return;
|
||||
|
||||
}
|
||||
Console::out(sprintf('Entry \'%s\' removed successfully.', $name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the main options section
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function displayOptions(): void
|
||||
{
|
||||
Console::out('Usage: ncc sources {command} [options]');
|
||||
Console::out('Options:');
|
||||
Console::outHelpSections([
|
||||
new CliHelpSection(['help'], 'Displays this help menu about the sources command'),
|
||||
new CliHelpSection(['add'], 'Adds a new entry to the list of remote sources (See below)'),
|
||||
new CliHelpSection(['remove', '--name'], 'Removes an entry from the list'),
|
||||
new CliHelpSection(['list'], 'Lists all entries defined as remote sources'),
|
||||
]);
|
||||
Console::out((string)null);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ncc\CLI;
|
||||
|
||||
use ncc\Objects\CliHelpSection;
|
||||
use ncc\Utilities\Console;
|
||||
|
||||
class PhpMenu
|
||||
{
|
||||
/**
|
||||
* Displays the main help menu
|
||||
*
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
public static function start($args): void
|
||||
{
|
||||
if(isset($args['create']))
|
||||
{
|
||||
self::createProject($args);
|
||||
}
|
||||
|
||||
self::displayOptions();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new Autoloader file for the project
|
||||
*
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
private static function generateAutoload($args): void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the main options section
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function displayOptions(): void
|
||||
{
|
||||
$options = [
|
||||
new CliHelpSection(['help'], 'Displays this help menu about the PHP command'),
|
||||
new CliHelpSection(['build', '--autoload'], 'Builds a new Autoload file for the project (Development purposes only)')
|
||||
];
|
||||
|
||||
$options_padding = \ncc\Utilities\Functions::detectParametersPadding($options) + 4;
|
||||
|
||||
Console::out('Usage: ncc php {command} [options]');
|
||||
Console::out('Options:' . PHP_EOL);
|
||||
foreach($options as $option)
|
||||
{
|
||||
Console::out(' ' . $option->toString($options_padding));
|
||||
}
|
||||
}
|
||||
}
|
56
src/ncc/Classes/BashExtension/BashRunner.php
Normal file
56
src/ncc/Classes/BashExtension/BashRunner.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Classes\BashExtension;
|
||||
|
||||
use ncc\Exceptions\FileNotFoundException;
|
||||
use ncc\Interfaces\RunnerInterface;
|
||||
use ncc\Objects\Package\ExecutionUnit;
|
||||
use ncc\Objects\ProjectConfiguration\ExecutionPolicy;
|
||||
use ncc\Utilities\IO;
|
||||
|
||||
class BashRunner implements RunnerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit
|
||||
{
|
||||
$execution_unit = new ExecutionUnit();
|
||||
if(!file_exists($path) && !is_file($path))
|
||||
throw new FileNotFoundException($path);
|
||||
$policy->Execute->Target = null;
|
||||
$execution_unit->ExecutionPolicy = $policy;
|
||||
$execution_unit->Data = IO::fread($path);
|
||||
|
||||
return $execution_unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getFileExtension(): string
|
||||
{
|
||||
return '.bash';
|
||||
}
|
||||
}
|
|
@ -1,6 +1,26 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Classes\ComposerExtension;
|
||||
namespace ncc\Classes\ComposerExtension;
|
||||
|
||||
use Exception;
|
||||
use FilesystemIterator;
|
||||
|
@ -28,10 +48,11 @@
|
|||
use ncc\Exceptions\ProjectConfigurationNotFoundException;
|
||||
use ncc\Exceptions\RuntimeException;
|
||||
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
||||
use ncc\Exceptions\UnsupportedRunnerException;
|
||||
use ncc\Exceptions\UserAbortedOperationException;
|
||||
use ncc\Interfaces\RemoteSourceInterface;
|
||||
use ncc\Interfaces\ServiceSourceInterface;
|
||||
use ncc\Managers\ProjectManager;
|
||||
use ncc\ncc;
|
||||
use ncc\Objects\ComposerJson;
|
||||
use ncc\Objects\ComposerLock;
|
||||
use ncc\Objects\ProjectConfiguration;
|
||||
use ncc\Objects\RemotePackageInput;
|
||||
|
@ -47,7 +68,7 @@
|
|||
use ncc\Utilities\RuntimeCache;
|
||||
use SplFileInfo;
|
||||
|
||||
class ComposerSource implements RemoteSourceInterface
|
||||
class ComposerSourceBuiltin implements ServiceSourceInterface
|
||||
{
|
||||
/**
|
||||
* Attempts to acquire the package from the composer repository and
|
||||
|
@ -77,7 +98,6 @@
|
|||
* @throws ProjectConfigurationNotFoundException
|
||||
* @throws RuntimeException
|
||||
* @throws UnsupportedCompilerExtensionException
|
||||
* @throws UnsupportedRunnerException
|
||||
* @throws UserAbortedOperationException
|
||||
*/
|
||||
public static function fetch(RemotePackageInput $packageInput): string
|
||||
|
@ -95,6 +115,70 @@
|
|||
throw new RuntimeException(sprintf('Could not find package %s in the compiled packages', $packageInput->toStandard()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Works with a local composer.json file and attempts to compile the required packages
|
||||
* and their dependencies, returns the path to the compiled package.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
* @throws AccessDeniedException
|
||||
* @throws BuildConfigurationNotFoundException
|
||||
* @throws BuildException
|
||||
* @throws ComposerDisabledException
|
||||
* @throws ComposerException
|
||||
* @throws ComposerNotAvailableException
|
||||
* @throws DirectoryNotFoundException
|
||||
* @throws FileNotFoundException
|
||||
* @throws IOException
|
||||
* @throws InternalComposerNotAvailableException
|
||||
* @throws MalformedJsonException
|
||||
* @throws PackageNotFoundException
|
||||
* @throws PackagePreparationFailedException
|
||||
* @throws ProjectConfigurationNotFoundException
|
||||
* @throws UnsupportedCompilerExtensionException
|
||||
* @throws UserAbortedOperationException
|
||||
*/
|
||||
public static function fromLocal(string $path): string
|
||||
{
|
||||
// Check if the file composer.json exists
|
||||
if (!file_exists($path . DIRECTORY_SEPARATOR . 'composer.json'))
|
||||
throw new FileNotFoundException(sprintf('File "%s" not found', $path . DIRECTORY_SEPARATOR . 'composer.json'));
|
||||
|
||||
// Execute composer with options
|
||||
$options = self::getOptions();
|
||||
$composer_exec = self::getComposerPath();
|
||||
$process = new Process([$composer_exec, 'install']);
|
||||
self::prepareProcess($process, $path, $options);
|
||||
|
||||
Console::outDebug(sprintf('executing %s', $process->getCommandLine()));
|
||||
$process->run(function ($type, $buffer) {
|
||||
Console::out($buffer, false);
|
||||
});
|
||||
|
||||
if (!$process->isSuccessful())
|
||||
throw new ComposerException($process->getErrorOutput());
|
||||
|
||||
$filesystem = new Filesystem();
|
||||
if($filesystem->exists($path . DIRECTORY_SEPARATOR . 'build'))
|
||||
$filesystem->remove($path . DIRECTORY_SEPARATOR . 'build');
|
||||
$filesystem->mkdir($path . DIRECTORY_SEPARATOR . 'build');
|
||||
|
||||
// Compile dependencies
|
||||
self::compilePackages($path . DIRECTORY_SEPARATOR . 'composer.lock');
|
||||
|
||||
$composer_lock = Functions::loadJson(IO::fread($path . DIRECTORY_SEPARATOR . 'composer.lock'), Functions::FORCE_ARRAY);
|
||||
$version_map = self::getVersionMap(ComposerLock::fromArray($composer_lock));
|
||||
|
||||
// Finally convert the main package's composer.json to package.json and compile it
|
||||
ComposerSourceBuiltin::convertProject($path, $version_map);
|
||||
$project_manager = new ProjectManager($path);
|
||||
$project_manager->load();
|
||||
$built_package = $project_manager->build();
|
||||
|
||||
RuntimeCache::setFileAsTemporary($built_package);
|
||||
return $built_package;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $composer_lock_path
|
||||
* @return array
|
||||
|
@ -109,7 +193,6 @@
|
|||
* @throws PackagePreparationFailedException
|
||||
* @throws ProjectConfigurationNotFoundException
|
||||
* @throws UnsupportedCompilerExtensionException
|
||||
* @throws UnsupportedRunnerException
|
||||
*/
|
||||
private static function compilePackages(string $composer_lock_path): array
|
||||
{
|
||||
|
@ -129,108 +212,19 @@
|
|||
}
|
||||
|
||||
$filesystem->mkdir($base_dir . DIRECTORY_SEPARATOR . 'build');
|
||||
$version_map = self::getVersionMap($composer_lock);
|
||||
|
||||
foreach ($composer_lock->Packages as $package)
|
||||
{
|
||||
$package_path = $base_dir . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $package->Name;
|
||||
// Generate the package configuration
|
||||
$project_configuration = ComposerSource::generateProjectConfiguration($package->Name, $composer_lock);
|
||||
|
||||
// Process the source files
|
||||
if ($package->Autoload !== null)
|
||||
{
|
||||
$source_directory = $package_path . DIRECTORY_SEPARATOR . '.src';
|
||||
if ($filesystem->exists($source_directory))
|
||||
{
|
||||
$filesystem->remove($source_directory);
|
||||
}
|
||||
$filesystem->mkdir($source_directory);
|
||||
$source_directories = [];
|
||||
$static_files = [];
|
||||
// Load the composer lock file
|
||||
$composer_package = $composer_lock->getPackage($package->Name);
|
||||
if ($composer_package == null)
|
||||
throw new PackageNotFoundException(sprintf('Package "%s" not found in composer lock file', $package->Name));
|
||||
|
||||
// TODO: Implement static files handling
|
||||
|
||||
// Extract all the source directories
|
||||
if ($package->Autoload->Psr4 !== null && count($package->Autoload->Psr4) > 0)
|
||||
{
|
||||
Console::outVerbose('Extracting PSR-4 source directories');
|
||||
foreach ($package->Autoload->Psr4 as $namespace_pointer)
|
||||
{
|
||||
if ($namespace_pointer->Path !== null && !in_array($namespace_pointer->Path, $source_directories))
|
||||
{
|
||||
$source_directories[] = $package_path . DIRECTORY_SEPARATOR . $namespace_pointer->Path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($package->Autoload->Psr0 !== null && count($package->Autoload->Psr0) > 0)
|
||||
{
|
||||
Console::outVerbose('Extracting PSR-0 source directories');
|
||||
foreach ($package->Autoload->Psr0 as $namespace_pointer)
|
||||
{
|
||||
if ($namespace_pointer->Path !== null && !in_array($namespace_pointer->Path, $source_directories))
|
||||
{
|
||||
$source_directories[] = $package_path . DIRECTORY_SEPARATOR . $namespace_pointer->Path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($package->Autoload->Files !== null && count($package->Autoload->Files) > 0)
|
||||
{
|
||||
Console::outVerbose('Extracting static files');
|
||||
foreach ($package->Autoload->Files as $file)
|
||||
{
|
||||
$static_files[] = $package_path . DIRECTORY_SEPARATOR . $file;
|
||||
}
|
||||
}
|
||||
|
||||
Console::outDebug(sprintf('source directories: %s', implode(', ', $source_directories)));
|
||||
|
||||
// First scan the project files and create a file struct.
|
||||
$DirectoryScanner = new DirectoryScanner();
|
||||
|
||||
// TODO: Implement exclude-class handling
|
||||
try
|
||||
{
|
||||
$DirectoryScanner->unsetFlag(FilesystemIterator::FOLLOW_SYMLINKS);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new PackagePreparationFailedException('Cannot unset flag \'FOLLOW_SYMLINKS\' in DirectoryScanner, ' . $e->getMessage(), $e);
|
||||
}
|
||||
|
||||
// Include file components that can be compiled
|
||||
$DirectoryScanner->setIncludes(ComponentFileExtensions::Php);
|
||||
|
||||
foreach ($source_directories as $directory)
|
||||
{
|
||||
/** @var SplFileInfo $item */
|
||||
/** @noinspection PhpRedundantOptionalArgumentInspection */
|
||||
foreach ($DirectoryScanner($directory, True) as $item)
|
||||
{
|
||||
if (is_dir($item->getPathName()))
|
||||
continue;
|
||||
|
||||
$parsed_path = str_ireplace($package_path . DIRECTORY_SEPARATOR, '', $item->getPathName());
|
||||
|
||||
Console::outDebug(sprintf('copying file %s for package %s', $parsed_path, $package->Name));
|
||||
$filesystem->copy($item->getPathName(), $source_directory . DIRECTORY_SEPARATOR . $parsed_path);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($static_files) > 0)
|
||||
{
|
||||
$project_configuration->Project->Options['static_files'] = $static_files;
|
||||
$parsed_path = str_ireplace($package_path . DIRECTORY_SEPARATOR, '', $item->getPathName());
|
||||
if (!$filesystem->exists($source_directory . DIRECTORY_SEPARATOR . $parsed_path))
|
||||
{
|
||||
Console::outDebug(sprintf('copying file %s for package %s', $parsed_path, $package->Name));
|
||||
$filesystem->copy($item->getPathName(), $source_directory . DIRECTORY_SEPARATOR . $parsed_path);
|
||||
}
|
||||
}
|
||||
|
||||
$project_configuration->toFile($package_path . DIRECTORY_SEPARATOR . 'project.json');
|
||||
}
|
||||
// Convert it to a NCC project configuration
|
||||
$project_configuration = self::convertProject($package_path, $version_map, $composer_package);
|
||||
|
||||
// Load the project
|
||||
$project_manager = new ProjectManager($package_path);
|
||||
|
@ -238,15 +232,31 @@
|
|||
$built_package = $project_manager->build();
|
||||
|
||||
// Copy the project to the build directory
|
||||
$out_path = $base_dir . DIRECTORY_SEPARATOR . 'build' . DIRECTORY_SEPARATOR . sprintf('%s=%s.ncc', $project_configuration->Assembly->Package, $project_configuration->Assembly->Version);
|
||||
$out_path = $base_dir . DIRECTORY_SEPARATOR . 'build' . DIRECTORY_SEPARATOR . sprintf('%s.ncc', $project_configuration->Assembly->Package);
|
||||
$filesystem->copy($built_package, $out_path);
|
||||
$filesystem->remove($built_package);
|
||||
$built_packages[$project_configuration->Assembly->Package] = $out_path;
|
||||
|
||||
}
|
||||
|
||||
return $built_packages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of versions from the ComposerLock file
|
||||
*
|
||||
* @param ComposerLock $composerLock
|
||||
* @return array
|
||||
*/
|
||||
private static function getVersionMap(ComposerLock $composerLock): array
|
||||
{
|
||||
$version_map = [];
|
||||
foreach($composerLock->Packages as $package)
|
||||
{
|
||||
$version_map[$package->Name] = $package->Version;
|
||||
}
|
||||
return $version_map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a composer package name to a valid package name
|
||||
*
|
||||
|
@ -271,22 +281,33 @@
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a valid version from a version map
|
||||
*
|
||||
* @param string $package_name
|
||||
* @param array $version_map
|
||||
* @return string
|
||||
*/
|
||||
private static function versionMap(string $package_name, array $version_map): string
|
||||
{
|
||||
if (array_key_exists($package_name, $version_map))
|
||||
{
|
||||
return Functions::convertToSemVer($version_map[$package_name]);
|
||||
}
|
||||
|
||||
return '1.0.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a project configuration from a package selection
|
||||
* from the composer.lock file
|
||||
*
|
||||
* @param string $package_name
|
||||
* @param ComposerLock $composer_lock
|
||||
* @param ComposerJson $composer_package
|
||||
* @param array $version_map
|
||||
* @return ProjectConfiguration
|
||||
* @throws PackageNotFoundException
|
||||
*/
|
||||
private static function generateProjectConfiguration(string $package_name, ComposerLock $composer_lock): ProjectConfiguration
|
||||
private static function generateProjectConfiguration(ComposerJson $composer_package, array $version_map): ProjectConfiguration
|
||||
{
|
||||
// Load the composer lock file
|
||||
$composer_package = $composer_lock->getPackage($package_name);
|
||||
if ($composer_package == null)
|
||||
throw new PackageNotFoundException(sprintf('Package "%s" not found in composer lock file', $package_name));
|
||||
|
||||
// Generate a new project configuration object
|
||||
$project_configuration = new ProjectConfiguration();
|
||||
|
||||
|
@ -294,37 +315,41 @@
|
|||
$project_configuration->Assembly->Name = $composer_package->Name;
|
||||
if (isset($composer_package->Description))
|
||||
$project_configuration->Assembly->Description = $composer_package->Description;
|
||||
if (isset($composer_package->Version))
|
||||
$project_configuration->Assembly->Version = Functions::parseVersion($composer_package->Version);
|
||||
|
||||
if(isset($version_map[$composer_package->Name]))
|
||||
$project_configuration->Assembly->Version = self::versionMap($composer_package->Name, $version_map);
|
||||
if($project_configuration->Assembly->Version == null || $project_configuration->Assembly->Version == '')
|
||||
$project_configuration->Assembly->Version = '1.0.0';
|
||||
|
||||
|
||||
$project_configuration->Assembly->UUID = Uuid::v1()->toRfc4122();
|
||||
$project_configuration->Assembly->Package = self::toPackageName($package_name);
|
||||
$project_configuration->Assembly->Package = self::toPackageName($composer_package->Name);
|
||||
|
||||
// Add the update source
|
||||
$project_configuration->Project->UpdateSource = new ProjectConfiguration\UpdateSource();
|
||||
$project_configuration->Project->UpdateSource->Source = sprintf('%s@composer', str_ireplace('\\', '/', $composer_package->Name));
|
||||
$project_configuration->Project->UpdateSource->Repository = null;
|
||||
|
||||
// Process the dependencies
|
||||
foreach ($composer_package->Require as $item)
|
||||
if($composer_package->Require !== null && count($composer_package->Require) > 0)
|
||||
{
|
||||
$package_name = self::toPackageName($item->PackageName);
|
||||
$package_version = $composer_lock->getPackage($item->PackageName)?->Version;
|
||||
if ($package_version == null)
|
||||
foreach ($composer_package->Require as $item)
|
||||
{
|
||||
$package_version = '1.0.0';
|
||||
// Check if the dependency is already in the project configuration
|
||||
$package_name = self::toPackageName($item->PackageName);
|
||||
if ($package_name == null)
|
||||
continue;
|
||||
$dependency = new ProjectConfiguration\Dependency();
|
||||
$dependency->Name = $package_name;
|
||||
$dependency->SourceType = DependencySourceType::Local;
|
||||
$dependency->Version = self::versionMap($item->PackageName, $version_map);
|
||||
$dependency->Source = $package_name . '.ncc';
|
||||
$project_configuration->Build->addDependency($dependency);
|
||||
}
|
||||
else
|
||||
{
|
||||
$package_version = Functions::parseVersion($package_version);
|
||||
}
|
||||
if ($package_name == null)
|
||||
continue;
|
||||
$dependency = new ProjectConfiguration\Dependency();
|
||||
$dependency->Name = $package_name;
|
||||
$dependency->SourceType = DependencySourceType::Local;
|
||||
$dependency->Version = $package_version;
|
||||
$dependency->Source = $package_name . '=' . $dependency->Version . '.ncc';
|
||||
$project_configuration->Build->Dependencies[] = $dependency;
|
||||
}
|
||||
|
||||
// Create a build configuration
|
||||
$build_configuration = new ProjectConfiguration\BuildConfiguration();
|
||||
$build_configuration = new ProjectConfiguration\Build\BuildConfiguration();
|
||||
$build_configuration->Name = 'default';
|
||||
$build_configuration->OutputPath = 'build';
|
||||
|
||||
|
@ -341,22 +366,6 @@
|
|||
return $project_configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts a version if available from the input
|
||||
*
|
||||
* @param string $input
|
||||
* @return string|null
|
||||
*/
|
||||
private static function extractVersion(string $input): ?string
|
||||
{
|
||||
if (stripos($input, ':'))
|
||||
{
|
||||
return explode(':', $input)[1];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the applicable options configured for composer
|
||||
*
|
||||
|
@ -437,7 +446,6 @@
|
|||
* @param string $vendor
|
||||
* @param string $package
|
||||
* @param string|null $version
|
||||
* @param array $options
|
||||
* @return string
|
||||
* @throws AccessDeniedException
|
||||
* @throws ComposerDisabledException
|
||||
|
@ -449,13 +457,15 @@
|
|||
* @throws InvalidScopeException
|
||||
* @throws UserAbortedOperationException
|
||||
*/
|
||||
private static function require(string $vendor, string $package, ?string $version = null, array $options = []): string
|
||||
private static function require(string $vendor, string $package, ?string $version = null): string
|
||||
{
|
||||
if (Resolver::resolveScope() !== Scopes::System)
|
||||
throw new AccessDeniedException('Insufficient permissions to require');
|
||||
|
||||
if ($version == null)
|
||||
$version = '*';
|
||||
if($version == 'latest')
|
||||
$version = '*';
|
||||
|
||||
$tpl_file = __DIR__ . DIRECTORY_SEPARATOR . 'composer.jtpl';
|
||||
if (!file_exists($tpl_file))
|
||||
|
@ -482,29 +492,11 @@
|
|||
// Execute composer with options
|
||||
$options = self::getOptions();
|
||||
$process = new Process(array_merge([$composer_exec, 'require'], $options));
|
||||
$process->setWorkingDirectory($tmp_dir);
|
||||
|
||||
// Check if scripts are enabled while running as root
|
||||
if (!in_array('--no-scripts', $options) && Resolver::resolveScope() == Scopes::System)
|
||||
{
|
||||
Console::outWarning('composer scripts are enabled while running as root, this can allow malicious scripts to run as root');
|
||||
if (!isset($options['--no-interaction']))
|
||||
{
|
||||
if (!Console::getBooleanInput('Do you want to continue?'))
|
||||
throw new UserAbortedOperationException('The operation was aborted by the user');
|
||||
|
||||
// The user understands the risks and wants to continue
|
||||
$process->setEnv(['COMPOSER_ALLOW_SUPERUSER' => 1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Composer is running "safely". We can disable the superuser check
|
||||
$process->setEnv(['COMPOSER_ALLOW_SUPERUSER' => 1]);
|
||||
}
|
||||
self::prepareProcess($process, $tmp_dir, $options);
|
||||
|
||||
Console::outDebug(sprintf('executing %s', $process->getCommandLine()));
|
||||
$process->run(function ($type, $buffer) {
|
||||
$process->run(function ($type, $buffer)
|
||||
{
|
||||
Console::out($buffer, false);
|
||||
});
|
||||
|
||||
|
@ -558,4 +550,206 @@
|
|||
|
||||
throw new ComposerNotAvailableException('No composer executable path is configured');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Process $process
|
||||
* @param string $path
|
||||
* @param array $options
|
||||
* @return void
|
||||
* @throws UserAbortedOperationException
|
||||
*/
|
||||
private static function prepareProcess(Process $process, string $path, array $options): void
|
||||
{
|
||||
$process->setWorkingDirectory($path);
|
||||
|
||||
// Check if scripts are enabled while running as root
|
||||
if (!in_array('--no-scripts', $options) && Resolver::resolveScope() == Scopes::System)
|
||||
{
|
||||
Console::outWarning('composer scripts are enabled while running as root, this can allow malicious scripts to run as root');
|
||||
if (!isset($options['--no-interaction']))
|
||||
{
|
||||
if (!Console::getBooleanInput('Do you want to continue?'))
|
||||
throw new UserAbortedOperationException('The operation was aborted by the user');
|
||||
|
||||
// The user understands the risks and wants to continue
|
||||
$process->setEnv(['COMPOSER_ALLOW_SUPERUSER' => 1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Composer is running "safely". We can disable the superuser check
|
||||
$process->setEnv(['COMPOSER_ALLOW_SUPERUSER' => 1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a composer project to a NCC project
|
||||
*
|
||||
* @param string $package_path
|
||||
* @param array $version_map
|
||||
* @param mixed $composer_package
|
||||
* @return ProjectConfiguration
|
||||
* @throws AccessDeniedException
|
||||
* @throws FileNotFoundException
|
||||
* @throws IOException
|
||||
* @throws MalformedJsonException
|
||||
* @throws PackagePreparationFailedException
|
||||
*/
|
||||
private static function convertProject(string $package_path, array $version_map, ?ComposerJson $composer_package=null): ProjectConfiguration
|
||||
{
|
||||
if($composer_package == null)
|
||||
$composer_package = ComposerJson::fromArray(Functions::loadJsonFile($package_path . DIRECTORY_SEPARATOR . 'composer.json', Functions::FORCE_ARRAY));
|
||||
|
||||
$project_configuration = ComposerSourceBuiltin::generateProjectConfiguration($composer_package, $version_map);
|
||||
$filesystem = new Filesystem();
|
||||
|
||||
// Process the source files
|
||||
if ($composer_package->Autoload !== null)
|
||||
{
|
||||
$source_directory = $package_path . DIRECTORY_SEPARATOR . '.src';
|
||||
if ($filesystem->exists($source_directory))
|
||||
$filesystem->remove($source_directory);
|
||||
$filesystem->mkdir($source_directory);
|
||||
$source_directories = [];
|
||||
$static_files = [];
|
||||
|
||||
// Extract all the source directories
|
||||
if ($composer_package->Autoload->Psr4 !== null && count($composer_package->Autoload->Psr4) > 0)
|
||||
{
|
||||
Console::outVerbose('Extracting PSR-4 source directories');
|
||||
foreach ($composer_package->Autoload->Psr4 as $namespace_pointer)
|
||||
{
|
||||
if ($namespace_pointer->Path !== null && !in_array($namespace_pointer->Path, $source_directories))
|
||||
{
|
||||
$source_directories[] = $package_path . DIRECTORY_SEPARATOR . $namespace_pointer->Path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($composer_package->Autoload->Psr0 !== null && count($composer_package->Autoload->Psr0) > 0)
|
||||
{
|
||||
Console::outVerbose('Extracting PSR-0 source directories');
|
||||
foreach ($composer_package->Autoload->Psr0 as $namespace_pointer)
|
||||
{
|
||||
if ($namespace_pointer->Path !== null && !in_array($namespace_pointer->Path, $source_directories))
|
||||
{
|
||||
$source_directories[] = $package_path . DIRECTORY_SEPARATOR . $namespace_pointer->Path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($composer_package->Autoload->Files !== null && count($composer_package->Autoload->Files) > 0)
|
||||
{
|
||||
Console::outVerbose('Extracting static files');
|
||||
foreach ($composer_package->Autoload->Files as $file)
|
||||
{
|
||||
$static_files[] = $package_path . DIRECTORY_SEPARATOR . $file;
|
||||
}
|
||||
}
|
||||
|
||||
Console::outDebug(sprintf('source directories: %s', implode(', ', $source_directories)));
|
||||
|
||||
// First scan the project files and create a file struct.
|
||||
$DirectoryScanner = new DirectoryScanner();
|
||||
|
||||
// TODO: Implement exclude-class handling
|
||||
try
|
||||
{
|
||||
$DirectoryScanner->unsetFlag(FilesystemIterator::FOLLOW_SYMLINKS);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new PackagePreparationFailedException('Cannot unset flag \'FOLLOW_SYMLINKS\' in DirectoryScanner, ' . $e->getMessage(), $e);
|
||||
}
|
||||
|
||||
// Include file components that can be compiled
|
||||
$DirectoryScanner->setIncludes(ComponentFileExtensions::Php);
|
||||
|
||||
foreach ($source_directories as $directory)
|
||||
{
|
||||
/** @var SplFileInfo $item */
|
||||
/** @noinspection PhpRedundantOptionalArgumentInspection */
|
||||
foreach ($DirectoryScanner($directory, True) as $item)
|
||||
{
|
||||
if (is_dir($item->getPathName()))
|
||||
continue;
|
||||
|
||||
$parsed_path = str_ireplace($package_path . DIRECTORY_SEPARATOR, '', $item->getPathName());
|
||||
|
||||
Console::outDebug(sprintf('copying file %s for package %s', $parsed_path, $composer_package->Name));
|
||||
$filesystem->copy($item->getPathName(), $source_directory . DIRECTORY_SEPARATOR . $parsed_path);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($static_files) > 0)
|
||||
{
|
||||
$project_configuration->Project->Options['static_files'] = $static_files;
|
||||
|
||||
foreach ($static_files as $file)
|
||||
{
|
||||
$parsed_path = str_ireplace($package_path . DIRECTORY_SEPARATOR, '', $file);
|
||||
Console::outDebug(sprintf('copying file %s for package %s', $parsed_path, $composer_package->Name));
|
||||
$filesystem->copy($file, $source_directory . DIRECTORY_SEPARATOR . $parsed_path);
|
||||
}
|
||||
unset($file);
|
||||
}
|
||||
}
|
||||
|
||||
$project_configuration->toFile($package_path . DIRECTORY_SEPARATOR . 'project.json');
|
||||
|
||||
// This part simply displays the package information to the command-line interface
|
||||
if(ncc::cliMode())
|
||||
{
|
||||
$license_files = [
|
||||
'LICENSE',
|
||||
'license',
|
||||
'LICENSE.txt',
|
||||
'license.txt'
|
||||
];
|
||||
|
||||
foreach($license_files as $license_file)
|
||||
{
|
||||
if($filesystem->exists($package_path . DIRECTORY_SEPARATOR . $license_file))
|
||||
{
|
||||
// Check configuration if composer.extension.display_licenses is set
|
||||
if(Functions::cbool(Functions::getConfigurationProperty('composer.extension.display_licenses')))
|
||||
{
|
||||
Console::out(sprintf('License for package %s:', $composer_package->Name));
|
||||
Console::out(IO::fread($package_path . DIRECTORY_SEPARATOR . $license_file));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Functions::cbool(Functions::getConfigurationProperty('composer.extension.display_authors')))
|
||||
{
|
||||
if($composer_package->Authors !== null && count($composer_package->Authors) > 0)
|
||||
{
|
||||
Console::out(sprintf('Authors for package %s:', $composer_package->Name));
|
||||
foreach($composer_package->Authors as $author)
|
||||
{
|
||||
Console::out(sprintf(' - %s', $author->Name));
|
||||
|
||||
if($author->Email !== null)
|
||||
{
|
||||
Console::out(sprintf(' %s', $author->Email));
|
||||
}
|
||||
|
||||
if($author->Homepage !== null)
|
||||
{
|
||||
Console::out(sprintf(' %s', $author->Homepage));
|
||||
}
|
||||
|
||||
if($author->Role !== null)
|
||||
{
|
||||
Console::out(sprintf(' %s', $author->Role));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $project_configuration;
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ncc\Classes;
|
||||
|
||||
use ncc\Objects\PhpConfiguration;
|
||||
|
||||
class EnvironmentConfiguration
|
||||
{
|
||||
/**
|
||||
* Returns an array of all the current configuration values set in this environment
|
||||
*
|
||||
* @return PhpConfiguration[]
|
||||
*/
|
||||
public static function getCurrentConfiguration(): array
|
||||
{
|
||||
$results = [];
|
||||
|
||||
foreach(ini_get_all() as $name => $config)
|
||||
{
|
||||
$results[$name] = PhpConfiguration::fromArray($config);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of only the changed configuration values
|
||||
*
|
||||
* @return PhpConfiguration[]
|
||||
*/
|
||||
public static function getChangedValues(): array
|
||||
{
|
||||
$results = [];
|
||||
|
||||
foreach(ini_get_all() as $name => $config)
|
||||
{
|
||||
$config = PhpConfiguration::fromArray($config);
|
||||
if($config->LocalValue !== $config->GlobalValue)
|
||||
{
|
||||
$results[$name] = $config;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file_path
|
||||
* @return void
|
||||
*/
|
||||
public static function export(string $file_path)
|
||||
{
|
||||
$configuration = [];
|
||||
foreach(self::getChangedValues() as $changedValue)
|
||||
{
|
||||
$configuration[$changedValue->getName()] = $changedValue->getValue();
|
||||
}
|
||||
|
||||
// TODO: Implement ini writing process here
|
||||
}
|
||||
|
||||
public static function import(string $file_path)
|
||||
{
|
||||
// TODO: Implement ini reading process here
|
||||
$configuration = [];
|
||||
foreach($configuration as $item => $value)
|
||||
{
|
||||
ini_set($item, $value);
|
||||
}
|
||||
}
|
||||
}
|
132
src/ncc/Classes/GitClient.php
Normal file
132
src/ncc/Classes/GitClient.php
Normal file
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* 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 NON-INFRINGEMENT. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace ncc\Classes;
|
||||
|
||||
use ncc\Exceptions\GitCheckoutException;
|
||||
use ncc\Exceptions\GitCloneException;
|
||||
use ncc\Exceptions\GitTagsException;
|
||||
use ncc\Exceptions\InvalidScopeException;
|
||||
use ncc\ThirdParty\Symfony\Process\Process;
|
||||
use ncc\Utilities\Console;
|
||||
use ncc\Utilities\Functions;
|
||||
|
||||
class GitClient
|
||||
{
|
||||
/**
|
||||
* Clones a remote repository to a temporary directory.
|
||||
*
|
||||
* @param string $url
|
||||
* @return string
|
||||
* @throws GitCloneException
|
||||
* @throws InvalidScopeException
|
||||
*/
|
||||
public static function cloneRepository(string $url): string
|
||||
{
|
||||
Console::outVerbose('Cloning repository: ' . $url);
|
||||
$path = Functions::getTmpDir();
|
||||
$process = new Process(["git", "clone", $url, $path]);
|
||||
$process->setTimeout(3600); // 1 hour
|
||||
$process->run(function ($type, $buffer)
|
||||
{
|
||||
Console::outVerbose($buffer);
|
||||
});
|
||||
|
||||
if (!$process->isSuccessful())
|
||||
throw new GitCloneException($process->getErrorOutput());
|
||||
|
||||
Console::outVerbose('Repository cloned to: ' . $path);
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks out a specific branch or tag.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $branch
|
||||
* @throws GitCheckoutException
|
||||
*/
|
||||
public static function checkout(string $path, string $branch): void
|
||||
{
|
||||
Console::outVerbose('Checking out branch' . $branch);
|
||||
$process = new Process(["git", "checkout", $branch], $path);
|
||||
$process->setTimeout(3600); // 1 hour
|
||||
$process->run(function ($type, $buffer)
|
||||
{
|
||||
if (Process::ERR === $type)
|
||||
{
|
||||
Console::outWarning($buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console::outVerbose($buffer);
|
||||
}
|
||||
});
|
||||
|
||||
if (!$process->isSuccessful())
|
||||
throw new GitCheckoutException($process->getErrorOutput());
|
||||
|
||||
Console::outVerbose('Checked out branch: ' . $branch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of tags that are available in the repository.
|
||||
*
|
||||
* @param string $path
|
||||
* @return array
|
||||
* @throws GitTagsException
|
||||
*/
|
||||
public static function getTags(string $path): array
|
||||
{
|
||||
Console::outVerbose('Getting tags for repository: ' . $path);
|
||||
$process = new Process(["git", "fetch", '--all', '--tags'] , $path);
|
||||
$process->setTimeout(3600); // 1 hour
|
||||
$process->run(function ($type, $buffer)
|
||||
{
|
||||
Console::outVerbose($buffer);
|
||||
});
|
||||
|
||||
if (!$process->isSuccessful())
|
||||
throw new GitTagsException($process->getErrorOutput());
|
||||
|
||||
$process = new Process(['git', '--no-pager', 'tag', '-l'] , $path);
|
||||
|
||||
$process->run(function ($type, $buffer)
|
||||
{
|
||||
Console::outVerbose($buffer);
|
||||
});
|
||||
|
||||
if (!$process->isSuccessful())
|
||||
throw new GitTagsException($process->getErrorOutput());
|
||||
|
||||
$tags = explode(PHP_EOL, $process->getOutput());
|
||||
$tags = array_filter($tags, function ($tag)
|
||||
{
|
||||
return !empty($tag);
|
||||
});
|
||||
|
||||
Console::outDebug('found ' . count($tags) . ' tags');
|
||||
return array_filter($tags);
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue