Skip to content

Commit

Permalink
chore(cdk-build-tools): allow packing of private packages for local t…
Browse files Browse the repository at this point in the history
…esting (#32644)

### Reason for this change

Sometimes there is a need to pack a private package so it can be tested as a package locally.
For example when a package is not released during development.
Previously it was not possible to pack a private package with our tooling.

### Description of changes

Adds a `--private` flag to the `cdk-package` command to allow force packing of private packages.

### Describe any new or updated permissions being added

n/a

### Description of how you validated changes

Manually used the new flag to pack a private package.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
mrgrain authored Dec 24, 2024
1 parent 44360cc commit b00de76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/@aws-cdk/cdk-build-tools/bin/cdk-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ async function main() {
})
.option('pre-only', { type: 'boolean', default: false, desc: 'run pre package steps only' })
.option('post-only', { type: 'boolean', default: false, desc: 'run post package steps only' })
.option('private', { type: 'boolean', default: false, desc: 'Also package private packages for local usage' })
.argv;

if (args['pre-only'] && args['post-only']) {
Expand All @@ -43,8 +44,9 @@ async function main() {
const outdir = 'dist';

// if this is a private module, don't package
if (isPrivate()) {
process.stdout.write('No packaging for private modules.\n');
const packPrivate = args.private || options.private;
if (isPrivate() && !packPrivate) {
process.stdout.write('No packaging for private modules.\nUse --private to force packing private packages for local testing.\n');
return;
}

Expand Down
6 changes: 6 additions & 0 deletions tools/@aws-cdk/cdk-build-tools/lib/package-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ export interface CDKPackageOptions {
* Should this package be bundled. (and if so, how)
*/
bundle?: Omit<BundleProps, 'packageDir'>;

/**
* Also package private packages for local usage.
* @default false
*/
private?: boolean;
}

/**
Expand Down

0 comments on commit b00de76

Please sign in to comment.