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

[kbn-pm] Enable intermediate build directory for projects #16839

Merged
merged 5 commits into from
Feb 21, 2018

Conversation

kimjoar
Copy link
Contributor

@kimjoar kimjoar commented Feb 21, 2018

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 the kibana.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 cached pacakge.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.

@kimjoar kimjoar added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.0.0 v6.3.0 labels Feb 21, 2018
@kimjoar kimjoar requested a review from azasypkin February 21, 2018 10:26
@kimjoar kimjoar force-pushed the platform/intermediate-build-directory branch from fde6768 to 98c1495 Compare February 21, 2018 10:29
@@ -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 });
Copy link
Contributor Author

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

@elastic elastic deleted a comment from elasticmachine Feb 21, 2018
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@azasypkin azasypkin left a 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
Copy link
Member

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) {
Copy link
Member

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();

Copy link
Contributor Author

@kimjoar kimjoar Feb 21, 2018

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.

@kimjoar kimjoar force-pushed the platform/intermediate-build-directory branch from 1d8a4ba to b19c0b0 Compare February 21, 2018 11:44
@@ -77,6 +77,17 @@ async function buildProject(project: Project) {
}
}

/**
* Copy the all the project's files from it's "intermediate build directory" and
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:partyparrot:

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v6.3.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants