Compare commits

...
Sign in to create a new pull request.

213 commits

Author SHA1 Message Date
Netkas
018918b4e9 Updated .gitlab-ci.yml 2023-01-29 18:22:47 -05:00
Netkas
de83f53a2d Code Refactoring 2023-01-29 17:22:24 -05:00
Netkas
4e0ce1fdb8 Updated PackageManager 2023-01-29 17:03:23 -05:00
Netkas
209d15acbe Updated HelpMenu 2023-01-29 16:59:25 -05:00
Netkas
15b723401b Updated DOCUMENTATION.md 2023-01-29 16:28:51 -05:00
Netkas
6c5168cdd6 Added missing files 2023-01-29 15:31:47 -05:00
Netkas
74b356867f Added documentation regarding installer 2023-01-29 15:30:49 -05:00
Netkas
4484200bb7 Added documentation regarding ExecutionPolicies & Runners 2023-01-29 15:27:43 -05:00
Netkas
29e2ba1594 Updated DOCUMENTATION.md 2023-01-29 15:00:08 -05:00
Netkas
ccfacbf296 Updated DOCUMENTATION.md 2023-01-29 14:59:48 -05:00
Netkas
ba580994f5 Updated HelpMenu 2023-01-29 14:58:58 -05:00
Netkas
bb8d8683c0 Updated \ncc\CLI\Management > CredentialMenu to use '--no-encryption' argument instead of '--encrypt' 2023-01-29 14:46:27 -05:00
Netkas
813860fef6 Added copyright 2023-01-29 14:41:05 -05:00
Netkas
625a4184d8 Updated \ncc\CLI > Main 2023-01-29 13:38:02 -05:00
Netkas
b5cc0d4b70 Updated \ncc\CLI > HelpMenu 2023-01-29 13:36:05 -05:00
Netkas
0548faa7d0 Updated Intellij Idea scopes 2023-01-29 13:32:34 -05:00
Netkas
2bd04cc481 Cleaned up abstract classes 2023-01-29 13:23:07 -05:00
Netkas
3a4e7413b6 Updated Makefile 2023-01-29 02:30:49 -05:00
Netkas
0975aaf88a Added error codes in DOCUMENTATION.md 2023-01-29 02:24:12 -05:00
Netkas
10cd70ff79 Refactored Exceptions 2023-01-29 01:28:06 -05:00
Netkas
893166ebf8 Updated ExceptionCodes 2023-01-29 01:11:23 -05:00
Netkas
f2d2839d0e Added SymlinkException 2023-01-29 01:11:14 -05:00
Netkas
f6bc814187 Minor changes 2023-01-29 00:31:10 -05:00
Netkas
f24d8611bf Deleted unused dependency 2023-01-28 10:55:03 -05:00
Netkas
cd3d5847ce Updated LICENSE 2023-01-28 10:21:11 -05:00
Netkas
5556c03402 Added documentation for assembly, versioning & UUIDs in DOCUMENTATION.md
https://git.n64.cc/nosial/ncc/-/issues/35
2023-01-28 09:38:49 -05:00
Netkas
546e6e03a9 Added TOC in DOCUMENTATION.md
https://git.n64.cc/nosial/ncc/-/issues/35
2023-01-28 09:06:00 -05:00
Netkas
5f951d35fd Added documentation for credentials in DOCUMENTATION.md
https://git.n64.cc/nosial/ncc/-/issues/35
2023-01-28 09:05:29 -05:00
Netkas
0be4224364 Added documentation for remote sources in DOCUMENTATION.md
https://git.n64.cc/nosial/ncc/-/issues/35
2023-01-28 08:44:02 -05:00
Netkas
02963ee853 Updated uninstallation section in DOCUMENTATION.md 2023-01-28 07:36:06 -05:00
Netkas
b530376af4 Reformatted DOCUMENTATION.md 2023-01-28 07:35:03 -05:00
Netkas
d65795fcb5 Refactored documentation into DOCUMENTATION.md 2023-01-28 07:10:22 -05:00
Netkas
bf73360f2c Implemented Symlinks 2023-01-28 06:21:20 -05:00
Netkas
a5c1124b6b Removed unused method getUnit() in \ncc\Managers > ExecutionPointerManager 2023-01-27 04:50:45 -05:00
Netkas
2f711bb509 Various improvements here and there, mostly regarding ExecutionUnits 2023-01-27 04:38:26 -05:00
Netkas
e0262ab134 Changed job names 2023-01-21 10:06:12 -05:00
Netkas
ab620886c0 Seperated build & release jobs in .gitlab-ci.yml 2023-01-21 10:05:36 -05:00
Netkas
417603e09d Minor change 2023-01-21 10:01:16 -05:00
Netkas
9cd424ec5b Removed 'test' from .gitlab-ci.yml and corrected artifact path 2023-01-21 09:59:26 -05:00
Netkas
39bba1b532 Updated Makefile 2023-01-21 09:56:35 -05:00
Netkas
eda127da48 Okay fine asshole, I'll use gpg 2023-01-21 09:54:20 -05:00
Netkas
ec7e7a31ca Minor changes, removed the use of 'sudo' & changed build archive name from ncc.tar.gz to build.tar.gz 2023-01-21 09:53:05 -05:00
Netkas
d34d857a84 Commented out gpg for now 2023-01-21 09:51:30 -05:00
Netkas
2cc0d6f582 Added 'wget' to .gitlab-ci.yml 2023-01-21 09:49:43 -05:00
Netkas
0b79f5598a Updated README.md to include information about mirrors 2023-01-21 09:45:18 -05:00
Netkas
ee99d4d465 Lol 2023-01-21 06:29:45 -05:00
Netkas
b8e4fe80af Updated Makefile 2023-01-21 06:28:30 -05:00
Netkas
e89a71da2f Added .gitlab-ci.yaml (Experimental) 2023-01-21 06:28:02 -05:00
Netkas
b51b7203e0 Added 'sdc' command to \ncc\CLI\Management > PackageManagerMenu to allow for semi-decompiling packages for debugging purposes. 2023-01-18 16:33:48 -05:00
Netkas
b62bb725cc Typo correction in \ncc\Utilities > PathFinder > getRemoteSource() 2023-01-12 16:19:23 -05:00
Netkas
b8f508d326 Typo Correction in \ncc\CLI\Management > ConfigMenu > start() 2023-01-12 16:15:33 -05:00
Netkas
5beb06abda Added basic syntax highlighting and performance tick indicators 2023-01-12 15:57:10 -05:00
Netkas
272c3b9d94 Added handler for arrays in \ncc\Classes\NccExtension > PackageCompiler > compilePackageConstants() 2023-01-12 15:00:39 -05:00
Netkas
63560ba64b Updated method \ncc\Manager > PackageManager > processDependency() to only throw an error regarding the dependency not being met if it is not met. 2023-01-12 15:00:10 -05:00
Netkas
2d7e71be84 Removed unused import statements 2023-01-11 19:55:47 -05:00
Netkas
ffcae1b8a0 Various changes, added more functions for executing packages (not finished) & updated documentation/project files. 2023-01-11 19:55:19 -05:00
Netkas
c08bc485a5 Updated Default Values 2023-01-08 16:10:17 -05:00
Netkas
0010a7257c Added Runtime Constant compiler 2023-01-07 02:49:40 -05:00
Netkas
bb0eb22f26 Added public methods get_constant() and set_constant() in extension 2023-01-07 02:48:08 -05:00
Netkas
334c40c1f3 Improved Import function in \ncc\Classes\PhpExtension > PhpRuntime > import() 2023-01-07 02:47:49 -05:00
Netkas
45cac3ec75 Added methods getConstant() and setConstant() in \ncc\Runtime 2023-01-07 02:47:27 -05:00
Netkas
5d9f02512f Added Logging calls to \ncc\Managers > PackageManager 2023-01-02 19:57:28 -05:00
Netkas
a995732ff7 Improved logging in \ncc\Classes > GitClient 2023-01-02 19:50:19 -05:00
Netkas
0281ba2af4 Added Logging calls to \ncc\Managers > PackageLockManager 2023-01-02 19:46:15 -05:00
Netkas
e878ce4ff9 Added Logging calls to \ncc\Managers > ExecutionPointerManager 2023-01-02 19:42:40 -05:00
Netkas
c2b7b31802 Oops. 2023-01-02 16:56:26 -05:00
Netkas
59277226b9 Added dependency php-parallel-lint\php-console-color 2023-01-02 16:54:29 -05:00
Netkas
3055547452 Deleted LICENSES since all the same licenses are already present in the project source. 2023-01-02 16:49:15 -05:00
Netkas
f311e60e8f Added Logging calls to \ncc\Managers > CredentialManager 2023-01-02 16:21:33 -05:00
Netkas
7c2735ce1b Added Logging calls to \ncc\Managers > ConfigurationManager 2023-01-02 16:21:33 -05:00
Netkas
39d98f8ff3 Updated README.md 2022-12-31 09:07:19 -05:00
Netkas
3dcc5ee989 Updated changelog 2022-12-31 09:07:12 -05:00
Netkas
4f5c706dd9 Added CONTRIBUTING.md 2022-12-31 09:00:21 -05:00
Netkas
f0946c6827 Added CODE_OF_CONDUCT.md 2022-12-31 09:00:14 -05:00
Netkas
17b5a73b65 Added property 'CreateSymlink' to \ncc\Objects\ProjectConfiguration > Build 2022-12-31 08:53:14 -05:00
Netkas
b3a75958e2 Moved BuildConfiguration 2022-12-31 06:17:24 -05:00
Netkas
7db78a51ae Updated \ncc\Classes\PhpExtension > PhpCompiler > prepare so that the libs folder is only created when it's being written to. 2022-12-23 03:43:34 -05:00
Netkas
b06661f595 Updated \ncc\Managers > PackageManager 2022-12-23 01:27:58 -05:00
Netkas
233d5ce6d2 Implemented DataPaths for packages 2022-12-23 01:27:30 -05:00
Netkas
8557c33b4a Minor correction in \ncc\CLI\Management > PackageManagerMenu > installPackage() where $require_dependencies is not always set. 2022-12-23 01:27:11 -05:00
Netkas
fa31416932 Added a shutdown task to finalize permissions for some directories that could be made un-writable after certain operations. 2022-12-22 17:32:15 -05:00
Netkas
c0db3ac4c6 Updated method \ncc\Managers > PackageManager > getPackageTree() 2022-12-22 13:01:25 -05:00
Netkas
1b5991425d Updated \ncc\Objects > PackageLock > addPackage()
https://git.n64.cc/nosial/ncc/-/issues/41
2022-12-20 15:00:03 -05:00
Netkas
8ff91590d2 Updated configuration manager to not use hard-coded configuration values (there's no way I'm hard-coding every single configuration value and checking their correct type.) 2022-12-19 18:59:02 -05:00
Netkas
7ffbdf72c1 Added Data path for packages 2022-12-19 18:41:10 -05:00
Netkas
558c0a3212 Updated method \ncc\CLI\Management > PackageManagerMenu > displayOptions() 2022-12-19 16:51:08 -05:00
Netkas
b39d0469cc Some bug fixes, added options --reinstall & --skip-dependencies for the ncc package install command. 2022-12-19 16:42:48 -05:00
Netkas
dc4ad1d08d Moved RuntimeImportOptions to \ncc\Abstracts > Options 2022-12-19 16:20:59 -05:00
Netkas
50042a244d Added check in \ncc\Managers > PackageManager > uninstallPackageVersion() 2022-12-19 00:57:31 -05:00
Netkas
856db39f9a Updated method in \ncc\Objects\Project > Project > fromArray() to invoke toArray() on UpdateSource if it's not null. 2022-12-18 17:01:29 -05:00
Netkas
a25f1e0c2a Added custom repository gitgud.io 2022-12-18 03:05:13 -05:00
Netkas
cada094371 Updated custom_repositories.json 2022-12-18 03:01:07 -05:00
Netkas
0099a86168 Refactored \ncc\CLI 2022-12-18 02:29:56 -05:00
Netkas
a1014eb2a5 Improved exception handling in \ncc\Managers > PackageManager > FetchFromSource() 2022-12-18 02:11:01 -05:00
Netkas
dd8d40989e Updated \ncc\Abstracts > ExceptionCodes
https://git.n64.cc/nosial/ncc/-/issues/4
2022-12-18 00:24:48 -05:00
Netkas
79cec40f23 Added \ncc\Exceptions > InvalidBuildConfigurationException
https://git.n64.cc/nosial/ncc/-/issues/4
2022-12-18 00:24:28 -05:00
Netkas
67391c0bde Added \ncc\Exceptions > InvalidDependencyConfiguration
https://git.n64.cc/nosial/ncc/-/issues/4
2022-12-18 00:24:12 -05:00
Netkas
10237159f2 Updated method \ncc\Objects\ProjectConfiguration > Build > validate()
https://git.n64.cc/nosial/ncc/-/issues/4
2022-12-18 00:22:45 -05:00
Netkas
4f30d343e5 Added method \ncc\Utilities > Validate > pathName()
https://git.n64.cc/nosial/ncc/-/issues/4
2022-12-18 00:12:45 -05:00
Netkas
f75625633c Added method \ncc\Objects\ProjectConfiguration > BuildConfiguration > validate()
https://git.n64.cc/nosial/ncc/-/issues/4
2022-12-17 09:52:33 -05:00
Netkas
405f53673a Added method \ncc\Objects\ProjectConfiguration > Dependency > validate()
https://git.n64.cc/nosial/ncc/-/issues/4
2022-12-17 09:50:34 -05:00
Netkas
a3c3322f28 Added method \ncc\Utilities > Validate > nameFriendly()
https://git.n64.cc/nosial/ncc/-/issues/4
2022-12-17 09:38:54 -05:00
Netkas
46f6cbba70 Minor correction in Runtime.php 2022-12-17 09:26:33 -05:00
Netkas
cc01051e73 Updated string 2022-12-17 08:32:35 -05:00
Netkas
24077691bb Bug fix: Duplicate dependencies 2022-12-17 08:29:41 -05:00
Netkas
570b21ca3d Updated method \ncc\Classes\NccExtension > PackageCompiler > tryCompile() to apply the correct version to the target package if a version is specified. 2022-12-17 08:21:56 -05:00
Netkas
61146d1b1d Bug Fixes Part 3
Also included refactoring of the current Remote repository system to make the codebase easier to maintain
2022-12-17 06:59:14 -05:00
Netkas
722c99879e Bug Fixes Part 2 2022-12-17 00:57:07 -05:00
Netkas
06e876bc03 Bug Fixes Part 1 2022-12-16 12:20:45 -05:00
Netkas
f41a3a6351 Improved exception display 2022-12-16 03:08:04 -05:00
Netkas
4bd8a0f017 Minor change 2022-12-16 01:49:33 -05:00
Netkas
aec5dea17c Cleanup 2022-12-16 01:48:59 -05:00
Netkas
a59c7c4a8d Added Credential passthrough 2022-12-16 01:48:16 -05:00
Netkas
b0d6654e95 Implemented remote source resolving and install handling
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-16 01:44:53 -05:00
Netkas
e1bb4cf92e Added \ncc\Classes\GitlabExtension > GitlabService
https://git.n64.cc/nosial/ncc/-/issues/24
2022-12-16 01:16:09 -05:00
Netkas
150ff9dee3 Refactored \ncc\Classes\ComposerExtension > ComposerSourceBuiltin to allow for building from local packages 2022-12-16 01:15:12 -05:00
Netkas
fecc7e0465 Updated \ncc\Objects > DefinedRemoteSource
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-16 00:41:09 -05:00
Netkas
75aacc62fa Added method \ncc\Resolvers > detectProjectType()
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-16 00:40:35 -05:00
Netkas
0da410ad31 Added method \ncc\Utilities > Functions > downloadGitServiceFile()
Added method \ncc\Utilities > Functions > prepareGitServiceRequest()

https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-16 00:40:13 -05:00
Netkas
2b78bdd959 Added \ncc\Objects > ProjectDetectionResults
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-16 00:39:05 -05:00
Netkas
03a7caa620 Added GitClient to \ncc\Classes
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-16 00:38:46 -05:00
Netkas
c904a17225 Moved HttpClient to \ncc\Classes 2022-12-16 00:38:19 -05:00
Netkas
ff04349ae4 Added method \ncc\Classes\NccExtension > PackageCompiler > tryCompile() 2022-12-16 00:38:04 -05:00
Netkas
847128cdc1 Added \ncc\Exceptions > UnsupportedProjectTypeException
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-16 00:37:43 -05:00
Netkas
6a37c8216d Added ProjectType to \ncc\Abstracts 2022-12-16 00:37:06 -05:00
Netkas
9003222d51 Added class \ncc\Classes\GithubExtension > GithubService
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-16 00:36:48 -05:00
Netkas
344454e8c4 Updated method \ncc\Utilities > HttpClient > displayProgress() 2022-12-16 00:21:26 -05:00
Netkas
7099b02514 Removed nocturn9x.json for now, gitea support intended in the future. 2022-12-16 00:03:57 -05:00
Netkas
d1367ad05d Added Default Repositories 2022-12-15 22:28:28 -05:00
Netkas
134c26452a Updated installer to automatically install pre-defined remote repositories 2022-12-15 22:25:34 -05:00
Netkas
815637cf3e Updated Makefile 2022-12-15 22:16:33 -05:00
Netkas
cadfd39836 Updated \ncc\Abstracts > ExceptionCodes 2022-12-15 21:21:16 -05:00
Netkas
a86140d8a9 Added exception \ncc\Exceptions > AuthenticationException
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-15 21:21:01 -05:00
Netkas
7b031af53d Added exception \ncc\Exceptions > GithubServiceException
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-15 21:20:49 -05:00
Netkas
623155d96e Added exception \ncc\Exceptions > GitTagsException
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-15 21:20:33 -05:00
Netkas
23b5ddfa1f Added exception \ncc\Exceptions > NotSupportedException 2022-12-15 21:20:00 -05:00
Netkas
d154aa02ca Updated \ncc\Abstracts > DefinedRemoteSourceType
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-15 21:19:33 -05:00
Netkas
eab6c2765f Minor correction 2022-12-15 21:17:07 -05:00
Netkas
3a6d008a17 Added support for 8.2 2022-12-15 21:15:12 -05:00
Netkas
35fd169123 Updated \ncc\Managers > PackageManager to allow installations from sources to be possible and added the ability to add new remote sources from packages.
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-15 21:08:51 -05:00
Netkas
eca1a3a666 Added auto-update for UpdateSource 2022-12-15 20:51:53 -05:00
Netkas
3e43df48ac Added UpdateSource to \ncc\Objects\PackageLock > PackageEntry 2022-12-15 20:47:23 -05:00
Netkas
698adff3b5 Added method \ncc\Utilities > Functions > prepareGitServiceRequest()
https://git.n64.cc/nosial/ncc/-/issues/34
2022-12-15 18:32:18 -05:00
Netkas
03b02774b6 Refactored HttpClient to support the ability to download files to disk. 2022-12-15 18:16:44 -05:00
Netkas
bfbd7b4828 Updated interface \ncc\Interfaces > RepositorySourceInterface
https://git.n64.cc/nosial/ncc/-/issues/34
2022-12-15 17:59:55 -05:00
Netkas
259620079e Implemented HttpResponse cache to reduce hitting rate-limits for redundant requests (plus it makes requests faster) 2022-12-15 17:49:09 -05:00
Netkas
fa8301710f Added method \ncc\Objects > HttpRequest > requestHash() 2022-12-15 17:48:20 -05:00
Netkas
6d35e42106 Added \ncc\Objects > HttpResponseCache 2022-12-15 17:48:03 -05:00
Netkas
54b733caf7 Added \ncc\Objects\UpdateSource > Repository
https://git.n64.cc/nosial/ncc/-/issues/34
2022-12-15 15:25:40 -05:00
Netkas
8e8c1dca58 Added optional UpdateSource to \ncc\Objects\Package > Header
https://git.n64.cc/nosial/ncc/-/issues/34
2022-12-15 15:25:31 -05:00
Netkas
57cf2dbca3 Updated Makefile 2022-12-15 01:31:34 -05:00
Netkas
b4acfaa0cb Implemented \ncc\Objects\ProjectConfiguration > updateSource
https://git.n64.cc/nosial/ncc/-/issues/34
2022-12-15 01:28:41 -05:00
Netkas
3757c970a5 Updated \ncc\Objects\ProjectConfiguration > Project
https://git.n64.cc/nosial/ncc/-/issues/34
2022-12-15 01:28:31 -05:00
Netkas
b670d6b8e9 Added method \ncc\Utilities > Resolver > detectRemoteSourceType()
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-15 01:07:23 -05:00
Netkas
b9252a0fda Added \ncc\Interfaces > RuntimeInterface
https://git.n64.cc/nosial/ncc/-/issues/33
2022-12-15 01:06:43 -05:00
Netkas
c77c7fcd55 Added \ncc\Classes\PhpExtension > PhpRuntime to import PHP packages
https://git.n64.cc/nosial/ncc/-/issues/33
2022-12-15 01:06:23 -05:00
Netkas
d237218562 Added \ncc\Abstracts > RuntimeImportOptions
https://git.n64.cc/nosial/ncc/-/issues/33
2022-12-15 01:05:53 -05:00
Netkas
223ae9189b Added \ncc\Abstracts > RemoteSourceType
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-15 01:05:11 -05:00
Netkas
a21ea606d9 Renamed RemoteSourceInterface.php to ServiceSourceInterface.php
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-15 01:04:52 -05:00
Netkas
31ae2fcddd Added RepositorySourceInterface.php
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-15 01:04:26 -05:00
Netkas
47f58aa50e Added RemoteResourcesManager to \ncc\Managers
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-15 01:04:13 -05:00
Netkas
13e3834fc7 Implemented the ability to install from a remote source in \ncc\Managers > PackageManager
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-15 01:04:13 -05:00
Netkas
1f64a39f33 Implemented \ncc\Runtime
https://git.n64.cc/nosial/ncc/-/issues/33
2022-12-15 00:58:32 -05:00
Netkas
7a7ceb319b Implemented php runtime functions into extension
https://git.n64.cc/nosial/ncc/-/issues/33
2022-12-15 00:58:32 -05:00
Netkas
0fbb374507 Added method \ncc\Runtime > Constants > get()
https://git.n64.cc/nosial/ncc/-/issues/33
2022-12-15 00:54:38 -05:00
Netkas
553bf5ede0 Added ImportException 2022-12-14 22:31:52 -05:00
Netkas
cccbe3f934 Added 'Latest' to \ncc\Abstracts > Versions
Added SourcesMenu.php
Updated \ncc\Utilities > PathFinder
Added 'source' menu to \ncc\CLI
Added method \ncc\Utilities\Functions > getTmpDir()
Updated \ncc\CLI > HelpMenu
Updated \ncc\Utilities > HttpClient
Updated \ncc\Objects > HttpRequest
Updated php.xml for .idea
Added \ncc\Exception > GitlabServiceException
Added \ncc\Exceptions > GitCloneException
Added \ncc\Exceptions > GitCheckoutException
Updated \ncc\Abstracts > ExceptionCodes
Updated \ncc\Abstracts > DefinedRemoteSourceType
Added \ncc\Objects > DefinedRemoteSource
Renamed ComposerSource to \ncc\Classes\ComposerExtension > ComposerSourceBuiltin
Renamed RemoteSource to \ncc\Abstracts > BuiltinRemoteSourceType
2022-12-14 20:14:09 -05:00
Netkas
b3c8779313 Added DefinedRemoteSourceType.php
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-10 04:29:17 -05:00
Netkas
1f4ef9aba1 Added UnsupportedRemoteSourceTypeException.php
https://git.n64.cc/nosial/ncc/-/issues/28
2022-12-10 04:29:03 -05:00
Netkas
d664cf7bf0 Added HttpException to ExceptionCodes.php 2022-12-10 04:27:26 -05:00
Netkas
f521c3291d Added more logging calls to \ncc\Utilities > HttpClient
https://git.n64.cc/nosial/ncc/-/issues/29
2022-12-10 04:25:30 -05:00
Netkas
4f9f78e21d Added HttpClient 2022-12-09 00:25:41 -05:00
Netkas
dbf0109700 Updated license, added MIT License for NCC 2022-12-08 16:23:02 -05:00
Netkas
4a252c0302 Corrected Help Menu in CredentialMenu.php 2022-12-07 23:21:22 -05:00
Netkas
a581183972 Added logging call to \ncc\Managers > ConfigurationManager > updateProperty()
https://git.n64.cc/nosial/ncc/-/issues/29
2022-12-07 23:20:38 -05:00
Netkas
87e67564fa Fully implemented all the runners
https://git.n64.cc/nosial/ncc/-/issues/32
2022-12-07 23:11:27 -05:00
Netkas
ef43b1ccbc Added LuaRunner
https://git.n64.cc/nosial/ncc/-/issues/32
2022-12-07 23:05:27 -05:00
Netkas
afb69cd9ea Added Python2Runner
https://git.n64.cc/nosial/ncc/-/issues/32
2022-12-07 23:03:13 -05:00
Netkas
e7e2cca62a Added Python3Runner
https://git.n64.cc/nosial/ncc/-/issues/32
2022-12-07 22:59:15 -05:00
Netkas
d2acf224f3 Added PythonRunner
https://git.n64.cc/nosial/ncc/-/issues/32
2022-12-07 22:58:03 -05:00
Netkas
71cda91c42 Added PerlRunner
https://git.n64.cc/nosial/ncc/-/issues/32
2022-12-07 22:53:18 -05:00
Netkas
852be3087b Implemented Bash runner
https://git.n64.cc/nosial/ncc/-/issues/32
2022-12-07 21:56:02 -05:00
Netkas
6679da8022 Updated execution_policy.md
https://git.n64.cc/nosial/ncc/-/issues/35
2022-12-07 21:48:52 -05:00
Netkas
388d856503 Added example ExecutionPolicy files 2022-12-07 21:17:25 -05:00
Netkas
daa954bd76 Updated build flag 2022-12-07 20:59:55 -05:00
Netkas
f4abc020ec Added more Runners to \ncc\Abstracts > Runners
https://git.n64.cc/nosial/ncc/-/issues/32
2022-12-07 20:59:34 -05:00
Netkas
2842e63637 Improved PhpRunner.php
https://git.n64.cc/nosial/ncc/-/issues/32
2022-12-07 20:59:06 -05:00
Netkas
a60981380f Added method \ncc\Utilities > PathFinder > findRunner() to simplify the process of finding a runner executable via the config or locally
https://git.n64.cc/nosial/ncc/-/issues/32
2022-12-07 20:58:00 -05:00
Netkas
2a7b92ca94 Minor Correction 2022-12-07 20:40:57 -05:00
Netkas
f8a7e22f59 Updated ComposerSource to display license information and authors.
https://git.n64.cc/nosial/ncc/-/issues/40
2022-12-07 20:33:42 -05:00
Netkas
f2bc94292a Added command 'test' to test an entry
https://git.n64.cc/nosial/ncc/-/issues/27
2022-12-07 19:56:18 -05:00
Netkas
ec1aaf1d0f Minor bug fix in \ncc\Objects\Vault > Entry > unlock()
https://git.n64.cc/nosial/ncc/-/issues/27
2022-12-07 19:56:18 -05:00
Netkas
3fc50e04e5 Disabled password prompt due to instability
https://git.n64.cc/nosial/ncc/-/issues/23
2022-12-07 19:56:18 -05:00
Netkas
33e373c798 Bug fix in \ncc\Objects > Vault > deleteEntry()
https://git.n64.cc/nosial/ncc/-/issues/27
2022-12-07 19:56:17 -05:00
Netkas
9716ad8e61 Updated CredentialMenu.php help menu
https://git.n64.cc/nosial/ncc/-/issues/27
2022-12-07 18:25:17 -05:00
Netkas
85fc872999 Merge remote-tracking branch 'origin/v1.0.0_alpha' into v1.0.0_alpha 2022-12-07 18:09:10 -05:00
Netkas
e38a4df2ee Added 'list' command to CredentialMenu.php
https://git.n64.cc/nosial/ncc/-/issues/27
2022-12-07 18:08:57 -05:00
Netkas
c6b67016f2 Added 'list' command to CredentialMenu.php 2022-12-07 18:08:38 -05:00
Netkas
5a83a7f6fe Minor bug fixes when parsing Vault
https://git.n64.cc/nosial/ncc/-/issues/27
2022-12-07 18:08:15 -05:00
Netkas
f1e7aeccfa Improved help menu
https://git.n64.cc/nosial/ncc/-/issues/23
2022-12-07 18:06:42 -05:00
Netkas
b465bcefa5 \ncc\CLI > Main > getArgs() will try to fetch $argv if available
https://git.n64.cc/nosial/ncc/-/issues/23
2022-12-07 18:04:47 -05:00
Netkas
b9a356fe40 Added 'remove' command to CredentialMenu.php
https://git.n64.cc/nosial/ncc/-/issues/27
2022-12-07 17:06:09 -05:00
Netkas
c99b58892f Shortened 'credential' in CLI to 'cred' 2022-12-07 14:46:59 -05:00
Netkas
8bda6da2dc Added add command to CredentialMenu & Detailed documentation in the help menu
https://git.n64.cc/nosial/ncc/-/issues/27
2022-12-07 13:21:11 -05:00
Netkas
fb645aacc4 Minor code corrections 2022-12-07 01:25:47 -05:00
Netkas
e53bc97e4a Refactored Vault & CredentialManager to support encryption and indexing.
https://git.n64.cc/nosial/ncc/-/issues/27
2022-12-07 01:25:21 -05:00
Netkas
273d4b6612 Refactored CredentialManager & Vault
https://git.n64.cc/nosial/ncc/-/issues/27
2022-12-06 04:26:43 -05:00
Netkas
274f33a5c9 More efficient logging 2022-12-06 01:48:06 -05:00
Netkas
9507cd6e43 Added more logging calls
ref #29 https://git.n64.cc/nosial/ncc/-/issues/29
2022-12-06 01:40:14 -05:00
Netkas
9cef8e4394 RuntimeCache.php code cleanup 2022-12-06 01:35:38 -05:00
Netkas
f08ecb7947 Added shutdown handler (for cli only) to clear cache
ref #38 https://git.n64.cc/nosial/ncc/-/issues/38
2022-12-06 01:35:09 -05:00
Netkas
6371f26046 Added method array_replace_recursive() & recurse() to the installer which corrects issue #30 see https://git.n64.cc/nosial/ncc/-/issues/30
Updated some default values for ncc.yaml for better security.
2022-12-06 01:23:51 -05:00
Netkas
e4e0c7b9b5 Added v1.0.0_alpha.md 2022-12-05 04:21:12 -05:00
297 changed files with 13712 additions and 2517 deletions

1
.gitignore vendored
View file

@ -11,6 +11,7 @@ build
src/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php src/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php
src/ncc/ThirdParty/jelix/version/autoload_spl.php src/ncc/ThirdParty/jelix/version/autoload_spl.php
src/ncc/ThirdParty/nikic/PhpParser/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-ctype/autoload_spl.php
src/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php src/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php
src/ncc/ThirdParty/Symfony/polyfill-uuid/autoload_spl.php src/ncc/ThirdParty/Symfony/polyfill-uuid/autoload_spl.php

33
.gitlab-ci.yml Normal file
View 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
View file

@ -0,0 +1,6 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="Copyright (c) Nosial &amp;#36;originalComment.match(&quot;Copyright \(c\) (\d+)&quot;, 1, &quot;-&quot;, &quot;&amp;#36;today.year&quot;)2022-&amp;#36;today.year, all rights reserved.&#10;&#10; Permission is hereby granted, free of charge, to any person obtaining a copy of this software and&#10; associated documentation files (the &quot;Software&quot;), to deal in the Software without restriction, including without&#10; limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the&#10; Software, and to permit persons to whom the Software is furnished to do so, subject to the following&#10; conditions:&#10; &#10; The above copyright notice and this permission notice shall be included in all copies or substantial portions&#10; of the Software.&#10; &#10; THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, &#10; INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR&#10; PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE&#10; LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR&#10; OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER&#10; DEALINGS IN THE SOFTWARE.&#10;" />
<option name="myName" value="Nosial" />
</copyright>
</component>

7
.idea/copyright/profiles_settings.xml generated Normal file
View 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
View file

@ -8,6 +8,8 @@
<excludeFolder url="file://$MODULE_DIR$/build" /> <excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/docs" /> <excludeFolder url="file://$MODULE_DIR$/docs" />
<excludeFolder url="file://$MODULE_DIR$/tests/example_project/ncc" /> <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> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />

17
.idea/php.xml generated
View file

@ -1,11 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <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"> <component name="PhpIncludePathManager">
<include_path> <include_path>
<path value="/usr/share/php" /> <path value="/usr/share/php" />
</include_path> </include_path>
</component> </component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.1"> <component name="PhpProjectSharedConfiguration" php_language_level="8.2">
<option name="suggestChangeDefaultLanguageLevel" value="false" /> <option name="suggestChangeDefaultLanguageLevel" value="false" />
</component> </component>
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" />
</component>
</project> </project>

3
.idea/scopes/Autoloaders.xml generated Normal file
View 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
View 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>

View file

@ -1,3 +1,3 @@
<component name="DependencyValidationManager"> <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> </component>

3
.idea/scopes/Symfony_Filesystem.xml generated Normal file
View 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
View 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
View 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
View 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
View file

@ -0,0 +1,3 @@
<component name="DependencyValidationManager">
<scope name="Symfony\polyfill-ctype" pattern="file[ncc]:src/ncc/ThirdParty/Symfony/polyfill-ctype//*" />
</component>

View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View file

@ -0,0 +1,3 @@
<component name="DependencyValidationManager">
<scope name="theseer\Autoload" pattern="file[ncc]:src/ncc/ThirdParty/theseer/Autoload//*" />
</component>

View 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
View 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
View 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.

View file

@ -5,30 +5,839 @@ NCC, from basic installation, basic usage, standards and much more.
## Table of contents ## Table of contents
- Introduction <!-- TOC -->
- What is NCC? * [NCC Documentation](#ncc-documentation)
- Advantages over other software * [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
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
# Introduction (May 24, 2022) 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? ## What is NCC?
NCC (*Acronym for **N**osial **C**ode **C**ompiler*) is a multi-purpose compiler, NCC (*Acronym for **N**osial **C**ode **C**ompiler*) is a multi-purpose compiler, package manager and toolkit. Allowing
package manager and toolkit. Allowing projects to be managed and built more easily projects to be managed and built more easily without having to mess with all the traditional tools that comes with your
without having to mess with all the traditional tools that comes with your language language of choice. Right now NCC only supports PHP as it's written in PHP but extensions for other languages/frameworks
of choice. Right now NCC only supports PHP as it's written in PHP but extensions can be built into the software in the future when the need comes for it.
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 NCC can make the process of building your code into a redistributable package much more efficient by treating each
more efficient by treating each building block of your project as a component that building block of your project as a component that is interconnected in your environment instead of the more popular
is interconnected in your environment instead of the more popular route taken by route taken by package/dependency managers such as [composer](https://getcomposer.org/),[npm](https://www.npmjs.com/) or
package/dependency managers such as [composer](https://getcomposer.org/), [pypi (or pip)](https://pypi.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.
![ncc cli](assets/ncc_cli.png)
## 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
View file

@ -1,355 +1,14 @@
------------------------ Copyright 2022-2023 Nosial - All Rights Reserved.
Nosial - NCC
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 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Proprietary and confidential, written by Zi Xing Narrakas <netkas@n64.cc> Software.
------------------------ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
Symfony - Process 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
Copyright (c) 2004-2022 Fabien Potencier OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.

View file

@ -1,5 +1,5 @@
PHPCC=/usr/bin/php PHPCC:=$(shell which php)
PHPAB=/usr/bin/phpab PHPAB:=$(shell which phpab)
BUILD_PATH=build BUILD_PATH=build
SRC_PATH=src SRC_PATH=src
@ -80,25 +80,28 @@ $(SRC_PATH)/ncc/autoload_spl.php:
$(SRC_PATH)/ncc/Objects \ $(SRC_PATH)/ncc/Objects \
$(SRC_PATH)/ncc/Runtime \ $(SRC_PATH)/ncc/Runtime \
$(SRC_PATH)/ncc/Utilities \ $(SRC_PATH)/ncc/Utilities \
$(SRC_PATH)/ncc/ncc.php $(SRC_PATH)/ncc/ncc.php \
$(SRC_PATH)/ncc/Runtime.php
redist: autoload redist: autoload
rm -rf $(BUILD_PATH)/src rm -rf $(BUILD_PATH)/src
mkdir -p $(BUILD_PATH)/src mkdir -p $(BUILD_PATH)/src
cp -rf $(SRC_PATH)/ncc/* $(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/installer $(BUILD_PATH)/src/INSTALL
cp $(SRC_PATH)/installer/ncc.sh $(BUILD_PATH)/$(SRC_PATH)/ncc.sh cp $(SRC_PATH)/installer/ncc.sh $(BUILD_PATH)/src/ncc.sh
cp $(SRC_PATH)/config/ncc.yaml $(BUILD_PATH)/$(SRC_PATH)/default_config.yaml; cp $(SRC_PATH)/config/ncc.yaml $(BUILD_PATH)/src/default_config.yaml;
cp $(SRC_PATH)/config/ncc.yaml $(BUILD_PATH)/$(SRC_PATH)/CLI/template_config.yaml; cp $(SRC_PATH)/config/ncc.yaml $(BUILD_PATH)/src/CLI/template_config.yaml;
cp $(SRC_PATH)/installer/extension $(BUILD_PATH)/$(SRC_PATH)/extension cp $(SRC_PATH)/installer/extension $(BUILD_PATH)/src/extension
chmod +x $(BUILD_PATH)/$(SRC_PATH)/INSTALL chmod +x $(BUILD_PATH)/src/INSTALL
cp LICENSE $(BUILD_PATH)/$(SRC_PATH)/LICENSE cp LICENSE $(BUILD_PATH)/src/LICENSE
cp README.md $(BUILD_PATH)/$(SRC_PATH)/README.md cp README.md $(BUILD_PATH)/src/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/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_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/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 tar: redist
cd $(BUILD_PATH)/src; tar -czvf ../ncc.tar.gz * cd $(BUILD_PATH)/src; tar -czvf ../build.tar.gz *
clean: clean:
rm -rf $(BUILD_PATH) rm -rf $(BUILD_PATH)

View file

@ -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) 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. 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 ## Alpha Stage
a PPM extension may be built in the future to allow for backwards compatibility.
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 We welcome contributions to NCC! If you have an idea for how to improve the project, please don't hesitate to reach out.
> designed to be used in production in a Unix environment and Windows should only be used for development purposes. 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 # Code of Conduct
> the user wishes to install and use one of the same dependencies that NCC uses.
## Authors We are committed to maintaining a welcoming and inclusive environment for all contributors. Please read and follow our
- Zi Xing Narrakas (netkas) <[netkas@n64.cc](mailto:netkas@64.cc)> [Code of Conduct](CODE_OF_CONDUCT.md).
## Special Thanks # Authors
- Marc Gutt (mgutt) <[marc@gutt.it](mailto:marc@gutt.it)>
- Debusschère Alexandre ([debuss](https://github.com/debuss)) - 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 # 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

18
changelog/v1.0.0_alpha.md Normal file
View 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

View file

@ -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.

View file

@ -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

View file

@ -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
}
```

View file

@ -19,12 +19,6 @@ ncc:
php: php:
# The main executable path for PHP that NCC should use # The main executable path for PHP that NCC should use
executable_path: "/usr/bin/php" 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: git:
# if git is enabled or not # if git is enabled or not
@ -55,10 +49,10 @@ composer:
quiet: false quiet: false
# Disable ANSI output # Disable ANSI output
no_ansi: false no_ansi: true
# Do not ask any interactive question # Do not ask any interactive question
no_interaction: false no_interaction: true
# Display timing and memory usage information # Display timing and memory usage information
profile: false profile: false

View file

@ -0,0 +1,6 @@
[
"gitgud.json",
"github.json",
"gitlab.json",
"n64.json"
]

View file

@ -0,0 +1,6 @@
{
"name": "gitgud",
"type": "gitlab",
"host": "gitgud.io",
"ssl": true
}

View file

@ -0,0 +1,6 @@
{
"name": "github",
"type": "github",
"host": "api.github.com",
"ssl": true
}

View file

@ -0,0 +1,6 @@
{
"name": "gitlab",
"type": "gitlab",
"host": "gitlab.com",
"ssl": true
}

View file

@ -0,0 +1,6 @@
{
"name": "n64",
"type": "gitlab",
"host": "git.n64.cc",
"ssl": true
}

View file

@ -1,8 +1,19 @@
<?php <?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\''); throw new RuntimeException('Cannot locate file \'%ncc_install' . DIRECTORY_SEPARATOR . 'autoload.php\'');
} }
@ -10,4 +21,150 @@
{ {
require('%ncc_install' . DIRECTORY_SEPARATOR . 'autoload.php'); 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);
}
}
} }

View file

@ -14,8 +14,10 @@
use ncc\Abstracts\ConsoleColors; use ncc\Abstracts\ConsoleColors;
use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\FileNotFoundException;
use ncc\Managers\RemoteSourcesManager;
use ncc\ncc; use ncc\ncc;
use ncc\Objects\CliHelpSection; use ncc\Objects\CliHelpSection;
use ncc\Objects\DefinedRemoteSource;
use ncc\ThirdParty\Symfony\Filesystem\Exception\IOException; use ncc\ThirdParty\Symfony\Filesystem\Exception\IOException;
use ncc\ThirdParty\Symfony\Filesystem\Filesystem; use ncc\ThirdParty\Symfony\Filesystem\Filesystem;
use ncc\ThirdParty\Symfony\Process\Exception\ProcessFailedException; use ncc\ThirdParty\Symfony\Process\Exception\ProcessFailedException;
@ -712,7 +714,6 @@
$config_obj['composer']['enable_internal_composer'] = false; $config_obj['composer']['enable_internal_composer'] = false;
if($config_obj['composer']['executable_path'] == null) 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'); 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())) if ($NCC_FILESYSTEM->exists(PathFinder::getConfigurationFile()))
{ {
$config_backup = IO::fread(PathFinder::getConfigurationFile()); $config_backup = Yaml::parseFile(PathFinder::getConfigurationFile());
} }
} }
catch (Exception $e) catch (Exception $e)
@ -736,33 +737,73 @@
// Create/Update configuration file // Create/Update configuration file
$config_obj = Yaml::parseFile(__DIR__ . DIRECTORY_SEPARATOR . 'default_config.yaml'); $config_obj = Yaml::parseFile(__DIR__ . DIRECTORY_SEPARATOR . 'default_config.yaml');
// Update the old configuration if(!function_exists('array_replace_recursive'))
if($config_backup !== null)
{ {
$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])) $array = recurse($array, $args[$i]);
{
$config_obj[$section][$section_item] = $section_value;
}
} }
} }
else return $array;
{
$config_obj[$section] = $value;
}
} }
} }
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) if($config_backup == null)
{ {
Console::out('Generating ncc.yaml'); Console::out('Generating ncc.yaml');
} }
else else
{ {
@ -779,6 +820,57 @@
return; 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('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\''); Console::out('For licensing information see \'' . $NCC_INSTALL_PATH . DIRECTORY_SEPARATOR . 'LICENSE\' or run \'ncc help --license\'');

View file

@ -1,12 +0,0 @@
<?php
namespace ncc\Abstracts;
abstract class AuthenticationSource
{
const None = 'NONE';
const ServerProvided = 'SERVER_PROVIDED';
const UserProvided = 'USER_PROVIDED';
}

View 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;
}

View 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
];
}

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class CompilerExtensionDefaultVersions
{ {
@ -9,5 +29,5 @@
// [1] = MaximumVersion // [1] = MaximumVersion
// ---------------------------------------------------------------- // ----------------------------------------------------------------
const PHP = ['8.0', '8.1']; const PHP = ['8.0', '8.2'];
} }

View file

@ -1,8 +1,28 @@
<?php <?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 abstract class CompilerExtensionSupportedVersions
{ {
const PHP = ['8.0', '8.1']; const PHP = ['8.0', '8.1', '8.2'];
} }

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class CompilerExtensions
{ {

View file

@ -1,8 +0,0 @@
<?php
namespace ncc\Abstracts;
abstract class CompilerOptions
{
}

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class ComponentDataType
{ {

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class ComponentFileExtensions
{ {

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class ComposerPackageTypes
{ {
@ -12,7 +32,7 @@
/** /**
* This denotes a project rather than a library. For example * This denotes a project rather than a library. For example
* application shells like the Symfony standard edition, CMSs * 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 * distributed as packages. This can for example be used by IDEs
* to provide listings of projects to initialize when creating * to provide listings of projects to initialize when creating
* a new workspace. * a new workspace.

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class ComposerStabilityTypes
{ {

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class ConsoleColors
{ {

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class ConstantReferences
{ {
@ -11,4 +31,6 @@
const DateTime = 'date_time'; const DateTime = 'date_time';
const Install = 'install'; const Install = 'install';
const Runtime = 'runtime';
} }

View 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
];
}

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class DependencySourceType
{ {

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class EncoderType
{ {

View file

@ -1,6 +1,28 @@
<?php <?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 * @author Zi Xing Narrakas
@ -268,6 +290,91 @@
*/ */
const MissingDependencyException = -1751; 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 * All the exception codes from NCC
*/ */
@ -322,6 +429,21 @@
self::ComposerNotAvailableException, self::ComposerNotAvailableException,
self::ComposerException, self::ComposerException,
self::UserAbortedOperationException, 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,
]; ];
} }

View 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';
}

View 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
];
}

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class LogLevel
{ {

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class NccBuildFlags
{ {
@ -8,5 +28,5 @@
* Indicates if the build is currently unstable and some features may not work correctly * Indicates if the build is currently unstable and some features may not work correctly
* and can cause errors * and can cause errors
*/ */
const Unstable = 'UNSTABLE'; const Unstable = 'unstable';
} }

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class BuildConfigurationValues
{ {

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class InitializeProjectOptions
{ {

View 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';
}

View 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';
}

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class PackageStandardVersions
{ {

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class PackageStructureVersions
{ {

View 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';
}

View file

@ -1,6 +1,26 @@
<?php <?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 * @author Zi Xing Narrakas

View file

@ -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';
}

View file

@ -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';
}

View 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
];
}

View file

@ -1,8 +1,51 @@
<?php <?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 abstract class Runners
{ {
const php = 'php'; 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
];
} }

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class Scopes
{ {

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class AssemblyConstants
{ {

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class BuildConstants
{ {

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class DateTimeConstants
{ {

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class InstallConstants
{ {

View file

@ -1,8 +1,33 @@
<?php <?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 abstract class RuntimeConstants
{ {
const CWD = '%CWD%'; const CWD = '%CWD%';
const PID = '%PID%';
const UID = '%UID%';
const GID = '%GID%';
const User = '%USER%';
} }

View file

@ -1,12 +0,0 @@
<?php
namespace ncc\Abstracts;
abstract class StringPaddingMethod
{
const LEFT = 'LEFT';
const RIGHT = 'RIGHT';
const BOTH = 'BOTH';
}

View file

@ -1,6 +1,26 @@
<?php <?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 abstract class Versions
{ {
@ -18,4 +38,9 @@
* The current version of the package lock structure file format * The current version of the package lock structure file format
*/ */
const PackageLockVersion = '1.0.0'; const PackageLockVersion = '1.0.0';
/**
* Generic version of the package structure file format (latest)
*/
const Latest = 'latest';
} }

View file

@ -1,14 +1,35 @@
<?php <?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 Exception;
use ncc\Abstracts\Options\BuildConfigurationValues; use ncc\Abstracts\Options\BuildConfigurationValues;
use ncc\Managers\ProjectManager; use ncc\Managers\ProjectManager;
use ncc\Objects\CliHelpSection; use ncc\Objects\CliHelpSection;
use ncc\Utilities\Console; use ncc\Utilities\Console;
use ncc\Utilities\Functions;
class BuildMenu class BuildCommand
{ {
/** /**
* Displays the main help menu * Displays the main help menu
@ -103,7 +124,7 @@
new CliHelpSection(['build', '--config'], 'Builds the current project with a specified build configuration') 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('Usage: ncc build [options]');
Console::out('Options:' . PHP_EOL); Console::out('Options:' . PHP_EOL);

View 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');
}
}

View file

@ -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);
}
}

View file

@ -1,9 +1,33 @@
<?php <?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\Objects\CliHelpSection;
use ncc\Utilities\Console; use ncc\Utilities\Console;
use ncc\Utilities\Functions;
class HelpMenu class HelpMenu
{ {
@ -12,8 +36,11 @@
* *
* @param $args * @param $args
* @return void * @return void
* @throws AccessDeniedException
* @throws FileNotFoundException
* @throws IOException
*/ */
public static function start($args) public static function start($args): void
{ {
$basic_ascii = false; $basic_ascii = false;
@ -23,7 +50,7 @@
} }
// TODO: Make copyright not hard-coded. // 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('Usage: ncc COMMAND [options]');
Console::out('Alternative Usage: ncc.php --ncc-cli=COMMAND [options]' . PHP_EOL); Console::out('Alternative Usage: ncc.php --ncc-cli=COMMAND [options]' . PHP_EOL);
@ -32,7 +59,6 @@
self::displayMainOptions(); self::displayMainOptions();
self::displayManagementCommands(); self::displayManagementCommands();
self::displayMainCommands(); self::displayMainCommands();
self::displayExtensions();
} }
/** /**
@ -42,22 +68,15 @@
*/ */
private static function displayMainOptions(): void private static function displayMainOptions(): void
{ {
$options = [ Console::out('Options:');
Console::outHelpSections([
new CliHelpSection(['{command} --help'], 'Displays help information about a specific command'), new CliHelpSection(['{command} --help'], 'Displays help information about a specific command'),
new CliHelpSection(['-v', '--version'], 'Display NCC version information'), new CliHelpSection(['-v', '--version'], 'Display NCC version information'),
new CliHelpSection(['-D', '--debug'], 'Enables debug mode'), new CliHelpSection(['-l', '--log-level={silent|debug|verbose|info|warn|error|fatal}'], 'Set the logging level', 'info'),
new CliHelpSection(['-l', '--log-level={debug|info|warn|error|fatal}'], 'Set the logging level', 'info'),
new CliHelpSection(['--basic-ascii'], 'Uses basic ascii characters'), new CliHelpSection(['--basic-ascii'], 'Uses basic ascii characters'),
new CliHelpSection(['--no-color'], 'Omits the use of colors'), new CliHelpSection(['--no-color'], 'Omits the use of colors'),
new CliHelpSection(['--no-banner'], 'Omits displaying the NCC ascii banner') 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 private static function displayManagementCommands(): void
{ {
$commands = [ Console::out('Management Commands:');
Console::outHelpSections([
new CliHelpSection(['project'], 'Manages the current project'), new CliHelpSection(['project'], 'Manages the current project'),
new CliHelpSection(['package'], 'Manages the package system'), new CliHelpSection(['package'], 'Manages the package system'),
new CliHelpSection(['cache'], 'Manages the system cache'), new CliHelpSection(['cred'], 'Manages credentials'),
new CliHelpSection(['credential'], 'Manages credentials'),
new CliHelpSection(['config'], 'Changes NCC configuration values'), new CliHelpSection(['config'], 'Changes NCC configuration values'),
]; new CliHelpSection(['source'], 'Manages remote sources'),
$commands_padding = \ncc\Utilities\Functions::detectParametersPadding($commands) + 2; ]);
Console::out('Management Commands:');
foreach($commands as $command)
{
Console::out(' ' . $command->toString($commands_padding));
}
} }
/** /**
@ -90,35 +103,10 @@
*/ */
private static function displayMainCommands(): void 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:'); Console::out('Commands:');
foreach($commands as $command) Console::outHelpSections([
{ new CliHelpSection(['build'], 'Builds the current project'),
Console::out(' ' . $command->toString($commands_padding)); new CliHelpSection(['exec'], 'Executes the main entrypoint of a package')
} ]);
}
/**
* 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));
}
} }
} }

View file

@ -1,4 +1,24 @@
<?php <?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 */ /** @noinspection PhpMissingFieldTypeInspection */
@ -7,11 +27,22 @@
use Exception; use Exception;
use ncc\Abstracts\LogLevel; use ncc\Abstracts\LogLevel;
use ncc\Abstracts\NccBuildFlags; 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\FileNotFoundException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\RuntimeException; use ncc\Exceptions\RuntimeException;
use ncc\ncc; use ncc\ncc;
use ncc\Utilities\Console; use ncc\Utilities\Console;
use ncc\Utilities\Functions;
use ncc\Utilities\Resolver; use ncc\Utilities\Resolver;
use ncc\Utilities\RuntimeCache;
class Main class Main
{ {
@ -30,6 +61,9 @@
* *
* @param $argv * @param $argv
* @return void * @return void
* @throws RuntimeException
* @throws AccessDeniedException
* @throws IOException
*/ */
public static function start($argv): void public static function start($argv): void
{ {
@ -51,8 +85,8 @@
Console::outException('Cannot initialize NCC due to a runtime error.', $e, 1); Console::outException('Cannot initialize NCC due to a runtime error.', $e, 1);
} }
// Define CLI stuff
define('NCC_CLI_MODE', 1); define('NCC_CLI_MODE', 1);
register_shutdown_function('ncc\CLI\Main::shutdown');
if(isset(self::$args['l']) || isset(self::$args['log-level'])) if(isset(self::$args['l']) || isset(self::$args['log-level']))
{ {
@ -82,13 +116,13 @@
if(Resolver::checkLogLevel(self::$log_level, LogLevel::Debug)) if(Resolver::checkLogLevel(self::$log_level, LogLevel::Debug))
{ {
Console::outDebug('Debug logging enabled'); 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))); Console::outDebug(sprintf('args: %s', json_encode(self::$args, JSON_UNESCAPED_SLASHES)));
} }
if(in_array(NccBuildFlags::Unstable, NCC_VERSION_FLAGS)) 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 try
@ -97,32 +131,44 @@
{ {
default: default:
Console::out('Unknown command ' . strtolower(self::$args['ncc-cli'])); Console::out('Unknown command ' . strtolower(self::$args['ncc-cli']));
exit(1); break;
case 'project': case 'project':
ProjectMenu::start(self::$args); ProjectMenu::start(self::$args);
exit(0); break;
case 'build': case 'build':
BuildMenu::start(self::$args); BuildCommand::start(self::$args);
exit(0); break;
case 'credential': case 'exec':
ExecCommand::start(self::$args);
break;
case 'cred':
CredentialMenu::start(self::$args); CredentialMenu::start(self::$args);
exit(0); break;
case 'package': case 'package':
PackageManagerMenu::start(self::$args); PackageManagerMenu::start(self::$args);
exit(0); break;
case 'config': case 'config':
ConfigMenu::start(self::$args); 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 '1':
case 'help': case 'help':
HelpMenu::start(self::$args); HelpMenu::start(self::$args);
exit(0); break;
} }
} }
catch(Exception $e) catch(Exception $e)
@ -131,14 +177,27 @@
exit(1); 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; return self::$args;
} }
@ -152,4 +211,20 @@
return self::$log_level; 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());
}
}
} }

View file

@ -1,6 +1,26 @@
<?php <?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\Abstracts\Scopes;
use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\AccessDeniedException;
@ -83,7 +103,7 @@
{ {
if(Resolver::resolveScope() !== Scopes::System) 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; return;
} }

View 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"');
}
}

View file

@ -1,15 +1,36 @@
<?php <?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 Exception;
use ncc\Abstracts\ConsoleColors; use ncc\Abstracts\ConsoleColors;
use ncc\Abstracts\RemoteSource; use ncc\Abstracts\Options\InstallPackageOptions;
use ncc\Abstracts\Scopes; use ncc\Abstracts\Scopes;
use ncc\Classes\ComposerExtension\ComposerSource;
use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\FileNotFoundException;
use ncc\Exceptions\PackageLockException; use ncc\Exceptions\PackageLockException;
use ncc\Exceptions\RuntimeException;
use ncc\Exceptions\VersionNotFoundException; use ncc\Exceptions\VersionNotFoundException;
use ncc\Managers\CredentialManager;
use ncc\Managers\PackageManager; use ncc\Managers\PackageManager;
use ncc\Objects\CliHelpSection; use ncc\Objects\CliHelpSection;
use ncc\Objects\Package; 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(); self::displayOptions();
exit(0); 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 * Displays all installed packages
* *
@ -156,6 +276,7 @@
$package_version = $package_manager->getPackageVersion($package, $version); $package_version = $package_manager->getPackageVersion($package, $version);
if($package_version == null) if($package_version == null)
continue; continue;
Console::out(sprintf('%s=%s (%s)', Console::out(sprintf('%s=%s (%s)',
Console::formatColor($package, ConsoleColors::LightGreen), Console::formatColor($package, ConsoleColors::LightGreen),
Console::formatColor($version, ConsoleColors::LightMagenta), Console::formatColor($version, ConsoleColors::LightMagenta),
@ -165,9 +286,10 @@
catch(Exception $e) catch(Exception $e)
{ {
unset($e); unset($e);
Console::out(sprintf('%s=%s', Console::out(sprintf('%s=%s (%s)',
Console::formatColor($package, ConsoleColors::LightGreen), 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; return;
} }
$path = $package; // check if authentication is provided
$parsed_source = new RemotePackageInput($path); $entry_arg = ($args['auth'] ?? null);
if($parsed_source->Vendor !== null && $parsed_source->Package !== 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; 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
try {
{ $credential->unlock(Console::passwordInput(sprintf('Enter Password for %s: ', $credential->getName())));
$path = ComposerSource::fetch($parsed_source); }
break; catch (RuntimeException $e)
} {
catch(Exception $e) Console::outException(sprintf('Failed to unlock credential %s', $credential->getName()), $e, 1);
{
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);
return; 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']); $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 try
{ {
$package = Package::load($path); $package = Package::load($path);
@ -261,38 +428,39 @@
Console::out(' Trademark: ' . Console::formatColor($package->Assembly->Trademark, ConsoleColors::LightGreen)); Console::out(' Trademark: ' . Console::formatColor($package->Assembly->Trademark, ConsoleColors::LightGreen));
Console::out((string)null); Console::out((string)null);
if(count($package->Dependencies) > 0) if(count($package->Dependencies) > 0 && !in_array(InstallPackageOptions::Reinstall, $installer_options))
{ {
$dependencies = []; $dependencies = [];
foreach($package->Dependencies as $dependency) foreach($package->Dependencies as $dependency)
{ {
$require_dependency = true; $require_dependency = false;
try if(!in_array(InstallPackageOptions::SkipDependencies, $installer_options))
{
$dependency_package = $package_manager->getPackage($dependency->Name);
}
catch (PackageLockException $e)
{
unset($e);
$dependency_package = null;
}
if($dependency_package !== null)
{ {
try try
{ {
$dependency_version = $dependency_package->getVersion($dependency->Version); $dependency_package = $package_manager->getPackage($dependency->Name);
} }
catch (VersionNotFoundException $e) catch (PackageLockException $e)
{ {
unset($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:'); if($dependencies !== null && count($dependencies) > 0)
Console::out(sprintf('%s', implode(PHP_EOL, $dependencies))); {
Console::out('The package requires the following dependencies:');
Console::out(sprintf('%s', implode(PHP_EOL, $dependencies)));
}
} }
Console::out(sprintf('Extension: %s', Console::out(sprintf('Extension: %s',
@ -326,11 +497,13 @@
if(!$user_confirmation) if(!$user_confirmation)
$user_confirmation = Console::getBooleanInput(sprintf('Do you want to install %s', $package->Assembly->Package)); $user_confirmation = Console::getBooleanInput(sprintf('Do you want to install %s', $package->Assembly->Package));
if($user_confirmation) if($user_confirmation)
{ {
try try
{ {
$package_manager->install($path); $package_manager->install($path, $credential, $installer_options);
Console::out(sprintf('Package %s installed successfully', $package->Assembly->Package)); Console::out(sprintf('Package %s installed successfully', $package->Assembly->Package));
} }
catch(Exception $e) catch(Exception $e)
@ -382,7 +555,6 @@
$version_entry = null; $version_entry = null;
if($version_entry !== null && $package_entry !== null) if($version_entry !== null && $package_entry !== null)
/** @noinspection PhpUnhandledExceptionInspection */
/** @noinspection PhpRedundantOptionalArgumentInspection */ /** @noinspection PhpRedundantOptionalArgumentInspection */
$version_entry = $package_entry->getVersion($version_entry, false); $version_entry = $package_entry->getVersion($version_entry, false);
@ -490,9 +662,12 @@
new CliHelpSection(['list'], 'Lists all installed packages on the system'), 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'], 'Installs a specified NCC package'),
new CliHelpSection(['install', '--package', '-p', '--version', '-v'], 'Installs a specified NCC package version'), 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'], 'Uninstalls a specified NCC package'),
new CliHelpSection(['uninstall', '--package', '-p', '--version', '-v'], 'Uninstalls a specified NCC package version'), new CliHelpSection(['uninstall', '--package', '-p', '--version', '-v'], 'Uninstalls a specified NCC package version'),
new CliHelpSection(['uninstall-all'], 'Uninstalls all packages'), 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; $options_padding = Functions::detectParametersPadding($options) + 4;

View file

@ -1,18 +1,45 @@
<?php <?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 Exception;
use ncc\Abstracts\CompilerExtensionDefaultVersions; use ncc\Abstracts\CompilerExtensionDefaultVersions;
use ncc\Abstracts\CompilerExtensions; use ncc\Abstracts\CompilerExtensions;
use ncc\Abstracts\CompilerExtensionSupportedVersions; use ncc\Abstracts\CompilerExtensionSupportedVersions;
use ncc\Exceptions\AccessDeniedException;
use ncc\Exceptions\DirectoryNotFoundException;
use ncc\Exceptions\FileNotFoundException;
use ncc\Exceptions\InvalidPackageNameException; use ncc\Exceptions\InvalidPackageNameException;
use ncc\Exceptions\InvalidProjectNameException; use ncc\Exceptions\InvalidProjectNameException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\ProjectAlreadyExistsException; use ncc\Exceptions\ProjectAlreadyExistsException;
use ncc\Exceptions\ProjectConfigurationNotFoundException;
use ncc\Managers\ProjectManager; use ncc\Managers\ProjectManager;
use ncc\Objects\CliHelpSection; use ncc\Objects\CliHelpSection;
use ncc\Objects\ProjectConfiguration\Compiler; use ncc\Objects\ProjectConfiguration\Compiler;
use ncc\Utilities\Console; use ncc\Utilities\Console;
use ncc\Utilities\Functions;
class ProjectMenu class ProjectMenu
{ {
@ -21,6 +48,12 @@
* *
* @param $args * @param $args
* @return void * @return void
* @throws AccessDeniedException
* @throws DirectoryNotFoundException
* @throws FileNotFoundException
* @throws IOException
* @throws MalformedJsonException
* @throws ProjectConfigurationNotFoundException
*/ */
public static function start($args): void public static function start($args): void
{ {
@ -30,13 +63,17 @@
} }
self::displayOptions(); self::displayOptions();
exit(0);
} }
/** /**
* @param $args * @param $args
* @return void * @return void
* @throws AccessDeniedException
* @throws DirectoryNotFoundException
* @throws FileNotFoundException
* @throws IOException
* @throws MalformedJsonException
* @throws ProjectConfigurationNotFoundException
*/ */
public static function createProject($args): void public static function createProject($args): void
{ {
@ -64,6 +101,7 @@
else else
{ {
Console::outError('The selected source directory \'' . $full_path . '\' was not found or is not a directory', true, 1); Console::outError('The selected source directory \'' . $full_path . '\' was not found or is not a directory', true, 1);
return;
} }
} }
else else
@ -72,7 +110,7 @@
} }
// Remove basename from real_src // 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 // Fetch the rest of the information needed for the project
//$compiler_extension = Console::getOptionInput($args, 'ce', 'Compiler Extension (php, java): '); //$compiler_extension = Console::getOptionInput($args, 'ce', 'Compiler Extension (php, java): ');
@ -221,7 +259,7 @@
new CliHelpSection(['create-makefile'], 'Generates a Makefile for the project'), 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('Usage: ncc project {command} [options]');
Console::out('Options:' . PHP_EOL); Console::out('Options:' . PHP_EOL);

View 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);
}
}

View file

@ -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));
}
}
}

View 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';
}
}

View file

@ -1,6 +1,26 @@
<?php <?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 Exception;
use FilesystemIterator; use FilesystemIterator;
@ -28,10 +48,11 @@
use ncc\Exceptions\ProjectConfigurationNotFoundException; use ncc\Exceptions\ProjectConfigurationNotFoundException;
use ncc\Exceptions\RuntimeException; use ncc\Exceptions\RuntimeException;
use ncc\Exceptions\UnsupportedCompilerExtensionException; use ncc\Exceptions\UnsupportedCompilerExtensionException;
use ncc\Exceptions\UnsupportedRunnerException;
use ncc\Exceptions\UserAbortedOperationException; use ncc\Exceptions\UserAbortedOperationException;
use ncc\Interfaces\RemoteSourceInterface; use ncc\Interfaces\ServiceSourceInterface;
use ncc\Managers\ProjectManager; use ncc\Managers\ProjectManager;
use ncc\ncc;
use ncc\Objects\ComposerJson;
use ncc\Objects\ComposerLock; use ncc\Objects\ComposerLock;
use ncc\Objects\ProjectConfiguration; use ncc\Objects\ProjectConfiguration;
use ncc\Objects\RemotePackageInput; use ncc\Objects\RemotePackageInput;
@ -47,7 +68,7 @@
use ncc\Utilities\RuntimeCache; use ncc\Utilities\RuntimeCache;
use SplFileInfo; use SplFileInfo;
class ComposerSource implements RemoteSourceInterface class ComposerSourceBuiltin implements ServiceSourceInterface
{ {
/** /**
* Attempts to acquire the package from the composer repository and * Attempts to acquire the package from the composer repository and
@ -77,7 +98,6 @@
* @throws ProjectConfigurationNotFoundException * @throws ProjectConfigurationNotFoundException
* @throws RuntimeException * @throws RuntimeException
* @throws UnsupportedCompilerExtensionException * @throws UnsupportedCompilerExtensionException
* @throws UnsupportedRunnerException
* @throws UserAbortedOperationException * @throws UserAbortedOperationException
*/ */
public static function fetch(RemotePackageInput $packageInput): string 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())); 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 * @param string $composer_lock_path
* @return array * @return array
@ -109,7 +193,6 @@
* @throws PackagePreparationFailedException * @throws PackagePreparationFailedException
* @throws ProjectConfigurationNotFoundException * @throws ProjectConfigurationNotFoundException
* @throws UnsupportedCompilerExtensionException * @throws UnsupportedCompilerExtensionException
* @throws UnsupportedRunnerException
*/ */
private static function compilePackages(string $composer_lock_path): array private static function compilePackages(string $composer_lock_path): array
{ {
@ -129,108 +212,19 @@
} }
$filesystem->mkdir($base_dir . DIRECTORY_SEPARATOR . 'build'); $filesystem->mkdir($base_dir . DIRECTORY_SEPARATOR . 'build');
$version_map = self::getVersionMap($composer_lock);
foreach ($composer_lock->Packages as $package) foreach ($composer_lock->Packages as $package)
{ {
$package_path = $base_dir . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $package->Name; $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 // Load the composer lock file
if ($package->Autoload !== null) $composer_package = $composer_lock->getPackage($package->Name);
{ if ($composer_package == null)
$source_directory = $package_path . DIRECTORY_SEPARATOR . '.src'; throw new PackageNotFoundException(sprintf('Package "%s" not found in composer lock file', $package->Name));
if ($filesystem->exists($source_directory))
{
$filesystem->remove($source_directory);
}
$filesystem->mkdir($source_directory);
$source_directories = [];
$static_files = [];
// TODO: Implement static files handling // Convert it to a NCC project configuration
$project_configuration = self::convertProject($package_path, $version_map, $composer_package);
// 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');
}
// Load the project // Load the project
$project_manager = new ProjectManager($package_path); $project_manager = new ProjectManager($package_path);
@ -238,15 +232,31 @@
$built_package = $project_manager->build(); $built_package = $project_manager->build();
// Copy the project to the build directory // 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->copy($built_package, $out_path);
$filesystem->remove($built_package);
$built_packages[$project_configuration->Assembly->Package] = $out_path; $built_packages[$project_configuration->Assembly->Package] = $out_path;
} }
return $built_packages; 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 * Converts a composer package name to a valid package name
* *
@ -271,22 +281,33 @@
return null; 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 * Generates a project configuration from a package selection
* from the composer.lock file * from the composer.lock file
* *
* @param string $package_name * @param ComposerJson $composer_package
* @param ComposerLock $composer_lock * @param array $version_map
* @return ProjectConfiguration * @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 // Generate a new project configuration object
$project_configuration = new ProjectConfiguration(); $project_configuration = new ProjectConfiguration();
@ -294,37 +315,41 @@
$project_configuration->Assembly->Name = $composer_package->Name; $project_configuration->Assembly->Name = $composer_package->Name;
if (isset($composer_package->Description)) if (isset($composer_package->Description))
$project_configuration->Assembly->Description = $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->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 // 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); foreach ($composer_package->Require as $item)
$package_version = $composer_lock->getPackage($item->PackageName)?->Version;
if ($package_version == null)
{ {
$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 // Create a build configuration
$build_configuration = new ProjectConfiguration\BuildConfiguration(); $build_configuration = new ProjectConfiguration\Build\BuildConfiguration();
$build_configuration->Name = 'default'; $build_configuration->Name = 'default';
$build_configuration->OutputPath = 'build'; $build_configuration->OutputPath = 'build';
@ -341,22 +366,6 @@
return $project_configuration; 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 * Gets the applicable options configured for composer
* *
@ -437,7 +446,6 @@
* @param string $vendor * @param string $vendor
* @param string $package * @param string $package
* @param string|null $version * @param string|null $version
* @param array $options
* @return string * @return string
* @throws AccessDeniedException * @throws AccessDeniedException
* @throws ComposerDisabledException * @throws ComposerDisabledException
@ -449,13 +457,15 @@
* @throws InvalidScopeException * @throws InvalidScopeException
* @throws UserAbortedOperationException * @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) if (Resolver::resolveScope() !== Scopes::System)
throw new AccessDeniedException('Insufficient permissions to require'); throw new AccessDeniedException('Insufficient permissions to require');
if ($version == null) if ($version == null)
$version = '*'; $version = '*';
if($version == 'latest')
$version = '*';
$tpl_file = __DIR__ . DIRECTORY_SEPARATOR . 'composer.jtpl'; $tpl_file = __DIR__ . DIRECTORY_SEPARATOR . 'composer.jtpl';
if (!file_exists($tpl_file)) if (!file_exists($tpl_file))
@ -482,29 +492,11 @@
// Execute composer with options // Execute composer with options
$options = self::getOptions(); $options = self::getOptions();
$process = new Process(array_merge([$composer_exec, 'require'], $options)); $process = new Process(array_merge([$composer_exec, 'require'], $options));
$process->setWorkingDirectory($tmp_dir); self::prepareProcess($process, $tmp_dir, $options);
// 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]);
}
Console::outDebug(sprintf('executing %s', $process->getCommandLine())); Console::outDebug(sprintf('executing %s', $process->getCommandLine()));
$process->run(function ($type, $buffer) { $process->run(function ($type, $buffer)
{
Console::out($buffer, false); Console::out($buffer, false);
}); });
@ -558,4 +550,206 @@
throw new ComposerNotAvailableException('No composer executable path is configured'); 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;
}
} }

View file

@ -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);
}
}
}

View 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