Repository navigation
Stop publishing the codegen node_modules #30
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ea39478
Bump smithy-aws-typescript-codegen to 0.54.0
francoisferrand b16535e
Stop publishing the codegen node_modules
francoisferrand 9e857c3
Check the npm package installs and loads in CI
francoisferrand 70394fb
Fail the build when a generated client dependency is not declared
francoisferrand 0a09a99
Handle cloudserver XML and HTML errors in the protocol
francoisferrand fb6dd25
Release 1.0.13
francoisferrand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,16 @@ | ||
| import { | ||
| CloudserverBackbeatRoutesClient, | ||
| import { | ||
| CloudserverBackbeatRoutesClient, | ||
| CloudserverBackbeatRoutesClientConfig, | ||
| } from '../../build/smithy/cloudserverBackbeatRoutes/typescript-codegen'; | ||
| import { createCustomErrorMiddleware } from '../utils'; | ||
| import { CloudserverRestJsonProtocol } from '../utils'; | ||
|
|
||
| export * from '../../build/smithy/cloudserverBackbeatRoutes/typescript-codegen'; | ||
| export class BackbeatRoutesClient extends CloudserverBackbeatRoutesClient { | ||
| constructor(config: CloudserverBackbeatRoutesClientConfig) { | ||
| super({ | ||
| protocol: CloudserverRestJsonProtocol, | ||
| ...config, | ||
| signingEscapePath: false, | ||
| }); | ||
|
|
||
| this.middlewareStack.add(createCustomErrorMiddleware(), { | ||
| step: 'deserialize', | ||
| name: 'cloudserverErrorHandler', | ||
| priority: 'normal', | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/usr/bin/env bash | ||
| # The generated clients are shipped inside this package, so their runtime | ||
| # dependencies must be declared in the root package.json too. | ||
| set -euo pipefail | ||
|
|
||
| cd "$(dirname "$0")/../.." | ||
|
|
||
| generated=(build/smithy/*/typescript-codegen/package.json) | ||
|
|
||
| missing=$(comm -23 \ | ||
| <(jq -r '.dependencies // {} | keys[]' "${generated[@]}" | sort -u) \ | ||
| <(jq -r '.dependencies // {} | keys[]' package.json | sort -u)) | ||
|
|
||
| if [ -n "$missing" ]; then | ||
| echo "ERROR: dependencies of the generated clients missing from package.json, add them with:" >&2 | ||
| echo " yarn add $(for name in $missing; do | ||
| jq -r --arg n "$name" '.dependencies[$n] // empty | "\($n)@\(.)"' "${generated[@]}" | head -1 | ||
| done | tr '\n' ' ')" >&2 | ||
| exit 1 | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #!/bin/bash | ||
| # Installs the npm tarball into a scratch consumer and checks it loads, sends | ||
| # requests and type-checks there. | ||
| # | ||
| # Usage: check-package.sh [package.tgz] (packs the current build if omitted) | ||
| set -euo pipefail | ||
|
|
||
| HERE=$(cd "$(dirname "$0")" && pwd) | ||
| WORK_DIR=$(mktemp -d) | ||
| trap 'rm -rf "$WORK_DIR"' EXIT | ||
|
|
||
| if [ $# -ge 1 ]; then | ||
| TARBALL=$(cd "$(dirname "$1")" && pwd)/$(basename "$1") | ||
| else | ||
| (cd "$HERE/../.." && npm pack --ignore-scripts --silent --pack-destination "$WORK_DIR" >/dev/null) | ||
| TARBALL=$(ls "$WORK_DIR"/*.tgz) | ||
| fi | ||
|
|
||
| if tar -tzf "$TARBALL" | grep -q '/node_modules/'; then | ||
| echo "ERROR: $(basename "$TARBALL") contains node_modules" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| cd "$WORK_DIR" | ||
| cp "$HERE/consumer.package.json" package.json | ||
| cp "$HERE/smoke.js" "$HERE/types.ts" "$HERE/tsconfig.json" . | ||
| npm install --omit=dev --ignore-scripts --no-audit --no-fund --silent "$TARBALL" | ||
| node smoke.js | ||
|
|
||
| npm install --no-save --ignore-scripts --no-audit --no-fund --silent typescript @types/node@20 | ||
| npx --no-install tsc -p tsconfig.json | ||
| echo "types OK" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "name": "cloudserverclient-packaging-consumer", | ||
| "version": "0.0.0", | ||
| "private": true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Sends one request with each generated client, from a consumer that only | ||
| // has the published tarball installed. | ||
| const assert = require('assert'); | ||
| const http = require('http'); | ||
| const pkg = require('@scality/cloudserverclient'); | ||
| require('@scality/cloudserverclient/clients/backbeatRoutes'); | ||
| require('@scality/cloudserverclient/clients/bucketQuota'); | ||
| require('@scality/cloudserverclient/clients/proxyBackbeatApis'); | ||
|
|
||
| const requests = []; | ||
| const server = http.createServer((req, res) => { | ||
| requests.push(`${req.method} ${req.url}`); | ||
| assert.match(req.headers.authorization || '', /^AWS4-HMAC-SHA256 /); | ||
| req.resume(); | ||
| req.on('end', () => res.writeHead(200, { 'content-length': 0 }).end()); | ||
| }); | ||
|
|
||
| server.listen(0, '127.0.0.1', async () => { | ||
| const client = new pkg.CloudserverClient({ | ||
| endpoint: `http://127.0.0.1:${server.address().port}`, | ||
| region: 'us-east-1', | ||
| credentials: { accessKeyId: 'accessKey', secretAccessKey: 'secretKey' }, | ||
| maxAttempts: 1, | ||
| }); | ||
| try { | ||
| await client.backbeatRoutes.send(new pkg.GetRaftIdCommand({ Bucket: 'bucket' })); | ||
| await client.bucketQuota.send(new pkg.GetBucketQuotaCommand({ Bucket: 'bucket' })); | ||
| await client.proxyBackbeatApis.send(new pkg.CheckConnectionCommand({})); | ||
| assert.strictEqual(requests.length, 3); | ||
| console.log(`runtime OK: ${requests.join(', ')}`); | ||
| } catch (err) { | ||
| console.error(err); | ||
| process.exitCode = 1; | ||
| } finally { | ||
| server.close(); | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "module": "node16", | ||
| "moduleResolution": "node16", | ||
| "target": "es2022", | ||
| "strict": true, | ||
| "noEmit": true, | ||
| "skipLibCheck": false, | ||
| "types": ["node"] | ||
| }, | ||
| "files": ["types.ts"] | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be node@24 ? And so in package json also node >= 24
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the packge is usable from node@20, and used in both node@22 and node@24. So should not move package.json to >= 24 just yet.
Bumping to node22/24 will come in followup PR