declapract-typescript-ehmpathy 0.17.0 → 0.17.2

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.
Files changed (31) hide show
  1. package/dist/practices/artifact/best-practice/.declapract.readme.md +6 -0
  2. package/dist/practices/artifact/best-practice/artifact.yml +7 -0
  3. package/dist/practices/artifact/best-practice/package.json +8 -0
  4. package/dist/practices/artifact/best-practice/package.json.declapract.ts +3 -0
  5. package/dist/practices/cicd-deploy-package/best-practice/.github/workflows/publish-on-tag.yml +1 -0
  6. package/dist/practices/git/best-practice/.gitignore.declapract.ts +1 -0
  7. package/dist/practices/linting/best-practice/.eslintrc.js +1 -1
  8. package/dist/practices/persist-with-dynamodb/best-practice/package.json +7 -1
  9. package/dist/practices/persist-with-dynamodb/best-practice/provision/docker/integration-test-db/docker-compose.yml +9 -0
  10. package/dist/practices/persist-with-rds/best-practice/provision/docker/{integration_test_db → integration-test-db}/build-image.dockerfile +0 -0
  11. package/dist/practices/persist-with-rds/best-practice/provision/docker/{integration_test_db → integration-test-db}/docker-compose.yml +0 -0
  12. package/dist/practices/persist-with-rds/best-practice/provision/docker/{integration_test_db → integration-test-db}/init/.gitignore +0 -0
  13. package/dist/practices/persist-with-rds/best-practice/provision/docker/{integration_test_db → integration-test-db}/init/readme.md +0 -0
  14. package/dist/practices/persist-with-rds/best-practice/provision/docker/{integration_test_db → integration-test-db}/wait-for-postgres.sh +0 -0
  15. package/dist/practices/serverless/best-practice/serverless.yml +3 -0
  16. package/dist/practices/terraform/best-practice/provision/aws/environments/test/main.tf +4 -0
  17. package/dist/practices/testing/best-practice/jest.acceptance.config.ts +17 -0
  18. package/dist/practices/testing/best-practice/{jest.acceptance.env.js → jest.acceptance.env.ts} +0 -0
  19. package/dist/practices/testing/best-practice/jest.config.ts +4 -0
  20. package/dist/practices/testing/best-practice/jest.integration.config.ts +17 -0
  21. package/dist/practices/testing/best-practice/{jest.integration.env.js → jest.integration.env.ts} +10 -5
  22. package/dist/practices/testing/best-practice/jest.unit.config.ts +22 -0
  23. package/dist/practices/testing/best-practice/{jest.unit.env.js → jest.unit.env.ts} +1 -5
  24. package/dist/practices/testing/best-practice/package.json +4 -4
  25. package/dist/practices/typescript/best-practice/package.json +1 -1
  26. package/dist/practices/typescript/best-practice/tsconfig.json +3 -1
  27. package/package.json +1 -1
  28. package/dist/practices/testing/best-practice/jest.acceptance.config.js +0 -15
  29. package/dist/practices/testing/best-practice/jest.config.js +0 -1
  30. package/dist/practices/testing/best-practice/jest.integration.config.js +0 -10
  31. package/dist/practices/testing/best-practice/jest.unit.config.js +0 -15
@@ -0,0 +1,6 @@
1
+ using an artifact file ensures that our builds are easily reproducible and contain only the minimum required data
2
+
3
+ benefits
4
+ - maximizes lambda performance
5
+ - guarantees reproducibility
6
+ - speeds up serverless framework deployments
@@ -0,0 +1,7 @@
1
+ trace:
2
+ - 'dist/contract/handlers/**/*.js' # include all dependencies of the handlers
3
+
4
+ pick:
5
+ - 'dist/**/*.js.map' # include all of the source maps # TODO: update simple-artifact-builder to do this automatically for all files it includes
6
+ - 'config/*'
7
+ - 'package.json'
@@ -0,0 +1,8 @@
1
+ {
2
+ "devDependencies": {
3
+ "simple-artifact-builder": "@declapract{check.minVersion('1.1.6')}"
4
+ },
5
+ "scripts": {
6
+ "build:artifact": "npx simple-artifact-builder zip"
7
+ }
8
+ }
@@ -0,0 +1,3 @@
1
+ import { FileCheckType } from 'declapract';
2
+
3
+ export const check = FileCheckType.CONTAINS;
@@ -22,6 +22,7 @@ jobs:
22
22
  uses: actions/setup-node@v2
23
23
  with:
24
24
  node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
25
+ registry-url: 'https://registry.npmjs.org'
25
26
  cache: 'npm'
26
27
 
27
28
  - name: install
@@ -3,6 +3,7 @@ import expect from 'expect';
3
3
  import uniq from 'lodash.uniq';
4
4
 
5
5
  const expectedIgnores = [
6
+ '.artifact', // deployment artifacts from `simple-artifact-builder` are produced here
6
7
  '.env',
7
8
  '.serverless',
8
9
  '.terraform',
@@ -2,8 +2,8 @@ module.exports = {
2
2
  parser: '@typescript-eslint/parser', // Specifies the ESLint parser
3
3
  extends: [
4
4
  'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
5
+ 'plugin:import/recommended', // specifies good import rules
5
6
  'airbnb-typescript/base', // uses the airbnb recommended rules
6
- 'prettier/@typescript-eslint', // disables ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
7
7
  'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
8
8
  ],
9
9
  parserOptions: {
@@ -1,5 +1,11 @@
1
1
  {
2
2
  "dependencies": {
3
- "simple-dynamodb-client": "@declapract{check.minVersion('7.0.0')}"
3
+ "simple-dynamodb-client": "@declapract{check.minVersion('0.10.0')}"
4
+ },
5
+ "scripts": {
6
+ "provision:docker:up": "docker-compose -f ./provision/docker/integration_test_db/docker-compose.yml up -d --force-recreate --build --renew-anon-volumes",
7
+ "provision:docker:down": "docker-compose -f ./provision/docker/integration_test_db/docker-compose.yml down",
8
+ "provision:dynamodb:schema": "terraform -chdir=provision/aws/environments/test apply -auto-approve",
9
+ "provision:integration-test-db": "npm run provision:docker:up && npm run provision:dynamodb:schema"
4
10
  }
5
11
  }
@@ -0,0 +1,9 @@
1
+ version: '3.8'
2
+ services:
3
+ dynamodb-local:
4
+ command: '-jar DynamoDBLocal.jar -sharedDb -inMemory'
5
+ image: 'amazon/dynamodb-local:latest'
6
+ container_name: dynamodb-local
7
+ ports:
8
+ - '7337:8000'
9
+ working_dir: /home/dynamodblocal
@@ -1,5 +1,8 @@
1
1
  service: @declapract{variable.projectName}
2
2
 
3
+ package:
4
+ artifact: .artifact/contents.zip
5
+
3
6
  provider:
4
7
  name: aws
5
8
  runtime: nodejs16.x
@@ -1,6 +1,10 @@
1
1
  provider "aws" {
2
2
  region = "us-east-1"
3
3
  allowed_account_ids = ["@declapract{variable.awsAccountId.dev}"] # `test` environment resources are provisioned in the `dev` aws account
4
+
5
+ endpoints {
6
+ dynamodb = "http://localhost:7337/"
7
+ }
4
8
  }
5
9
 
6
10
  terraform {
@@ -0,0 +1,17 @@
1
+ import type { Config } from 'jest';
2
+
3
+ // https://jestjs.io/docs/configuration
4
+ const config: Config = {
5
+ verbose: true,
6
+ testEnvironment: 'node',
7
+ moduleFileExtensions: ['js', 'ts'],
8
+ transform: {
9
+ '^.+\\.[tj]sx?$': 'ts-jest', // https://kulshekhar.github.io/ts-jest/docs/getting-started/presets
10
+ },
11
+ testMatch: ['**/*.acceptance.test.ts'],
12
+ setupFiles: ['core-js'],
13
+ setupFilesAfterEnv: ['./jest.acceptance.env.ts'],
14
+ };
15
+
16
+ // eslint-disable-next-line import/no-default-export
17
+ export default config;
@@ -0,0 +1,4 @@
1
+ import config from './jest.unit.config';
2
+
3
+ // eslint-disable-next-line import/no-default-export
4
+ export default config;
@@ -0,0 +1,17 @@
1
+ import type { Config } from 'jest';
2
+
3
+ // https://jestjs.io/docs/configuration
4
+ const config: Config = {
5
+ verbose: true,
6
+ testEnvironment: 'node',
7
+ moduleFileExtensions: ['js', 'ts'],
8
+ transform: {
9
+ '^.+\\.[tj]sx?$': 'ts-jest', // https://kulshekhar.github.io/ts-jest/docs/getting-started/presets
10
+ },
11
+ testMatch: ['**/*.integration.test.ts'],
12
+ setupFiles: ['core-js'],
13
+ setupFilesAfterEnv: ['./jest.integration.env.ts'],
14
+ };
15
+
16
+ // eslint-disable-next-line import/no-default-export
17
+ export default config;
@@ -1,5 +1,8 @@
1
- // eslint-disable-next-line @typescript-eslint/no-var-requires
2
- const { stage, Stage } = require('./src/utils/environment');
1
+ import { stage, Stage } from './src/utils/environment';
2
+
3
+ // set a longer timeout
4
+ // eslint-disable-next-line no-undef
5
+ jest.setTimeout(90000); // since we're calling downstream apis
3
6
 
4
7
  /**
5
8
  * sanity check that integration tests are only run in 'test' environment
@@ -8,6 +11,8 @@ const { stage, Stage } = require('./src/utils/environment');
8
11
  if (stage !== Stage.TEST && process.env.I_KNOW_WHAT_IM_DOING !== 'true')
9
12
  throw new Error(`integration-test is not targeting stage 'test'`);
10
13
 
11
- // set a longer timeout
12
- // eslint-disable-next-line no-undef
13
- jest.setTimeout(90000); // since we're calling downstream apis
14
+ /**
15
+ * specify that dynamodb should use the local dynamodb database, if running in test env
16
+ */
17
+ if (stage === Stage.TEST)
18
+ process.env.USE_CUSTOM_DYNAMODB_ENDPOINT = 'http://localhost:7337';
@@ -0,0 +1,22 @@
1
+ import type { Config } from 'jest';
2
+
3
+ // https://jestjs.io/docs/configuration
4
+ const config: Config = {
5
+ verbose: true,
6
+ testEnvironment: 'node',
7
+ moduleFileExtensions: ['js', 'ts'],
8
+ transform: {
9
+ '^.+\\.[tj]sx?$': 'ts-jest', // https://kulshekhar.github.io/ts-jest/docs/getting-started/presets
10
+ },
11
+ testMatch: [
12
+ // note: order matters
13
+ '**/*.test.ts',
14
+ '!**/*.acceptance.test.ts',
15
+ '!**/*.integration.test.ts',
16
+ ],
17
+ setupFiles: ['core-js'],
18
+ setupFilesAfterEnv: ['./jest.unit.env.ts'],
19
+ };
20
+
21
+ // eslint-disable-next-line import/no-default-export
22
+ export default config;
@@ -1,10 +1,6 @@
1
- /* eslint-disable global-require */
2
- // eslint-disable-next-line @typescript-eslint/no-var-requires
3
- const { stage, Stage } = require('./src/utils/environment');
1
+ import { stage, Stage } from './src/utils/environment';
4
2
 
5
- // eslint-disable-next-line no-undef
6
3
  jest.mock('./src/utils/config/getConfig', () => ({
7
- // eslint-disable-next-line no-undef
8
4
  getConfig: jest.fn().mockImplementation(() => require('./config/test.json')), // mock that getConfig just returns plaintext test env config in unit tests
9
5
  }));
10
6
 
@@ -7,10 +7,10 @@
7
7
  "simple-lambda-testing-methods": "@declapract{check.minVersion('0.2.1')}"
8
8
  },
9
9
  "scripts": {
10
- "test:unit": "jest -c ./jest.unit.config.js --forceExit --coverage --verbose --passWithNoTests",
11
- "test:integration": "jest -c ./jest.integration.config.js --forceExit --coverage --verbose --passWithNoTests",
12
- "test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.js --forceExit --verbose --runInBand",
10
+ "test:unit": "jest -c ./jest.unit.config.ts --forceExit --coverage --verbose --passWithNoTests",
11
+ "test:integration": "jest -c ./jest.integration.config.ts --forceExit --coverage --verbose --passWithNoTests",
12
+ "test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand",
13
13
  "test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
14
- "test:acceptance": "npm run build && jest -c ./jest.acceptance.config.js --forceExit --verbose --runInBand"
14
+ "test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand"
15
15
  }
16
16
  }
@@ -6,7 +6,7 @@
6
6
  "scripts": {
7
7
  "build:clean": "rm dist/ -rf",
8
8
  "build:compile": "tsc -p ./tsconfig.build.json",
9
- "build": "npm run build:clean && npm run build:compile",
9
+ "build": "npm run build:clean && npm run build:compile && npm run build:artifact",
10
10
  "test:types": "tsc -p ./tsconfig.build.json --noEmit"
11
11
  }
12
12
  }
@@ -3,12 +3,14 @@
3
3
  "compilerOptions": {
4
4
  "importsNotUsedAsValues": "remove",
5
5
  "noPropertyAccessFromIndexSignature": false,
6
+ "noImplicitOverride": false,
6
7
  "resolveJsonModule": true,
7
8
  "sourceMap": true,
8
9
  "outDir": "dist",
10
+ "target": "es6",
9
11
  },
10
12
  "include": [
11
- "src/**/*.ts"
13
+ "**/*.ts"
12
14
  ],
13
15
  "exclude": [
14
16
  "dist",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "declapract-typescript-ehmpathy",
3
- "version": "0.17.0",
3
+ "version": "0.17.2",
4
4
  "description": "declapract best practices declarations for typescript",
5
5
  "main": "src/index.js",
6
6
  "repository": "ehmpathy/declapract-typescript-ehmpathy",
@@ -1,15 +0,0 @@
1
- // https://jestjs.io/docs/en/configuration.html
2
- module.exports = {
3
- preset: 'ts-jest',
4
- globals: {
5
- 'ts-jest': {
6
- tsconfig: 'tsconfig.json',
7
- },
8
- },
9
- verbose: true,
10
- testEnvironment: 'node',
11
- moduleFileExtensions: ['js', 'ts'],
12
- testMatch: ['**/*.acceptance.test.ts'],
13
- setupFiles: ['core-js'],
14
- setupFilesAfterEnv: ['./jest.acceptance.env.js'],
15
- };
@@ -1 +0,0 @@
1
- module.exports = require('./jest.unit.config'); // default to unit tests
@@ -1,10 +0,0 @@
1
- // https://jestjs.io/docs/en/configuration.html
2
- module.exports = {
3
- preset: 'ts-jest',
4
- verbose: true,
5
- testEnvironment: 'node',
6
- moduleFileExtensions: ['js', 'ts'],
7
- testMatch: ['**/*.integration.test.ts'],
8
- setupFiles: ['core-js'],
9
- setupFilesAfterEnv: ['./jest.integration.env.js'],
10
- };
@@ -1,15 +0,0 @@
1
- // https://jestjs.io/docs/en/configuration.html
2
- module.exports = {
3
- preset: 'ts-jest',
4
- verbose: true,
5
- testEnvironment: 'node',
6
- moduleFileExtensions: ['js', 'ts'],
7
- testMatch: [
8
- // note: order matters
9
- '**/*.test.ts',
10
- '!**/*.acceptance.test.ts',
11
- '!**/*.integration.test.ts',
12
- ],
13
- setupFiles: ['core-js'],
14
- setupFilesAfterEnv: ['./jest.unit.env.js'],
15
- };