-
-
Notifications
You must be signed in to change notification settings - Fork 834
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'extensions_package_manager/REWRITE'
- Loading branch information
Showing
104 changed files
with
8,786 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.{diff,md}] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{php,xml,json}] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.gitmodules export-ignore | ||
.github export-ignore | ||
.travis export-ignore | ||
.travis.yml export-ignore | ||
.editorconfig export-ignore | ||
.styleci.yml export-ignore | ||
|
||
phpunit.xml export-ignore | ||
tests export-ignore | ||
|
||
js/dist/* -diff | ||
js/dist/* linguist-generated | ||
js/dist-typings/* linguist-generated | ||
js/yarn.lock -diff | ||
js/package-lock.json -diff | ||
|
||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Package Manager PHP | ||
|
||
on: [workflow_dispatch, push, pull_request] | ||
|
||
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon. | ||
# This will break your current script. | ||
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure. | ||
|
||
jobs: | ||
run: | ||
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@as/support-npm-yarn | ||
with: | ||
enable_backend_testing: true | ||
|
||
backend_directory: . | ||
|
||
php_versions: '["7.4", "8.0"]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Package Manager JS | ||
|
||
on: [workflow_dispatch, push, pull_request] | ||
|
||
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon. | ||
# This will break your current script. | ||
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure. | ||
|
||
jobs: | ||
run: | ||
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@as/support-npm-yarn | ||
with: | ||
enable_bundlewatch: false | ||
enable_prettier: true | ||
enable_typescript: true | ||
|
||
frontend_directory: ./js | ||
backend_directory: . | ||
package_manager: yarn | ||
main_git_branch: main | ||
|
||
secrets: | ||
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/vendor | ||
composer.lock | ||
composer.phar | ||
|
||
.DS_Store | ||
Thumbs.db | ||
tests/.phpunit.result.cache | ||
/tests/integration/tmp | ||
.vagrant | ||
.idea/* | ||
.vscode | ||
js/coverage-ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
preset: recommended | ||
|
||
enabled: | ||
- logical_not_operators_with_successor_space | ||
|
||
disabled: | ||
- align_double_arrow | ||
- blank_line_after_opening_tag | ||
- multiline_array_trailing_comma | ||
- new_with_braces | ||
- phpdoc_align | ||
- phpdoc_order | ||
- phpdoc_separation | ||
- phpdoc_types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) Sami Mazouz | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Package Manager | ||
|
||
*An Experiment.* | ||
|
||
Read: https://github.com/flarum/package-manager/wiki |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
{ | ||
"name": "flarum/package-manager", | ||
"description": "A Flarum Package Manager.", | ||
"keywords": [ | ||
"extensions", | ||
"composer", | ||
"packages", | ||
"manager", | ||
"updater" | ||
], | ||
"type": "flarum-extension", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Flarum", | ||
"email": "info@flarum.org", | ||
"homepage": "https://flarum.org/team" | ||
} | ||
], | ||
"support": { | ||
"issues": "https://github.com/flarum/package-manager/issues", | ||
"source": "https://github.com/flarum/package-manager" | ||
}, | ||
"require": { | ||
"flarum/core": "^1.0.0", | ||
"composer/composer": "^2.0" | ||
}, | ||
"require-dev": { | ||
"flarum/testing": "^1.0.0", | ||
"flarum/tags": "*" | ||
}, | ||
"extra": { | ||
"flarum-extension": { | ||
"title": "Package Manager", | ||
"icon": { | ||
"name": "fas fa-box-open", | ||
"backgroundColor": "#117187", | ||
"color": "#fff" | ||
} | ||
}, | ||
"flarum-cli": { | ||
"excludeScaffolding": [ | ||
".github/workflows/backend.yml", | ||
"js/src/admin/index.ts", | ||
"tests/phpunit.integration.xml", | ||
"tests/integration/setup.php" | ||
], | ||
"excludeScaffoldingConfigKeys": { | ||
"composer.json": [ | ||
"scripts.test:setup" | ||
] | ||
}, | ||
"modules": { | ||
"admin": true, | ||
"forum": false, | ||
"js": true, | ||
"jsCommon": false, | ||
"css": true, | ||
"gitConf": true, | ||
"githubActions": true, | ||
"prettier": true, | ||
"typescript": true, | ||
"bundlewatch": false, | ||
"backendTesting": true, | ||
"editorConfig": true, | ||
"styleci": true | ||
} | ||
} | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Flarum\\PackageManager\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Flarum\\PackageManager\\Tests\\": "tests/" | ||
} | ||
}, | ||
"scripts": { | ||
"test": [ | ||
"@test:unit", | ||
"@test:integration" | ||
], | ||
"test:unit": "phpunit -c tests/phpunit.unit.xml", | ||
"test:integration": "phpunit -c tests/phpunit.integration.xml", | ||
"test:setup": [ | ||
"@php tests/integration/setup.php", | ||
"cd $FLARUM_TEST_TMP_DIR_LOCAL && composer install" | ||
] | ||
}, | ||
"scripts-descriptions": { | ||
"test": "Runs all tests.", | ||
"test:unit": "Runs all unit tests.", | ||
"test:integration": "Runs all integration tests.", | ||
"test:setup": "Sets up a database for use with integration tests. Execute this only once." | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Flarum. | ||
* | ||
* For detailed copyright and license information, please view the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Flarum\PackageManager; | ||
|
||
use Flarum\Extend; | ||
use Flarum\Foundation\Paths; | ||
use Flarum\Frontend\Document; | ||
use Flarum\PackageManager\Exception\ComposerCommandFailedException; | ||
use Flarum\PackageManager\Exception\ExceptionHandler; | ||
use Flarum\PackageManager\Exception\ComposerRequireFailedException; | ||
use Flarum\PackageManager\Exception\ComposerUpdateFailedException; | ||
use Flarum\PackageManager\Exception\MajorUpdateFailedException; | ||
use Flarum\PackageManager\Settings\LastUpdateCheck; | ||
use Flarum\PackageManager\Settings\LastUpdateRun; | ||
|
||
return [ | ||
(new Extend\Routes('api')) | ||
->post('/package-manager/extensions', 'package-manager.extensions.require', Api\Controller\RequireExtensionController::class) | ||
->patch('/package-manager/extensions/{id}', 'package-manager.extensions.update', Api\Controller\UpdateExtensionController::class) | ||
->delete('/package-manager/extensions/{id}', 'package-manager.extensions.remove', Api\Controller\RemoveExtensionController::class) | ||
->post('/package-manager/check-for-updates', 'package-manager.check-for-updates', Api\Controller\CheckForUpdatesController::class) | ||
->post('/package-manager/why-not', 'package-manager.why-not', Api\Controller\WhyNotController::class) | ||
->post('/package-manager/minor-update', 'package-manager.minor-update', Api\Controller\MinorUpdateController::class) | ||
->post('/package-manager/major-update', 'package-manager.major-update', Api\Controller\MajorUpdateController::class) | ||
->post('/package-manager/global-update', 'package-manager.global-update', Api\Controller\GlobalUpdateController::class), | ||
|
||
(new Extend\Frontend('admin')) | ||
->css(__DIR__ . '/less/admin.less') | ||
->js(__DIR__ . '/js/dist/admin.js') | ||
->content(function (Document $document) { | ||
$paths = resolve(Paths::class); | ||
|
||
$document->payload['isRequiredDirectoriesWritable'] = is_writable($paths->vendor) | ||
&& is_writable($paths->storage.'/.composer') | ||
&& is_writable($paths->base.'/composer.json') | ||
&& is_writable($paths->base.'/composer.lock'); | ||
}), | ||
|
||
new Extend\Locales(__DIR__ . '/locale'), | ||
|
||
(new Extend\Settings()) | ||
->default(LastUpdateCheck::key(), json_encode(LastUpdateCheck::default())) | ||
->default(LastUpdateRun::key(), json_encode(LastUpdateRun::default())), | ||
|
||
(new Extend\ServiceProvider) | ||
->register(PackageManagerServiceProvider::class), | ||
|
||
(new Extend\ErrorHandling) | ||
->handler(ComposerCommandFailedException::class, ExceptionHandler::class) | ||
->handler(ComposerRequireFailedException::class, ExceptionHandler::class) | ||
->handler(ComposerUpdateFailedException::class, ExceptionHandler::class) | ||
->handler(MajorUpdateFailedException::class, ExceptionHandler::class) | ||
->status('extension_already_installed', 409) | ||
->status('extension_not_installed', 409) | ||
->status('no_new_major_version', 409), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.pnp.* | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
|
||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './src/admin'; |
20 changes: 20 additions & 0 deletions
20
extensions/package-manager/js/dist-typings/components/ExtensionItem.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Mithril from 'mithril'; | ||
import Component, { ComponentAttrs } from 'flarum/common/Component'; | ||
import { Extension as BaseExtension } from 'flarum/admin/AdminApplication'; | ||
import { UpdatedPackage } from './Updater'; | ||
export declare type Extension = BaseExtension & { | ||
name: string; | ||
}; | ||
export interface ExtensionItemAttrs extends ComponentAttrs { | ||
extension: Extension; | ||
updates: UpdatedPackage; | ||
onClickUpdate: CallableFunction; | ||
whyNotWarning?: boolean; | ||
isCore?: boolean; | ||
updatable?: boolean; | ||
isDanger?: boolean; | ||
} | ||
export default class ExtensionItem<Attrs extends ExtensionItemAttrs = ExtensionItemAttrs> extends Component<Attrs> { | ||
view(vnode: Mithril.Vnode<Attrs, this>): Mithril.Children; | ||
private version; | ||
} |
11 changes: 11 additions & 0 deletions
11
extensions/package-manager/js/dist-typings/components/Installer.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type Mithril from 'mithril'; | ||
import Component from 'flarum/common/Component'; | ||
import Stream from 'flarum/common/utils/Stream'; | ||
export default class Installer<Attrs> extends Component<Attrs> { | ||
packageName: Stream<string>; | ||
isLoading: boolean; | ||
oninit(vnode: Mithril.Vnode<Attrs, this>): void; | ||
view(): Mithril.Children; | ||
data(): any; | ||
onsubmit(): void; | ||
} |
15 changes: 15 additions & 0 deletions
15
extensions/package-manager/js/dist-typings/components/MajorUpdater.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Component, { ComponentAttrs } from 'flarum/common/Component'; | ||
import Mithril from 'mithril'; | ||
import { UpdatedPackage, UpdateState } from './Updater'; | ||
interface MajorUpdaterAttrs extends ComponentAttrs { | ||
coreUpdate: UpdatedPackage; | ||
updateState: UpdateState; | ||
} | ||
export default class MajorUpdater<T extends MajorUpdaterAttrs = MajorUpdaterAttrs> extends Component<T> { | ||
isLoading: string | null; | ||
updateState: UpdateState; | ||
oninit(vnode: Mithril.Vnode<T, this>): void; | ||
view(vnode: Mithril.Vnode<T, this>): Mithril.Children; | ||
update(dryRun: boolean): void; | ||
} | ||
export {}; |
Oops, something went wrong.