Skip to content

Commit

Permalink
fix: move devDeps into deps
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Sep 15, 2023
1 parent 61d5e22 commit 1552f8e
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 56 deletions.
2 changes: 1 addition & 1 deletion packages/middleware-endpoint-discovery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@smithy/node-config-provider": "^2.0.10",
"@tsconfig/recommended": "1.0.1",
"concurrently": "7.0.0",
"downlevel-dts": "0.10.1",
Expand All @@ -32,6 +31,7 @@
"dependencies": {
"@aws-sdk/endpoint-cache": "*",
"@aws-sdk/types": "*",
"@smithy/node-config-provider": "^2.0.10",
"@smithy/protocol-http": "^3.0.3",
"@smithy/types": "^2.3.1",
"tslib": "^2.5.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/rds-signer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
"@smithy/node-config-provider": "^2.0.10",
"@smithy/protocol-http": "^3.0.3",
"@smithy/signature-v4": "^2.0.0",
"@smithy/types": "^2.3.1",
"tslib": "^2.5.0"
},
"devDependencies": {
"@aws-sdk/types": "*",
"@smithy/types": "^2.3.1",
"@types/node": "^14.14.31",
"concurrently": "7.0.0",
"downlevel-dts": "0.10.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/signature-v4-crt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@aws-sdk/signature-v4-multi-region": "*",
"@smithy/querystring-parser": "^2.0.0",
"@smithy/signature-v4": "^2.0.0",
"@smithy/types": "^2.3.1",
"@smithy/util-middleware": "^2.0.0",
"aws-crt": "^1.15.9",
"tslib": "^2.5.0"
Expand All @@ -33,7 +34,6 @@
"@aws-crypto/sha256-js": "3.0.0",
"@aws-sdk/types": "*",
"@smithy/protocol-http": "^3.0.3",
"@smithy/types": "^2.3.1",
"@tsconfig/recommended": "1.0.1",
"concurrently": "7.0.0",
"downlevel-dts": "0.10.1",
Expand Down
48 changes: 0 additions & 48 deletions packages/util-create-request/src/foo.fixture.ts

This file was deleted.

49 changes: 47 additions & 2 deletions packages/util-create-request/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,60 @@
import { constructStack } from "@smithy/middleware-stack";
import { HttpRequest } from "@smithy/protocol-http";
import { Client } from "@smithy/smithy-client";
import { Client, Command } from "@smithy/smithy-client";
import {
BuildHandlerArguments,
FinalizeHandlerArguments,
MetadataBearer,
MiddlewareStack,
SerializeHandlerArguments,
} from "@smithy/types";

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

export interface OperationInput {
String: string;
}

export type InputTypesUnion = OperationInput;

export interface OperationOutput extends MetadataBearer {
Data: string;
$metadata: {};
}

export type OutputTypesUnion = OperationOutput;

const output: OperationOutput = { Data: "data", $metadata: {} };

const input: OperationInput = { String: "input" };

export const fooClient: Client<any, InputTypesUnion, OutputTypesUnion, any> = {
config: {},
middlewareStack: constructStack<InputTypesUnion, OutputTypesUnion>(),
send: (command: Command<InputTypesUnion, OutputTypesUnion, any, OperationInput, OperationOutput>) =>
command.resolveMiddleware(fooClient.middlewareStack, fooClient.config, undefined)({ input }),
destroy: () => {},
};

export const operationCommand: Command<InputTypesUnion, OutputTypesUnion, any, OperationInput, MetadataBearer> = {
middlewareStack: constructStack<OperationInput, OutputTypesUnion>(),
input: {} as any,
// @ts-ignore
resolveMiddleware: (stack: MiddlewareStack<InputTypesUnion, OutputTypesUnion>) => {
const concatStack = stack.concat(operationCommand.middlewareStack);
return concatStack.resolve(() => Promise.resolve({ output, response: {} }), {} as any);
},
};

export const httpRequest = new HttpRequest({
protocol: "https:",
path: "/foo",
hostname: "foo-service.us-east-1.amazonaws.com",
headers: {},
method: "GET",
body: "",
});

describe("create-request", () => {
it("should concat initialize and serialize middlewares from client and command", async () => {
operationCommand.middlewareStack.add(
Expand Down
4 changes: 2 additions & 2 deletions packages/util-dns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
},
"license": "Apache-2.0",
"dependencies": {
"tslib": "^2.5.0"
"tslib": "^2.5.0",
"@aws-sdk/types": "*"
},
"devDependencies": {
"@aws-sdk/types": "*",
"@tsconfig/recommended": "1.0.1",
"@types/node": "^14.14.31",
"concurrently": "7.0.0",
Expand Down
5 changes: 4 additions & 1 deletion packages/util-dynamodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@
"tslib": "^2.5.0"
},
"devDependencies": {
"@aws-sdk/client-dynamodb": "*",
"@aws-sdk/client-dynamodb": "^3.0.0",
"@tsconfig/recommended": "1.0.1",
"concurrently": "7.0.0",
"downlevel-dts": "0.10.1",
"rimraf": "3.0.2",
"typedoc": "0.23.23",
"typescript": "~4.9.5"
},
"peerDependencies": {
"@aws-sdk/client-dynamodb": "^3.0.0"
},
"engines": {
"node": ">=14.0.0"
},
Expand Down
49 changes: 49 additions & 0 deletions scripts/runtime-dependency-version-check/check-dev-dependencies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Checks devDependency declarations for runtime packages.
* They should be moved to the dependencies section even if only imported for types.
*/

const fs = require("node:fs");
const path = require("node:path");

const root = path.join(__dirname, "..", "..");
const packages = path.join(root, "packages");
const walk = require("../utils/walk");

(async () => {
for (const folder of fs.readdirSync(packages)) {
if (folder === "util-dynamodb") {
// exempt
continue;
}

const pkgJsonPath = path.join(packages, folder, "package.json");
const srcPath = path.join(packages, folder, "src");
const pkgJson = require(pkgJsonPath);

for await (const file of walk(srcPath, ["node_modules"])) {
const contents = fs.readFileSync(file);

if (file.endsWith(".spec.ts")) {
continue;
}

if (!file.endsWith(".ts")) {
continue;
}

for (const [dep, version] of Object.entries(pkgJson.devDependencies ?? {})) {
if ((dep.startsWith("@smithy") || dep.startsWith("@aws-sdk")) && contents.includes(`from "${dep}";`)) {
console.warn(`${dep} incorrectly declared in devDependencies of ${folder}`);
delete pkgJson.devDependencies[dep];
if (!pkgJson.dependencies) {
pkgJson.dependencies = {};
}
pkgJson.dependencies[dep] = version;

fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
}
}
}
}
})();

0 comments on commit 1552f8e

Please sign in to comment.