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
package/README.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Create a new AWS project from scratch including CloudFront, API Gateway, Lambdas, Cognito or Auth0, DynamoDB. GitHub pipeline for testing and deploying.
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/create-aws-project)
|
|
6
6
|
|
|
7
7
|
## Quick Start
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npx create-aws-
|
|
10
|
+
npx create-aws-project my-project
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
**Requirements:** Node.js 22.16.0+ (npm included)
|
|
@@ -33,35 +33,24 @@ The generated project is a full-stack Nx monorepo with:
|
|
|
33
33
|
## CLI Options
|
|
34
34
|
|
|
35
35
|
```
|
|
36
|
-
create-aws-
|
|
36
|
+
create-aws-project [command] [options]
|
|
37
|
+
|
|
38
|
+
Commands:
|
|
39
|
+
(default) Create a new project (interactive wizard)
|
|
40
|
+
setup-aws-envs Set up AWS Organizations and environment accounts
|
|
41
|
+
initialize-github Configure GitHub Environment for deployment
|
|
37
42
|
|
|
38
43
|
Options:
|
|
39
|
-
--help, -h
|
|
40
|
-
--version, -v
|
|
44
|
+
--help, -h Show help message
|
|
45
|
+
--version, -v Show version number
|
|
41
46
|
|
|
42
47
|
Examples:
|
|
43
|
-
npx create-aws-
|
|
44
|
-
npx create-aws-
|
|
45
|
-
npx create-aws-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
### Setup GitHub Command
|
|
49
|
-
|
|
50
|
-
After generating a project with AWS Organizations enabled, configure GitHub Actions deployment:
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
npx create-aws-starter-kit setup-github
|
|
48
|
+
npx create-aws-project my-app
|
|
49
|
+
npx create-aws-project setup-aws-envs
|
|
50
|
+
npx create-aws-project initialize-github dev
|
|
51
|
+
npx create-aws-project --help
|
|
54
52
|
```
|
|
55
53
|
|
|
56
|
-
This command:
|
|
57
|
-
- Creates IAM deployment users per environment (dev, stage, prod)
|
|
58
|
-
- Configures GitHub Environments with AWS credentials
|
|
59
|
-
- Sets up least-privilege CDK deployment permissions
|
|
60
|
-
|
|
61
|
-
**Requirements:**
|
|
62
|
-
- GitHub Personal Access Token with `repo` and `admin:org` scopes
|
|
63
|
-
- AWS credentials with IAM permissions
|
|
64
|
-
|
|
65
54
|
## Wizard Prompts
|
|
66
55
|
|
|
67
56
|
The interactive wizard will ask you about:
|
|
@@ -72,11 +61,7 @@ The interactive wizard will ask you about:
|
|
|
72
61
|
- None (add later)
|
|
73
62
|
- AWS Cognito
|
|
74
63
|
- Auth0
|
|
75
|
-
|
|
76
|
-
4. **AWS Organizations** - Multi-account setup (optional):
|
|
77
|
-
- Creates separate AWS accounts for each environment
|
|
78
|
-
- Environments: dev, stage, prod (plus optional qa, sandbox)
|
|
79
|
-
- Requires root email per account
|
|
64
|
+
4. **Auth features** - Social login, MFA (conditional on auth provider)
|
|
80
65
|
5. **Features** - Optional extras:
|
|
81
66
|
- GitHub Actions workflows for CI/CD
|
|
82
67
|
- VS Code workspace configuration
|
|
@@ -89,9 +74,148 @@ The interactive wizard will ask you about:
|
|
|
89
74
|
- Note: Node 25+ has Jest compatibility issues - use 22.x or 24.x
|
|
90
75
|
- **npm** - Included with Node.js
|
|
91
76
|
|
|
92
|
-
##
|
|
77
|
+
## Post-Install Setup
|
|
78
|
+
|
|
79
|
+
After creating your project, you'll set up AWS environments and GitHub deployment. This is a one-time setup.
|
|
80
|
+
|
|
81
|
+
### Prerequisites
|
|
82
|
+
|
|
83
|
+
Before you begin:
|
|
84
|
+
- AWS CLI configured with credentials from your AWS management account
|
|
85
|
+
- GitHub repository created for your project
|
|
86
|
+
- GitHub Personal Access Token with "repo" scope ([create one here](https://github.com/settings/tokens/new))
|
|
87
|
+
|
|
88
|
+
### Step 1: connect to your .git project
|
|
89
|
+
|
|
90
|
+
* Initialize the repository
|
|
91
|
+
```
|
|
92
|
+
git init
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
* Add the remote repository using the git remote add <name> <url> command. A common practice is to name it origin.
|
|
96
|
+
```bash
|
|
97
|
+
git remote add origin <REMOTE_URL>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
* Verify the connection by listing your remotes. The -v flag shows the URLs.
|
|
101
|
+
```bash
|
|
102
|
+
git remote -v
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
* Push your local commits to the remote repository for the first time.
|
|
106
|
+
```bash
|
|
107
|
+
git push -u origin main
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Step 2: Set Up AWS Environments
|
|
111
|
+
|
|
112
|
+
From your project directory, run:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npx create-aws-project setup-aws-envs
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
This command:
|
|
119
|
+
- Creates an AWS Organization (if you don't have one)
|
|
120
|
+
- Creates three environment accounts: dev, stage, prod
|
|
121
|
+
- Prompts for a unique root email for each account (tip: use aliases like you+dev@email.com)
|
|
122
|
+
|
|
123
|
+
**What's happening:** AWS Organizations lets you isolate each environment in its own AWS account. This is a security best practice - your production data is completely separate from development.
|
|
124
|
+
|
|
125
|
+
Expected output:
|
|
126
|
+
```
|
|
127
|
+
✔ Created AWS Organization: o-xxxxxxxxxx
|
|
128
|
+
✔ Created dev account: 123456789012
|
|
129
|
+
✔ Created stage account: 234567890123
|
|
130
|
+
✔ Created prod account: 345678901234
|
|
131
|
+
|
|
132
|
+
AWS environment setup complete!
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Account IDs are saved to `.aws-starter-config.json` for the next step.
|
|
136
|
+
|
|
137
|
+
### Step 3: Configure GitHub Environments
|
|
138
|
+
|
|
139
|
+
For each environment, run:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
npx create-aws-project initialize-github dev
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
This command:
|
|
146
|
+
- Creates an IAM deployment user in the target AWS account
|
|
147
|
+
- Configures GitHub Environment secrets with AWS credentials
|
|
148
|
+
- Sets up least-privilege permissions for CDK deployments
|
|
149
|
+
|
|
150
|
+
**What's happening:** Each GitHub Environment (Development, Staging, Production) gets its own AWS credentials. When GitHub Actions runs, it uses the right credentials for the target environment.
|
|
151
|
+
|
|
152
|
+
Repeat for each environment:
|
|
153
|
+
```bash
|
|
154
|
+
npx create-aws-project initialize-github stage
|
|
155
|
+
npx create-aws-project initialize-github prod
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
You'll be prompted for your GitHub PAT each time (it's not stored).
|
|
159
|
+
|
|
160
|
+
### You're Done!
|
|
161
|
+
|
|
162
|
+
Push to main to trigger your first deployment:
|
|
163
|
+
```bash
|
|
164
|
+
git push origin main
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
GitHub Actions will deploy to your dev environment automatically.
|
|
168
|
+
|
|
169
|
+
## Troubleshooting
|
|
170
|
+
|
|
171
|
+
### setup-aws-envs errors
|
|
172
|
+
|
|
173
|
+
**"Insufficient AWS permissions"**
|
|
174
|
+
|
|
175
|
+
Your AWS credentials need Organizations permissions. Ensure you're using credentials from the management account (not a member account).
|
|
176
|
+
|
|
177
|
+
Required permissions:
|
|
178
|
+
- organizations:DescribeOrganization
|
|
179
|
+
- organizations:CreateOrganization
|
|
180
|
+
- organizations:CreateAccount
|
|
181
|
+
- organizations:DescribeCreateAccountStatus
|
|
182
|
+
|
|
183
|
+
**"AWS Organizations limit reached"**
|
|
184
|
+
|
|
185
|
+
AWS limits how many accounts you can create. Contact AWS Support to request a limit increase.
|
|
186
|
+
|
|
187
|
+
**"AWS Organization is still initializing"**
|
|
188
|
+
|
|
189
|
+
New organizations take up to an hour to fully initialize. Wait and try again.
|
|
190
|
+
|
|
191
|
+
### initialize-github errors
|
|
192
|
+
|
|
193
|
+
**"Cannot assume role in target account"**
|
|
194
|
+
|
|
195
|
+
The command needs to access the target AWS account via `OrganizationAccountAccessRole`. This role is created automatically when you create accounts via `setup-aws-envs`. Ensure:
|
|
196
|
+
1. You ran `setup-aws-envs` first
|
|
197
|
+
2. Your credentials are from the management account
|
|
198
|
+
3. The account ID in `.aws-starter-config.json` is correct
|
|
199
|
+
|
|
200
|
+
**"IAM user already exists"**
|
|
201
|
+
|
|
202
|
+
The deployment user already exists in the target account. To retry:
|
|
203
|
+
1. Go to AWS Console > IAM > Users
|
|
204
|
+
2. Delete the existing `<project>-<env>-deploy` user
|
|
205
|
+
3. Run the command again
|
|
206
|
+
|
|
207
|
+
**"GitHub authentication failed"**
|
|
208
|
+
|
|
209
|
+
Your Personal Access Token may be invalid or missing permissions. Ensure:
|
|
210
|
+
1. Token has "repo" scope enabled
|
|
211
|
+
2. Token belongs to the repository owner (or has collaborator access)
|
|
212
|
+
3. Token is not expired
|
|
213
|
+
|
|
214
|
+
Create a new token at: https://github.com/settings/tokens/new
|
|
215
|
+
|
|
216
|
+
## After Setup
|
|
93
217
|
|
|
94
|
-
Once your project is
|
|
218
|
+
Once your project is set up:
|
|
95
219
|
|
|
96
220
|
```bash
|
|
97
221
|
cd my-project
|
|
@@ -12,6 +12,9 @@ describe('replaceTokens', () => {
|
|
|
12
12
|
AUTH_AUTH0: 'false',
|
|
13
13
|
AUTH_SOCIAL_LOGIN: 'false',
|
|
14
14
|
AUTH_MFA: 'false',
|
|
15
|
+
WEB: 'false',
|
|
16
|
+
MOBILE: 'false',
|
|
17
|
+
API: 'false',
|
|
15
18
|
};
|
|
16
19
|
describe('single token replacement', () => {
|
|
17
20
|
it('should replace PROJECT_NAME token', () => {
|
|
@@ -107,6 +110,9 @@ describe('processConditionalBlocks', () => {
|
|
|
107
110
|
AUTH_AUTH0: 'false',
|
|
108
111
|
AUTH_SOCIAL_LOGIN: 'false',
|
|
109
112
|
AUTH_MFA: 'false',
|
|
113
|
+
WEB: 'false',
|
|
114
|
+
MOBILE: 'false',
|
|
115
|
+
API: 'false',
|
|
110
116
|
};
|
|
111
117
|
describe('comment-wrapped conditionals', () => {
|
|
112
118
|
it('should keep content when token is true (removes markers)', () => {
|
|
@@ -228,6 +234,9 @@ describe('replaceTokens integration with conditionals', () => {
|
|
|
228
234
|
AUTH_AUTH0: 'false',
|
|
229
235
|
AUTH_SOCIAL_LOGIN: 'false',
|
|
230
236
|
AUTH_MFA: 'false',
|
|
237
|
+
WEB: 'false',
|
|
238
|
+
MOBILE: 'false',
|
|
239
|
+
API: 'false',
|
|
231
240
|
};
|
|
232
241
|
it('should process conditionals before token replacement', () => {
|
|
233
242
|
const tokens = { ...baseTokens, AUTH_COGNITO: 'true' };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ProjectConfig } from '../../../types.js';
|
|
2
|
+
export declare const createWebCognitoConfig: () => ProjectConfig;
|
|
3
|
+
export declare const createWebAuth0Config: () => ProjectConfig;
|
|
4
|
+
export declare const createMobileCognitoConfig: () => ProjectConfig;
|
|
5
|
+
export declare const createMobileAuth0Config: () => ProjectConfig;
|
|
6
|
+
export declare const createApiCognitoConfig: () => ProjectConfig;
|
|
7
|
+
export declare const createApiAuth0Config: () => ProjectConfig;
|
|
8
|
+
export declare const createWebMobileCognitoConfig: () => ProjectConfig;
|
|
9
|
+
export declare const createWebMobileAuth0Config: () => ProjectConfig;
|
|
10
|
+
export declare const createWebApiCognitoConfig: () => ProjectConfig;
|
|
11
|
+
export declare const createWebApiAuth0Config: () => ProjectConfig;
|
|
12
|
+
export declare const createMobileApiCognitoConfig: () => ProjectConfig;
|
|
13
|
+
export declare const createMobileApiAuth0Config: () => ProjectConfig;
|
|
14
|
+
export declare const createFullStackCognitoConfig: () => ProjectConfig;
|
|
15
|
+
export declare const createFullStackAuth0Config: () => ProjectConfig;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a base configuration with sensible defaults.
|
|
3
|
+
* All factories should call this to ensure consistent structure.
|
|
4
|
+
*/
|
|
5
|
+
function createBaseConfig(overrides = {}) {
|
|
6
|
+
const authProvider = overrides.authProvider ?? 'cognito';
|
|
7
|
+
return {
|
|
8
|
+
projectName: overrides.projectName ?? 'test-project',
|
|
9
|
+
platforms: overrides.platforms ?? ['web', 'api'],
|
|
10
|
+
awsRegion: overrides.awsRegion ?? 'us-east-1',
|
|
11
|
+
features: overrides.features ?? [],
|
|
12
|
+
brandColor: overrides.brandColor ?? 'blue',
|
|
13
|
+
auth: {
|
|
14
|
+
provider: authProvider,
|
|
15
|
+
features: authProvider === 'none' ? [] : (overrides.authFeatures ?? []),
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
// Single platform factories
|
|
20
|
+
export const createWebCognitoConfig = () => createBaseConfig({ projectName: 'test-web-cognito', platforms: ['web'], authProvider: 'cognito' });
|
|
21
|
+
export const createWebAuth0Config = () => createBaseConfig({ projectName: 'test-web-auth0', platforms: ['web'], authProvider: 'auth0' });
|
|
22
|
+
export const createMobileCognitoConfig = () => createBaseConfig({
|
|
23
|
+
projectName: 'test-mobile-cognito',
|
|
24
|
+
platforms: ['mobile'],
|
|
25
|
+
authProvider: 'cognito',
|
|
26
|
+
});
|
|
27
|
+
export const createMobileAuth0Config = () => createBaseConfig({ projectName: 'test-mobile-auth0', platforms: ['mobile'], authProvider: 'auth0' });
|
|
28
|
+
export const createApiCognitoConfig = () => createBaseConfig({ projectName: 'test-api-cognito', platforms: ['api'], authProvider: 'cognito' });
|
|
29
|
+
export const createApiAuth0Config = () => createBaseConfig({ projectName: 'test-api-auth0', platforms: ['api'], authProvider: 'auth0' });
|
|
30
|
+
// Double platform factories
|
|
31
|
+
export const createWebMobileCognitoConfig = () => createBaseConfig({
|
|
32
|
+
projectName: 'test-web-mobile-cognito',
|
|
33
|
+
platforms: ['web', 'mobile'],
|
|
34
|
+
authProvider: 'cognito',
|
|
35
|
+
});
|
|
36
|
+
export const createWebMobileAuth0Config = () => createBaseConfig({
|
|
37
|
+
projectName: 'test-web-mobile-auth0',
|
|
38
|
+
platforms: ['web', 'mobile'],
|
|
39
|
+
authProvider: 'auth0',
|
|
40
|
+
});
|
|
41
|
+
export const createWebApiCognitoConfig = () => createBaseConfig({
|
|
42
|
+
projectName: 'test-web-api-cognito',
|
|
43
|
+
platforms: ['web', 'api'],
|
|
44
|
+
authProvider: 'cognito',
|
|
45
|
+
});
|
|
46
|
+
export const createWebApiAuth0Config = () => createBaseConfig({
|
|
47
|
+
projectName: 'test-web-api-auth0',
|
|
48
|
+
platforms: ['web', 'api'],
|
|
49
|
+
authProvider: 'auth0',
|
|
50
|
+
});
|
|
51
|
+
export const createMobileApiCognitoConfig = () => createBaseConfig({
|
|
52
|
+
projectName: 'test-mobile-api-cognito',
|
|
53
|
+
platforms: ['mobile', 'api'],
|
|
54
|
+
authProvider: 'cognito',
|
|
55
|
+
});
|
|
56
|
+
export const createMobileApiAuth0Config = () => createBaseConfig({
|
|
57
|
+
projectName: 'test-mobile-api-auth0',
|
|
58
|
+
platforms: ['mobile', 'api'],
|
|
59
|
+
authProvider: 'auth0',
|
|
60
|
+
});
|
|
61
|
+
// Triple platform factories
|
|
62
|
+
export const createFullStackCognitoConfig = () => createBaseConfig({
|
|
63
|
+
projectName: 'test-full-cognito',
|
|
64
|
+
platforms: ['web', 'mobile', 'api'],
|
|
65
|
+
authProvider: 'cognito',
|
|
66
|
+
});
|
|
67
|
+
export const createFullStackAuth0Config = () => createBaseConfig({
|
|
68
|
+
projectName: 'test-full-auth0',
|
|
69
|
+
platforms: ['web', 'mobile', 'api'],
|
|
70
|
+
authProvider: 'auth0',
|
|
71
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { describe, it, expect } from '@jest/globals';
|
|
2
|
+
import { TEST_MATRIX, getConfigsByTier, getConfigByName } from './matrix.js';
|
|
3
|
+
describe('Test Fixtures', () => {
|
|
4
|
+
describe('TEST_MATRIX', () => {
|
|
5
|
+
it('should define exactly 14 configurations', () => {
|
|
6
|
+
expect(TEST_MATRIX).toHaveLength(14);
|
|
7
|
+
});
|
|
8
|
+
it('should have unique names for all configurations', () => {
|
|
9
|
+
const names = TEST_MATRIX.map(c => c.name);
|
|
10
|
+
const uniqueNames = new Set(names);
|
|
11
|
+
expect(uniqueNames.size).toBe(names.length);
|
|
12
|
+
});
|
|
13
|
+
it('should have unique project names for all configurations', () => {
|
|
14
|
+
const projectNames = TEST_MATRIX.map(c => c.config.projectName);
|
|
15
|
+
const uniqueNames = new Set(projectNames);
|
|
16
|
+
expect(uniqueNames.size).toBe(projectNames.length);
|
|
17
|
+
});
|
|
18
|
+
it('should cover all 7 platform combinations', () => {
|
|
19
|
+
const platformSets = TEST_MATRIX.map(c => [...c.config.platforms].sort().join('+'));
|
|
20
|
+
const uniquePlatforms = new Set(platformSets);
|
|
21
|
+
expect(uniquePlatforms.size).toBe(7);
|
|
22
|
+
});
|
|
23
|
+
it('should cover both auth providers (cognito, auth0)', () => {
|
|
24
|
+
const authProviders = TEST_MATRIX.map(c => c.config.auth.provider);
|
|
25
|
+
const uniqueProviders = new Set(authProviders);
|
|
26
|
+
expect(uniqueProviders).toContain('cognito');
|
|
27
|
+
expect(uniqueProviders).toContain('auth0');
|
|
28
|
+
});
|
|
29
|
+
it('should not include auth provider none', () => {
|
|
30
|
+
const authProviders = TEST_MATRIX.map(c => c.config.auth.provider);
|
|
31
|
+
const uniqueProviders = new Set(authProviders);
|
|
32
|
+
expect(uniqueProviders).not.toContain('none');
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe('getConfigsByTier', () => {
|
|
36
|
+
it('should return 1 config for smoke tier', () => {
|
|
37
|
+
const configs = getConfigsByTier('smoke');
|
|
38
|
+
expect(configs).toHaveLength(1);
|
|
39
|
+
});
|
|
40
|
+
it('should return 5 configs for core tier (smoke + core)', () => {
|
|
41
|
+
const configs = getConfigsByTier('core');
|
|
42
|
+
expect(configs).toHaveLength(5);
|
|
43
|
+
});
|
|
44
|
+
it('should return all 14 configs for full tier', () => {
|
|
45
|
+
const configs = getConfigsByTier('full');
|
|
46
|
+
expect(configs).toHaveLength(14);
|
|
47
|
+
});
|
|
48
|
+
it('core tier should include at least one config per platform', () => {
|
|
49
|
+
const configs = getConfigsByTier('core');
|
|
50
|
+
const platforms = new Set();
|
|
51
|
+
for (const config of configs) {
|
|
52
|
+
for (const platform of config.config.platforms) {
|
|
53
|
+
platforms.add(platform);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
expect(platforms).toContain('web');
|
|
57
|
+
expect(platforms).toContain('mobile');
|
|
58
|
+
expect(platforms).toContain('api');
|
|
59
|
+
});
|
|
60
|
+
it('core tier should include at least one config per auth provider', () => {
|
|
61
|
+
const configs = getConfigsByTier('core');
|
|
62
|
+
const providers = new Set(configs.map(c => c.config.auth.provider));
|
|
63
|
+
expect(providers).toContain('cognito');
|
|
64
|
+
expect(providers).toContain('auth0');
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
describe('getConfigByName', () => {
|
|
68
|
+
it('should return config when name exists', () => {
|
|
69
|
+
const config = getConfigByName('web-api-cognito');
|
|
70
|
+
expect(config.name).toBe('web-api-cognito');
|
|
71
|
+
});
|
|
72
|
+
it('should throw when name does not exist', () => {
|
|
73
|
+
expect(() => getConfigByName('nonexistent')).toThrow('Configuration "nonexistent" not found in TEST_MATRIX');
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe('Config validity', () => {
|
|
77
|
+
it.each(TEST_MATRIX)('$name should have valid ProjectConfig structure', ({ config }) => {
|
|
78
|
+
// Required fields
|
|
79
|
+
expect(config.projectName).toBeDefined();
|
|
80
|
+
expect(config.platforms.length).toBeGreaterThan(0);
|
|
81
|
+
expect(config.awsRegion).toBeDefined();
|
|
82
|
+
expect(config.brandColor).toBeDefined();
|
|
83
|
+
expect(config.auth.provider).toBeDefined();
|
|
84
|
+
// Valid values
|
|
85
|
+
expect(['web', 'mobile', 'api']).toEqual(expect.arrayContaining(config.platforms));
|
|
86
|
+
expect(['cognito', 'auth0', 'none']).toContain(config.auth.provider);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { createWebCognitoConfig, createWebAuth0Config, createMobileCognitoConfig, createMobileAuth0Config, createApiCognitoConfig, createApiAuth0Config, createWebMobileCognitoConfig, createWebMobileAuth0Config, createWebApiCognitoConfig, createWebApiAuth0Config, createMobileApiCognitoConfig, createMobileApiAuth0Config, createFullStackCognitoConfig, createFullStackAuth0Config, } from './config-factories.js';
|
|
2
|
+
export { TEST_MATRIX, getConfigsByTier, getConfigByName, type TestTier, type TestConfiguration, } from './matrix.js';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { createWebCognitoConfig, createWebAuth0Config, createMobileCognitoConfig, createMobileAuth0Config, createApiCognitoConfig, createApiAuth0Config, createWebMobileCognitoConfig, createWebMobileAuth0Config, createWebApiCognitoConfig, createWebApiAuth0Config, createMobileApiCognitoConfig, createMobileApiAuth0Config, createFullStackCognitoConfig, createFullStackAuth0Config, } from './config-factories.js';
|
|
2
|
+
export { TEST_MATRIX, getConfigsByTier, getConfigByName, } from './matrix.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ProjectConfig } from '../../../types.js';
|
|
2
|
+
export type TestTier = 'smoke' | 'core' | 'full';
|
|
3
|
+
export interface TestConfiguration {
|
|
4
|
+
name: string;
|
|
5
|
+
config: ProjectConfig;
|
|
6
|
+
tier: TestTier;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Complete test matrix: 14 configurations (7 platforms x 2 auth providers)
|
|
10
|
+
*
|
|
11
|
+
* Tier assignments:
|
|
12
|
+
* - smoke: 1 config (quick sanity check)
|
|
13
|
+
* - core: 4 configs (PR validation - covers all platforms and auth providers)
|
|
14
|
+
* - full: 9 configs (release validation - remaining combinations)
|
|
15
|
+
*/
|
|
16
|
+
export declare const TEST_MATRIX: TestConfiguration[];
|
|
17
|
+
/**
|
|
18
|
+
* Get configurations by tier (cumulative)
|
|
19
|
+
* - 'smoke' returns smoke configs only (1)
|
|
20
|
+
* - 'core' returns smoke + core configs (5)
|
|
21
|
+
* - 'full' returns all configs (14)
|
|
22
|
+
*/
|
|
23
|
+
export declare function getConfigsByTier(tier: TestTier): TestConfiguration[];
|
|
24
|
+
/**
|
|
25
|
+
* Get a single configuration by name.
|
|
26
|
+
* Throws if not found (fail-fast for typos).
|
|
27
|
+
*/
|
|
28
|
+
export declare function getConfigByName(name: string): TestConfiguration;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as factories from './config-factories.js';
|
|
2
|
+
/**
|
|
3
|
+
* Complete test matrix: 14 configurations (7 platforms x 2 auth providers)
|
|
4
|
+
*
|
|
5
|
+
* Tier assignments:
|
|
6
|
+
* - smoke: 1 config (quick sanity check)
|
|
7
|
+
* - core: 4 configs (PR validation - covers all platforms and auth providers)
|
|
8
|
+
* - full: 9 configs (release validation - remaining combinations)
|
|
9
|
+
*/
|
|
10
|
+
export const TEST_MATRIX = [
|
|
11
|
+
// === SMOKE TIER (1 config) ===
|
|
12
|
+
// Most common configuration - web+api with cognito
|
|
13
|
+
{ name: 'web-api-cognito', tier: 'smoke', config: factories.createWebApiCognitoConfig() },
|
|
14
|
+
// === CORE TIER (4 configs) ===
|
|
15
|
+
// Ensures every platform and every auth provider is tested on PRs
|
|
16
|
+
{ name: 'web-cognito', tier: 'core', config: factories.createWebCognitoConfig() },
|
|
17
|
+
{ name: 'mobile-auth0', tier: 'core', config: factories.createMobileAuth0Config() },
|
|
18
|
+
{ name: 'api-cognito', tier: 'core', config: factories.createApiCognitoConfig() },
|
|
19
|
+
{ name: 'full-auth0', tier: 'core', config: factories.createFullStackAuth0Config() },
|
|
20
|
+
// === FULL TIER (9 remaining configs) ===
|
|
21
|
+
// All other combinations for release validation
|
|
22
|
+
{ name: 'web-auth0', tier: 'full', config: factories.createWebAuth0Config() },
|
|
23
|
+
{ name: 'mobile-cognito', tier: 'full', config: factories.createMobileCognitoConfig() },
|
|
24
|
+
{ name: 'api-auth0', tier: 'full', config: factories.createApiAuth0Config() },
|
|
25
|
+
{ name: 'web-mobile-cognito', tier: 'full', config: factories.createWebMobileCognitoConfig() },
|
|
26
|
+
{ name: 'web-mobile-auth0', tier: 'full', config: factories.createWebMobileAuth0Config() },
|
|
27
|
+
{ name: 'web-api-auth0', tier: 'full', config: factories.createWebApiAuth0Config() },
|
|
28
|
+
{ name: 'mobile-api-cognito', tier: 'full', config: factories.createMobileApiCognitoConfig() },
|
|
29
|
+
{ name: 'mobile-api-auth0', tier: 'full', config: factories.createMobileApiAuth0Config() },
|
|
30
|
+
{ name: 'full-cognito', tier: 'full', config: factories.createFullStackCognitoConfig() },
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* Get configurations by tier (cumulative)
|
|
34
|
+
* - 'smoke' returns smoke configs only (1)
|
|
35
|
+
* - 'core' returns smoke + core configs (5)
|
|
36
|
+
* - 'full' returns all configs (14)
|
|
37
|
+
*/
|
|
38
|
+
export function getConfigsByTier(tier) {
|
|
39
|
+
switch (tier) {
|
|
40
|
+
case 'smoke':
|
|
41
|
+
return TEST_MATRIX.filter(c => c.tier === 'smoke');
|
|
42
|
+
case 'core':
|
|
43
|
+
return TEST_MATRIX.filter(c => c.tier === 'smoke' || c.tier === 'core');
|
|
44
|
+
case 'full':
|
|
45
|
+
return TEST_MATRIX;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get a single configuration by name.
|
|
50
|
+
* Throws if not found (fail-fast for typos).
|
|
51
|
+
*/
|
|
52
|
+
export function getConfigByName(name) {
|
|
53
|
+
const config = TEST_MATRIX.find(c => c.name === name);
|
|
54
|
+
if (!config) {
|
|
55
|
+
throw new Error(`Configuration "${name}" not found in TEST_MATRIX`);
|
|
56
|
+
}
|
|
57
|
+
return config;
|
|
58
|
+
}
|