starlight-cli 1.1.4 → 1.1.5
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 +74 -85
- package/dist/index.js +8974 -5
- package/package.json +4 -1
- package/src/evaluator.js +1 -2
- package/src/starlight.js +105 -2
package/README.md
CHANGED
|
@@ -1,65 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
# Starlight Programming Language
|
|
2
3
|
|
|
3
4
|
Starlight is a lightweight, developer-oriented programming language designed for **server-side scripting, automation, and general-purpose programming**. It combines a clean, readable syntax inspired by JavaScript and Python with powerful runtime features such as async/await, modules, and interactive I/O.
|
|
4
5
|
|
|
5
|
-
**Official Reference:**
|
|
6
|
+
**Official Reference:**
|
|
7
|
+
https://starlight-learn-lang.pages.dev/
|
|
6
8
|
|
|
7
9
|
---
|
|
8
10
|
|
|
9
11
|
## Key Features
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- **Built-in Utilities** – `sleep`, `len`, `keys`, `values`, `fetch`, `get`, `post`
|
|
18
|
-
|
|
13
|
+
- **Modern, Simple Syntax** – Familiar to JavaScript and Python developers
|
|
14
|
+
- **Async / Await** – Native support for asynchronous operations
|
|
15
|
+
- **Modules & Imports** – Import JavaScript packages or other `.sl` files
|
|
16
|
+
- **Server-side Ready** – Built on Node.js, ideal for backend logic
|
|
17
|
+
- **Interactive I/O** – Built-in `ask` and `sldeploy`
|
|
18
|
+
- **Built-in Utilities** – `sleep`, `len`, `keys`, `values`, `fetch`, `get`, `post`
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
22
|
## Installation
|
|
23
23
|
|
|
24
|
+
1. Install **Node.js** (v18+ recommended)
|
|
25
|
+
2. Install the Starlight CLI:
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
Install Starlight CLI:1. $1
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
|
|
27
|
+
```bash
|
|
31
28
|
npm install -g starlight-cli
|
|
32
|
-
|
|
33
|
-
```
|
|
29
|
+
````
|
|
34
30
|
|
|
35
31
|
---
|
|
36
32
|
|
|
37
33
|
## Your First Program (`hello.sl`)
|
|
38
34
|
|
|
39
|
-
```
|
|
40
|
-
|
|
35
|
+
```sl
|
|
41
36
|
let name = ask("What is your name?")
|
|
42
37
|
sldeploy "Hello, " + name + "!"
|
|
43
|
-
|
|
44
38
|
```
|
|
45
39
|
|
|
46
40
|
Run:
|
|
47
41
|
|
|
48
|
-
```
|
|
49
|
-
|
|
42
|
+
```bash
|
|
50
43
|
starlight hello.sl
|
|
51
|
-
|
|
52
44
|
```
|
|
53
45
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
## Output
|
|
57
|
-
|
|
58
|
-
```
|
|
46
|
+
### Output
|
|
59
47
|
|
|
48
|
+
```
|
|
60
49
|
What is your name? Alice
|
|
61
50
|
Hello, Alice!
|
|
62
|
-
|
|
63
51
|
```
|
|
64
52
|
|
|
65
53
|
---
|
|
@@ -68,68 +56,59 @@ Hello, Alice!
|
|
|
68
56
|
|
|
69
57
|
### Variables
|
|
70
58
|
|
|
71
|
-
```
|
|
72
|
-
|
|
59
|
+
```sl
|
|
73
60
|
let x = 10
|
|
74
61
|
let text = "hello"
|
|
75
|
-
|
|
76
62
|
```
|
|
77
63
|
|
|
78
64
|
---
|
|
79
65
|
|
|
80
66
|
### Functions
|
|
81
67
|
|
|
82
|
-
```
|
|
83
|
-
|
|
68
|
+
```sl
|
|
84
69
|
func add(a, b) {
|
|
85
70
|
return a + b
|
|
86
71
|
}
|
|
87
72
|
|
|
88
73
|
sldeploy add(2, 3)
|
|
89
|
-
|
|
90
74
|
```
|
|
91
75
|
|
|
92
|
-
|
|
76
|
+
---
|
|
93
77
|
|
|
94
|
-
|
|
78
|
+
### Async Functions
|
|
95
79
|
|
|
80
|
+
```sl
|
|
96
81
|
async func load() {
|
|
97
82
|
let data = await get("https://example.com/api")
|
|
98
83
|
sldeploy data
|
|
99
84
|
}
|
|
100
85
|
|
|
101
86
|
load()
|
|
102
|
-
|
|
103
87
|
```
|
|
104
88
|
|
|
105
89
|
---
|
|
106
90
|
|
|
107
91
|
## Arrow Functions
|
|
108
92
|
|
|
109
|
-
Arrow functions provide a **concise and expressive** way to define functions.
|
|
93
|
+
Arrow functions provide a **concise and expressive** way to define functions.
|
|
110
94
|
|
|
111
95
|
### Basic Arrow Function
|
|
112
96
|
|
|
113
|
-
```
|
|
114
|
-
|
|
97
|
+
```sl
|
|
115
98
|
let square = x => x * x
|
|
116
99
|
sldeploy square(5)
|
|
117
|
-
|
|
118
100
|
```
|
|
119
101
|
|
|
120
102
|
### Multiple Parameters
|
|
121
103
|
|
|
122
|
-
```
|
|
123
|
-
|
|
104
|
+
```sl
|
|
124
105
|
let add = (a, b) => a + b
|
|
125
106
|
sldeploy add(10, 20)
|
|
126
|
-
|
|
127
107
|
```
|
|
128
108
|
|
|
129
109
|
### Block Body with if / else
|
|
130
110
|
|
|
131
|
-
```
|
|
132
|
-
|
|
111
|
+
```sl
|
|
133
112
|
let label = p => {
|
|
134
113
|
if (p.price > 1000) {
|
|
135
114
|
return "Premium"
|
|
@@ -137,20 +116,17 @@ let label = p => {
|
|
|
137
116
|
return "Standard"
|
|
138
117
|
}
|
|
139
118
|
}
|
|
140
|
-
|
|
141
119
|
```
|
|
142
120
|
|
|
143
121
|
### Arrow Functions with Objects
|
|
144
122
|
|
|
145
|
-
```
|
|
146
|
-
|
|
123
|
+
```sl
|
|
147
124
|
let summarize = p => {
|
|
148
125
|
return {
|
|
149
126
|
"name": p.name,
|
|
150
127
|
"value": p.price * p.stock
|
|
151
128
|
}
|
|
152
129
|
}
|
|
153
|
-
|
|
154
130
|
```
|
|
155
131
|
|
|
156
132
|
Arrow functions capture their surrounding scope and behave like standard functions while remaining lightweight and readable.
|
|
@@ -159,14 +135,12 @@ Arrow functions capture their surrounding scope and behave like standard functio
|
|
|
159
135
|
|
|
160
136
|
## Conditionals
|
|
161
137
|
|
|
162
|
-
```
|
|
163
|
-
|
|
138
|
+
```sl
|
|
164
139
|
if (x > 5) {
|
|
165
140
|
sldeploy "Greater than 5"
|
|
166
141
|
} else {
|
|
167
142
|
sldeploy "5 or less"
|
|
168
143
|
}
|
|
169
|
-
|
|
170
144
|
```
|
|
171
145
|
|
|
172
146
|
---
|
|
@@ -175,16 +149,12 @@ if (x > 5) {
|
|
|
175
149
|
|
|
176
150
|
### While Loop
|
|
177
151
|
|
|
178
|
-
```
|
|
179
|
-
|
|
152
|
+
```sl
|
|
180
153
|
let i = 0
|
|
181
|
-
while (i
|
|
182
|
-
|
|
183
|
-
|
|
154
|
+
while (i < 3) {
|
|
155
|
+
sldeploy i
|
|
156
|
+
i = i + 1
|
|
184
157
|
}
|
|
185
|
-
|
|
186
|
-
server()
|
|
187
|
-
|
|
188
158
|
```
|
|
189
159
|
|
|
190
160
|
---
|
|
@@ -195,8 +165,7 @@ Starlight includes a **start / race** control structure similar to a switch stat
|
|
|
195
165
|
|
|
196
166
|
### Syntax
|
|
197
167
|
|
|
198
|
-
```
|
|
199
|
-
|
|
168
|
+
```sl
|
|
200
169
|
start (value) {
|
|
201
170
|
race (1) {
|
|
202
171
|
# body
|
|
@@ -206,49 +175,69 @@ start (value) {
|
|
|
206
175
|
# body
|
|
207
176
|
}
|
|
208
177
|
}
|
|
209
|
-
|
|
210
178
|
```
|
|
211
179
|
|
|
212
180
|
### Example
|
|
213
181
|
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
define x = 2;
|
|
182
|
+
```sl
|
|
183
|
+
define x = 2
|
|
217
184
|
|
|
218
185
|
start (x) {
|
|
219
|
-
race (1) { sldeploy("Race 1 executed")
|
|
220
|
-
race (2) { sldeploy("Race 2 executed")
|
|
221
|
-
race (3) { sldeploy("Race 3 executed")
|
|
186
|
+
race (1) { sldeploy("Race 1 executed") }
|
|
187
|
+
race (2) { sldeploy("Race 2 executed") }
|
|
188
|
+
race (3) { sldeploy("Race 3 executed") }
|
|
222
189
|
}
|
|
223
190
|
|
|
224
|
-
sldeploy("Done with start statement")
|
|
225
|
-
|
|
191
|
+
sldeploy("Done with start statement")
|
|
226
192
|
```
|
|
227
193
|
|
|
228
194
|
### Expected Output
|
|
229
195
|
|
|
230
|
-
```
|
|
231
|
-
|
|
196
|
+
```
|
|
232
197
|
Race 2 executed
|
|
233
198
|
Race 3 executed
|
|
234
199
|
Done with start statement
|
|
235
|
-
|
|
236
200
|
```
|
|
237
201
|
|
|
238
202
|
---
|
|
239
203
|
|
|
240
|
-
##
|
|
204
|
+
## Markdown Preview (`starlight filename.md`)
|
|
241
205
|
|
|
206
|
+
Starlight can also be used to **preview Markdown files** directly from the CLI.
|
|
242
207
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
208
|
+
### Usage
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
starlight README.md
|
|
212
|
+
```
|
|
247
213
|
|
|
214
|
+
### How It Works (Execution Flow)
|
|
215
|
+
|
|
216
|
+
1. The CLI detects the `.md` file extension
|
|
217
|
+
2. The Markdown file is read from disk
|
|
218
|
+
3. Markdown is converted to HTML using a full-featured Markdown renderer
|
|
219
|
+
4. A **temporary HTML file** is created in the system temp directory
|
|
220
|
+
5. The file is opened in your default browser using `file://`
|
|
221
|
+
6. After the browser loads, the temporary file is **automatically deleted**
|
|
222
|
+
|
|
223
|
+
This makes Starlight useful not only as a programming language, but also as a **developer productivity tool**.
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Why Starlight?
|
|
228
|
+
|
|
229
|
+
* A **simple but powerful** scripting language
|
|
230
|
+
* **Fast server-side automation**
|
|
231
|
+
* Familiar syntax with **less boilerplate**
|
|
232
|
+
* Full access to the **Node.js ecosystem**
|
|
248
233
|
|
|
249
234
|
---
|
|
250
235
|
|
|
251
|
-
|
|
252
|
-
|
|
236
|
+
## License
|
|
237
|
+
|
|
238
|
+
MIT License
|
|
239
|
+
|
|
240
|
+
---
|
|
253
241
|
|
|
254
|
-
|
|
242
|
+
## Author and Developer
|
|
243
|
+
Dominex Macedon
|