Skip to content

Commit

Permalink
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into dep-updat…
Browse files Browse the repository at this point in the history
…es-2025-01-06
  • Loading branch information
Zachary Rogers committed Jan 10, 2025
2 parents c501fda + fa6858f commit 285c78f
Show file tree
Hide file tree
Showing 103 changed files with 3,454 additions and 2,008 deletions.
16 changes: 8 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
name: Test Users Setup
command: |
if [ "${CIRCLE_BRANCH}" != "prod" ] && [ "$DEPLOY_EMPTY_PERSISTENCE" != "true" ]; then
npx ts-node --transpile-only scripts/user/setup-test-users.ts
./scripts/user/setup-test-users.ts
else
echo "skipping…"
fi
Expand All @@ -174,7 +174,7 @@ jobs:
--query 'DomainStatus.Endpoint' \
--output text)
export ELASTICSEARCH_ENDPOINT="$ELASTICSEARCH_ENDPOINT"
npx ts-node --transpile-only ./scripts/user/setup-glued-judges.ts
./scripts/user/setup-glued-judges.ts
else
npx ts-node --transpile-only ./scripts/circleci/judge/bulkImportJudgeUsers.ts | tee bulk-import-log.txt
fi
Expand Down Expand Up @@ -299,7 +299,7 @@ jobs:
name: Track successful migrations
command: |
if [ "$MIGRATE_FLAG" == "true" ]; then
npx ts-node --transpile-only ./scripts/migration/track-successful-migrations.ts
./scripts/migration/track-successful-migrations.ts
fi
- run:
name: Set Marker to Indicate Migration is Complete
Expand All @@ -311,7 +311,7 @@ jobs:
name: Begin Reindexing
command: |
if [ "$MIGRATE_FLAG" == "false" ]; then
npx ts-node --transpile-only ./scripts/elasticsearch/reindex.ts
./scripts/elasticsearch/reindex.ts
fi
- run:
name: Deploy Check Reindex Status Cron Lambda
Expand Down Expand Up @@ -390,7 +390,7 @@ jobs:
./scripts/env/env-for-circle.sh
- run:
name: Create and Enable Test User
command: npx ts-node --transpile-only ./scripts/user/create-and-enable-smoketest-user.ts
command: ./scripts/user/create-and-enable-smoketest-user.ts
- run:
name: 'Cypress Readonly Smoke Tests'
command: |
Expand All @@ -400,7 +400,7 @@ jobs:
set -e
- run:
name: Disable Test User
command: npx ts-node --transpile-only ./scripts/user/disable-smoketest-user.ts
command: ./scripts/user/disable-smoketest-user.ts
- run:
name: Kill Build if Smoketests Failed
command: |
Expand Down Expand Up @@ -842,7 +842,7 @@ jobs:
- run:
name: Start Glue Job
command: |
npx ts-node --transpile-only scripts/glue/start-glue-job.ts "efcms-${LOWER_ENV}-alpha"
./scripts/glue/start-glue-job.ts "efcms-${LOWER_ENV}-alpha"
- run:
name: Enable Check Glue Job Run State Cron
command: |
Expand Down Expand Up @@ -871,7 +871,7 @@ jobs:
- run:
name: Restore Postgres
command: |
TARGET_ENV=$LOWER_ENV TARGET_ACCOUNT_ID="${LOWER_ENV_ACCOUNT_ID}" npx ts-node --transpileOnly scripts/postgres/restoreDbFromSource.ts
TARGET_ENV=$LOWER_ENV TARGET_ACCOUNT_ID="${LOWER_ENV_ACCOUNT_ID}" ./scripts/postgres/restoreDbFromSource.ts
finish-glue-job:
docker:
Expand Down
2 changes: 1 addition & 1 deletion clear-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ echo "clearing dynamo"
npx ts-node --transpile-only ./web-api/clear-dynamodb-table.ts "efcms-${ENV}-${SOURCE_TABLE_VERSION}"
echo "setting up test users"
# shellcheck disable=SC1091
npx ts-node --transpile-only scripts/user/setup-test-users.ts "${ENV}"
./scripts/user/setup-test-users.ts "${ENV}"
echo "importing judge users"
npx ts-node --transpile-only ./scripts/circleci/judge/bulkImportJudgeUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Sometimes we need to query against information that isn't indexed in OpenSearch.
```
1. Run the `create-temporary-indices` script to create the new index (or indices, if you modified multiple mappings) from the locally-defined mappings:
```bash
npx ts-node --transpile-only scripts/elasticsearch/create-temporary-indices.ts
./scripts/elasticsearch/create-temporary-indices.ts
```
1. You can now query against your temporary index (or indices) by utilizing [searchClient](../../web-api/src/persistence/elasticsearch/searchClient.ts)'s `search` or `searchAll`:
```typescript
Expand Down
2 changes: 1 addition & 1 deletion docs/additional-resources/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Solution:
- This solution should only be used on non-prod environments. Clear the dynamo tables and recreate the users and judges.

```bash
npx ts-node --transpile-only scripts/user/setup-test-users.ts
./scripts/user/setup-test-users.ts
```

```bash
Expand Down
2 changes: 1 addition & 1 deletion docs/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ EF-CMS currently has both the concept of a deployment at a domain as well as a n
20. If the environment is a test environment, setup test users and judges so smoketests will pass:
```bash
npx ts-node --transpile-only scripts/user/setup-test-users.ts
./scripts/user/setup-test-users.ts
```
```bash
ENV=exp5 npx ts-node --transpile-only ./scripts/circleci/judge/bulkImportJudgeUsers.ts
Expand Down
2 changes: 1 addition & 1 deletion docs/operations/runbooks/add-or-update-judge-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This runbook describes the process of onboarding or updating a Judge user. DO NO
3. To update the test environment: Use the environment switcher and run `add-judge.ts` or `update-judge.ts` according to your needs, e.g.:
```
source ./scripts/env/set-env.zsh ustc-test
npx ts-node --transpile-only ./scripts/user/add-judge.ts ...
./scripts/user/add-judge.ts ...
```
These scripts will add/update the appropriate user records in Cognito and Dynamo.
4. To update the production environment: If you have access to the production environment, run either `add-judge.ts` or `update-judge.ts` as above. If you do not have access, hand off to a USTC engineer, linking to this documentation.
Expand Down
26 changes: 11 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@
"winston": "3.17.0"
},
"scripts": {
"admin:become-user": "npx ts-node --transpile-only scripts/user/become-user.ts",
"admin:create-user": "npx ts-node --transpile-only scripts/user/add-user.ts",
"admin:download-case-documents": "npx ts-node --transpile-only scripts/download-all-case-documents.ts",
"admin:lookup-user": "npx ts-node --transpile-only scripts/user/lookup-user.ts",
"admin:resend-service-email-to-irs-superuser": "npx ts-node --transpile-only scripts/email/resend-service-email-to-irs-superuser.ts",
"admin:become-user": "./scripts/user/become-user.ts",
"admin:create-user": "./scripts/user/add-user.ts",
"admin:download-case-documents": "./scripts/download-all-case-documents.ts",
"admin:lookup-user": "./scripts/user/lookup-user.ts",
"admin:resend-service-email-to-irs-superuser": "./scripts/email/resend-service-email-to-irs-superuser.ts",
"backup:dynamo-table": "./scripts/dynamo/backup-dynamo-table.sh",
"build:all": "npm run clean && npm run build:assets && npm run build:client",
"build:assets": "node shared/createModule.js",
Expand Down Expand Up @@ -180,10 +180,10 @@
"lint:swagger": "swagger-cli validate web-api/swagger.json && swagger-cli validate docs/api/v1.yaml && swagger-cli validate docs/api/v2.yaml",
"lint": "npm run lint:swagger & npm run lint:css & npm run lint:js/ts",
"loadtest:pdf-generation": "npx ts-node --transpile-only ./web-api/storage/scripts/loadTest/loadTestPdfGeneration.ts",
"maintenance:disengage": "ts-node ./scripts/dynamo/set-maintenance-mode.ts false",
"maintenance:engage": "ts-node ./scripts/dynamo/set-maintenance-mode.ts true",
"maintenance:disengage:local": ". ./setup-local-env.sh && npx ts-node --transpile-only scripts/set-maintenance-mode-locally.ts false",
"maintenance:engage:local": ". ./setup-local-env.sh && npx ts-node --transpile-only scripts/set-maintenance-mode-locally.ts true",
"maintenance:disengage": "./scripts/dynamo/set-maintenance-mode.ts false",
"maintenance:engage": "./scripts/dynamo/set-maintenance-mode.ts true",
"maintenance:disengage:local": ". ./setup-local-env.sh && ./scripts/set-maintenance-mode-locally.ts false",
"maintenance:engage:local": ". ./setup-local-env.sh && ./scripts/set-maintenance-mode-locally.ts true",
"migrate:local": "AWS_ACCESS_KEY_ID=S3RVER AWS_SECRET_ACCESS_KEY=S3RVER SOURCE_TABLE=efcms-local DESTINATION_TABLE=efcms-local-1 ts-node --transpile-only ./web-api/run-local-migration.ts",
"migration:cleanup": "./scripts/migration/update-deploy-table-after-migration.sh",
"migration:postgres": "npx ts-node --transpile-only ./web-api/src/persistence/postgres/utils/migrate/migrate.ts",
Expand All @@ -192,13 +192,9 @@
"postinstall": "husky install",
"print:success": "echo 'Build successful. You can access the site at http://localhost:1234'",
"reindex:elasticsearch": "./reindex-elasticsearch.sh",
"report:event-codes-by-year": "npx ts-node --transpile-only scripts/reports/event-codes-by-year.ts",
"report:petition-counts": "npx ts-node --transpile-only scripts/reports/petition-counts.ts",
"report:trial-sessions-by-fiscal-year": "npx ts-node --transpile-only scripts/reports/trial-sessions-by-fiscal-year.ts",
"report:trial-sessions-by-year": "npx ts-node --transpile-only scripts/reports/trial-sessions-by-calendar-year.ts",
"reset-cases": "./clear-env.sh",
"secrets:rotate-circleci": "scripts/user/rotate-circleci-secrets.sh",
"secrets:rotate-environment": "npx ts-node --transpile-only scripts/user/rotate-environment-secrets.ts",
"secrets:rotate-circleci": "./scripts/user/rotate-circleci-secrets.sh",
"secrets:rotate-environment": "./scripts/user/rotate-environment-secrets.ts",
"seed:db": "npx ts-node --transpile-only ./web-api/create-dynamo-tables.ts && npx ts-node --transpile-only ./web-api/seed-dynamo.ts",
"seed:elasticsearch": "./web-api/seed-elasticsearch.sh",
"seed:postgres": "npx ts-node --transpile-only ./web-api/src/persistence/postgres/utils/seed/seed.ts",
Expand Down
2 changes: 2 additions & 0 deletions scripts/checkAllFilesForTypeErrorCount.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env -S npx ts-node --transpile-only

import { spawnSync } from 'child_process';

function runTypescriptCommand(cwd: string): { stdout: string } {
Expand Down
29 changes: 19 additions & 10 deletions scripts/circleci/approve-pending-job.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import { approvePendingJob } from '../../shared/admin-tools/circleci/circleci-helper';
import { requireEnvVars } from '../../shared/admin-tools/util';
#!/usr/bin/env -S npx ts-node --transpile-only

requireEnvVars([
'APPROVAL_JOB_NAME',
'CIRCLE_MACHINE_USER_TOKEN',
'CIRCLE_WORKFLOW_ID',
]);
import {
type ScriptConfig,
parseArgsAndEnvVars,
} from '../helpers/parseArgsAndEnvVars';
import { approvePendingJob } from '../../shared/admin-tools/circleci/circleci-helper';

const apiToken = process.env.CIRCLE_MACHINE_USER_TOKEN!;
const jobName = process.env.APPROVAL_JOB_NAME!;
const workflowId = process.env.CIRCLE_WORKFLOW_ID!;
const scriptConfig: ScriptConfig = {
description: 'approve-pending-job - Approve a pending CircleCI job',
environment: {
apiToken: 'CIRCLE_MACHINE_USER_TOKEN',
jobName: 'APPROVAL_JOB_NAME',
workflowId: 'CIRCLE_WORKFLOW_ID',
},
};
const { apiToken, jobName, workflowId } = parseArgsAndEnvVars(scriptConfig) as {
apiToken: string;
jobName: string;
workflowId: string;
};

// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
Expand Down
23 changes: 18 additions & 5 deletions scripts/circleci/cancel-workflow.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import { cancelWorkflow } from '../../shared/admin-tools/circleci/circleci-helper';
import { requireEnvVars } from '../../shared/admin-tools/util';
#!/usr/bin/env -S npx ts-node --transpile-only

requireEnvVars(['CIRCLE_MACHINE_USER_TOKEN', 'CIRCLE_WORKFLOW_ID']);
import {
type ScriptConfig,
parseArgsAndEnvVars,
} from '../helpers/parseArgsAndEnvVars';
import { cancelWorkflow } from '../../shared/admin-tools/circleci/circleci-helper';

const apiToken = process.env.CIRCLE_MACHINE_USER_TOKEN!;
const workflowId = process.env.CIRCLE_WORKFLOW_ID!;
const scriptConfig: ScriptConfig = {
description: 'cancel-workflow - Cancel a CircleCI workflow',
environment: {
apiToken: 'CIRCLE_MACHINE_USER_TOKEN',
workflowId: 'CIRCLE_WORKFLOW_ID',
},
};
const { apiToken, workflowId } = parseArgsAndEnvVars(scriptConfig) as {
apiToken: string;
jobName: string;
workflowId: string;
};

// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
Expand Down
4 changes: 2 additions & 2 deletions scripts/circleci/sync-s3-buckets-with-timeout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ fi
if [[ "$S3_SYNC_RESULT" -eq 0 ]]; then
echo "Sync completed, approving referrer"
export APPROVAL_JOB_NAME="wait-for-s3-sync-workflow"
CIRCLE_WORKFLOW_ID="$REFERRER" npx ts-node --transpile-only ./scripts/circleci/approve-pending-job.ts
CIRCLE_WORKFLOW_ID="$REFERRER" ./scripts/circleci/approve-pending-job.ts
exit 0
fi

echo "Error syncing S3 buckets, canceling referrer"
CIRCLE_WORKFLOW_ID="$REFERRER" npx ts-node --transpile-only ./scripts/circleci/cancel-workflow.ts
CIRCLE_WORKFLOW_ID="$REFERRER" ./scripts/circleci/cancel-workflow.ts
exit $S3_SYNC_RESULT
2 changes: 2 additions & 0 deletions scripts/compareTypescriptErrors.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env -S npx ts-node --transpile-only

import { spawnSync } from 'child_process';

/*
Expand Down
47 changes: 34 additions & 13 deletions scripts/download-all-case-documents.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
// usage: npx ts-node --transpile-only scripts/download-all-case-documents.js "453-17"
#!/usr/bin/env -S npx ts-node --transpile-only

import { createApplicationContext } from '@web-api/applicationContext';
import {
type ScriptConfig,
parseArgsAndEnvVars,
} from './helpers/parseArgsAndEnvVars';
import {
type ServerApplicationContext,
createApplicationContext,
} from '@web-api/applicationContext';
import { getCaseByDocketNumber } from '@web-api/persistence/dynamo/cases/getCaseByDocketNumber';
import fs from 'fs';

const DOCKET_NUMBER = process.argv[2];

if (!DOCKET_NUMBER) {
console.error('Error: please provide a docket number.');
process.exit(1);
}
const scriptConfig: ScriptConfig = {
description:
'download-all-case-documents - Downloads all docket entries for the given docket number.',
environment: {
dynamoDbTableName: 'DYNAMODB_TABLE_NAME',
efcmsDomain: 'EFCMS_DOMAIN',
env: 'ENV',
},
parameters: {
docketNumber: {
position: 0,
required: true,
type: 'string',
},
},
requireActiveAwsSession: true,
};
const { docketNumber } = parseArgsAndEnvVars(scriptConfig) as {
docketNumber: string;
};

const OUTPUT_DIR = `${process.env.HOME}/Downloads/${DOCKET_NUMBER}`;
const OUTPUT_DIR = `${process.env.HOME}/Downloads/${docketNumber}`;

const downloadPdf = async ({
applicationContext,
docketEntryId,
filename,
path,
}: {
applicationContext: IApplicationContext;
applicationContext: ServerApplicationContext;
docketEntryId: string;
filename: string;
path: string;
Expand All @@ -42,10 +63,10 @@ const downloadPdf = async ({

const generateFilename = ({
caseCaption,
docketEntry: { docketNumber, documentType, index },
docketEntry: { documentType, index },
}: {
caseCaption: string;
docketEntry: { docketNumber: string; documentType: string; index: number };
docketEntry: { documentType: string; index: number };
}): string => {
const MAX_OVERALL_FILE_LENGTH = 64;
const EXT = '.pdf';
Expand All @@ -70,7 +91,7 @@ const generateFilename = ({
}
const caseEntity = await getCaseByDocketNumber({
applicationContext,
docketNumber: DOCKET_NUMBER,
docketNumber,
});
let numSealed = 0;
let numError = 0;
Expand Down
Loading

0 comments on commit 285c78f

Please sign in to comment.