diff --git a/.projen/deps.json b/.projen/deps.json index e6a7e2d..296509e 100644 --- a/.projen/deps.json +++ b/.projen/deps.json @@ -96,7 +96,7 @@ }, { "name": "constructs", - "version": "^10.0.5", + "version": "^10.5.1", "type": "peer" } ], diff --git a/API.md b/API.md index 7a7ce9e..6570ebd 100644 --- a/API.md +++ b/API.md @@ -51,6 +51,7 @@ Configuration for building and pushing the Docker image. | **Name** | **Description** | | --- | --- | | toString | Returns a string representation of this construct. | +| with | Applies one or more mixins to this construct. | --- @@ -62,6 +63,27 @@ public toString(): string Returns a string representation of this construct. +##### `with` + +```typescript +public with(mixins: ...IMixin[]): IConstruct +``` + +Applies one or more mixins to this construct. + +Mixins are applied in order. The list of constructs is captured at the +start of the call, so constructs added by a mixin will not be visited. +Use multiple `with()` calls if subsequent mixins should apply to added +constructs. + +###### `mixins`Required + +- *Type:* ...constructs.IMixin[] + +The mixins to apply. + +--- + #### Static Functions | **Name** | **Description** | @@ -70,7 +92,7 @@ Returns a string representation of this construct. --- -##### ~~`isConstruct`~~ +##### `isConstruct` ```typescript import { TokenInjectableDockerBuilder } from 'token-injectable-docker-builder' @@ -80,6 +102,20 @@ TokenInjectableDockerBuilder.isConstruct(x: any) Checks if `x` is a construct. +Use this method instead of `instanceof` to properly detect `Construct` +instances, even when the construct library is symlinked. + +Explanation: in JavaScript, multiple copies of the `constructs` library on +disk are seen as independent, completely different libraries. As a +consequence, the class `Construct` in each copy of the `constructs` library +is seen as a different class, and an instance of one class will not test as +`instanceof` the other class. `npm install` will not create installations +like this, but users may manually symlink construct libraries together or +use a monorepo tool: in those cases, multiple copies of the `constructs` +library can be accidentally installed, and `instanceof` will behave +unpredictably. It is safest to avoid using `instanceof`, and using +this type-testing method instead. + ###### `x`Required - *Type:* any @@ -148,6 +184,7 @@ shared Lambdas have permission to start builds and read logs. | **Name** | **Description** | | --- | --- | | toString | Returns a string representation of this construct. | +| with | Applies one or more mixins to this construct. | | registerProject | Grant the shared Lambdas permission to start builds for a specific CodeBuild project and pull/push to its ECR repository. | --- @@ -160,6 +197,27 @@ public toString(): string Returns a string representation of this construct. +##### `with` + +```typescript +public with(mixins: ...IMixin[]): IConstruct +``` + +Applies one or more mixins to this construct. + +Mixins are applied in order. The list of constructs is captured at the +start of the call, so constructs added by a mixin will not be visited. +Use multiple `with()` calls if subsequent mixins should apply to added +constructs. + +###### `mixins`Required + +- *Type:* ...constructs.IMixin[] + +The mixins to apply. + +--- + ##### `registerProject` ```typescript @@ -195,7 +253,7 @@ Grant the shared Lambdas permission to start builds for a specific CodeBuild pro --- -##### ~~`isConstruct`~~ +##### `isConstruct` ```typescript import { TokenInjectableDockerBuilderProvider } from 'token-injectable-docker-builder' @@ -205,6 +263,20 @@ TokenInjectableDockerBuilderProvider.isConstruct(x: any) Checks if `x` is a construct. +Use this method instead of `instanceof` to properly detect `Construct` +instances, even when the construct library is symlinked. + +Explanation: in JavaScript, multiple copies of the `constructs` library on +disk are seen as independent, completely different libraries. As a +consequence, the class `Construct` in each copy of the `constructs` library +is seen as a different class, and an instance of one class will not test as +`instanceof` the other class. `npm install` will not create installations +like this, but users may manually symlink construct libraries together or +use a monorepo tool: in those cases, multiple copies of the `constructs` +library can be accidentally installed, and `instanceof` will behave +unpredictably. It is safest to avoid using `instanceof`, and using +this type-testing method instead. + ###### `x`Required - *Type:* any diff --git a/package-lock.json b/package-lock.json index a3fde62..b186dec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@typescript-eslint/parser": "^8", "aws-cdk-lib": "2.238.0", "commit-and-tag-version": "^12", - "constructs": "10.0.5", + "constructs": "10.5.1", "eslint": "^9", "eslint-import-resolver-typescript": "^3.10.1", "eslint-plugin-import": "^2.32.0", @@ -27,14 +27,14 @@ "jsii-docgen": "^10.11.0", "jsii-pacmak": "^1.126.0", "jsii-rosetta": "~5.9.27", - "projen": "^0.99.12", + "projen": "^0.99.16", "ts-jest": "^29.4.6", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "peerDependencies": { "aws-cdk-lib": "^2.238.0", - "constructs": "^10.0.5" + "constructs": "^10.5.1" } }, "node_modules/@ampproject/remapping": { @@ -71,6 +71,7 @@ ], "dev": true, "license": "Apache-2.0", + "peer": true, "dependencies": { "jsonschema": "~1.4.1", "semver": "^7.7.2" @@ -125,6 +126,7 @@ "version": "7.26.0", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.26.0", @@ -735,9 +737,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.39.2", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.2.tgz", - "integrity": "sha512-q1mjIoW1VX4IvSocvM/vbTiveKC4k9eLrajNEuSsmjymSDEbpGddtpfOoN7YGAqBK3NG+uqo8ia4PDTt8buCYA==", + "version": "9.39.3", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.3.tgz", + "integrity": "sha512-1B1VkCq6FuUNlQvlBYb+1jDu/gV297TIs/OeiaSR9l1H27SVW55ONE1e1Vp16NqP683+xEGzxYtv4XCiDPaQiw==", "dev": true, "license": "MIT", "engines": { @@ -1458,6 +1460,7 @@ "integrity": "sha512-BH7YwL6rA93ReqeQS1c4bsPpcfOmJasG+Fkr6Y59q83f9M1WcBRHR2vM+P9eOisYRcN3ujQoiZY8uk5W+1WL8w==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "undici-types": "~6.21.0" } @@ -1530,6 +1533,7 @@ "integrity": "sha512-IgSWvLobTDOjnaxAfDTIHaECbkNlAlKv2j5SjpB2v7QHKv1FIfjwMy8FsDbVfDX/KjmCmYICcw7uGaXLhtsLNg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.56.0", "@typescript-eslint/types": "8.56.0", @@ -2001,6 +2005,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2864,6 +2869,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001669", "electron-to-chromium": "^1.5.41", @@ -3359,12 +3365,12 @@ } }, "node_modules/constructs": { - "version": "10.0.5", + "version": "10.5.1", + "resolved": "https://registry.npmjs.org/constructs/-/constructs-10.5.1.tgz", + "integrity": "sha512-f/TfFXiS3G/yVIXDjOQn9oTlyu9Wo7Fxyjj7lb8r92iO81jR2uST+9MstxZTmDGx/CgIbxCXkFXgupnLTNxQZg==", "dev": true, "license": "Apache-2.0", - "engines": { - "node": ">= 10.17.0" - } + "peer": true }, "node_modules/conventional-changelog": { "version": "4.0.0", @@ -4156,11 +4162,12 @@ } }, "node_modules/eslint": { - "version": "9.39.2", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.2.tgz", - "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", + "version": "9.39.3", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.3.tgz", + "integrity": "sha512-VmQ+sifHUbI/IcSopBCF/HO3YiHQx/AVd3UVyYL6weuwW+HvON9VYn5l6Zl1WZzPWXPNZrSQpxwkkZ/VuvJZzg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -4168,7 +4175,7 @@ "@eslint/config-helpers": "^0.4.2", "@eslint/core": "^0.17.0", "@eslint/eslintrc": "^3.3.1", - "@eslint/js": "9.39.2", + "@eslint/js": "9.39.3", "@eslint/plugin-kit": "^0.4.1", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", @@ -4302,6 +4309,7 @@ "integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@rtsao/scc": "^1.1.0", "array-includes": "^3.1.9", @@ -5809,6 +5817,7 @@ "version": "29.7.0", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@jest/core": "^29.7.0", "@jest/types": "^29.6.3", @@ -6689,11 +6698,12 @@ } }, "node_modules/jsii-rosetta": { - "version": "5.9.30", - "resolved": "https://registry.npmjs.org/jsii-rosetta/-/jsii-rosetta-5.9.30.tgz", - "integrity": "sha512-nW41LCZMSf7PRzpy90iU6X+xUKsbFCEDIw6Q2FLnhfrkgjKchpKJ1bF8bEDg7xsFm0AwdhKP8QC4FR4lZikdYQ==", + "version": "5.9.31", + "resolved": "https://registry.npmjs.org/jsii-rosetta/-/jsii-rosetta-5.9.31.tgz", + "integrity": "sha512-g0WR8oeFKe0xGtuPy6QU8BFArv5h2OlioKlemnHNAHUvnl+uahVy+I+qOw+HKtzr74LWi6Tv5nOZKhxnwSVuAQ==", "dev": true, "license": "Apache-2.0", + "peer": true, "dependencies": { "@jsii/check-node": "^1.126.0", "@jsii/spec": "^1.126.0", @@ -7712,9 +7722,9 @@ "license": "MIT" }, "node_modules/projen": { - "version": "0.99.12", - "resolved": "https://registry.npmjs.org/projen/-/projen-0.99.12.tgz", - "integrity": "sha512-wfOKE8tJ46wKz4SgBoJ5sK+4OcX+BscfZdXoTw7dVEKh7MpnJXqD6/GgRs0iT78e6Z0pkwGaYQK6m1OuhCHVpw==", + "version": "0.99.16", + "resolved": "https://registry.npmjs.org/projen/-/projen-0.99.16.tgz", + "integrity": "sha512-zG39JO/f0BgNXvkevQdlexjdsSgoSShxoiNCTfgJYrDzBdjFBkHpjC06Vn4bk+95TaMfaIn7Dgbdp6jxnbvRqA==", "bundleDependencies": [ "@iarna/toml", "case", @@ -9832,6 +9842,7 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -9954,6 +9965,7 @@ "version": "10.9.2", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -10139,6 +10151,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/package.json b/package.json index 18ee80b..6580689 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@typescript-eslint/parser": "^8", "aws-cdk-lib": "2.238.0", "commit-and-tag-version": "^12", - "constructs": "10.0.5", + "constructs": "10.5.1", "eslint": "^9", "eslint-import-resolver-typescript": "^3.10.1", "eslint-plugin-import": "^2.32.0", @@ -58,14 +58,14 @@ "jsii-docgen": "^10.11.0", "jsii-pacmak": "^1.126.0", "jsii-rosetta": "~5.9.27", - "projen": "^0.99.12", + "projen": "^0.99.16", "ts-jest": "^29.4.6", "ts-node": "^10.9.2", "typescript": "^5.9.3" }, "peerDependencies": { "aws-cdk-lib": "^2.238.0", - "constructs": "^10.0.5" + "constructs": "^10.5.1" }, "keywords": [ "aws",