create-aws-project 1.2.1 → 1.4.3
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 +156 -32
- package/dist/__tests__/generator/replace-tokens.spec.js +9 -0
- package/dist/__tests__/harness/fixtures/config-factories.d.ts +15 -0
- package/dist/__tests__/harness/fixtures/config-factories.js +71 -0
- package/dist/__tests__/harness/fixtures/fixtures.spec.d.ts +1 -0
- package/dist/__tests__/harness/fixtures/fixtures.spec.js +89 -0
- package/dist/__tests__/harness/fixtures/index.d.ts +2 -0
- package/dist/__tests__/harness/fixtures/index.js +2 -0
- package/dist/__tests__/harness/fixtures/matrix.d.ts +28 -0
- package/dist/__tests__/harness/fixtures/matrix.js +58 -0
- package/dist/__tests__/harness/local-runner.d.ts +2 -0
- package/dist/__tests__/harness/local-runner.js +184 -0
- package/dist/__tests__/harness/run-command.d.ts +7 -0
- package/dist/__tests__/harness/run-command.js +26 -0
- package/dist/__tests__/harness/run-command.spec.d.ts +1 -0
- package/dist/__tests__/harness/run-command.spec.js +67 -0
- package/dist/__tests__/harness/temp-dir.d.ts +1 -0
- package/dist/__tests__/harness/temp-dir.js +14 -0
- package/dist/__tests__/harness/temp-dir.spec.d.ts +1 -0
- package/dist/__tests__/harness/temp-dir.spec.js +40 -0
- package/dist/__tests__/harness/validate-project.d.ts +16 -0
- package/dist/__tests__/harness/validate-project.js +78 -0
- package/dist/__tests__/harness/validate-project.spec.d.ts +1 -0
- package/dist/__tests__/harness/validate-project.spec.js +189 -0
- package/dist/__tests__/wizard.spec.js +2 -3
- package/dist/aws/iam.d.ts +8 -1
- package/dist/aws/iam.js +22 -3
- package/dist/cli.js +79 -102
- package/dist/commands/initialize-github.d.ts +13 -0
- package/dist/commands/initialize-github.js +329 -0
- package/dist/commands/setup-aws-envs.d.ts +14 -0
- package/dist/commands/setup-aws-envs.js +233 -0
- package/dist/commands/setup-github.d.ts +11 -0
- package/dist/commands/setup-github.js +22 -0
- package/dist/github/secrets.js +10 -42
- package/dist/templates/manifest.js +5 -0
- package/dist/templates/types.d.ts +4 -0
- package/dist/utils/project-context.d.ts +44 -0
- package/dist/utils/project-context.js +63 -0
- package/dist/wizard.js +2 -37
- package/package.json +11 -3
- package/templates/apps/api/src/handlers/users/get-me.ts +2 -2
- package/templates/apps/api/src/middleware/auth0-auth.ts +4 -4
- package/templates/apps/api/src/middleware/cognito-auth.ts +3 -3
- package/templates/apps/api/src/utils/auth-context.ts +1 -1
- package/templates/apps/mobile/jest.config.ts +1 -0
- package/templates/apps/mobile/src/test-setup.ts +1 -1
- package/templates/apps/web/jest.config.ts +1 -0
- package/templates/apps/web/src/__mocks__/config/auth0-config.ts +16 -0
- package/templates/apps/web/src/__tests__/App.spec.tsx +12 -0
- package/templates/apps/web/src/config/amplify-config.ts +23 -25
- package/templates/apps/web/src/config/auth0-config.ts +3 -3
- package/templates/apps/web/src/test-setup.ts +4 -0
- package/templates/apps/web/tsconfig.spec.json +1 -0
- package/templates/manifest.json +1 -0
- package/templates/root/README.md +156 -0
- package/templates/root/package.json +12 -9
|
@@ -18,6 +18,7 @@ export default {
|
|
|
18
18
|
'^\\.\\./\\.\\./config/api$': '<rootDir>/src/__mocks__/config/api.ts',
|
|
19
19
|
'^\\.\\./src/config/api$': '<rootDir>/src/__mocks__/config/api.ts',
|
|
20
20
|
'^./config/api$': '<rootDir>/src/__mocks__/config/api.ts',
|
|
21
|
+
'^\\.\\./config/auth0-config$': '<rootDir>/src/__mocks__/config/auth0-config.ts',
|
|
21
22
|
'^{{PACKAGE_SCOPE}}/common-types$': '<rootDir>/../../packages/common-types/src/index.ts',
|
|
22
23
|
'^{{PACKAGE_SCOPE}}/api-client$': '<rootDir>/../../packages/api-client/src/index.ts',
|
|
23
24
|
},
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock Auth0 configuration for tests
|
|
3
|
+
*/
|
|
4
|
+
export interface Auth0Config {
|
|
5
|
+
domain: string;
|
|
6
|
+
clientId: string;
|
|
7
|
+
audience?: string;
|
|
8
|
+
redirectUri: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const auth0Config: Auth0Config = {
|
|
12
|
+
domain: 'test.auth0.com',
|
|
13
|
+
clientId: 'test-client-id',
|
|
14
|
+
audience: 'https://test-api',
|
|
15
|
+
redirectUri: 'http://localhost:3000',
|
|
16
|
+
};
|
|
@@ -14,6 +14,18 @@ jest.mock('../config/api', () => ({
|
|
|
14
14
|
},
|
|
15
15
|
}));
|
|
16
16
|
|
|
17
|
+
// Mock useAuth hook to provide auth context for tests
|
|
18
|
+
jest.mock('../auth/use-auth', () => ({
|
|
19
|
+
useAuth: () => ({
|
|
20
|
+
user: null,
|
|
21
|
+
isAuthenticated: false,
|
|
22
|
+
isLoading: false,
|
|
23
|
+
login: jest.fn(),
|
|
24
|
+
logout: jest.fn(),
|
|
25
|
+
getAccessToken: jest.fn().mockResolvedValue(null),
|
|
26
|
+
}),
|
|
27
|
+
}));
|
|
28
|
+
|
|
17
29
|
const mockApiClient = apiClient as jest.Mocked<typeof apiClient>;
|
|
18
30
|
|
|
19
31
|
const renderWithChakra = async (component: React.ReactElement) => {
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ResourcesConfig } from 'aws-amplify';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Amplify configuration for Cognito authentication
|
|
5
5
|
* Values should be set via environment variables
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
requireNumbers: true,
|
|
27
|
-
},
|
|
7
|
+
export const amplifyConfig: ResourcesConfig = {
|
|
8
|
+
Auth: {
|
|
9
|
+
Cognito: {
|
|
10
|
+
userPoolId: import.meta.env['VITE_COGNITO_USER_POOL_ID'] ?? '',
|
|
11
|
+
userPoolClientId: import.meta.env['VITE_COGNITO_CLIENT_ID'] ?? '',
|
|
12
|
+
// Optional: Identity Pool for AWS credentials
|
|
13
|
+
// identityPoolId: import.meta.env['VITE_COGNITO_IDENTITY_POOL_ID'],
|
|
14
|
+
loginWith: {
|
|
15
|
+
email: true,
|
|
16
|
+
},
|
|
17
|
+
signUpVerificationMethod: 'code',
|
|
18
|
+
userAttributes: {
|
|
19
|
+
email: { required: true },
|
|
20
|
+
},
|
|
21
|
+
passwordFormat: {
|
|
22
|
+
minLength: 8,
|
|
23
|
+
requireLowercase: true,
|
|
24
|
+
requireUppercase: true,
|
|
25
|
+
requireNumbers: true,
|
|
28
26
|
},
|
|
29
27
|
},
|
|
30
|
-
}
|
|
31
|
-
}
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -10,8 +10,8 @@ export interface Auth0Config {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const auth0Config: Auth0Config = {
|
|
13
|
-
domain: import.meta.env
|
|
14
|
-
clientId: import.meta.env
|
|
15
|
-
audience: import.meta.env
|
|
13
|
+
domain: import.meta.env['VITE_AUTH0_DOMAIN'] ?? '',
|
|
14
|
+
clientId: import.meta.env['VITE_AUTH0_CLIENT_ID'] ?? '',
|
|
15
|
+
audience: import.meta.env['VITE_AUTH0_AUDIENCE'] ?? undefined,
|
|
16
16
|
redirectUri: typeof window !== 'undefined' ? window.location.origin : '',
|
|
17
17
|
};
|
package/templates/manifest.json
CHANGED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# {{PROJECT_NAME}}
|
|
2
|
+
|
|
3
|
+
Full-stack application built with create-aws-project.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
{{#if WEB}}
|
|
12
|
+
Start the web app:
|
|
13
|
+
```bash
|
|
14
|
+
npm run web
|
|
15
|
+
```
|
|
16
|
+
{{/if WEB}}
|
|
17
|
+
|
|
18
|
+
{{#if MOBILE}}
|
|
19
|
+
Start the mobile app:
|
|
20
|
+
```bash
|
|
21
|
+
npm run mobile
|
|
22
|
+
```
|
|
23
|
+
{{/if MOBILE}}
|
|
24
|
+
|
|
25
|
+
{{#if API}}
|
|
26
|
+
Deploy to AWS:
|
|
27
|
+
```bash
|
|
28
|
+
npm run cdk:deploy
|
|
29
|
+
```
|
|
30
|
+
{{/if API}}
|
|
31
|
+
|
|
32
|
+
## Project Structure
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
{{PROJECT_NAME}}/
|
|
36
|
+
{{#if WEB}}
|
|
37
|
+
├── apps/web/ # React + Vite web application
|
|
38
|
+
{{/if WEB}}
|
|
39
|
+
{{#if MOBILE}}
|
|
40
|
+
├── apps/mobile/ # React Native + Expo mobile app
|
|
41
|
+
{{/if MOBILE}}
|
|
42
|
+
{{#if API}}
|
|
43
|
+
├── apps/api/ # AWS Lambda API + CDK infrastructure
|
|
44
|
+
{{/if API}}
|
|
45
|
+
├── packages/
|
|
46
|
+
│ ├── common-types/ # Shared TypeScript types
|
|
47
|
+
│ └── api-client/ # Shared API client
|
|
48
|
+
└── package.json # Root package with Nx scripts
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Available Commands
|
|
52
|
+
|
|
53
|
+
| Command | Description |
|
|
54
|
+
|---------|-------------|
|
|
55
|
+
{{#if WEB}}
|
|
56
|
+
| `npm run web` | Start web development server |
|
|
57
|
+
| `npm run build:web` | Build web app for production |
|
|
58
|
+
{{/if WEB}}
|
|
59
|
+
{{#if MOBILE}}
|
|
60
|
+
| `npm run mobile` | Start Expo development server |
|
|
61
|
+
| `npm run mobile:ios` | Run on iOS simulator |
|
|
62
|
+
| `npm run mobile:android` | Run on Android emulator |
|
|
63
|
+
{{/if MOBILE}}
|
|
64
|
+
{{#if API}}
|
|
65
|
+
| `npm run cdk:deploy` | Deploy to AWS (dev environment) |
|
|
66
|
+
| `npm run cdk:deploy:stage` | Deploy to staging |
|
|
67
|
+
| `npm run cdk:deploy:prod` | Deploy to production |
|
|
68
|
+
| `npm run cdk:synth` | Synthesize CloudFormation template |
|
|
69
|
+
{{/if API}}
|
|
70
|
+
| `npm run test` | Run all tests |
|
|
71
|
+
| `npm run lint` | Lint all projects |
|
|
72
|
+
|
|
73
|
+
## AWS Setup
|
|
74
|
+
|
|
75
|
+
Before deploying to AWS, you need to set up your AWS environments and GitHub deployment pipeline.
|
|
76
|
+
|
|
77
|
+
### Prerequisites
|
|
78
|
+
|
|
79
|
+
- AWS Root account created
|
|
80
|
+
- AWS CLI configured with management account credentials
|
|
81
|
+
- GitHub repository created for this project
|
|
82
|
+
- GitHub Personal Access Token with "repo" scope
|
|
83
|
+
|
|
84
|
+
### 1. Set Up AWS Environments
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npx create-aws-project setup-aws-envs
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
This creates an AWS Organization with three environment accounts (dev, stage, prod).
|
|
91
|
+
|
|
92
|
+
### 2. Configure GitHub Deployment
|
|
93
|
+
|
|
94
|
+
For each environment:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npx create-aws-project initialize-github dev
|
|
98
|
+
npx create-aws-project initialize-github stage
|
|
99
|
+
npx create-aws-project initialize-github prod
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
This configures GitHub Environment secrets for automated deployments.
|
|
103
|
+
|
|
104
|
+
### 3. Deploy
|
|
105
|
+
|
|
106
|
+
Push to main to trigger your first deployment:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
git push origin main
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
For detailed setup instructions and troubleshooting, see the [create-aws-project documentation](https://www.npmjs.com/package/create-aws-starter-kit).
|
|
113
|
+
|
|
114
|
+
## CI/CD Workflows
|
|
115
|
+
|
|
116
|
+
| Workflow | Trigger | Description |
|
|
117
|
+
|----------|---------|-------------|
|
|
118
|
+
| pull-request.yml | Any PR | Runs lint, test, and build validation |
|
|
119
|
+
| deploy-dev.yml | Push to main | Deploys to development environment |
|
|
120
|
+
| deploy-stage.yml | Manual | Deploys to staging environment |
|
|
121
|
+
| deploy-prod.yml | Manual | Deploys to production environment |
|
|
122
|
+
|
|
123
|
+
## Environment Variables
|
|
124
|
+
|
|
125
|
+
{{#if WEB}}
|
|
126
|
+
### Web App
|
|
127
|
+
|
|
128
|
+
Copy `apps/web/.env.example` to `apps/web/.env.local` and configure:
|
|
129
|
+
|
|
130
|
+
- `VITE_API_URL` - API Gateway endpoint URL
|
|
131
|
+
{{/if WEB}}
|
|
132
|
+
|
|
133
|
+
{{#if API}}
|
|
134
|
+
### API
|
|
135
|
+
|
|
136
|
+
Environment variables are configured in CDK stacks (`apps/api/cdk/`).
|
|
137
|
+
{{/if API}}
|
|
138
|
+
|
|
139
|
+
## Technology Stack
|
|
140
|
+
|
|
141
|
+
{{#if WEB}}
|
|
142
|
+
- **Web**: React 19, Vite, Chakra UI, TypeScript
|
|
143
|
+
{{/if WEB}}
|
|
144
|
+
{{#if MOBILE}}
|
|
145
|
+
- **Mobile**: React Native, Expo, TypeScript
|
|
146
|
+
{{/if MOBILE}}
|
|
147
|
+
{{#if API}}
|
|
148
|
+
- **API**: AWS Lambda, API Gateway, DynamoDB, CDK
|
|
149
|
+
{{/if API}}
|
|
150
|
+
- **Monorepo**: Nx
|
|
151
|
+
- **Testing**: Jest, Testing Library
|
|
152
|
+
- **CI/CD**: GitHub Actions
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
ISC
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
],
|
|
51
51
|
"author": "",
|
|
52
52
|
"license": "ISC",
|
|
53
|
-
|
|
53
|
+
"devDependencies": {
|
|
54
54
|
"@aws-lambda-powertools/logger": "^2.29.0",
|
|
55
55
|
"@aws-sdk/client-dynamodb": "^3.940.0",
|
|
56
56
|
"@aws-sdk/lib-dynamodb": "^3.940.0",
|
|
@@ -66,15 +66,16 @@
|
|
|
66
66
|
"@nx/react": "22.3.3",
|
|
67
67
|
"@nx/vite": "22.3.3",
|
|
68
68
|
"@nx/workspace": "22.3.3",
|
|
69
|
+
"@testing-library/dom": "^10.4.0",
|
|
69
70
|
"@testing-library/jest-dom": "^6.9.1",
|
|
70
|
-
"@testing-library/
|
|
71
|
-
"@testing-library/react": "^14.3.1",
|
|
71
|
+
"@testing-library/react": "^16.3.2",
|
|
72
72
|
"@testing-library/react-native": "^12.4.0",
|
|
73
73
|
"@testing-library/user-event": "^14.6.1",
|
|
74
74
|
"@types/jest": "^30.0.0",
|
|
75
75
|
"@types/js-yaml": "^4.0.9",
|
|
76
76
|
"@types/node": "^24.10.1",
|
|
77
77
|
"@types/react": "^19.2.4",
|
|
78
|
+
"@types/aws-lambda": "^8.10.149",
|
|
78
79
|
"@types/react-dom": "^19.2.3",
|
|
79
80
|
"@typescript-eslint/eslint-plugin": "^8.48.0",
|
|
80
81
|
"@typescript-eslint/parser": "^8.48.0",
|
|
@@ -83,18 +84,18 @@
|
|
|
83
84
|
"aws-cdk-lib": "^2.224.0",
|
|
84
85
|
"aws-cdk-local": "^3.0.1",
|
|
85
86
|
"babel-plugin-module-resolver": "^5.0.0",
|
|
86
|
-
"babel-preset-expo": "
|
|
87
|
+
"babel-preset-expo": "~13.2.4",
|
|
87
88
|
"constructs": "^10.4.3",
|
|
88
89
|
"esbuild": "^0.27.0",
|
|
89
90
|
"eslint": "^9.39.1",
|
|
90
91
|
"eslint-plugin-react": "^7.37.5",
|
|
91
92
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
92
93
|
"eslint-plugin-react-native": "^5.0.0",
|
|
93
|
-
"expo": "
|
|
94
|
+
"expo": "^53.0.0",
|
|
94
95
|
"jest": "^30.2.0",
|
|
95
96
|
"jest-environment-jsdom": "^30.2.0",
|
|
96
97
|
"jest-environment-node": "^30.2.0",
|
|
97
|
-
"jest-expo": "^
|
|
98
|
+
"jest-expo": "^53.0.0",
|
|
98
99
|
"jest-jasmine2": "^30.2.0",
|
|
99
100
|
"jest-junit": "^16.0.0",
|
|
100
101
|
"js-yaml": "^4.1.1",
|
|
@@ -114,6 +115,8 @@
|
|
|
114
115
|
}
|
|
115
116
|
},
|
|
116
117
|
"dependencies": {
|
|
118
|
+
"@auth0/auth0-react": "^2.2.4",
|
|
119
|
+
"aws-amplify": "^6.14.4",
|
|
117
120
|
"@chakra-ui/icons": "^2.2.4",
|
|
118
121
|
"aws-jwt-verify": "^4.0.0",
|
|
119
122
|
"jose": "^5.2.0",
|
|
@@ -123,9 +126,9 @@
|
|
|
123
126
|
"ajv": "^8.17.1",
|
|
124
127
|
"ajv-formats": "^3.0.1",
|
|
125
128
|
"axios": "^1.13.2",
|
|
126
|
-
"expo-status-bar": "~
|
|
127
|
-
"framer-motion": "^
|
|
128
|
-
"react-native": "0.
|
|
129
|
+
"expo-status-bar": "~3.0.0",
|
|
130
|
+
"framer-motion": "^12.29.2",
|
|
131
|
+
"react-native": "0.79.7",
|
|
129
132
|
"zustand": "^5.0.8"
|
|
130
133
|
}
|
|
131
134
|
}
|