@brunoluizdesiqueira/bbuilder-cli 1.0.10 → 1.0.12
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.
- package/README.md +2 -0
- package/dist/build/compiler.js +0 -2
- package/dist/build/execute.js +9 -4
- package/dist/build/resources.js +0 -6
- package/dist/ui/output.js +113 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -162,6 +162,8 @@ bbuilder build --type FAST --project faturamento\BimerFaturamento
|
|
|
162
162
|
bbuilder build --type RELEASE --project Bimer --version 11.3.1
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
+
Durante o build, o CLI exibe feedback visual por etapas com spinner, barra indeterminada e tempo decorrido. Essa barra representa atividade do pipeline, não percentual real do `dcc64`.
|
|
166
|
+
|
|
165
167
|
### Atalhos diretos por modo
|
|
166
168
|
```bash
|
|
167
169
|
bbuilder fast # interativo para projeto/versão
|
package/dist/build/compiler.js
CHANGED
|
@@ -122,7 +122,6 @@ async function runCgrc(opts, projectName) {
|
|
|
122
122
|
const vrcFile = path.join(tempDir, `${projectName}.vrc`);
|
|
123
123
|
const resFile = path.join(tempDir, `${projectName}.res`);
|
|
124
124
|
const delphiEnv = await getDelphiEnvironment(opts.delphiDir);
|
|
125
|
-
(0, output_1.step)('Compilando recursos e embutindo ícone...');
|
|
126
125
|
try {
|
|
127
126
|
await (0, execa_1.default)(path.win32.join(opts.delphiDir, 'bin', 'cgrc.exe'), [vrcFile, `-fo${resFile}`], {
|
|
128
127
|
env: delphiEnv,
|
|
@@ -144,7 +143,6 @@ async function runDcc64(opts, projectName, workspaceDir) {
|
|
|
144
143
|
fs.mkdirSync(exeOut, { recursive: true });
|
|
145
144
|
if (!fs.existsSync(dcuOut))
|
|
146
145
|
fs.mkdirSync(dcuOut, { recursive: true });
|
|
147
|
-
(0, output_1.step)(`Iniciando compilação do código fonte (${opts.type})...`);
|
|
148
146
|
const nsValue = 'Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;FireDAC.VCLUI;System.Win;';
|
|
149
147
|
const aliasValue = 'Generics.Collections=System.Generics.Collections;Generics.Defaults=System.Generics.Defaults;WinTypes=Winapi.Windows;WinProcs=Winapi.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE';
|
|
150
148
|
const dcc64 = path.win32.join(opts.delphiDir, 'bin', 'dcc64.exe');
|
package/dist/build/execute.js
CHANGED
|
@@ -41,16 +41,21 @@ const compiler_1 = require("./compiler");
|
|
|
41
41
|
const project_1 = require("./project");
|
|
42
42
|
const resources_1 = require("./resources");
|
|
43
43
|
async function executeBuild(opts) {
|
|
44
|
+
const totalStages = 4;
|
|
44
45
|
(0, output_1.banner)();
|
|
45
46
|
const { workspaceDir, projectName } = (0, project_1.resolveProject)(opts.project, opts.repoBase);
|
|
46
47
|
(0, output_1.printBuildHeader)(opts, projectName, workspaceDir);
|
|
47
|
-
(0,
|
|
48
|
+
await (0, output_1.withProgress)(1, totalStages, 'Preparando versao, manifesto e recursos', () => {
|
|
49
|
+
(0, resources_1.prepareProjectResources)(opts, projectName, workspaceDir);
|
|
50
|
+
});
|
|
48
51
|
const oldRes = path.win32.join(workspaceDir, `${projectName}.res`);
|
|
49
52
|
if (fs.existsSync(oldRes))
|
|
50
53
|
fs.unlinkSync(oldRes);
|
|
51
|
-
const resFile = await (0, compiler_1.runCgrc)(opts, projectName);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
const resFile = await (0, output_1.withProgress)(2, totalStages, 'Compilando recursos nativos', () => (0, compiler_1.runCgrc)(opts, projectName));
|
|
55
|
+
await (0, output_1.withProgress)(3, totalStages, 'Sincronizando recurso final no projeto', () => {
|
|
56
|
+
fs.copyFileSync(resFile, path.win32.join(workspaceDir, `${projectName}.res`));
|
|
57
|
+
});
|
|
58
|
+
await (0, output_1.withProgress)(4, totalStages, `Compilando projeto Delphi (${opts.type})`, () => (0, compiler_1.runDcc64)(opts, projectName, workspaceDir));
|
|
54
59
|
(0, output_1.printSuccess)(opts.type);
|
|
55
60
|
const { runAfter } = (0, compiler_1.buildCompilerFlags)(opts.type);
|
|
56
61
|
if (runAfter) {
|
package/dist/build/resources.js
CHANGED
|
@@ -151,12 +151,6 @@ function prepareProjectResources(opts, projectName, workspaceDir) {
|
|
|
151
151
|
if (!fs.existsSync(dproj)) {
|
|
152
152
|
(0, output_1.fatal)(`Arquivo de projeto não encontrado: ${dproj}`);
|
|
153
153
|
}
|
|
154
|
-
if (opts.version) {
|
|
155
|
-
(0, output_1.step)(`Injetando versão ${opts.version} no projeto...`);
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
(0, output_1.step)('Nenhuma versão informada. Lendo atual do projeto...');
|
|
159
|
-
}
|
|
160
154
|
try {
|
|
161
155
|
const projectContent = fs.readFileSync(dproj, 'utf-8');
|
|
162
156
|
const { content: updatedContent, fullVersion, parts } = resolveVersionInfo(projectContent, opts.version);
|
package/dist/ui/output.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -7,8 +40,13 @@ exports.banner = banner;
|
|
|
7
40
|
exports.printBuildHeader = printBuildHeader;
|
|
8
41
|
exports.printSuccess = printSuccess;
|
|
9
42
|
exports.step = step;
|
|
43
|
+
exports.withProgress = withProgress;
|
|
10
44
|
exports.fatal = fatal;
|
|
11
45
|
const chalk_1 = __importDefault(require("chalk"));
|
|
46
|
+
const readline = __importStar(require("readline"));
|
|
47
|
+
const SPINNER_FRAMES = ['|', '/', '-', '\\'];
|
|
48
|
+
const BAR_WIDTH = 18;
|
|
49
|
+
const BAR_SEGMENT = 6;
|
|
12
50
|
function banner() {
|
|
13
51
|
console.log('');
|
|
14
52
|
console.log(chalk_1.default.blue(' ══════════════════════════════════════════════════════════════'));
|
|
@@ -57,6 +95,81 @@ function printSuccess(buildType) {
|
|
|
57
95
|
function step(msg) {
|
|
58
96
|
console.log(chalk_1.default.cyan(' [*]') + ' ' + chalk_1.default.white(msg));
|
|
59
97
|
}
|
|
98
|
+
function formatElapsed(startTime) {
|
|
99
|
+
const totalSeconds = Math.max(0, Math.floor((Date.now() - startTime) / 1000));
|
|
100
|
+
const minutes = Math.floor(totalSeconds / 60)
|
|
101
|
+
.toString()
|
|
102
|
+
.padStart(2, '0');
|
|
103
|
+
const seconds = (totalSeconds % 60).toString().padStart(2, '0');
|
|
104
|
+
return `${minutes}:${seconds}`;
|
|
105
|
+
}
|
|
106
|
+
function buildIndeterminateBar(frameIndex) {
|
|
107
|
+
const chars = new Array(BAR_WIDTH).fill('░');
|
|
108
|
+
const start = frameIndex % (BAR_WIDTH + BAR_SEGMENT);
|
|
109
|
+
for (let offset = 0; offset < BAR_SEGMENT; offset++) {
|
|
110
|
+
const position = start - offset;
|
|
111
|
+
if (position >= 0 && position < BAR_WIDTH) {
|
|
112
|
+
chars[position] = '█';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return chars.join('');
|
|
116
|
+
}
|
|
117
|
+
function truncateLabel(label, maxLength) {
|
|
118
|
+
if (maxLength <= 0)
|
|
119
|
+
return '';
|
|
120
|
+
if (label.length <= maxLength)
|
|
121
|
+
return label;
|
|
122
|
+
if (maxLength <= 1)
|
|
123
|
+
return label.slice(0, maxLength);
|
|
124
|
+
return `${label.slice(0, maxLength - 1)}…`;
|
|
125
|
+
}
|
|
126
|
+
function renderProgressLine(stage, total, label, startTime, frameIndex) {
|
|
127
|
+
const spinner = SPINNER_FRAMES[frameIndex % SPINNER_FRAMES.length];
|
|
128
|
+
const bar = buildIndeterminateBar(frameIndex);
|
|
129
|
+
const elapsed = formatElapsed(startTime);
|
|
130
|
+
const columns = process.stdout.columns || 100;
|
|
131
|
+
const reservedLength = 2 + `[${stage}/${total}]`.length + 1 + 1 + 1 + 1 + 1 + (BAR_WIDTH + 2) + 1 + elapsed.length;
|
|
132
|
+
const maxLabelLength = Math.max(12, columns - reservedLength);
|
|
133
|
+
const safeLabel = truncateLabel(label, maxLabelLength);
|
|
134
|
+
return ` ${chalk_1.default.cyan(`[${stage}/${total}]`)} ${chalk_1.default.yellow(spinner)} ${chalk_1.default.white(safeLabel)} ${chalk_1.default.blue(`[${bar}]`)} ${chalk_1.default.gray(elapsed)}`;
|
|
135
|
+
}
|
|
136
|
+
function drawProgressLine(line) {
|
|
137
|
+
readline.clearLine(process.stdout, 0);
|
|
138
|
+
readline.cursorTo(process.stdout, 0);
|
|
139
|
+
process.stdout.write(line);
|
|
140
|
+
}
|
|
141
|
+
function clearProgressLine() {
|
|
142
|
+
readline.clearLine(process.stdout, 0);
|
|
143
|
+
readline.cursorTo(process.stdout, 0);
|
|
144
|
+
}
|
|
145
|
+
async function withProgress(stage, total, label, task) {
|
|
146
|
+
const startTime = Date.now();
|
|
147
|
+
if (!process.stdout.isTTY) {
|
|
148
|
+
step(`[${stage}/${total}] ${label}`);
|
|
149
|
+
const result = await task();
|
|
150
|
+
console.log(` ${chalk_1.default.green('OK')} ${chalk_1.default.white(label)} ${chalk_1.default.gray(`(${formatElapsed(startTime)})`)}`);
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
let frameIndex = 0;
|
|
154
|
+
drawProgressLine(renderProgressLine(stage, total, label, startTime, frameIndex));
|
|
155
|
+
const timer = setInterval(() => {
|
|
156
|
+
frameIndex += 1;
|
|
157
|
+
drawProgressLine(renderProgressLine(stage, total, label, startTime, frameIndex));
|
|
158
|
+
}, 120);
|
|
159
|
+
try {
|
|
160
|
+
const result = await task();
|
|
161
|
+
clearInterval(timer);
|
|
162
|
+
clearProgressLine();
|
|
163
|
+
console.log(` ${chalk_1.default.green('OK')} ${chalk_1.default.white(label)} ${chalk_1.default.gray(`(${formatElapsed(startTime)})`)}`);
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
clearInterval(timer);
|
|
168
|
+
clearProgressLine();
|
|
169
|
+
console.log(` ${chalk_1.default.red('FAIL')} ${chalk_1.default.white(label)} ${chalk_1.default.gray(`(${formatElapsed(startTime)})`)}`);
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
60
173
|
function fatal(msg) {
|
|
61
174
|
console.error('');
|
|
62
175
|
console.error(chalk_1.default.red(' [ERRO FATAL] ') + msg);
|