@brunoluizdesiqueira/bbuilder-cli 1.0.12 → 1.0.13

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.
@@ -55,7 +55,7 @@ async function executeBuild(opts) {
55
55
  await (0, output_1.withProgress)(3, totalStages, 'Sincronizando recurso final no projeto', () => {
56
56
  fs.copyFileSync(resFile, path.win32.join(workspaceDir, `${projectName}.res`));
57
57
  });
58
- await (0, output_1.withProgress)(4, totalStages, `Compilando projeto Delphi (${opts.type})`, () => (0, compiler_1.runDcc64)(opts, projectName, workspaceDir));
58
+ await (0, output_1.withProgress)(4, totalStages, `Compilando projeto Delphi (${opts.type})`, () => (0, compiler_1.runDcc64)(opts, projectName, workspaceDir), { streamingOutput: true });
59
59
  (0, output_1.printSuccess)(opts.type);
60
60
  const { runAfter } = (0, compiler_1.buildCompilerFlags)(opts.type);
61
61
  if (runAfter) {
package/dist/ui/output.js CHANGED
@@ -142,30 +142,63 @@ function clearProgressLine() {
142
142
  readline.clearLine(process.stdout, 0);
143
143
  readline.cursorTo(process.stdout, 0);
144
144
  }
145
- async function withProgress(stage, total, label, task) {
145
+ async function withProgress(stage, total, label, task, options) {
146
146
  const startTime = Date.now();
147
+ const streamingOutput = options?.streamingOutput ?? false;
147
148
  if (!process.stdout.isTTY) {
148
149
  step(`[${stage}/${total}] ${label}`);
149
150
  const result = await task();
150
151
  console.log(` ${chalk_1.default.green('OK')} ${chalk_1.default.white(label)} ${chalk_1.default.gray(`(${formatElapsed(startTime)})`)}`);
151
152
  return result;
152
153
  }
154
+ if (streamingOutput) {
155
+ step(`[${stage}/${total}] ${label}`);
156
+ try {
157
+ const result = await task();
158
+ console.log(` ${chalk_1.default.green('OK')} ${chalk_1.default.white(label)} ${chalk_1.default.gray(`(${formatElapsed(startTime)})`)}`);
159
+ return result;
160
+ }
161
+ catch (error) {
162
+ console.log(` ${chalk_1.default.red('FAIL')} ${chalk_1.default.white(label)} ${chalk_1.default.gray(`(${formatElapsed(startTime)})`)}`);
163
+ throw error;
164
+ }
165
+ }
153
166
  let frameIndex = 0;
154
- drawProgressLine(renderProgressLine(stage, total, label, startTime, frameIndex));
155
- const timer = setInterval(() => {
156
- frameIndex += 1;
167
+ let rendered = false;
168
+ let timer;
169
+ const render = () => {
170
+ clearProgressLine();
157
171
  drawProgressLine(renderProgressLine(stage, total, label, startTime, frameIndex));
158
- }, 120);
172
+ rendered = true;
173
+ };
174
+ const startTimer = () => {
175
+ if (timer)
176
+ return;
177
+ timer = setInterval(() => {
178
+ frameIndex += 1;
179
+ render();
180
+ }, 120);
181
+ };
182
+ const initialDelay = setTimeout(() => {
183
+ render();
184
+ startTimer();
185
+ }, 180);
159
186
  try {
160
187
  const result = await task();
161
- clearInterval(timer);
162
- clearProgressLine();
188
+ clearTimeout(initialDelay);
189
+ if (timer)
190
+ clearInterval(timer);
191
+ if (rendered)
192
+ clearProgressLine();
163
193
  console.log(` ${chalk_1.default.green('OK')} ${chalk_1.default.white(label)} ${chalk_1.default.gray(`(${formatElapsed(startTime)})`)}`);
164
194
  return result;
165
195
  }
166
196
  catch (error) {
167
- clearInterval(timer);
168
- clearProgressLine();
197
+ clearTimeout(initialDelay);
198
+ if (timer)
199
+ clearInterval(timer);
200
+ if (rendered)
201
+ clearProgressLine();
169
202
  console.log(` ${chalk_1.default.red('FAIL')} ${chalk_1.default.white(label)} ${chalk_1.default.gray(`(${formatElapsed(startTime)})`)}`);
170
203
  throw error;
171
204
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brunoluizdesiqueira/bbuilder-cli",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "CLI de build local para projetos Delphi do Bimer",
5
5
  "license": "ISC",
6
6
  "repository": {