Projects and extensions
A project is a folder with a config.NAIL file in it. njim sets one up and installs extensions and packages into it, and you can make extensions of your own.
Making a project
In an empty folder, njim init makes a project: a config.NAIL file and a main.naja to start from. njim init -focus asks for its name, version, author and the extensions it needs. njim init -focused(discord) lets an extension set the project up its own way, like a Discord bot with a menu for adding commands.
njim init
Made the project bakery here: config.NAIL and main.naja. Run it with naja run.config.NAIL
config.NAIL says what the project is: its name, its version and the file to start from. It's written in NAIL, Najova's data language, with the name of each value on its own line and the value under it.
name:
> "bakery"
version:
> "0.0.1"
main:
> "main.naja"Running a project
In the project's folder, naja run with no file runs the main file. Your own shared scripts go in modules/, and $use finds them there from any script in the project: see Modules.
$use[prices]
$print[Rye is $call[prices.price;rye] today.]› naja run
Rye is 3.75 today.What's in a project folder
bakery/
config.NAIL the project's name, version and main file
main.naja where naja run starts
modules/ your shared scripts, and the extensions njim installs
packages/ the packages njim installs
data.dnaj dataNaja's table shapes (its rows go in .najdata/)Installing extensions and packages
Run njim in the project's folder. An extension or package it installs is on for every file in the project, with nothing to add to your code. To turn one off in a single file, put $exclude[discord] at its top.
| Command | What it does |
|---|---|
njim i ext discord | Installs an extension into this project |
njim i pack discord/xp | Installs a package, and its extension too if it isn't there |
njim list | What's installed here and for every project |
njim list -available | What you can install |
njim rm ext discord | Removes it again, to the Recycle Bin |
njim i ext discord -global | Installs it once for every project on this computer |
njim only ever removes or replaces what it installed itself, so a file of your own with the same name is safe. Every download is checked before it's unpacked. See njim for all its commands.
Making an extension
An extension is a folder with an extension.json that names it and lists the functions it adds.
{
"id": "clock",
"name": "clock",
"version": "0.1.0",
"description": "Opening hours: is the shop open, and when does it open next.",
"entry": "main.naja",
"adds": ["isOpen", "opensAt"]
}Its main file makes each of those functions. The $-- lines above a function are its help, and a $-- usage: line says how it's written: the Najova IDE and these docs show both.
$-- Whether the shop is open at an hour of the day (0 to 23).
$-- usage: $isOpen[hour]
$function[isOpen;hour]
$return[$get[hour] >= 7 && $get[hour] < 18]
$endfunction
$-- The hour the shop opens.
$-- usage: $opensAt
$function[opensAt]
$return[7]
$endfunctionPut the folder in a project's modules/ to try it: $isOpen[9] then works in every file. Add a README.md and a CHANGELOG.md beside them, and they become the Readme and Changelog tabs of its page under Extensions & Packages.
Packages
A package adds to one extension, like XP and levels for a Discord bot. It's made the same way, with "id": "discord/xp" and the version of the extension it needs in "requires". A package can only add new names, never change the extension's own.
Sharing
Najova's own extensions, like discord, can be installed with njim now. Sharing your own with everyone comes with the registry at Najova 1.0, where each one is named with its author, like clock.Sam, so two people can use the same name. See the roadmap.