Skip to content

Commit 4afa515

Browse files
authored
fix: move devDeps into deps (#5223)
1 parent 4c521d6 commit 4afa515

File tree

8 files changed

+105
-56
lines changed

8 files changed

+105
-56
lines changed

Diff for: packages/middleware-endpoint-discovery/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
},
2222
"license": "Apache-2.0",
2323
"devDependencies": {
24-
"@smithy/node-config-provider": "^2.0.10",
2524
"@tsconfig/recommended": "1.0.1",
2625
"concurrently": "7.0.0",
2726
"downlevel-dts": "0.10.1",
@@ -32,6 +31,7 @@
3231
"dependencies": {
3332
"@aws-sdk/endpoint-cache": "*",
3433
"@aws-sdk/types": "*",
34+
"@smithy/node-config-provider": "^2.0.10",
3535
"@smithy/protocol-http": "^3.0.3",
3636
"@smithy/types": "^2.3.1",
3737
"tslib": "^2.5.0"

Diff for: packages/rds-signer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
"@smithy/node-config-provider": "^2.0.10",
3636
"@smithy/protocol-http": "^3.0.3",
3737
"@smithy/signature-v4": "^2.0.0",
38+
"@smithy/types": "^2.3.1",
3839
"tslib": "^2.5.0"
3940
},
4041
"devDependencies": {
4142
"@aws-sdk/types": "*",
42-
"@smithy/types": "^2.3.1",
4343
"@types/node": "^14.14.31",
4444
"concurrently": "7.0.0",
4545
"downlevel-dts": "0.10.1",

Diff for: packages/signature-v4-crt/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@aws-sdk/signature-v4-multi-region": "*",
2626
"@smithy/querystring-parser": "^2.0.0",
2727
"@smithy/signature-v4": "^2.0.0",
28+
"@smithy/types": "^2.3.1",
2829
"@smithy/util-middleware": "^2.0.0",
2930
"aws-crt": "^1.15.9",
3031
"tslib": "^2.5.0"
@@ -33,7 +34,6 @@
3334
"@aws-crypto/sha256-js": "3.0.0",
3435
"@aws-sdk/types": "*",
3536
"@smithy/protocol-http": "^3.0.3",
36-
"@smithy/types": "^2.3.1",
3737
"@tsconfig/recommended": "1.0.1",
3838
"concurrently": "7.0.0",
3939
"downlevel-dts": "0.10.1",

Diff for: packages/util-create-request/src/foo.fixture.ts

-48
This file was deleted.

Diff for: packages/util-create-request/src/index.spec.ts

+47-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,60 @@
1+
import { constructStack } from "@smithy/middleware-stack";
12
import { HttpRequest } from "@smithy/protocol-http";
2-
import { Client } from "@smithy/smithy-client";
3+
import { Client, Command } from "@smithy/smithy-client";
34
import {
45
BuildHandlerArguments,
56
FinalizeHandlerArguments,
67
MetadataBearer,
8+
MiddlewareStack,
79
SerializeHandlerArguments,
810
} from "@smithy/types";
911

10-
import { fooClient, httpRequest, InputTypesUnion, operationCommand, OperationInput } from "./foo.fixture";
1112
import { createRequest } from "./index";
1213

14+
export interface OperationInput {
15+
String: string;
16+
}
17+
18+
export type InputTypesUnion = OperationInput;
19+
20+
export interface OperationOutput extends MetadataBearer {
21+
Data: string;
22+
$metadata: {};
23+
}
24+
25+
export type OutputTypesUnion = OperationOutput;
26+
27+
const output: OperationOutput = { Data: "data", $metadata: {} };
28+
29+
const input: OperationInput = { String: "input" };
30+
31+
export const fooClient: Client<any, InputTypesUnion, OutputTypesUnion, any> = {
32+
config: {},
33+
middlewareStack: constructStack<InputTypesUnion, OutputTypesUnion>(),
34+
send: (command: Command<InputTypesUnion, OutputTypesUnion, any, OperationInput, OperationOutput>) =>
35+
command.resolveMiddleware(fooClient.middlewareStack, fooClient.config, undefined)({ input }),
36+
destroy: () => {},
37+
};
38+
39+
export const operationCommand: Command<InputTypesUnion, OutputTypesUnion, any, OperationInput, MetadataBearer> = {
40+
middlewareStack: constructStack<OperationInput, OutputTypesUnion>(),
41+
input: {} as any,
42+
// @ts-ignore
43+
resolveMiddleware: (stack: MiddlewareStack<InputTypesUnion, OutputTypesUnion>) => {
44+
const concatStack = stack.concat(operationCommand.middlewareStack);
45+
return concatStack.resolve(() => Promise.resolve({ output, response: {} }), {} as any);
46+
},
47+
};
48+
49+
export const httpRequest = new HttpRequest({
50+
protocol: "https:",
51+
path: "/foo",
52+
hostname: "foo-service.us-east-1.amazonaws.com",
53+
headers: {},
54+
method: "GET",
55+
body: "",
56+
});
57+
1358
describe("create-request", () => {
1459
it("should concat initialize and serialize middlewares from client and command", async () => {
1560
operationCommand.middlewareStack.add(

Diff for: packages/util-dns/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
},
2424
"license": "Apache-2.0",
2525
"dependencies": {
26-
"tslib": "^2.5.0"
26+
"tslib": "^2.5.0",
27+
"@aws-sdk/types": "*"
2728
},
2829
"devDependencies": {
29-
"@aws-sdk/types": "*",
3030
"@tsconfig/recommended": "1.0.1",
3131
"@types/node": "^14.14.31",
3232
"concurrently": "7.0.0",

Diff for: packages/util-dynamodb/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@
2424
"tslib": "^2.5.0"
2525
},
2626
"devDependencies": {
27-
"@aws-sdk/client-dynamodb": "*",
27+
"@aws-sdk/client-dynamodb": "^3.0.0",
2828
"@tsconfig/recommended": "1.0.1",
2929
"concurrently": "7.0.0",
3030
"downlevel-dts": "0.10.1",
3131
"rimraf": "3.0.2",
3232
"typedoc": "0.23.23",
3333
"typescript": "~4.9.5"
3434
},
35+
"peerDependencies": {
36+
"@aws-sdk/client-dynamodb": "^3.0.0"
37+
},
3538
"engines": {
3639
"node": ">=14.0.0"
3740
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Checks devDependency declarations for runtime packages.
3+
* They should be moved to the dependencies section even if only imported for types.
4+
*/
5+
6+
const fs = require("node:fs");
7+
const path = require("node:path");
8+
9+
const root = path.join(__dirname, "..", "..");
10+
const packages = path.join(root, "packages");
11+
const walk = require("../utils/walk");
12+
13+
(async () => {
14+
for (const folder of fs.readdirSync(packages)) {
15+
if (folder === "util-dynamodb") {
16+
// exempt
17+
continue;
18+
}
19+
20+
const pkgJsonPath = path.join(packages, folder, "package.json");
21+
const srcPath = path.join(packages, folder, "src");
22+
const pkgJson = require(pkgJsonPath);
23+
24+
for await (const file of walk(srcPath, ["node_modules"])) {
25+
const contents = fs.readFileSync(file);
26+
27+
if (file.endsWith(".spec.ts")) {
28+
continue;
29+
}
30+
31+
if (!file.endsWith(".ts")) {
32+
continue;
33+
}
34+
35+
for (const [dep, version] of Object.entries(pkgJson.devDependencies ?? {})) {
36+
if ((dep.startsWith("@smithy") || dep.startsWith("@aws-sdk")) && contents.includes(`from "${dep}";`)) {
37+
console.warn(`${dep} incorrectly declared in devDependencies of ${folder}`);
38+
delete pkgJson.devDependencies[dep];
39+
if (!pkgJson.dependencies) {
40+
pkgJson.dependencies = {};
41+
}
42+
pkgJson.dependencies[dep] = version;
43+
44+
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
45+
}
46+
}
47+
}
48+
}
49+
})();

0 commit comments

Comments
 (0)