Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.12.1] - 2025-12-04

### Changed

- **Configuration Display in Generated Headers**: Renamed `//cmdline:` to `//config:` in all generated header files
- Now displays effective configuration values regardless of source (RC file, CLI arguments, or both)
- Shows all active configuration parameters: `engine`, `sourcepath`, `outputfile`, `etag`, `gzip`, `cachetime`, `espmethod`, `define`, and `exclude` patterns
- Provides complete traceability of configuration used for code generation
- Format: `//config: engine=psychic sourcepath=./dist outputfile=./output.h etag=true gzip=true ...`

### Fixed

- Configuration comment in generated headers now displays values when using RC file (previously showed empty when using RC file without CLI arguments)

## [1.12.0] - 2025-12-04

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

[1.12.1]: https://github.com/BCsabaEngine/svelteesp32/compare/v1.12.0...v1.12.1
[1.12.0]: https://github.com/BCsabaEngine/svelteesp32/compare/v1.11.0...v1.12.0
[1.11.0]: https://github.com/BCsabaEngine/svelteesp32/compare/v1.10.0...v1.11.0
[1.10.0]: https://github.com/BCsabaEngine/svelteesp32/compare/v1.9.4...v1.10.0
Expand Down
16 changes: 16 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,19 @@ The generated header file includes C++ defines for build-time validation:
- `{PREFIX}_{EXT}_FILES`: Count of files by extension (e.g., `SVELTEESP32_CSS_FILES`)

These allow C++ code to verify expected files are present using `#ifndef` and `#error` directives.

## Generated Header Configuration Comment

The generated header file includes a `//config:` comment at the top that displays the effective configuration used during code generation:

```cpp
//engine: PsychicHttpServer
//config: engine=psychic sourcepath=./dist outputfile=./output.h etag=true gzip=true cachetime=0 espmethod=initSvelteStaticFiles define=SVELTEESP32 exclude=[*.map, *.md]
```

**Implementation** (`src/commandLine.ts`, `src/cppCode.ts`):

- `formatConfiguration()` function creates a formatted string from the `ICopyFilesArguments` object
- Shows all configuration parameters: `engine`, `sourcepath`, `outputfile`, `etag`, `gzip`, `cachetime`, `espmethod`, `define`, and `exclude` patterns
- Works consistently whether configuration comes from RC file, CLI arguments, or both
- Provides complete traceability of the configuration used for code generation
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ The content of **generated file** (do not edit, just use):

```c
//engine: PsychicHttpServer
//cmdline: -e psychic -s ./dist -o ./output.h --etag=true --gzip=true
//config: engine=psychic sourcepath=./dist outputfile=./output.h etag=true gzip=true cachetime=0 espmethod=initSvelteStaticFiles define=SVELTEESP32
//
#define SVELTEESP32_COUNT 5
#define SVELTEESP32_SIZE 468822
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "svelteesp32",
"version": "1.12.0",
"version": "1.12.1",
"description": "Convert Svelte (or any frontend) JS application to serve it from ESP32 webserver (PsychicHttp)",
"author": "BCsabaEngine",
"license": "ISC",
Expand Down
23 changes: 23 additions & 0 deletions src/commandLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,29 @@ function parseArguments(): ICopyFilesArguments {
return result as ICopyFilesArguments;
}

export function formatConfiguration(cmdLine: ICopyFilesArguments): string {
const parts: string[] = [
`engine=${cmdLine.engine}`,
`sourcepath=${cmdLine.sourcepath}`,
`outputfile=${cmdLine.outputfile}`,
`etag=${cmdLine.etag}`,
`gzip=${cmdLine.gzip}`,
`cachetime=${cmdLine.cachetime}`
];

if (cmdLine.created) parts.push(`created=${cmdLine.created}`);

if (cmdLine.version) parts.push(`version=${cmdLine.version}`);

if (cmdLine.espmethod) parts.push(`espmethod=${cmdLine.espmethod}`);

if (cmdLine.define) parts.push(`define=${cmdLine.define}`);

if (cmdLine.exclude.length > 0) parts.push(`exclude=[${cmdLine.exclude.join(', ')}]`);

return parts.join(' ');
}

export const cmdLine = parseArguments();

if (!existsSync(cmdLine.sourcepath) || !statSync(cmdLine.sourcepath).isDirectory()) {
Expand Down
10 changes: 5 additions & 5 deletions src/cppCode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { compile as handlebarsCompile, HelperOptions } from 'handlebars';

import { cmdLine } from './commandLine';
import { cmdLine, formatConfiguration } from './commandLine';
import { espidfTemplate } from './cppCodeEspIdf';

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

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

const psychic2Template = `
//engine: PsychicHttpServerV2
//cmdline: {{{commandLine}}}
//config: {{{config}}}
{{#if created }}
//created: {{now}}
{{/if}}
Expand Down Expand Up @@ -344,7 +344,7 @@ void {{methodName}}(PsychicHttpServer * server) {

const asyncTemplate = `
//engine: ESPAsyncWebServer
//cmdline: {{{commandLine}}}
//config: {{{config}}}
{{#if created }}
//created: {{now}}
{{/if}}
Expand Down Expand Up @@ -573,7 +573,7 @@ const createHandlebarsHelpers = () => {
export const getCppCode = (sources: CppCodeSources, filesByExtension: ExtensionGroups): string => {
const template = handlebarsCompile(getTemplate(cmdLine.engine));
const templateData = {
commandLine: process.argv.slice(2).join(' '),
config: formatConfiguration(cmdLine),
now: `${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,
fileCount: sources.length.toString(),
fileSize: sources.reduce((previous, current) => previous + current.content.length, 0).toString(),
Expand Down
2 changes: 1 addition & 1 deletion src/cppCodeEspIdf.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const espidfTemplate = `
//engine: espidf
//cmdline: {{{commandLine}}}
//config: {{{config}}}
{{#if created }}
//created: {{now}}
{{/if}}
Expand Down
44 changes: 30 additions & 14 deletions test/unit/cppCode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ vi.mock('../../src/commandLine', () => ({
created: false,
version: 'v1.0.0',
espmethod: 'initSvelteStaticFiles',
define: 'SVELTEESP32'
}
define: 'SVELTEESP32',
exclude: []
},
formatConfiguration: vi.fn((cmdLine) => {
return `engine=${cmdLine.engine} sourcepath=${cmdLine.sourcepath} outputfile=${cmdLine.outputfile} etag=${cmdLine.etag} gzip=${cmdLine.gzip} cachetime=${cmdLine.cachetime}`;
})
}));

const createMockSource = (filename: string, content: string): CppCodeSource => ({
Expand Down Expand Up @@ -208,8 +212,10 @@ describe('cppCode', () => {
created: false,
version: '',
espmethod: 'initSvelteStaticFiles',
define: 'SVELTEESP32'
}
define: 'SVELTEESP32',
exclude: []
},
formatConfiguration: vi.fn((cmdLine) => `engine=${cmdLine.engine}`)
}));

const { getCppCode } = await import('../../src/cppCode');
Expand All @@ -231,8 +237,10 @@ describe('cppCode', () => {
created: false,
version: '',
espmethod: 'initSvelteStaticFiles',
define: 'SVELTEESP32'
}
define: 'SVELTEESP32',
exclude: []
},
formatConfiguration: vi.fn((cmdLine) => `engine=${cmdLine.engine}`)
}));

const { getCppCode } = await import('../../src/cppCode');
Expand All @@ -254,8 +262,10 @@ describe('cppCode', () => {
created: false,
version: '',
espmethod: 'initSvelteStaticFiles',
define: 'SVELTEESP32'
}
define: 'SVELTEESP32',
exclude: []
},
formatConfiguration: vi.fn((cmdLine) => `engine=${cmdLine.engine}`)
}));

const { getCppCode } = await import('../../src/cppCode');
Expand All @@ -278,8 +288,10 @@ describe('cppCode', () => {
created: false,
version: '',
espmethod: 'initSvelteStaticFiles',
define: 'SVELTEESP32'
}
define: 'SVELTEESP32',
exclude: []
},
formatConfiguration: vi.fn((cmdLine) => `engine=${cmdLine.engine}`)
}));

const { getCppCode } = await import('../../src/cppCode');
Expand All @@ -303,8 +315,10 @@ describe('cppCode', () => {
created: false,
version: '',
espmethod: 'initSvelteStaticFiles',
define: 'SVELTEESP32'
}
define: 'SVELTEESP32',
exclude: []
},
formatConfiguration: vi.fn((cmdLine) => `engine=${cmdLine.engine}`)
}));

const { getCppCode } = await import('../../src/cppCode');
Expand All @@ -327,8 +341,10 @@ describe('cppCode', () => {
created: false,
version: '',
espmethod: 'initSvelteStaticFiles',
define: 'SVELTEESP32'
}
define: 'SVELTEESP32',
exclude: []
},
formatConfiguration: vi.fn((cmdLine) => `engine=${cmdLine.engine}`)
}));

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