Git Product home page Git Product logo

vscode's Introduction

sn-edit

Tools and Docs

What is sn-edit?

The app has been built out of a need to have a way to develop scripts locally in your favorite editor. With sn-edit, you are able to develop your scripts, change entries on your instance, without opening it.

You can use your favorite IDE/Editor to develop new features. We provide binaries for all the major platforms, this makes sn-edit fully compatible with MacOS, Windows and Linux too. This is achieved due to the nature of the language sn-edit was built with.

We've built sn-edit in Go which makes it easy to support all the major platforms listed above.

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

We would like to make sn-edit as minimal as possible. This means that in the long-run, we would rather have fewer features which are stable, than to support many and have a lot of issues with the scope of it.

We are pro-simplicity. If we can get the information from a Servicenow instance, we would like to make the experience as easy as possible. For the supported commands, we always try to minimize the impact of you providing the minimal amount of flags needed to execute the command. In any case, that you find that we are asking too much, that could've been queried from the instance and easily reusable, then let us know in an issue, and we will try to evaluate the requirement.

Installation

Please refer to the docs for an installation guide. You can find the guide for every major platform there. Please follow the steps closely.

Features

Here is a list of features we are supporting right now. The list is something more like a highlight of it. If you find the list incomplete at any point, please send a pull request.

  • Download an entry
  • Upload fields of an entry
  • Scope support
  • Update sets support
  • Masking the credentials (rest)
  • Custom tables support
  • Custom fields, saved into a file based on the configured extension (script => js, name => txt)
  • Execute scripts on the instance
  • A local low-profile sqlite database for metadata and usage inside of sn-edit

Extensions support

We've built sn-edit in a way, to make it very easy to integrate anywhere. Due to it's nature of being supported on any major platform and for the fact, that the commands are basically the same everywhere, we invite you, the community to develop extensions for any IDE or Editor of choice. We may support some of them officially, but we are not able cover every one of them.

Official Extensions:

Personal maintainer note:

I invite all of you to create community built extensions to the major editors out there. I am determined to provide a stable CLI as the building stone of the various extensions.

We would like to support every major Editor or IDE in this case too, so if you have the skill and time, please develop an extension for any one of them. The best could be moved to an official repo under this organization. The idea is to have wide support for all the major platforms out there.

vscode's People

Contributors

0x111 avatar isger avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

ddonnelly19

vscode's Issues

Support downloading of entries

We need a UI for the users in the vscode extension called with a command, that would allow them to search entries on the instance.

Some kind of autocomplete functionality must be workable I think from the extension. Needs some research.

A cli command will be needed too, that will return dataset in json format and this could be then feeded to the extension.

Flow:

  • User chooses the download command
  • Display an autocomplete box or whatever vscode provides for this
  • User first picks the table (Pending changes of sn-edit/sn-edit#19)
  • Only display tables pre-existing in our config table (Up for discussion)
  • Then after picking a table, call a different command that would then list all the entries (We will need some kind of limit on what to display at first and then an infinity scroll like stuff, lets talk about our options here)
  • After picking one of the entries, run sn-edit download with the table and sys_id to download an entry more here

Blocking PR #12

Escape userinput

We need to use something that can escape user input, implementing it ourselves will not be ideal, there can be a lot of edge-cases which we are not able to think about all of them.

Config generation

The config generation should be done in multiple steps.

  • Someone runs command, generate config
  • The extension downloads the sample yaml file from here: https://github.com/sn-edit/sn-edit/blob/master/_config/sn-edit.sample.yaml
  • After download, we parse the yaml into some kind of object and display choices based on the yaml file
  • Everything under the core key is mandatory, so users have to fill out through the UI the following details
  core:
    log_level: info
    rate_limit: 2
    db:
      path: /path/to/db/file
      initialised: false
    rest:
      masked: false
      password: password
      url: https://dev111.service-now.com
      user: admin
      xor_key: randomxorkey
    root_directory: /path/to/scripts/folder/tmp
  • Ask the user for each input separately, so first he would set the log level. That can be one of these:
    https://github.com/sn-edit/sn-edit/blob/f0a64fd5ced9f2c9850527f66e0ffcff3032e149/conf/conf.go#L31-L47
    See the strings there. (debug, info etc.)
    The user should pick one in Vscode and this would be written to that value
  • Rate limit is a historical option, leave it at 2, optinally it will disappear
  • Db path is a path to the database file locally, it should be a valid path.
    If you can pick files in vscode, then we should use that, if not, default of this option is the current workspace path.
    Let the user write the whole path. Only a full path is allowed here.
  • After submission, validate if the db path is valid. The folder described should exist, but the file will be automatically created by sn-edit if nonexistent.
  • Another bigger topic here are the rest credentials. The user provides a username and password for these so please request that from them through the UI.
    • Show input for username and password
    • Ask for the xor_key, this is used for masking the password so we do not store plaintext values
  • The root_directory is also mandatory, ask for it and after submission validate if the directory exists.

Make some functions generic

To avoid repetitive calls to determine the currently edited filename and also to have some generics lets make a core function that would be used throughout the app.

This would also allow us for more flexibility in the future if we would decide to change this at some point.

Functions that we need in core:

  • Get the current field name
    If someone is editing script.js which is a script field in some table, then we should have a simple function lets call it getFieldName that would based on the vscode objects determine the current file)
  • Get table name
    Detect the current table based on the path we are in, there is some template code available, reuse that with some checks
  • Get the scope for current file
    The same as above, from the file path we should be able to determine this without an issue.
    Get sys_id for fields
    This should do something similar, we should be able to read sys_id.txt in our currently edited files folder, which should be present always but introduce some checks for this. The function should return the sys_id or some error if none found.

Implement Open on instance

Implement a feature that would allow users to open the file they are currently editing on their instance.

Also find a suitable keyboard shortcut to make this more easily usable!

Support uploading entries

Uploading an entry should be possible with a command but also with the option to listen on the "onsave" event of a file that is currently opened and has a valid path to tour workspace.

Two flows here:
Uploading with a command
* Run upload command
* The extension identifies sys_id and table from path and sys_id.txt file
* Calls the sn-edit upload --table tablename --sys_id sys_id command which will upload the entry
* Display a notification about success/failure

One flow in this case

  • Upload on save
    • The extension identifies sys_id and table from path and sys_id.txt file
    • Calls the sn-edit upload --table tablename --sys_id sys_id command which will upload the entry
    • Display a notification about success/failure

Update sets management

On the right bottom side we will display the current update set based on the opened file that is currently open in the editor.

If there is no valid update set found, we will not display update set information (like for the config file which makes no apparent sense right?)

  • Onclick on this statusbar item, we have a command bound
  • After clicking, display a list of other update sets other than the current one and let the user choose a different one
  • After the user chooses a different update set, use the sn-edit updateset --set flag to set this new update set as the session default more info here
  • Display success/error if update set was set or not and update the bottom right corner display with the newly selected update set (since that would be our new default)

Display and Manage update set

  • Display the currently selected default update set for the scope that we are working in.

The scope is always added to the path of the files/entries. This means that if a file is open in the editor, we can determine the scope from the filepath.

Based on this we can call the command sn-edit updateset --list --scope scopename, this will first request the data from the instance and then cache it in the database.

After subsequent calls, the data will be only returned from the database, which is quite instant. The update set name should be displayed in a notification bar or somewhere in the UI where appropiate.

  • Update update set based on file changes

If the currently opened file changes (someone switches to a new file), we should check if this new file is in a different scope, if yes, update the update set as described above by calling the command again.

While gathering information, please display some loading bar if technically possible in place of an empty update set name or something that would show the users that we are detecting the current update set.

  • Clear update set cache command

Also add a command that would truncate the local cache.
Call it "Clear update set cache", this will be a seaparate command that would call sn-edit updateset --truncate in the background and clear all update set data.

  • Set default update set per scope
    Please add a command that would allow users to set a default update set for subsequent entry uploads.

After calling this vscode command, please display a text field, where they could write update set names. After submission, call sn-edit updateset --list --scope scopename --json which gets us a list of currently available update sets for that scope.

After the listing, display these to the user, so they can choose one update set to set as default. If they did choose one, run sn-edit updateset --set --scope scopename --update_set sysidofupdateset, this will set the update set if run.

Display some notification to the user about success/failure.

Check for workspacepath

Check if workspacepath is existent and print out an error if not.

const workspacePath = vscode.workspace.workspaceFolders[0].uri.path;

This path specifically

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.