-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[kbn-pm] Enable intermediate build directory for projects #16839
[kbn-pm] Enable intermediate build directory for projects #16839
Conversation
fde6768
to
98c1495
Compare
@@ -7,7 +7,7 @@ export type PackageDependencies = { [key: string]: string }; | |||
export type PackageScripts = { [key: string]: string }; | |||
|
|||
export function readPackageJson(dir: string) { | |||
return readPkg(path.join(dir, 'package.json'), { normalize: false }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this, as it's already handled by readPkg
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
parents: true, | ||
nodir: true, | ||
dot: true, | ||
}); | ||
|
||
const packageJson = project.json; | ||
// When a project is using an intermediate build directory, they might copy | ||
// the `package.json` into that directory. If so, we want to use that as the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe make it clear that projects not only can copy package.json
(that's not a problem per se), but rather put a modified version of package.json
into that directory that we'd like to rely on?
@@ -38,7 +39,15 @@ describe('kbn-pm production', function() { | |||
}); | |||
|
|||
expect(files.sort()).toMatchSnapshot(); | |||
|
|||
for (const file of files) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Maybe we can get rid of "conditional" expect
and do something like this instead?
const packageFilePromises = files
.filter(file => file.endsWith('package.json'))
.map(packageFile => readPackageJson(join(buildRoot, packageFile)));
expect(await Promise.all(packageFilePromises)).toMatchSnapshot();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the snapshots already account for the expect
not running (aka it handles the snapshot count), I think I'll keep this as-is for now.
1d8a4ba
to
b19c0b0
Compare
@@ -77,6 +77,17 @@ async function buildProject(project: Project) { | |||
} | |||
} | |||
|
|||
/** | |||
* Copy the all the project's files from it's "intermediate build directory" and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: Copy the all the
--> Copy all the
?
typo: from it's
--> from its
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:partyparrot:
💚 Build Succeeded |
Replaces #16815.
Introduces the option of having an intermediate build directory for projects.
This extends
@kbn/pm
to better support build steps like Kibana's and the build step provided by the plugin helpers. First, it adds support for thekibana.build.intermediateBuildDirectory
config in package.json that can define an alternate directory to use for the source of the built package. Next, rather than relying on the cachedpacakge.json
when writing the production package,package.json
is read from the build output and falls back to the cached value. This allows packages to modify their package.json in their build step and not have those changes discarded.