Skip to content

Commit c34b7fc

Browse files
chore: upgrade to typescript 4.3.5
1 parent b14b179 commit c34b7fc

File tree

8 files changed

+82
-52
lines changed

8 files changed

+82
-52
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,25 @@ You can erase the persistent flash memory, which will be equivalent to a factory
142142
<sup>1</sup> SSL client connections currently not working properly for ESP32-S2 devices due to esp-idf bug in 4.2.x:
143143
https://github.com/espressif/esp-idf/pull/6998 , but can be fixed manually (see changes in PR).
144144

145+
## REPL
146+
147+
The [examples](examples/) directory contains a [repl](examples/repl.js) that can be used as JS OTA Url:
148+
https://raw.githubusercontent.com/marcelkottmann/esp32-javascript/http-streaming/examples/repl.js
149+
150+
The repl can be used with netcat directly or with a combination of rlwrap and netcat to have a history-support:
151+
`rlwrap netcat [IP-ADDRESS] 1234`
152+
153+
Enter username and password separated with colon(`:`) to authenticate, e.g. `esp32:esp32` + Enter
154+
155+
```bash
156+
~/esp/esp32-javascript> rlwrap netcat 192.168.188.24 1234
157+
> esp32:esp32
158+
====> authorized.
159+
> console.log('Hello world.')
160+
LOG|Hello world.
161+
====> undefined
162+
>
163+
```
145164
## API
146165

147166
[API documentation](docs/README.md)

components/esp32-javascript/modules/esp32-javascript/configserver.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ function startConfigServer() {
182182
res.headers.set("WWW-Authenticate", 'Basic realm="Enter credentials"');
183183
res.end("401 Unauthorized");
184184
}
185+
else if (req.path === "/health") {
186+
res.end(JSON.stringify({ status: "ok" }));
187+
}
185188
else if (req.path === "/restart" && req.method === "POST") {
186189
page(res, "Restart", '<div class="formpad green">Restarting... please wait. <a href="/">Home</a></div>', function () {
187190
setTimeout(restart, 1000);

components/esp32-javascript/modules/esp32-javascript/configserver.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ export function startConfigServer(): void {
255255
res.setStatus(401);
256256
res.headers.set("WWW-Authenticate", 'Basic realm="Enter credentials"');
257257
res.end("401 Unauthorized");
258+
} else if (req.path === "/health") {
259+
res.end(JSON.stringify({ status: "ok" }));
258260
} else if (req.path === "/restart" && req.method === "POST") {
259261
page(
260262
res,

components/esp32-javascript/modules/esp32-javascript/native-ota.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function upgradeModules(partition, modulesImageUrl, submitSuccess, submitError)
9999
}, assertStatusCode(200, modulesImageUrl));
100100
return client;
101101
}
102-
exports.upgrade = function (appImageUrl, modulesImageUrl, onError, onFinish) {
102+
var upgrade = function (appImageUrl, modulesImageUrl, onError, onFinish) {
103103
if (!el_is_native_ota_supported()) {
104104
onError && onError("Native OTA is not supported.");
105105
return;
@@ -142,3 +142,4 @@ exports.upgrade = function (appImageUrl, modulesImageUrl, onError, onFinish) {
142142
upgradeModules(partition, modulesImageUrl, submitSuccess, submitError),
143143
];
144144
};
145+
exports.upgrade = upgrade;

package-lock.json

Lines changed: 3 additions & 3 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
@@ -28,6 +28,6 @@
2828
"eslint-plugin-inclusive-language": "^1.2.1",
2929
"typedoc": "^0.17.8",
3030
"typedoc-plugin-markdown": "^2.4.2",
31-
"typescript": "^3.9.9"
31+
"typescript": "4.3.5"
3232
}
3333
}

scripts/cp2/cp2.js

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env node
2-
const fs = require('fs');
3-
const path = require('path');
2+
const fs = require("fs");
3+
const path = require("path");
44

5-
const glob = require('glob');
6-
const meow = require('meow');
5+
const glob = require("glob");
6+
const meow = require("meow");
77

88
async function main() {
9-
10-
const cli = meow(`
9+
const cli = meow(
10+
`
1111
Usage of cp2
1212
1313
$ cp2 [--dry-run] [--verbose] SRC EXPR
@@ -25,52 +25,56 @@ async function main() {
2525
2626
Please use single-quotes enclosed arguments to protect glob and expression
2727
from interpretion by your shell.
28-
`, {
29-
flags: {
30-
'dry-run': {
31-
type: 'boolean',
32-
},
33-
'verbose': {
34-
type: 'boolean',
35-
},
36-
'move': {
37-
type: 'boolean',
38-
}
39-
}
40-
});
41-
42-
if (cli.input.length < 2) {
43-
console.error(cli.help);
44-
process.exit(1);
28+
`,
29+
{
30+
flags: {
31+
"dry-run": {
32+
type: "boolean",
33+
},
34+
verbose: {
35+
type: "boolean",
36+
},
37+
move: {
38+
type: "boolean",
39+
},
40+
},
4541
}
42+
);
4643

47-
const files = glob.sync(cli.input[0]);
44+
if (cli.input.length < 2) {
45+
console.error(cli.help);
46+
process.exit(1);
47+
}
4848

49-
let findReplace;
50-
try {
51-
findReplace = eval(cli.input.slice(1).join(' '));
52-
} catch (error) {
53-
console.error('javascript find-replace-function contains error:');
54-
console.error(error);
55-
process.exit(2);
56-
}
49+
const files = glob.sync(cli.input[0], {
50+
ignore: ["**/node_modules/**"],
51+
});
5752

58-
files.forEach(f => {
59-
let target = findReplace.call(findReplace, f);
53+
let findReplace;
54+
try {
55+
findReplace = eval(cli.input.slice(1).join(" "));
56+
} catch (error) {
57+
console.error("javascript find-replace-function contains error:");
58+
console.error(error);
59+
process.exit(2);
60+
}
6061

61-
if (f === target) {
62-
console.log(`ommiting ${f}: src and target are equal`)
63-
} else {
64-
if (cli.flags.verbose) {
65-
console.log(`${cli.flags.move ? 'mv' : 'cp'} ${f} ==> ${target}`);
66-
}
62+
files.forEach((f) => {
63+
let target = findReplace.call(findReplace, f);
6764

68-
if (!cli.flags.dryRun) {
69-
fs.mkdirSync(path.dirname(target), { recursive: true });
70-
cli.flags.move ? fs.renameSync(f, target) : fs.copyFileSync(f, target);
71-
}
72-
}
73-
});
65+
if (f === target) {
66+
console.log(`ommiting ${f}: src and target are equal`);
67+
} else {
68+
if (cli.flags.verbose) {
69+
console.log(`${cli.flags.move ? "mv" : "cp"} ${f} ==> ${target}`);
70+
}
71+
72+
if (!cli.flags.dryRun) {
73+
fs.mkdirSync(path.dirname(target), { recursive: true });
74+
cli.flags.move ? fs.renameSync(f, target) : fs.copyFileSync(f, target);
75+
}
76+
}
77+
});
7478
}
7579

7680
main();

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
"*": [
1616
"esp32-javascript/modules/*",
1717
"wifi-events/modules/*",
18-
"socket-events/modules/*"
18+
"socket-events/modules/*",
1919
]
2020
},
21+
"noEmitOnError": true,
2122
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
2223
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
2324
},

0 commit comments

Comments
 (0)