Skip to content

Commit

Permalink
chore(NA): stop grouping bazel out symlink folders (elastic#96066)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic authored and kibanamachine committed Apr 1, 2021
1 parent 6c98e5d commit 761d45e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 15 deletions.
5 changes: 4 additions & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
.idea
.teamcity
.yarn-local-mirror
/bazel
bazel-bin
bazel-kibana
bazel-out
bazel-testlogs
build
node_modules
target
5 changes: 2 additions & 3 deletions .bazelrc.common
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ build --disk_cache=~/.bazel-cache/disk-cache
build --repository_cache=~/.bazel-cache/repository-cache

# Bazel will create symlinks from the workspace directory to output artifacts.
# Build results will be placed in a directory called "bazel/bin"
# Build results will be placed in a directory called "bazel-bin"
# This will still create a bazel-out symlink in
# the project directory, which must be excluded from the
# editor's search path.
build --symlink_prefix=bazel/
# To disable the symlinks altogether (including bazel-out) we can use
# build --symlink_prefix=/
# however this makes it harder to find outputs.

# Prevents the creation of bazel-out dir
build --experimental_no_product_name_out_symlink
# build --experimental_no_product_name_out_symlink

# Make direct file system calls to create symlink trees
build --experimental_inprocess_symlink_creation
Expand Down
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ snapshots.js
/packages/kbn-monaco/src/painless/antlr

# Bazel
/bazel
/bazel-*
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ report.asciidoc
.yarn-local-mirror

# Bazel
/bazel
/.bazelrc.user
bazel-*
.bazelrc.user
1 change: 1 addition & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
x-pack/plugins/canvas/shareable_runtime/**/*.s+(a|c)ss
build
target
bazel-*
8 changes: 4 additions & 4 deletions packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22981,7 +22981,7 @@ class Project {

ensureValidProjectDependency(project) {
const relativePathToProject = normalizePath(path__WEBPACK_IMPORTED_MODULE_1___default.a.relative(this.path, project.path));
const relativePathToProjectIfBazelPkg = normalizePath(path__WEBPACK_IMPORTED_MODULE_1___default.a.relative(this.path, `bazel/bin/packages/${path__WEBPACK_IMPORTED_MODULE_1___default.a.basename(project.path)}`));
const relativePathToProjectIfBazelPkg = normalizePath(path__WEBPACK_IMPORTED_MODULE_1___default.a.relative(this.path, `bazel-bin/packages/${path__WEBPACK_IMPORTED_MODULE_1___default.a.basename(project.path)}`));
const versionInPackageJson = this.allDependencies[project.name];
const expectedVersionInPackageJson = `link:${relativePathToProject}`;
const expectedVersionInPackageJsonIfBazelPkg = `link:${relativePathToProjectIfBazelPkg}`; // TODO: after introduce bazel to build all the packages and completely remove the support for kbn packages
Expand Down Expand Up @@ -23143,7 +23143,7 @@ const createProductionPackageJson = pkgJson => _objectSpread(_objectSpread({}, p
dependencies: transformDependencies(pkgJson.dependencies)
});
const isLinkDependency = depVersion => depVersion.startsWith('link:');
const isBazelPackageDependency = depVersion => depVersion.startsWith('link:bazel/bin/');
const isBazelPackageDependency = depVersion => depVersion.startsWith('link:bazel-bin/');
/**
* Replaces `link:` dependencies with `file:` dependencies. When installing
* dependencies, these `file:` dependencies will be copied into `node_modules`
Expand All @@ -23153,7 +23153,7 @@ const isBazelPackageDependency = depVersion => depVersion.startsWith('link:bazel
* will then _copy_ the `file:` dependencies into `node_modules` instead of
* symlinking like we do in development.
*
* Additionally it also taken care of replacing `link:bazel/bin/` with
* Additionally it also taken care of replacing `link:bazel-bin/` with
* `file:` so we can also support the copy of the Bazel packages dist already into
* build/packages to be copied into the node_modules
*/
Expand All @@ -23170,7 +23170,7 @@ function transformDependencies(dependencies = {}) {
}

if (isBazelPackageDependency(depVersion)) {
newDeps[name] = depVersion.replace('link:bazel/bin/', 'file:');
newDeps[name] = depVersion.replace('link:bazel-bin/', 'file:');
continue;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/kbn-pm/src/utils/package_json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const createProductionPackageJson = (pkgJson: IPackageJson) => ({
export const isLinkDependency = (depVersion: string) => depVersion.startsWith('link:');

export const isBazelPackageDependency = (depVersion: string) =>
depVersion.startsWith('link:bazel/bin/');
depVersion.startsWith('link:bazel-bin/');

/**
* Replaces `link:` dependencies with `file:` dependencies. When installing
Expand All @@ -46,7 +46,7 @@ export const isBazelPackageDependency = (depVersion: string) =>
* will then _copy_ the `file:` dependencies into `node_modules` instead of
* symlinking like we do in development.
*
* Additionally it also taken care of replacing `link:bazel/bin/` with
* Additionally it also taken care of replacing `link:bazel-bin/` with
* `file:` so we can also support the copy of the Bazel packages dist already into
* build/packages to be copied into the node_modules
*/
Expand All @@ -61,7 +61,7 @@ export function transformDependencies(dependencies: IPackageDependencies = {}) {
}

if (isBazelPackageDependency(depVersion)) {
newDeps[name] = depVersion.replace('link:bazel/bin/', 'file:');
newDeps[name] = depVersion.replace('link:bazel-bin/', 'file:');
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/src/utils/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class Project {
public ensureValidProjectDependency(project: Project) {
const relativePathToProject = normalizePath(Path.relative(this.path, project.path));
const relativePathToProjectIfBazelPkg = normalizePath(
Path.relative(this.path, `bazel/bin/packages/${Path.basename(project.path)}`)
Path.relative(this.path, `bazel-bin/packages/${Path.basename(project.path)}`)
);

const versionInPackageJson = this.allDependencies[project.name];
Expand Down

0 comments on commit 761d45e

Please sign in to comment.