Skip to content

Commit 3531fee

Browse files
authored
fix: show config in result file (#53)
* fix: show config * release: 1.12.1
1 parent 2708773 commit 3531fee

File tree

9 files changed

+94
-24
lines changed

9 files changed

+94
-24
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.12.1] - 2025-12-04
11+
12+
### Changed
13+
14+
- **Configuration Display in Generated Headers**: Renamed `//cmdline:` to `//config:` in all generated header files
15+
- Now displays effective configuration values regardless of source (RC file, CLI arguments, or both)
16+
- Shows all active configuration parameters: `engine`, `sourcepath`, `outputfile`, `etag`, `gzip`, `cachetime`, `espmethod`, `define`, and `exclude` patterns
17+
- Provides complete traceability of configuration used for code generation
18+
- Format: `//config: engine=psychic sourcepath=./dist outputfile=./output.h etag=true gzip=true ...`
19+
20+
### Fixed
21+
22+
- Configuration comment in generated headers now displays values when using RC file (previously showed empty when using RC file without CLI arguments)
23+
1024
## [1.12.0] - 2025-12-04
1125

1226
### Added
@@ -306,6 +320,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
306320
- CLI interface with `-s`, `-e`, `-o` options
307321
- `index.html` automatic default route handling
308322

323+
[1.12.1]: https://github.com/BCsabaEngine/svelteesp32/compare/v1.12.0...v1.12.1
309324
[1.12.0]: https://github.com/BCsabaEngine/svelteesp32/compare/v1.11.0...v1.12.0
310325
[1.11.0]: https://github.com/BCsabaEngine/svelteesp32/compare/v1.10.0...v1.11.0
311326
[1.10.0]: https://github.com/BCsabaEngine/svelteesp32/compare/v1.9.4...v1.10.0

CLAUDE.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,19 @@ The generated header file includes C++ defines for build-time validation:
294294
- `{PREFIX}_{EXT}_FILES`: Count of files by extension (e.g., `SVELTEESP32_CSS_FILES`)
295295

296296
These allow C++ code to verify expected files are present using `#ifndef` and `#error` directives.
297+
298+
## Generated Header Configuration Comment
299+
300+
The generated header file includes a `//config:` comment at the top that displays the effective configuration used during code generation:
301+
302+
```cpp
303+
//engine: PsychicHttpServer
304+
//config: engine=psychic sourcepath=./dist outputfile=./output.h etag=true gzip=true cachetime=0 espmethod=initSvelteStaticFiles define=SVELTEESP32 exclude=[*.map, *.md]
305+
```
306+
307+
**Implementation** (`src/commandLine.ts`, `src/cppCode.ts`):
308+
309+
- `formatConfiguration()` function creates a formatted string from the `ICopyFilesArguments` object
310+
- Shows all configuration parameters: `engine`, `sourcepath`, `outputfile`, `etag`, `gzip`, `cachetime`, `espmethod`, `define`, and `exclude` patterns
311+
- Works consistently whether configuration comes from RC file, CLI arguments, or both
312+
- Provides complete traceability of the configuration used for code generation

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ The content of **generated file** (do not edit, just use):
202202

203203
```c
204204
//engine: PsychicHttpServer
205-
//cmdline: -e psychic -s ./dist -o ./output.h --etag=true --gzip=true
205+
//config: engine=psychic sourcepath=./dist outputfile=./output.h etag=true gzip=true cachetime=0 espmethod=initSvelteStaticFiles define=SVELTEESP32
206206
//
207207
#define SVELTEESP32_COUNT 5
208208
#define SVELTEESP32_SIZE 468822

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelteesp32",
3-
"version": "1.12.0",
3+
"version": "1.12.1",
44
"description": "Convert Svelte (or any frontend) JS application to serve it from ESP32 webserver (PsychicHttp)",
55
"author": "BCsabaEngine",
66
"license": "ISC",

src/commandLine.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,29 @@ function parseArguments(): ICopyFilesArguments {
418418
return result as ICopyFilesArguments;
419419
}
420420

421+
export function formatConfiguration(cmdLine: ICopyFilesArguments): string {
422+
const parts: string[] = [
423+
`engine=${cmdLine.engine}`,
424+
`sourcepath=${cmdLine.sourcepath}`,
425+
`outputfile=${cmdLine.outputfile}`,
426+
`etag=${cmdLine.etag}`,
427+
`gzip=${cmdLine.gzip}`,
428+
`cachetime=${cmdLine.cachetime}`
429+
];
430+
431+
if (cmdLine.created) parts.push(`created=${cmdLine.created}`);
432+
433+
if (cmdLine.version) parts.push(`version=${cmdLine.version}`);
434+
435+
if (cmdLine.espmethod) parts.push(`espmethod=${cmdLine.espmethod}`);
436+
437+
if (cmdLine.define) parts.push(`define=${cmdLine.define}`);
438+
439+
if (cmdLine.exclude.length > 0) parts.push(`exclude=[${cmdLine.exclude.join(', ')}]`);
440+
441+
return parts.join(' ');
442+
}
443+
421444
export const cmdLine = parseArguments();
422445

423446
if (!existsSync(cmdLine.sourcepath) || !statSync(cmdLine.sourcepath).isDirectory()) {

src/cppCode.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { compile as handlebarsCompile, HelperOptions } from 'handlebars';
22

3-
import { cmdLine } from './commandLine';
3+
import { cmdLine, formatConfiguration } from './commandLine';
44
import { espidfTemplate } from './cppCodeEspIdf';
55

66
export type CppCodeSource = {
@@ -126,7 +126,7 @@ const char * etag_{{this.dataname}} = "{{this.md5}}";
126126

127127
const psychicTemplate = `
128128
//engine: PsychicHttpServer
129-
//cmdline: {{{commandLine}}}
129+
//config: {{{config}}}
130130
//You should use server.config.max_uri_handlers = {{fileCount}}; or higher value to proper handles all files
131131
{{#if created }}
132132
//created: {{now}}
@@ -237,7 +237,7 @@ void {{methodName}}(PsychicHttpServer * server) {
237237

238238
const psychic2Template = `
239239
//engine: PsychicHttpServerV2
240-
//cmdline: {{{commandLine}}}
240+
//config: {{{config}}}
241241
{{#if created }}
242242
//created: {{now}}
243243
{{/if}}
@@ -344,7 +344,7 @@ void {{methodName}}(PsychicHttpServer * server) {
344344

345345
const asyncTemplate = `
346346
//engine: ESPAsyncWebServer
347-
//cmdline: {{{commandLine}}}
347+
//config: {{{config}}}
348348
{{#if created }}
349349
//created: {{now}}
350350
{{/if}}
@@ -573,7 +573,7 @@ const createHandlebarsHelpers = () => {
573573
export const getCppCode = (sources: CppCodeSources, filesByExtension: ExtensionGroups): string => {
574574
const template = handlebarsCompile(getTemplate(cmdLine.engine));
575575
const templateData = {
576-
commandLine: process.argv.slice(2).join(' '),
576+
config: formatConfiguration(cmdLine),
577577
now: `${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,
578578
fileCount: sources.length.toString(),
579579
fileSize: sources.reduce((previous, current) => previous + current.content.length, 0).toString(),

src/cppCodeEspIdf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const espidfTemplate = `
22
//engine: espidf
3-
//cmdline: {{{commandLine}}}
3+
//config: {{{config}}}
44
{{#if created }}
55
//created: {{now}}
66
{{/if}}

test/unit/cppCode.test.ts

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ vi.mock('../../src/commandLine', () => ({
1313
created: false,
1414
version: 'v1.0.0',
1515
espmethod: 'initSvelteStaticFiles',
16-
define: 'SVELTEESP32'
17-
}
16+
define: 'SVELTEESP32',
17+
exclude: []
18+
},
19+
formatConfiguration: vi.fn((cmdLine) => {
20+
return `engine=${cmdLine.engine} sourcepath=${cmdLine.sourcepath} outputfile=${cmdLine.outputfile} etag=${cmdLine.etag} gzip=${cmdLine.gzip} cachetime=${cmdLine.cachetime}`;
21+
})
1822
}));
1923

2024
const createMockSource = (filename: string, content: string): CppCodeSource => ({
@@ -208,8 +212,10 @@ describe('cppCode', () => {
208212
created: false,
209213
version: '',
210214
espmethod: 'initSvelteStaticFiles',
211-
define: 'SVELTEESP32'
212-
}
215+
define: 'SVELTEESP32',
216+
exclude: []
217+
},
218+
formatConfiguration: vi.fn((cmdLine) => `engine=${cmdLine.engine}`)
213219
}));
214220

215221
const { getCppCode } = await import('../../src/cppCode');
@@ -231,8 +237,10 @@ describe('cppCode', () => {
231237
created: false,
232238
version: '',
233239
espmethod: 'initSvelteStaticFiles',
234-
define: 'SVELTEESP32'
235-
}
240+
define: 'SVELTEESP32',
241+
exclude: []
242+
},
243+
formatConfiguration: vi.fn((cmdLine) => `engine=${cmdLine.engine}`)
236244
}));
237245

238246
const { getCppCode } = await import('../../src/cppCode');
@@ -254,8 +262,10 @@ describe('cppCode', () => {
254262
created: false,
255263
version: '',
256264
espmethod: 'initSvelteStaticFiles',
257-
define: 'SVELTEESP32'
258-
}
265+
define: 'SVELTEESP32',
266+
exclude: []
267+
},
268+
formatConfiguration: vi.fn((cmdLine) => `engine=${cmdLine.engine}`)
259269
}));
260270

261271
const { getCppCode } = await import('../../src/cppCode');
@@ -278,8 +288,10 @@ describe('cppCode', () => {
278288
created: false,
279289
version: '',
280290
espmethod: 'initSvelteStaticFiles',
281-
define: 'SVELTEESP32'
282-
}
291+
define: 'SVELTEESP32',
292+
exclude: []
293+
},
294+
formatConfiguration: vi.fn((cmdLine) => `engine=${cmdLine.engine}`)
283295
}));
284296

285297
const { getCppCode } = await import('../../src/cppCode');
@@ -303,8 +315,10 @@ describe('cppCode', () => {
303315
created: false,
304316
version: '',
305317
espmethod: 'initSvelteStaticFiles',
306-
define: 'SVELTEESP32'
307-
}
318+
define: 'SVELTEESP32',
319+
exclude: []
320+
},
321+
formatConfiguration: vi.fn((cmdLine) => `engine=${cmdLine.engine}`)
308322
}));
309323

310324
const { getCppCode } = await import('../../src/cppCode');
@@ -327,8 +341,10 @@ describe('cppCode', () => {
327341
created: false,
328342
version: '',
329343
espmethod: 'initSvelteStaticFiles',
330-
define: 'SVELTEESP32'
331-
}
344+
define: 'SVELTEESP32',
345+
exclude: []
346+
},
347+
formatConfiguration: vi.fn((cmdLine) => `engine=${cmdLine.engine}`)
332348
}));
333349

334350
const { getCppCode } = await import('../../src/cppCode');

0 commit comments

Comments
 (0)