Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/310-repeater-…
Browse files Browse the repository at this point in the history
…component
  • Loading branch information
danielnaab committed Jan 14, 2025
2 parents b32846a + bc1a1b6 commit 74c3300
Show file tree
Hide file tree
Showing 114 changed files with 13,056 additions and 18,639 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.18.0
v22.12.0
23 changes: 23 additions & 0 deletions documents/adr/0016-unused-css.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 16. Unused CSS removal

Date: 2025-01-10

## Status

Approved

## Context

During the build of the application, the entirety of USWDS was imported into the project to ease prototyping. As the application is nearing MVP the number of new components that will go into the application has started to level off, and we're nearing a point where the application will need to be production ready. Since CSS is a render-blocking asset, we want to provide a better experience for the users of the application by shipping less code down the wire.

## Decision

Instead of importing all USWDS as a SASS package, we will instead use the [packages](https://designsystem.digital.gov/components/packages/) imports that USWDS provides out of the box.

Using [PurgeCSS](https://purgecss.com/) and its corresponding Astro integration was also evaluated. Although this method resulted in a much smaller CSS file (110kb on disk compared to 575kb on disk for the USWDS packages build at the time of testing), it requires more setup and a careful audit to make we aren't being too aggressive with removal and accidentally removing styles we do need.

Using the provided USWDS packages is the sweet spot until there are visual regression and more comprehensive end-to-end test coverage available.

## Consequences

As new features are introduced, developers will need to also make sure that the styles are imported as well.
12 changes: 12 additions & 0 deletions infra/cdktf/src/lib/app-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { withBackend } from './backend';
import { CloudGovSpace } from './cloud.gov/space';
import { DataAwsSsmParameter } from '../../.gen/providers/aws/data-aws-ssm-parameter';

/**
* Register an application stack and translates the IaC to a template format via the `synth` function.
*/
export const registerAppStack = (
stackPrefix: string,
gitCommitHash: string
Expand All @@ -18,6 +21,15 @@ export const registerAppStack = (
app.synth();
};

/**
* Represents a Terraform stack designed to deploy and manage resources for the application using AWS and Cloud Foundry providers.
* This sets up necessary providers and resources specific to the application's deployment needs and handles configuration for the following:
*
* - AWS as a provider with a specific region.
* - Retrieves Cloud Foundry credentials from AWS SSM Parameter Store.
* - Sets up the Cloud Foundry provider for integration with the Cloud.gov environment.
* - Instantiates a CloudGovSpace resource with the provided git commit hash identifier.
*/
class AppStack extends TerraformStack {
constructor(scope: Construct, id: string, gitCommitHash: string) {
super(scope, id);
Expand Down
4 changes: 4 additions & 0 deletions infra/cdktf/src/lib/backend.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { S3Backend, TerraformStack } from 'cdktf';

/**
* Configures an S3 backend for a given Terraform stack to store the Terraform
* state in an S3 bucket with a specific key and region.
*/
export const withBackend = (stack: TerraformStack, stackPrefix: string) =>
new S3Backend(stack, {
bucket: '10x-atj-tfstate',
Expand Down
11 changes: 11 additions & 0 deletions infra/cdktf/src/lib/cloud.gov/node-astro.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { Construct } from 'constructs';
import * as cloudfoundry from '../../../.gen/providers/cloudfoundry';

/**
* Represents a service configuration for deploying an application on a Cloud Foundry platform.
* The `AstroService` class sets up the required resources, routes, services, and configurations
* needed to deploy, run, and maintain the application.
*
* ### Important Notes:
* - The RDS instance is configured to prevent destruction to ensure database persistence.
* - Timeout settings for the database instance allow for extended creation, update, and deletion times.
* - Routes and services are bound together to enable communication with the database and login service
*
*/
export class AstroService extends Construct {
constructor(
scope: Construct,
Expand Down
4 changes: 4 additions & 0 deletions infra/cdktf/src/lib/cloud.gov/space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { CLOUD_GOV_ORG_NAME } from './config';
import { AstroService } from './node-astro';
import { getSecret } from '../secrets';

/**
* Initializes a [Cloud.gov space](https://cloud.gov/docs/getting-started/concepts/#spaces) within a specified organization
* and deploys AstroService instance(s)
*/
export class CloudGovSpace extends Construct {
constructor(scope: Construct, id: string, gitCommitHash: string) {
super(scope, id);
Expand Down
4 changes: 4 additions & 0 deletions infra/cdktf/src/lib/rest-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { AssetType, TerraformAsset, TerraformOutput } from 'cdktf';
import { Construct } from 'constructs';
import * as aws from '../../.gen/providers/aws';

/**
* Creates and deploys infrastructure that includes an AWS Lambda function and API Gateway using Terraform.
* It also manages the creation of necessary roles, permissions, and assets required for these components.
*/
export class FormService extends Construct {
readonly url: string;

Expand Down
3 changes: 3 additions & 0 deletions infra/cdktf/src/lib/secrets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Construct } from 'constructs';
import { DataAwsSsmParameter } from '../../.gen/providers/aws/data-aws-ssm-parameter';

/**
* Retrieves the value of an AWS SSM Parameter Store secret.
*/
export const getSecret = (scope: Construct, name: string) => {
const parameter = new DataAwsSsmParameter(scope, name, {
name,
Expand Down
3 changes: 3 additions & 0 deletions infra/core/src/commands/delete-secret.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { SecretKey, SecretsVault } from '../lib/types.js';

/**
* Deletes a secret from the provided secrets vault.
*/
export const deleteSecret = async (vault: SecretsVault, key: SecretKey) => {
return await vault.deleteSecret(key);
};
3 changes: 3 additions & 0 deletions infra/core/src/commands/get-secret-key-list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { type SecretsVault } from '../lib/types.js';

/**
* Retrieves a list of secret keys from the provided secrets vault.
*/
export const getSecretKeyList = async (vault: SecretsVault) => {
return await vault.getSecretKeys();
};
3 changes: 3 additions & 0 deletions infra/core/src/commands/get-secret.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { type SecretsVault } from '../lib/types.js';

/**
* Retrieves a secret value from the provided secrets vault.
*/
export const getSecret = async (vault: SecretsVault, key: string) => {
return await vault.getSecret(key);
};
3 changes: 3 additions & 0 deletions infra/core/src/commands/get-secrets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { type SecretsVault } from '../lib/types.js';

/**
* Retrieves all secrets from the provided secrets vault.
*/
export const getSecrets = async (vault: SecretsVault) => {
const allKeys = await vault.getSecretKeys();
return await vault.getSecrets(allKeys);
Expand Down
13 changes: 13 additions & 0 deletions infra/core/src/commands/set-login-gov-secrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ type Context = {
generateLoginGovKey?: GenerateLoginGovKey;
};

/**
* Sets or retrieves Login.gov secrets for the given application key. It retrieves and returns the
* existing key pair or generates, stores, and returns new key pair if one didn't exist previously.
*/
export const setLoginGovSecrets = async (
ctx: Context,
env: DeployEnv,
Expand Down Expand Up @@ -54,12 +58,21 @@ export const setLoginGovSecrets = async (
};
};

/**
* Gets the file path for the Login.gov public key (`.pem`) file.
*/
const loginGovPublicKeyPath = (secretsDir: string, appKey: string) =>
`${secretsDir}/login-gov-${appKey}-key.pem`;

/**
* Gets the file path for the Login.gov private key certificate (`.pem`) file.
*/
const loginGovPrivateKeyPath = (secretsDir: string, appKey: string) =>
`${secretsDir}/login-gov-${appKey}-cert.pem`;

/**
* Generates a public-private key pair for Login.gov using OpenSSL.
*/
const generateLoginGovKey: GenerateLoginGovKey = async (
privateKeyPath: string,
publicKeyPath: string
Expand Down
3 changes: 3 additions & 0 deletions infra/core/src/commands/set-secret.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { type SecretsVault } from '../lib/types.js';

/**
* Sets a secret in a specified secrets vault.
*/
export const setSecret = async (
vault: SecretsVault,
key: string,
Expand Down
4 changes: 4 additions & 0 deletions infra/core/src/lib/adapters/aws-param-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import type {
SecretsVault,
} from '../types.js';

/**
* Provides an implementation of the SecretsVault interface leveraging
* AWS Systems Manager Parameter Store to manage secrets securely.
*/
export class AWSParameterStoreSecretsVault implements SecretsVault {
client: SSMClient;

Expand Down
3 changes: 3 additions & 0 deletions infra/core/src/lib/adapters/in-memory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { SecretMap, SecretsVault } from '../types.js';

/**
* Provides an in-memory implementation of the SecretsVault interface
*/
export class InMemorySecretsVault implements SecretsVault {
constructor(private secretMap: SecretMap) {}

Expand Down
5 changes: 5 additions & 0 deletions infra/core/src/values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ export type DeployEnv = 'dev' | 'staging';

const getPathPrefix = (env: DeployEnv) => `/tts-10x-atj-${env}`;

/**
* Generates an object containing the paths for private/public keys pairs
* associated with login.gov for an application in the specified
* deployment environment.
*/
export const getAppLoginGovKeys = (env: DeployEnv, appKey: string) => {
const prefix = getPathPrefix(env);
return {
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"format": "prettier --write \"packages/*/src/**/*.{js,jsx,ts,tsx,scss,css}\"",
"lint": "turbo run lint",
"pages": "rm -rf node_modules && npm i -g pnpm turbo && pnpm i && pnpm build && ln -sf ./apps/spotlight/dist _site",
"test": "vitest run && pnpm --filter @atj/design test:ci",
"test:ci": "vitest run && pnpm --filter @atj/design test:ci # --coverage.enabled --coverage.provider=v8 --coverage.reporter=text --coverage.reporter=json-summary --coverage.reporter=json --coverage.reportOnFailure",
"test": "vitest run",
"test:ci": "vitest run # --coverage.enabled --coverage.provider=v8 --coverage.reporter=text --coverage.reporter=json-summary --coverage.reporter=json --coverage.reportOnFailure",
"test:infra": "turbo run --filter=infra-cdktf test",
"typecheck": "tsc --build",
"prepare": "husky"
Expand All @@ -25,27 +25,27 @@
"pre-commit": "pnpm format"
},
"devDependencies": {
"@playwright/test": "^1.48.1",
"@rollup/plugin-commonjs": "^28.0.0",
"@playwright/test": "^1.49.1",
"@rollup/plugin-commonjs": "^28.0.2",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.3.0",
"@types/node": "^22.7.4",
"@vitest/browser": "^2.1.3",
"@vitest/coverage-v8": "^2.1.3",
"@vitest/ui": "^2.1.3",
"@rollup/plugin-node-resolve": "^16.0.0",
"@types/node": "^22.10.5",
"@vitest/browser": "^3.0.0-beta.4",
"@vitest/coverage-v8": "^3.0.0-beta.4",
"@vitest/ui": "^3.0.0-beta.4",
"esbuild": "^0.24.0",
"eslint": "^8.57.0",
"husky": "^9.1.6",
"npm-run-all": "^4.1.5",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"rollup": "^4.23.0",
"rollup": "^4.30.1",
"rollup-plugin-typescript2": "^0.36.0",
"ts-node": "^10.9.2",
"tsup": "^8.3.0",
"turbo": "^2.1.3",
"typescript": "^5.6.2",
"vitest": "^2.1.3",
"vitest-mock-extended": "^2.0.0"
"vitest": "^3.0.0-beta.4",
"vitest-mock-extended": "^2.0.2"
}
}
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
},
"devDependencies": {
"@types/better-sqlite3": "^7.6.11",
"vitest-fetch-mock": "^0.3.0"
"vitest-fetch-mock": "^0.4.3"
}
}
2 changes: 1 addition & 1 deletion packages/auth/src/repository/create-session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createSession } from './create-session.js';

describeDatabase('create session', () => {
it<DbTestContext>('fails with unknown userId', async ({ db }) => {
expect(() =>
await expect(() =>
createSession(db.ctx, {
id: '31b72aca-116e-412d-b9b8-467300a53748',
expiresAt: new Date(),
Expand Down
16 changes: 8 additions & 8 deletions packages/database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
"types": "dist/types/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"types": "./dist/types/index.d.ts"
"require": "./dist/cjs/index.js"
},
"./context": {
"types": "./dist/types/context/index.d.ts",
"import": "./dist/esm/context.js",
"require": "./dist/cjs/context.js",
"types": "./dist/types/context/index.d.ts"
"require": "./dist/cjs/context.js"
},
"./testing": {
"types": "./dist/types/testing.d.ts",
"import": "./dist/esm/testing.js",
"require": "./dist/cjs/testing.js",
"types": "./dist/types/testing.d.ts"
"require": "./dist/cjs/testing.js"
}
},
"scripts": {
Expand All @@ -33,7 +33,7 @@
"dependencies": {
"@atj/common": "workspace:*",
"@types/pg": "^8.11.6",
"better-sqlite3": "^11.1.2",
"better-sqlite3": "^11.7.2",
"knex": "^3.1.0",
"kysely": "^0.27.4",
"pg": "^8.12.0"
Expand All @@ -42,6 +42,6 @@
"@testcontainers/postgresql": "^10.13.2",
"@types/better-sqlite3": "^7.6.11",
"testcontainers": "^10.13.2",
"vite-tsconfig-paths": "^4.3.2"
"vite-tsconfig-paths": "^5.1.4"
}
}
4 changes: 2 additions & 2 deletions packages/database/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import typescript from 'rollup-plugin-typescript2';

import packageJson from './package.json' assert { type: 'json' };
import workspacePackageJson from '../../package.json' assert { type: 'json' };
import packageJson from './package.json' with { type: 'json' };
import workspacePackageJson from '../../package.json' with { type: 'json' };

export default {
//input: ['src/index.ts', 'src/context/index.ts', 'src/testing.ts'],
Expand Down
1 change: 1 addition & 0 deletions packages/design/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const config: StorybookConfig = {
getAbsolutePath('@storybook/addon-interactions'),
getAbsolutePath('@storybook/addon-a11y'),
getAbsolutePath('@storybook/addon-coverage'),
getAbsolutePath('@storybook/experimental-addon-test'),
],
core: {
disableTelemetry: true,
Expand Down
Loading

0 comments on commit 74c3300

Please sign in to comment.