Skip to content

Commit 00d5ce0

Browse files
committed
Rearrange config file. Ignore ! in excluded paths. Add warm command
1 parent d3ba88f commit 00d5ce0

File tree

4 files changed

+54
-21
lines changed

4 files changed

+54
-21
lines changed

config/sidecar.php

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@
1616
*/
1717
'env' => env('SIDECAR_ENV', env('APP_ENV')),
1818

19+
/*
20+
* The default timeout for your functions, in seconds.
21+
* This can be overridden per function.
22+
*/
23+
'timeout' => env('SIDECAR_TIMEOUT', 300),
24+
25+
/*
26+
* The default memory for your functions, in megabytes.
27+
* This can be overridden per function.
28+
*/
29+
'memory' => env('SIDECAR_MEMORY', 512),
30+
31+
/*
32+
* The base path for your package files. If you e.g. keep
33+
* all your Lambda package files in your resource path,
34+
* you may change the base path here.
35+
*/
36+
'package_base_path' => env('SIDECAR_PACKAGE_BASE_PATH', base_path()),
37+
1938
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2039
* *
2140
* You are welcome to edit this configuration directly, or you can run *
@@ -42,8 +61,9 @@
4261
'aws_region' => env('SIDECAR_REGION'),
4362

4463
/*
45-
* The bucket that temporarily holds your function's ZIP files as they
46-
* are deployed to Lambda. It must be the same region as your Lambdas.
64+
* The bucket that temporarily holds your function's ZIP files
65+
* while they are deployed to Lambda. It must be in the same
66+
* region as your functions.
4767
*/
4868
'aws_bucket' => env('SIDECAR_ARTIFACT_BUCKET_NAME'),
4969

@@ -53,23 +73,4 @@
5373
* See CreateExecutionRole::policy for the IAM policy.
5474
*/
5575
'execution_role' => env('SIDECAR_EXECUTION_ROLE'),
56-
57-
/*
58-
* The default timeout for your functions, in seconds.
59-
* This can be overridden per function.
60-
*/
61-
'timeout' => env('SIDECAR_TIMEOUT', 300),
62-
63-
/*
64-
* The default memory for your functions, in megabytes.
65-
* This can be overridden per function.
66-
*/
67-
'memory' => env('SIDECAR_MEMORY', 512),
68-
69-
/*
70-
* The base path for your package files. If you e.g. keep
71-
* all your Lambda package files in your resource path,
72-
* you may change the base path here.
73-
*/
74-
'package_base_path' => env('SIDECAR_PACKAGE_BASE_PATH', base_path()),
7576
];

src/Package.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ public function include($paths)
8484
*/
8585
public function exclude($paths)
8686
{
87+
// If someone passed e.g. "!ignore.js", we'll just silently
88+
// strip it off here. The array style happily accepts the
89+
// exclamation as a negate flag, and I can see that
90+
// causing unnecessary DX issues.
91+
$paths = array_map(function ($path) {
92+
if (Str::startsWith($path, '!')) {
93+
$path = Str::replaceFirst('!', '', $path);
94+
}
95+
96+
return $path;
97+
}, Arr::wrap($paths));
98+
8799
$this->exclude = array_merge($this->exclude, $this->pathsForMerging($paths));
88100

89101
$this->files = null;

src/Providers/SidecarServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Hammerstone\Sidecar\Commands\Configure;
1212
use Hammerstone\Sidecar\Commands\Deploy;
1313
use Hammerstone\Sidecar\Commands\Install;
14+
use Hammerstone\Sidecar\Commands\Warm;
1415
use Hammerstone\Sidecar\Manager;
1516
use Illuminate\Support\ServiceProvider;
1617

@@ -56,6 +57,7 @@ public function boot()
5657
$this->commands([
5758
Activate::class,
5859
Configure::class,
60+
Warm::class,
5961
Deploy::class,
6062
Install::class,
6163
]);

tests/Unit/PackageTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,24 @@ public function it_excludes_files()
151151
}
152152
}
153153

154+
/** @test */
155+
public function an_exclamation_excludes_is_ignored()
156+
{
157+
$package = Package::make()
158+
->include([
159+
'include',
160+
])
161+
->exclude([
162+
'!exclude',
163+
]);
164+
165+
$this->assertCount(1, $package->getIncludedPaths());
166+
$this->assertStringContainsString('include', $package->getIncludedPaths()[0]);
167+
168+
$this->assertCount(1, $package->getExcludedPaths());
169+
$this->assertStringContainsString('exclude', $package->getExcludedPaths()[0]);
170+
}
171+
154172
/** @test */
155173
public function hashes_are_stable()
156174
{

0 commit comments

Comments
 (0)