1diff -urN a/BUILD.bazel b/BUILD.bazel
2--- a/BUILD.bazel 2023-09-25 16:52:51.395439671 +0000
3+++ b/BUILD.bazel 1970-01-01 00:00:00.000000000 +0000
4@@ -1,47 +0,0 @@
5-load("@bazel_gazelle//:def.bzl", "gazelle")
6-load("//buildifier:def.bzl", "buildifier")
7-
8-exports_files([
9- "LICENSE",
10- "launcher.js",
11-])
12-
13-config_setting(
14- name = "windows",
15- values = {"cpu": "x64_windows"},
16-)
17-
18-filegroup(
19- name = "warnings",
20- srcs = ["WARNINGS.md"],
21- visibility = ["//warn/docs:__pkg__"],
22-)
23-
24-test_suite(
25- name = "tests",
26- tests = [
27- "//api_proto:api.gen.pb.go_checkshtest",
28- "//build:build_test",
29- "//build_proto:build.gen.pb.go_checkshtest",
30- "//buildifier:buildifier_integration_test",
31- "//deps_proto:deps.gen.pb.go_checkshtest",
32- "//edit:edit_test",
33- "//extra_actions_base_proto:extra_actions_base.gen.pb.go_checkshtest",
34- "//labels:labels_test",
35- "//lang:tables.gen.go_checkshtest",
36- "//tables:tables_test",
37- "//warn:warn_test",
38- "//warn/docs:docs_test",
39- "//wspace:wspace_test",
40- ],
41-)
42-
43-#gazelle:go_naming_convention import_alias
44-gazelle(
45- name = "gazelle",
46- prefix = "github.com/bazelbuild/buildtools",
47-)
48-
49-buildifier(
50- name = "buildifier",
51-)
52diff -urN a/buildifier/npm/BUILD.bazel b/buildifier/npm/BUILD.bazel
53--- a/buildifier/npm/BUILD.bazel 2023-09-25 16:52:51.403439550 +0000
54+++ b/buildifier/npm/BUILD.bazel 1970-01-01 00:00:00.000000000 +0000
55@@ -1,61 +0,0 @@
56-load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
57-load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test", "pkg_npm")
58-
59-copy_file(
60- name = "copy_LICENSE",
61- src = "//:LICENSE",
62- out = "LICENSE",
63-)
64-
65-genrule(
66- name = "buildifier_launcher",
67- srcs = ["//:launcher.js"],
68- outs = ["buildifier.js"],
69- cmd = "sed s/_TOOL_/buildifier/ $< > $@",
70-)
71-
72-# npm rules live in this subdirectory to avoid a load() statement
73-# in the parent package leaking to users. This means we need
74-# to copy the output files so the pkg_npm will find them in the
75-# output directory for this package.
76-_PARENT_PACKAGE_FILES = [
77- "README.md",
78- "buildifier-darwin_amd64",
79- "buildifier-darwin_arm64",
80- "buildifier-linux_amd64",
81- "buildifier-linux_arm64",
82- "buildifier-windows_amd64.exe",
83-]
84-
85-[
86- copy_file(
87- name = "copy_%s" % s,
88- # go_binary doesn't give a predeclared output for
89- # the file in "out" so we have to construct a
90- # label to reference the go_binary rule itself.
91- src = "//buildifier:%s" % s.replace("_arm64", "-arm64").split("_amd64")[0],
92- out = s,
93- )
94- for s in _PARENT_PACKAGE_FILES
95-]
96-
97-pkg_npm(
98- name = "buildifier",
99- package_name = "@bazel/buildifier",
100- srcs = [
101- "package.json",
102- ],
103- substitutions = {
104- "0.0.0-PLACEHOLDER": "{BUILD_SCM_VERSION}",
105- },
106- deps = [
107- "LICENSE",
108- "buildifier.js",
109- ] + _PARENT_PACKAGE_FILES,
110-)
111-
112-nodejs_test(
113- name = "integration_test",
114- data = [":buildifier"],
115- entry_point = "test.js",
116-)
117diff -urN a/buildifier/npm/package.json b/buildifier/npm/package.json
118--- a/buildifier/npm/package.json 2023-09-25 16:52:51.403439550 +0000
119+++ b/buildifier/npm/package.json 1970-01-01 00:00:00.000000000 +0000
120@@ -1,19 +0,0 @@
121-{
122- "name": "@bazel/buildifier",
123- "description": "A tool for formatting bazel BUILD and .bzl files",
124- "version": "0.0.0-PLACEHOLDER",
125- "license": "Apache-2.0",
126- "bin": {
127- "buildifier": "buildifier.js"
128- },
129- "keywords": [
130- "bazel"
131- ],
132- "repository": {
133- "type": "git",
134- "url": "https://github.com/bazelbuild/buildtools.git"
135- },
136- "bugs": {
137- "url": "https://github.com/bazelbuild/buildtools/issues"
138- }
139-}
140diff -urN a/buildifier/npm/test.js b/buildifier/npm/test.js
141--- a/buildifier/npm/test.js 2023-09-25 16:52:51.403439550 +0000
142+++ b/buildifier/npm/test.js 1970-01-01 00:00:00.000000000 +0000
143@@ -1,12 +0,0 @@
144-const dir = require('path').join(
145- process.env['TEST_SRCDIR'],
146- process.env['BAZEL_WORKSPACE'],
147- 'buildifier/npm/buildifier');
148-process.chdir(dir);
149-const {stdout} = require('child_process').spawnSync(
150- process.argv0,
151- ['./buildifier.js', '--help'],
152- {encoding: 'utf-8'});
153-if (!/usage: buildifier/.test(stdout)) {
154- throw new Error('buildifier --help should include usage: buildifier');
155-}
156diff -urN a/buildozer/npm/BUILD.bazel b/buildozer/npm/BUILD.bazel
157--- a/buildozer/npm/BUILD.bazel 2023-09-25 16:52:51.403439550 +0000
158+++ b/buildozer/npm/BUILD.bazel 1970-01-01 00:00:00.000000000 +0000
159@@ -1,83 +0,0 @@
160-load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
161-load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test", "pkg_npm")
162-load("@buildozer_npm_deps//typescript:index.bzl", "tsc")
163-
164-copy_file(
165- name = "copy_LICENSE",
166- src = "//:LICENSE",
167- out = "LICENSE",
168-)
169-
170-tsc(
171- name = "compile_ts",
172- outs = [
173- "index.d.ts",
174- "index.js",
175- ],
176- args = [
177- "$(execpath index.ts)",
178- "--outDir $(RULEDIR)",
179- "--target es2015",
180- "--module commonjs",
181- "--declaration",
182- ],
183- data = [
184- "index.ts",
185- "@buildozer_npm_deps//@types/node",
186- ],
187-)
188-
189-genrule(
190- name = "buildozer_launcher",
191- srcs = ["//:launcher.js"],
192- outs = ["buildozer.js"],
193- cmd = "sed s/_TOOL_/buildozer/ $< > $@",
194-)
195-
196-# npm rules live in this subdirectory to avoid a load() statement
197-# in the parent package leaking to users. This means we need
198-# to copy the output files so the pkg_npm will find them in the
199-# output directory for this package.
200-_PARENT_PACKAGE_FILES = [
201- "README.md",
202- "buildozer-darwin_amd64",
203- "buildozer-darwin_arm64",
204- "buildozer-linux_amd64",
205- "buildozer-linux_arm64",
206- "buildozer-windows_amd64.exe",
207-]
208-
209-[
210- copy_file(
211- name = "copy_%s" % s,
212- # go_binary doesn't give a predeclared output for
213- # the file in "out" so we have to construct a
214- # label to reference the go_binary rule itself.
215- src = "//buildozer:%s" % s.replace("_arm64", "-arm64").split("_amd64")[0],
216- out = s,
217- )
218- for s in _PARENT_PACKAGE_FILES
219-]
220-
221-pkg_npm(
222- name = "buildozer",
223- package_name = "@bazel/buildozer",
224- srcs = [
225- "package.json",
226- ],
227- substitutions = {
228- "0.0.0-PLACEHOLDER": "{BUILD_SCM_VERSION}",
229- },
230- deps = [
231- "LICENSE",
232- "buildozer.js",
233- "index.d.ts",
234- "index.js",
235- ] + _PARENT_PACKAGE_FILES,
236-)
237-
238-nodejs_test(
239- name = "integration_test",
240- data = [":buildozer"],
241- entry_point = "test.js",
242-)
243diff -urN a/buildozer/npm/.gitignore b/buildozer/npm/.gitignore
244--- a/buildozer/npm/.gitignore 2023-09-25 16:52:51.403439550 +0000
245+++ b/buildozer/npm/.gitignore 1970-01-01 00:00:00.000000000 +0000
246@@ -1 +0,0 @@
247-node_modules
248\ No newline at end of file
249diff -urN a/buildozer/npm/index.ts b/buildozer/npm/index.ts
250--- a/buildozer/npm/index.ts 2023-09-25 16:52:51.403439550 +0000
251+++ b/buildozer/npm/index.ts 1970-01-01 00:00:00.000000000 +0000
252@@ -1,61 +0,0 @@
253-/**
254- * @fileoverview NodeJS binding to run the buildozer command through a convenient API
255- */
256-import {spawnSync} from 'child_process';
257-// Use require() here since the file doesn't exist at design-time;
258-// bazel will copy the /launcher.js in this repo while building the package
259-const {getNativeBinary} = require('./buildozer');
260-
261-/**
262- * Models the data structure of a buildozer command file.
263- * You should group as many commands as possible into one call to `run` for efficiency.
264- * https://github.com/bazelbuild/buildtools/tree/master/buildozer#do-multiple-changes-at-once
265- */
266-export interface CommandBatch {
267- /**
268- * Each entry is a buildozer edit command like 'new cc_library foo' or a print command
269- * @see https://github.com/bazelbuild/buildtools/tree/master/buildozer#edit-commands
270- */
271- commands: string[];
272- /**
273- * Each entry is like a Bazel label
274- * @see https://github.com/bazelbuild/buildtools/tree/master/buildozer#targets
275- */
276- targets: string[];
277-};
278-
279-/**
280- * run buildozer with a list of commands
281- * @see https://github.com/bazelbuild/buildtools/tree/master/buildozer#do-multiple-changes-at-once
282- * @returns The standard out of the buildozer command, split by lines
283- */
284-export function run(...commands: CommandBatch[]): string[] {
285- return runWithOptions(commands, {});
286-}
287-
288-/**
289- * run buildozer with a list of commands
290- * @param commands a list of CommandBatch to pass to buildozer
291- * @param options Options to pass to spawn
292- * @param flags any buildozer flags to pass
293- */
294-export function runWithOptions(commands: CommandBatch[], options: {cwd?: string}, flags: string[] = []): string[] {
295- // From https://github.com/bazelbuild/buildtools/tree/master/buildozer#usage:
296- // Here, label-list is a space-separated list of Bazel labels,
297- // for example //path/to/pkg1:rule1 //path/to/pkg2:rule2.
298- // Buildozer reads commands from FILE (- for stdin
299- // (format: |-separated command line arguments to buildozer, excluding flags))
300- const input = commands.map(c => [...c.commands, c.targets.join(',')].join('|')).join('\n');
301- const {stdout, stderr, status, error} = spawnSync(getNativeBinary(), flags.concat([
302- '-f', '-' /* read commands from stdin */
303- ]), {
304- ...options,
305- input,
306- encoding: 'utf-8',
307- });
308- // https://github.com/bazelbuild/buildtools/tree/master/buildozer#error-code
309- if (status == 0 || status == 3) return stdout.trim().split('\n').filter(l => !!l);
310-
311- console.error(`buildozer exited with status ${status}\n${stderr}`);
312- throw error;
313-}
314diff -urN a/buildozer/npm/package.json b/buildozer/npm/package.json
315--- a/buildozer/npm/package.json 2023-09-25 16:52:51.403439550 +0000
316+++ b/buildozer/npm/package.json 1970-01-01 00:00:00.000000000 +0000
317@@ -1,23 +0,0 @@
318-{
319- "name": "@bazel/buildozer",
320- "description": "A command line tool to rewrite multiple BUILD files using standard commands",
321- "version": "0.0.0-PLACEHOLDER",
322- "license": "Apache-2.0",
323- "bin": {
324- "buildozer": "buildozer.js"
325- },
326- "keywords": [
327- "bazel"
328- ],
329- "repository": {
330- "type": "git",
331- "url": "https://github.com/bazelbuild/buildtools.git"
332- },
333- "bugs": {
334- "url": "https://github.com/bazelbuild/buildtools/issues"
335- },
336- "devDependencies": {
337- "@types/node": "^13.9.0",
338- "typescript": "^3.8.3"
339- }
340-}
341diff -urN a/buildozer/npm/package-lock.json b/buildozer/npm/package-lock.json
342--- a/buildozer/npm/package-lock.json 2023-09-25 16:52:51.403439550 +0000
343+++ b/buildozer/npm/package-lock.json 1970-01-01 00:00:00.000000000 +0000
344@@ -1,20 +0,0 @@
345-{
346- "name": "@bazel/buildozer",
347- "version": "0.0.0-PLACEHOLDER",
348- "lockfileVersion": 1,
349- "requires": true,
350- "dependencies": {
351- "@types/node": {
352- "version": "13.9.0",
353- "resolved": "https://registry.npmjs.org/@types/node/-/node-13.9.0.tgz",
354- "integrity": "sha512-0ARSQootUG1RljH2HncpsY2TJBfGQIKOOi7kxzUY6z54ePu/ZD+wJA8zI2Q6v8rol2qpG/rvqsReco8zNMPvhQ==",
355- "dev": true
356- },
357- "typescript": {
358- "version": "3.8.3",
359- "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz",
360- "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==",
361- "dev": true
362- }
363- }
364-}
365diff -urN a/buildozer/npm/test.js b/buildozer/npm/test.js
366--- a/buildozer/npm/test.js 2023-09-25 16:52:51.403439550 +0000
367+++ b/buildozer/npm/test.js 1970-01-01 00:00:00.000000000 +0000
368@@ -1,23 +0,0 @@
369-const dir = require('path').join(
370- process.env['TEST_SRCDIR'],
371- process.env['BAZEL_WORKSPACE'],
372- 'buildozer/npm/buildozer');
373-process.chdir(dir);
374-const {stderr} = require('child_process').spawnSync(
375- process.argv0,
376- ['./buildozer.js', '--help'],
377- {encoding: 'utf-8'});
378-if (!/Usage of .*buildozer/.test(stderr)) {
379- throw new Error('buildozer --help should include usage: buildifier');
380-}
381-
382-process.chdir(process.env['TEST_TMPDIR']);
383-const buildozer = require(dir);
384-const fs = require('fs');
385-fs.mkdirSync('foo');
386-fs.writeFileSync('foo/BUILD', '');
387-buildozer.run({commands: ['new_load //:some.bzl some_rule'], targets: ['//foo:__pkg__']});
388-const content = fs.readFileSync('foo/BUILD', 'utf-8');
389-if (!content.includes('load("//:some.bzl", "some_rule")')) {
390- throw new Error('buildozer generated file should include load statement');
391-}
392diff -urN a/WORKSPACE b/WORKSPACE
393--- a/WORKSPACE 2023-09-25 16:52:51.395439671 +0000
394+++ b/WORKSPACE 1970-01-01 00:00:00.000000000 +0000
395@@ -1,95 +0,0 @@
396-workspace(name = "com_github_bazelbuild_buildtools")
397-
398-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
399-
400-http_archive(
401- name = "io_bazel_rules_go",
402- sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996",
403- urls = [
404- "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip",
405- "https://github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip",
406- ],
407-)
408-
409-load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
410-
411-go_rules_dependencies()
412-
413-go_register_toolchains(version = "1.20.3")
414-
415-http_archive(
416- name = "bazel_gazelle",
417- sha256 = "727f3e4edd96ea20c29e8c2ca9e8d2af724d8c7778e7923a854b2c80952bc405",
418- urls = [
419- "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz",
420- "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz",
421- ],
422-)
423-
424-load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
425-
426-gazelle_dependencies()
427-
428-go_repository(
429- name = "skylark_syntax",
430- importpath = "go.starlark.net",
431- sum = "h1:Qoe+9POtDT51UBQ8XEnS9QKeHDQzEl2QRh3eok9R4aw=",
432- version = "v0.0.0-20200203144150-6677ee5c7211",
433-)
434-
435-http_archive(
436- name = "com_google_protobuf",
437- sha256 = "9b4ee22c250fe31b16f1a24d61467e40780a3fbb9b91c3b65be2a376ed913a1a",
438- strip_prefix = "protobuf-3.13.0",
439- urls = [
440- "https://github.com/protocolbuffers/protobuf/archive/v3.13.0.tar.gz",
441- ],
442-)
443-
444-go_repository(
445- name = "com_github_google_go_cmp",
446- importpath = "github.com/google/go-cmp",
447- tag = "v0.5.9",
448-)
449-
450-load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
451-
452-protobuf_deps()
453-
454-http_archive(
455- name = "rules_proto",
456- sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da",
457- strip_prefix = "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488",
458- urls = [
459- "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
460- "https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
461- ],
462-)
463-
464-load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
465-
466-rules_proto_dependencies()
467-
468-rules_proto_toolchains()
469-
470-load("@com_github_bazelbuild_buildtools//buildifier:deps.bzl", "buildifier_dependencies")
471-
472-buildifier_dependencies()
473-
474-# We don't use any nodejs but this includes a rule for publishing releases to npm
475-http_archive(
476- name = "build_bazel_rules_nodejs",
477- sha256 = "8a7c981217239085f78acc9898a1f7ba99af887c1996ceb3b4504655383a2c3c",
478- urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.0.0/rules_nodejs-4.0.0.tar.gz"],
479-)
480-
481-load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "npm_install")
482-
483-node_repositories(node_version = "16.7.0")
484-
485-# Fetch third-party dependencies for building npm packages
486-npm_install(
487- name = "buildozer_npm_deps",
488- package_json = "//buildozer/npm:package.json",
489- package_lock_json = "//buildozer/npm:package-lock.json",
490-)
View as plain text