@nx/gradle 22.5.3 → 22.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,218 @@
1
+ (function (window, document) {
2
+ "use strict";
3
+
4
+ function changeElementClass(element, classValue) {
5
+ if (element.getAttribute("className")) {
6
+ element.setAttribute("className", classValue);
7
+ } else {
8
+ element.setAttribute("class", classValue);
9
+ }
10
+ }
11
+
12
+ function getClassAttribute(element) {
13
+ if (element.getAttribute("className")) {
14
+ return element.getAttribute("className");
15
+ } else {
16
+ return element.getAttribute("class");
17
+ }
18
+ }
19
+
20
+ function addClass(element, classValue) {
21
+ changeElementClass(element, getClassAttribute(element) + " " + classValue);
22
+ }
23
+
24
+ function removeClass(element, classValue) {
25
+ changeElementClass(element, getClassAttribute(element).replace(classValue, ""));
26
+ }
27
+
28
+ function getCheckBox() {
29
+ return document.getElementById("line-wrapping-toggle");
30
+ }
31
+
32
+ function getLabelForCheckBox() {
33
+ return document.getElementById("label-for-line-wrapping-toggle");
34
+ }
35
+
36
+ function findCodeBlocks() {
37
+ const codeBlocks = [];
38
+ const tabContainers = getTabContainers();
39
+ for (let i = 0; i < tabContainers.length; i++) {
40
+ const spans = tabContainers[i].getElementsByTagName("span");
41
+ for (let i = 0; i < spans.length; ++i) {
42
+ if (spans[i].className.indexOf("code") >= 0) {
43
+ codeBlocks.push(spans[i]);
44
+ }
45
+ }
46
+ }
47
+ return codeBlocks;
48
+ }
49
+
50
+ function forAllCodeBlocks(operation) {
51
+ const codeBlocks = findCodeBlocks();
52
+
53
+ for (let i = 0; i < codeBlocks.length; ++i) {
54
+ operation(codeBlocks[i], "wrapped");
55
+ }
56
+ }
57
+
58
+ function toggleLineWrapping() {
59
+ const checkBox = getCheckBox();
60
+
61
+ if (checkBox.checked) {
62
+ forAllCodeBlocks(addClass);
63
+ } else {
64
+ forAllCodeBlocks(removeClass);
65
+ }
66
+ }
67
+
68
+ function initControls() {
69
+ if (findCodeBlocks().length > 0) {
70
+ const checkBox = getCheckBox();
71
+ const label = getLabelForCheckBox();
72
+
73
+ checkBox.onclick = toggleLineWrapping;
74
+ checkBox.checked = false;
75
+
76
+ removeClass(label, "hidden");
77
+ }
78
+ }
79
+
80
+ class TabManager {
81
+ baseId;
82
+ tabs;
83
+ titles;
84
+ headers;
85
+
86
+ constructor(baseId, tabs, titles, headers) {
87
+ this.baseId = baseId;
88
+ this.tabs = tabs;
89
+ this.titles = titles;
90
+ this.headers = headers;
91
+ }
92
+
93
+ select(i) {
94
+ this.deselectAll();
95
+
96
+ changeElementClass(this.tabs[i], "tab selected");
97
+ changeElementClass(this.headers[i], "selected");
98
+
99
+ while (this.headers[i].firstChild) {
100
+ this.headers[i].removeChild(this.headers[i].firstChild);
101
+ }
102
+
103
+ const a = document.createElement("a");
104
+
105
+ a.appendChild(document.createTextNode(this.titles[i]));
106
+ this.headers[i].appendChild(a);
107
+ }
108
+
109
+ deselectAll() {
110
+ for (let i = 0; i < this.tabs.length; i++) {
111
+ changeElementClass(this.tabs[i], "tab deselected");
112
+ changeElementClass(this.headers[i], "deselected");
113
+
114
+ while (this.headers[i].firstChild) {
115
+ this.headers[i].removeChild(this.headers[i].firstChild);
116
+ }
117
+
118
+ const a = document.createElement("a");
119
+
120
+ const id = this.baseId + "-tab" + i;
121
+ a.setAttribute("id", id);
122
+ a.setAttribute("href", "#tab" + i);
123
+ a.onclick = () => {
124
+ this.select(i);
125
+ return false;
126
+ };
127
+ a.appendChild(document.createTextNode(this.titles[i]));
128
+
129
+ this.headers[i].appendChild(a);
130
+ }
131
+ }
132
+ }
133
+
134
+ function getTabContainers() {
135
+ const tabContainers = Array.from(document.getElementsByClassName("tab-container"));
136
+
137
+ // Used by existing TabbedPageRenderer users, which have not adjusted to use TabsRenderer yet.
138
+ const legacyContainer = document.getElementById("tabs");
139
+ if (legacyContainer) {
140
+ tabContainers.push(legacyContainer);
141
+ }
142
+
143
+ return tabContainers;
144
+ }
145
+
146
+ function initTabs() {
147
+ let tabGroups = 0;
148
+
149
+ function createTab(num, container) {
150
+ const tabElems = findTabs(container);
151
+ const tabManager = new TabManager("tabs" + num, tabElems, findTitles(tabElems), findHeaders(container));
152
+ tabManager.select(0);
153
+ }
154
+
155
+ const tabContainers = getTabContainers();
156
+
157
+ for (let i = 0; i < tabContainers.length; i++) {
158
+ createTab(tabGroups, tabContainers[i]);
159
+ tabGroups++;
160
+ }
161
+
162
+ return true;
163
+ }
164
+
165
+ function findTabs(container) {
166
+ return findChildElements(container, "DIV", "tab");
167
+ }
168
+
169
+ function findHeaders(container) {
170
+ const owner = findChildElements(container, "UL", "tabLinks");
171
+ return findChildElements(owner[0], "LI", null);
172
+ }
173
+
174
+ function findTitles(tabs) {
175
+ const titles = [];
176
+
177
+ for (let i = 0; i < tabs.length; i++) {
178
+ const tab = tabs[i];
179
+ const header = findChildElements(tab, "H2", null)[0];
180
+
181
+ header.parentNode.removeChild(header);
182
+
183
+ if (header.innerText) {
184
+ titles.push(header.innerText);
185
+ } else {
186
+ titles.push(header.textContent);
187
+ }
188
+ }
189
+
190
+ return titles;
191
+ }
192
+
193
+ function findChildElements(container, name, targetClass) {
194
+ const elements = [];
195
+ const children = container.childNodes;
196
+
197
+ for (let i = 0; i < children.length; i++) {
198
+ const child = children.item(i);
199
+
200
+ if (child.nodeType === 1 && child.nodeName === name) {
201
+ if (targetClass && child.className.indexOf(targetClass) < 0) {
202
+ continue;
203
+ }
204
+
205
+ elements.push(child);
206
+ }
207
+ }
208
+
209
+ return elements;
210
+ }
211
+
212
+ // Entry point.
213
+
214
+ window.onload = function() {
215
+ initTabs();
216
+ initControls();
217
+ };
218
+ } (window, window.document));
@@ -1 +1 @@
1
- {"version":3,"file":"gradle-batch.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/executors/gradle/gradle-batch.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,uBAAuB,EACvB,SAAS,EAEV,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,kBAAkB,EACnB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAkBhD,eAAO,MAAM,eAAe,QAG3B,CAAC;AAEF,wBAA8B,WAAW,CACvC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAC5C,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,YAAY,CAAC,CAkEvB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAC5C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC;;;;EAiE/C"}
1
+ {"version":3,"file":"gradle-batch.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/executors/gradle/gradle-batch.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,uBAAuB,EACvB,SAAS,EAEV,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,kBAAkB,EACnB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAchD,eAAO,MAAM,eAAe,QAG3B,CAAC;AAEF,wBAA8B,WAAW,CACvC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAC5C,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,YAAY,CAAC,CAkEvB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAC5C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC;;;;EAiE/C"}
@@ -8,7 +8,6 @@ const run_commands_impl_1 = require("nx/src/executors/run-commands/run-commands.
8
8
  const exec_gradle_1 = require("../../utils/exec-gradle");
9
9
  const path_1 = require("path");
10
10
  const child_process_1 = require("child_process");
11
- const pseudo_terminal_1 = require("nx/src/tasks-runner/pseudo-terminal");
12
11
  const get_exclude_task_1 = require("./get-exclude-task");
13
12
  exports.batchRunnerPath = (0, path_1.join)(__dirname, '../../../batch-runner/build/libs/gradle-batch-runner-all.jar');
14
13
  async function gradleBatch(taskGraph, inputs, overrides, context) {
@@ -112,38 +111,20 @@ function getGradlewTasksToRun(taskIds, taskGraph, inputs, nodes) {
112
111
  }
113
112
  async function runTasksInBatch(gradlewTasksToRun, excludeTasks, excludeTestTasks, args, root) {
114
113
  const gradlewBatchStart = performance.mark(`gradlew-batch:start`);
115
- const usePseudoTerminal = process.env.NX_NATIVE_COMMAND_RUNNER !== 'false' &&
116
- pseudo_terminal_1.PseudoTerminal.isSupported();
117
114
  const debugOptions = ' ' + (process.env.NX_GRADLE_BATCH_DEBUG ?? '');
118
115
  const command = `java${debugOptions} -jar ${exports.batchRunnerPath} --tasks='${JSON.stringify(gradlewTasksToRun)}' --workspaceRoot=${root} --args='${args
119
116
  .join(' ')
120
117
  .replaceAll("'", '"')}' --excludeTasks='${Array.from(excludeTasks).join(',')}' --excludeTestTasks='${Array.from(excludeTestTasks).join(',')}' ${process.env.NX_VERBOSE_LOGGING === 'true' ? '' : '--quiet'}`;
121
- let batchResults;
122
- if (usePseudoTerminal && process.env.NX_VERBOSE_LOGGING !== 'true') {
123
- const terminal = (0, pseudo_terminal_1.createPseudoTerminal)();
124
- await terminal.init();
125
- const cp = terminal.runCommand(command, {
126
- cwd: devkit_1.workspaceRoot,
127
- jsEnv: process.env,
128
- quiet: true,
129
- });
130
- const results = await cp.getResults();
131
- terminal.shutdown(0);
132
- batchResults = results.terminalOutput;
133
- batchResults = batchResults.replace(command, '');
134
- const startIndex = batchResults.indexOf('{');
135
- const endIndex = batchResults.lastIndexOf('}');
136
- // only keep the json part
137
- batchResults = batchResults.substring(startIndex, endIndex + 1);
138
- }
139
- else {
140
- batchResults = (0, child_process_1.execSync)(command, {
141
- cwd: devkit_1.workspaceRoot,
142
- windowsHide: true,
143
- env: process.env,
144
- maxBuffer: run_commands_impl_1.LARGE_BUFFER,
145
- }).toString();
146
- }
118
+ // Use 'inherit' for stderr so Gradle output (tee'd to System.err
119
+ // by TeeOutputStream) flows to the terminal in real-time.
120
+ // stdout is piped to capture the JSON batch results.
121
+ const batchResults = (0, child_process_1.execSync)(command, {
122
+ cwd: devkit_1.workspaceRoot,
123
+ windowsHide: true,
124
+ env: process.env,
125
+ stdio: ['pipe', 'pipe', 'inherit'],
126
+ maxBuffer: run_commands_impl_1.LARGE_BUFFER,
127
+ }).toString();
147
128
  const gradlewBatchEnd = performance.mark(`gradlew-batch:end`);
148
129
  performance.measure(`gradlew-batch`, gradlewBatchStart.name, gradlewBatchEnd.name);
149
130
  const gradlewBatchResults = JSON.parse(batchResults);