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(builtin): flip the default of the strict_visibility flag on the npm and yarn install rules to True #2238

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions e2e/concatjs_devserver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"jasmine": "2.8.0",
"protractor": "^5.4.2",
"rxjs": "^6.5.2",
"tslib": "^1.9.0",
"typeorm": "^0.2.17",
"typescript": "2.7.x"
},
Expand Down
3 changes: 2 additions & 1 deletion e2e/jasmine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"test": "bazel test ..."
},
"devDependencies": {
"jasmine": "2.99.0"
"jasmine": "2.99.0",
"jasmine-core": "2.99.0"
}
}
5 changes: 5 additions & 0 deletions e2e/jasmine/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ istanbul-reports@^3.0.2:
html-escaper "^2.0.0"
istanbul-lib-report "^3.0.0"

[email protected]:
version "2.99.0"
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.99.0.tgz#c105ab5222da45f1b0a10580383f5adbbff56d2c"
integrity sha1-wQWrUiLaRfGwoQWAOD9a27/1bSw=

jasmine-core@~2.99.0:
version "2.99.1"
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.99.1.tgz#e6400df1e6b56e130b61c4bcd093daa7f6e8ca15"
Expand Down
5 changes: 5 additions & 0 deletions examples/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"@ngrx/store": "9.2.0",
"@nguniversal/express-engine": "^9.0.0",
"date-fns": "1.30.1",
"domino": "^2.1.2",
"reflect-metadata": "^0.1.2",
"rxjs": "6.5.3",
"systemjs": "6.1.2",
"tslib": "2.0.0",
Expand Down Expand Up @@ -50,9 +52,12 @@
"@types/jasmine": "3.4.0",
"@types/node": "6.14.6",
"core-js": "2.6.9",
"express": "^4.14.0",
"firebase-tools": "7.1.0",
"history-server": "^1.3.1",
"html-insert-assets": "^0.6.0",
"jasmine": "2.8.0",
"jasmine-core": "2.8.0",
"karma": "~4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-firefox-launcher": "1.1.0",
Expand Down
2 changes: 2 additions & 0 deletions examples/angular_view_engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
"firebase-tools": "7.1.0",
"history-server": "^1.3.1",
"html-insert-assets": "^0.6.0",
"jasmine": "2.8.0",
"jasmine-core": "2.8.0",
"karma": "~4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-firefox-launcher": "1.1.0",
Expand Down
1 change: 1 addition & 0 deletions examples/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@bazel/terser": "^2.2.2",
"@bazel/typescript": "^2.2.2",
"@types/jasmine": "3.3.15",
"@types/node": "^12.12.2",
"html-insert-assets": "^0.6.0",
"http-server": "^0.11.1",
"less": "^3.10.3",
Expand Down
5 changes: 5 additions & 0 deletions examples/app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.21.tgz#4a9db7ef1d1671c0015e632c5fa3d46c86c58c1e"
integrity sha512-nuFlRdBiqbF+PJIEVxm2jLFcQWN7q7iWEJGsBV4n7v1dbI9qXB8im2pMMKMCUZe092sQb5SQft2DHfuQGK5hqQ==

"@types/node@^12.12.2":
version "12.12.68"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.68.tgz#dd5acf4a52a458ff1d9ef4fd66406fba0afbbb33"
integrity sha512-3RW2s24ewB7F9dAHvgb9FRvNHn6nO9IK6Eaknbz7HTOe2a5GVne5XbUh5+YA+kcCn67glyHhClUUdFP73LWrgQ==

"@types/node@^12.7.2":
version "12.7.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.8.tgz#cb1bf6800238898bc2ff6ffa5702c3cadd350708"
Expand Down
1 change: 1 addition & 0 deletions examples/create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/dom": "^6.15.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
Expand Down
1 change: 1 addition & 0 deletions examples/cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@cypress/browserify-preprocessor": "^3.0.0",
"@types/node": "14.0.13",
"cypress": "^4.8.0",
"rxjs": "^6.5.2",
"typescript": "3.9.5"
},
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions examples/cypress/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3856,6 +3856,13 @@ rxjs@^6.3.3:
dependencies:
tslib "^1.9.0"

rxjs@^6.5.2:
version "6.6.3"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.3.tgz#8ca84635c4daa900c0d3967a6ee7ac60271ee552"
integrity sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ==
dependencies:
tslib "^1.9.0"

[email protected], safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.2"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
Expand Down
4 changes: 3 additions & 1 deletion examples/nestjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
"minimist": "1.2.0",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.2",
"supertest": "^4.0.2"
"supertest": "^4.0.2",
"superagent": "~3.8.3"
},
"devDependencies": {
"@bazel/typescript": "^2.2.2",
"@types/node": "12.6.3",
"tslib": "^1.9.0",
"typescript": "3.5.3"
},
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions examples/protocol_buffers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"google-protobuf": "3.11.4",
"grpc-web": "1.1.0",
"http-server": "^0.11.1",
"jasmine": "2.8.0",
"jasmine-core": "2.8.0",
"karma": "~4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-firefox-launcher": "1.1.0",
Expand Down
1 change: 1 addition & 0 deletions examples/react_webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@types/react": "^16.9.5",
"@types/react-dom": "^16.9.1",
"css-loader": "^3.2.0",
"csstype": "^2.2.0",
"http-server": "^0.11.1",
"react": "^16.10.2",
"react-dom": "^16.10.2",
Expand Down
1 change: 1 addition & 0 deletions examples/web_testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"@bazel/typescript": "^2.2.2",
"@types/jasmine": "2.8.2",
"@types/node": "11.11.1",
"jasmine-core": "^3.3.0",
"karma": "~4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-firefox-launcher": "1.1.0",
Expand Down
5 changes: 5 additions & 0 deletions examples/web_testing/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,11 @@ jasmine-core@^3.3:
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-3.5.0.tgz#132c23e645af96d85c8bca13c8758b18429fc1e4"
integrity sha512-nCeAiw37MIMA9w9IXso7bRaLl+c/ef3wnxsoSAlYrzS+Ot0zTG6nU8G/cIfGkqpkjX2wNaIW9RFG0TwIFnG6bA==

jasmine-core@^3.3.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-3.6.0.tgz#491f3bb23941799c353ceb7a45b38a950ebc5a20"
integrity sha512-8uQYa7zJN8hq9z+g8z1bqCfdC8eoDAeVnM5sfqs7KHv9/ifoJ500m018fpFc7RDaO6SWCLCXwo/wPSNcdYTgcw==

jsonfile@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
Expand Down
2 changes: 1 addition & 1 deletion internal/npm_install/generate_build_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ export function parsePackage(p: string, dependencies: Set<string> = new Set()):

// set if this is a direct dependency of the root package.json file
// which is later used to determine the generated rules visibility
pkg._directDependency = dependencies.has(pkg._moduleName);
pkg._directDependency = dependencies.has(pkg._moduleName) || dependencies.has(pkg._name);

return pkg;
}
Expand Down
2 changes: 1 addition & 1 deletion internal/npm_install/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ function parsePackage(p, dependencies = new Set()) {
pkg._files = listFiles(p);
pkg._runfiles = pkg._files.filter((f) => !/[^\x21-\x7E]/.test(f));
pkg._dependencies = [];
pkg._directDependency = dependencies.has(pkg._moduleName);
pkg._directDependency = dependencies.has(pkg._moduleName) || dependencies.has(pkg._name);
return pkg;
}
exports.parsePackage = parsePackage;
Expand Down
4 changes: 1 addition & 3 deletions internal/npm_install/npm_install.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,12 @@ fine grained npm dependencies.
doc = "If stdout and stderr should be printed to the terminal.",
),
"strict_visibility": attr.bool(
default = False,
default = True,
doc = """Turn on stricter visibility for generated BUILD.bazel files

When enabled, only dependencies within the given `package.json` file are given public visibility.
All transitive dependencies are given limited visibility, enforcing that all direct dependencies are
listed in the `package.json` file.

Currently the default is set `False`, but will likely be flipped `True` in rules_nodejs 3.0.0
""",
),
"symlink_node_modules": attr.bool(
Expand Down
38 changes: 38 additions & 0 deletions internal/npm_install/test/golden/BUILD.bazel.golden
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,44 @@ exports_files([
"node_modules/jasmine/lib/jasmine.js",
"node_modules/jasmine/lib/reporters/completion_reporter.js",
"node_modules/jasmine/lib/reporters/console_reporter.js",
"node_modules/jasmine/node_modules/jasmine-core/.editorconfig",
"node_modules/jasmine/node_modules/jasmine-core/.github/CONTRIBUTING.md",
"node_modules/jasmine/node_modules/jasmine-core/.github/ISSUE_TEMPLATE.md",
"node_modules/jasmine/node_modules/jasmine-core/.github/PULL_REQUEST_TEMPLATE.md",
"node_modules/jasmine/node_modules/jasmine-core/.ruby-version",
"node_modules/jasmine/node_modules/jasmine-core/CODE_OF_CONDUCT.md",
"node_modules/jasmine/node_modules/jasmine-core/MANIFEST.in",
"node_modules/jasmine/node_modules/jasmine-core/MIT.LICENSE",
"node_modules/jasmine/node_modules/jasmine-core/README.md",
"node_modules/jasmine/node_modules/jasmine-core/RELEASE.md",
"node_modules/jasmine/node_modules/jasmine-core/bower.json",
"node_modules/jasmine/node_modules/jasmine-core/images/__init__.pyc",
"node_modules/jasmine/node_modules/jasmine-core/images/__pycache__/__init__.cpython-36.pyc",
"node_modules/jasmine/node_modules/jasmine-core/images/jasmine-horizontal.png",
"node_modules/jasmine/node_modules/jasmine-core/images/jasmine-horizontal.svg",
"node_modules/jasmine/node_modules/jasmine-core/images/jasmine_favicon.png",
"node_modules/jasmine/node_modules/jasmine-core/jasmine_core.egg-info/PKG-INFO",
"node_modules/jasmine/node_modules/jasmine-core/jasmine_core.egg-info/SOURCES.txt",
"node_modules/jasmine/node_modules/jasmine-core/jasmine_core.egg-info/dependency_links.txt",
"node_modules/jasmine/node_modules/jasmine-core/jasmine_core.egg-info/requires.txt",
"node_modules/jasmine/node_modules/jasmine-core/jasmine_core.egg-info/top_level.txt",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core.js",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/boot.js",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/node_example/lib/jasmine_examples/Player.js",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/node_example/lib/jasmine_examples/Song.js",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/node_example/spec/helpers/jasmine_examples/SpecHelper.js",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/spec/PlayerSpec.js",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/spec/SpecHelper.js",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/src/Player.js",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/src/Song.js",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.css",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/json2.js",
"node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/node_boot.js",
"node_modules/jasmine/node_modules/jasmine-core/package.json",
"node_modules/jasmine/node_modules/jasmine-core/requirements.txt",
"node_modules/jasmine/package.json",
"node_modules/jasmine/tasks/jasmine.js",
"node_modules/jasmine-core/.editorconfig",
Expand Down
22 changes: 21 additions & 1 deletion internal/npm_install/test/golden/jasmine/BUILD.bazel.golden
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@ filegroup(
)
filegroup(
name = "jasmine__nested_node_modules",
srcs = [
"//:node_modules/jasmine/node_modules/jasmine-core/.editorconfig",
"//:node_modules/jasmine/node_modules/jasmine-core/.ruby-version",
"//:node_modules/jasmine/node_modules/jasmine-core/bower.json",
"//:node_modules/jasmine/node_modules/jasmine-core/jasmine_core.egg-info/PKG-INFO",
"//:node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core.js",
"//:node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/boot.js",
"//:node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/node_example/lib/jasmine_examples/Player.js",
"//:node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/node_example/lib/jasmine_examples/Song.js",
"//:node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/node_example/spec/helpers/jasmine_examples/SpecHelper.js",
"//:node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js",
"//:node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/spec/PlayerSpec.js",
"//:node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/spec/SpecHelper.js",
"//:node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/src/Player.js",
"//:node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/example/src/Song.js",
"//:node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js",
"//:node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js",
"//:node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/json2.js",
"//:node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/node_boot.js",
"//:node_modules/jasmine/node_modules/jasmine-core/package.json",
],
visibility = ["//:__subpackages__"],
)
filegroup(
Expand Down Expand Up @@ -50,7 +71,6 @@ js_library(
"//balanced-match:balanced-match__contents",
"//concat-map:concat-map__contents",
"//path-is-absolute:path-is-absolute__contents",
"//jasmine-core:jasmine-core__contents",
],
)
js_library(
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"@babel/cli": "^7.6.2",
"@babel/core": "^7.6.2",
"@babel/preset-env": "^7.6.2",
"@babel/parser": "^7.6.2",
"@babel/types": "^7.6.2",
"@bazel/bazelisk": "^1.5.0",
"@bazel/buildifier": "^3.2.0",
"@bazel/buildozer": "^3.2.0",
Expand Down Expand Up @@ -51,6 +53,7 @@
"jasmine-core": "~3.4.0",
"jasmine-reporters": "~2.3.2",
"jest": "~25.3.0",
"jest-cli": "~25.3.0",
"jest-websocket-mock": "~2.0.2",
"karma": "~4.1.0",
"karma-chrome-launcher": "2.2.0",
Expand Down
1 change: 1 addition & 0 deletions packages/cypress/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"cypress": "^4.8.0",
"@cypress/browserify-preprocessor": "^3.0.0",
"@types/node": "14.0.14",
"rxjs": "^6.5.2",
"typescript": "3.9.5"
}
}
7 changes: 7 additions & 0 deletions packages/cypress/test/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3696,6 +3696,13 @@ rxjs@^6.3.3:
dependencies:
tslib "^1.9.0"

rxjs@^6.5.2:
version "6.6.3"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.3.tgz#8ca84635c4daa900c0d3967a6ee7ac60271ee552"
integrity sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ==
dependencies:
tslib "^1.9.0"

[email protected], safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.2"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
Expand Down
2 changes: 0 additions & 2 deletions packages/karma/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ ts_library(
tsconfig = ":tsconfig.json",
deps = [
"@npm//@types/node",
"@npm//tmp",
],
)

Expand All @@ -46,7 +45,6 @@ nodejs_binary(
"@npm//karma-requirejs",
"@npm//karma-sourcemap-loader",
"@npm//requirejs",
"@npm//tmp",
],
entry_point = "@npm//:node_modules/karma/bin/karma",
)
Expand Down
9 changes: 4 additions & 5 deletions packages/karma/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as fs from 'fs';
import * as path from 'path';
import * as process from 'process';
import {createInterface} from 'readline';
import * as tmp from 'tmp';
///<reference types="lib.dom"/>

/**
Expand All @@ -24,14 +23,14 @@ function sha1(data) {
function initConcatJs(logger, emitter, basePath, hostname, port) {
const log = logger.create('framework.concat_js');

// Create a tmp file for the concat bundle that is automatically cleaned up on
// exit.
const tmpFile = tmp.fileSync({keep: false, dir: process.env['TEST_TMPDIR']});
// Create a tmp file for the concat bundle, rely on Bazel to clean the TMPDIR
const tmpFile =
path.join(process.env['TEST_TMPDIR'], crypto.randomBytes(6).readUIntLE(0, 6).toString(36));

emitter.on('file_list_modified', files => {
const bundleFile = {
path: '/concatjs_bundle.js',
contentPath: tmpFile.name,
contentPath: tmpFile,
isUrl: false,
content: '',
encodings: {},
Expand Down
10 changes: 5 additions & 5 deletions packages/karma/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Karma configuration
// GENERATED BY Bazel
try {
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const tmp = require('tmp');
const child_process = require('child_process');
const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER']);

Expand Down Expand Up @@ -272,10 +272,10 @@ try {
})();
`;

const requireConfigFile =
tmp.fileSync({keep: false, postfix: '.js', dir: process.env['TEST_TMPDIR']});
fs.writeFileSync(requireConfigFile.name, requireConfigContent);
conf.files.push(requireConfigFile.name);
const requireConfigFile = path.join(
process.env['TEST_TMPDIR'], crypto.randomBytes(6).readUIntLE(0, 6).toString(36) + '.js');
fs.writeFileSync(requireConfigFile, requireConfigContent);
conf.files.push(requireConfigFile);
}

/**
Expand Down
1 change: 0 additions & 1 deletion packages/karma/karma_web_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ KARMA_PEER_DEPS = [
"@npm//karma-requirejs",
"@npm//karma-sourcemap-loader",
"@npm//requirejs",
"@npm//tmp",
]

KARMA_WEB_TEST_ATTRS = {
Expand Down
Loading