@kirschbaum-development/sst-laravel 0.0.13 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,21 +41,22 @@ npx sst-laravel init
41
41
  To start using, you only need to import the component in your `sst.config.ts` file:
42
42
 
43
43
  ```ts
44
- import { Laravel } from "@kirschbaum-development/sst-laravel";
44
+ import { LaravelService } from "@kirschbaum-development/sst-laravel";
45
45
  ```
46
46
 
47
47
  And now you can start using the `Laravel` SST component. All the configuration options are Typescript files with documentation, so
48
48
 
49
49
  To check the full list of options. check [here](https://github.com/kirschbaum-development/sst-laravel/blob/main/docs/api.md).
50
50
 
51
- ### HTTP
51
+ ### Web (HTTP)
52
52
 
53
- Setting up your app to receive HTTP requests, on the `laravel-sst-demo.kdg.dev` domain (with SSL), with auto-scaling with a max of 3 servers.
53
+ Below is an example of setting up your application to receive HTTP requests, on the `laravel-sst-demo.example.com` domain (with SSL), with auto-scaling with a max of 3 servers.
54
54
 
55
55
  ```js
56
- const app = new Laravel('MyLaravelApp', {
56
+ const app = new LaravelService('MyLaravelApp', {
57
57
  web: {
58
- domain: 'laravel-sst-demo.kdg.dev',
58
+ dns: sst.cloudflare.dns(),
59
+ domain: 'laravel-sst-demo.example.com',
59
60
  scaling: {
60
61
  min: 1,
61
62
  max: 3,
@@ -64,6 +65,8 @@ const app = new Laravel('MyLaravelApp', {
64
65
  });
65
66
  ```
66
67
 
68
+ Check all the `web` options [here](https://github.com/kirschbaum-development/sst-laravel/blob/main/docs/api.md#web).
69
+
67
70
  ### Workers
68
71
 
69
72
  Beyond HTTP requests, you can set up one or more `workers` for your Laravel application. Workers are meant to run background commands like Laravel Horizon, the Laravel Scheduler or any background command you may need to run.
@@ -74,7 +77,7 @@ SST Laravel will automatically deploy and configure worker containers running yo
74
77
  **Running the Laravel scheduler**
75
78
 
76
79
  ```js
77
- const app = new Laravel('MyLaravelApp', {
80
+ const app = new LaravelService('MyLaravelApp', {
78
81
  workers: [
79
82
  {
80
83
  name: 'scheduler',
@@ -87,7 +90,7 @@ const app = new Laravel('MyLaravelApp', {
87
90
  **Running the Laravel Horizon**
88
91
 
89
92
  ```js
90
- const app = new Laravel('MyLaravelApp', {
93
+ const app = new LaravelService('MyLaravelApp', {
91
94
  workers: [
92
95
  {
93
96
  name: 'horizon',
@@ -100,7 +103,7 @@ const app = new Laravel('MyLaravelApp', {
100
103
  **Running custom commands**
101
104
 
102
105
  ```js
103
- const app = new Laravel('MyLaravelApp', {
106
+ const app = new LaravelService('MyLaravelApp', {
104
107
  workers: [
105
108
  {
106
109
  name: 'worker',
@@ -120,6 +123,8 @@ const app = new Laravel('MyLaravelApp', {
120
123
  });
121
124
  ```
122
125
 
126
+ Check all the `workers` options [here](https://github.com/kirschbaum-development/sst-laravel/blob/main/docs/api.md#workers).
127
+
123
128
  ## Environment Variables
124
129
 
125
130
  There are multiple ways to configure environment variables. If you want SST Laravel to copy an environment file, you can configure the `config.environment.file` entry.
@@ -127,7 +132,7 @@ There are multiple ways to configure environment variables. If you want SST Lara
127
132
  The below configuration would copy a file named `.env.$STAGE` (e.g. `.env.production`) into the deployment containers as your `.env` file.
128
133
 
129
134
  ```js
130
- const app = new Laravel('MyLaravelApp', {
135
+ const app = new LaravelService('MyLaravelApp', {
131
136
  // ...
132
137
  config: {
133
138
  environment: {
@@ -140,7 +145,7 @@ const app = new Laravel('MyLaravelApp', {
140
145
  You can also configure it to use simply `.env`.
141
146
 
142
147
  ```js
143
- const app = new Laravel('MyLaravelApp', {
148
+ const app = new LaravelService('MyLaravelApp', {
144
149
  // ...
145
150
  config: {
146
151
  environment: {
@@ -161,7 +166,7 @@ const database = new sst.aws.Postgres('MyDatabase', { vpc });
161
166
  const redis = new sst.aws.Redis("MyRedis", { vpc });
162
167
  const bucket = new sst.aws.Bucket("MyBucket");
163
168
 
164
- const app = new Laravel('MyLaravelApp', {
169
+ const app = new LaravelService('MyLaravelApp', {
165
170
  link: [database, redis, bucket],
166
171
  });
167
172
  ```
@@ -175,7 +180,7 @@ You can also [import existing resources](https://sst.dev/docs/import-resources/)
175
180
  If you need to customize the environment variable names for your resources, you can provide an object with the resource and a callback function in the `link` array:
176
181
 
177
182
  ```js
178
- const app = new Laravel('MyLaravelApp', {
183
+ const app = new LaravelService('MyLaravelApp', {
179
184
  link: [
180
185
  email,
181
186
  {
@@ -223,7 +228,7 @@ The IAM permissions for the linked resources are also automatically added to the
223
228
  You can configure the PHP version, custom environment variables and a custom deployment script.
224
229
 
225
230
  ```js
226
- const app = new Laravel('MyLaravelApp', {
231
+ const app = new LaravelService('MyLaravelApp', {
227
232
  config: {
228
233
  php: 8.4,
229
234
  opcache: true,
package/laravel-sst.ts CHANGED
@@ -202,7 +202,7 @@ export interface LaravelArgs extends ClusterArgs {
202
202
  }
203
203
  }
204
204
 
205
- export class Laravel extends Component {
205
+ export class LaravelService extends Component {
206
206
  private readonly services: Record<string, sst.aws.Service>;
207
207
 
208
208
  constructor(
@@ -483,8 +483,17 @@ export class Laravel extends Component {
483
483
  ...customEnv,
484
484
  };
485
485
 
486
- // TODO: Write resourcesEnvVars to the .env file
487
- // TODO: Add proper types
486
+ const envFile = path.resolve(pluginBuildPath, 'deploy', '.env');
487
+
488
+ all(Object.entries(resourcesEnvVars)).apply(entries => {
489
+ const envContent = entries
490
+ .map(([key, value]) => `${key}=${value}`)
491
+ .join('\n');
492
+
493
+ if (envContent) {
494
+ fs.appendFileSync(envFile, '\n' + envContent);
495
+ }
496
+ });
488
497
  };
489
498
 
490
499
  /**
@@ -555,6 +564,6 @@ export class Laravel extends Component {
555
564
  }
556
565
  }
557
566
 
558
- const __pulumiType = "sst:aws:Laravel";
567
+ const __pulumiType = "sst:aws:LaravelService";
559
568
  // @ts-expect-error
560
- Laravel.__pulumiType = __pulumiType;
569
+ LaravelService.__pulumiType = __pulumiType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kirschbaum-development/sst-laravel",
3
- "version": "0.0.13",
3
+ "version": "0.0.19",
4
4
  "type": "module",
5
5
  "description": "An unofficial extension of SST to deploy containerized Laravel applications to AWS Fargate.",
6
6
  "main": "laravel-sst.ts",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "homepage": "https://github.com/kirschbaum-development/sst-laravel#readme",
43
43
  "bin": {
44
- "sst-laravel": "./dist/bin/cli.js"
44
+ "sst-laravel": "dist/bin/cli.js"
45
45
  },
46
46
  "dependencies": {
47
47
  "@aws-sdk/client-ecs": "^3.0.0",
@@ -1,11 +1,11 @@
1
- const { Laravel } = await import("@kirschbaum-development/sst-laravel");
1
+ const { LaravelService } = await import("@kirschbaum-development/sst-laravel");
2
2
  const vpc = new sst.aws.Vpc("MyVpc");
3
3
  // you can also use an existing VPC
4
4
  // const vpc = sst.aws.Vpc.get("DefaultVpc", "vpc-12345678901234567");
5
5
 
6
6
  const database = new sst.aws.Postgres('MyDB', { vpc });
7
7
 
8
- const app = new Laravel("MyLaravelApp", {
8
+ const app = new LaravelService("MyLaravelApp", {
9
9
  vpc,
10
10
  link: [database],
11
11