Skip to content

Commit

Permalink
feat: created and version info
Browse files Browse the repository at this point in the history
  • Loading branch information
BCsabaEngine committed Aug 15, 2024
1 parent 5624bc5 commit c4225a7
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 39 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ During the translation process, data in gzip format is generated and will be use

Automatic compression can be turned off with the `--gzip=false` option.

> This setting has three states: yes, no, and compiler mode is available. In compiler mode, you can disable/enable Gzip by setting the `SVELTEESP32_ENABLE_GZIP` c++ compiler directive.
> For example, if using platformio, you can use `-D SVELTEESP32_ENABLE_GZIP`.
> This setting has three states: yes, no, and compiler mode is available. In compiler mode, you can disable/enable Gzip by setting the `SVELTEESP32_ENABLE_GZIP` c++ compiler directive. For example, if using platformio, just write `-D SVELTEESP32_ENABLE_GZIP`.
### ETag

Expand All @@ -175,8 +174,7 @@ Since microcontroller data traffic is moderately expensive, it is an individual

The use of ETag is **not enabled by default**, this can be achieved with the `--etag=true` switch.

> This setting has three states: yes, no, and compiler mode is available. In compiler mode, you can disable/enable ETag by setting the `SVELTEESP32_ENABLE_ETAG` c++ compiler directive.
> For example, if using platformio, you can use `-D SVELTEESP32_ENABLE_ETAG`.
> This setting has three states: yes, no, and compiler mode is available. In compiler mode, you can disable/enable ETag by setting the `SVELTEESP32_ENABLE_ETAG` c++ compiler directive. For example, if using platformio, just type `-D SVELTEESP32_ENABLE_ETAG`.
### Main entry point - index.html

Expand Down Expand Up @@ -227,16 +225,18 @@ You can use the following c++ directives at the project level if you want to con

### Command line options

| Option | Description | default |
| ------------- | ---------------------------------------------------------------- | ----------------------- |
| `-s` | **Source dist folder contains compiled web files** | |
| `-e` | The engine for which the include file is created (psychic/async) | psychic |
| `-o` | Generated output file with path | `svelteesp32.h` |
| `--etag` | Use ETag header for cache (true/false/compiler) | false |
| `--gzip` | Compress content with gzip (true/false/compiler) | true |
| `--espmethod` | Name of generated method | `initSvelteStaticFiles` |
| `--define` | Prefix of c++ defines | `SVELTEESP32` |
| `-h` | Show help | |
| Option | Description | default |
| ------------- | ------------------------------------------------------------------------ | ----------------------- |
| `-s` | **Source dist folder contains compiled web files** | |
| `-e` | The engine for which the include file is created (psychic/async) | psychic |
| `-o` | Generated output file with path | `svelteesp32.h` |
| `--etag` | Use ETag header for cache (true/false/compiler) | false |
| `--gzip` | Compress content with gzip (true/false/compiler) | true |
| `--created` | Include creation time (now) in the output file | false |
| `--version` | Include version info (ex. from frontend package.json) in the output file | '' |
| `--espmethod` | Name of generated method | `initSvelteStaticFiles` |
| `--define` | Prefix of c++ defines | `SVELTEESP32` |
| `-h` | Show help | |

### Q&A

Expand Down
12 changes: 5 additions & 7 deletions demo/esp32/include/svelteesp32async.h

Large diffs are not rendered by default.

14 changes: 6 additions & 8 deletions demo/esp32/include/svelteesp32psychic.h

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
},
"homepage": "https://github.com/BCsabaEngine/svelteesp32",
"scripts": {
"dev:async": "nodemon src/index.ts -- -e async -s ./demo/svelte/dist -o ./demo/esp32/include/svelteesp32async.h --etag=compiler --gzip=compiler",
"dev:psychic": "nodemon src/index.ts -- -e psychic -s ./demo/svelte/dist -o ./demo/esp32/include/svelteesp32psychic.h --etag=compiler --gzip=compiler",
"run:async": "tsx src/index.ts -e async -s ./demo/svelte/dist -o ./demo/esp32/include/svelteesp32async.h --etag=compiler --gzip=compiler",
"run:psychic": "tsx src/index.ts -e psychic -s ./demo/svelte/dist -o ./demo/esp32/include/svelteesp32psychic.h --etag=compiler --gzip=compiler",
"dev:async": "nodemon src/index.ts -- -e async -s ./demo/svelte/dist -o ./demo/esp32/include/svelteesp32async.h --etag=compiler --gzip=compiler --created --version=v1.5.0",
"dev:psychic": "nodemon src/index.ts -- -e psychic -s ./demo/svelte/dist -o ./demo/esp32/include/svelteesp32psychic.h --etag=compiler --gzip=compiler --version=v1.5.0",
"run:async": "tsx src/index.ts -e async -s ./demo/svelte/dist -o ./demo/esp32/include/svelteesp32async.h --etag=compiler --gzip=compiler --version=v1.5.0",
"run:psychic": "tsx src/index.ts -e psychic -s ./demo/svelte/dist -o ./demo/esp32/include/svelteesp32psychic.h --etag=compiler --gzip=compiler --version=v1.5.0",
"run:both": "npm run run:async && npm run run:psychic",
"platformio": "~/.platformio/penv/bin/pio run -d ./demo/esp32",
"run:both:build": "npm run run:both && npm run platformio",
Expand Down
24 changes: 18 additions & 6 deletions src/commandLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ interface ICopyFilesArguments {
define: string;
gzip: 'true' | 'false' | 'compiler';
etag: 'true' | 'false' | 'compiler';
created: boolean;
version: string;
help?: boolean;
}

Expand All @@ -36,25 +38,35 @@ export const cmdLine = parse<ICopyFilesArguments>(
description: 'Generated output file with path',
defaultValue: 'svelteesp32.h'
},
gzip: {
etag: {
type: (value) => {
if (value === 'true') return 'true';
if (value === 'false') return 'false';
if (value === 'compiler') return 'compiler';
throw new Error(`Invalid etag: ${value}`);
},
description: 'Compress content with gzip',
defaultValue: 'true'
description: 'Use ETAG header for cache',
defaultValue: 'false'
},
etag: {
gzip: {
type: (value) => {
if (value === 'true') return 'true';
if (value === 'false') return 'false';
if (value === 'compiler') return 'compiler';
throw new Error(`Invalid etag: ${value}`);
},
description: 'Use ETAG header for cache',
defaultValue: 'false'
description: 'Compress content with gzip',
defaultValue: 'true'
},
created: {
type: Boolean,
description: 'Include creation time in the output file',
defaultValue: false
},
version: {
type: String,
description: 'Include version info in the output file',
defaultValue: ''
},
espmethod: {
type: String,
Expand Down

0 comments on commit c4225a7

Please sign in to comment.