Code Monkey home page Code Monkey logo

nest's Introduction

Nest CLI

Nest's (soon to be) official CLI to manage your modules

NOTE: Nest CLI is still under development and non operational. Until official release, eggs is the official CLI.

Getting started

INSTALL

deno install -Af https://nest.land/-/nest/nest.ts

PUBLISH

Log into your Nest account

nest login <username> <auth_token>

Initialize a nest module

cd <module directory>
nest init <name> # follow the prompts

Publish to Nest

nest publish <version>

Contributing

REQUIREMENTS

Deno: >=v1.7.0

License

The contents of this repository are licensed under The MIT license.

nest's People

Contributors

maximousblk avatar steelalloy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nest's Issues

Config files (data.json module.json)

  • parse files
  • type checking
// .nest/module.json

{
  "$schema": "https://nest.land/-/nest-cli/schema.json",

  "name": "mod",
  "full_name": "My Awesome Module",
  "description": "I swear my module is the best out there",
  "homepage": "https://my.awesome.module",
  "license": "LICENSE",

  "hooks": {
    "presync": "command",
    "postsync": "command",
    "prepack": "command",
    "postpack": "command",
    "prepublish": "command",
    "postpublish": "command",
    "preaudit": "command",
    "postaudit": "command"
  },

  "unlisted": false,
  "private": false
  // ...
}
// .nest/module.json interface
interface Module {
  $schema: string;

  name: string;
  fullName?: string; // default: `${name}`
  description?: string; // default: ""
  homepage?: string; // default: `https://nest.land/x/${user}/${module}`
  license?: string; // default: "UNKNOWN"

  hooks: {
    presync: string; // default: ""
    postsync: string; // default: ""
    prepack: string; // default: ""
    postpack: string; // default: ""
    prepublish: string; // default: ""
    postpublish: string; // default: ""
    preaudit: string; // default: ""
    postaudit: string; // default: ""
  };

  unlisted?: boolean; // default: false
  private?: boolean; // default: false
  // ...
}
// .nest/data.json

// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.

{
  "meta": {
    "name": "mod",
    "full_name": "My Awesome Module",
    "description": "I swear my module is the best out there",
    "homepage": "https://my.awesome.module",
    "license": "LICENSE",

    "hooks": {
      "presync": "command",
      "postsync": "command",
      "prepack": "command",
      "postpack": "command",
      "prepublish": "command",
      "postpublish": "command",
      "preaudit": "command",
      "postaudit": "command"
    },

    "unlisted": false,
    "private": false
    // ...
  },
  // cache the api for offline use
  "api": {
    "versions": ["1.0.0", "0.9.8", "0.9.7", "..."],
    "latestVersion": "1.0.0",
    "lastPublished": 1603171976111,
    "license": "MIT"
    // ...
  },
  "version": "1.0.0", // nest cli version
  "lastSync": 1602831956336,
  "nextAutoSync": 1602832005131
  // ...
}

Nest.land fails to install

๐Ÿ› Bug Report

The forst instruktion in the readme "INSTALL" does not work.

To Reproduce

  1. Run deno install -Af https://nest.land/-/nest/nest.ts

Expected behavior

Nest.land installs successfully

Actual Behavior

Deno throws error "error: An unsupported media type was attempted to be imported as a module." because https://nest.land/-/nest/nest.ts returns 404.

Environment

  • CLI version: -
  • Deno version: deno 1.7.1
  • Operating system and version: Windows 10 v88.0.4324.150

Additional context

-

Setup Command

  • implement logic
nest setup <name> # link current directory to an existing module

Switch Command

  • implement logic
nest switch [username] # switch to another user

Login Command

  • implement logic
nest login # prompt for login info
nest login [username] [token]

Init Command

  • implement UI
  • find a way to determine if a module is already initialized and linked
  • get username
nest init # asks to initialize a new module or link an existing one

  # if a module is already initialized and linked, just sync the metadata

  # Nest CLI 1.0.0
  # ? setup "~/mod"? [Y/n]:
  # ? link to an existing module? [Y/n]:
  # ? what's the name of your existing module? (mod):
  # i linked to "user/mod" (created .nest and added it to .gitignore)

  # Nest CLI 1.0.0
  # ? Setup "~/mod"? [Y/n]:
  # ? Link to an existing module? [Y/n]: n
  # ? Module name (mod):
  # ? Version (0.1.0):
  # ? Description:
  # ? Homepage:
  # i Linked to "user/mod" (created .nest and added it to .gitignore)

nest init <name> # initialize a new module in specified directory

Settings Command

  • Implement logic
nest settings # opens user settings in editor

Custom CLI framework

  • implement global command options
  • help command
  • catch errors and output log to file
  • flags type checking
  • custom logger
  • UX
    • advise on similar commands, flags, etc.
  • UI
    • use ASCII for stdout as much as possible
    • consistent look and feel
flag description
-h, --help Show this help
-V, --version Display version number
-L, --log-level <level> Set log level, info by default
-l, --log <path> Specify filepath to output logs, nest-debug.log by default
-G, --gui Perform the task in the gui

Upgrade Command

  • implement logic
  • update to new route format
  • change eggs to nest
nest upgrade [version] # upgrade nest cli to the given version

[version] A given version, the latest by default

Ignore file

  • implement logic
# .nest/ignore

@extends .gitignore

docs/
tests/
CHANGELOG
CODE_OF_CONDUCT.md
CONTRIBUTING.md
funding.yml

# all dot files are ignored by default so user needs to include them
!.shared_dot_file
!.shared_dot_directory/

Register Command

  • implement logic
nest register # opens the register page in browser

Sync Command

  • 1. compare the config in module.json (user editable) and data.json.
  • 1.1 if they are same just download the remote config (same as sync)
  • 1.2 if not same
  • 1.2.1 check what properties have changed
  • 1.2.2 download the remote config
  • 1.2.3 update the new properties
  • 1.2.4 upload the final result to the api
nest sync

Publish Command

Steps

nest publish

  1. evaluate the config
  2. create a tarball with a uuid in the file name
  3. upload the tarball and config to twig
  4. twig does it's magic and uploads to arweave
  5. twig sends the arweave URLs and the config to the api
  6. db gets updated, module is published

nest publish --wallet <path>

  1. evaluate the config
  2. create a tarball
  3. upload the tarball to arweave and get the file URLs
  4. send the arweave URLs and the config to the api
  5. db is updated, module is published

CLI

nest publish [ version ] [ --git ] [ --pre <id> ] [ --deno <semver>] [ --wallet <path> ] [ --unlisted ]

ARGUMENTS

  version            semver tag or one of "major", "minor", "patch" (default: "patch")

OPTIONS

  --git              use the latest git tag as version (ignored if <version> is provided)
  --pre <id>         publish as a prerelease with optional identifier
  --deno <semver>    semver range for supported deno versions
  --wallet <path>    path to custom arweave wallet
  --unlisted         publish as an unlisted version

semver behavior

# say the current version is [email protected]

nest publish                      # [email protected]
nest publish 1.2.3                # [email protected]
nest publish patch                # [email protected]
nest publish minor                # [email protected]
nest publish major                # [email protected]

nest publish --pre                # [email protected]
nest publish 1.2.3 --pre          # [email protected]
nest publish patch --pre          # [email protected]
nest publish minor --pre          # [email protected]
nest publish major --pre          # [email protected]

nest publish --pre alpha          # [email protected]
nest publish 1.2.3 --pre beta     # [email protected]
nest publish patch --pre rc       # [email protected]
nest publish minor --pre asdf     # [email protected]
nest publish major --pre pre      # [email protected]

Notes

  • if no versions are published yet and user runs nest publish use the version 0.1.0 (unstable)
  • when (and only) uploading to twig, include the .nest directory in the tarball

ToDo

  • create a tarball
  • send the config and uuid to the api
  • upload the tarball to arweave
  • do the twig magic locally

Audit Command

  • implement logic
nest audit # returns an audit report

deno install scripts failed

Desktop ๐ŸŽ deno install -Af https://nest.land/-/nest/nest.ts

Download https://nest.land/-/nest/nest.ts
error: An unsupported media type was attempted to be imported as a module.
  Specifier: https://nest.land/-/nest/nest.ts
  MediaType: Unknown

env:

Desktop ๐ŸŽ  deno --version
deno 1.8.3 (release, x86_64-apple-darwin)
v8 9.0.257.3
typescript 4.2.2

feat: use WebStorage API for internal data

๐Ÿš€ Feature

All the info that should not be view or edited by the user should be stored in localstorage.

Motivation

Deno added support for WebStorage API

blog post: https://deno.com/blog/v1.10#support-for-web-storage-api

This would also make the code a bit cleaner since we won't have to poke the environment variables to find the home directory just to get the user's access token.

pr: denoland/deno#7819

Implementation

The user would define the location during install like so:

deno install -qA --unstable --location https://nest.land https://nest.land/-/nest/nest.ts

and used like so:

// Add new user (nest login)
addUser(username: string, token: string) {
  const users: Users = JSON.parse(localStorage.getItem('users'));
	  
  users[username] = { token }

  localStorage.setItem('users', JSON.stringify(users);
}

addUser('maximousblk', 'NEST_6FF4C8F4374F46C5A5928AFE85C2354EA37AED00')


// Change active user (nest switch)
setActiveUser(username: string) {
  localStorage.setItem('activeUser', username);
}

setActiveUser('maximousblk')

Alternatives

n/a

Additional context

n/a

Config Command

  • Implement logic
nest settings # opens user settings in editor

Test codebase

  • ignore file parsing
  • JSON diff
  • type checking
  • version
  • CLI performances
  • etc.

Design guidelines

  • Use the latest standard modules as much as possible
    • semver on nest
  • Avoid using --unstable APIs
  • Store all config in a temporary .nest directory
  • Exclude all dotfiles by default while publishing
  • Enforce semver
  • Companion server for gui (later)

Logout Command

  • Implement logic
nest logout [username] # logout of current account

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.