-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move runtime packages into deps from devDeps (#936)
- Loading branch information
Showing
9 changed files
with
78 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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,10 @@ | ||
--- | ||
"@smithy/service-error-classification": patch | ||
"@smithy/util-defaults-mode-browser": patch | ||
"@smithy/util-defaults-mode-node": patch | ||
"@smithy/middleware-stack": patch | ||
"@smithy/util-middleware": patch | ||
"@smithy/util-retry": patch | ||
--- | ||
|
||
move devDeps into deps |
This file contains 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 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 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 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 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 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 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,44 @@ | ||
/** | ||
* 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)) { | ||
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/") && 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)); | ||
} | ||
} | ||
} | ||
} | ||
})(); |
This file contains 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,16 @@ | ||
const fs = require("node:fs"); | ||
const path = require("node:path"); | ||
|
||
module.exports = async function* walk(dir, ignore = []) { | ||
for await (const d of await fs.promises.opendir(dir)) { | ||
const entry = path.join(dir, d.name); | ||
if (ignore.find((ignored) => entry.includes(ignored))) { | ||
continue; | ||
} | ||
if (d.isDirectory()) { | ||
yield* walk(entry, ignore); | ||
} else if (d.isFile()) { | ||
yield entry; | ||
} | ||
} | ||
}; |