Skip to content

Commit 462d89b

Browse files
committed
readme refactor wip
1 parent 755df79 commit 462d89b

File tree

2 files changed

+61
-60
lines changed

2 files changed

+61
-60
lines changed

README.md

+61-60
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,39 @@
1-
# yavascript
1+
# ![YavaScript logo](meta/assets/logo.png)
22

3-
YavaScript is a cross-platform bash-like script runner and repl which is distributed as a single
4-
statically-linked binary. Scripts can be written in [JavaScript](https://en.wikipedia.org/wiki/JavaScript), [TypeScript](https://www.typescriptlang.org/), [JSX/TSX](https://react.dev/learn/writing-markup-with-jsx), [CoffeeScript](https://coffeescript.org/) or [Civet](https://civet.dev/).
3+
YavaScript is a cross-platform bash-like script runner and repl which is distributed as a single statically-linked program, weighing in at about 4MB. Scripts can be written in [JavaScript](https://en.wikipedia.org/wiki/JavaScript) or [JS-related languages](#languages).
54

65
> YavaScript is the name of the program. YavaScript is not a new language. YavaScript uses normal JavaScript.
76
8-
There are APIs available for all the things you'd normally want to do in
9-
a bash script, such as:
7+
## Why?
108

11-
- Running programs and getting their stdout/stderr/status
12-
- Reading/writing environment variables
13-
- Checking if files/folders exist
14-
- Removing/creating/copying files/folders
15-
- Reading and changing the current working directory
16-
- Reading and resolving symbolic links
17-
- Using globs to get large lists of files
18-
- Printing stylized text
19-
- Clearing the terminal
20-
- Fetching files from the internet
21-
22-
Additionally, you can do other things that are either not present in bash or are cumbersome to use in bash, namely:
23-
24-
- Serialize and deserialize JSON, CSV, YAML, and TOML
25-
- Removing ANSI control characters from a string
26-
- Split path strings into a list of segments and rejoin them into a string
27-
- Check if a path is absolute and resolve relative paths
28-
- Parse command-line flags
29-
- Work with Arrays (lists)
30-
- Work with Objects (key/value dictionaries)
31-
- Work with Typed Arrays (byte buffers)
32-
- Reliably get the path to the currently-running file
33-
- Strongly-typed interfaces and functions (via TypeScript)
34-
- Cross-file import/export using ECMAScript Modules
35-
- Split strings on delimeters
36-
- Pretty-print complex structures
37-
- Call low-level POSIX C APIs like fputs, sprintf, isatty
38-
- Perform work in threads
39-
- Import packages from npm (via "npm:" imports) or local node_modules
40-
41-
You'll also find analogues to familiar CLI tools, like:
9+
YavaScript exists as an alternative to bash scripts. Instead of writing scripts using shell syntax and running them with bash, you write them in JavaScript and run them with YavaScript.
4210

43-
- dirname
44-
- basename
45-
- cat
46-
- ls
47-
- realpath
48-
- readlink
11+
At only ~4MB and with no dependencies, YavaScript is easy to install or include in a Docker image. As such, it's suitable for use in all the places you would use shell scripts now. It's a great fit for those sort of "environment-level infrastructure" scripts that every Git repo ends up needing, like "build the app", "pull the latest docker images", "install/use the correct versions of languages and tools", etc.
4912

50-
...and more.
13+
YavaScript has built-in APIs for all the things you'd normally want to do in a bash script, such as:
5114

52-
## API Documentation
15+
- Running programs
16+
- Using environment variables
17+
- Working with files/folders
18+
- Resolving globs into lists of paths
19+
- Printing stylized text
5320

54-
See [here](/meta/generated-docs/README.md).
21+
As well as APIs for things which are difficult or cumbersome in bash, like:
5522

56-
## TypeScript Types
23+
- (De)serialize JSON, CSV, YAML, and TOML
24+
- Parse command-line flags into a structured object
25+
- Safely manipulate and resolve path strings
26+
- Work with raw byte buffers (typed arrays)
27+
- Reliably get the path to the currently-running script
28+
- Strongly-typed interfaces and functions (via TypeScript)
29+
- Cross-file import/export using ECMAScript Modules
30+
- Call low-level POSIX C APIs like fputs, sprintf, isatty
5731

58-
YavaScript comes with a TypeScript type definition (`.d.ts`) file.
32+
You'll also find cross-platform analogues to familiar CLI tools, like `mkdir`, `rm`, `chmod`, `dirname`, `which`, and more.
5933

60-
The `.d.ts` file contains documented TypeScript type definitions which can be given to your IDE to assist you when writing scripts, even if you aren't writing your scripts in TypeScript.
34+
## APIs
6135

62-
You can [view the `.d.ts` file online](./yavascript.d.ts), but if you have YavaScript installed, you should instead run `yavascript --print-types` to obtain the `.d.ts` file for your specific release.
36+
**For the full API documentation, see [here](/meta/generated-docs/README.md).**
6337

6438
## Example
6539

@@ -124,6 +98,43 @@ console.log(os.lstat(".gitignore").size);
12498
console.log("Is tty?", os.isatty(std.in));
12599
```
126100

101+
## How is that different from \_\_\_\_?
102+
103+
There are several other projects that bring a shell-like environment to JS, such as [zx](https://github.com/google/zx), [ShellJS](https://www.npmjs.com/package/shelljs), and [Bun Shell](https://bun.sh/docs/runtime/shell). The main difference between those and YavaScript is that YavaScript is very small, fully cross-platform, and brings its own JavaScript engine. The effect of those differences is that you can rely on YavaScript in places where you couldn't always rely on zx/shelljs/bun, like in your bootstrapping script that installs Node, or your smallest Docker containers. Or even on tiny constrained systems, like your router!
104+
105+
## Supported Platforms
106+
107+
- macOS (10.16 or higher)
108+
- Intel Processors (x86_64)
109+
- Apple Silicon (aarch64)
110+
- Linux
111+
- aarch64 or x86_64
112+
- glibc, muslc, or statically-linked
113+
- Windows (MinGW)
114+
- x86_64
115+
116+
## Installation
117+
118+
You can find the binary for your platform on [the releases page](https://github.com/suchipi/yavascript/releases). As YavaScript is fully self-contained in one small file, it's trivial to install and uninstall; simply place it somewhere specified in your [`PATH`](https://superuser.com/a/284351).
119+
120+
## Languages
121+
122+
YavaScript can load and run any of these languages with no ahead-of-time compilation step needed:
123+
124+
- JavaScript
125+
- [TypeScript](https://www.typescriptlang.org/)
126+
- [JSX/TSX](https://react.dev/learn/writing-markup-with-jsx)
127+
- [CoffeeScript](https://coffeescript.org/)
128+
- [Civet](https://civet.dev/)
129+
130+
## TypeScript Types
131+
132+
YavaScript comes with a TypeScript type definition (`.d.ts`) file.
133+
134+
The `.d.ts` file contains documented TypeScript type definitions which can be given to your IDE to assist you when writing scripts, even if you aren't writing your scripts in TypeScript.
135+
136+
You can [view the `.d.ts` file online](./yavascript.d.ts), but if you have YavaScript installed, you should instead run `yavascript --print-types` to obtain the `.d.ts` file for your specific release.
137+
127138
## QuickJS
128139

129140
YavaScript is powered by a fork of the QuickJS JavaScript Engine, originally
@@ -133,17 +144,7 @@ supporting the ES2020 specification.
133144
- Original QuickJS engine: https://bellard.org/quickjs/
134145
- The fork we use: https://github.com/suchipi/quickjs/
135146

136-
## Installation
137-
138-
You can find the binary for your platform on [the releases page](https://github.com/suchipi/yavascript/releases). As YavaScript is fully self-contained in one small file, it's trivial to install and uninstall; simply place it somewhere specified in your [`PATH`](https://superuser.com/a/284351). Supported platforms are:
139-
140-
- macOS 10.16 or higher, either Intel or Apple Silicon (M1, M2, etc)
141-
- Linux (gnu), either aarch64 or x86_64
142-
- Linux (musl), either aarch64 or x86_64
143-
- Linux (with musl libc statically linked into the binary), either aarch64 or x86_64
144-
- Windows (MinGW), x86_64
145-
146-
## Compiling
147+
## Compiling from Source
147148

148149
You'll need to install these prerequisites:
149150

meta/assets/logo.png

16.2 KB
Loading

0 commit comments

Comments
 (0)