Skip to content

Commit b00de76

Browse files
authored
chore(cdk-build-tools): allow packing of private packages for local testing (#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*
1 parent 44360cc commit b00de76

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

tools/@aws-cdk/cdk-build-tools/bin/cdk-package.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ async function main() {
2424
})
2525
.option('pre-only', { type: 'boolean', default: false, desc: 'run pre package steps only' })
2626
.option('post-only', { type: 'boolean', default: false, desc: 'run post package steps only' })
27+
.option('private', { type: 'boolean', default: false, desc: 'Also package private packages for local usage' })
2728
.argv;
2829

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

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

tools/@aws-cdk/cdk-build-tools/lib/package-info.ts

+6
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ export interface CDKPackageOptions {
205205
* Should this package be bundled. (and if so, how)
206206
*/
207207
bundle?: Omit<BundleProps, 'packageDir'>;
208+
209+
/**
210+
* Also package private packages for local usage.
211+
* @default false
212+
*/
213+
private?: boolean;
208214
}
209215

210216
/**

0 commit comments

Comments
 (0)