xs-dev 0.15.0 → 0.17.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.
Files changed (45) hide show
  1. package/bin/xs-dev +3 -4
  2. package/build/commands/build.js +30 -0
  3. package/build/commands/include.js +9 -7
  4. package/build/commands/remove.js +5 -5
  5. package/build/commands/run.js +15 -124
  6. package/build/commands/setup.js +3 -3
  7. package/build/commands/update.js +3 -3
  8. package/build/extensions/build-extension.js +7 -0
  9. package/build/toolbox/build/index.js +145 -0
  10. package/build/toolbox/setup/fontbm.js +7 -3
  11. package/build/toolbox/setup/linux.js +45 -7
  12. package/build/toolbox/setup/mac.js +51 -12
  13. package/build/toolbox/setup/moddable.js +35 -2
  14. package/build/toolbox/setup/types.js +3 -0
  15. package/build/toolbox/setup/windows.js +2 -2
  16. package/build/toolbox/update/esp32.js +3 -3
  17. package/build/toolbox/update/linux.js +92 -31
  18. package/build/toolbox/update/mac.js +80 -26
  19. package/build/types/commands/build.d.ts +4 -0
  20. package/build/types/extensions/build-extension.d.ts +3 -0
  21. package/build/types/toolbox/build/index.d.ts +13 -0
  22. package/build/types/toolbox/setup/linux.d.ts +2 -1
  23. package/build/types/toolbox/setup/mac.d.ts +2 -1
  24. package/build/types/toolbox/setup/moddable.d.ts +11 -0
  25. package/build/types/toolbox/setup/types.d.ts +3 -0
  26. package/build/types/toolbox/setup/windows.d.ts +2 -1
  27. package/build/types/toolbox/update/linux.d.ts +2 -1
  28. package/build/types/toolbox/update/mac.d.ts +2 -1
  29. package/build/types/types.d.ts +5 -2
  30. package/docs/public/make-scrollable-code-focusable.js +2 -2
  31. package/docs/public/run-hello-world.png +0 -0
  32. package/docs/src/components/HeadCommon.astro +0 -9
  33. package/docs/src/components/HeadSEO.astro +2 -8
  34. package/docs/src/components/Header/Header.astro +1 -1
  35. package/docs/src/components/LeftSidebar/LeftSidebar.astro +1 -1
  36. package/docs/src/config.ts +3 -0
  37. package/docs/src/languages.ts +6 -6
  38. package/docs/src/layouts/MainLayout.astro +1 -1
  39. package/docs/src/pages/en/features/run.md +29 -2
  40. package/docs/src/pages/en/features/setup.md +13 -1
  41. package/docs/src/pages/en/features/update.md +16 -0
  42. package/docs/src/pages/en/guide/00-prepare.md +50 -0
  43. package/docs/src/pages/en/guide/01-hello-console.md +62 -0
  44. package/docs/tsconfig.json +1 -0
  45. package/package.json +13 -9
@@ -1 +1,2 @@
1
- export default function (): Promise<void>;
1
+ import { SetupArgs } from './types';
2
+ export default function ({ targetBranch }: SetupArgs): Promise<void>;
@@ -1 +1,2 @@
1
- export default function (): Promise<void>;
1
+ import { SetupArgs } from './types';
2
+ export default function ({ targetBranch }: SetupArgs): Promise<void>;
@@ -1 +1,12 @@
1
+ import { RestEndpointMethodTypes } from '@octokit/rest';
1
2
  export declare function moddableExists(): boolean;
3
+ declare type ExtractFromArray<Item extends readonly unknown[]> = Item extends Readonly<Array<infer ItemType>> ? ItemType : never;
4
+ declare type GitHubRelease = ExtractFromArray<RestEndpointMethodTypes['repos']['listReleases']['response']['data']>;
5
+ export declare function fetchLatestRelease(): Promise<GitHubRelease>;
6
+ interface DownloadToolsArgs {
7
+ writePath: string;
8
+ assetName: string;
9
+ release: GitHubRelease;
10
+ }
11
+ export declare function downloadReleaseTools({ writePath, assetName, release, }: DownloadToolsArgs): Promise<void>;
12
+ export {};
@@ -0,0 +1,3 @@
1
+ export interface SetupArgs {
2
+ targetBranch: 'public' | 'latest-release';
3
+ }
@@ -1 +1,2 @@
1
- export default function (): Promise<void>;
1
+ import { SetupArgs } from './types';
2
+ export default function (_args: SetupArgs): Promise<void>;
@@ -1 +1,2 @@
1
- export default function (): Promise<void>;
1
+ import { SetupArgs } from '../setup/types';
2
+ export default function ({ targetBranch }: SetupArgs): Promise<void>;
@@ -1 +1,2 @@
1
- export default function (): Promise<void>;
1
+ import { SetupArgs } from '../setup/types';
2
+ export default function ({ targetBranch }: SetupArgs): Promise<void>;
@@ -1,6 +1,9 @@
1
1
  import type { GluegunToolbox } from 'gluegun';
2
+ import type { SetupArgs } from './toolbox/setup/types';
3
+ import type { BuildArgs } from './toolbox/build/index';
2
4
  export declare type Device = 'darwin' | 'linux' | 'windows_nt' | 'esp' | 'esp8266' | 'esp32' | 'wasm' | 'pico';
3
5
  export interface XSDevToolbox extends GluegunToolbox {
4
- setup: Record<Device, () => Promise<void>>;
5
- update: Record<Device, () => Promise<void>>;
6
+ setup: Record<Device, (() => Promise<void>) | ((args: SetupArgs) => Promise<void>)>;
7
+ update: Record<Device, (() => Promise<void>) | ((args: SetupArgs) => Promise<void>)>;
8
+ build: (args: BuildArgs) => Promise<void>;
6
9
  }
@@ -1,3 +1,3 @@
1
1
  Array.from(document.getElementsByTagName('pre')).forEach((element) => {
2
- element.setAttribute('tabindex', '0');
3
- });
2
+ element.setAttribute('tabindex', '0')
3
+ })
Binary file
@@ -30,12 +30,3 @@ import '../styles/index.css';
30
30
  root.classList.remove('theme-dark');
31
31
  }
32
32
  </script>
33
-
34
- <!-- Global site tag (gtag.js) - Google Analytics -->
35
- <!-- <script async src="https://www.googletagmanager.com/gtag/js?id=G-TEL60V1WM9" is:inline></script>
36
- <script>
37
- window.dataLayer = window.dataLayer || [];
38
- function gtag(){dataLayer.push(arguments);}
39
- gtag('js', new Date());
40
- gtag('config', 'G-TEL60V1WM9');
41
- </script> -->
@@ -5,7 +5,8 @@ export interface Props {
5
5
  site: any;
6
6
  canonicalURL: URL | string;
7
7
  }
8
- const { content = {}, canonicalURL } = Astro.props;
8
+ const canonicalURL = new URL(Astro.url.pathname, Astro.site);
9
+ const { content = {} } = Astro.props;
9
10
  const formattedContentTitle = content.title ? `${content.title} 🚀 ${SITE.title}` : SITE.title;
10
11
  ---
11
12
 
@@ -25,10 +26,3 @@ const formattedContentTitle = content.title ? `${content.title} 🚀 ${SITE.titl
25
26
  <meta name="twitter:site" content={OPEN_GRAPH.twitter} />
26
27
  <meta name="twitter:title" content={formattedContentTitle} />
27
28
  <meta name="twitter:description" content={content.description ? content.description : SITE.description} />
28
-
29
- <!--
30
- TODO: Add json+ld data, maybe https://schema.org/APIReference makes sense?
31
- Docs: https://developers.google.com/search/docs/advanced/structured-data/intro-structured-data
32
- https://www.npmjs.com/package/schema-dts seems like a great resource for implementing this.
33
- Even better, there's a React component that integrates with `schema-dts`: https://github.com/google/react-schemaorg
34
- -->
@@ -17,7 +17,7 @@ const lang = currentPage && getLanguageFromURL(currentPage);
17
17
  <SidebarToggle client:idle />
18
18
  </div>
19
19
  <div class="logo flex">
20
- <a href={Astro.site}>
20
+ <a href={import.meta.env.BASE_URL}>
21
21
  <h1>{CONFIG.SITE.title ?? "Documentation"}</h1>
22
22
  </a>
23
23
  </div>
@@ -31,7 +31,7 @@ const sidebarSections = SIDEBAR[langCode].reduce((col, item, i) => {
31
31
  <ul>
32
32
  {section.children.map((child) => (
33
33
  <li class="nav-link">
34
- <a href={`${Astro.site.pathname}${child.link}`} aria-current={`${currentPageMatch === child.link ? 'page' : 'false'}`}>
34
+ <a href={`${import.meta.env.BASE_URL}${child.link}`} aria-current={`${currentPageMatch === child.link ? 'page' : 'false'}`}>
35
35
  {child.text}
36
36
  </a>
37
37
  </li>
@@ -39,5 +39,8 @@ export const SIDEBAR = {
39
39
  { text: 'Project Creation', link: 'en/features/init' },
40
40
  { text: 'Build & Run', link: 'en/features/run' },
41
41
  { text: 'SDK Module Management', link: 'en/features/include' },
42
+ { text: 'Guide', header: true },
43
+ { text: '00. Prepare', link: 'en/guide/00-prepare' },
44
+ { text: '01. Hello Console', link: 'en/guide/01-hello-console' },
42
45
  ],
43
46
  }
@@ -1,10 +1,10 @@
1
- import { KNOWN_LANGUAGES } from './config';
1
+ import { KNOWN_LANGUAGES } from './config'
2
2
 
3
- export { KNOWN_LANGUAGES };
4
- export const KNOWN_LANGUAGE_CODES = Object.values(KNOWN_LANGUAGES);
5
- export const langPathRegex = /\/([a-z]{2}-?[A-Z]{0,2})\//;
3
+ export { KNOWN_LANGUAGES }
4
+ export const KNOWN_LANGUAGE_CODES = Object.values(KNOWN_LANGUAGES)
5
+ export const langPathRegex = /\/([a-z]{2}-?[A-Z]{0,2})\//
6
6
 
7
7
  export function getLanguageFromURL(pathname: string) {
8
- const langCodeMatch = pathname.match(langPathRegex);
9
- return langCodeMatch ? langCodeMatch[1] : 'en';
8
+ const langCodeMatch = pathname.match(langPathRegex)
9
+ return langCodeMatch ? langCodeMatch[1] : 'en'
10
10
  }
@@ -17,7 +17,7 @@ const githubEditUrl = CONFIG.GITHUB_EDIT_URL && CONFIG.GITHUB_EDIT_URL + current
17
17
  <html dir={content.dir ?? 'ltr'} lang={content.lang ?? 'en-us'} class="initial">
18
18
  <head>
19
19
  <HeadCommon />
20
- <HeadSEO {content} canonicalURL={Astro.canonicalURL} />
20
+ <HeadSEO {content} />
21
21
  <title>{content.title ? `${content.title} 🚀 ${CONFIG.SITE.title}` : CONFIG.SITE.title}</title>
22
22
  <style>
23
23
  body {
@@ -1,10 +1,10 @@
1
1
  ---
2
- title: Run
2
+ title: Build and Run
3
3
  description: Build and run Moddable projects or examples
4
4
  layout: ../../../layouts/MainLayout.astro
5
5
  ---
6
6
 
7
- # Run Moddable projects
7
+ ## Running Projects
8
8
 
9
9
  Within a project directory, the `run` command will invoke [`mcconfig`](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md#mcconfig) to generate the `make` file based on the `manifest.json` followed by building and running the project in the current environment simulator:
10
10
 
@@ -61,3 +61,30 @@ xs-dev run --port /dev/cu.usbserial-0001 --device esp8266
61
61
  ```
62
62
 
63
63
  _This value can be discovered using the [`scan`](./scan) command._
64
+
65
+
66
+ ## Building projects for release
67
+
68
+ Within a project directory, the `build` command takes the same flags as the `run` command to invoke [`mcconfig`](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md#mcconfig) to generate the `make` file based on the `manifest.json` followed by only building the project for [the target device](#select-a-device-target):
69
+
70
+ ```
71
+ xs-dev build --device esp32
72
+ ```
73
+
74
+ The build `--mode` can be set to `production` for the optimized release code or `development` for the debug-enabled release code. This will default to the `NODE_ENV` environment variable or `development` if that variable is not set.
75
+
76
+ ```
77
+ xs-dev build --mode production --device esp32
78
+ ```
79
+
80
+ The output directory can also be set using the `--output` flag, overriding the default path of `$MODDABLE/build`, where `$MODDABLE` is the location of the Moddable tooling repo on your local filesystem.
81
+
82
+ ```
83
+ xs-dev build --output ./dist --device esp32
84
+ ```
85
+
86
+ If you want to immediately deploy the release build, use the `--deploy` flag:
87
+
88
+ ```
89
+ xs-dev build --deploy --device esp32
90
+ ```
@@ -6,7 +6,7 @@ layout: ../../../layouts/MainLayout.astro
6
6
 
7
7
  # Moddable Platform Setup
8
8
 
9
- This command downloads and builds the [Moddable developer tooling](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md) for the current OS (Windows support coming soon).
9
+ This command downloads the [Moddable developer tooling](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md) for the current OS (Windows support coming soon).
10
10
 
11
11
  [After installing the CLI](/en/introduction#installation), call the `setup` command:
12
12
 
@@ -28,6 +28,18 @@ A symlink for [`xsbug.app`](https://github.com/Moddable-OpenSource/moddable/blob
28
28
 
29
29
  The [`moddable` git repo](https://github.com/Moddable-OpenSource/moddable) is cloned into `~/.local/share` instead of a new/existing `~/Projects` directory.
30
30
 
31
+ ## Target Branch
32
+
33
+ The default behavior of this command for Moddable developer tooling pulls the [latest release tooling](https://github.com/Moddable-OpenSource/moddable/releases) and source code for the associated tagged branch. This provides a known-working state for the SDK and avoids needing to build the tooling on the local machine.
34
+
35
+ To override this behavior, use the `--target-branch` flag to select `public`; this fetches the latest commit off that main branch and runs the build to generate the associated tools.
36
+
37
+ ```
38
+ xs-dev setup --target-branch public
39
+ ```
40
+
41
+ _This will only work for the `mac`, `windows`, and `linux` device options, which are the respective defaults for the operating system on which the command is run._
42
+
31
43
  ## Device Setup
32
44
 
33
45
  While the `setup` command provides the Moddable SDK for the dev environment, the `--device` flag selects another platform target SDK to set up. It ensures the Moddable SDK has been installed first.
@@ -12,6 +12,22 @@ Stay up to date with the latest tooling from Moddable and supported device targe
12
12
  xs-dev update
13
13
  ```
14
14
 
15
+ ## Target Branch
16
+
17
+ The default behavior of this command for Moddable developer tooling pulls the [latest release tooling](https://github.com/Moddable-OpenSource/moddable/releases) and source code for the associated tagged branch. This provides a known-working state for the SDK and avoids needing to build the tooling on the local machine.
18
+
19
+ To override this behavior, use the `--target-branch` flag to select `public`; this fetches the latest commit off that main branch and runs the build to generate the associated tools.
20
+
21
+ ```
22
+ xs-dev setup --target-branch public
23
+ ```
24
+
25
+ _This will only work for the `mac`, `windows`, and `linux` device options, which are the respective defaults for the operating system on which the command is run._
26
+
27
+ ## Device Updates
28
+
29
+ While the `update` command provides the latest Moddable SDK for the dev environment, the `--device` flag selects another platform target SDK to set up. It ensures the Moddable SDK has been installed first.
30
+
15
31
  The `--device` flag allows for selecting a different target platform:
16
32
 
17
33
  ```
@@ -0,0 +1,50 @@
1
+ ---
2
+ title: Prerequisites
3
+ description: Prepare for embedded JS development
4
+ layout: ../../../layouts/MainLayout.astro
5
+ ---
6
+
7
+ **Prepare for embedded JS development**
8
+
9
+ Getting started on the journey to developing embedded hardware projects with JavaScript assumes some knowledge of various technologies like the command line, text editors, package managers, and [the JavaScript programming language](https://developer.mozilla.org/en-US/docs/Web/javascript).
10
+
11
+ ## Command Line
12
+
13
+ Tutorial content will reference command line utilities and jargon as part of the workflow for developing embedded JS projects. Select your operating system to learn more about this subject:
14
+
15
+ - [MacOS OR Linux](https://www.freecodecamp.org/news/command-line-for-beginners/)
16
+ - [Windows](https://www.freecodecamp.org/news/command-line-commands-cli-tutorial/)
17
+
18
+ Inline terminal commands will usually be formatting like the following: `echo "hello world"`
19
+
20
+ Code examples will look like the following:
21
+
22
+ ```javascript
23
+ trace('hello world')
24
+ ```
25
+
26
+ ## Text Editors
27
+
28
+ A local plain text editor is generally required for creating and editing your JavaScript projects. You can download one of the following free applications with either built-in or third-party support for JavaScript:
29
+
30
+ - [Visual Studio Code](https://code.visualstudio.com/)
31
+ - [Neovim](http://www.sublimetext.com/) / [Vim](https://www.vim.org/)
32
+ - [Sublime Text](http://www.sublimetext.com/)
33
+
34
+ These are not the only available editors, so feel free to do your own research and pick what feels right to you!
35
+
36
+ ## NodeJS Package Manager (optional)
37
+
38
+ While [NodeJS](https://nodejs.org/en/) is not required for [Moddable XS](https://github.com/Moddable-OpenSource/moddable) projects, it is a dependency for installing and using the [`xs-dev` CLI](https://hipsterbrown.github.io/xs-dev/en/introduction/).
39
+
40
+ Node can be [downloaded directly from the website](https://nodejs.org/en/download/), however using one of the following version managers can help with quickly switching to recommended versions of the tooling in the future:
41
+
42
+ - [Volta](https://volta.sh/)
43
+ - [fnm](https://github.com/Schniz/fnm)
44
+ - [asdf](https://asdf-vm.com/guide/getting-started.html#_4-install-a-plugin)
45
+ - [`pnpm env`](https://pnpm.io/cli/env)
46
+
47
+ Node comes with [npm](https://docs.npmjs.com/cli/v8/commands/npm) as the included package manager, but there are other options available if needed:
48
+
49
+ - [pnpm](https://pnpm.io/installation)
50
+ - [yarn](https://yarnpkg.com/)
@@ -0,0 +1,62 @@
1
+ ---
2
+ title: Hello Console
3
+ description: How to set up the basic development environment and run your first program
4
+ layout: ../../../layouts/MainLayout.astro
5
+ ---
6
+
7
+ **How to set up the basic development environment and run your first program**
8
+
9
+ ## Install the CLI
10
+
11
+ `xs-dev` can be installed globally using the [NodeJS package manager of your choice](./00-prepare#nodejs-package-manager-optional).
12
+
13
+ ```
14
+ npm install -g xs-dev
15
+ ```
16
+
17
+ ```
18
+ pnpm install -g xs-dev
19
+ ```
20
+
21
+ ```
22
+ yarn global add xs-dev
23
+ ```
24
+
25
+ ## Setup system tooling
26
+
27
+ As specified in the [setup documentation](../features/setup), the [Moddable SDK and associated tooling](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md) is installed using the following command:
28
+
29
+ ```
30
+ xs-dev setup
31
+ ```
32
+
33
+ This will determine the correct tooling to install based on your operating system.
34
+
35
+ **[Windows support coming soon](https://github.com/HipsterBrown/xs-dev/pull/53)**
36
+
37
+ Once this process is done, you should see a success message:
38
+
39
+ ```
40
+ Moddable SDK successfully set up! Start a new terminal session and run the "helloworld example": xs-dev run --example helloworld
41
+ ```
42
+
43
+ ## Run the Hello World example
44
+
45
+ To start a new terminal session, you can either execute your shell of choice (`bash`/`zsh`/`fish`) or create a new terminal window / tab. This will ensure the expected tooling is available in your session [PATH](https://en.wikipedia.org/wiki/PATH_(variable)).
46
+
47
+ You can [run any Moddable example included in the SDK](../features/run#moddable-examples). The "Hello World" example provides the simplest program to get started and can be run in the [simulator](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/tools.md#simulator):
48
+
49
+ ```
50
+ xs-dev run --example helloworld
51
+ ```
52
+
53
+ This will start up the debugger and simulator:
54
+
55
+ ![Moddable simulator app and debugger app running on MacOS](/run-hello-world.png)
56
+
57
+ This will keep running until the `Ctrl+C` keys are entered in the terminal session or both apps are quit.
58
+
59
+ ## Keep exploring!
60
+
61
+ Use the `--list-examples` flag with the `run` command to search the extensive list of available examples to run in the simulator: `xs-dev run --list-examples`
62
+
@@ -9,6 +9,7 @@
9
9
  "resolveJsonModule": true,
10
10
  // Enable stricter transpilation for better output.
11
11
  "isolatedModules": true,
12
+ "noEmit": true,
12
13
  // Add type definitions for our Vite runtime.
13
14
  "types": ["vite/client"]
14
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xs-dev",
3
- "version": "0.15.0",
3
+ "version": "0.17.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": {
@@ -20,6 +20,7 @@
20
20
  "url": "https://github.com/HipsterBrown/xs-dev.git"
21
21
  },
22
22
  "dependencies": {
23
+ "@octokit/rest": "^19.0.3",
23
24
  "axios": "^0.24.0",
24
25
  "gluegun": "^5.0.0",
25
26
  "serialport": "^10.3.0",
@@ -29,11 +30,10 @@
29
30
  "usb": "^2.2.0"
30
31
  },
31
32
  "devDependencies": {
32
- "@astrojs/lit": "^0.1.4",
33
- "@astrojs/markdown-remark": "^0.11.0",
34
- "@astrojs/preact": "^0.1.3",
35
- "@astrojs/sitemap": "^0.1.0",
36
- "@astrojs/tailwind": "^0.2.1",
33
+ "@astrojs/lit": "^1.0.0",
34
+ "@astrojs/preact": "^1.0.1",
35
+ "@astrojs/sitemap": "^1.0.0",
36
+ "@astrojs/tailwind": "^1.0.0",
37
37
  "@changesets/cli": "^2.19.0",
38
38
  "@types/jest": "^27.4.0",
39
39
  "@types/node": "^16.11.0",
@@ -43,7 +43,7 @@
43
43
  "@typescript-eslint/eslint-plugin": "^4.0.1",
44
44
  "@typescript-eslint/parser": "^4.0.0",
45
45
  "@webcomponents/template-shadowroot": "^0.1.0",
46
- "astro": "^1.0.0-beta.40",
46
+ "astro": "^1.0.2",
47
47
  "eslint": "^7.12.1",
48
48
  "eslint-config-prettier": "^8.3.0",
49
49
  "eslint-config-standard-with-typescript": "^21.0.1",
@@ -57,7 +57,7 @@
57
57
  "preact-render-to-string": "^5.2.0",
58
58
  "prettier": "^2.5.1",
59
59
  "ts-jest": "^27.1.0",
60
- "ts-node": "^10.4.0",
60
+ "ts-node": "^10.9.1",
61
61
  "typescript": "^4.7.3"
62
62
  },
63
63
  "jest": {
@@ -84,6 +84,10 @@
84
84
  "coverage": "jest --coverage",
85
85
  "start:docs": "astro dev --root ./docs",
86
86
  "build:docs": "astro build --root ./docs",
87
- "preview:docs": "astro preview --root ./docs"
87
+ "preview:docs": "astro preview --root ./docs",
88
+ "ci:version:changeset": "changeset version",
89
+ "ci:version": "pnpm ci:version:changeset && pnpm ci:version:install",
90
+ "ci:version:install": "pnpm install --frozen-lockfile=false",
91
+ "ci:publish": "changeset publish"
88
92
  }
89
93
  }