UNPKG

svelteesp32

Version:

Convert Svelte (or any frontend) JS application to serve it from ESP32 webserver (PsychicHttp)

95 lines (94 loc) 3.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cmdLine = void 0; const node_fs_1 = require("node:fs"); const ts_command_line_args_1 = require("ts-command-line-args"); exports.cmdLine = (0, ts_command_line_args_1.parse)({ engine: { type: (value) => { if (value === 'psychic') return 'psychic'; if (value === 'psychic2') return 'psychic2'; if (value === 'async') return 'async'; if (value === 'espidf') return 'espidf'; throw new Error(`Invalid engine: ${value}`); }, alias: 'e', description: 'The engine for which the include file is created (psychic|psychic2|async)', defaultValue: 'psychic' }, sourcepath: { type: String, alias: 's', description: 'Source dist folder contains compiled web files' }, outputfile: { type: String, alias: 'o', description: 'Generated output file with path', defaultValue: 'svelteesp32.h' }, 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: 'Use ETAG header for cache', defaultValue: 'false' }, 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: '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, description: 'Name of generated method', defaultValue: 'initSvelteStaticFiles' }, define: { type: String, description: 'Prefix of c++ defines', defaultValue: 'SVELTEESP32' }, cachetime: { type: Number, description: 'max-age cache time in seconds', defaultValue: 0 }, help: { type: Boolean, optional: true, alias: 'h', description: 'Shows this help' } }, { helpArg: 'help', headerContentSections: [{ header: 'svelteesp32', content: 'Svelte JS to ESP32 converter' }] }); if (!(0, node_fs_1.existsSync)(exports.cmdLine.sourcepath) || !(0, node_fs_1.statSync)(exports.cmdLine.sourcepath).isDirectory()) { console.error(`Directory ${exports.cmdLine.sourcepath} not exists or not a directory`); process.exit(1); } console.log(`[SvelteESP32] Generate code for ${exports.cmdLine.engine} engine`);