@brunoluizdesiqueira/bbuilder-cli 1.0.15 → 1.0.17
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/dist/build/compiler.js +5 -0
- package/dist/build/execute.js +6 -5
- package/dist/cli/program.js +1 -1
- package/dist/ui/output.js +12 -121
- package/dist/ui/prompts.js +1 -1
- package/package.json +2 -1
package/dist/build/compiler.js
CHANGED
|
@@ -37,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.buildCompilerFlags = buildCompilerFlags;
|
|
40
|
+
exports.ensureDelphiEnvironment = ensureDelphiEnvironment;
|
|
40
41
|
exports.runCgrc = runCgrc;
|
|
41
42
|
exports.runDcc64 = runDcc64;
|
|
42
43
|
exports.runBuiltExecutable = runBuiltExecutable;
|
|
@@ -103,6 +104,7 @@ async function getDelphiEnvironment(delphiDir) {
|
|
|
103
104
|
const command = `call "${rsvarsPath}" >nul && set`;
|
|
104
105
|
const result = await (0, execa_1.default)('cmd.exe', ['/d', '/c', command], {
|
|
105
106
|
env: process.env,
|
|
107
|
+
windowsVerbatimArguments: true,
|
|
106
108
|
});
|
|
107
109
|
const resolved = {
|
|
108
110
|
...process.env,
|
|
@@ -116,6 +118,9 @@ async function getDelphiEnvironment(delphiDir) {
|
|
|
116
118
|
(0, output_1.fatal)(`Falha ao carregar o ambiente do Delphi via rsvars.bat (${rsvarsPath}). Detalhe: ${message}`);
|
|
117
119
|
}
|
|
118
120
|
}
|
|
121
|
+
async function ensureDelphiEnvironment(delphiDir) {
|
|
122
|
+
await getDelphiEnvironment(delphiDir);
|
|
123
|
+
}
|
|
119
124
|
async function runCgrc(opts, projectName) {
|
|
120
125
|
const tempDir = path.join(os.tmpdir(), `BimerBuild_${projectName}`);
|
|
121
126
|
const vrcFile = path.join(tempDir, `${projectName}.vrc`);
|
package/dist/build/execute.js
CHANGED
|
@@ -41,21 +41,22 @@ 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 =
|
|
44
|
+
const totalStages = 5;
|
|
45
45
|
(0, output_1.banner)();
|
|
46
46
|
const { workspaceDir, projectName } = (0, project_1.resolveProject)(opts.project, opts.repoBase);
|
|
47
47
|
(0, output_1.printBuildHeader)(opts, projectName, workspaceDir);
|
|
48
|
-
await (0, output_1.
|
|
48
|
+
await (0, output_1.withStep)(1, totalStages, 'Carregando ambiente do Delphi', () => (0, compiler_1.ensureDelphiEnvironment)(opts.delphiDir));
|
|
49
|
+
await (0, output_1.withStep)(2, totalStages, 'Preparando versao, manifesto e recursos', () => {
|
|
49
50
|
(0, resources_1.prepareProjectResources)(opts, projectName, workspaceDir);
|
|
50
51
|
});
|
|
51
52
|
const oldRes = path.win32.join(workspaceDir, `${projectName}.res`);
|
|
52
53
|
if (fs.existsSync(oldRes))
|
|
53
54
|
fs.unlinkSync(oldRes);
|
|
54
|
-
const resFile = await (0, output_1.
|
|
55
|
-
await (0, output_1.
|
|
55
|
+
const resFile = await (0, output_1.withStep)(3, totalStages, 'Compilando recursos nativos', () => (0, compiler_1.runCgrc)(opts, projectName));
|
|
56
|
+
await (0, output_1.withStep)(4, totalStages, 'Sincronizando recurso final no projeto', () => {
|
|
56
57
|
fs.copyFileSync(resFile, path.win32.join(workspaceDir, `${projectName}.res`));
|
|
57
58
|
});
|
|
58
|
-
await (0, output_1.
|
|
59
|
+
await (0, output_1.withStep)(5, totalStages, `Compilando projeto Delphi (${opts.type})`, () => (0, compiler_1.runDcc64)(opts, projectName, workspaceDir));
|
|
59
60
|
(0, output_1.printSuccess)(opts.type);
|
|
60
61
|
const { runAfter } = (0, compiler_1.buildCompilerFlags)(opts.type);
|
|
61
62
|
if (runAfter) {
|
package/dist/cli/program.js
CHANGED
|
@@ -98,7 +98,7 @@ async function runCli(argv) {
|
|
|
98
98
|
.description('Compila um projeto Delphi (interativo se flags omitidas)')
|
|
99
99
|
.option('-t, --type <FAST|DEBUG|RELEASE>', 'Modo de build')
|
|
100
100
|
.option('-p, --project <path>', 'Caminho do projeto (ex: faturamento\\BimerFaturamento)')
|
|
101
|
-
.option('-v, --version <version>', 'Versão a injetar (ex: 11.
|
|
101
|
+
.option('-v, --version <version>', 'Versão a injetar (ex: 11.3.0)'), HELP_EXAMPLES.build)
|
|
102
102
|
.action(async (opts) => {
|
|
103
103
|
const buildType = opts.type?.toUpperCase();
|
|
104
104
|
if (buildType && !['FAST', 'DEBUG', 'RELEASE'].includes(buildType)) {
|
package/dist/ui/output.js
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
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
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
@@ -40,13 +7,11 @@ exports.banner = banner;
|
|
|
40
7
|
exports.printBuildHeader = printBuildHeader;
|
|
41
8
|
exports.printSuccess = printSuccess;
|
|
42
9
|
exports.step = step;
|
|
10
|
+
exports.formatElapsedMs = formatElapsedMs;
|
|
11
|
+
exports.withStep = withStep;
|
|
43
12
|
exports.withProgress = withProgress;
|
|
44
13
|
exports.fatal = fatal;
|
|
45
14
|
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;
|
|
50
15
|
function banner() {
|
|
51
16
|
console.log('');
|
|
52
17
|
console.log(chalk_1.default.blue(' ══════════════════════════════════════════════════════════════'));
|
|
@@ -95,105 +60,31 @@ function printSuccess(buildType) {
|
|
|
95
60
|
function step(msg) {
|
|
96
61
|
console.log(chalk_1.default.cyan(' [*]') + ' ' + chalk_1.default.white(msg));
|
|
97
62
|
}
|
|
98
|
-
function
|
|
99
|
-
const totalSeconds = Math.max(0, Math.floor(
|
|
63
|
+
function formatElapsedMs(elapsedMs) {
|
|
64
|
+
const totalSeconds = Math.max(0, Math.floor(elapsedMs / 1000));
|
|
100
65
|
const minutes = Math.floor(totalSeconds / 60)
|
|
101
66
|
.toString()
|
|
102
67
|
.padStart(2, '0');
|
|
103
68
|
const seconds = (totalSeconds % 60).toString().padStart(2, '0');
|
|
104
69
|
return `${minutes}:${seconds}`;
|
|
105
70
|
}
|
|
106
|
-
function
|
|
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, options) {
|
|
71
|
+
async function withStep(stage, total, label, task, options) {
|
|
146
72
|
const startTime = Date.now();
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
step(`[${stage}/${total}] ${label}`);
|
|
150
|
-
const result = await task();
|
|
151
|
-
console.log(` ${chalk_1.default.green('OK')} ${chalk_1.default.white(label)} ${chalk_1.default.gray(`(${formatElapsed(startTime)})`)}`);
|
|
152
|
-
return result;
|
|
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
|
-
}
|
|
166
|
-
let frameIndex = 0;
|
|
167
|
-
let rendered = false;
|
|
168
|
-
let timer;
|
|
169
|
-
const render = () => {
|
|
170
|
-
clearProgressLine();
|
|
171
|
-
drawProgressLine(renderProgressLine(stage, total, label, startTime, frameIndex));
|
|
172
|
-
rendered = true;
|
|
173
|
-
};
|
|
174
|
-
render();
|
|
175
|
-
timer = setInterval(() => {
|
|
176
|
-
frameIndex += 1;
|
|
177
|
-
render();
|
|
178
|
-
}, 120);
|
|
73
|
+
const prefix = `[${stage}/${total}] ${label}`;
|
|
74
|
+
step(prefix);
|
|
179
75
|
try {
|
|
180
76
|
const result = await task();
|
|
181
|
-
|
|
182
|
-
clearInterval(timer);
|
|
183
|
-
if (rendered)
|
|
184
|
-
clearProgressLine();
|
|
185
|
-
console.log(` ${chalk_1.default.green('OK')} ${chalk_1.default.white(label)} ${chalk_1.default.gray(`(${formatElapsed(startTime)})`)}`);
|
|
77
|
+
console.log(` ${chalk_1.default.green('OK')} ${chalk_1.default.white(label)} ${chalk_1.default.gray(`(${formatElapsedMs(Date.now() - startTime)})`)}`);
|
|
186
78
|
return result;
|
|
187
79
|
}
|
|
188
80
|
catch (error) {
|
|
189
|
-
|
|
190
|
-
clearInterval(timer);
|
|
191
|
-
if (rendered)
|
|
192
|
-
clearProgressLine();
|
|
193
|
-
console.log(` ${chalk_1.default.red('FAIL')} ${chalk_1.default.white(label)} ${chalk_1.default.gray(`(${formatElapsed(startTime)})`)}`);
|
|
81
|
+
console.log(` ${chalk_1.default.red('FAIL')} ${chalk_1.default.white(label)} ${chalk_1.default.gray(`(${formatElapsedMs(Date.now() - startTime)})`)}`);
|
|
194
82
|
throw error;
|
|
195
83
|
}
|
|
196
84
|
}
|
|
85
|
+
async function withProgress(stage, total, label, task, options) {
|
|
86
|
+
return withStep(stage, total, label, task, options);
|
|
87
|
+
}
|
|
197
88
|
function fatal(msg) {
|
|
198
89
|
console.error('');
|
|
199
90
|
console.error(chalk_1.default.red(' [ERRO FATAL] ') + msg);
|
package/dist/ui/prompts.js
CHANGED
|
@@ -43,7 +43,7 @@ async function promptBuild(config, cliType, cliProject, cliVersion) {
|
|
|
43
43
|
type: 'input',
|
|
44
44
|
name: 'version',
|
|
45
45
|
message: 'Versão do EXE? (deixe em branco para manter atual):',
|
|
46
|
-
default: '',
|
|
46
|
+
default: '11.3.0',
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
const answers = await inquirer_1.default.prompt(questions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brunoluizdesiqueira/bbuilder-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "CLI de build local para projetos Delphi do Bimer",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsc",
|
|
35
35
|
"dev": "ts-node src/index.ts",
|
|
36
|
+
"test": "npm run build && node --test test/**/*.test.js",
|
|
36
37
|
"prepack": "npm run build",
|
|
37
38
|
"changeset": "changeset",
|
|
38
39
|
"version-packages": "changeset version",
|