Skip to content

Update to Node.js 14.x runtime #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*Issue #, if available:*

*Description of changes:*

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
repos:
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.17
rev: v5.10.1
hooks:
- id: isort
# language_version: python3.6
- repo: https://github.com/ambv/black
rev: stable
rev: 21.12b0
hooks:
- id: black
# language_version: python3.6
Expand Down Expand Up @@ -35,18 +35,18 @@ repos:
- id: check-merge-conflict
- id: check-yaml
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.3.0
rev: v1.9.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-mock-methods
- id: python-no-log-warn
- repo: https://github.com/PyCQA/bandit
rev: 1.6.2
rev: 1.7.1
hooks:
- id: bandit
files: "^python/"
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v6.8.0
rev: v8.7.0
hooks:
- id: eslint
args: [--fix]
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ information to effectively respond to your bug report or contribution.

We welcome you to use the GitHub issue tracker to report bugs or suggest features.

When filing an issue, please check [existing open](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin/issues), or [recently closed](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
When filing an issue, please check [existing open](https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin/issues), or [recently closed](https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:

* A reproducible test case or series of steps
Expand Down Expand Up @@ -41,7 +41,7 @@ GitHub provides additional document on [forking a repository](https://help.githu


## Finding contributions to work on
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin/labels/help%20wanted) issues is a great place to start.
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin/labels/help%20wanted) issues is a great place to start.


## Security issue notifications
Expand All @@ -50,6 +50,6 @@ If you discover a potential security issue in this project we ask that you notif

## Licensing

See the [LICENSE](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
See the [LICENSE](https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.

We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.
816 changes: 514 additions & 302 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ We're excited to share our progress with adding new languages to the CloudFormat

## AWS CloudFormation Resource Provider TypeScript Plugin

[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/eduardomourar/cloudformation-cli-typescript-plugin/ci/master)](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin/actions?query=branch%3Amaster+workflow%3Aci) [![Codecov](https://img.shields.io/codecov/c/gh/eduardomourar/cloudformation-cli-typescript-plugin)](https://codecov.io/gh/eduardomourar/cloudformation-cli-typescript-plugin) [![GitHub release](https://img.shields.io/github/v/release/eduardomourar/cloudformation-cli-typescript-plugin?include_prereleases)](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin/releases) [![Node.js version](https://img.shields.io/badge/dynamic/json?color=brightgreen&url=https://raw.githubusercontent.com/eduardomourar/cloudformation-cli-typescript-plugin/master/package.json&query=$.engines.node&label=nodejs)](https://nodejs.org/)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/aws-cloudformation/cloudformation-cli-typescript-plugin/ci/master)](https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin/actions?query=branch%3Amaster+workflow%3Aci) [![Codecov](https://img.shields.io/codecov/c/gh/aws-cloudformation/cloudformation-cli-typescript-plugin)](https://codecov.io/gh/aws-cloudformation/cloudformation-cli-typescript-plugin) [![PyPI version](https://img.shields.io/pypi/v/cloudformation-cli-typescript-plugin)](https://pypi.org/project/cloudformation-cli-typescript-plugin) [![NPM version](https://img.shields.io/npm/v/@amazon-web-services-cloudformation/cloudformation-cli-typescript-lib)](https://www.npmjs.com/package/@amazon-web-services-cloudformation/cloudformation-cli-typescript-lib) [![Node.js version](https://img.shields.io/badge/dynamic/json?color=brightgreen&url=https://raw.githubusercontent.com/aws-cloudformation/cloudformation-cli-typescript-plugin/master/package.json&query=$.engines.node&label=nodejs)](https://nodejs.org/)

The CloudFormation CLI (cfn) allows you to author your own resource providers that can be used by CloudFormation.

Expand All @@ -13,7 +13,7 @@ This plugin library helps to provide TypeScript runtime bindings for the executi
Usage
-----

If you are using this package to build resource providers for CloudFormation, install the [CloudFormation CLI TypeScript Plugin](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin) - this will automatically install the [CloudFormation CLI](https://github.com/aws-cloudformation/cloudformation-cli)! A Python virtual environment is recommended.
If you are using this package to build resource providers for CloudFormation, install the [CloudFormation CLI TypeScript Plugin](https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin) - this will automatically install the [CloudFormation CLI](https://github.com/aws-cloudformation/cloudformation-cli)! A Python virtual environment is recommended.

**Prerequisites**

Expand Down
21 changes: 13 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"test:debug": "npx --node-arg=--inspect jest --runInBand"
},
"engines": {
"node": ">=12.0.0",
"node": ">=14.0.0",
"npm": ">=6.9.0"
},
"repository": {
Expand All @@ -44,7 +44,7 @@
"uuid": "^7.0.2"
},
"devDependencies": {
"@tsconfig/node12": "^1.0.7",
"@tsconfig/node14": "^1.0.1",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
"@types/uuid": "^7.0.0",
Expand Down
7 changes: 3 additions & 4 deletions python/rpdk/typescript/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def validate_no(value):
class TypescriptLanguagePlugin(LanguagePlugin):
MODULE_NAME = __name__
NAME = "typescript"
RUNTIME = "nodejs12.x"
RUNTIME = "nodejs14.x"
ENTRY_POINT = "dist/handlers.entrypoint"
TEST_ENTRY_POINT = "dist/handlers.testEntrypoint"
CODE_URI = "./"
Expand Down Expand Up @@ -121,9 +121,7 @@ def _copy_resource(path, resource_name=None):
_render_template(
project.root / "package.json",
name=project.hypenated_name,
description="AWS custom resource provider named {}.".format(
project.type_name
),
description=f"AWS custom resource provider named {project.type_name}.",
lib_name=SUPPORT_LIB_NAME,
lib_path=self._lib_path,
)
Expand Down Expand Up @@ -176,6 +174,7 @@ def generate(self, project):
LOG.debug("Generate complete")

def _pre_package(self, build_path):
# pylint: disable=consider-using-with
f = TemporaryFile("w+b")

# pylint: disable=unexpected-keyword-arg
Expand Down
2 changes: 1 addition & 1 deletion python/rpdk/typescript/templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ const progress = ProgressEvent.builder<ProgressEvent<ResourceModel>>()
.build()
```

While importing the [{{ lib_name }}](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin) library, failures can be passed back to CloudFormation by either raising an exception from `exceptions`, or setting the ProgressEvent's `status` to `OperationStatus.Failed` and `errorCode` to one of `HandlerErrorCode`. There is a static helper function, `ProgressEvent.failed`, for this common case.
While importing the [{{ lib_name }}](https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin) library, failures can be passed back to CloudFormation by either raising an exception from `exceptions`, or setting the ProgressEvent's `status` to `OperationStatus.Failed` and `errorCode` to one of `HandlerErrorCode`. There is a static helper function, `ProgressEvent.failed`, for this common case.

Keep in mind, during runtime all logs will be delivered to CloudWatch if you use the `log()` method from `LoggerProxy` class.
19 changes: 18 additions & 1 deletion tests/lib/resource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,9 @@ describe('when getting resource', () => {
resource['castResourceRequest'](request);
};
expect(castResourceRequest).toThrow(exceptions.InvalidRequest);
expect(castResourceRequest).toThrow('TypeError: Cannot read property');
expect(castResourceRequest).toThrow(
/TypeError: Cannot read.*resourceProperties.*$/
);
});

test('parse request valid request and cast resource request', () => {
Expand Down Expand Up @@ -639,6 +641,21 @@ describe('when getting resource', () => {
);
});

test('invoke handler does not provide response', async () => {
expect.assertions(1);
const mockHandler: jest.Mock = jest.fn().mockResolvedValue(null);
const resource = new Resource(TYPE_NAME, MockModel);
resource.addHandler(Action.Create, mockHandler);
const callbackContext = {};
try {
await resource['invokeHandler'](null, null, Action.Create, callbackContext);
} catch (e) {
expect(e).toMatchObject({
message: 'Handler failed to provide a response.',
});
}
});

test('parse test request invalid request', () => {
const resource = getResource();
const parseTestRequest = () => {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@tsconfig/node12/tsconfig.json",
"extends": "@tsconfig/node14/tsconfig.json",
"compilerOptions": {
"strict": true,
"noImplicitAny": false,
Expand Down