abw-react-starter 1.0.2 → 1.0.4
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 +101 -2
- package/bin/create.js +26 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -87,6 +87,7 @@ If enabled, the CLI will:
|
|
|
87
87
|
|
|
88
88
|
* `plugins.ts`
|
|
89
89
|
* `middlewares.ts`
|
|
90
|
+
* `server.ts`
|
|
90
91
|
* Ask for:
|
|
91
92
|
|
|
92
93
|
* Bucket name
|
|
@@ -96,6 +97,94 @@ If enabled, the CLI will:
|
|
|
96
97
|
|
|
97
98
|
---
|
|
98
99
|
|
|
100
|
+
## ⚠️ S3 Bucket Configuration (IMPORTANT)
|
|
101
|
+
|
|
102
|
+
For image uploads to work correctly, your S3 bucket **must allow public read access**.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### 1. Block Public Access
|
|
107
|
+
|
|
108
|
+
Go to:
|
|
109
|
+
|
|
110
|
+
S3 → Your Bucket → Permissions → Block public access
|
|
111
|
+
|
|
112
|
+
Configure:
|
|
113
|
+
|
|
114
|
+
* ❌ Do NOT block all public access
|
|
115
|
+
* ✔ Allow public access (at least partially)
|
|
116
|
+
|
|
117
|
+
If everything is blocked, images **will not load in the browser**.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
### 2. Object Ownership (ACLs)
|
|
122
|
+
|
|
123
|
+
Go to:
|
|
124
|
+
|
|
125
|
+
S3 → Your Bucket → Permissions → Object Ownership
|
|
126
|
+
|
|
127
|
+
Set:
|
|
128
|
+
|
|
129
|
+
* ✔ ACLs enabled
|
|
130
|
+
|
|
131
|
+
This is required because Strapi uploads files using:
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
ACL: 'public-read'
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 🔓 What this means
|
|
140
|
+
|
|
141
|
+
* Uploaded images will be publicly accessible via URL:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
https://your-bucket.s3.region.amazonaws.com/image.jpg
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
* Only your backend (using AWS credentials) can:
|
|
148
|
+
|
|
149
|
+
* upload
|
|
150
|
+
* delete
|
|
151
|
+
* modify files
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 🔐 Is this secure?
|
|
156
|
+
|
|
157
|
+
Yes — this is standard practice for most web apps.
|
|
158
|
+
|
|
159
|
+
As long as you:
|
|
160
|
+
|
|
161
|
+
* ❌ do NOT expose your AWS credentials
|
|
162
|
+
* ✔ use restricted IAM permissions
|
|
163
|
+
|
|
164
|
+
your setup is safe.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 🚀 Advanced (optional)
|
|
169
|
+
|
|
170
|
+
For more advanced setups, you can later switch to:
|
|
171
|
+
|
|
172
|
+
* CloudFront (CDN)
|
|
173
|
+
* Private buckets + signed URLs
|
|
174
|
+
* Bucket policies instead of ACLs
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## 🧠 Summary
|
|
179
|
+
|
|
180
|
+
| Setting | Value |
|
|
181
|
+
| ----------------------- | ------------------- |
|
|
182
|
+
| Block Public Access | ❌ Not fully blocked |
|
|
183
|
+
| Object Ownership (ACLs) | ✔ Enabled |
|
|
184
|
+
| Upload ACL | public-read |
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
99
188
|
## 🔐 Requirements
|
|
100
189
|
|
|
101
190
|
Make sure you have installed:
|
|
@@ -129,8 +218,8 @@ npm run dev
|
|
|
129
218
|
|
|
130
219
|
```
|
|
131
220
|
my-app/
|
|
132
|
-
├── backend/
|
|
133
|
-
├── frontend/
|
|
221
|
+
├── backend/
|
|
222
|
+
├── frontend/
|
|
134
223
|
└── .abw-starter.json
|
|
135
224
|
```
|
|
136
225
|
|
|
@@ -164,6 +253,16 @@ The CLI will prompt you to login automatically.
|
|
|
164
253
|
|
|
165
254
|
---
|
|
166
255
|
|
|
256
|
+
### Images not loading (S3)
|
|
257
|
+
|
|
258
|
+
Check:
|
|
259
|
+
|
|
260
|
+
* Bucket is not fully blocking public access
|
|
261
|
+
* ACLs are enabled
|
|
262
|
+
* Correct bucket name and region
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
167
266
|
## 📄 License
|
|
168
267
|
|
|
169
268
|
MIT
|
package/bin/create.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import inquirer from "inquirer";
|
|
@@ -187,8 +187,20 @@ async function mergeEnvFile(filePath, values) {
|
|
|
187
187
|
await fs.writeFile(filePath, content);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
async function commitAllIfNeeded(cwd, message) {
|
|
191
|
+
await run("git", ["add", "."], { cwd });
|
|
192
|
+
|
|
193
|
+
const status = await runCapture("git", ["status", "--porcelain"], { cwd });
|
|
194
|
+
if (!status) {
|
|
195
|
+
console.log("ℹ️ Nada novo para commitar");
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
await run("git", ["commit", "-m", message], { cwd });
|
|
200
|
+
}
|
|
201
|
+
|
|
190
202
|
/* =========================
|
|
191
|
-
Heroku Login
|
|
203
|
+
Heroku Login
|
|
192
204
|
========================= */
|
|
193
205
|
|
|
194
206
|
async function isHerokuLoggedIn() {
|
|
@@ -263,7 +275,7 @@ async function initGitRepo(cwd, message) {
|
|
|
263
275
|
}
|
|
264
276
|
|
|
265
277
|
/* =========================
|
|
266
|
-
|
|
278
|
+
S3 Setup
|
|
267
279
|
========================= */
|
|
268
280
|
|
|
269
281
|
async function configureBackendS3(projectDir, aws) {
|
|
@@ -395,6 +407,7 @@ async function createBackendLocal(projectDir) {
|
|
|
395
407
|
cwd: path.join(projectDir, "backend"),
|
|
396
408
|
});
|
|
397
409
|
|
|
410
|
+
console.log("\n=== BACKEND: git init/commit ===\n");
|
|
398
411
|
await initGitRepo(path.join(projectDir, "backend"), "Init Strapi backend");
|
|
399
412
|
}
|
|
400
413
|
|
|
@@ -451,6 +464,7 @@ module.exports = nextConfig;
|
|
|
451
464
|
await fs.writeFile(envLocalPath, "NEXT_PUBLIC_STRAPI_URL=http://localhost:1337\n");
|
|
452
465
|
}
|
|
453
466
|
|
|
467
|
+
console.log("\n=== FRONTEND: git init/commit ===\n");
|
|
454
468
|
await initGitRepo(feDir, "Init Next frontend");
|
|
455
469
|
}
|
|
456
470
|
|
|
@@ -518,6 +532,9 @@ async function deployBackendHeroku({ projectDir, backendApp, region }) {
|
|
|
518
532
|
}
|
|
519
533
|
}
|
|
520
534
|
|
|
535
|
+
console.log("\n=== BACKEND: garantir commit antes do deploy ===\n");
|
|
536
|
+
await commitAllIfNeeded(beDir, "Pre-deploy commit");
|
|
537
|
+
|
|
521
538
|
console.log("\n=== BACKEND: deploy ===\n");
|
|
522
539
|
await run("git", ["push", "heroku", "main"], { cwd: beDir });
|
|
523
540
|
|
|
@@ -555,6 +572,9 @@ async function deployFrontendHeroku({ projectDir, frontendApp, region, backendWe
|
|
|
555
572
|
cwd: feDir,
|
|
556
573
|
});
|
|
557
574
|
|
|
575
|
+
console.log("\n=== FRONTEND: garantir commit antes do deploy ===\n");
|
|
576
|
+
await commitAllIfNeeded(feDir, "Pre-deploy commit");
|
|
577
|
+
|
|
558
578
|
console.log("\n=== FRONTEND: deploy ===\n");
|
|
559
579
|
await run("git", ["push", "heroku", "main"], { cwd: feDir });
|
|
560
580
|
|
|
@@ -622,6 +642,9 @@ async function doCreate(projectDirArg, opts) {
|
|
|
622
642
|
|
|
623
643
|
if (useS3 && aws) {
|
|
624
644
|
await configureBackendS3(projectDir, aws);
|
|
645
|
+
|
|
646
|
+
console.log("\n=== BACKEND: commit configs S3 ===\n");
|
|
647
|
+
await commitAllIfNeeded(path.join(projectDir, "backend"), "Configure S3 upload");
|
|
625
648
|
}
|
|
626
649
|
|
|
627
650
|
await createFrontendLocal(projectDir, nodeVersion);
|