Skip to content
This repository was archived by the owner on Dec 8, 2025. It is now read-only.

Commit c420c70

Browse files
committed
updated docs
1 parent e0c2f5b commit c420c70

5 files changed

Lines changed: 80 additions & 4 deletions

File tree

website/docs/developer/cli.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ A device script project will look as follows:
5151
main.ts usual name for your entry point application
5252
package.json additional dependencies and also has the `devicescript` field entry
5353
tsconfig.json configure the TypeScript compiler to compile DeviceScript syntax
54+
... A few additional files supporting the coding experience in VS Code
5455
```
5556

5657
### --force
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Getting Started",
3+
"position": 2
4+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Visual Studio Code
6+
7+
[Visual Studio Code](https://code.visualstudio.com/) (`code`) is a popular editor for TypeScript program. It is the
8+
preferred editor for DeviceScript projects.
9+
10+
The command line tool is compatible with container and virtual machines so you can run it
11+
in Docker, GitHub Codespaces, ...
12+
13+
## Setting up the project
14+
15+
Let's get started by installing the [DeviceScript command line](/developer/cli) and create an empty project
16+
17+
- Open `code` in a new empty folder
18+
- Open a terminal (`` Ctrl + ` ``)
19+
- Install the command line globally. You can call it using `devsc`
20+
21+
```bash
22+
npm install -g -u @devicescript/cli
23+
```
24+
25+
- Use the `init` command to setup the files
26+
27+
```bash
28+
devsc init
29+
```
30+
31+
You will have the following files created.
32+
33+
```
34+
.devicescript reserved folder for devicescript generated
35+
/lib supporting runtime types and libraries
36+
/bin compilation file output
37+
.gitignore if you are using git, make sure to ignore .devicescript
38+
main.ts usual name for your entry point application
39+
package.json additional dependencies and also has the `devicescript` field entry
40+
tsconfig.json configure the TypeScript compiler to compile DeviceScript syntax
41+
... A few additional files supporting the coding experience in VS Code
42+
```
43+
44+
## Launch the build watch
45+
46+
Assuming `main.ts` is the root file of your application,
47+
launch a compilation task in watch mode using this command.
48+
49+
```bash
50+
devsc build --watch
51+
```
52+
53+
The command line task will also start a local web server that will send the compiled bytecode
54+
to a developer tools page similar to the one hosted in the docs.
55+
56+
- open the developer tools page (see cli output)
57+
58+
## Edit, deploy, debug loop
59+
60+
From here, your developer inner loop will be very similar to building/debugging a web site with hot reload.
61+
62+
- make an edit in your source file, say `main.ts`
63+
- after a couple seconds, the compiler picks up the changes, produces a new bytecode and sends it to the developer tools
64+
- the developer tools automatically deploy thew bytecode to the select device (by default the simulator)
65+
- switch from VS Code to the browser and debug your new code

website/docs/developer/getting-started.md renamed to website/docs/developer/getting-started/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
sidebar_position: 2
32
hide_table_of_contents: true
43
---
54

@@ -176,3 +175,8 @@ in the developer tools window.
176175

177176
Click on the chip to start flasing the DeviceScript bytecode
178177
to your Raspberry Pico. It will automatically reflash when it detects changes.
178+
179+
## Part 3: Using the command line
180+
181+
That's it for this guide. In the next getting started, we'll show how to build
182+
this example using the command line tool in VS Code.

website/src/remark/render-code-blocks.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44

55
// TODO: factor into an independent plugin
66
import visit from "unist-util-visit"
7-
import logger from "@docusaurus/logger"
87
import fs_extra_pkg from "fs-extra"
98
import { spawnSync } from "child_process"
109
const { readJsonSync, writeJsonSync, ensureDirSync } = fs_extra_pkg
1110
import { createHash } from "crypto"
1211

12+
const info = console.debug
13+
const debug = console.debug
14+
1315
// site version
1416
const sitePkg = readJsonSync("../compiler/package.json")
1517
// for version `x.y.z`, only recompute hashes if `x` changes
1618
// to avoid recomputation over minor changes on the website
1719
// (so we only recompute for every major release)
1820
const VERSION = sitePkg.version.replace(/(\..)*$/g, "")
1921

20-
logger.info(`rendering snippets ${VERSION}`)
22+
info(`rendering snippets ${VERSION}`)
2123
// language configs
2224
import getLangConfig from "../../language.config.js"
2325
const languageConfig = await getLangConfig()
@@ -144,7 +146,7 @@ async function getOutput(config, input, lang, skipErr) {
144146
)
145147
}
146148

147-
logger.debug`${lang}: ${hash}, ${status}, ${error}`
149+
debug(`${lang}: ${hash}, ${status}, ${error}`)
148150

149151
const errorToReport = checkRuntimeError(
150152
langVersion,

0 commit comments

Comments
 (0)