xs-dev 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -6
- package/build/commands/include.js +24 -5
- package/build/commands/init.js +61 -25
- package/build/commands/remove.js +30 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ npm install -g xs-dev
|
|
|
37
37
|
## Update
|
|
38
38
|
|
|
39
39
|
```
|
|
40
|
-
npm update -g xs-dev
|
|
40
|
+
npm update -g xs-dev
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
## Features
|
|
@@ -185,12 +185,32 @@ Flags:
|
|
|
185
185
|
xs-dev init my-project
|
|
186
186
|
```
|
|
187
187
|
|
|
188
|
-
Creates a `main.js` and
|
|
188
|
+
Creates a `main.js` and minimally configured `manifest.json` for running in the simulator.
|
|
189
189
|
|
|
190
190
|
Flags:
|
|
191
191
|
|
|
192
192
|
- `typescript`: includes typings and creates `main.ts` (experimental)
|
|
193
193
|
- `io`: includes [TC53 IO manifest](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/io/io.md)
|
|
194
|
+
- `example`: use [Moddable example project](https://github.com/Moddable-OpenSource/moddable/tree/public/examples) as base for new project
|
|
195
|
+
- `overwrite`: replace any existing directory of the same name
|
|
196
|
+
|
|
197
|
+
For the example flag, it can be used as a boolean to select a project from a list:
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
xs-dev init my-project --example
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Or select from a filtered list of projects:
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
xs-dev init my-project --example http
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Or if the complete example name is passed, it will be selected by default:
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
xs-dev init my-project --example network/mqtt/mqttbasic
|
|
213
|
+
```
|
|
194
214
|
|
|
195
215
|
### Build and run a project
|
|
196
216
|
|
|
@@ -211,7 +231,7 @@ Flags:
|
|
|
211
231
|
- `device`: `esp8266` | `esp32` | `pico` | [any of the allowed platform identifiers](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md#arguments) (defaults to current OS platform)
|
|
212
232
|
- `port`: path to port for connected device (defaults to: `UPLOAD_PORT` environment variable)
|
|
213
233
|
|
|
214
|
-
### Add a Moddable module
|
|
234
|
+
### Add a Moddable SDK module
|
|
215
235
|
|
|
216
236
|
```
|
|
217
237
|
xs-dev include network/wifi
|
|
@@ -221,9 +241,18 @@ Or select from available modules:
|
|
|
221
241
|
|
|
222
242
|
```
|
|
223
243
|
xs-dev include
|
|
244
|
+
xs-dev include files
|
|
224
245
|
```
|
|
225
246
|
|
|
226
|
-
Updates the `manifest.json`
|
|
247
|
+
Updates the `manifest.json` to include the module.
|
|
248
|
+
|
|
249
|
+
Flags:
|
|
250
|
+
|
|
251
|
+
- `device`: When this flag is present, the module is added to the `platforms` section for the specified device. When `device` is not provided, the module is added to the global manifest section to be used for all devices. For example, the following adds the module for use on `esp32` devices only:
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
xs-dev include files/flash --device esp32
|
|
255
|
+
```
|
|
227
256
|
|
|
228
257
|
### Scan for available devices
|
|
229
258
|
|
|
@@ -255,13 +284,27 @@ To include a specific module for the installed dependency:
|
|
|
255
284
|
xs-dev include j5e/lib/led
|
|
256
285
|
```
|
|
257
286
|
|
|
258
|
-
### Remove a
|
|
287
|
+
### Remove a Moddable SDK module
|
|
259
288
|
|
|
260
289
|
```
|
|
261
290
|
xs-dev remove network/wifi
|
|
262
291
|
```
|
|
263
292
|
|
|
264
|
-
Updates the `manifest.json` to remove the
|
|
293
|
+
Updates the `manifest.json` to remove the module.
|
|
294
|
+
|
|
295
|
+
Or remove all modules that contain a string. This removes all modules that contain `"wifi"`.
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
xs-dev remove wifi
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Flags:
|
|
302
|
+
|
|
303
|
+
- `device`: When this flag is present, the module is removed from the `platforms` section for the specified device. When `device` is not provided, the module is removed from the global manifest section. For example, the following adds the module for use on `esp32` devices only:
|
|
304
|
+
|
|
305
|
+
```
|
|
306
|
+
xs-dev remove network/mqtt --device esp32
|
|
307
|
+
```
|
|
265
308
|
|
|
266
309
|
## Development
|
|
267
310
|
|
|
@@ -13,6 +13,7 @@ const command = {
|
|
|
13
13
|
}
|
|
14
14
|
const modulesPath = filesystem.resolve(String(process.env.MODDABLE), 'modules');
|
|
15
15
|
let moduleName = parameters.first;
|
|
16
|
+
const { device = "" } = parameters.options;
|
|
16
17
|
if (moduleName === undefined ||
|
|
17
18
|
filesystem.exists(filesystem.resolve(modulesPath, moduleName, 'manifest.json')) === false) {
|
|
18
19
|
// prompt with choices from $MODDABLE/modules
|
|
@@ -20,23 +21,41 @@ const command = {
|
|
|
20
21
|
const choices = modules !== undefined
|
|
21
22
|
? modules.map((mod) => (0, choices_1.collectChoicesFromTree)(mod)).flat()
|
|
22
23
|
: [];
|
|
24
|
+
const filtered = (moduleName !== undefined) ? choices.filter((mod) => mod.includes(String(moduleName))) : choices;
|
|
23
25
|
const { mod: selectedModule } = await prompt.ask([
|
|
24
26
|
{
|
|
25
27
|
type: 'autocomplete',
|
|
26
28
|
name: 'mod',
|
|
27
29
|
message: 'Here are the available modules:',
|
|
28
|
-
choices,
|
|
30
|
+
choices: (filtered.length > 0) ? filtered : choices,
|
|
29
31
|
},
|
|
30
32
|
]);
|
|
31
33
|
moduleName = selectedModule;
|
|
32
34
|
}
|
|
33
35
|
print.info(`Adding "${String(moduleName)}" to manifest includes`);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
const modulePath = `$(MODDABLE)/modules/${String(moduleName)}/manifest.json`;
|
|
37
|
+
await patching.update(manifestPath, (manifestIn) => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
var _c;
|
|
40
|
+
let manifest = manifestIn;
|
|
41
|
+
if (device !== "") {
|
|
42
|
+
(_a = manifest.platforms) !== null && _a !== void 0 ? _a : (manifest.platforms = {});
|
|
43
|
+
(_b = (_c = manifest.platforms)[device]) !== null && _b !== void 0 ? _b : (_c[device] = {});
|
|
44
|
+
manifest = manifest.platforms[device];
|
|
45
|
+
}
|
|
46
|
+
if (!("include" in manifest))
|
|
47
|
+
manifest.include = [];
|
|
48
|
+
if (typeof manifest.include === "string")
|
|
49
|
+
manifest.include = [manifest.include];
|
|
50
|
+
if (manifest.include.includes(modulePath) === false) {
|
|
51
|
+
manifest.include.push(modulePath);
|
|
52
|
+
}
|
|
53
|
+
if (manifest.include.length === 1)
|
|
54
|
+
manifest.include = manifest.include[0];
|
|
55
|
+
return manifestIn;
|
|
37
56
|
});
|
|
38
57
|
print.success('Done!');
|
|
39
58
|
},
|
|
40
59
|
};
|
|
41
60
|
exports.default = command;
|
|
42
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
61
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5jbHVkZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb21tYW5kcy9pbmNsdWRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQ0EsdURBQWtFO0FBTWxFLE1BQU0sT0FBTyxHQUFtQjtJQUM5QixJQUFJLEVBQUUsU0FBUztJQUNmLFdBQVcsRUFBRSwyREFBMkQ7SUFDeEUsR0FBRyxFQUFFLEtBQUssRUFBRSxFQUFFLE1BQU0sRUFBRSxVQUFVLEVBQUUsUUFBUSxFQUFFLEtBQUssRUFBRSxVQUFVLEVBQUUsRUFBRSxFQUFFOztRQUNqRSxNQUFNLFlBQVksR0FBRyxVQUFVLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsRUFBRSxlQUFlLENBQUMsQ0FBQTtRQUN2RSxJQUFJLFVBQVUsQ0FBQyxNQUF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QTtnQkFDakMsUUFBUSxHQUFHLFFBQVEsQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLENBQUE7YUFDdEM7WUFDRCxJQUFJLENBQUMsQ0FBQyxTQUFTLElBQUksUUFBUSxDQUFDO2dCQUMxQixRQUFRLENBQUMsT0FBTyxHQUFHLEVBQUUsQ0FBQTtZQUN2QixJQUFJLE9BQU8sUUFBUSxDQUFDLE9BQU8sS0FBSyxRQUFRO2dCQUN0QyxRQUFRLENBQUMsT0FBTyxHQUFHLENBQUMsUUFBUSxDQUFDLE9BQU8sQ0FBQyxDQUFBO1lBQ3ZDLElBQUksUUFBUSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsVUFBVSxDQUFDLEtBQUssS0FBSyxFQUFFO2dCQUNuRCxRQUFRLENBQUMsT0FBTyxDQUFDLElBQUksQ0FDbkIsVUFBVSxDQUNYLENBQUE7YUFDRjtZQUNELElBQUksUUFBUSxDQUFDLE9BQU8sQ0FBQyxNQUFNLEtBQUssQ0FBQztnQkFDL0IsUUFBUSxDQUFDLE9BQU8sR0FBRyxRQUFRLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQyxDQUFBO1lBQ3hDLE9BQU8sVUFBVSxDQUFBO1FBQ25CLENBQUMsQ0FBQyxDQUFBO1FBQ0YsS0FBSyxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQTtJQUN4QixDQUFDO0NBQ0YsQ0FBQTtBQUVELGtCQUFlLE9BQU8sQ0FBQSJ9
|
package/build/commands/init.js
CHANGED
|
@@ -1,36 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const choices_1 = require("../toolbox/prompt/choices");
|
|
3
4
|
const command = {
|
|
4
5
|
name: 'init',
|
|
5
6
|
alias: ['i'],
|
|
6
7
|
description: 'Scaffold a new Moddable XS project',
|
|
7
8
|
run: async (toolbox) => {
|
|
8
|
-
|
|
9
|
+
var _a;
|
|
10
|
+
const { parameters, filesystem, template: { generate }, print: { warning, info, success }, prompt, } = toolbox;
|
|
9
11
|
const name = parameters.first;
|
|
10
|
-
const { typescript = false, io = false } = parameters.options;
|
|
12
|
+
const { typescript = false, io = false, example = false, overwrite = false, } = parameters.options;
|
|
11
13
|
if (name !== undefined) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
14
|
+
if (!overwrite && filesystem.isDirectory(name)) {
|
|
15
|
+
warning(`Directory called ${name} already exists. Please pass the --overwrite flag to replace an existing project.`);
|
|
16
|
+
process.exit(0);
|
|
17
|
+
}
|
|
18
|
+
if (example !== false) {
|
|
19
|
+
// find example project
|
|
20
|
+
const exampleProjectPath = filesystem.resolve(String(process.env.MODDABLE), 'examples');
|
|
21
|
+
const examples = (_a = filesystem.inspectTree(exampleProjectPath)) === null || _a === void 0 ? void 0 : _a.children;
|
|
22
|
+
const choices = examples !== undefined
|
|
23
|
+
? examples.map((example) => (0, choices_1.collectChoicesFromTree)(example)).flat()
|
|
24
|
+
: [];
|
|
25
|
+
let selectedExample = choices.find((choice) => choice === example);
|
|
26
|
+
if (example === true || selectedExample === undefined) {
|
|
27
|
+
const filteredChoices = choices.filter((choice) => choice.includes(String(example)));
|
|
28
|
+
({ example: selectedExample } = await prompt.ask([
|
|
29
|
+
{
|
|
30
|
+
type: 'autocomplete',
|
|
31
|
+
name: 'example',
|
|
32
|
+
message: 'Here are the available examples templates:',
|
|
33
|
+
choices: filteredChoices.length > 0 ? filteredChoices : choices,
|
|
34
|
+
},
|
|
35
|
+
]));
|
|
36
|
+
}
|
|
37
|
+
// copy files into new project directory
|
|
38
|
+
if (selectedExample !== '' && selectedExample !== undefined) {
|
|
39
|
+
const selectedExamplePath = filesystem.resolve(exampleProjectPath, selectedExample);
|
|
40
|
+
info(`Generating project directory from ${selectedExample}`);
|
|
41
|
+
filesystem.copy(selectedExamplePath, name);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
warning('Please select an example template to use.');
|
|
45
|
+
process.exit(0);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
info(`Generating Moddable project: ${name}`);
|
|
50
|
+
filesystem.dir(name, { empty: false });
|
|
51
|
+
const includes = [
|
|
52
|
+
io
|
|
53
|
+
? '"$(MODDABLE)/modules/io/manifest.json"'
|
|
54
|
+
: '"$(MODDABLE)/examples/manifest_base.json"',
|
|
55
|
+
typescript && '"$(MODDABLE)/examples/manifest_typings.json"',
|
|
56
|
+
]
|
|
57
|
+
.filter(Boolean)
|
|
58
|
+
.join(',\n\t');
|
|
59
|
+
await generate({
|
|
60
|
+
template: 'manifest.json.ejs',
|
|
61
|
+
target: `${name}/manifest.json`,
|
|
62
|
+
props: { includes },
|
|
63
|
+
});
|
|
64
|
+
await generate({
|
|
65
|
+
template: 'main.js.ejs',
|
|
66
|
+
target: `${name}/main.${typescript ? 'ts' : 'js'}`,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
success(`Run the project using: cd ${name} && xs-dev run`);
|
|
34
70
|
}
|
|
35
71
|
else {
|
|
36
72
|
warning('Name is required to generate project: xs-dev init my-project-name');
|
|
@@ -38,4 +74,4 @@ const command = {
|
|
|
38
74
|
},
|
|
39
75
|
};
|
|
40
76
|
exports.default = command;
|
|
41
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
77
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5pdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb21tYW5kcy9pbml0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QUU7aUJBQ3BCLENBQUMsQ0FBQTtnQkFFRixNQUFNLFFBQVEsQ0FBQztvQkFDYixRQUFRLEVBQUUsYUFBYTtvQkFDdkIsTUFBTSxFQUFFLEdBQUcsSUFBSSxTQUFTLFVBQVUsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxJQUFJLEVBQUU7aUJBQ25ELENBQUMsQ0FBQTthQUNIO1lBRUQsT0FBTyxDQUFDLDZCQUE2QixJQUFJLGdCQUFnQixDQUFDLENBQUE7U0FDM0Q7YUFBTTtZQUNMLE9BQU8sQ0FDTCxtRUFBbUUsQ0FDcEUsQ0FBQTtTQUNGO0lBQ0gsQ0FBQztDQUNGLENBQUE7QUFFRCxrQkFBZSxPQUFPLENBQUEifQ==
|
package/build/commands/remove.js
CHANGED
|
@@ -10,17 +10,42 @@ const command = {
|
|
|
10
10
|
process.exit(1);
|
|
11
11
|
}
|
|
12
12
|
const moduleName = parameters.first;
|
|
13
|
+
const { device = "" } = parameters.options;
|
|
13
14
|
if (moduleName === undefined) {
|
|
14
15
|
print.error('Module name is required');
|
|
15
16
|
process.exit(1);
|
|
16
17
|
}
|
|
17
|
-
print.info(`Removing "${String(moduleName)}"
|
|
18
|
-
await patching.update(manifestPath, (
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
print.info(`Removing "${String(moduleName)}" from manifest includes`);
|
|
19
|
+
await patching.update(manifestPath, (manifestIn) => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
var _c;
|
|
22
|
+
let manifest = manifestIn;
|
|
23
|
+
if (device !== "") {
|
|
24
|
+
(_a = manifest.platforms) !== null && _a !== void 0 ? _a : (manifest.platforms = {});
|
|
25
|
+
(_b = (_c = manifest.platforms)[device]) !== null && _b !== void 0 ? _b : (_c[device] = {});
|
|
26
|
+
manifest = manifest.platforms[device];
|
|
27
|
+
}
|
|
28
|
+
if (!("include" in manifest))
|
|
29
|
+
return;
|
|
30
|
+
if (typeof manifest.include === "string")
|
|
31
|
+
manifest.include = [manifest.include];
|
|
32
|
+
const length = manifest.include.length;
|
|
33
|
+
manifest.include = manifest.include.filter((mod) => {
|
|
34
|
+
const result = !mod.includes(moduleName);
|
|
35
|
+
if (!result)
|
|
36
|
+
print.info(` Removing: ${mod}`);
|
|
37
|
+
return result;
|
|
38
|
+
});
|
|
39
|
+
if (length === manifest.include.length)
|
|
40
|
+
print.error(`"${moduleName}" not found. No modules removed.`);
|
|
41
|
+
if (manifest.include.length === 1)
|
|
42
|
+
manifest.include = manifest.include[0];
|
|
43
|
+
else if (manifest.include.length === 0)
|
|
44
|
+
delete manifest.include;
|
|
45
|
+
return manifestIn;
|
|
21
46
|
});
|
|
22
47
|
print.success('Done!');
|
|
23
48
|
},
|
|
24
49
|
};
|
|
25
50
|
exports.default = command;
|
|
26
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
51
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVtb3ZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbW1hbmRzL3JlbW92ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQU1BLE1BQU0sT0FBTyxHQUFtQjtJQUM5QixJQUFJLEVBQUUsUUFBUTtJQUNkLFdBQVcsRUFBRSxnRUFBZ0U7SUFDN0UsR0FBRyxFQUFFLEtBQUssRUFBRSxFQUFFLFVBQVUsRUFBRSxRQUFRLEVBQUUsS0FBSyxFQUFFLFVBQVUsRUFBRSxFQUFFLEVBQUU7UUFDekQsTUFBTSxZQUFZLEdBQUcsVUFBVSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLEVBQUUsZUFBZSxDQUFDLENBQUE7UUFDdkUsSUFBSSxVQUFVLENBQUMsTUFBTSxDQUFDLFlBQVksQ0FBQyxLQUFLLEtBQUssRUFBRTtZQUM3QyxLQUFLLENBQUMsS0FBSyxDQUN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
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xs-dev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "CLI for automating the setup and usage of Moddable XS tools",
|
|
5
5
|
"types": "build/types/types.d.ts",
|
|
6
6
|
"bin": {
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"snapupdate": "jest --updateSnapshot",
|
|
72
72
|
"coverage": "jest --coverage"
|
|
73
73
|
},
|
|
74
|
-
"readme": "# CLI for automating the setup and usage of [Moddable XS tools](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/Moddable%20SDK%20-%20Getting%20Started.md)\n\nThe Moddable SDK and associated dev board tooling is incredibly empowering for embedded JS hardware development, however the set up process can be tedious to follow when getting started. This project aims to streamline the install and environment configuration requirements across platforms in just a few commands.\n\n**This project is a work in progress and should be considered pre-1.0.**\n\n**Feature support:**\n\n- [X] [Moddable SDK install & setup](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/Moddable%20SDK%20-%20Getting%20Started.md)\n- [X] [ESP32 SDK setup](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/devices/esp32.md)\n- [X] [ESP8266 SDK setup](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/devices/esp8266.md)\n- [X] [WASM simulator](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/devices/wasm.md)\n- [X] [Raspberry Pi Pico](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/devices/pico.md)\n- [X] Update Moddable SDK\n- [X] Project management, including dependencies\n\n**Platform support:**\n\n- [X] Mac\n- [ ] Windows\n- [X] Linux\n\n## Requirements\n\n[Node.js >= v12](https://nodejs.org/en/)\n\n**On Linux:**\n\nSetup commands rely on [`ssh-askpass`](https://packages.ubuntu.com/bionic/ssh-askpass) to prompt for permission when installing other tools and dependencies.\n\n## Install\n\n```\nnpm install -g xs-dev\n```\n\n## Update\n\n```\nnpm update -g xs-dev@latest\n```\n\n## Features\n\n### Moddable SDK setup / update / teardown\n\nThis process mostly automates the instructions provided by Moddable's \"Getting Started\" documentation with a few exceptions:\n\n- it will not install XCode, just ensures the command line tools are available\n- the `moddable` git repo is cloned into `~/.local/share` instead of a new/existing `~/Projects` directory\n- a symlink for `xsbug.app` is created in `/Applications` for easy access through Launchpad (on Mac)\n\nRun script for initial setup:\n\n```\nxs-dev setup\n```\n\nRun script for updating SDK:\n\n```\nxs-dev update\n```\n\nRemove all setup and environment changes with teardown command:\n\n```\nxs-dev teardown\n```\n\n### ESP32 SDK install / setup\n\nThis process automates the instructions for downloading and building the esp-idf SDK tooling. This tooling will be placed in the `~/.local/share/esp32` directory, which will be created if it doesn't exist.\n\nRun script for platform setup:\n\n```\nxs-dev setup --device=esp32\n```\n\nRun script to confirm the setup:\n\n```\nxs-dev run --example helloworld --device=esp32\n```\n\nFlags:\n\n- `device`: `esp8266` | `esp32` | `pico` | [any of the allowed platform identifiers](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md#arguments) (defaults to current OS platform)\n- `port`: path to port for connected device (defaults to: `UPLOAD_PORT` environment variable)\n\n### ESP8266 SDK install / setup\n\nThis process automates the instructions for downloading all the dependencies for the ESP8266 RTOS SDK. These dependencies will be placed in the `~/.local/share/esp` directory, which will be created if it doesn't exist.\n\nRun script for platform setup:\n\n```\nxs-dev setup --device=esp8266\n```\n\nRun script to confirm the setup:\n\n```\nxs-dev run --example helloworld --device=esp8266\n```\n\nFlags:\n\n- `device`: `esp8266` | `esp32` | `pico` | [any of the allowed platform identifiers](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md#arguments) (defaults to current OS platform)\n- `port`: path to port for connected device (defaults to: `UPLOAD_PORT` environment variable)\n\n### Wasm Simulator install / setup\n\nThis process automates the instructions for downloading all the dependencies for the [wasm simulator](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/devices/wasm.md) and building the Moddable tooling. These dependencies will be placed in `~/.local/share/wasm`, which will be created if it doesn't exist.\n\nRun script for platform setup:\n\n```\nxs-dev setup --device=wasm\n```\n\n_If there are issues building the Moddable wasm tools, please try running `eval $SHELL` or starting a new shell insance before running the setup script again._\n\n\nRun script to confirm the setup:\n\n```\nxs-dev run --example helloworld --device=wasm\n```\n\n### Raspberry Pi Pico SDK install / setup\n\nThis process automates the instructions for downloading all the dependencies for the Pico SDK. These dependencies will be placed in the `~/.local/share/pico` directory, which will be created if it doesn't exist.\n\nRun script for platform setup:\n\n```\nxs-dev setup --device=pico\n```\n\nRun script to confirm the setup:\n\n```\nxs-dev run --example helloworld --device=pico\n```\n\nFlags:\n\n- `device`: `esp8266` | `esp32` | `pico` | [any of the allowed platform identifiers](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md#arguments) (defaults to current OS platform)\n- `port`: path to port for connected device (defaults to: `UPLOAD_PORT` environment variable)\n\n### Run Moddable examples\n\nWhile it is still possible to run the Moddable example projects in the documented workflow:\n\n```\ncd $MODDABLE/examples/<example directory>\nmcconfig -d -m -p <platform here>\n```\n\nThis tool aims to simplify that process.\n\nList available examples:\n```\nxs-dev run --list-examples\n```\n\nRun an example:\n```\nxs-dev run --example helloworld\n```\n\nFlags:\n\n- `device`: `esp8266` | `esp32` | `pico` | [any of the allowed platform identifiers](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md#arguments) (defaults to current OS platform)\n- `port`: path to port for connected device (defaults to: `UPLOAD_PORT` environment variable)\n\n## Project management\n\n### Start a project\n\n\n```\nxs-dev init my-project\n```\n\nCreates a `main.js` and base configured `manifest.json` for running in the simulator.\n\nFlags:\n\n- `typescript`: includes typings and creates `main.ts` (experimental)\n- `io`: includes [TC53 IO manifest](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/io/io.md)\n\n### Build and run a project\n\nIn the project directory:\n\n```\nxs-dev run\n```\n\nWhen not in the project directory:\n\n```\nxs-dev run path/to/project\n```\n\nFlags:\n\n- `device`: `esp8266` | `esp32` | `pico` | [any of the allowed platform identifiers](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md#arguments) (defaults to current OS platform)\n- `port`: path to port for connected device (defaults to: `UPLOAD_PORT` environment variable)\n\n### Add a Moddable module\n\n```\nxs-dev include network/wifi\n```\n\nOr select from available modules:\n\n```\nxs-dev include\n```\n\nUpdates the `manifest.json` with the path to the dependency.\n\n### Scan for available devices\n\nIf the default device discovery is having trouble finding the correct port when running a project, use this command to find available ports to pass through the `--port` flag:\n\n```\n$ xs-dev scan\n\n✔ Found the following available devices!\n Port Device Features\n /dev/cu.usbserial-0001 ESP8266EX WiFi\n /dev/cu.usbserial-DN02N5XK ESP32-D0WDQ6 (revision 0) WiFi, BT, Dual Core, Coding Scheme None\n\n$ xs-dev run --port /dev/cu.usbserial-0001 --device esp8266\n```\n\n\n### Add a remote dependency (Coming soon)\n\n```\nxs-dev get dtex/j5e\n```\n\nAssumes the dependency is a GitHub repo, clones it to `~/.local/share`, creates an environment variable with the name of the repo, and updates the `manifest.json` with the path to that dependency.\n\nTo include a specific module for the installed dependency:\n\n```\nxs-dev include j5e/lib/led\n```\n\n### Remove a dependency\n\n```\nxs-dev remove network/wifi\n```\n\nUpdates the `manifest.json` to remove the dependency.\n\n## Development\n\nClone the project and install dependencies. We're using [pnpm](https://pnpm.io/) and [volta](https://volta.sh/) to manage packages and Node.\n\n```\ngit clone https://github.com/HipsterBrown/xs-dev.git\ncd xs-dev\npnpm install\n```\n\nLink dev version of CLI using `pnpm`, which will override any other globally installed version:\n\n```\npnpm link --global\npnpm link --global xs-dev\n```\n\nOr create an alias to clearly denote the local version of the CLI:\n\n```\nalias local-xs-dev=$PWD/bin/xs-dev\n```\n\nTo maintain the alias between shell sessions, for example I use zsh:\n\n```\necho \"alias local-xs-dev=$PWD/bin/xs-dev\" >> ~/.zshrc\n```\n"
|
|
74
|
+
"readme": "# CLI for automating the setup and usage of [Moddable XS tools](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/Moddable%20SDK%20-%20Getting%20Started.md)\n\nThe Moddable SDK and associated dev board tooling is incredibly empowering for embedded JS hardware development, however the set up process can be tedious to follow when getting started. This project aims to streamline the install and environment configuration requirements across platforms in just a few commands.\n\n**This project is a work in progress and should be considered pre-1.0.**\n\n**Feature support:**\n\n- [X] [Moddable SDK install & setup](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/Moddable%20SDK%20-%20Getting%20Started.md)\n- [X] [ESP32 SDK setup](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/devices/esp32.md)\n- [X] [ESP8266 SDK setup](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/devices/esp8266.md)\n- [X] [WASM simulator](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/devices/wasm.md)\n- [X] [Raspberry Pi Pico](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/devices/pico.md)\n- [X] Update Moddable SDK\n- [X] Project management, including dependencies\n\n**Platform support:**\n\n- [X] Mac\n- [ ] Windows\n- [X] Linux\n\n## Requirements\n\n[Node.js >= v12](https://nodejs.org/en/)\n\n**On Linux:**\n\nSetup commands rely on [`ssh-askpass`](https://packages.ubuntu.com/bionic/ssh-askpass) to prompt for permission when installing other tools and dependencies.\n\n## Install\n\n```\nnpm install -g xs-dev\n```\n\n## Update\n\n```\nnpm update -g xs-dev\n```\n\n## Features\n\n### Moddable SDK setup / update / teardown\n\nThis process mostly automates the instructions provided by Moddable's \"Getting Started\" documentation with a few exceptions:\n\n- it will not install XCode, just ensures the command line tools are available\n- the `moddable` git repo is cloned into `~/.local/share` instead of a new/existing `~/Projects` directory\n- a symlink for `xsbug.app` is created in `/Applications` for easy access through Launchpad (on Mac)\n\nRun script for initial setup:\n\n```\nxs-dev setup\n```\n\nRun script for updating SDK:\n\n```\nxs-dev update\n```\n\nRemove all setup and environment changes with teardown command:\n\n```\nxs-dev teardown\n```\n\n### ESP32 SDK install / setup\n\nThis process automates the instructions for downloading and building the esp-idf SDK tooling. This tooling will be placed in the `~/.local/share/esp32` directory, which will be created if it doesn't exist.\n\nRun script for platform setup:\n\n```\nxs-dev setup --device=esp32\n```\n\nRun script to confirm the setup:\n\n```\nxs-dev run --example helloworld --device=esp32\n```\n\nFlags:\n\n- `device`: `esp8266` | `esp32` | `pico` | [any of the allowed platform identifiers](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md#arguments) (defaults to current OS platform)\n- `port`: path to port for connected device (defaults to: `UPLOAD_PORT` environment variable)\n\n### ESP8266 SDK install / setup\n\nThis process automates the instructions for downloading all the dependencies for the ESP8266 RTOS SDK. These dependencies will be placed in the `~/.local/share/esp` directory, which will be created if it doesn't exist.\n\nRun script for platform setup:\n\n```\nxs-dev setup --device=esp8266\n```\n\nRun script to confirm the setup:\n\n```\nxs-dev run --example helloworld --device=esp8266\n```\n\nFlags:\n\n- `device`: `esp8266` | `esp32` | `pico` | [any of the allowed platform identifiers](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md#arguments) (defaults to current OS platform)\n- `port`: path to port for connected device (defaults to: `UPLOAD_PORT` environment variable)\n\n### Wasm Simulator install / setup\n\nThis process automates the instructions for downloading all the dependencies for the [wasm simulator](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/devices/wasm.md) and building the Moddable tooling. These dependencies will be placed in `~/.local/share/wasm`, which will be created if it doesn't exist.\n\nRun script for platform setup:\n\n```\nxs-dev setup --device=wasm\n```\n\n_If there are issues building the Moddable wasm tools, please try running `eval $SHELL` or starting a new shell insance before running the setup script again._\n\n\nRun script to confirm the setup:\n\n```\nxs-dev run --example helloworld --device=wasm\n```\n\n### Raspberry Pi Pico SDK install / setup\n\nThis process automates the instructions for downloading all the dependencies for the Pico SDK. These dependencies will be placed in the `~/.local/share/pico` directory, which will be created if it doesn't exist.\n\nRun script for platform setup:\n\n```\nxs-dev setup --device=pico\n```\n\nRun script to confirm the setup:\n\n```\nxs-dev run --example helloworld --device=pico\n```\n\nFlags:\n\n- `device`: `esp8266` | `esp32` | `pico` | [any of the allowed platform identifiers](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md#arguments) (defaults to current OS platform)\n- `port`: path to port for connected device (defaults to: `UPLOAD_PORT` environment variable)\n\n### Run Moddable examples\n\nWhile it is still possible to run the Moddable example projects in the documented workflow:\n\n```\ncd $MODDABLE/examples/<example directory>\nmcconfig -d -m -p <platform here>\n```\n\nThis tool aims to simplify that process.\n\nList available examples:\n```\nxs-dev run --list-examples\n```\n\nRun an example:\n```\nxs-dev run --example helloworld\n```\n\nFlags:\n\n- `device`: `esp8266` | `esp32` | `pico` | [any of the allowed platform identifiers](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md#arguments) (defaults to current OS platform)\n- `port`: path to port for connected device (defaults to: `UPLOAD_PORT` environment variable)\n\n## Project management\n\n### Start a project\n\n\n```\nxs-dev init my-project\n```\n\nCreates a `main.js` and minimally configured `manifest.json` for running in the simulator.\n\nFlags:\n\n- `typescript`: includes typings and creates `main.ts` (experimental)\n- `io`: includes [TC53 IO manifest](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/io/io.md)\n- `example`: use [Moddable example project](https://github.com/Moddable-OpenSource/moddable/tree/public/examples) as base for new project\n- `overwrite`: replace any existing directory of the same name\n\nFor the example flag, it can be used as a boolean to select a project from a list:\n\n```\nxs-dev init my-project --example\n```\n\nOr select from a filtered list of projects:\n\n```\nxs-dev init my-project --example http\n```\n\nOr if the complete example name is passed, it will be selected by default:\n\n```\nxs-dev init my-project --example network/mqtt/mqttbasic\n```\n\n### Build and run a project\n\nIn the project directory:\n\n```\nxs-dev run\n```\n\nWhen not in the project directory:\n\n```\nxs-dev run path/to/project\n```\n\nFlags:\n\n- `device`: `esp8266` | `esp32` | `pico` | [any of the allowed platform identifiers](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md#arguments) (defaults to current OS platform)\n- `port`: path to port for connected device (defaults to: `UPLOAD_PORT` environment variable)\n\n### Add a Moddable SDK module\n\n```\nxs-dev include network/wifi\n```\n\nOr select from available modules:\n\n```\nxs-dev include\nxs-dev include files\n```\n\nUpdates the `manifest.json` to include the module. \n\nFlags:\n\n- `device`: When this flag is present, the module is added to the `platforms` section for the specified device. When `device` is not provided, the module is added to the global manifest section to be used for all devices. For example, the following adds the module for use on `esp32` devices only:\n\n```\nxs-dev include files/flash --device esp32\n```\n\n### Scan for available devices\n\nIf the default device discovery is having trouble finding the correct port when running a project, use this command to find available ports to pass through the `--port` flag:\n\n```\n$ xs-dev scan\n\n✔ Found the following available devices!\n Port Device Features\n /dev/cu.usbserial-0001 ESP8266EX WiFi\n /dev/cu.usbserial-DN02N5XK ESP32-D0WDQ6 (revision 0) WiFi, BT, Dual Core, Coding Scheme None\n\n$ xs-dev run --port /dev/cu.usbserial-0001 --device esp8266\n```\n\n\n### Add a remote dependency (Coming soon)\n\n```\nxs-dev get dtex/j5e\n```\n\nAssumes the dependency is a GitHub repo, clones it to `~/.local/share`, creates an environment variable with the name of the repo, and updates the `manifest.json` with the path to that dependency.\n\nTo include a specific module for the installed dependency:\n\n```\nxs-dev include j5e/lib/led\n```\n\n### Remove a Moddable SDK module\n\n```\nxs-dev remove network/wifi\n```\n\nUpdates the `manifest.json` to remove the module.\n\nOr remove all modules that contain a string. This removes all modules that contain `\"wifi\"`.\n\n```\nxs-dev remove wifi\n```\n\nFlags:\n\n- `device`: When this flag is present, the module is removed from the `platforms` section for the specified device. When `device` is not provided, the module is removed from the global manifest section. For example, the following adds the module for use on `esp32` devices only:\n\n```\nxs-dev remove network/mqtt --device esp32\n```\n\n## Development\n\nClone the project and install dependencies. We're using [pnpm](https://pnpm.io/) and [volta](https://volta.sh/) to manage packages and Node.\n\n```\ngit clone https://github.com/HipsterBrown/xs-dev.git\ncd xs-dev\npnpm install\n```\n\nLink dev version of CLI using `pnpm`, which will override any other globally installed version:\n\n```\npnpm link --global\npnpm link --global xs-dev\n```\n\nOr create an alias to clearly denote the local version of the CLI:\n\n```\nalias local-xs-dev=$PWD/bin/xs-dev\n```\n\nTo maintain the alias between shell sessions, for example I use zsh:\n\n```\necho \"alias local-xs-dev=$PWD/bin/xs-dev\" >> ~/.zshrc\n```\n"
|
|
75
75
|
}
|