Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add configurable pack command #4021

Merged
merged 5 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
250 changes: 125 additions & 125 deletions gh-pages/content/specification/6-compliance-report.md

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions packages/jsii-pacmak/bin/jsii-pacmak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ import { VERSION_DESC } from '../lib/version';
default: undefined,
hidden: true,
})
.option('npm-pack-command', {
type: 'string',
desc: 'Configure a custom command to execute when packaging i.e. pnpm pack --pack-destination {{destDir}}. Bundle must be written to {{destDir}} which will be substituted at runtime.',
defaultDescription: 'npm pack is used.',
default: 'npm pack --pack-destination {{destDir}}',
hidden: true,
})
agdimech marked this conversation as resolved.
Show resolved Hide resolved
.option('validate-assemblies', {
type: 'boolean',
desc: 'Whether jsii assemblies should be validated. This can be expensive and is skipped by default.',
Expand Down
4 changes: 3 additions & 1 deletion packages/jsii-pacmak/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export async function pacmak({

await timers.recordAsync('npm pack', () => {
logging.info('Packaging NPM bundles');
return Promise.all(modulesToPackageFlat.map((m) => m.npmPack()));
return Promise.all(
modulesToPackageFlat.map((m) => m.npmPack(argv['npm-pack-command'])),
);
});

await timers.recordAsync('load jsii', () => {
Expand Down
14 changes: 9 additions & 5 deletions packages/jsii-pacmak/lib/packaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ export class JsiiModule {
/**
* Prepare an NPM package from this source module
*/
public async npmPack() {
public async npmPack(
packCommand = 'npm pack --pack-destination {{destDir}}',
) {
this._tarball = await Scratch.make(async (tmpdir) => {
// Quoting (JSON-stringifying) the module directory in order to avoid
// problems if there are spaces or other special characters in the path.
const args = ['pack', JSON.stringify(this.moduleDirectory)];
const args = [
...packCommand.split(' ').map((c) => c.replace(/{{destDir}}/g, tmpdir)),
];
if (logging.level >= logging.LEVEL_VERBOSE) {
args.push('--loglevel=verbose');
}
agdimech marked this conversation as resolved.
Show resolved Hide resolved
const out = await shell('npm', args, { cwd: tmpdir });
const out = await shell(args[0], args.slice(1), {
cwd: this.moduleDirectory,
agdimech marked this conversation as resolved.
Show resolved Hide resolved
});
// Take only the last line of npm pack which should contain the
// tarball name. otherwise, there can be a lot of extra noise there
// from scripts that emit to STDOUT.
Expand Down
3 changes: 2 additions & 1 deletion packages/jsii-pacmak/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
"jsii": "^0.0.0",
"jsii-build-tools": "^0.0.0",
"jsii-calc": "^3.20.120",
"pyright": "^1.1.296"
"pyright": "^1.1.296",
"pnpm": "^7.30.0"
},
"keywords": [
"jsii",
Expand Down
4 changes: 4 additions & 0 deletions packages/jsii-pacmak/test/build-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ done
clean_dists
echo "Testing ALL-AT-ONCE build."
${pacmak} ${OPTS} -v --no-parallel $packagedirs

clean_dists
echo "Testing pnpm."
${pacmak} ${OPTS} -v --no-parallel --npm-pack-command='yarn run pnpm pack --pack-destination {{destDir}}' $packagedirs
5 changes: 5 additions & 0 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.