Skip to content

Commit 2b5c85e

Browse files
committed
OPAL
1 parent 238cee0 commit 2b5c85e

34 files changed

+1946
-1
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Generate Package Metadata
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
generate-metadata:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '18'
22+
23+
- name: Generate package metadata
24+
run: node generate-metadata.js
25+
26+
- name: Commit generated files
27+
run: |
28+
git config --local user.email "[email protected]"
29+
git config --local user.name "GitHub Action"
30+
git add -A
31+
if git diff --staged --quiet; then
32+
echo "No changes to commit"
33+
else
34+
git commit -m "Auto-generate package metadata [skip ci]"
35+
git push
36+
fi

README.md

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,110 @@
1-
# opal
1+
2+
# 🌸 Opal – The OSL Package Manager
3+
4+
**Opal** is the official package manager for the OSL programming language. It helps you install, manage, and publish OSL packages with ease.
5+
6+
## ✨ Features
7+
8+
- Lightweight and fast
9+
- Clean CLI interface
10+
- Local and remote package resolution
11+
- Human-readable manifests
12+
13+
---
14+
15+
## 📦 Installation
16+
17+
`opal` comes with originOS v5.7.9 and later, previously it was named `package`
18+
19+
## 🛠️ Usage
20+
21+
### Install a package
22+
23+
```sh
24+
opal install <package>
25+
# attempts to install latest
26+
opal install <package>:<version>
27+
# attempts to install a specific version
28+
````
29+
30+
Downloads and installs a package into your local environment.
31+
32+
Example:
33+
34+
```sh
35+
opal install rotur
36+
```
37+
38+
---
39+
40+
### View info about a package
41+
42+
```sh
43+
opal describe <package>
44+
```
45+
46+
Shows metadata about a package: description, version, dependencies, author, etc.
47+
48+
---
49+
50+
### Uninstall a package
51+
52+
```sh
53+
opal uninstall <package>
54+
```
55+
56+
Removes a package from the project.
57+
58+
---
59+
60+
### List installed packages
61+
62+
```sh
63+
opal list
64+
```
65+
66+
Shows all packages currently installed in the project.
67+
68+
---
69+
70+
### Search for packages
71+
72+
```sh
73+
opal search <query>
74+
```
75+
76+
Looks up packages by name or tag from the registry.
77+
78+
---
79+
80+
### Update packages
81+
82+
```sh
83+
opal sync
84+
```
85+
86+
Updates all packages to their latest compatible versions.
87+
88+
---
89+
90+
```sh
91+
opal sync <package>
92+
```
93+
94+
Updates a specific package.
95+
96+
---
97+
98+
### Start a new osl package project
99+
100+
```sh
101+
opal init
102+
```
103+
104+
### Publish an osl package
105+
106+
```sh
107+
opal export
108+
```
109+
110+
Looks in your current directory and builds your osl package and exports it to your computer.

datetime/package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"title": "datetime",
3+
"versions": [
4+
{
5+
"name": "datetime",
6+
"version": "1.0.0",
7+
"description": "A comprehensive datetime utility library for OSL with formatting, manipulation, and relative time functionality",
8+
"main": "script.osl",
9+
"dependencies": {},
10+
"tags": [
11+
"time",
12+
"date",
13+
"formatting",
14+
"utility",
15+
"calendar"
16+
],
17+
"size": "7 KB",
18+
"sizeBytes": 6686
19+
}
20+
],
21+
"tags": [
22+
"time",
23+
"date",
24+
"formatting",
25+
"utility",
26+
"calendar"
27+
]
28+
}

datetime/v1.0.0/README.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# 📅 DateTime - OSL Package
2+
3+
A comprehensive datetime utility library for OSL with formatting, manipulation, and relative time functionality.
4+
5+
## 🚀 Installation
6+
7+
```sh
8+
opal install datetime
9+
```
10+
11+
## 📖 Usage
12+
13+
```osl
14+
import 'datetime/v1' from 'packages' as 'dt'
15+
16+
// Get current timestamp
17+
local now = dt.now()
18+
19+
// Format a timestamp
20+
local formatted = dt.format(now, "YYYY-MM-DD HH:mm:ss")
21+
log formatted // Output: 2025-07-06 14:30:25
22+
23+
// Make timestamp relative
24+
local relative = dt.makeRelative(now)
25+
log relative // Output: "just now" or "2 minutes ago"
26+
27+
// Add ordinal suffix to numbers
28+
local suffix = dt.addSuffix(21)
29+
log suffix // Output: "21st"
30+
```
31+
32+
## 🔧 API Reference
33+
34+
### Methods
35+
36+
#### `now()`
37+
38+
Returns the current timestamp.
39+
40+
**Returns:** `number` - Current timestamp
41+
42+
#### `format(timestamp, format)`
43+
44+
Formats a timestamp according to the provided format string.
45+
46+
**Parameters:**
47+
48+
- `timestamp` (number) - The timestamp to format
49+
- `format` (string) - Format string with tokens
50+
51+
**Format Tokens:**
52+
53+
- `YYYY` - 4-digit year (e.g., 2025)
54+
- `YY` - 2-digit year (e.g., 25)
55+
- `MMMM` - Full month name (e.g., January)
56+
- `MMM` - Short month name (e.g., Jan)
57+
- `MM` - 2-digit month (e.g., 01)
58+
- `M` - Month number (e.g., 1)
59+
- `DD` - 2-digit day (e.g., 06)
60+
- `Do` - Day with ordinal suffix (e.g., 6th)
61+
- `D` - Day number (e.g., 6)
62+
- `HH` - 2-digit hour (e.g., 14)
63+
- `H` - Hour number (e.g., 14)
64+
- `mm` - 2-digit minute (e.g., 30)
65+
- `m` - Minute number (e.g., 30)
66+
- `ss` - 2-digit second (e.g., 25)
67+
- `s` - Second number (e.g., 25)
68+
- `SSS` - 3-digit milliseconds (e.g., 123)
69+
- `SS` - 2-digit milliseconds (e.g., 12)
70+
- `S` - 1-digit milliseconds (e.g., 1)
71+
- `X` - Unix timestamp in seconds
72+
- `x` - Unix timestamp in milliseconds
73+
74+
**Returns:** `string` - Formatted date string
75+
76+
#### `makeRelative(timestamp)`
77+
78+
Converts a timestamp to a relative time string.
79+
80+
**Parameters:**
81+
82+
- `timestamp` (number) - The timestamp to convert
83+
84+
**Returns:** `string` - Relative time string (e.g., "2 minutes ago")
85+
86+
#### `addSuffix(num)`
87+
88+
Adds ordinal suffix to a number (1st, 2nd, 3rd, 4th, etc.).
89+
90+
**Parameters:**
91+
92+
- `num` (number|string) - The number to add suffix to
93+
94+
**Returns:** `string` - Number with ordinal suffix
95+
96+
### Properties
97+
98+
#### `months`
99+
100+
Array of month names:
101+
102+
```osl
103+
["January", "February", "March", "April", "May", "June",
104+
"July", "August", "September", "October", "November", "December"]
105+
```
106+
107+
#### `mul`
108+
109+
Time multiplication constants:
110+
111+
```osl
112+
{
113+
second: 1,
114+
minute: 60,
115+
hour: 3600,
116+
day: 86400,
117+
year: 31557600
118+
}
119+
```
120+
121+
## 📝 Examples
122+
123+
### Basic Formatting
124+
125+
```osl
126+
import 'datetime/v1' from 'packages' as 'dt'
127+
128+
local now = dt.now()
129+
130+
// Different format examples
131+
log dt.format(now, "YYYY-MM-DD") // 2025-07-06
132+
log dt.format(now, "MMMM Do, YYYY") // July 6th, 2025
133+
log dt.format(now, "MMM DD, YY") // Jul 06, 25
134+
log dt.format(now, "HH:mm:ss") // 14:30:25
135+
log dt.format(now, "h:mm A") // 2:30 PM
136+
```
137+
138+
### Working with Ordinals
139+
140+
```osl
141+
import 'datetime/v1' from 'packages' as 'dt'
142+
143+
log dt.addSuffix(1) // "1st"
144+
log dt.addSuffix(2) // "2nd"
145+
log dt.addSuffix(3) // "3rd"
146+
log dt.addSuffix(4) // "4th"
147+
log dt.addSuffix(11) // "11th"
148+
log dt.addSuffix(21) // "21st"
149+
log dt.addSuffix(22) // "22nd"
150+
```
151+
152+
### Time Calculations
153+
154+
```osl
155+
import 'datetime/v1' from 'packages' as 'dt'
156+
157+
local now = dt.now()
158+
local oneHourAgo = now - dt.mul.hour
159+
local oneDayFromNow = now + dt.mul.day
160+
161+
log dt.format(oneHourAgo, "HH:mm") // One hour ago
162+
log dt.format(oneDayFromNow, "YYYY-MM-DD") // Tomorrow's date
163+
```

datetime/v1.0.0/info.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "datetime",
3+
"version": "1.0.0",
4+
"description": "A comprehensive datetime utility library for OSL with formatting, manipulation, and relative time functionality",
5+
"main": "script.osl",
6+
"dependencies": {},
7+
"tags": ["time", "date", "formatting", "utility", "calendar"]
8+
}

0 commit comments

Comments
 (0)