Skip to content

Commit f6659e7

Browse files
committed
chore: update workspace and clients npm scripts
Now in each client you can run `yarn build` or `yarn pretest`. They are the same that build js files to `dist` folder. In the workspace root, you can run `yarn: build:all` to compile the whole workspace from .ts to .js. You can also `yarn: test:all` to run all the test we have. Furthermore, you can run `yarn test:functional` to run the hostname integration test. This script can only be called after the repo is compiled.
1 parent 983b512 commit f6659e7

File tree

6 files changed

+118
-486
lines changed

6 files changed

+118
-486
lines changed

clients/client-rds-data/endpoints.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,47 +26,59 @@ const AWS_REGIONS = new Set([
2626
"us-east-1",
2727
"us-east-2",
2828
"us-west-1",
29-
"us-west-2"
29+
"us-west-2",
30+
]);
31+
const AWS_CN_REGIONS = new Set([
32+
"cn-north-1",
33+
"cn-northwest-1",
34+
]);
35+
const AWS_ISO_REGIONS = new Set([
36+
"us-iso-east-1",
37+
]);
38+
const AWS_ISO_B_REGIONS = new Set([
39+
"us-isob-east-1",
40+
]);
41+
const AWS_US_GOV_REGIONS = new Set([
42+
"us-gov-west-1",
43+
"us-gov-east-1",
3044
]);
31-
const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]);
32-
const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]);
33-
const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]);
34-
const AWS_US_GOV_REGIONS = new Set(["us-gov-west-1", "us-gov-east-1"]);
3545

36-
export let defaultRegionInfoProvider: RegionInfoProvider;
37-
defaultRegionInfoProvider = function(region: string, options?: any) {
46+
export const defaultRegionInfoProvider: RegionInfoProvider = (
47+
region: string,
48+
options?: any
49+
) => {
3850
switch (region) {
3951
// First, try to match exact region names.
4052
// Next, try to match partition endpoints.
4153
default:
42-
if (region in AWS_REGIONS) {
54+
if (AWS_REGIONS.has(region)) {
4355
return {
44-
hostname: AWS_TEMPLATE.replace("{region}", region)
56+
hostname: AWS_TEMPLATE.replace("{region}", region),
4557
};
4658
}
47-
if (region in AWS_CN_REGIONS) {
59+
if (AWS_CN_REGIONS.has(region)) {
4860
return {
49-
hostname: AWS_CN_TEMPLATE.replace("{region}", region)
61+
hostname: AWS_CN_TEMPLATE.replace("{region}", region),
5062
};
5163
}
52-
if (region in AWS_ISO_REGIONS) {
64+
if (AWS_ISO_REGIONS.has(region)) {
5365
return {
54-
hostname: AWS_ISO_TEMPLATE.replace("{region}", region)
66+
hostname: AWS_ISO_TEMPLATE.replace("{region}", region),
5567
};
5668
}
57-
if (region in AWS_ISO_B_REGIONS) {
69+
if (AWS_ISO_B_REGIONS.has(region)) {
5870
return {
59-
hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region)
71+
hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region),
6072
};
6173
}
62-
if (region in AWS_US_GOV_REGIONS) {
74+
if (AWS_US_GOV_REGIONS.has(region)) {
6375
return {
64-
hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region)
76+
hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region),
6577
};
6678
}
6779
// Finally, assume it's an AWS partition endpoint.
6880
return {
69-
hostname: AWS_TEMPLATE.replace("{region}", region)
81+
hostname: AWS_TEMPLATE.replace("{region}", region),
7082
};
7183
}
7284
};

clients/client-rds-data/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66
"clean": "npm run remove-definitions && npm run remove-dist && npm run remove-js && npm run remove-maps",
77
"build-documentation": "npm run clean && typedoc ./",
88
"prepublishOnly": "yarn build",
9-
"pretest": "tsc",
9+
"pretest": "yarn build",
1010
"remove-definitions": "rimraf ./types",
1111
"remove-dist": "rimraf ./dist",
1212
"remove-documentation": "rimraf ./docs",
1313
"remove-js": "rimraf *.js && rimraf ./commands/*.js && rimraf ./lib/*.js && rimraf ./models/*.js && rimraf ./protocols/*.js",
1414
"remove-maps": "rimraf *.js.map && rimraf ./commands/*.js.map && rimraf ./lib/*.js.map && rimraf ./models/*.js.map && rimraf ./protocols/*.js.map",
1515
"test": "exit 0",
1616
"smoke-test": "npm run pretest && node ./test/smoke/index.spec.js",
17+
"build:cjs": "tsc -p tsconfig.json",
1718
"build:es": "tsc -p tsconfig.es.json",
18-
"build": "yarn pretest && yarn build:es"
19+
"build": "yarn build:cjs && yarn build:es"
1920
},
2021
"main": "./dist/cjs/index.js",
2122
"types": "./types/index.d.ts",

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
"clear-build-cache": "rimraf ./packages/*/build/* ./clients/*/*/build/*",
1212
"clear-build-info": "rimraf ./packages/*/*.tsbuildinfo ./clients/*/*/*.tsbuildinfo",
1313
"build:crypto-dependencies": "lerna run --scope '@aws-sdk/types' --scope '@aws-sdk/util-utf8-browser' --scope '@aws-sdk/util-locate-window' --scope '@aws-sdk/hash-node' --include-dependencies pretest",
14-
"build:smithy-client": "lerna run --scope '@aws-sdk/client-rds-data' --include-dependencies pretest",
15-
"pretest": "yarn build:crypto-dependencies && yarn build:smithy-client",
16-
"test": "jest --coverage --passWithNoTests",
14+
"build:smithy-client": "yarn build:crypto-dependencies && lerna run --scope '@aws-sdk/client-rds-data' --include-dependencies pretest",
15+
"build:all": "yarn build:crypto-dependencies && lerna run --scope '@aws-sdk/client-*' --include-dependencies pretest",
16+
"pretest:all": "yarn build:all",
17+
"test:all": "jest --coverage --passWithNoTests",
1718
"test:functional": "jest --config tests/functional/jest.config.js --passWithNoTests",
18-
"integ-test": "cucumber.js"
19+
"test:integration": "cucumber.js"
1920
},
2021
"repository": {
2122
"type": "git",
Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
1-
const {parseRequest} = require('@aws-sdk/http-serialization');
2-
const {
3-
readdirSync,
4-
readFileSync,
5-
statSync,
6-
writeFileSync,
7-
} = require('fs');
8-
const {dirname, join} = require('path');
1+
const { parseRequest } = require("@aws-sdk/http-serialization");
2+
const { readdirSync, readFileSync, statSync, writeFileSync } = require("fs");
3+
const { dirname, join } = require("path");
94

105
const packageRoot = dirname(__dirname);
11-
const suiteRoot = join(packageRoot, 'suite');
6+
const suiteRoot = join(packageRoot, "suite");
127

138
const testCases = [];
149

1510
for (const [testDir, name] of getTestDirectories()) {
16-
testCases.push({
17-
name,
18-
request: Object.assign({protocol: 'https:'}, parseRequest(
19-
readFileSync(join(testDir, `${name}.req`), 'utf8')
20-
)),
21-
authorization: readFileSync(join(testDir, `${name}.authz`), 'utf8'),
22-
});
11+
testCases.push({
12+
name,
13+
request: Object.assign(
14+
{ protocol: "https:" },
15+
parseRequest(readFileSync(join(testDir, `${name}.req`), "utf8"))
16+
),
17+
authorization: readFileSync(join(testDir, `${name}.authz`), "utf8")
18+
});
2319
}
2420

2521
writeFileSync(
26-
join(packageRoot, 'src', 'suite.fixture.ts'),
27-
`
22+
join(packageRoot, "src", "suite.fixture.ts"),
23+
`
2824
import {HttpRequest} from '@aws-sdk/types';
2925
3026
export interface TestCase {
3127
name: string;
32-
request: HttpRequest<string>;
28+
request: HttpRequest;
3329
authorization: string;
3430
}
3531
@@ -46,16 +42,15 @@ export const requests: Array<TestCase> = ${JSON.stringify(testCases, null, 4)};
4642
`.trim()
4743
);
4844

45+
function* getTestDirectories() {
46+
for (const basename of readdirSync(suiteRoot)) {
47+
const dir = join(suiteRoot, basename);
48+
if (!statSync(dir).isDirectory()) continue;
4949

50-
function *getTestDirectories() {
51-
for (const basename of readdirSync(suiteRoot)) {
52-
const dir = join(suiteRoot, basename);
53-
if (!statSync(dir).isDirectory()) continue;
54-
55-
for (const entry of readdirSync(dir)) {
56-
if (entry.match(/\.req$/)) {
57-
yield [dir, entry.replace(/\.req$/, '')];
58-
}
59-
}
50+
for (const entry of readdirSync(dir)) {
51+
if (entry.match(/\.req$/)) {
52+
yield [dir, entry.replace(/\.req$/, "")];
53+
}
6054
}
55+
}
6156
}

0 commit comments

Comments
 (0)