Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
]
},
"dependencies": {
"glob": "^11.0.1",
"string-width": "^4.2.3"
}
}
3 changes: 1 addition & 2 deletions packages/@aws-cdk-testing/cli-integ/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@types/semver": "^7.5.8",
"@types/yargs": "^15.0.19",
"@types/fs-extra": "^9.0.13",
"@types/glob": "^7.2.0",
"@types/npm": "^7.19.3",
"@aws-cdk/pkglint": "0.0.0"
},
Expand All @@ -56,7 +55,7 @@
"axios": "1.7.7",
"chalk": "^4",
"fs-extra": "^9.1.0",
"glob": "^7.2.3",
"glob": "^11.0.1",
"jest": "^29.7.0",
"jest-junit": "^14.0.1",
"make-runnable": "^1.4.1",
Expand Down
3 changes: 1 addition & 2 deletions packages/aws-cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
"@octokit/rest": "^18.12.0",
"@types/archiver": "^5.3.4",
"@types/fs-extra": "^9.0.13",
"@types/glob": "^7.2.0",
"@types/jest": "^29.5.12",
"@types/mockery": "^1.4.33",
"@types/node": "^18.18.14",
Expand Down Expand Up @@ -181,7 +180,7 @@
"chokidar": "^3.6.0",
"decamelize": "^5.0.1",
"fs-extra": "^9.1.0",
"glob": "^7.2.3",
"glob": "^11.0.1",
"json-diff": "^0.10.0",
"minimatch": "^9.0.5",
"p-limit": "^3.1.0",
Expand Down
32 changes: 18 additions & 14 deletions tools/@aws-cdk/cdk-build-tools/bin/cdk-copy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import * as path from 'path';
import { promisify } from 'util';
import * as fs from 'fs-extra';
import * as _glob from 'glob';
import { globIterate } from 'glob';
import * as pLimit from 'p-limit';
import yargs from 'yargs';

const glob = promisify(_glob);

async function main() {
const args = yargs(process.argv.slice(2))
.command('$0 [MODULE_NAME]', 'Copy a submodule of aws-cdk-lib to it\'s own package', argv =>
Expand Down Expand Up @@ -78,35 +75,42 @@ async function duplicateModule(config: DuplicateConfig) {
}

async function copyAndRewrite(sourceDirectory: string, targetDirectory: string, ignore: string[]) {
const files = await glob(path.join(sourceDirectory, '**', '*'), {
// Get an async iterator for all files, excluding ignored ones
const files = globIterate(path.join(sourceDirectory, '**', '*'), {
ignore: [
...autoIgnore(sourceDirectory),
...ignore,
],
});

// Copy all files to new destination and rewrite imports if needed
// Create a concurrency limiter - only 20 files processed at once
const limit = pLimit(20);
// eslint-disable-next-line @cdklabs/promiseall-no-unbounded-parallelism
await Promise.all(
files.map((filePath: string) => limit(async () => {

// Process each file one at a time, but allow up to 20 concurrent operations
for await (const filePath of files) {
await limit(async () => {
// Get file stats
const stat = await fs.stat(filePath);
// Calculate the new path
const relativePath = filePath.replace(sourceDirectory, '');
const newPath = path.join(targetDirectory, relativePath);

if (stat.isFile()) {
// Create directory structure
await fs.mkdir(path.dirname(newPath), { recursive: true });
if (fs.existsSync(newPath)) {
await fs.remove(newPath);
}
// Remove existing file (fs.remove is idempotent)
await fs.remove(newPath);

// Calculate depth for import path adjustments
const relativeDepth = relativePath.split(path.sep).length - 1;

// Rewrite source files with adjusted imports
if (isSourceFile(filePath)) {
await rewriteFileTo(filePath, newPath, relativeDepth);
}
}
})),
);
});
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tools/@aws-cdk/cdk-build-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"eslint-plugin-jest": "^28",
"eslint-plugin-jsdoc": "^50.6.3",
"fs-extra": "^9.1.0",
"glob": "^7.2.3",
"glob": "^11.0.1",
"jest": "^29.7.0",
"jest-junit": "^13.2.0",
"jsii": "~5.7.0",
Expand Down
3 changes: 1 addition & 2 deletions tools/@aws-cdk/pkglint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"devDependencies": {
"@cdklabs/eslint-plugin": "^1.3.0",
"@types/fs-extra": "^9.0.13",
"@types/glob": "^7.2.0",
"@types/jest": "^29.5.14",
"@types/semver": "^7.5.8",
"@types/yargs": "^15.0.19",
Expand All @@ -65,7 +64,7 @@
"case": "^1.6.3",
"chalk": "^4",
"fs-extra": "^9.1.0",
"glob": "^7.2.3",
"glob": "^11.0.1",
"npm-bundled": "^1.1.2",
"semver": "^7.6.3",
"yargs": "^16.2.0"
Expand Down
3 changes: 1 addition & 2 deletions tools/@aws-cdk/prlint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
"@octokit/webhooks-definitions": "^3.68.1",
"conventional-commits-parser": "^3.2.4",
"fs-extra": "^9.1.0",
"glob": "^7.2.3"
"glob": "^11.0.1"
},
"devDependencies": {
"@types/conventional-commits-parser": "3.0.2",
"@types/fs-extra": "^9.0.13",
"@types/glob": "^7.2.0",
"@types/jest": "^29.5.14",
"jest": "^29.7.0",
"make-runnable": "^1.4.1",
Expand Down
Loading