Skip to content

Commit 1254a61

Browse files
committed
chore: wip
1 parent e5c5ae3 commit 1254a61

File tree

9 files changed

+41
-7
lines changed

9 files changed

+41
-7
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ DB_PASSWORD=
1414
AWS_ACCESS_KEY_ID=
1515
AWS_SECRET_ACCESS_KEY=
1616
AWS_DEFAULT_REGION=us-east-1
17+
AWS_DEFAULT_PASSWORD=Verysecret123-
1718

1819
MAIL_MAILER=smtp
1920
MAIL_HOST=mailpit

.stacks/core/cloud/src/cloud.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ import { env } from '@stacksjs/env'
3030
import type { EnvKey } from '~/storage/framework/stacks/env'
3131

3232
const appEnv = config.app.env === 'local' ? 'dev' : config.app.env
33+
function capitalizeFirstLetter(string: string) {
34+
return string.charAt(0).toUpperCase() + string.slice(1)
35+
}
3336

3437
export class StacksCloud extends Stack {
3538
domain: string
@@ -66,6 +69,9 @@ export class StacksCloud extends Stack {
6669
if (!config.app.url)
6770
throw new Error('Your ./config app.url needs to be defined in order to deploy. You may need to adjust the APP_URL inside your .env file.')
6871

72+
if (!config.team || Object.keys(config.team).length === 0)
73+
throw new Error('Your ./config team needs to at least have one member defined. Please set yourself as a team member and try deploying again.')
74+
6975
this.domain = config.app.url
7076
this.apiPrefix = config.api.prefix || 'api'
7177
this.docsPrefix = config.app.docMode ? undefined : config.docs.base
@@ -254,13 +260,20 @@ export class StacksCloud extends Stack {
254260
}
255261

256262
manageUsers() {
257-
const user = new iam.User(this, 'User', {
258-
userName: 'chris',
259-
password: SecretValue.unsafePlainText(string.random()),
260-
passwordResetRequired: true,
261-
})
263+
const users = config.team
264+
265+
for (const userName in users) {
266+
// const userEmail = users[userName]
267+
const user = new iam.User(this, `${capitalizeFirstLetter(userName)}User`, {
268+
userName,
269+
password: SecretValue.unsafePlainText(env.AWS_DEFAULT_PASSWORD || string.random()),
270+
passwordResetRequired: true,
271+
})
272+
273+
user.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('AdministratorAccess'))
262274

263-
user.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonS3FullAccess'))
275+
// TODO: email the userEmail their credentials
276+
}
264277
}
265278

266279
manageZone() {

.stacks/core/config/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const {
2828
searchEngine,
2929
services,
3030
storage,
31+
team,
3132
ui,
3233
}: StacksOptions = config
3334

.stacks/core/config/src/defaults.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ export default {
467467
driver: 's3',
468468
},
469469

470+
team: {},
471+
470472
ui: {
471473
shortcuts: [
472474
['btn', 'inline-flex items-center px-4 py-2 ml-2 border border-transparent shadow-sm text-base font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 cursor-pointer'],

.stacks/core/config/src/overrides.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import storage from '~/config/storage'
1818
import searchEngine from '~/config/search-engine'
1919
import security from '~/config/security'
2020
import services from '~/config/services'
21+
import team from '~/config/team'
2122
import ui from '~/config/ui'
2223

2324
// this "user config" will override the default config options
@@ -41,5 +42,6 @@ export default {
4142
security,
4243
services,
4344
storage,
45+
team,
4446
ui,
4547
} satisfies StacksConfig

.stacks/core/types/src/stacks.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type {
1919
SecurityConfig,
2020
ServicesConfig,
2121
StorageConfig,
22+
Team,
2223
UiConfig,
2324
} from './'
2425

@@ -210,6 +211,15 @@ export interface StacksOptions {
210211
*/
211212
storage: StorageConfig
212213

214+
/**
215+
* **Team Members**
216+
*
217+
* This configuration defines all of your Team members. Because Stacks is fully-typed, you
218+
* may hover any of the options below and the definitions will be provided. In case you
219+
* have any questions, feel free to reach out via Discord or GitHub Discussions.
220+
*/
221+
team: Team
222+
213223
/**
214224
* **UI Options**
215225
*

.stacks/core/types/src/team.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
type TeamMemberName = string
2+
type Email = string
3+
14
export interface Team {
2-
[key: string]: string
5+
[key: TeamMemberName]: Email
36
}

config/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default {
2929
AWS_ACCESS_KEY_ID: validate.string(),
3030
AWS_SECRET_ACCESS_KEY: validate.string(),
3131
AWS_DEFAULT_REGION: validate.string(),
32+
AWS_DEFAULT_PASSWORD: validate.string(),
3233

3334
MAIL_MAILER: validate.enum(['smtp', 'mailgun', 'ses', 'postmark', 'sendmail', 'log']),
3435
MAIL_HOST: validate.string(),

storage/framework/stacks/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const envKeys = [
2121
'AWS_ACCESS_KEY_ID',
2222
'AWS_SECRET_ACCESS_KEY',
2323
'AWS_DEFAULT_REGION',
24+
'AWS_DEFAULT_PASSWORD',
2425
'MAIL_MAILER',
2526
'MAIL_HOST',
2627
'MAIL_PORT',

0 commit comments

Comments
 (0)