declapract-typescript-ehmpathy 0.17.0
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/declapract.declare.yml +4 -0
- package/dist/examples/todo.md +1 -0
- package/dist/getVariables.ts +27 -0
- package/dist/practices/cicd-deploy-package/bad-practices/old-names/.github/workflows/publish_on_tag.yml.declapract.ts +3 -0
- package/dist/practices/cicd-deploy-package/best-practice/.declapract.readme.md +2 -0
- package/dist/practices/cicd-deploy-package/best-practice/.github/workflows/publish-on-tag.yml +36 -0
- package/dist/practices/cicd-deploy-service/bad-practices/old-names/.github/workflows/deploy_dev_on_main.yml.declapract.ts +3 -0
- package/dist/practices/cicd-deploy-service/bad-practices/old-names/.github/workflows/deploy_dev_on_master.yml.declapract.ts +3 -0
- package/dist/practices/cicd-deploy-service/bad-practices/old-names/.github/workflows/deploy_on_tag.yml.declapract.ts +3 -0
- package/dist/practices/cicd-deploy-service/bad-practices/old-names/.github/workflows/deploy_prod_on_tag.yml.declapract.ts +3 -0
- package/dist/practices/cicd-deploy-service/best-practice/.declapract.readme.md +4 -0
- package/dist/practices/cicd-deploy-service/best-practice/.github/workflows/deploy-dev-on-main.yml +59 -0
- package/dist/practices/cicd-deploy-service/best-practice/.github/workflows/deploy-prod-on-tag.yml +74 -0
- package/dist/practices/cicd-integrate/bad-practices/old-names/.github/workflows/ci-on-commit.yml.declapract.ts +3 -0
- package/dist/practices/cicd-integrate/bad-practices/old-names/.github/workflows/ci_on_commit.yml.declapract.ts +3 -0
- package/dist/practices/cicd-integrate/bad-practices/old-names/.github/workflows/test_on_commit.yml.declapract.ts +3 -0
- package/dist/practices/cicd-integrate/best-practice/.declapract.readme.md +3 -0
- package/dist/practices/cicd-integrate/best-practice/.github/workflows/pr-release-on-main.yml +17 -0
- package/dist/practices/cicd-integrate/best-practice/.github/workflows/test-on-commit.yml +285 -0
- package/dist/practices/config/bad-practices/configs-contain-wrong-account-id/config/dev.json.declapract.ts +9 -0
- package/dist/practices/config/bad-practices/configs-contain-wrong-account-id/config/prod.json.declapract.ts +9 -0
- package/dist/practices/config/bad-practices/configs-contain-wrong-account-id/config/test.json.declapract.ts +9 -0
- package/dist/practices/config/bad-practices/divergent-config-shapes/.declapract.readme.md +8 -0
- package/dist/practices/config/bad-practices/divergent-config-shapes/config/dev.json.declapract.ts +37 -0
- package/dist/practices/config/bad-practices/divergent-config-shapes/config/prod.json.declapract.ts +37 -0
- package/dist/practices/config/bad-practices/in-util-dir-directly/.declapract.readme.md +1 -0
- package/dist/practices/config/bad-practices/in-util-dir-directly/src/<star><star>/<star>.ts.declapract.ts +16 -0
- package/dist/practices/config/bad-practices/in-util-dir-directly/src/utils/config.integration.test.ts.declapract.ts +3 -0
- package/dist/practices/config/bad-practices/in-util-dir-directly/src/utils/config.ts.declapract.ts +3 -0
- package/dist/practices/config/bad-practices/promise-config/src/<star><star>/<star>.ts.declapract.ts +19 -0
- package/dist/practices/config/best-practice/config/dev.json +3 -0
- package/dist/practices/config/best-practice/config/dev.json.declapract.ts +3 -0
- package/dist/practices/config/best-practice/config/prod.json +3 -0
- package/dist/practices/config/best-practice/config/prod.json.declapract.ts +3 -0
- package/dist/practices/config/best-practice/config/test.json +3 -0
- package/dist/practices/config/best-practice/config/test.json.declapract.ts +3 -0
- package/dist/practices/config/best-practice/nontyped_modules/config-with-paramstore.d.ts +1 -0
- package/dist/practices/config/best-practice/package.json +5 -0
- package/dist/practices/config/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/config/best-practice/provision/aws/product/parameter-store.tf +3 -0
- package/dist/practices/config/best-practice/provision/aws/product/parameter-store.tf.declapract.ts +16 -0
- package/dist/practices/config/best-practice/provision/aws/product/variables.tf +3 -0
- package/dist/practices/config/best-practice/provision/aws/product/variables.tf.declapract.ts +3 -0
- package/dist/practices/config/best-practice/src/utils/config/Config.ts +1 -0
- package/dist/practices/config/best-practice/src/utils/config/Config.ts.declapract.ts +7 -0
- package/dist/practices/config/best-practice/src/utils/config/getConfig.integration.test.ts +8 -0
- package/dist/practices/config/best-practice/src/utils/config/getConfig.ts +8 -0
- package/dist/practices/config/best-practice/src/utils/environment.ts +3 -0
- package/dist/practices/config/best-practice/src/utils/environment.ts.declapract.ts +3 -0
- package/dist/practices/conventional-commits/best-practice/.declapract.readme.md +5 -0
- package/dist/practices/conventional-commits/best-practice/.husky/commit-msg +4 -0
- package/dist/practices/conventional-commits/best-practice/commitlint.config.js +4 -0
- package/dist/practices/conventional-commits/best-practice/package.json +17 -0
- package/dist/practices/conventional-commits/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/dates-and-times/bad-practices/moment/.declapract.readme.md +9 -0
- package/dist/practices/dates-and-times/bad-practices/moment/package.json.declapract.ts +12 -0
- package/dist/practices/dates-and-times/best-practice/.declapract.readme.md +1 -0
- package/dist/practices/dates-and-times/best-practice/package.json +5 -0
- package/dist/practices/dates-and-times/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/directory-structure-src/bad-practices/model-dir/.declapract.readme.md +2 -0
- package/dist/practices/directory-structure-src/bad-practices/model-dir/src/<star><star>/<star>.ts.declapract.ts +44 -0
- package/dist/practices/directory-structure-src/bad-practices/model-dir/src/model/<star><star>/<star>.ts.declapract.ts +16 -0
- package/dist/practices/directory-structure-src/bad-practices/services-dir/.declapract.readme.md +5 -0
- package/dist/practices/directory-structure-src/bad-practices/services-dir/src/services/<star><star>/<star>.ts.declapract.ts +3 -0
- package/dist/practices/directory-structure-src/best-practice/.declapract.readme.md +32 -0
- package/dist/practices/directory-structure-src/best-practice/src/contract/<star><star>/<star>.ts.declapract.ts +4 -0
- package/dist/practices/directory-structure-src/best-practice/src/data/clients/<star><star>/<star>.ts.declapract.ts +3 -0
- package/dist/practices/directory-structure-src/best-practice/src/data/dao/<star><star>/<star>.ts.declapract.ts +3 -0
- package/dist/practices/directory-structure-src/best-practice/src/domain/constants.ts.declapract.ts +15 -0
- package/dist/practices/directory-structure-src/best-practice/src/domain/index.ts.declapract.ts +3 -0
- package/dist/practices/directory-structure-src/best-practice/src/domain/objects/index.ts.declapract.ts +4 -0
- package/dist/practices/directory-structure-src/best-practice/src/logic/<star><star>/<star>.ts.declapract.ts +4 -0
- package/dist/practices/domain/bad-practices/schematic-joi-model/src/domain/<star><star>/<star>.ts.declapract.ts +16 -0
- package/dist/practices/domain/best-practice/package.json +7 -0
- package/dist/practices/domain/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/domain/best-practice/src/domain/objects/index.ts.declapract.ts +4 -0
- package/dist/practices/environments/best-practice/.declapract.readme.md +30 -0
- package/dist/practices/environments/best-practice/provision/aws/environments/dev/main.tf.declapract.ts +3 -0
- package/dist/practices/environments/best-practice/provision/aws/environments/prod/main.tf.declapract.ts +3 -0
- package/dist/practices/environments/best-practice/provision/aws/environments/test/main.tf.declapract.ts +3 -0
- package/dist/practices/environments/best-practice/src/utils/environment.ts +35 -0
- package/dist/practices/errors/best-practice/src/utils/errors/UnexpectedCodePathError.ts +14 -0
- package/dist/practices/format/best-practice/package.json +6 -0
- package/dist/practices/format/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/git/best-practice/.gitignore.declapract.ts +29 -0
- package/dist/practices/lambda-clients/bad-practices/lambda-service-client-package/.declapract.readme.md +1 -0
- package/dist/practices/lambda-clients/bad-practices/lambda-service-client-package/package.json +5 -0
- package/dist/practices/lambda-clients/bad-practices/lambda-service-client-package/package.json.declapract.ts +16 -0
- package/dist/practices/lambda-clients/best-practice/package.json +5 -0
- package/dist/practices/lambda-clients/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/lambda-clients/best-practice/src/data/clients/<star>.ts +1 -0
- package/dist/practices/lambda-clients/best-practice/src/data/clients/<star>.ts.declapract.ts +3 -0
- package/dist/practices/lambda-handlers/best-practice/package.json +9 -0
- package/dist/practices/lambda-handlers/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/lambda-handlers/best-practice/src/contract/handlers/<star><star>/<star>.declapract.ts +3 -0
- package/dist/practices/linting/best-practice/.eslintrc.js +44 -0
- package/dist/practices/linting/best-practice/package.json +16 -0
- package/dist/practices/linting/best-practice/package.json.declapract.ts +4 -0
- package/dist/practices/logging/best-practice/package.json +5 -0
- package/dist/practices/logging/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/logging/best-practice/src/utils/logger.ts +3 -0
- package/dist/practices/node/bad-practices/license/package.json.declapract.ts +22 -0
- package/dist/practices/node/best-practice/.nvmrc +1 -0
- package/dist/practices/node/best-practice/package.json +11 -0
- package/dist/practices/node/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/node/best-practice/readme.md +1 -0
- package/dist/practices/node/best-practice/readme.md.declapract.ts +3 -0
- package/dist/practices/nonpublished-modules/.declapract.readme.md +5 -0
- package/dist/practices/nonpublished-modules/bad-practices/ahbode-standard-lambda-handler/.declapract.readme.md +1 -0
- package/dist/practices/nonpublished-modules/bad-practices/ahbode-standard-lambda-handler/src/__nonpublished_modules__/ahbode-standard-lambda-handler/<star><star>/<star>.ts.declapract.ts +3 -0
- package/dist/practices/nonpublished-modules/bad-practices/ahbode-standard-lambda-handler/src/contract/handlers/<star>.integration.test.ts +1 -0
- package/dist/practices/nonpublished-modules/bad-practices/ahbode-standard-lambda-handler/src/contract/handlers/<star>.integration.test.ts.declapract.ts +15 -0
- package/dist/practices/nonpublished-modules/bad-practices/ahbode-standard-lambda-handler/src/contract/handlers/<star>.ts +1 -0
- package/dist/practices/nonpublished-modules/bad-practices/ahbode-standard-lambda-handler/src/contract/handlers/<star>.ts.declapract.ts +13 -0
- package/dist/practices/nonpublished-modules/bad-practices/deep-omit/.declapract.readme.md +1 -0
- package/dist/practices/nonpublished-modules/bad-practices/deep-omit/src/__nonpublished_modules__/deep-omit/<star><star>/<star>.ts.declapract.ts +3 -0
- package/dist/practices/nonpublished-modules/bad-practices/deep-omit/src/data/dao/<star><star>/<star>.integration.test.ts +1 -0
- package/dist/practices/nonpublished-modules/bad-practices/deep-omit/src/data/dao/<star><star>/<star>.integration.test.ts.declapract.ts +18 -0
- package/dist/practices/nonpublished-modules/bad-practices/simple-dynamodb-client/.declapract.readme.md +1 -0
- package/dist/practices/nonpublished-modules/bad-practices/simple-dynamodb-client/src/__nonpublished_modules__/simple-dynamodb-client/<star><star>/<star>.ts.declapract.ts +3 -0
- package/dist/practices/package-json-order/best-practice/.declapract.readme.md +3 -0
- package/dist/practices/package-json-order/best-practice/package.json.declapract.ts +171 -0
- package/dist/practices/persist-with-dynamodb/best-practice/package.json +5 -0
- package/dist/practices/persist-with-dynamodb/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/persist-with-rds/bad-practices/non-prefixed-manual-init-sqls/provision/schema/sql/init/database.sql.declapract.ts +3 -0
- package/dist/practices/persist-with-rds/bad-practices/non-prefixed-manual-init-sqls/provision/schema/sql/init/extensions.sql.declapract.ts +13 -0
- package/dist/practices/persist-with-rds/bad-practices/non-prefixed-manual-init-sqls/provision/schema/sql/init/schema.sql.declapract.ts +3 -0
- package/dist/practices/persist-with-rds/bad-practices/non-prefixed-manual-init-sqls/provision/schema/sql/init/user.cicd.sql.declapract.ts +3 -0
- package/dist/practices/persist-with-rds/bad-practices/non-prefixed-manual-init-sqls/provision/schema/sql/init/user.datalakedb.sql.declapract.ts +3 -0
- package/dist/practices/persist-with-rds/bad-practices/non-prefixed-manual-init-sqls/readme.md +5 -0
- package/dist/practices/persist-with-rds/bad-practices/old-config-file-names/codegen.sql.yml.declapract.ts +3 -0
- package/dist/practices/persist-with-rds/bad-practices/schema-entities-dir/.declapract.readme.md +1 -0
- package/dist/practices/persist-with-rds/bad-practices/schema-entities-dir/provision/schema/entities/<star>.ts.declapract.ts +12 -0
- package/dist/practices/persist-with-rds/bad-practices/schema-entities-dir/provision/schema/sql/entities.yml.declapract.ts +13 -0
- package/dist/practices/persist-with-rds/best-practice/.declapract.readme.md +6 -0
- package/dist/practices/persist-with-rds/best-practice/codegen.sql.dao.yml +18 -0
- package/dist/practices/persist-with-rds/best-practice/codegen.sql.dao.yml.declapract.ts +3 -0
- package/dist/practices/persist-with-rds/best-practice/codegen.sql.schema.yml +6 -0
- package/dist/practices/persist-with-rds/best-practice/codegen.sql.types.yml +15 -0
- package/dist/practices/persist-with-rds/best-practice/config/dev.json +20 -0
- package/dist/practices/persist-with-rds/best-practice/config/dev.json.declapract.ts +15 -0
- package/dist/practices/persist-with-rds/best-practice/config/prod.json +20 -0
- package/dist/practices/persist-with-rds/best-practice/config/prod.json.declapract.ts +3 -0
- package/dist/practices/persist-with-rds/best-practice/config/test.json +20 -0
- package/dist/practices/persist-with-rds/best-practice/config/test.json.declapract.ts +3 -0
- package/dist/practices/persist-with-rds/best-practice/package.json +27 -0
- package/dist/practices/persist-with-rds/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/persist-with-rds/best-practice/provision/aws/product/parameter-store.tf +24 -0
- package/dist/practices/persist-with-rds/best-practice/provision/aws/product/parameter-store.tf.declapract.ts +18 -0
- package/dist/practices/persist-with-rds/best-practice/provision/docker/integration_test_db/build-image.dockerfile +7 -0
- package/dist/practices/persist-with-rds/best-practice/provision/docker/integration_test_db/docker-compose.yml +13 -0
- package/dist/practices/persist-with-rds/best-practice/provision/docker/integration_test_db/init/.gitignore +3 -0
- package/dist/practices/persist-with-rds/best-practice/provision/docker/integration_test_db/init/readme.md +3 -0
- package/dist/practices/persist-with-rds/best-practice/provision/docker/integration_test_db/wait-for-postgres.sh +15 -0
- package/dist/practices/persist-with-rds/best-practice/provision/schema/connection.config.js +23 -0
- package/dist/practices/persist-with-rds/best-practice/provision/schema/control.yml +7 -0
- package/dist/practices/persist-with-rds/best-practice/provision/schema/deploy.database.sh +71 -0
- package/dist/practices/persist-with-rds/best-practice/provision/schema/sql/init/.database.sql +10 -0
- package/dist/practices/persist-with-rds/best-practice/provision/schema/sql/init/.extensions.sql +16 -0
- package/dist/practices/persist-with-rds/best-practice/provision/schema/sql/init/.extensions.sql.declapract.ts +37 -0
- package/dist/practices/persist-with-rds/best-practice/provision/schema/sql/init/.schema.sql +11 -0
- package/dist/practices/persist-with-rds/best-practice/provision/schema/sql/init/.user.cicd.sql +14 -0
- package/dist/practices/persist-with-rds/best-practice/provision/schema/sql/init/.user.datalakedb.sql +12 -0
- package/dist/practices/persist-with-rds/best-practice/provision/schema/sql/init/default_transaction_isolation.sql +6 -0
- package/dist/practices/persist-with-rds/best-practice/provision/schema/sql/init/user.service.sql +16 -0
- package/dist/practices/persist-with-rds/best-practice/provision/schema/sql/init.yml +9 -0
- package/dist/practices/persist-with-rds/best-practice/provision/schema/sql/init.yml.declapract.ts +3 -0
- package/dist/practices/persist-with-rds/best-practice/src/utils/config/getConfig.ts +2 -0
- package/dist/practices/persist-with-rds/best-practice/src/utils/config/getConfig.ts.declapract.ts +3 -0
- package/dist/practices/persist-with-rds/best-practice/src/utils/database/getDatabaseConnection.integration.test.ts +10 -0
- package/dist/practices/persist-with-rds/best-practice/src/utils/database/getDatabaseConnection.ts +65 -0
- package/dist/practices/persist-with-rds/best-practice/src/utils/database/withDatabaseConnection.ts +38 -0
- package/dist/practices/persist-with-rds/best-practice/src/utils/database/withDatabaseTransaction.ts +20 -0
- package/dist/practices/prettier/bad-practices/format-script/package.json.declapract.ts +26 -0
- package/dist/practices/prettier/best-practice/.prettierignore +1 -0
- package/dist/practices/prettier/best-practice/package.json +10 -0
- package/dist/practices/prettier/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/prettier/best-practice/prettier.config.js +9 -0
- package/dist/practices/runtime-type-checking/bad-practices/joi-types/package.json +5 -0
- package/dist/practices/runtime-type-checking/bad-practices/joi-types/package.json.declapract.ts +18 -0
- package/dist/practices/runtime-type-checking/bad-practices/old-joi-syntax-valid-input-cant-be-array/.declapract.readme.md +1 -0
- package/dist/practices/runtime-type-checking/bad-practices/old-joi-syntax-valid-input-cant-be-array/src/<star><star>/<star>.ts.declapract.ts +15 -0
- package/dist/practices/runtime-type-checking/best-practice/package.json +5 -0
- package/dist/practices/runtime-type-checking/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/serverless/bad-practices/generic-deploy-script/package.json +8 -0
- package/dist/practices/serverless/bad-practices/generic-deploy-script/package.json.declapract.ts +23 -0
- package/dist/practices/serverless/bad-practices/old-sls-plugins/package.json +6 -0
- package/dist/practices/serverless/bad-practices/old-sls-plugins/package.json.declapract.ts +19 -0
- package/dist/practices/serverless/best-practice/package.json +11 -0
- package/dist/practices/serverless/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/serverless/best-practice/serverless.yml +70 -0
- package/dist/practices/serverless/best-practice/serverless.yml.declapract.ts +26 -0
- package/dist/practices/terraform/bad-practices/terraform-dir/.declapract.readme.md +8 -0
- package/dist/practices/terraform/bad-practices/terraform-dir/provision/terraform/<star><star>/.gitignore.declapract.ts +12 -0
- package/dist/practices/terraform/bad-practices/terraform-dir/provision/terraform/<star><star>/<star>.hcl.declapract.ts +12 -0
- package/dist/practices/terraform/bad-practices/terraform-dir/provision/terraform/<star><star>/<star>.tf.declapract.ts +12 -0
- package/dist/practices/terraform/best-practice/.terraform-version +1 -0
- package/dist/practices/terraform/best-practice/package.json +6 -0
- package/dist/practices/terraform/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/terraform/best-practice/provision/aws/environments/dev/main.tf +18 -0
- package/dist/practices/terraform/best-practice/provision/aws/environments/dev/versions.tf +9 -0
- package/dist/practices/terraform/best-practice/provision/aws/environments/prod/main.tf +18 -0
- package/dist/practices/terraform/best-practice/provision/aws/environments/prod/versions.tf +9 -0
- package/dist/practices/terraform/best-practice/provision/aws/environments/test/main.tf +18 -0
- package/dist/practices/terraform/best-practice/provision/aws/environments/test/versions.tf +9 -0
- package/dist/practices/terraform/best-practice/provision/aws/product/variables.tf +14 -0
- package/dist/practices/terraform/best-practice/provision/github/environment/import-existing-repo.sh +12 -0
- package/dist/practices/terraform/best-practice/provision/github/environment/main.tf +20 -0
- package/dist/practices/terraform/best-practice/provision/github/environment/versions.tf +9 -0
- package/dist/practices/terraform/best-practice/provision/github/product/repository.tf +70 -0
- package/dist/practices/testing/bad-practices/mocks/.declapract.readme.md +8 -0
- package/dist/practices/testing/bad-practices/mocks/<star><star>/__mock__/<star>.js +3 -0
- package/dist/practices/testing/bad-practices/mocks/<star><star>/__mock__/<star>.ts +3 -0
- package/dist/practices/testing/bad-practices/old-acceptance-test-utils/acceptance/_utils/getDataFromLastOpenBracketAtStartOfLine.ts.declapract.ts +3 -0
- package/dist/practices/testing/bad-practices/old-acceptance-test-utils/acceptance/_utils/invokeLambda.ts.declapract.ts +3 -0
- package/dist/practices/testing/bad-practices/old-acceptance-test-utils/acceptance/lambdas/<star>.ts.declapract.ts +44 -0
- package/dist/practices/testing/bad-practices/old-acceptance-test-utils-2/acceptance/__test_utils__/environment.ts.declapract.ts +3 -0
- package/dist/practices/testing/bad-practices/old-acceptance-test-utils-2/acceptance/lambdas/<star>.ts.declapract.ts +22 -0
- package/dist/practices/testing/bad-practices/old-acceptance-test-utils-3/acceptance/_utils/environment.ts.declapract.ts +3 -0
- package/dist/practices/testing/bad-practices/old-acceptance-test-utils-3/acceptance/lambdas/<star>.ts.declapract.ts +18 -0
- package/dist/practices/testing/bad-practices/old-extension-pattern/.declapract.readme.md +3 -0
- package/dist/practices/testing/bad-practices/old-extension-pattern/<star><star>/<star>.test.acceptance.ts.declapract.ts +11 -0
- package/dist/practices/testing/bad-practices/old-extension-pattern/<star><star>/<star>.test.integration.ts.declapract.ts +11 -0
- package/dist/practices/testing/best-practice/.declapract.readme.md +45 -0
- package/dist/practices/testing/best-practice/acceptance/<star><star>/<star>.acceptance.test.ts.declapract.ts +3 -0
- package/dist/practices/testing/best-practice/acceptance/environment.ts +5 -0
- package/dist/practices/testing/best-practice/acceptance/lambdas/<star>.acceptance.test.ts.declapract.ts +32 -0
- package/dist/practices/testing/best-practice/jest.acceptance.config.js +15 -0
- package/dist/practices/testing/best-practice/jest.acceptance.env.js +2 -0
- package/dist/practices/testing/best-practice/jest.config.js +1 -0
- package/dist/practices/testing/best-practice/jest.integration.config.js +10 -0
- package/dist/practices/testing/best-practice/jest.integration.env.js +13 -0
- package/dist/practices/testing/best-practice/jest.unit.config.js +15 -0
- package/dist/practices/testing/best-practice/jest.unit.env.js +16 -0
- package/dist/practices/testing/best-practice/package.json +16 -0
- package/dist/practices/testing/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/testing/best-practice/src/<star><star>/<star>.integration.test.ts.declapract.ts +3 -0
- package/dist/practices/testing/best-practice/src/<star><star>/<star>.test.ts.declapract.ts +3 -0
- package/dist/practices/testing/best-practice/src/utils/environment.ts +3 -0
- package/dist/practices/testing/best-practice/src/utils/environment.ts.declapract.ts +3 -0
- package/dist/practices/testing/defineFunctionNameFromTestFileName.ts +11 -0
- package/dist/practices/typescript/best-practice/.declapract.readme.md +10 -0
- package/dist/practices/typescript/best-practice/package.json +12 -0
- package/dist/practices/typescript/best-practice/package.json.declapract.ts +3 -0
- package/dist/practices/typescript/best-practice/tsconfig.build.json +17 -0
- package/dist/practices/typescript/best-practice/tsconfig.json +18 -0
- package/dist/practices/uuid/bad-practices/npm-uuidv4/.declapract.readme.md +1 -0
- package/dist/practices/uuid/bad-practices/npm-uuidv4/package.json.declapract.ts +17 -0
- package/dist/practices/uuid/best-practice/.declapract.readme.md +1 -0
- package/dist/practices/uuid/best-practice/package.json +8 -0
- package/dist/practices/uuid/best-practice/package.json.declapract.ts +3 -0
- package/dist/useCases.yml +48 -0
- package/package.json +96 -0
- package/readme.md +39 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
todo: create example of best practices followed when declapract supports cloning and validating the examples
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createGetVariables } from 'declapract';
|
|
2
|
+
|
|
3
|
+
export const getProjectVariables = createGetVariables({
|
|
4
|
+
organizationName: 'awesum',
|
|
5
|
+
projectName: 'svc-awesome-thing',
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const getServiceVariables = createGetVariables({
|
|
9
|
+
infrastructureNamespaceId: 'abcde12345',
|
|
10
|
+
slackWebhookUrl: 'https://...',
|
|
11
|
+
awsAccountId: {
|
|
12
|
+
dev: '123abc',
|
|
13
|
+
prod: '456def',
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const getRdsVariables = createGetVariables({
|
|
18
|
+
databaseName: 'awesomethingdb',
|
|
19
|
+
databaseClusterHost: {
|
|
20
|
+
dev: 'awesomesdb.cluster-abc123.us-east-1.rds.amazonaws.com',
|
|
21
|
+
prod: 'awesomesdb.cluster-def456.us-east-1.rds.amazonaws.com',
|
|
22
|
+
},
|
|
23
|
+
databaseUserName: {
|
|
24
|
+
serviceUser: 'svc_awesome_thing_user',
|
|
25
|
+
cicdUser: 'awesomethingdb_cicd',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: deploy_on_tag
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- v*
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test_and_deploy:
|
|
10
|
+
runs-on: ubuntu-20.04
|
|
11
|
+
steps:
|
|
12
|
+
- name: checkout
|
|
13
|
+
uses: actions/checkout@v2
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0 # we need all commits to test:commits
|
|
16
|
+
|
|
17
|
+
- name: read nvmrc
|
|
18
|
+
id: nvmrc
|
|
19
|
+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
|
|
20
|
+
|
|
21
|
+
- name: setup node
|
|
22
|
+
uses: actions/setup-node@v2
|
|
23
|
+
with:
|
|
24
|
+
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
|
|
25
|
+
cache: 'npm'
|
|
26
|
+
|
|
27
|
+
- name: install
|
|
28
|
+
run: npm ci
|
|
29
|
+
|
|
30
|
+
- name: tests
|
|
31
|
+
run: npm run test
|
|
32
|
+
|
|
33
|
+
- name: publish
|
|
34
|
+
run: npm publish
|
|
35
|
+
env:
|
|
36
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/dist/practices/cicd-deploy-service/best-practice/.github/workflows/deploy-dev-on-main.yml
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: deploy-dev-on-main
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: # only on main branch
|
|
6
|
+
- 'main'
|
|
7
|
+
- 'master'
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test-and-deploy:
|
|
15
|
+
runs-on: ubuntu-20.04
|
|
16
|
+
steps:
|
|
17
|
+
- name: checkout
|
|
18
|
+
uses: actions/checkout@v2
|
|
19
|
+
with:
|
|
20
|
+
fetch-depth: 0 # we need all commits to test:commits
|
|
21
|
+
|
|
22
|
+
- name: read nvmrc
|
|
23
|
+
id: nvmrc
|
|
24
|
+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
|
|
25
|
+
|
|
26
|
+
- name: setup node
|
|
27
|
+
uses: actions/setup-node@v2
|
|
28
|
+
with:
|
|
29
|
+
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
|
|
30
|
+
cache: 'npm'
|
|
31
|
+
|
|
32
|
+
- name: install
|
|
33
|
+
run: npm ci
|
|
34
|
+
|
|
35
|
+
- name: configure aws credentials
|
|
36
|
+
uses: aws-actions/configure-aws-credentials@v1
|
|
37
|
+
id: credentials
|
|
38
|
+
with:
|
|
39
|
+
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
|
|
40
|
+
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
|
|
41
|
+
aws-region: us-east-1
|
|
42
|
+
|
|
43
|
+
- name: confirm aws credentials
|
|
44
|
+
run: |
|
|
45
|
+
[[ ${{steps.credentials.outputs.aws-account-id}} != '@declapract{variable.awsAccountId.dev}' ]] \
|
|
46
|
+
&& echo 'wrong aws account' && exit 1 \
|
|
47
|
+
|| echo 'correct aws account';
|
|
48
|
+
|
|
49
|
+
- name: provision:integration-test-db
|
|
50
|
+
run: npm run provision:integration-test-db
|
|
51
|
+
|
|
52
|
+
- name: test
|
|
53
|
+
run: npm run test
|
|
54
|
+
|
|
55
|
+
- name: deploy
|
|
56
|
+
run: DEPLOYER_NAME=$GITHUB_ACTOR npm run deploy:dev
|
|
57
|
+
|
|
58
|
+
- name: test:acceptance
|
|
59
|
+
run: DEPLOYMENT_STAGE=dev npm run test:acceptance
|
package/dist/practices/cicd-deploy-service/best-practice/.github/workflows/deploy-prod-on-tag.yml
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
name: deploy-prod-on-tag
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- v*
|
|
7
|
+
|
|
8
|
+
concurrency:
|
|
9
|
+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
10
|
+
cancel-in-progress: true
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test-and-deploy:
|
|
14
|
+
runs-on: ubuntu-20.04
|
|
15
|
+
steps:
|
|
16
|
+
- name: checkout
|
|
17
|
+
uses: actions/checkout@v2
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0 # we need all commits to test:commits
|
|
20
|
+
|
|
21
|
+
- name: read nvmrc
|
|
22
|
+
id: nvmrc
|
|
23
|
+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
|
|
24
|
+
|
|
25
|
+
- name: setup node
|
|
26
|
+
uses: actions/setup-node@v2
|
|
27
|
+
with:
|
|
28
|
+
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
|
|
29
|
+
cache: 'npm'
|
|
30
|
+
|
|
31
|
+
- name: install
|
|
32
|
+
run: npm ci
|
|
33
|
+
|
|
34
|
+
# test in dev env
|
|
35
|
+
- name: configure aws credentials
|
|
36
|
+
uses: aws-actions/configure-aws-credentials@v1
|
|
37
|
+
id: credentials-dev
|
|
38
|
+
with:
|
|
39
|
+
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
|
|
40
|
+
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
|
|
41
|
+
aws-region: us-east-1
|
|
42
|
+
|
|
43
|
+
- name: confirm aws credentials
|
|
44
|
+
run: |
|
|
45
|
+
[[ ${{steps.credentials-dev.outputs.aws-account-id}} != '@declapract{variable.awsAccountId.dev}' ]] \
|
|
46
|
+
&& echo 'wrong aws account' && exit 1 \
|
|
47
|
+
|| echo 'correct aws account';
|
|
48
|
+
|
|
49
|
+
- name: provision:integration-test-db
|
|
50
|
+
run: npm run provision:integration-test-db
|
|
51
|
+
|
|
52
|
+
- name: test
|
|
53
|
+
run: npm run test
|
|
54
|
+
|
|
55
|
+
# deploy in prod env
|
|
56
|
+
- name: configure aws credentials
|
|
57
|
+
uses: aws-actions/configure-aws-credentials@v1
|
|
58
|
+
id: credentials-prod
|
|
59
|
+
with:
|
|
60
|
+
aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }}
|
|
61
|
+
aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }}
|
|
62
|
+
aws-region: us-east-1
|
|
63
|
+
|
|
64
|
+
- name: confirm aws credentials
|
|
65
|
+
run: |
|
|
66
|
+
[[ ${{steps.credentials-prod.outputs.aws-account-id}} != '@declapract{variable.awsAccountId.prod}' ]] \
|
|
67
|
+
&& echo 'wrong aws account' && exit 1 \
|
|
68
|
+
|| echo 'correct aws account';
|
|
69
|
+
|
|
70
|
+
- name: deploy
|
|
71
|
+
run: DEPLOYER_NAME=$GITHUB_ACTOR npm run deploy:prod
|
|
72
|
+
|
|
73
|
+
- name: test:acceptance
|
|
74
|
+
run: DEPLOYMENT_STAGE=prod npm run test:acceptance
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
name: pr-release-on-main
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
release-please:
|
|
10
|
+
runs-on: ubuntu-20.04
|
|
11
|
+
steps:
|
|
12
|
+
- uses: google-github-actions/release-please-action@v3
|
|
13
|
+
with:
|
|
14
|
+
token: ${{ secrets.RELEASE_PLEASE_GITHUB_TOKEN }}
|
|
15
|
+
release-type: node
|
|
16
|
+
pull-request-title-pattern: 'chore(release): v${version} 🎉'
|
|
17
|
+
changelog-path: changelog.md
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
name: test-on-commit
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: # run for any branch
|
|
6
|
+
- '**'
|
|
7
|
+
tags-ignore: # but not for releases, as deploy_on_tag will trigger for it
|
|
8
|
+
- '**'
|
|
9
|
+
|
|
10
|
+
concurrency:
|
|
11
|
+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
12
|
+
cancel-in-progress: true
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
install:
|
|
16
|
+
runs-on: ubuntu-20.04
|
|
17
|
+
steps:
|
|
18
|
+
- name: checkout
|
|
19
|
+
uses: actions/checkout@v2
|
|
20
|
+
|
|
21
|
+
- name: read nvmrc
|
|
22
|
+
id: nvmrc
|
|
23
|
+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
|
|
24
|
+
|
|
25
|
+
- name: setup node
|
|
26
|
+
uses: actions/setup-node@v2
|
|
27
|
+
with:
|
|
28
|
+
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
|
|
29
|
+
cache: 'npm'
|
|
30
|
+
|
|
31
|
+
- name: install
|
|
32
|
+
run: npm ci
|
|
33
|
+
|
|
34
|
+
- name: cache node modules
|
|
35
|
+
uses: actions/cache@v2
|
|
36
|
+
with:
|
|
37
|
+
path: node_modules
|
|
38
|
+
key: ${{ runner.os }}-node-${{ github.sha }}
|
|
39
|
+
|
|
40
|
+
# run tests in parallel
|
|
41
|
+
test-commits:
|
|
42
|
+
runs-on: ubuntu-20.04
|
|
43
|
+
needs: [install]
|
|
44
|
+
steps:
|
|
45
|
+
- name: checkout
|
|
46
|
+
uses: actions/checkout@v2
|
|
47
|
+
with:
|
|
48
|
+
fetch-depth: 0 # we need all commits to test:commits
|
|
49
|
+
|
|
50
|
+
- name: read nvmrc
|
|
51
|
+
id: nvmrc
|
|
52
|
+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
|
|
53
|
+
|
|
54
|
+
- name: setup node
|
|
55
|
+
uses: actions/setup-node@v2
|
|
56
|
+
with:
|
|
57
|
+
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
|
|
58
|
+
cache: 'npm'
|
|
59
|
+
|
|
60
|
+
- name: grab node_modules from cache
|
|
61
|
+
uses: actions/cache@v2
|
|
62
|
+
with:
|
|
63
|
+
path: node_modules
|
|
64
|
+
key: ${{ runner.os }}-node-${{ github.sha }}
|
|
65
|
+
|
|
66
|
+
- name: test:commits
|
|
67
|
+
run: npm run test:commits
|
|
68
|
+
|
|
69
|
+
test-types:
|
|
70
|
+
runs-on: ubuntu-20.04
|
|
71
|
+
needs: [install]
|
|
72
|
+
steps:
|
|
73
|
+
- name: checkout
|
|
74
|
+
uses: actions/checkout@v2
|
|
75
|
+
|
|
76
|
+
- name: read nvmrc
|
|
77
|
+
id: nvmrc
|
|
78
|
+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
|
|
79
|
+
|
|
80
|
+
- name: setup node
|
|
81
|
+
uses: actions/setup-node@v2
|
|
82
|
+
with:
|
|
83
|
+
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
|
|
84
|
+
cache: 'npm'
|
|
85
|
+
|
|
86
|
+
- name: grab node_modules from cache
|
|
87
|
+
uses: actions/cache@v2
|
|
88
|
+
with:
|
|
89
|
+
path: node_modules
|
|
90
|
+
key: ${{ runner.os }}-node-${{ github.sha }}
|
|
91
|
+
|
|
92
|
+
- name: test:types
|
|
93
|
+
run: npm run test:types
|
|
94
|
+
|
|
95
|
+
test-format:
|
|
96
|
+
runs-on: ubuntu-20.04
|
|
97
|
+
needs: [install]
|
|
98
|
+
steps:
|
|
99
|
+
- name: checkout
|
|
100
|
+
uses: actions/checkout@v2
|
|
101
|
+
|
|
102
|
+
- name: read nvmrc
|
|
103
|
+
id: nvmrc
|
|
104
|
+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
|
|
105
|
+
|
|
106
|
+
- name: setup node
|
|
107
|
+
uses: actions/setup-node@v2
|
|
108
|
+
with:
|
|
109
|
+
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
|
|
110
|
+
cache: 'npm'
|
|
111
|
+
|
|
112
|
+
- name: grab node_modules from cache
|
|
113
|
+
uses: actions/cache@v2
|
|
114
|
+
with:
|
|
115
|
+
path: node_modules
|
|
116
|
+
key: ${{ runner.os }}-node-${{ github.sha }}
|
|
117
|
+
|
|
118
|
+
- name: test:format
|
|
119
|
+
run: npm run test:format
|
|
120
|
+
|
|
121
|
+
test-lint:
|
|
122
|
+
runs-on: ubuntu-20.04
|
|
123
|
+
needs: [install]
|
|
124
|
+
steps:
|
|
125
|
+
- name: checkout
|
|
126
|
+
uses: actions/checkout@v2
|
|
127
|
+
|
|
128
|
+
- name: read nvmrc
|
|
129
|
+
id: nvmrc
|
|
130
|
+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
|
|
131
|
+
|
|
132
|
+
- name: setup node
|
|
133
|
+
uses: actions/setup-node@v2
|
|
134
|
+
with:
|
|
135
|
+
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
|
|
136
|
+
cache: 'npm'
|
|
137
|
+
|
|
138
|
+
- name: grab node_modules from cache
|
|
139
|
+
uses: actions/cache@v2
|
|
140
|
+
with:
|
|
141
|
+
path: node_modules
|
|
142
|
+
key: ${{ runner.os }}-node-${{ github.sha }}
|
|
143
|
+
|
|
144
|
+
- name: test:lint
|
|
145
|
+
run: npm run test:lint
|
|
146
|
+
|
|
147
|
+
test-unit:
|
|
148
|
+
runs-on: ubuntu-20.04
|
|
149
|
+
needs: [install]
|
|
150
|
+
steps:
|
|
151
|
+
- name: checkout
|
|
152
|
+
uses: actions/checkout@v2
|
|
153
|
+
|
|
154
|
+
- name: read nvmrc
|
|
155
|
+
id: nvmrc
|
|
156
|
+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
|
|
157
|
+
|
|
158
|
+
- name: setup node
|
|
159
|
+
uses: actions/setup-node@v2
|
|
160
|
+
with:
|
|
161
|
+
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
|
|
162
|
+
cache: 'npm'
|
|
163
|
+
|
|
164
|
+
- name: grab node_modules from cache
|
|
165
|
+
uses: actions/cache@v2
|
|
166
|
+
with:
|
|
167
|
+
path: node_modules
|
|
168
|
+
key: ${{ runner.os }}-node-${{ github.sha }}
|
|
169
|
+
|
|
170
|
+
- name: test:unit
|
|
171
|
+
run: npm run test:unit
|
|
172
|
+
|
|
173
|
+
test-integration:
|
|
174
|
+
runs-on: ubuntu-20.04
|
|
175
|
+
needs: [install]
|
|
176
|
+
steps:
|
|
177
|
+
- name: checkout
|
|
178
|
+
uses: actions/checkout@v2
|
|
179
|
+
|
|
180
|
+
- name: read nvmrc
|
|
181
|
+
id: nvmrc
|
|
182
|
+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
|
|
183
|
+
|
|
184
|
+
- name: setup node
|
|
185
|
+
uses: actions/setup-node@v2
|
|
186
|
+
with:
|
|
187
|
+
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
|
|
188
|
+
cache: 'npm'
|
|
189
|
+
|
|
190
|
+
- name: grab node_modules from cache
|
|
191
|
+
uses: actions/cache@v2
|
|
192
|
+
with:
|
|
193
|
+
path: node_modules
|
|
194
|
+
key: ${{ runner.os }}-node-${{ github.sha }}
|
|
195
|
+
|
|
196
|
+
- name: configure aws credentials
|
|
197
|
+
uses: aws-actions/configure-aws-credentials@v1
|
|
198
|
+
id: credentials
|
|
199
|
+
with:
|
|
200
|
+
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
|
|
201
|
+
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
|
|
202
|
+
aws-region: us-east-1
|
|
203
|
+
|
|
204
|
+
- name: provision:integration-test-db
|
|
205
|
+
run: npm run provision:integration-test-db
|
|
206
|
+
|
|
207
|
+
- name: test:integration
|
|
208
|
+
run: npm run test:integration
|
|
209
|
+
|
|
210
|
+
test-acceptance-locally:
|
|
211
|
+
runs-on: ubuntu-20.04
|
|
212
|
+
needs: [install]
|
|
213
|
+
steps:
|
|
214
|
+
- name: checkout
|
|
215
|
+
uses: actions/checkout@v2
|
|
216
|
+
|
|
217
|
+
- name: read nvmrc
|
|
218
|
+
id: nvmrc
|
|
219
|
+
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
|
|
220
|
+
|
|
221
|
+
- name: setup node
|
|
222
|
+
uses: actions/setup-node@v2
|
|
223
|
+
with:
|
|
224
|
+
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
|
|
225
|
+
cache: 'npm'
|
|
226
|
+
|
|
227
|
+
- name: grab node_modules from cache
|
|
228
|
+
uses: actions/cache@v2
|
|
229
|
+
with:
|
|
230
|
+
path: node_modules
|
|
231
|
+
key: ${{ runner.os }}-node-${{ github.sha }}
|
|
232
|
+
|
|
233
|
+
- name: configure aws credentials
|
|
234
|
+
uses: aws-actions/configure-aws-credentials@v1
|
|
235
|
+
id: credentials
|
|
236
|
+
with:
|
|
237
|
+
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
|
|
238
|
+
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
|
|
239
|
+
aws-region: us-east-1
|
|
240
|
+
|
|
241
|
+
- name: provision:integration-test-db
|
|
242
|
+
run: npm run provision:integration-test-db
|
|
243
|
+
|
|
244
|
+
- name: test:acceptance:locally
|
|
245
|
+
run: npm run test:acceptance:locally
|
|
246
|
+
|
|
247
|
+
check-provisions-github:
|
|
248
|
+
runs-on: ubuntu-20.04
|
|
249
|
+
defaults:
|
|
250
|
+
run:
|
|
251
|
+
working-directory: ./provision/github/environment
|
|
252
|
+
steps:
|
|
253
|
+
- name: checkout
|
|
254
|
+
uses: actions/checkout@v2
|
|
255
|
+
|
|
256
|
+
- name: setup terraform
|
|
257
|
+
uses: hashicorp/setup-terraform@v1
|
|
258
|
+
|
|
259
|
+
- name: configure aws credentials
|
|
260
|
+
uses: aws-actions/configure-aws-credentials@v1
|
|
261
|
+
id: credentials
|
|
262
|
+
with:
|
|
263
|
+
aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }}
|
|
264
|
+
aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }}
|
|
265
|
+
aws-region: us-east-1
|
|
266
|
+
|
|
267
|
+
- name: confirm aws credentials
|
|
268
|
+
run: |
|
|
269
|
+
[[ ${{steps.credentials.outputs.aws-account-id}} != '398838478359' ]] \
|
|
270
|
+
&& echo 'wrong aws account' && exit 1 \
|
|
271
|
+
|| echo 'correct aws account';
|
|
272
|
+
|
|
273
|
+
- name: terraform init
|
|
274
|
+
id: init
|
|
275
|
+
run: terraform init
|
|
276
|
+
|
|
277
|
+
- name: terraform validate
|
|
278
|
+
id: validate
|
|
279
|
+
run: terraform validate -no-color
|
|
280
|
+
|
|
281
|
+
- name: terraform plan
|
|
282
|
+
id: plan
|
|
283
|
+
run: terraform plan -no-color -detailed-exitcode
|
|
284
|
+
env:
|
|
285
|
+
GITHUB_TOKEN: ${{ secrets.PROVISION_GITHUB_GITHUB_TOKEN }}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FileCheckFunction } from 'declapract';
|
|
2
|
+
|
|
3
|
+
import { getServiceVariables } from '../../../../../getVariables';
|
|
4
|
+
|
|
5
|
+
export const check: FileCheckFunction = (contents, context) => {
|
|
6
|
+
const { awsAccountId } = getServiceVariables(context);
|
|
7
|
+
if (!contents?.includes(awsAccountId.prod))
|
|
8
|
+
throw new Error('does not contain aws prod account id');
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FileCheckFunction } from 'declapract';
|
|
2
|
+
|
|
3
|
+
import { getServiceVariables } from '../../../../../getVariables';
|
|
4
|
+
|
|
5
|
+
export const check: FileCheckFunction = (contents, context) => {
|
|
6
|
+
const { awsAccountId } = getServiceVariables(context);
|
|
7
|
+
if (!contents?.includes(awsAccountId.dev))
|
|
8
|
+
throw new Error('does not contain aws dev account id');
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FileCheckFunction } from 'declapract';
|
|
2
|
+
|
|
3
|
+
import { getServiceVariables } from '../../../../../getVariables';
|
|
4
|
+
|
|
5
|
+
export const check: FileCheckFunction = (contents, context) => {
|
|
6
|
+
const { awsAccountId } = getServiceVariables(context);
|
|
7
|
+
if (!contents?.includes(awsAccountId.prod))
|
|
8
|
+
throw new Error('does not contain aws prod account id');
|
|
9
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
the following places should have the shape of the config defined identically:
|
|
2
|
+
- `config/test.json`
|
|
3
|
+
- `config/dev.json`
|
|
4
|
+
- `config/prod.json`
|
|
5
|
+
|
|
6
|
+
this check complains if one of them does not look like the others
|
|
7
|
+
|
|
8
|
+
note: ideally we would have a separate util for this, but for now, we'll do this check here
|
package/dist/practices/config/bad-practices/divergent-config-shapes/config/dev.json.declapract.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { FileCheckFunction } from 'declapract';
|
|
2
|
+
import flatten from 'flat';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import util from 'util';
|
|
5
|
+
|
|
6
|
+
export const readFile = async (filePath: string) =>
|
|
7
|
+
util.promisify(fs.readFile)(filePath, 'utf-8');
|
|
8
|
+
|
|
9
|
+
export const check: FileCheckFunction = async (contents, context) => {
|
|
10
|
+
if (!contents) throw new Error('its fine'); // ... yeah, i know, todo: eliminate this weird "throw an error if its fine" pattern
|
|
11
|
+
|
|
12
|
+
// grab the desired keys
|
|
13
|
+
const testConfigJsonContents = await readFile(
|
|
14
|
+
`${context.getProjectRootDirectory()}/config/test.json`,
|
|
15
|
+
);
|
|
16
|
+
if (!testConfigJsonContents)
|
|
17
|
+
throw new Error('can only check if test file exists');
|
|
18
|
+
const testConfigObject = JSON.parse(testConfigJsonContents);
|
|
19
|
+
const flattenedTestConfigKeys = Object.keys(flatten(testConfigObject));
|
|
20
|
+
|
|
21
|
+
// grab the found keys
|
|
22
|
+
const devConfigObject = JSON.parse(contents);
|
|
23
|
+
const flattenedDevConfigKeys = Object.keys(flatten(devConfigObject));
|
|
24
|
+
|
|
25
|
+
// determine which keys are not matched
|
|
26
|
+
const keysInTestButNotInDev = flattenedTestConfigKeys.filter(
|
|
27
|
+
(key) => !flattenedDevConfigKeys.includes(key),
|
|
28
|
+
);
|
|
29
|
+
const keysInDevButNotInTest = flattenedDevConfigKeys.filter(
|
|
30
|
+
(key) => !flattenedTestConfigKeys.includes(key),
|
|
31
|
+
);
|
|
32
|
+
if (keysInTestButNotInDev.length) return; // matches bad practice
|
|
33
|
+
if (keysInDevButNotInTest.length) return; // matches bad practice
|
|
34
|
+
|
|
35
|
+
// otherwise, does not match a bad practice
|
|
36
|
+
throw new Error('its fine');
|
|
37
|
+
};
|
package/dist/practices/config/bad-practices/divergent-config-shapes/config/prod.json.declapract.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { FileCheckFunction } from 'declapract';
|
|
2
|
+
import flatten from 'flat';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import util from 'util';
|
|
5
|
+
|
|
6
|
+
export const readFile = async (filePath: string) =>
|
|
7
|
+
util.promisify(fs.readFile)(filePath, 'utf-8');
|
|
8
|
+
|
|
9
|
+
export const check: FileCheckFunction = async (contents, context) => {
|
|
10
|
+
if (!contents) throw new Error('its fine'); // ... yeah, i know, todo: eliminate this weird "throw an error if its fine" pattern
|
|
11
|
+
|
|
12
|
+
// grab the desired keys
|
|
13
|
+
const testConfigJsonContents = await readFile(
|
|
14
|
+
`${context.getProjectRootDirectory()}/config/test.json`,
|
|
15
|
+
);
|
|
16
|
+
if (!testConfigJsonContents)
|
|
17
|
+
throw new Error('can only check if test file exists');
|
|
18
|
+
const testConfigObject = JSON.parse(testConfigJsonContents);
|
|
19
|
+
const flattenedTestConfigKeys = Object.keys(flatten(testConfigObject));
|
|
20
|
+
|
|
21
|
+
// grab the found keys
|
|
22
|
+
const prodConfigObject = JSON.parse(contents);
|
|
23
|
+
const flattenedProdConfigKeys = Object.keys(flatten(prodConfigObject));
|
|
24
|
+
|
|
25
|
+
// determine which keys are not matched
|
|
26
|
+
const keysInTestButNotInProd = flattenedTestConfigKeys.filter(
|
|
27
|
+
(key) => !flattenedProdConfigKeys.includes(key),
|
|
28
|
+
);
|
|
29
|
+
const keysInProdButNotInTest = flattenedProdConfigKeys.filter(
|
|
30
|
+
(key) => !flattenedTestConfigKeys.includes(key),
|
|
31
|
+
);
|
|
32
|
+
if (keysInTestButNotInProd.length) return; // matches bad practice
|
|
33
|
+
if (keysInProdButNotInTest.length) return; // matches bad practice
|
|
34
|
+
|
|
35
|
+
// otherwise, does not match a bad practice
|
|
36
|
+
throw new Error('its fine');
|
|
37
|
+
};
|