@brunoluizdesiqueira/bbuilder-cli 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bruno Siqueira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,211 @@
1
+ # bbuilder-cli
2
+
3
+ CLI em Node.js/TypeScript que substitui o `build_local.bat` com interface interativa e suporte a flags diretas.
4
+
5
+ ---
6
+
7
+ ## Instalação
8
+
9
+ ```bash
10
+ # Desenvolvimento local
11
+ npm install
12
+ npm run build
13
+ npm link # disponibiliza o comando 'delphi' globalmente
14
+ ```
15
+
16
+ ```bash
17
+ # Instalação via npm
18
+ npm install -g @brunoluizdesiqueira/bbuilder-cli
19
+ ```
20
+
21
+ ```bash
22
+ # Publicação
23
+ npm publish --access public
24
+ ```
25
+
26
+ Ou use direto sem instalar globalmente:
27
+ ```bash
28
+ npx ts-node src/index.ts build
29
+ ```
30
+
31
+ ---
32
+
33
+ ## Uso
34
+
35
+ ### Modo interativo (sem argumentos)
36
+ ```bash
37
+ delphi
38
+ ```
39
+ Exibe menus para escolher: modo de build → projeto → versão.
40
+
41
+ ### Comando `build` com flags opcionais
42
+ ```bash
43
+ delphi build # interativo completo
44
+ delphi build --type DEBUG # escolhe projeto e versão interativamente
45
+ delphi build --type FAST --project faturamento\BimerFaturamento
46
+ delphi build --type RELEASE --project Bimer --version 11.3.1
47
+ ```
48
+
49
+ ### Atalhos diretos por modo
50
+ ```bash
51
+ delphi fast # interativo para projeto/versão
52
+ delphi debug --project Bimer
53
+ delphi release --project Bimer --version 11.3.1
54
+ ```
55
+
56
+ ### Gerenciamento de projetos
57
+ ```bash
58
+ delphi project list # lista projetos configurados
59
+ delphi project add # adiciona novo projeto (interativo)
60
+ ```
61
+
62
+ ### Configuração do ambiente
63
+ ```bash
64
+ delphi config init # assistente para criar bbuilder.config.json
65
+ delphi config show # exibe configuração atual
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Configuração (`bbuilder.config.json`)
71
+
72
+ Prioridade de resolução da configuração:
73
+
74
+ 1. `delphi --config <caminho>`
75
+ 2. Variável de ambiente `BBUILDER_CONFIG`
76
+ 3. `bbuilder.config.json` no diretório atual
77
+ 4. `bimer.config.json` no diretório atual, por compatibilidade
78
+ 5. Arquivo global do usuário
79
+
80
+ No Windows, o arquivo global fica em `%APPDATA%\bbuilder-cli\bbuilder.config.json`.
81
+
82
+ Crie com `delphi config init`, ou manualmente:
83
+
84
+ ```json
85
+ {
86
+ "repoBase": "C:\\git\\bimer",
87
+ "delphiDir": "C:\\Program Files (x86)\\Embarcadero\\Studio\\22.0",
88
+ "envVersion": "11.03.00",
89
+ "libRoot": "C:\\LibraryDelphiAlexandria\\Externos\\3.00",
90
+ "libErp": "C:\\LibraryDelphiAlexandria\\ERP\\11.03.00",
91
+ "libAlterdata": "C:\\LibraryDelphiAlexandria\\LibAlterdata\\1.0.0",
92
+ "dependencyPaths": [
93
+ "C:\\git\\bimer\\dependencies",
94
+ "C:\\Program Files (x86)\\Embarcadero\\Studio\\22.0\\lib\\Win64\\release",
95
+ "C:\\LibraryDelphiAlexandria\\Externos\\3.00\\sgcWebSockets\\Win64",
96
+ "C:\\LibraryDelphiAlexandria\\ERP\\11.03.00\\Win64"
97
+ ],
98
+ "projects": {
99
+ "BimerFaturamento": "faturamento\\BimerFaturamento",
100
+ "Bimer": "Bimer",
101
+ "LiberadorEstoque": "geral\\gerenteeletronico.jobs.liberadorestoque\\LiberadorEstoque",
102
+ "BimerEstoque": "estoque\\BimerEstoque"
103
+ }
104
+ }
105
+ ```
106
+
107
+ `dependencyPaths` deve ser ajustado no `bbuilder.config.json`, porque esses caminhos podem variar entre usuários e máquinas.
108
+
109
+ `projects` agora usa o formato `nome amigável: caminho real do projeto`, para a CLI exibir nomes humanizados sem perder a referência correta de compilação.
110
+
111
+ Se o arquivo não existir, os valores padrão acima são usados automaticamente. Ao rodar `delphi config init`, a CLI gera um `dependencyPaths` inicial com base nos diretórios informados.
112
+
113
+ Exemplos:
114
+
115
+ ```bash
116
+ delphi --config C:\configs\bbuilder.config.json build
117
+ ```
118
+
119
+ ```bash
120
+ set BBUILDER_CONFIG=C:\configs\bbuilder.config.json
121
+ delphi config show
122
+ ```
123
+
124
+ ---
125
+
126
+ ## Integração com VSCode (`tasks.json`)
127
+
128
+ Substitua o `tasks.json` atual por este (sem mais menus do VSCode, a CLI cuida de tudo):
129
+
130
+ ```json
131
+ {
132
+ "version": "2.0.0",
133
+ "tasks": [
134
+ {
135
+ "label": "Bimer: FAST + Run",
136
+ "type": "shell",
137
+ "command": "delphi fast",
138
+ "group": "build",
139
+ "presentation": { "reveal": "always", "focus": true, "panel": "dedicated", "clear": true },
140
+ "problemMatcher": {
141
+ "owner": "delphi",
142
+ "fileLocation": ["autoDetect", "${workspaceFolder}"],
143
+ "pattern": {
144
+ "regexp": "^(.*?)\\s*\\((\\d+)\\)(?:\\s+|:\\s*)(Fatal|Error|Warning|Hint|error|fatal):\\s+(.*)$",
145
+ "file": 1, "line": 2, "severity": 3, "message": 4
146
+ }
147
+ }
148
+ },
149
+ {
150
+ "label": "Bimer: DEBUG + Run",
151
+ "type": "shell",
152
+ "command": "delphi debug",
153
+ "group": "build",
154
+ "presentation": { "reveal": "always", "focus": true, "panel": "dedicated", "clear": true },
155
+ "problemMatcher": {
156
+ "owner": "delphi",
157
+ "fileLocation": ["autoDetect", "${workspaceFolder}"],
158
+ "pattern": {
159
+ "regexp": "^(.*?)\\s*\\((\\d+)\\)(?:\\s+|:\\s*)(Fatal|Error|Warning|Hint|error|fatal):\\s+(.*)$",
160
+ "file": 1, "line": 2, "severity": 3, "message": 4
161
+ }
162
+ }
163
+ },
164
+ {
165
+ "label": "Bimer: RELEASE",
166
+ "type": "shell",
167
+ "command": "delphi release",
168
+ "group": "build",
169
+ "presentation": { "reveal": "always", "focus": true, "panel": "dedicated", "clear": true },
170
+ "problemMatcher": {
171
+ "owner": "delphi",
172
+ "fileLocation": ["autoDetect", "${workspaceFolder}"],
173
+ "pattern": {
174
+ "regexp": "^(.*?)\\s*\\((\\d+)\\)(?:\\s+|:\\s*)(Fatal|Error|Warning|Hint|error|fatal):\\s+(.*)$",
175
+ "file": 1, "line": 2, "severity": 3, "message": 4
176
+ }
177
+ }
178
+ }
179
+ ]
180
+ }
181
+ ```
182
+
183
+ E nos keybindings, nada muda — os atalhos continuam os mesmos.
184
+
185
+ ---
186
+
187
+ ## Estrutura do Projeto
188
+
189
+ ```
190
+ bbuilder-cli/
191
+ ├── src/
192
+ │ ├── build/
193
+ │ ├── cli/
194
+ │ ├── config/
195
+ │ ├── ui/
196
+ │ ├── index.ts
197
+ │ └── types.ts
198
+ ├── package.json
199
+ ├── tsconfig.json
200
+ └── README.md
201
+ ```
202
+
203
+ ## Stack
204
+
205
+ | Lib | Por quê |
206
+ |---|---|
207
+ | **commander** | Parsing de comandos e flags |
208
+ | **inquirer** | Menus interativos com setas |
209
+ | **chalk** | Cores ANSI no terminal |
210
+ | **execa** | Spawn de processos externos (CGRC, DCC64) |
211
+ | **typescript** | Tipagem, autocomplete, menos bugs |
@@ -0,0 +1,140 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.buildCompilerFlags = buildCompilerFlags;
40
+ exports.runCgrc = runCgrc;
41
+ exports.runDcc64 = runDcc64;
42
+ exports.runBuiltExecutable = runBuiltExecutable;
43
+ const execa_1 = __importDefault(require("execa"));
44
+ const fs = __importStar(require("fs"));
45
+ const os = __importStar(require("os"));
46
+ const path = __importStar(require("path"));
47
+ const output_1 = require("../ui/output");
48
+ function buildCompilerFlags(buildType) {
49
+ const baseDefines = 'DEBUG;ALT_CEF133_0;EUREKALOG';
50
+ const releaseDefines = 'RELEASE;ALT_CEF133_0;EUREKALOG';
51
+ switch (buildType) {
52
+ case 'FAST':
53
+ return {
54
+ flags: ['-$W+', '-$J+', '-$D+', '-$L+', '-$Y+', '-$O-'],
55
+ defines: baseDefines,
56
+ runAfter: true,
57
+ };
58
+ case 'DEBUG':
59
+ return {
60
+ flags: ['-B', '-$W+', '-$J+', '-$D+', '-$L+', '-$Y+', '-$O-', '-V', '-VR'],
61
+ defines: baseDefines,
62
+ runAfter: true,
63
+ };
64
+ case 'RELEASE':
65
+ return {
66
+ flags: ['-B', '-$W+', '-$J+', '-$D0', '-$L-', '-$Y-', '-$O+'],
67
+ defines: releaseDefines,
68
+ runAfter: false,
69
+ };
70
+ }
71
+ }
72
+ function buildDependencies(opts) {
73
+ return opts.dependencyPaths.map(p => `"${p}"`).join(';');
74
+ }
75
+ async function runCgrc(opts, projectName) {
76
+ const tempDir = path.join(os.tmpdir(), `BimerBuild_${projectName}`);
77
+ const vrcFile = path.join(tempDir, `${projectName}.vrc`);
78
+ const resFile = path.join(tempDir, `${projectName}.res`);
79
+ (0, output_1.step)('Compilando recursos e embutindo ícone...');
80
+ try {
81
+ await (0, execa_1.default)(path.win32.join(opts.delphiDir, 'bin', 'cgrc.exe'), [vrcFile, `-fo${resFile}`], { stdio: 'inherit' });
82
+ }
83
+ catch {
84
+ (0, output_1.fatal)('Falha do compilador CGRC ao gerar o arquivo de recursos .res.');
85
+ }
86
+ return resFile;
87
+ }
88
+ async function runDcc64(opts, projectName, workspaceDir) {
89
+ const { flags, defines } = buildCompilerFlags(opts.type);
90
+ const deps = buildDependencies(opts);
91
+ const exeOut = path.win32.join('C:\\Temp', opts.envVersion, 'EXE');
92
+ const dcuOut = path.win32.join('C:\\Temp', opts.envVersion, 'DCU');
93
+ if (!fs.existsSync(exeOut))
94
+ fs.mkdirSync(exeOut, { recursive: true });
95
+ if (!fs.existsSync(dcuOut))
96
+ fs.mkdirSync(dcuOut, { recursive: true });
97
+ (0, output_1.step)(`Iniciando compilação do código fonte (${opts.type})...`);
98
+ 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;';
99
+ const aliasValue = 'Generics.Collections=System.Generics.Collections;Generics.Defaults=System.Generics.Defaults;WinTypes=Winapi.Windows;WinProcs=Winapi.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE';
100
+ const dcc64 = path.win32.join(opts.delphiDir, 'bin', 'dcc64.exe');
101
+ const args = [
102
+ ...flags,
103
+ '--no-config', '-Q', '-H-', '-W-',
104
+ '-TX.exe',
105
+ `-A${aliasValue}`,
106
+ `-D${defines}`,
107
+ `-E${exeOut}`,
108
+ `-I${deps}`,
109
+ `-LE${exeOut}`,
110
+ `-LN${exeOut}`,
111
+ `-NU${dcuOut}`,
112
+ `-NS${nsValue}`,
113
+ `-O${deps}`,
114
+ `-R${deps}`,
115
+ `-U${deps}`,
116
+ '-K00400000', '-GD',
117
+ `-NB${exeOut}`,
118
+ `-NH${exeOut}`,
119
+ `-NO${dcuOut}`,
120
+ '-W-', '-W-SYMBOL_PLATFORM', '-W-UNIT_PLATFORM', '-W-DUPLICATE_CTOR_DTOR', '-W-IMPLICIT_STRING_CAST',
121
+ `${projectName}.dpr`,
122
+ ];
123
+ try {
124
+ await (0, execa_1.default)(dcc64, args, {
125
+ cwd: workspaceDir,
126
+ stdio: 'inherit',
127
+ });
128
+ }
129
+ catch {
130
+ (0, output_1.fatal)('Falha na compilação do Delphi. Verifique os logs de erro acima.');
131
+ }
132
+ }
133
+ function runBuiltExecutable(opts, projectName) {
134
+ const { runAfter } = buildCompilerFlags(opts.type);
135
+ if (!runAfter)
136
+ return;
137
+ const exeOut = path.win32.join('C:\\Temp', opts.envVersion, 'EXE', `${projectName}.exe`);
138
+ (0, output_1.step)(`Iniciando ${projectName}.exe...`);
139
+ (0, execa_1.default)(exeOut, [], { detached: true, stdio: 'ignore' }).unref();
140
+ }
@@ -0,0 +1,59 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.executeBuild = executeBuild;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const output_1 = require("../ui/output");
40
+ const compiler_1 = require("./compiler");
41
+ const project_1 = require("./project");
42
+ const resources_1 = require("./resources");
43
+ async function executeBuild(opts) {
44
+ (0, output_1.banner)();
45
+ const { workspaceDir, projectName } = (0, project_1.resolveProject)(opts.project, opts.repoBase);
46
+ (0, output_1.printBuildHeader)(opts, projectName, workspaceDir);
47
+ (0, resources_1.prepareProjectResources)(opts, projectName, workspaceDir);
48
+ const oldRes = path.win32.join(workspaceDir, `${projectName}.res`);
49
+ if (fs.existsSync(oldRes))
50
+ fs.unlinkSync(oldRes);
51
+ const resFile = await (0, compiler_1.runCgrc)(opts, projectName);
52
+ fs.copyFileSync(resFile, path.win32.join(workspaceDir, `${projectName}.res`));
53
+ await (0, compiler_1.runDcc64)(opts, projectName, workspaceDir);
54
+ (0, output_1.printSuccess)(opts.type);
55
+ const { runAfter } = (0, compiler_1.buildCompilerFlags)(opts.type);
56
+ if (runAfter) {
57
+ (0, compiler_1.runBuiltExecutable)(opts, projectName);
58
+ }
59
+ }
@@ -0,0 +1,43 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.resolveProject = resolveProject;
37
+ const path = __importStar(require("path"));
38
+ function resolveProject(projectPath, repoBase) {
39
+ const fullPath = path.win32.join(repoBase, projectPath);
40
+ const workspaceDir = path.win32.dirname(fullPath) + path.win32.sep;
41
+ const projectName = path.win32.basename(fullPath);
42
+ return { workspaceDir, projectName };
43
+ }
@@ -0,0 +1,175 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.prepareProjectResources = prepareProjectResources;
37
+ const fs = __importStar(require("fs"));
38
+ const os = __importStar(require("os"));
39
+ const path = __importStar(require("path"));
40
+ const output_1 = require("../ui/output");
41
+ function parseVersionParts(version) {
42
+ const normalized = version.trim().replace(/\.+$/, '');
43
+ const parts = normalized.split('.');
44
+ return [
45
+ parts[0] ? Number(parts[0]) : 0,
46
+ parts[1] ? Number(parts[1]) : 0,
47
+ parts[2] ? Number(parts[2]) : 0,
48
+ parts[3] ? Number(parts[3]) : 0,
49
+ ];
50
+ }
51
+ function resolveVersionInfo(content, version) {
52
+ if (version && version.trim()) {
53
+ const [major, minor, release, build] = parseVersionParts(version);
54
+ const fullVersion = `${major}.${minor}.${release}.${build}`;
55
+ const nextContent = content
56
+ .replace(/(<VerInfo_MajorVer>)[^<]*(<\/VerInfo_MajorVer>)/, `$1${major}$2`)
57
+ .replace(/(<VerInfo_MinorVer>)[^<]*(<\/VerInfo_MinorVer>)/, `$1${minor}$2`)
58
+ .replace(/(<VerInfo_Release>)[^<]*(<\/VerInfo_Release>)/, `$1${release}$2`)
59
+ .replace(/(<VerInfo_Build>)[^<]*(<\/VerInfo_Build>)/, `$1${build}$2`)
60
+ .replace(/(FileVersion=)[^;<]*/g, `$1${fullVersion}`)
61
+ .replace(/(ProductVersion=)[^;<]*/g, `$1${fullVersion}`);
62
+ return { content: nextContent, fullVersion, parts: [major, minor, release, build] };
63
+ }
64
+ const major = Number(content.match(/<VerInfo_MajorVer>([^<]*)<\/VerInfo_MajorVer>/)?.[1] || 1);
65
+ const minor = Number(content.match(/<VerInfo_MinorVer>([^<]*)<\/VerInfo_MinorVer>/)?.[1] || 0);
66
+ const release = Number(content.match(/<VerInfo_Release>([^<]*)<\/VerInfo_Release>/)?.[1] || 0);
67
+ const build = Number(content.match(/<VerInfo_Build>([^<]*)<\/VerInfo_Build>/)?.[1] || 0);
68
+ const fullVersion = `${major}.${minor}.${release}.${build}`;
69
+ return { content, fullVersion, parts: [major, minor, release, build] };
70
+ }
71
+ function resolveMainIcon(content, delphiDir, projectDir, projectName) {
72
+ const iconPathRaw = (content.match(/<Icon_MainIcon>([^<]*)<\/Icon_MainIcon>/)?.[1] || '').trim();
73
+ let resolvedIconPath = iconPathRaw.replace(/\$\(BDS\)/g, delphiDir);
74
+ if (resolvedIconPath && !path.win32.isAbsolute(resolvedIconPath)) {
75
+ resolvedIconPath = path.win32.join(projectDir, resolvedIconPath);
76
+ }
77
+ const projectIcon = path.win32.join(projectDir, `${projectName}_Icon.ico`);
78
+ const fallbackIcon = path.win32.join(delphiDir, 'bin', 'delphi_PROJECTICON.ico');
79
+ if (resolvedIconPath && fs.existsSync(resolvedIconPath)) {
80
+ return resolvedIconPath;
81
+ }
82
+ if (fs.existsSync(projectIcon)) {
83
+ return projectIcon;
84
+ }
85
+ return fallbackIcon;
86
+ }
87
+ function buildManifestContent(projectName, fullVersion) {
88
+ return [
89
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
90
+ '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">',
91
+ ` <assemblyIdentity type="win32" name="${projectName}" version="${fullVersion}" processorArchitecture="*"/>`,
92
+ ' <dependency>',
93
+ ' <dependentAssembly>',
94
+ ' <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*"/>',
95
+ ' </dependentAssembly>',
96
+ ' </dependency>',
97
+ ' <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">',
98
+ ' <security>',
99
+ ' <requestedPrivileges>',
100
+ ' <requestedExecutionLevel level="asInvoker" uiAccess="false"/>',
101
+ ' </requestedPrivileges>',
102
+ ' </security>',
103
+ ' </trustInfo>',
104
+ '</assembly>',
105
+ ].join('\r\n');
106
+ }
107
+ function buildVrcContent(projectName, fullVersion, parts, manifestPath, iconPath) {
108
+ const [major, minor, release, build] = parts;
109
+ const lines = [];
110
+ if (iconPath) {
111
+ lines.push(`MAINICON ICON "${iconPath.replace(/\\/g, '\\\\')}"`);
112
+ }
113
+ lines.push(`1 24 "${manifestPath.replace(/\\/g, '\\\\')}"`);
114
+ lines.push('1 VERSIONINFO');
115
+ lines.push(`FILEVERSION ${major},${minor},${release},${build}`);
116
+ lines.push(`PRODUCTVERSION ${major},${minor},${release},${build}`);
117
+ lines.push('FILEFLAGSMASK 0x3FL');
118
+ lines.push('FILEFLAGS 0x00L');
119
+ lines.push('FILEOS 0x40004L');
120
+ lines.push('FILETYPE 0x1L');
121
+ lines.push('FILESUBTYPE 0x0L');
122
+ lines.push('BEGIN');
123
+ lines.push(' BLOCK "StringFileInfo"');
124
+ lines.push(' BEGIN');
125
+ lines.push(' BLOCK "040904E4"');
126
+ lines.push(' BEGIN');
127
+ lines.push(' VALUE "CompanyName", "\\0"');
128
+ lines.push(` VALUE "FileDescription", "${projectName}\\0"`);
129
+ lines.push(` VALUE "FileVersion", "${fullVersion}\\0"`);
130
+ lines.push(' VALUE "InternalName", "\\0"');
131
+ lines.push(' VALUE "LegalCopyright", "\\0"');
132
+ lines.push(` VALUE "OriginalFilename", "${projectName}.exe\\0"`);
133
+ lines.push(` VALUE "ProductName", "${projectName}\\0"`);
134
+ lines.push(` VALUE "ProductVersion", "${fullVersion}\\0"`);
135
+ lines.push(' END');
136
+ lines.push(' END');
137
+ lines.push(' BLOCK "VarFileInfo"');
138
+ lines.push(' BEGIN');
139
+ lines.push(' VALUE "Translation", 0x0409, 1252');
140
+ lines.push(' END');
141
+ lines.push('END');
142
+ return lines.join('\r\n');
143
+ }
144
+ function prepareProjectResources(opts, projectName, workspaceDir) {
145
+ const dproj = path.win32.join(workspaceDir, `${projectName}.dproj`);
146
+ const tempDir = path.join(os.tmpdir(), `BimerBuild_${projectName}`);
147
+ const manifestFile = path.join(tempDir, `${projectName}.manifest`);
148
+ const vrcFile = path.join(tempDir, `${projectName}.vrc`);
149
+ if (!fs.existsSync(tempDir))
150
+ fs.mkdirSync(tempDir, { recursive: true });
151
+ if (!fs.existsSync(dproj)) {
152
+ (0, output_1.fatal)(`Arquivo de projeto não encontrado: ${dproj}`);
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
+ try {
161
+ const projectContent = fs.readFileSync(dproj, 'utf-8');
162
+ const { content: updatedContent, fullVersion, parts } = resolveVersionInfo(projectContent, opts.version);
163
+ if (updatedContent !== projectContent) {
164
+ fs.writeFileSync(dproj, updatedContent, 'utf-8');
165
+ }
166
+ const iconPath = resolveMainIcon(updatedContent, opts.delphiDir, workspaceDir, projectName);
167
+ const manifestContent = buildManifestContent(projectName, fullVersion);
168
+ const vrcContent = buildVrcContent(projectName, fullVersion, parts, manifestFile, iconPath);
169
+ fs.writeFileSync(manifestFile, manifestContent, 'ascii');
170
+ fs.writeFileSync(vrcFile, vrcContent, 'ascii');
171
+ }
172
+ catch {
173
+ (0, output_1.fatal)('Falha ao preparar versão, manifesto e recursos do projeto.');
174
+ }
175
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runCli = runCli;
7
+ const commander_1 = require("commander");
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const execute_1 = require("../build/execute");
10
+ const config_1 = require("../config/config");
11
+ const output_1 = require("../ui/output");
12
+ const prompts_1 = require("../ui/prompts");
13
+ async function runCli(argv) {
14
+ const resolvedConfigPath = (0, config_1.resolveConfigPath)(argv);
15
+ const writableConfigPath = (0, config_1.getWritableConfigPath)(resolvedConfigPath);
16
+ const config = (0, config_1.loadConfig)(resolvedConfigPath);
17
+ const program = new commander_1.Command();
18
+ program
19
+ .name('delphi')
20
+ .description('CLI de build local para projetos Delphi do Bimer')
21
+ .version('1.0.0')
22
+ .option('-c, --config <path>', `Caminho do arquivo de configuração (ou ${config_1.CONFIG_ENV_VAR})`);
23
+ program
24
+ .command('build')
25
+ .description('Compila um projeto Delphi (interativo se flags omitidas)')
26
+ .option('-t, --type <FAST|DEBUG|RELEASE>', 'Modo de build')
27
+ .option('-p, --project <path>', 'Caminho do projeto (ex: faturamento\\BimerFaturamento)')
28
+ .option('-v, --version <version>', 'Versão a injetar (ex: 11.2.4)')
29
+ .action(async (opts) => {
30
+ const buildType = opts.type?.toUpperCase();
31
+ if (buildType && !['FAST', 'DEBUG', 'RELEASE'].includes(buildType)) {
32
+ (0, output_1.fatal)(`Tipo de build inválido: "${opts.type}". Use FAST, DEBUG ou RELEASE.`);
33
+ }
34
+ const resolved = await (0, prompts_1.promptBuild)(config, buildType, opts.project, opts.version);
35
+ await (0, execute_1.executeBuild)(resolved);
36
+ });
37
+ for (const type of ['fast', 'debug', 'release']) {
38
+ program
39
+ .command(type)
40
+ .description(`Compila no modo ${type.toUpperCase()} (interativo para projeto/versão)`)
41
+ .option('-p, --project <path>', 'Caminho do projeto')
42
+ .option('-v, --version <version>', 'Versão a injetar')
43
+ .action(async (opts) => {
44
+ const resolved = await (0, prompts_1.promptBuild)(config, type.toUpperCase(), opts.project, opts.version);
45
+ await (0, execute_1.executeBuild)(resolved);
46
+ });
47
+ }
48
+ const configCmd = program
49
+ .command('config')
50
+ .description('Gerencia a configuração do ambiente');
51
+ configCmd
52
+ .command('init')
53
+ .description('Configura o ambiente de forma interativa (cria bbuilder.config.json)')
54
+ .action(() => (0, prompts_1.runConfigInit)(config, writableConfigPath));
55
+ configCmd
56
+ .command('show')
57
+ .description('Exibe a configuração atual')
58
+ .action(() => {
59
+ console.log('');
60
+ console.log(chalk_1.default.cyan(' Configuração Atual'));
61
+ console.log(chalk_1.default.blue(' ──────────────────'));
62
+ console.log(chalk_1.default.gray(` Arquivo: ${resolvedConfigPath}`));
63
+ console.log('');
64
+ console.log(JSON.stringify(config, null, 2)
65
+ .split('\n')
66
+ .map(line => ' ' + line)
67
+ .join('\n'));
68
+ console.log('');
69
+ });
70
+ const projectCmd = program
71
+ .command('project')
72
+ .description('Gerencia a lista de projetos');
73
+ projectCmd
74
+ .command('add')
75
+ .description('Adiciona um novo projeto à lista')
76
+ .action(() => (0, prompts_1.runProjectAdd)(config, writableConfigPath));
77
+ projectCmd
78
+ .command('list')
79
+ .description('Lista todos os projetos configurados')
80
+ .action(() => {
81
+ console.log('');
82
+ console.log(chalk_1.default.cyan(' Projetos Configurados'));
83
+ console.log(chalk_1.default.blue(' ─────────────────────'));
84
+ Object.entries(config.projects).forEach(([name, projectPath], index) => {
85
+ console.log(` ${chalk_1.default.yellow(String(index + 1).padStart(2))}. ${chalk_1.default.white(name)} ${chalk_1.default.gray(`→ ${projectPath}`)}`);
86
+ });
87
+ console.log('');
88
+ });
89
+ if (argv.length <= 2) {
90
+ (0, output_1.banner)();
91
+ const resolved = await (0, prompts_1.promptBuild)(config);
92
+ await (0, execute_1.executeBuild)(resolved);
93
+ return;
94
+ }
95
+ await program.parseAsync(argv);
96
+ }
@@ -0,0 +1,184 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.DEFAULT_CONFIG = exports.CONFIG_ENV_VAR = exports.LEGACY_CONFIG_FILENAME = exports.CONFIG_FILENAME = void 0;
37
+ exports.buildDefaultDependencyPaths = buildDefaultDependencyPaths;
38
+ exports.getDefaultConfigPath = getDefaultConfigPath;
39
+ exports.getWritableConfigPath = getWritableConfigPath;
40
+ exports.resolveConfigPath = resolveConfigPath;
41
+ exports.loadConfig = loadConfig;
42
+ exports.saveConfig = saveConfig;
43
+ const fs = __importStar(require("fs"));
44
+ const os = __importStar(require("os"));
45
+ const path = __importStar(require("path"));
46
+ exports.CONFIG_FILENAME = 'bbuilder.config.json';
47
+ exports.LEGACY_CONFIG_FILENAME = 'bimer.config.json';
48
+ exports.CONFIG_ENV_VAR = 'BBUILDER_CONFIG';
49
+ const DEFAULT_CONFIG_BASE = {
50
+ repoBase: 'C:\\git\\bimer',
51
+ delphiDir: 'C:\\Program Files (x86)\\Embarcadero\\Studio\\22.0',
52
+ envVersion: '11.03.00',
53
+ libRoot: 'C:\\LibraryDelphiAlexandria\\Externos\\3.00',
54
+ libErp: 'C:\\LibraryDelphiAlexandria\\ERP\\11.03.00',
55
+ libAlterdata: 'C:\\LibraryDelphiAlexandria\\LibAlterdata\\1.0.0',
56
+ };
57
+ function buildDefaultDependencyPaths(params) {
58
+ const { repoBase, delphiDir, libRoot, libErp, libAlterdata } = params;
59
+ return [
60
+ `${repoBase}\\dependencies`,
61
+ `${delphiDir}\\lib\\Win64\\release`,
62
+ `${libRoot}\\sgcWebSockets\\Win64`,
63
+ `${libRoot}\\DevExpress\\Win64`,
64
+ `${libRoot}\\dataset-serialize\\Win64`,
65
+ `${libRoot}\\UniDAC\\Win64`,
66
+ `${libRoot}\\EurekaLog\\Common`,
67
+ `${libRoot}\\EurekaLog\\Win64`,
68
+ `${libRoot}\\SMImport\\Win64`,
69
+ `${libRoot}\\SMExport\\Win64`,
70
+ `${libRoot}\\RXLibrary\\Win64`,
71
+ `${libRoot}\\ReportBuilder\\Win64`,
72
+ `${libRoot}\\ComPort\\Win64`,
73
+ `${libRoot}\\QuickReport\\Win64`,
74
+ `${libRoot}\\FastMM\\Win64`,
75
+ `${libRoot}\\Tee\\Win64`,
76
+ `${libRoot}\\ExtraDevices\\Win64`,
77
+ `${libRoot}\\ExtraFilter\\Win64`,
78
+ `${libErp}\\Win64`,
79
+ `${libRoot}\\ZipForge\\Win64`,
80
+ `${libRoot}\\FortesReport\\Win64`,
81
+ `${libRoot}\\TBGWebCharts\\Win64`,
82
+ `${libRoot}\\EventBus\\Win64`,
83
+ `${libRoot}\\Horse\\Win64`,
84
+ `${libAlterdata}\\feedbacker`,
85
+ `${libAlterdata}\\rest-client`,
86
+ ];
87
+ }
88
+ exports.DEFAULT_CONFIG = {
89
+ ...DEFAULT_CONFIG_BASE,
90
+ dependencyPaths: buildDefaultDependencyPaths(DEFAULT_CONFIG_BASE),
91
+ projects: {
92
+ BimerFaturamento: 'faturamento\\BimerFaturamento',
93
+ Bimer: 'Bimer',
94
+ LiberadorEstoque: 'geral\\gerenteeletronico.jobs.liberadorestoque\\LiberadorEstoque',
95
+ BimerEstoque: 'estoque\\BimerEstoque',
96
+ },
97
+ };
98
+ function deriveProjectName(projectPath) {
99
+ const normalized = projectPath.replace(/[\\/]+$/, '');
100
+ const segments = normalized.split(/[\\/]/).filter(Boolean);
101
+ return segments[segments.length - 1] || projectPath;
102
+ }
103
+ function normalizeProjects(projects) {
104
+ if (projects && typeof projects === 'object' && !Array.isArray(projects)) {
105
+ return { ...projects };
106
+ }
107
+ if (Array.isArray(projects)) {
108
+ return projects.reduce((acc, projectPath) => {
109
+ if (typeof projectPath === 'string' && projectPath.trim()) {
110
+ acc[deriveProjectName(projectPath)] = projectPath;
111
+ }
112
+ return acc;
113
+ }, {});
114
+ }
115
+ return { ...exports.DEFAULT_CONFIG.projects };
116
+ }
117
+ function getUserConfigDirectory() {
118
+ if (process.platform === 'win32') {
119
+ const appData = process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming');
120
+ return path.join(appData, 'bbuilder-cli');
121
+ }
122
+ const xdgConfig = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config');
123
+ return path.join(xdgConfig, 'bbuilder-cli');
124
+ }
125
+ function getDefaultConfigPath() {
126
+ return path.join(getUserConfigDirectory(), exports.CONFIG_FILENAME);
127
+ }
128
+ function getWritableConfigPath(configPath) {
129
+ if (path.basename(configPath) === exports.LEGACY_CONFIG_FILENAME) {
130
+ return path.join(path.dirname(configPath), exports.CONFIG_FILENAME);
131
+ }
132
+ return configPath;
133
+ }
134
+ function resolveConfigPath(argv = process.argv) {
135
+ for (let index = 0; index < argv.length; index++) {
136
+ const current = argv[index];
137
+ if (current === '--config' || current === '-c') {
138
+ const next = argv[index + 1];
139
+ if (next)
140
+ return path.resolve(next);
141
+ }
142
+ if (current.startsWith('--config=')) {
143
+ return path.resolve(current.slice('--config='.length));
144
+ }
145
+ }
146
+ const envPath = process.env[exports.CONFIG_ENV_VAR];
147
+ if (envPath) {
148
+ return path.resolve(envPath);
149
+ }
150
+ const localConfig = path.join(process.cwd(), exports.CONFIG_FILENAME);
151
+ if (fs.existsSync(localConfig)) {
152
+ return localConfig;
153
+ }
154
+ const legacyLocalConfig = path.join(process.cwd(), exports.LEGACY_CONFIG_FILENAME);
155
+ if (fs.existsSync(legacyLocalConfig)) {
156
+ return legacyLocalConfig;
157
+ }
158
+ return getDefaultConfigPath();
159
+ }
160
+ function loadConfig(configPath) {
161
+ if (fs.existsSync(configPath)) {
162
+ try {
163
+ const raw = fs.readFileSync(configPath, 'utf-8');
164
+ const parsed = JSON.parse(raw);
165
+ const merged = {
166
+ ...exports.DEFAULT_CONFIG,
167
+ ...parsed,
168
+ projects: normalizeProjects(parsed.projects),
169
+ };
170
+ if (!Array.isArray(parsed.dependencyPaths) || parsed.dependencyPaths.length === 0) {
171
+ merged.dependencyPaths = buildDefaultDependencyPaths(merged);
172
+ }
173
+ return merged;
174
+ }
175
+ catch {
176
+ // ignora parse error, usa default
177
+ }
178
+ }
179
+ return { ...exports.DEFAULT_CONFIG };
180
+ }
181
+ function saveConfig(config, configPath) {
182
+ fs.mkdirSync(path.dirname(configPath), { recursive: true });
183
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
184
+ }
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const program_1 = require("./cli/program");
9
+ (0, program_1.runCli)(process.argv).catch(err => {
10
+ console.error(chalk_1.default.red('\n [FATAL] ') + (err instanceof Error ? err.message : String(err)));
11
+ process.exit(1);
12
+ });
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.banner = banner;
7
+ exports.printBuildHeader = printBuildHeader;
8
+ exports.printSuccess = printSuccess;
9
+ exports.step = step;
10
+ exports.fatal = fatal;
11
+ const chalk_1 = __importDefault(require("chalk"));
12
+ function banner() {
13
+ console.log('');
14
+ console.log(chalk_1.default.blue(' ══════════════════════════════════════════════════════════════'));
15
+ console.log(chalk_1.default.cyan(' ____ _ ____ _ __ __ '));
16
+ console.log(chalk_1.default.cyan(' / __ )(_)___ ___ ___ _____/ __ )__ __(_) /___/ / '));
17
+ console.log(chalk_1.default.cyan(' / __ / / __ `__ \\/ _ \\/ ___/ __ / / / / / / __ / '));
18
+ console.log(chalk_1.default.cyan(' / /_/ / / / / / / / __/ / / /_/ / /_/ / / / /_/ / '));
19
+ console.log(chalk_1.default.cyan(' /_____/_/_/ /_/ /_/\\___/_/ /_____/\\__,_/_/_/\\__,_/ '));
20
+ console.log(chalk_1.default.blue(' ──────────────────────────────────────────────────────────────'));
21
+ console.log(chalk_1.default.green(' [+]') + chalk_1.default.white(' Iniciando Pipeline DevOps Local... ') + chalk_1.default.green('[ RUNNING ]'));
22
+ console.log(chalk_1.default.green(' [+]') + chalk_1.default.white(' Engatando Motor Embarcadero... ') + chalk_1.default.green('[ STANDBY ]'));
23
+ console.log(chalk_1.default.green(' [+]') + chalk_1.default.white(' Sanitizando Caches Fantasmas... ') + chalk_1.default.green('[ CLEARED ]'));
24
+ console.log(chalk_1.default.blue(' ══════════════════════════════════════════════════════════════'));
25
+ console.log('');
26
+ }
27
+ function printBuildHeader(opts, projectName, workspaceDir) {
28
+ const typeColor = {
29
+ FAST: chalk_1.default.yellow,
30
+ DEBUG: chalk_1.default.cyan,
31
+ RELEASE: chalk_1.default.green,
32
+ };
33
+ const col = typeColor[opts.type];
34
+ console.log(chalk_1.default.magenta(' [ PROJETO ]') + ' ' + chalk_1.default.white(projectName));
35
+ console.log(chalk_1.default.magenta(' [ CAMINHO ]') + ' ' + chalk_1.default.white(workspaceDir));
36
+ console.log(chalk_1.default.magenta(' [ VERSÃO ]') + ' ' + chalk_1.default.yellow(opts.version || '(atual)') + ` (Base: ${opts.envVersion})`);
37
+ console.log(chalk_1.default.magenta(' [ PROFILE ]') + ' ' + col(opts.type));
38
+ console.log(chalk_1.default.blue(' ──────────────────────────────────────────────────────────────'));
39
+ console.log('');
40
+ }
41
+ function printSuccess(buildType) {
42
+ console.log('');
43
+ console.log(chalk_1.default.red(' .oooooo. ') + chalk_1.default.green(' _____________________________________________'));
44
+ console.log(chalk_1.default.red(' .o00000000o. ') + chalk_1.default.green(' _____ _ _ _____ _____ ______ _____ _____ '));
45
+ console.log(chalk_1.default.red(' .00') + chalk_1.default.white('######') + chalk_1.default.red('0000. ') + chalk_1.default.green(' / ____| | | |/ ____/ ____| ____/ ____|/ ____|'));
46
+ console.log(chalk_1.default.red(' 000') + chalk_1.default.white('##') + chalk_1.default.red('0000') + chalk_1.default.white('##') + chalk_1.default.red('000 ') + chalk_1.default.green(' | (___ | | | | | | | | |__ \\___ \\___ |'));
47
+ console.log(chalk_1.default.red(' 000') + chalk_1.default.white('##') + chalk_1.default.red('00000') + chalk_1.default.white('##') + chalk_1.default.red('00 ') + chalk_1.default.green(' \\___ \\| | | | | | | | __| ___ \\ ___ |'));
48
+ console.log(chalk_1.default.red(' 000') + chalk_1.default.white('##') + chalk_1.default.red('0000') + chalk_1.default.white('##') + chalk_1.default.red('000 ') + chalk_1.default.green(' ____) | |__| | |___| |____| |____ ____) |____) |'));
49
+ console.log(chalk_1.default.red(" `00") + chalk_1.default.white('######') + chalk_1.default.red("0000' ") + chalk_1.default.green(' |_____/ \\____/ \\_____\\_____|______|_____/|_____/'));
50
+ console.log(chalk_1.default.red(" `o00000000o' ") + chalk_1.default.green(' _____________________________________________'));
51
+ console.log(chalk_1.default.red(" `oooooo' ") + chalk_1.default.cyan(' [*] ') + chalk_1.default.white('Build ') + chalk_1.default.yellow(buildType) + chalk_1.default.white(' finalizado com êxito absoluto!'));
52
+ console.log(chalk_1.default.red(' ') + chalk_1.default.cyan(' [*] ') + chalk_1.default.white('Artefatos validados, versionados e linkados na raiz.'));
53
+ console.log(chalk_1.default.red(' ') + chalk_1.default.green(' [ RUN ] O ecossistema está pronto para combate.'));
54
+ console.log(chalk_1.default.green(' _____________________________________________'));
55
+ console.log('');
56
+ }
57
+ function step(msg) {
58
+ console.log(chalk_1.default.cyan(' [*]') + ' ' + chalk_1.default.white(msg));
59
+ }
60
+ function fatal(msg) {
61
+ console.error('');
62
+ console.error(chalk_1.default.red(' [ERRO FATAL] ') + msg);
63
+ console.error('');
64
+ process.exit(1);
65
+ }
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.promptBuild = promptBuild;
7
+ exports.runConfigInit = runConfigInit;
8
+ exports.runProjectAdd = runProjectAdd;
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const inquirer_1 = __importDefault(require("inquirer"));
11
+ const config_1 = require("../config/config");
12
+ async function promptBuild(config, cliType, cliProject, cliVersion) {
13
+ const questions = [];
14
+ const projectChoices = Object.entries(config.projects).map(([name, projectPath]) => ({
15
+ name,
16
+ value: projectPath,
17
+ }));
18
+ if (!cliType) {
19
+ questions.push({
20
+ type: 'list',
21
+ name: 'type',
22
+ message: 'Modo de build:',
23
+ choices: [
24
+ { name: '⚡ FAST — Rápido, sem full rebuild, abre o sistema', value: 'FAST' },
25
+ { name: '🔍 DEBUG — Com símbolos de debug, abre o sistema', value: 'DEBUG' },
26
+ { name: '🚀 RELEASE — Otimizado, não abre o sistema', value: 'RELEASE' },
27
+ ],
28
+ default: 'DEBUG',
29
+ });
30
+ }
31
+ if (!cliProject) {
32
+ questions.push({
33
+ type: 'list',
34
+ name: 'project',
35
+ message: 'Qual projeto compilar?',
36
+ choices: projectChoices,
37
+ default: projectChoices[0]?.value,
38
+ });
39
+ }
40
+ if (!cliVersion) {
41
+ questions.push({
42
+ type: 'input',
43
+ name: 'version',
44
+ message: 'Versão do EXE? (deixe em branco para manter atual):',
45
+ default: '',
46
+ });
47
+ }
48
+ const answers = await inquirer_1.default.prompt(questions);
49
+ return {
50
+ type: (cliType || answers.type),
51
+ project: cliProject || answers.project,
52
+ version: cliVersion || answers.version || '',
53
+ repoBase: config.repoBase,
54
+ delphiDir: config.delphiDir,
55
+ envVersion: config.envVersion,
56
+ libRoot: config.libRoot,
57
+ libErp: config.libErp,
58
+ libAlterdata: config.libAlterdata,
59
+ dependencyPaths: config.dependencyPaths,
60
+ };
61
+ }
62
+ async function runConfigInit(config, configPath) {
63
+ console.log('');
64
+ console.log(chalk_1.default.cyan(' Configuração Interativa do Ambiente'));
65
+ console.log(chalk_1.default.blue(' ────────────────────────────────────'));
66
+ const answers = await inquirer_1.default.prompt([
67
+ { type: 'input', name: 'repoBase', message: 'Raiz do repositório:', default: config.repoBase },
68
+ { type: 'input', name: 'delphiDir', message: 'Diretório do Delphi:', default: config.delphiDir },
69
+ { type: 'input', name: 'envVersion', message: 'Versão do ambiente (ENV):', default: config.envVersion },
70
+ { type: 'input', name: 'libRoot', message: 'LibraryDelphiAlexandria root:', default: config.libRoot },
71
+ ]);
72
+ const libErp = `C:\\LibraryDelphiAlexandria\\ERP\\${answers.envVersion}`;
73
+ const newConfig = {
74
+ ...config,
75
+ ...answers,
76
+ libErp,
77
+ libAlterdata: config.libAlterdata,
78
+ dependencyPaths: (0, config_1.buildDefaultDependencyPaths)({
79
+ repoBase: answers.repoBase,
80
+ delphiDir: answers.delphiDir,
81
+ libRoot: answers.libRoot,
82
+ libErp,
83
+ libAlterdata: config.libAlterdata,
84
+ }),
85
+ };
86
+ (0, config_1.saveConfig)(newConfig, configPath);
87
+ console.log('');
88
+ console.log(chalk_1.default.green(' ✔ bbuilder.config.json salvo com sucesso!'));
89
+ console.log(chalk_1.default.gray(` ${configPath}`));
90
+ console.log('');
91
+ }
92
+ async function runProjectAdd(config, configPath) {
93
+ const { projectName, projectPath } = await inquirer_1.default.prompt([
94
+ {
95
+ type: 'input',
96
+ name: 'projectName',
97
+ message: 'Nome do projeto (ex: BimerFaturamento):',
98
+ },
99
+ {
100
+ type: 'input',
101
+ name: 'projectPath',
102
+ message: 'Caminho do projeto (ex: geral\\integrador\\IntegradorXPTO):',
103
+ },
104
+ ]);
105
+ if (!projectName || !projectPath)
106
+ return;
107
+ if (config.projects[projectName]) {
108
+ console.log(chalk_1.default.yellow('\n Já existe um projeto com esse nome.\n'));
109
+ return;
110
+ }
111
+ if (Object.values(config.projects).includes(projectPath)) {
112
+ console.log(chalk_1.default.yellow('\n Esse caminho de projeto já está cadastrado.\n'));
113
+ return;
114
+ }
115
+ const nextConfig = {
116
+ ...config,
117
+ projects: {
118
+ ...config.projects,
119
+ [projectName]: projectPath,
120
+ },
121
+ };
122
+ (0, config_1.saveConfig)(nextConfig, configPath);
123
+ console.log(chalk_1.default.green(`\n ✔ Projeto "${projectName}" adicionado!\n`));
124
+ }
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@brunoluizdesiqueira/bbuilder-cli",
3
+ "version": "1.0.0",
4
+ "description": "CLI de build local para projetos Delphi do Bimer",
5
+ "files": [
6
+ "dist",
7
+ "README.md",
8
+ "LICENSE"
9
+ ],
10
+ "bin": {
11
+ "delphi": "./dist/index.js"
12
+ },
13
+ "scripts": {
14
+ "build": "tsc",
15
+ "dev": "ts-node src/index.ts",
16
+ "prepack": "npm run build"
17
+ },
18
+ "engines": {
19
+ "node": ">=18"
20
+ },
21
+ "dependencies": {
22
+ "chalk": "4.1.2",
23
+ "commander": "^12.0.0",
24
+ "execa": "5.1.1",
25
+ "inquirer": "^8.2.6"
26
+ },
27
+ "devDependencies": {
28
+ "@types/inquirer": "^8.2.10",
29
+ "@types/node": "^20.0.0",
30
+ "ts-node": "^10.9.2",
31
+ "typescript": "^5.4.0"
32
+ }
33
+ }