-
Notifications
You must be signed in to change notification settings - Fork 17
WIP: publish files for discussion #24
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,8 @@ | |
|
|
||
|
|
||
| class InstallAssetStepRunner extends BaseStepRunner { | ||
| // TODO following the github API - this is not an exposed step - maybe it's internals should be used by other steps and not extended? | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had the same thought, just couldn't think of the right names for things. |
||
| // especially since it is a functionality primarily focused on unzipping | ||
|
|
||
| protected function unzipAssetTo( $zipResource, $targetPath ) { | ||
| if ( ! file_exists( $targetPath ) ) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,16 +2,16 @@ | |
|
|
||
| namespace WordPress\Blueprints\Runner\Step; | ||
|
|
||
| use Symfony\Component\Filesystem\Exception\IOException; | ||
| use WordPress\Blueprints\BlueprintException; | ||
| use WordPress\Blueprints\Model\DataClass\MkdirStep; | ||
|
|
||
|
|
||
| class MkdirStepRunner extends BaseStepRunner { | ||
|
|
||
| function run( MkdirStep $input ) { | ||
| // @TODO: Treat $input->path as relative path to the document root (unless it's absolute) | ||
| $success = mkdir( $input->path ); | ||
| if ( ! $success ) { | ||
| throw new \Exception( "Failed to create directory at {$input->path}" ); | ||
| } | ||
| function run(MkdirStep $input) { | ||
| $path = $input->path; | ||
| $this->fileManager->assertNoFileExists($path); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line obscures that |
||
| $this->fileManager->mkdir($path); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| <?php | ||
|
|
||
| namespace WordPress\FileManager; | ||
|
|
||
| use Symfony\Component\Filesystem\Exception\IOException; | ||
| use Symfony\Component\Filesystem\Filesystem; | ||
| use Symfony\Component\Filesystem\Path; | ||
| use WordPress\Blueprints\BlueprintException; | ||
| use WordPress\Blueprints\Runtime\RuntimeInterface; | ||
|
|
||
| class FileManager { | ||
|
|
||
| private RuntimeInterface $runtime; | ||
|
|
||
| private Filesystem $filesystem; | ||
|
|
||
| function __construct(RuntimeInterface $runtime) { | ||
| $this->filesystem = new Filesystem(); | ||
| $this->runtime = $runtime; | ||
| } | ||
|
|
||
| public function toAbsolutePath(string $path): string { | ||
| return Path::makeAbsolute($path, $this->runtime->getDocumentRoot()); | ||
| } | ||
|
|
||
| public function mkdir(string $path): void { | ||
| $absolutePath = $this->toAbsolutePath($path); | ||
| try { | ||
| $this->filesystem->mkdir($absolutePath); | ||
| } catch (IOException $exception) { | ||
| throw new BlueprintException("Failed to create directory at $absolutePath.", 0, $exception); | ||
| } | ||
| } | ||
|
|
||
| public function assertFileExists($path) { | ||
| $absolutePath = $this->toAbsolutePath($path); | ||
| if (!file_exists($absolutePath)) { | ||
| throw new BlueprintException("Fail. No file at \"$absolutePath\" exists."); | ||
| } | ||
| } | ||
|
|
||
| public function rename(string $fromPath, string $toPath): void { | ||
| $absoluteFromPath = $this->toAbsolutePath($fromPath); | ||
| $absoluteToPath = $this->toAbsolutePath($toPath); | ||
| $isSuccessful = rename($absoluteFromPath, $absoluteToPath); | ||
| if (!$isSuccessful) { | ||
| throw new BlueprintException( "Failed to move the file from \"$absoluteFromPath\" at \"$absoluteToPath\"." ); | ||
| } | ||
| } | ||
|
|
||
| public function assertNoFileExists($path): void { | ||
| $absolutePath = $this->toAbsolutePath($path); | ||
| if (!file_exists($absolutePath)) { | ||
| return; | ||
| } | ||
| if (is_dir($absolutePath)) { | ||
| throw new BlueprintException("Fail. A directory at \"$absolutePath\" exists."); | ||
| } | ||
| if (is_file($absolutePath)) { | ||
| throw new BlueprintException("Fail. A file at \"$absolutePath\" exists."); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| <?php | ||
|
|
||
| use \WordPress\Blueprints\Compiler; | ||
|
|
||
| it('Compiler should validate Blueprints', function () { | ||
| $c = new Compiler(); | ||
| $c->compile([ | ||
| 'steps' => [] | ||
| ]); | ||
| }); | ||
| //use \WordPress\Blueprints\Compiler; | ||
| // | ||
| //it('Compiler should validate Blueprints', function () { | ||
| // $c = new Compiler(); | ||
| // $c->compile([ | ||
| // 'steps' => [] | ||
| // ]); | ||
| //}); |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Installation is a separate step. The developer may not want to run the installation wizard automatically.