Skip to content

Commit 45e0469

Browse files
Merge pull request #3 from codenamephp/main
Compatibility with registerTask()
2 parents 89fc2b1 + ec16d9a commit 45e0469

14 files changed

Lines changed: 120 additions & 8 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [1.0.0](https://github.com/codenamephp/deployer.npm/tree/1.0.0) (2022-02-06)
4+
5+
[Full Changelog](https://github.com/codenamephp/deployer.npm/compare/3ba187fd8d4c1c5ca4ce8d64c8621c9b668b25ca...1.0.0)
6+
37

48

59
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*

MIGRATION.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Migration
2+
3+
Contains all information needed to migrate between major versions
4+
5+
## 1.x -> 2.x
6+
7+
Added `\de\codenamephp\deployer\base\task\iTaskWithName` and `\de\codenamephp\deployer\base\task\iTaskWithDescription` to
8+
`\de\codenamephp\deployer\npm\task\run\AbstractRunTask` and `\de\codenamephp\deployer\npm\task\AbstractNpmTask` classes so if you extended those you need to
9+
implement those methods.
10+
11+
Also `\de\codenamephp\deployer\npm\task\run\Generic::__construct` now has a mandatory `$taskName` parameter and an optional description parameter:
12+
13+
```
14+
public function __construct(string $scriptName,
15+
+ public string $taskName,
16+
array $arguments = [],
17+
+ public string $taskDescription = '',
18+
iNpmRunCommandFactory $commandFactory = new DecorateCommandFactory(),
19+
20+
```
21+
22+
so you need to update any instantiations.

src/task/AbstractNpmTask.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
namespace de\codenamephp\deployer\npm\task;
1919

20-
use de\codenamephp\deployer\base\task\iTask;
20+
use de\codenamephp\deployer\base\task\iTaskWithDescription;
21+
use de\codenamephp\deployer\base\task\iTaskWithName;
2122
use de\codenamephp\deployer\command\runner\iRunner;
2223
use de\codenamephp\deployer\command\runner\WithDeployerFunctions;
2324
use de\codenamephp\deployer\npm\command\iNpmCommandFactory;
@@ -26,9 +27,9 @@
2627
/**
2728
* Base class for npm command setting the binary to npm
2829
*/
29-
abstract class AbstractNpmTask implements iTask {
30+
abstract class AbstractNpmTask implements iTaskWithName, iTaskWithDescription {
3031

31-
public function __construct(public iNpmCommandFactory $commandFactory = new WithBinaryFromDeployer(), public iRunner $runner = new WithDeployerFunctions()) {}
32+
public function __construct(public iNpmCommandFactory $commandFactory = new WithBinaryFromDeployer(), public iRunner $runner = new WithDeployerFunctions()) { }
3233

3334
/**
3435
* Gets the command for npm, e.g. install or run-script

src/task/install/Development.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,17 @@
2222
*/
2323
final class Development extends AbstractInstallTask {
2424

25+
public const NAME = 'npm:install:development';
26+
2527
public function getArguments() : array {
2628
return ['--production=false'];
2729
}
30+
31+
public function getDescription() : string {
32+
return 'Runs npm install with the --production=false flag so development dependencies will be installed.';
33+
}
34+
35+
public function getName() : string {
36+
return self::NAME;
37+
}
2838
}

src/task/install/Production.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,17 @@
2222
*/
2323
final class Production extends AbstractInstallTask {
2424

25+
public const NAME = 'npm:install';
26+
2527
public function getArguments() : array {
2628
return ['--production'];
2729
}
30+
31+
public function getDescription() : string {
32+
return 'Runs npm install with the production flag to dev dependencies are not installed.';
33+
}
34+
35+
public function getName() : string {
36+
return self::NAME;
37+
}
2838
}

src/task/run/AbstractRunTask.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717

1818
namespace de\codenamephp\deployer\npm\task\run;
1919

20-
use de\codenamephp\deployer\base\task\iTask;
20+
use de\codenamephp\deployer\base\task\iTaskWithDescription;
21+
use de\codenamephp\deployer\base\task\iTaskWithName;
2122
use de\codenamephp\deployer\command\runner\iRunner;
2223
use de\codenamephp\deployer\command\runner\WithDeployerFunctions;
2324
use de\codenamephp\deployer\npm\command\run\DecorateCommandFactory;
2425
use de\codenamephp\deployer\npm\command\run\iNpmRunCommandFactory;
2526

26-
abstract class AbstractRunTask implements iTask {
27+
abstract class AbstractRunTask implements iTaskWithName, iTaskWithDescription {
2728

28-
public function __construct(public iNpmRunCommandFactory $commandFactory = new DecorateCommandFactory(), public iRunner $runner = new WithDeployerFunctions()) {}
29+
public function __construct(public iNpmRunCommandFactory $commandFactory = new DecorateCommandFactory(), public iRunner $runner = new WithDeployerFunctions()) { }
2930

3031
abstract public function getScriptName() : string;
3132

src/task/run/Generic.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ final class Generic extends AbstractRunTask {
3838
* @param iRunner $runner The runner that runs the command. Will be passed to parent.
3939
*/
4040
public function __construct(string $scriptName,
41+
public string $taskName,
4142
array $arguments = [],
43+
public string $taskDescription = '',
4244
iNpmRunCommandFactory $commandFactory = new DecorateCommandFactory(),
4345
iRunner $runner = new WithDeployerFunctions()) {
4446
parent::__construct($commandFactory, $runner);
@@ -53,4 +55,12 @@ public function getScriptName() : string {
5355
public function getArguments() : array {
5456
return $this->arguments;
5557
}
58+
59+
public function getDescription() : string {
60+
return $this->taskDescription;
61+
}
62+
63+
public function getName() : string {
64+
return $this->taskName;
65+
}
5666
}

src/task/run/build/Development.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
final class Development extends AbstractRunTask {
2626

27+
public const NAME = 'npm:build:development';
28+
2729
public function getScriptName() : string {
2830
return 'build:development';
2931
}
@@ -32,4 +34,11 @@ public function getArguments() : array {
3234
return [];
3335
}
3436

37+
public function getDescription() : string {
38+
return 'Runs the npm build script that builds the assets for development (without minifying, compression, ...).';
39+
}
40+
41+
public function getName() : string {
42+
return self::NAME;
43+
}
3544
}

src/task/run/build/Production.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
final class Production extends AbstractRunTask {
2626

27+
public const NAME = 'npm:build';
28+
2729
public function getScriptName() : string {
2830
return 'build';
2931
}
@@ -32,4 +34,11 @@ public function getArguments() : array {
3234
return [];
3335
}
3436

37+
public function getDescription() : string {
38+
return 'Runs the npm build script that builds the assets for production (with minifying, compression, ...).';
39+
}
40+
41+
public function getName() : string {
42+
return self::NAME;
43+
}
3544
}

test/task/install/DevelopmentTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,12 @@ protected function setUp() : void {
3838
public function testGetArguments() : void {
3939
self::assertEquals(['--production=false'], $this->sut->getArguments());
4040
}
41+
42+
public function testGetName() : void {
43+
self::assertEquals(Development::NAME, $this->sut->getName());
44+
}
45+
46+
public function testGEtDescription() : void {
47+
self::assertEquals('Runs npm install with the --production=false flag so development dependencies will be installed.', $this->sut->getDescription());
48+
}
4149
}

0 commit comments

Comments
 (0)