Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Refactor CLI interaction with Silverstripe app #11353

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions _config/cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
Name: cli-config
---
SilverStripe\Core\Injector\Injector:
Symfony\Contracts\EventDispatcher\EventDispatcherInterface.sake:
class: 'Symfony\Component\EventDispatcher\EventDispatcher'
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
Symfony\Component\Console\Formatter\OutputFormatterInterface:
class: 'Symfony\Component\Console\Formatter\OutputFormatter'
calls:
- ['setDecorated', [true]]
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
SilverStripe\PolyExecution\HtmlOutputFormatter:
constructor:
formatter: '%$Symfony\Component\Console\Formatter\OutputFormatterInterface'
6 changes: 1 addition & 5 deletions _config/confirmation-middleware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@ SilverStripe\Core\Injector\Injector:
class: SilverStripe\Control\Middleware\ConfirmationMiddleware\EnvironmentBypass
type: prototype

SilverStripe\Control\Middleware\ConfirmationMiddleware\CliBypass:
class: SilverStripe\Control\Middleware\ConfirmationMiddleware\CliBypass
type: prototype
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved

SilverStripe\Control\Middleware\ConfirmationMiddleware\HttpMethodBypass:
class: SilverStripe\Control\Middleware\ConfirmationMiddleware\HttpMethodBypass
type: prototype

SilverStripe\Control\Middleware\ConfirmationMiddleware\Url:
class: SilverStripe\Control\Middleware\ConfirmationMiddleware\Url
type: prototype
type: prototype
25 changes: 12 additions & 13 deletions _config/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
Name: DevelopmentAdmin
---
SilverStripe\Dev\DevelopmentAdmin:
registered_controllers:
build:
controller: SilverStripe\Dev\DevBuildController
links:
build: 'Build/rebuild this environment. Call this whenever you have updated your project sources'
commands:
build: 'SilverStripe\Dev\Command\DbBuild'
'build/cleanup': 'SilverStripe\Dev\Command\DbCleanup'
'build/defaults': 'SilverStripe\Dev\Command\DbDefaults'
config: 'SilverStripe\Dev\Command\ConfigDump'
'config/audit': 'SilverStripe\Dev\Command\ConfigAudit'
generatesecuretoken: 'SilverStripe\Dev\Command\GenerateSecureToken'
controllers:
tasks:
controller: SilverStripe\Dev\TaskRunner
links:
tasks: 'See a list of build tasks to run'
class: 'SilverStripe\Dev\TaskRunner'
description: 'See a list of build tasks to run'
confirm:
controller: SilverStripe\Dev\DevConfirmationController
config:
controller: Silverstripe\Dev\DevConfigController
links:
config: 'View the current config, useful for debugging'
class: 'SilverStripe\Dev\DevConfirmationController'
skipLink: true

SilverStripe\Dev\CSSContentParser:
disable_xml_external_entities: true
4 changes: 2 additions & 2 deletions _config/extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ SilverStripe\Security\Member:
SilverStripe\Security\Group:
extensions:
- SilverStripe\Security\InheritedPermissionFlusher
SilverStripe\ORM\DatabaseAdmin:
SilverStripe\Dev\Command\DbBuild:
extensions:
- SilverStripe\Dev\Validation\DatabaseAdminExtension
- SilverStripe\Dev\Validation\DbBuildExtension
4 changes: 2 additions & 2 deletions _config/logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Only:
# Dev handler outputs detailed information including notices
SilverStripe\Core\Injector\Injector:
Monolog\Handler\HandlerInterface:
class: SilverStripe\Logging\HTTPOutputHandler
class: SilverStripe\Logging\ErrorOutputHandler
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
constructor:
- "notice"
properties:
Expand All @@ -66,7 +66,7 @@ Except:
# CLI errors still show full details
SilverStripe\Core\Injector\Injector:
Monolog\Handler\HandlerInterface:
class: SilverStripe\Logging\HTTPOutputHandler
class: SilverStripe\Logging\ErrorOutputHandler
constructor:
- "error"
properties:
Expand Down
2 changes: 0 additions & 2 deletions _config/requestprocessors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ SilverStripe\Core\Injector\Injector:
ConfirmationStorageId: 'url-specials'
ConfirmationFormUrl: '/dev/confirm'
Bypasses:
- '%$SilverStripe\Control\Middleware\ConfirmationMiddleware\CliBypass'
- '%$SilverStripe\Control\Middleware\ConfirmationMiddleware\EnvironmentBypass("dev")'
- '%$SilverStripe\Control\Middleware\ConfirmationMiddleware\UrlPathStartswith("dev/confirm")'
EnforceAuthentication: true
Expand Down Expand Up @@ -94,7 +93,6 @@ SilverStripe\Core\Injector\Injector:
ConfirmationStorageId: 'dev-urls'
ConfirmationFormUrl: '/dev/confirm'
Bypasses:
- '%$SilverStripe\Control\Middleware\ConfirmationMiddleware\CliBypass'
- '%$SilverStripe\Control\Middleware\ConfirmationMiddleware\EnvironmentBypass("dev")'
EnforceAuthentication: false

Expand Down
15 changes: 15 additions & 0 deletions bin/sake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env php
<?php

use SilverStripe\Cli\Sake;

// Ensure that people can't access this from a web-server
if (!in_array(PHP_SAPI, ['cli', 'cgi', 'cgi-fcgi'])) {
echo 'sake cannot be run from a web request, you have to run it on the command-line.';
die();
}

require_once __DIR__ . '/../src/includes/autoload.php';

$sake = new Sake();
$sake->run();
35 changes: 0 additions & 35 deletions cli-script.php

This file was deleted.

40 changes: 35 additions & 5 deletions client/styles/debug.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ a:active {
}

/* Content types */
.build,
.options,
.trace {
position: relative;
Expand All @@ -128,22 +127,28 @@ a:active {
line-height: 1.3;
}

.build .success {
.options .success {
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
color: #2b6c2d;
}

.build .error {
.options .error {
color: #d30000;
}

.build .warning {
.options .warning {
color: #8a6d3b;
}

.build .info {
.options .info {
color: #0073c1;
}

.options .more-details {
border: 1px dotted;
width: fit-content;
padding: 5px;
}

/* Backtrace styles */
pre {
overflow: auto;
Expand All @@ -162,3 +167,28 @@ pre span {
pre .error {
color: #d30000;
}

.params {
margin-top: 0;
margin-left: 10px;
}

.param {
display: flex;
align-items: baseline;
}

.param__name {
display: inline-block;
font-weight: 200;
}

.param__name::after {
content: ": ";
}

.param__description {
display: inline-block;
margin-left: 0.5em;
font-style: italic;
}
6 changes: 6 additions & 0 deletions client/styles/task-runner.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
margin-bottom: 12px;
}

.task__help {
border: 1px dotted;
width: fit-content;
padding: 5px;
}

.task__button {
border: 1px solid #ced5e1;
border-radius: 5px;
Expand Down
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
],
"bin": [
"sake"
"bin/sake"
],
"require": {
"php": "^8.3",
Expand All @@ -36,12 +36,14 @@
"psr/container": "^1.1 || ^2.0",
"psr/http-message": "^1",
"sebastian/diff": "^6.0",
"sensiolabs/ansi-to-html": "^1.2",
"silverstripe/config": "^3",
"silverstripe/assets": "^3",
"silverstripe/vendor-plugin": "^2",
"sminnee/callbacklist": "^0.1.1",
"symfony/cache": "^7.0",
"symfony/config": "^7.0",
"symfony/console": "^7.0",
"symfony/dom-crawler": "^7.0",
"symfony/filesystem": "^7.0",
"symfony/http-foundation": "^7.0",
Expand Down Expand Up @@ -84,6 +86,8 @@
},
"autoload": {
"psr-4": {
"SilverStripe\\Cli\\": "src/Cli/",
"SilverStripe\\Cli\\Tests\\": "tests/php/Cli/",
"SilverStripe\\Control\\": "src/Control/",
"SilverStripe\\Control\\Tests\\": "tests/php/Control/",
"SilverStripe\\Core\\": "src/Core/",
Expand All @@ -100,6 +104,8 @@
"SilverStripe\\Model\\Tests\\": "tests/php/Model/",
"SilverStripe\\ORM\\": "src/ORM/",
"SilverStripe\\ORM\\Tests\\": "tests/php/ORM/",
"SilverStripe\\PolyExecution\\": "src/PolyExecution/",
"SilverStripe\\PolyExecution\\Tests\\": "tests/php/PolyExecution/",
"SilverStripe\\Security\\": "src/Security/",
"SilverStripe\\Security\\Tests\\": "tests/php/Security/",
"SilverStripe\\View\\": "src/View/",
Expand Down
Loading
Loading