diff --git a/docs/cli/README.md b/docs/cli/README.md index 9bc7dec..368cb4c 100644 --- a/docs/cli/README.md +++ b/docs/cli/README.md @@ -1,13 +1,55 @@ --- -title: Nest CLI -sidebar_label: Introduction +title: Getting started +sidebar_label: Getting started slug: /cli --- -:::caution Not a 404 but almost +:::caution Work in progress -This page is a work in progress. +Until the release of nest 1.0.0, the current CLI for nest is [eggs](../eggs/README.md). + +In the future, [eggs](../eggs/README.md) will be a reference module manager that has first-class support for Nest including private modules. Other module managers can use this reference to integrate Nest into their software. ::: -[More info](https://github.com/nestdotland/cli) +The nest command line interface allows developers to easily create and publish modules on [nest.land](https://nest.land). + +It's written in TypesScript, utilizing the power of Deno. It's lightweight yet efficient, and it provides an easy and safe way for developers to manage their modules. + +### Install + +```shell script +deno install -Afq https://nest.land/-/nest/nest.ts +``` + +### Publish + +Log into your Nest account + +```shell script +nest login +``` + +:::note New to Nest.land? +[Create an account](https://nest.land/#). +::: + +Initialize a nest module + +```shell script +cd +nest init # follow the prompts +``` + +Publish to Nest + +```shell script +nest publish +``` + +You should now see your module on the [gallery](https://nest.land/gallery) ! + +## Contributing + +Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated. [Learn more](https://github.com/nestdotland/nest/blob/main/.github/CONTRIBUTING.md) + diff --git a/docs/cli/cicd.md b/docs/cli/cicd.md new file mode 100644 index 0000000..3b2a970 --- /dev/null +++ b/docs/cli/cicd.md @@ -0,0 +1,4 @@ +--- +title: Continuous Integration / Continuous Development +sidebar_label: CI/CD +--- diff --git a/docs/cli/commands/config/diff.md b/docs/cli/commands/config/diff.md new file mode 100644 index 0000000..fcd6b77 --- /dev/null +++ b/docs/cli/commands/config/diff.md @@ -0,0 +1,69 @@ +--- +title: nest config diff +sidebar_label: diff +--- + +Show changes in local config. + +```shell script +nest config diff +``` + +## Options + + | options | description | + | ----------- | ---------------------------- | + | `-r, --remote` | Compare with remote config | + +:::info +Compares the changes with the data.json file by default. +::: + +## Examples + +```shell script +nest config diff +nest config diff --remote +``` + +```diff + { + fullName: "Nest CLI", + description: "Nest's official CLI to manage your modules", + main: "nest.ts", + bin: [ + "cli.ts", ++ "nest.js", + ], +- logo: "assets/logo.png", ++ logo: "assets/nest.png", + homepage: "https://nest.land/x/author/module", + repository: "https://github.com/nestdotland/nest", + issues: "https://github.com/nestdotland/nest/issues", + license: "MIT", +- unlisted: false, + private: false, + keywords: [ + "cli", + "registry", + "nest", + ], + hooks: { + prepublish: "deno fmt --check", +- postpublish: "echo Success!", + presync: "sleep 3", + postsync: "cat .nest/module.json", + }, + }, +``` +```diff + # List here the files and directories to be ignored, one by line as a glob expression. + +- # Dotfiles are ignored by default. ++ # Dotfiles are ignored by default + .* + ++ *_test.ts ++ .nest ++ +``` \ No newline at end of file diff --git a/docs/cli/commands/config/pull.md b/docs/cli/commands/config/pull.md new file mode 100644 index 0000000..da69eff --- /dev/null +++ b/docs/cli/commands/config/pull.md @@ -0,0 +1,27 @@ +--- +title: nest config pull +sidebar_label: pull +--- + +Fetch from and integrate with remote config. Your local changes will be merged with a diff algorithm. You will be warned if conflicts are found during the merge process. + +```shell script +nest config pull +``` + +## Options + + | options | description | + | ------------- | ---------------------- | + | `-f, --force` | Overwrite local config | + +:::caution +Use the `--force` option only if you need to reset your local config. Resolving merge conflicts is preferable in most cases. +::: + +## Examples + +```shell script +nest config +nest config ---force +``` diff --git a/docs/cli/commands/config/push.md b/docs/cli/commands/config/push.md new file mode 100644 index 0000000..670f7de --- /dev/null +++ b/docs/cli/commands/config/push.md @@ -0,0 +1,27 @@ +--- +title: nest config push +sidebar_label: push +--- + +Update remote config. By default you can only push your configuration if it is newer than the remote configuration or if you have previously pulled the changes. + +```shell script +nest config push +``` + +## Options + + | options | description | + | ------------- | ----------------------- | + | `-f, --force` | Overwrite remote config | + +:::caution +Use the `--force` option only if you need to reset remote config. Resolving merge conflicts is preferable in most cases. +::: + +## Examples + +```shell script +nest config push +nest config push --force +``` diff --git a/docs/cli/commands/config/status.md b/docs/cli/commands/config/status.md new file mode 100644 index 0000000..7909b89 --- /dev/null +++ b/docs/cli/commands/config/status.md @@ -0,0 +1,27 @@ +--- +title: nest config status +sidebar_label: status +--- + +Show the current config status. + +```shell script +nest config status +``` + +## Examples + +```shell script +nest config status +``` +``` +i Local diff status: + - module.json modified + - ignore unchanged + +i Remote diff status: + - module.json modified + - ignore modified + +i Current config is newer than remote config +``` diff --git a/docs/cli/commands/help.md b/docs/cli/commands/help.md new file mode 100644 index 0000000..a048612 --- /dev/null +++ b/docs/cli/commands/help.md @@ -0,0 +1,28 @@ +--- +title: nest help +sidebar_label: help +--- + +Show the global help or the help of a sub-command. + +```shell script +nest help [...command] +``` + +## Arguments + + | argument | description | + | ---------- | -------------------------- | + | ...command | A command or a sub-command | + +:::info +Show the global help if no command is provided +::: + +## Examples + +```shell script +nest help +nest help login +nest help publish 1.2.5 --pre +``` diff --git a/docs/cli/commands/init.md b/docs/cli/commands/init.md new file mode 100644 index 0000000..b0b0a6e --- /dev/null +++ b/docs/cli/commands/init.md @@ -0,0 +1,43 @@ +--- +title: nest init +sidebar_label: init +--- + +Initiate a new module for the nest.land registry. Will create the necessary configuration files. + +```shell script +nest init +``` + +:::tip +Use [`nest setup`](./setup.md) if your module already exists ! +::: + +## Prompts + +```script shell +Initialize directory ? > +``` +Exits if `false` + +```script shell +Link to an existing module? > +``` + +:::info +If you answer `yes`, behaves in the same way as the [`nest setup`](./setup.md) command. +::: + +```script shell +Module name > +Module full name > +Description > +Homepage > +Homepage > +``` + +## Examples + +```shell script +nest init +``` diff --git a/docs/cli/commands/login.md b/docs/cli/commands/login.md new file mode 100644 index 0000000..a3183fc --- /dev/null +++ b/docs/cli/commands/login.md @@ -0,0 +1,33 @@ +--- +title: nest login +sidebar_label: login +--- + +Add an existing user account. + +```shell script +nest login [username] [token] +``` + +:::note New to Nest.land? +[Create an account](https://nest.land/#). +::: + +## Arguments + + | argument | description | + | -------- | ------------- | + | username | A username | + | token | A login token | + +:::info +If `[username]` or `[token]` is missing, you will be prompted to enter it. +::: + +## Examples + +```shell script +nest login +nest login me +nest login me OltCnjbXVnkNYIr60/4IvA== +``` diff --git a/docs/cli/commands/logout.md b/docs/cli/commands/logout.md new file mode 100644 index 0000000..24734bd --- /dev/null +++ b/docs/cli/commands/logout.md @@ -0,0 +1,27 @@ +--- +title: nest logout +sidebar_label: logout +--- + +Remove an existing user account. + +```shell script +nest logout [username] +``` + +## Arguments + + | argument | description | + | -------- | ----------- | + | username | A username | + +:::info +If `[username]` is missing, you will be prompted to enter it. +::: + +## Examples + +```shell script +nest logout +nest logout me +``` diff --git a/docs/cli/commands/publish.md b/docs/cli/commands/publish.md new file mode 100644 index 0000000..86468a2 --- /dev/null +++ b/docs/cli/commands/publish.md @@ -0,0 +1,71 @@ +--- +title: nest publish +sidebar_label: publish +--- + +Publish your module to the nest.land registry. + +```shell script +nest publish [version] +``` + +## Arguments + + | argument | default | description | + | -------- | --------- | --------------------------------------------------------------------- | + | version | `"patch"` | [Semver tag](https://semver.org/) or one of "major", "minor", "patch" | + +If a release type is provided as `version`, increments the previous version from the given release type. See [examples](#examples) below. + +:::info +If no version is published yet, `version` defaults to `0.1.0` +::: + +## Options + + | options | description | + | --------------------- | ---------------------------------------------------------------------------------------- | + | `-Y, --yes` | Disable confirmation prompts | + | `-d, --dry-run` | No changes will actually be made, reports the details of what would have been published | + | `-g, --git-tag` | Use the latest git tag as version (ignored if `[version]` is provided) | + | `--pre [tag]` | Publish as a prerelease with optional identifier | + | `--deno ` | [Semver range](https://github.com/nestdotland/semver#ranges) for supported deno versions | + | `-w, --wallet ` | Path to custom arweave wallet | + | `--unlisted` | Publish as an unlisted version | + +:::tip +Use `--git-tag` when publishing to [deno.land](https://deno.land) and [nest.land](https://nest.land) on Github. +::: + +## Examples + +```shell script +# say the current version is module@1.0.0 + +nest publish # module@1.0.1 +nest publish 1.2.3 # module@1.2.3 +nest publish patch # module@1.0.1 +nest publish minor # module@1.1.0 +nest publish major # module@2.0.0 + +nest publish --pre # module@1.0.1-0 +nest publish 1.2.3 --pre # module@1.2.3-0 +nest publish patch --pre # module@1.0.1-0 +nest publish minor --pre # module@1.1.0-0 +nest publish major --pre # module@2.0.0-0 + +nest publish --pre alpha # module@1.0.1-alpha.0 +nest publish 1.2.3 --pre beta # module@1.2.3-beta.0 +nest publish patch --pre rc # module@1.0.1-rc.0 +nest publish minor --pre asdf # module@1.1.0-asdf.0 +nest publish major --pre pre # module@1.0.1-pre.0 +``` + +```shell script +nest publish --git-tag # module@[latest git tag] +``` + +```shell script +nest publish --deno ^1.7.1 +nest publish --deno ">=1.2.3 <1.7.0" +``` diff --git a/docs/cli/commands/setup.md b/docs/cli/commands/setup.md new file mode 100644 index 0000000..4d307a5 --- /dev/null +++ b/docs/cli/commands/setup.md @@ -0,0 +1,29 @@ +--- +title: nest setup +sidebar_label: setup +--- + +Link current directory to an existing module. + +```shell script +nest setup [author] [module] +``` + +## Arguments + + | argument | description | + | -------- | --------------- | + | author | A module author | + | module | A module name | + +:::info +If `[author]` or `[module]` is missing, you will be prompted to enter it. +::: + +## Examples + +```shell script +nest setup +nest setup me +nest setup me my-module +``` diff --git a/docs/cli/commands/switch.md b/docs/cli/commands/switch.md new file mode 100644 index 0000000..999171a --- /dev/null +++ b/docs/cli/commands/switch.md @@ -0,0 +1,31 @@ +--- +title: nest switch +sidebar_label: switch +--- + +Publish your module to the nest.land registry. + +```shell script +nest switch [username] +``` + +:::tip +Use this command when you need to work on multiple projects with different accounts. +::: + +## Arguments + + | argument | description | + | -------- | ----------- | + | username | A username | + +:::info +If `[username]` is missing, you will be prompted to enter it. +::: + +## Examples + +```shell script +nest switch +nest switch user12648 +``` diff --git a/docs/cli/commands/sync.md b/docs/cli/commands/sync.md new file mode 100644 index 0000000..4c5783c --- /dev/null +++ b/docs/cli/commands/sync.md @@ -0,0 +1,29 @@ +--- +title: nest sync +sidebar_label: sync +--- + +Synchronize remote and local configuration. This command is an abstraction of the [pull](config/pull.md) and [push](config/push.md) commands. + +```shell script +nest sync +``` + +:::info +Synchronization logic: +```js +if (local config older than remote config) { + pull config & merge config; + if (conflicts) { + return; + } +} +push config; +``` +::: + +## Examples + +```shell script +nest sync +``` diff --git a/docs/cli/commands/upgrade.md b/docs/cli/commands/upgrade.md new file mode 100644 index 0000000..3ada27d --- /dev/null +++ b/docs/cli/commands/upgrade.md @@ -0,0 +1,23 @@ +--- +title: nest upgrade +sidebar_label: upgrade +--- + +Upgrade nest cli to the given version. + +```shell script +nest upgrade [version] +``` + +## Arguments + + | argument | default | description | + | -------- | ------- | ---------------------- | + | version | latest | A given semver version | + +## Examples + +```shell script +nest upgrade +nest upgrade 1.0.0 +``` diff --git a/docs/cli/configuration/ignore.md b/docs/cli/configuration/ignore.md new file mode 100644 index 0000000..5ebd714 --- /dev/null +++ b/docs/cli/configuration/ignore.md @@ -0,0 +1,58 @@ +--- +title: ignore +sidebar_label: ignore +--- + +An `ignore` file specifies intentionally files that nest should ignore. Each line in an `ignore` file specifies a pattern. + +The syntax of nest's `ignore` file is a superset of the [`.gitignore` pattern format](https://git-scm.com/docs/gitignore#_pattern_format). + +## Pattern format + + - A blank line matches no files, so it can serve as a separator for readability. + + - A line starting with # serves as a comment. Put a backslash ("`\`") in front of the first hash for patterns that begin with a hash. + + - Trailing spaces are ignored unless they are quoted with backslash ("`\`"). + + - An optional prefix "`!`" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn't list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined. Put a backslash ("`\`") in front of the first "`!`" for patterns that begin with a literal "`!`", for example, "`\!important!.txt`". + + - The slash / is used as the directory separator. Separators may occur at the beginning, middle or end of the `ignore` search pattern. + + - If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular `ignore` file itself. Otherwise the pattern may also match at any level below the `ignore` level. + + - If there is a separator at the end of the pattern then the pattern will only match directories, otherwise the pattern can match both files and directories. + + - For example, a pattern `doc/frotz/` matches `doc/frotz` directory, but not `a/doc/frotz` directory; however `frotz/` matches `frotz` and `a/frotz` that is a directory (all paths are relative from the `ignore` file). + + - An asterisk "`*`" matches anything except a slash. The character "`?`" matches any one character except "`/`". The range notation, e.g. `[a-zA-Z]`, can be used to match one of the characters in a range. + +Two consecutive asterisks ("`**`") in patterns matched against full pathname may have special meaning: + + - A leading "`**`" followed by a slash means match in all directories. For example, "`**/foo`" matches file or directory "`foo`" anywhere, the same as pattern "`foo`". "`**/foo/bar`" matches file or directory "`bar`" anywhere that is directly under directory "`foo`". + + - A trailing "`/**`" matches everything inside. For example, "`abc/**`" matches all files inside directory "`abc`", relative to the location of the `ignore` file, with infinite depth. + + - A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "`a/**/b`" matches "`a/b`", "`a/x/b`", "`a/x/y/b`" and so on. + + - Other consecutive asterisks are considered regular asterisks and will match according to the previous rules. + +## `@extends` keyword + +You can import other files with the `@extends` keyword. The extended file must follow the same syntax. + +:::tip +Use the `@extends` keyword to avoid duplicating the content of your `.gitignore` file. +::: + +## Examples + +```shell script +@extends .gitignore + +# exclude everything except directory foo/bar +/* +!/foo +/foo/* +!/foo/bar +``` \ No newline at end of file diff --git a/docs/cli/configuration/module.json.md b/docs/cli/configuration/module.json.md new file mode 100644 index 0000000..e79d48a --- /dev/null +++ b/docs/cli/configuration/module.json.md @@ -0,0 +1,67 @@ +--- +title: module.json +sidebar_label: module.json +--- + +The metadata file of your module. + +None of the properties described in this section are required to publish your module. However, it brings valuable information on your module that helps users to use it. + +| field | type | description | +| ----------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------- | +| fullName | `string` | A longer name, without character restrictions or length limit. | +| description | `string` | This helps people discover your module by explaining its purpose. | +| main | `string` | A file path to the primary entry point to your program. | +| bin | `string[]` | An array of file path to one or more executable files. | +| logo | `string` | A file path to your module logo. Will be displayed when module is featured. | +| homepage | `string` | The url to the project homepage. | +| repository | `string` | Specify the place where your code lives. This is helpful for people who want to contribute. | +| issues | `string` | The url to your project's issue tracker and / or the email address to which issues should be reported. | +| license | `string` | You should specify a license for your module so that people know how they are permitted to use it, and any restrictions you're placing on it. | +| unlisted | `boolean` | The module will not be found on the website unless you have the exact link. | +| private | `boolean` | Encrypts your module on the blockweave. You can fetch it and decrypt it through the eggs CLI. (not implemented yet) | +| keywords | `string[]` | It helps people to find your module when searching for it. | +| hooks | `Hooks` | Hooks are scripts that nest executes before or after events such as: publish, and sync. | + +## Hooks + +To create "pre" or "post" hooks for any valid event in the `hooks` section of the module.json, simply create another key with a matching name and add "pre" or "post" to the beginning of them. + +Valid events: + - `publish` + - `sync` + +## Example + +Here is an example of a complete configuration: + +```json +{ + "fullName": "Nest CLI", + "description": "Nest's official CLI to manage your modules", + "main": "nest.ts", + "bin": ["bin/cli.ts", "eggs.ts"], + "logo": "assets/logo.png", + "homepage": "https://nest.land", + "repository": "https://github.com/nestdotland/nest", + "issues": "https://github.com/nestdotland/nest/issues", + "license": "MIT", + "unlisted": false, + "private": false, + "keywords": ["cli", "registry", "nest" ], + "hooks": { + "prepublish": "deno fmt --check", + "postpublish": "echo Success!", + "presync": "sleep 3", + "postsync": "cat .nest/module.json" + } +} +``` + +## data.json + +:::danger +`data.json` is an autogenerated file. Do not edit this file directly. +::: + +This file is used by the CLI to determine the properties that have been changed during synchronization. In addition, you can find out the most recent version published as well as other information provided by the API. diff --git a/docs/cli/faq.md b/docs/cli/faq.md new file mode 100644 index 0000000..48b878a --- /dev/null +++ b/docs/cli/faq.md @@ -0,0 +1,25 @@ +--- +title: FAQ +sidebar_label: FAQ +--- + +### Why do I have a directory named `.nest` in my project? + +The `.nest` directory is created when you link a directory to a Nest module. + +### What does this directory contain? + +The `module.json` file contains metadata about the module + +The `ignore` file contains a list of files that are ignored or included + +The `data.json` file is an auto generated file. This file should **NOT** be directly edited by the user. + +### Should I commit the `.nest` directory? + +**No**, you should not commit the `.nest` directory to your repository. +Upon creation, it will be automatically added to your `.gitignore` file. + +### Why are Nest CLI and eggs separate? + +Nest CLI is the main utility you would use to create and publish modules. Eggs on the other hand, is just a reference module manager that has first-class support for Nest including private modules. Other module managers can use this reference to integrate Nest into their software. diff --git a/docs/nest/README.md b/docs/nest/README.md index ce537d8..305c855 100644 --- a/docs/nest/README.md +++ b/docs/nest/README.md @@ -1,5 +1,5 @@ --- -title: Nest +title: Nest.land sidebar_label: Introduction slug: / --- @@ -34,6 +34,13 @@ You can find our source code [here](https://github.com/nestdotland). 2. Your code is served from a truly decentralized network of computers from around the world. 3. You don't need to vendor your modules! -## Questions? +## Staying informed -Start a [GitHub Discussion](https://github.com/nestdotland/nest.land/discussions) or [tweet at us](https://twitter.com/nestdotland)! +- [Github](https://github.com/nestdotland) +- [Twitter](https://twitter.com/nestdotland) +- [Discord](https://discord.gg/hYUsX3H) +- [Blog](https://nest.land/blog) + +## Something missing / Questions ? + +If you find issues with the documentation or have suggestions on how to improve the documentation or the project in general, please [file an issue](https://github.com/nestdotland/nest.land/issues/new/choose) for us, start a new [GitHub Discussion](https://github.com/nestdotland/nest.land/discussions), or [tweet at us](https://twitter.com/nestdotland)! diff --git a/sidebars.js b/sidebars.js index 30fa14d..449cacf 100644 --- a/sidebars.js +++ b/sidebars.js @@ -1,7 +1,38 @@ module.exports = { someSidebar: { - Nest: ["nest/README"], - "Nest CLI": ["cli/README"], + "Nest.land": ["nest/README"], + "Nest CLI": [ + "cli/README", + { + Commands: [ + "cli/commands/help", + "cli/commands/init", + "cli/commands/setup", + "cli/commands/login", + "cli/commands/logout", + "cli/commands/switch", + "cli/commands/publish", + "cli/commands/sync", + { + config: [ + "cli/commands/config/pull", + "cli/commands/config/push", + "cli/commands/config/diff", + "cli/commands/config/status", + ], + }, + "cli/commands/upgrade", + ], + }, + { + "Configuration files": [ + "cli/configuration/module.json", + "cli/configuration/ignore", + ], + }, + "cli/faq", + "cli/cicd", + ], Eggs: [ "eggs/README", "eggs/installation",