An open API service indexing awesome lists of open source software.

https://github.com/didoesdigital/typey-type-cli

Builds stenography lessons for Typey Type for Stenographers
https://github.com/didoesdigital/typey-type-cli

nodejs stenography typescript

Last synced: 2 months ago
JSON representation

Builds stenography lessons for Typey Type for Stenographers

Awesome Lists containing this project

README

        

# Typey Type CLI

This repo houses the [Typey Type](https://didoesdigital.com/typey-type) Command Line Interface (CLI) to build stenography (steno) lessons.

The Typey Type CLI is used to build [Typey Type](https://didoesdigital.com/typey-type) stenography lessons by using source data in this repo to produce lessons and dictionaries in the [Typey Type data repo](https://github.com/didoesdigital/typey-type-data).

## Sponsor

You can support [Di’s efforts on Patreon](https://www.patreon.com/didoesdigital). A monthly donation helps [Di](https://didoesdigital.com) build more lessons and features to help you fast-track your steno progress.

## Development

Note: I've tested this on macOS and Linux. It mostly uses POSIX-compatible tools. Please let me know what other systems you run it successfully on.

Note: both the source and output lesson data is committed in git so that it's easy to `git diff` and compare the impact of dictionary changes across all lessons.

### Setup

Requirements:

- Node version 18 or later. Note: the project is currently built with Node version 20.
- Install [yarn](https://yarnpkg.com/getting-started/install) v4.
- The CLI uses built-in tools including:
- [GNU Make](https://www.gnu.org/software/make/)
- `find`, which is usually part of [findutils](https://www.gnu.org/software/findutils/)
- `mkdir`
- `comm`
- `grep`
- `sed`
- `cat`
- `diff`
- `sort`
- `git`
- `echo`
- `cp`
- `rsync`

This project includes a Git submodule for [steno dictionaries](https://github.com/didoesdigital/steno-dictionaries). If you want to clone this repository as well as its submodules, you can use the `--recursive` parameter:

```sh
git clone --recursive [email protected]:didoesdigital/typey-type-cli.git
```

Alternatively, if you've already cloned the repository without the `--recursive` parameter, you can load its submodules using `submodule update`:

```sh
git submodule update --init --recursive
```

Change directory into the cloned repository:

```sh
cd typey-type-cli
```

Yarn install the dependencies:

```
yarn install
```

You'll also need the Typey Type data repo somewhere nearby to produce lessons, which you *can* clone by itself but I recommend setting up the Typey Type app with the data repo included as a submodule so you have everything you might want in the right place:

```
cd ../
git clone https://github.com/didoesdigital/typey-type.git
cd typey-type
git submodule update --init --recursive
```

If you want to install the Typey Type app dependencies:

```
yarn install
```

## Updates

```
cd typey-type-cli
git pull
yarn
cd ../
cd typey-type
git pull
yarn
git submodule update
```

## Development / usage

For the following commands, make sure you're in the right repo:

`cd typey-type-cli`

To build the lessons, lesson index, and dictionaries, and compile, test, and lint everything:

```sh
time make -j 8 build-everything
```

- `-j 8` builds as many jobs in parallel as possible (i.e. for 4 CPUs, use `-j 4`).
- `time` times the whole process including making prerequisites

### Publishing lessons

When you're happy with the results of `build-everything`, sync the `misstrokes.json` and `emoji.json` files to the `steno-dictionaries` submodule and copy all the finalised lessons into the Typey Type data repo **at the path that you need to specify** ahead of publishing to production:

```sh
make sync-typey-type-data TYPEY_TYPE_DATA_REPO_PATH="~/projects/typey-type/typey-type-data/"
```

> **Warning**
> You need to change the value of TYPEY_TYPE_DATA_REPO_PATH to the path where you have cloned the `typey-type-data` repo *with* a trailing slash.

For testing, try an alternative test path like this:

```sh
time make -j 8 sync-typey-type-data TYPEY_TYPE_DATA_REPO_PATH="~/projects/test-typey-type/test-typey-type-data/"
```

### More details

To build all the **lessons** one at time:

```sh
make lessons
```

> **Note**
> To create a *new* lesson, see the new lesson section below.

To build the **lesson index**:

```sh
make lesson-index
```

To rebuild a specific lesson and always build it, even if dependencies have not changed:

```sh
time make --always-make faux-typey-type-data/lessons/fundamentals/numbers/lesson.txt
```

To build the **Typey Type dictionary** with one preferred entry for every word:

```sh
time make typey-type-dict
```

To **copy source dictionaries** (Plover, Jade's phrasing dictionary, Di's steno-dictionaries from the submodule that aren't auto-generated, etc.) to dictionaries target:

```sh
time make copy-dictionaries
```

To **build recommendations courses**:

```sh
time make build-recommendations-courses
```

To **generate emoji dictionary** as `emoji.json`:

```sh
time make emoji-dict
```

To **generate modified emoji strategy** in order to build emoji dictionary:

```sh
time make emoji-modified-strategy
```

To **collect misstrokes** into `misstrokes.json`:

```sh
time make collect-misstrokes
```

## Other one-off commands

To check for outlines that are duplicated across Typey Type dictionaries:

```sh
yarn dev help check-duplicate-outlines
yarn dev check-duplicate-outlines
yarn dev check-duplicate-outlines --unique-translations
```

## Debugging

While you can run CLI commands individually, for lessons, just use `make`. If you want to run a command though, do this:

```sh
yarn dev
yarn dev help
```

For example, `yarn dev build-emoji-dictionary --target didoesdigital/steno-dictionaries/dictionaries/emoji.json`.

For interactive debugging, here are some options:

```sh
yarn build && node --inspect-brk ./build/index.js build-lesson --target=faux-typey-type-data/lessons/drills/homophones/lesson.txt --metadata=faux-typey-type-data/lesson-source-data/drills/homophones/meta.json
yarn build && node --inspect-brk ./build/index.js build-typey-type-dictionary --target=faux-typey-type-data/lesson-intermediate-data/typey-type-standard-dict-set-combined.json --intermediate
yarn build && node --inspect-brk ./build/index.js build-lesson-index
```

For interactive debugging of tests, edit the `tsconfig.json` file to compile tests and edit the `jest.config.js` file to include the `build` directory:

```sh
yarn build && node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand build/shared/utils/transformingDictionaries/rankOutlines/rankOutlines.test.js
```

## Testing

```sh
time make lint-and-test
```

… or:

```sh
yarn lint:check
yarn lint:fix
yarn test
yarn test:watch
```

## Validate lessons

```sh
yarn dev validate-lessons
```

## Build

This cleans the `build` directory, compiles all the TypeScript to JavaScript and makes the `./build/index.js` executable:

```sh
yarn build
```

## Cleaning

To remove all intermediate data (which is git ignored) and target data (which is tracked in git) for lessons and dictionaries, and remove the `build` directory where compiled JavaScript is built:

```sh
make clean
```

## Glossary

These terms are not necessarily technically accurate, but are used frequently throughout the code. "Word" is often used where something like "phrase" might be more precise but "word" is more representative of typical content.

**Word** is often used to refer to an item of material in a lesson. It is often a plain, single word, but it could also be something like `pick-axe`, `sister-in-law`, `bread and butter`, `React.Component`, `
yarn dev add-new-rule --rule testRule # example
```

## Contributing

See the [CONTRIBUTING](./CONTRIBUTING.md) guidelines.

## Code of Conduct

This project and everyone participating in it is governed by the [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behaviour to [[email protected]](mailto:[email protected]).

## Licenses

- The project code (e.g. `src/**`) is licensed under MIT License, as shown in [LICENSE.md](./LICENSE.md).
- Note, [Ted Morin gave permission](https://github.com/didoesdigital/steno-dictionaries/issues/592#issuecomment-2365165919) to add the `stemoji.js` script from [stemoji](https://github.com/morinted/stemoji) to this Typey Type CLI repo under MIT License.
- The main data is licensed under GPL-2.0:
- The following files came from [Plover](https://github.com/openstenoproject/plover/) and are licensed under GPL-2.0 as shown in [the plover repo's LICENSE](https://github.com/openstenoproject/plover/blob/main/LICENSE.txt):
- [Plover’s Main Dictionary Jun 3, 2018 (latest)](./faux-typey-type-data/dictionaries/plover/main-3-jun-2018.json) in `faux-typey-type-data/dictionaries/plover/` and `faux-typey-type-data/dictionary-source-data/plover`
- [Plover’s Main Dictionary Oct 5, 2016](./faux-typey-type-data/dictionaries/plover/main-5-oct-2016.json) in `faux-typey-type-data/dictionaries/plover/` and `faux-typey-type-data/dictionary-source-data/plover`
- [Plover’s Commands Dictionary Jun 3, 2018 (latest)](./faux-typey-type-data/dictionaries/plover/commands-3-jun-2018.json) in `faux-typey-type-data/dictionaries/plover/` and `faux-typey-type-data/dictionary-source-data/plover`
- The dictionary and lessons data (e.g. `faux-typey-type-data/`) are licensed under GPL-2.0 as shown in [LICENSE_DATA](./LICENSE_DATA).
- The emoji vendor data is licensed under MIT License, as shown in [LICENSE_3RD_PARTY.md](./LICENSE_3RD_PARTY.md).
- `vendor/emoji_strategy_c8900a0.json` renamed from `emoji_strategy.json` from the original [emojione](https://github.com/joypixels/emojione/blob/c8900a0f4824c84b994accbeb319945b9a171052/emoji_strategy.json) project.
- `vendor/emoji_strategy.json` from the updated [emoji-toolkit](https://github.com/joypixels/emoji-toolkit) project.
- `vendor/emoji_strategy_reduced_to_c8900a0_chars.json` derived from `vendor/emoji_strategy.json` and `vendor/emoji_strategy_c8900a0.json`.

## Author

Typey Type was created by [Di](https://didoesdigital.com).

## Related repos

- [Typey Type](https://github.com/didoesdigital/typey-type)
- [Typey Type data](https://github.com/didoesdigital/typey-type-data)
- [Di's steno dictionaries](https://github.com/didoesdigital/steno-dictionaries)
- [Stenoboard diagram SVG to React](https://github.com/didoesdigital/typey-type-stenoboard-diagram-svg-to-react)