Giter Club home page Giter Club logo

gh-edu's People

Contributors

ggcristo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

gh-edu's Issues

improvement to keep the configuration file in a separated user repo

Improvement to keep the configuration file in a separated user repo

The current code in file config.ts is to check if the file exist and otherwise to create a minimal file from the template:

export let config: configType;
if (!fs.existsSync(configPath)) {
  console.log("No config file detected");
  console.log("Creating new config...");
  fs.copyFileSync(__dirname + "/../utils/config.template.json", configPath, fs.constants.COPYFILE_EXCL);
}

Alternative to explore:

  1. if (!fs.existsSync(configPath)) {
    1. try to see if there is a repo github-user/gh-edu-profile in GitHub and if so
    2. get the config file config.json from there by cloning the repo,
    3. make a symbolic link to the config file
  2. otherwise, if there is no gh-edu-profile repo at GH
    1. make a folder gh-edu-profile in the extension folder
    2. copy the minimal template to gh-edu-profile
    3. make a symbolic link to the just created config file
    4. create the github repo github-user/gh-edu-profile and push the config file

It is a lot of work

design thoughts

State at 22/04/2022

gh org clone

  • search option is convenient

  • specific help for clone must be improved

    • fzf must be installed, what is going to happen, etc.

Some Commands to add

gh org cd ULL-ESIT-PL-2122

cd subcommand is needed.

May be fuzzy search with fzf and cache can improve efficiency

gh org cd PL-2122

wu¡ill find org ULL-ESIT-PL-2122

gh org pwd

gives the default org

Cache

May be we cache the orgs inside the config file and other things, but if we cache we need a gh org update command

Strategy Pattern

gh org install

Example: gh org install clone will install plugin in https://github.com/gh-cli-for-education/gh-org-clone

a variant of the command will be:

gh org install ggcristo/gh-org-clone

Configuration file

Stored in:

$HOME/.local/share/gh/extensions/gh-org/config.js

__dirname

module.exports = {
  defaultOrg: "ULL-ESIT-PL-2122",
  commands: {
     "clone" : { ... },
     "cd": { ...},
     "pwd": {... },
    ...
 },
  cache: {
        orgs: [. ... user orgs ... ]
   }
}

troubles with config.json

I pulled the repo (27/06/2022) and installed using a link (gh extension install .)

Then I did:

➜  gh-edu git:(main) ✗ gh edu -h
No configuration file detected
Remote config file detected
Configuration file dowloaded
All commands must have a lastCommit field

Which is because I had already a tuned profile repo, but not compatible with the gh-edu current version.
That leads to a couple of questions:

  • Compatibility between different versions of the config file?
  • How to manage corruption of the config file?

I noticed the file config.json is a plain file downloaded from my gh-edu repo, but there is no way to track from what repo was obtained. I prefer you make a folder config/config.json that is an image of the config repo (i.e. is a local repo from user/gh-edu-profile).

So I decided to remove my gh-edu-profile user repo at GitHub and try it again, remove the extension

➜  gh-edu git:(casiano) ✗ gh extension remove gh-edu
✓ Removed extension edu

and install gh-edu again, this time without the link:

➜  gh-edu git:(casiano) ✗ gh extension install gh-cli-for-education/gh-edu

Clonando en '/Users/casianorodriguezleon/.local/share/gh/extensions/gh-edu'...
remote: Enumerating objects: 5645, done.
remote: Counting objects: 100% (40/40), done.
remote: Compressing objects: 100% (24/24), done.
remote: Total 5645 (delta 16), reused 28 (delta 12), pack-reused 5605
Recibiendo objetos: 100% (5645/5645), 5.13 MiB | 5.41 MiB/s, listo.
Resolviendo deltas: 100% (1802/1802), listo.
✓ Installed extension gh-cli-for-education/gh-edu

but the problem repeats:

➜  gh-edu git:(casiano) ✗ gh edu -h
No configuration file detected
Remote config file detected
Internal error: runCommand:  gh repo clone gh-edu-profile /var/folders/t8/zb7yv2x968537k4bjzrm189m0000gn/T/tmp-22371-hkF0yLyvycyd
GraphQL: Could not resolve to a Repository with the name 'crguezl/gh-edu-profile'. (repository)
Internal error: runCommand:  mv /var/folders/t8/zb7yv2x968537k4bjzrm189m0000gn/T/tmp-22371-hkF0yLyvycyd/config.json /Users/casianorodriguezleon/.local/share/gh/extensions/gh-edu/config.json

It says Remote config file detected but I have deleted my config repo and also the error says Could not resolve to a Repository with the name 'crguezl/gh-edu-profile' that I guess is normal, since the repo no longer exists. It does not creates the repo in case it doesn't exist?

gh edu install .

@GGCristo

There are several issues with gh-edu during development.

There is no way to install a plugin from a folder:

➜  gh-edu-browse git:(main) ✗ gh edu install .
Installing gh-cli-for-education/gh-edu-. ...
extension is not installable: missing executable

gh edu install (no args)

What do you think about this @GGCristo ?

We will keep of the plugins installed with gh edu install plugin inside the config.json file and then ...

When called without arguments:

gh edu install

should install (or update?) the plugins specified in file config.json.

config.json and upgrading gh-edu

@GGCristo

When a user upgrades gh-edu to the last version with s.t. like gh instal gh-edu,
since the file config.json belongs to the repo and more than likely the user has changed the config.json with organizations info, etc. conflicts may arise.

It seems that config.json is an independent file and must be stored in a different user repo?

Add plugin version in config.json

@GGCristo

This issue is related with issue #3

I see that the list of installed plugins is in the command section of the config.json file. It does not include the plugin version.

  "commands": {
    "view": {
      "originalName": "gh-cli-for-education/gh-edu-view"
    }

may be we must keep also the version of the installed plugins

For a medium size org the caching takes time "gh edu set -o"

Took 4 or 5 minutes to finish:

➜  gh-edu git:(main) gh edu set -o ULL-ESIT-PL-2122
Not in cache. Fetching... (Cache will be updated)
Default org set to:  ULL-ESIT-PL-2122

May be we can warn the user to wait or give some estimation of the time is going to take?

information leak

@GGCristo what do you think of this?

The file config.json contains data (students names, organizations, etc.) that must remain secret.

Since the repo we are using is public, the current info in the config file is exposed.

I am going to change the visibility of the repo to private until we found a satisfactory solution to this.

`org` in gh-edu but in `get` it is `organization`

@GGCristo

With the organization set:

➜ gh-edu git:(main) ✗ gh edu get -o
No option. doing nothing

In gh-edu the option is called org but in get it is organization. The inconsistency causes the option to be false

version:

➜ gh-edu git:(main) ✗ gh extension list | grep gh-edu
gh edu gh-cli-for-education/gh-edu 6ba2495d

gh edu does not find plugin when in development

When gh edu is cloned from gh-cli-for-education/gh-edu and later we install it locally with

gh extension install .

so that a symbolic link referencing the development folder (mine is /Users/casianorodriguezleon/campus-virtual/2122/tfg2122/tfg-cristo-garcia-gonzalez-alu0101204512/gh-edu) is created in ~/.local/share/gh/extensions.

Next, we install the view plugin:

gh edu install view

I have seen it is cloned in the folder ~/.local/share/gh/extensions/gh-edu-view and not in /Users/casianorodriguezleon/campus-virtual/2122/tfg2122/tfg-cristo-garcia-gonzalez-alu0101204512/gh-edu-view

In such conditions, when I try to run the plugin, gh edu is not able to locate it and fails.
However, when installed in production mode gh extension install gh-cli-for-education/gh-eduworks fine.

list of installed plugins: gh edu get -p

Versions

➜  gh-edu-view git:(main) gh extension list | grep gh-edu
gh edu	gh-cli-for-education/gh-edu	74da8868
gh edu-data	gh-cli-for-education/gh-edu-data	d3da62de
gh edu-view	gh-cli-for-education/gh-edu-view	1ea9b099
➜  gh-edu-view git:(main) date
viernes, 27 de mayo de 2022, 11:27:38 WEST

Problem

Dos not list the plugins:

➜  gh-edu-view git:(main) gh edu get -p
Builtin commands:
clone
get
install
remove
reset
set
update
External commands:
{
  "view": {
    "originalName": "gh-cli-for-education/gh-edu-view"
  }
}

Add support for secure token storage

Token storage change in latest release of gh

This is a message from the GitHub CLI team, maintainers of gh, writing to inform you that the most recent release of gh contains changes which may affect your extension. The latest release introduces the feature of storing authentication tokens in the system keyring (encrypted storage) instead of in a plain text file.
The keyrings that are supported are:

  • Keychain on macOS

  • GNOME Keyring on Linux (Secret Service dbus interface)

  • Wincred on Windows

This has huge security benefits for the users of our tool and was one of our oldest outstanding issues. Unfortunately this change has the potential to break extensions that rely on utilizing the users authentication token to work.

In order to have continued compatibility with gh there are some actions you, as an extension author, need to take. These actions will depend on the implementation of your extension.

Extensions built in Go using go-gh:

  1. Upgrade your go-gh version to v1.2.1, the latest version.

  2. Verify that in your extension retrieval of the user authentication token is done using the auth.TokenForHost function.

    • If you were previously accessing the authentication token using any other method it will no longer work.
    • Automatic resolution of the authentication token when using the API clients will continue to work without changes.

All other extensions:

  1. Verify that in your extension retrieval of the user authentication token is done by shelling out to the gh auth token command.

    • If you were previously accessing the authentication token using the gh config get command, reading the configuration file directly, or any other methods it will no longer work.

As of right now storing the authentication token in the system keyring is an opt-in feature, but in the near future it will be required and at that point if the changes above are not made then your extension will be broken for all users. If you have any questions/concerns about this change please feel free to open a discussion in the gh repo.

Thanks,
The GitHub CLI Team

fzf as a node lib

@GGCristo

Hay varias librerías que implementan fzf en JS.

Esta es una

https://www.npmjs.com/package/node-fzf

pero hay otras.

Quizá sería una consideración para el futuro en vez de usar fzf como programa (así no tiene que estar instalado en la máquina del usuario y es una dependencia?)

Lo digo por la memoria sección fzf

Exception raised for gh edu get -m when org is not set

After installing gh-edu on another mac, it gives an exception when running:

[~/.../tecnologia/tribunales(main)]$ gh edu get -m
No current organization configured
fatal error: runtime: bsdthread_register error

runtime stack:
runtime.throw(0x1164418, 0x21)
	/usr/local/Cellar/go/1.9.2/libexec/src/runtime/panic.go:605 +0x95 fp=0x7ff7bfeff4d0 sp=0x7ff7bfeff4b0 pc=0x1028165
runtime.goenvs()
	/usr/local/Cellar/go/1.9.2/libexec/src/runtime/os_darwin.go:108 +0x83 fp=0x7ff7bfeff500 sp=0x7ff7bfeff4d0 pc=0x1025a03
runtime.schedinit()
	/usr/local/Cellar/go/1.9.2/libexec/src/runtime/proc.go:492 +0xa1 fp=0x7ff7bfeff540 sp=0x7ff7bfeff500 pc=0x102ab41
runtime.rt0_go(0x7ff7bfeff570, 0x4, 0x7ff7bfeff570, 0x1000000, 0x4, 0x7ff7bfeff760, 0x7ff7bfeff764, 0x7ff7bfeff786, 0x7ff7bfeff797, 0x0, ...)
	/usr/local/Cellar/go/1.9.2/libexec/src/runtime/asm_amd64.s:175 +0x1eb fp=0x7ff7bfeff548 sp=0x7ff7bfeff540 pc=0x105292b

When the orgis set the error dissapears:

[~/.../tecnologia/tribunales(main)]$ gh edu set -o ULL-ESIT-PL-2122
Not in cache. Fetching... (Cache will be updated)
[~/.../tecnologia/tribunales(main)]$ gh edu get -m
[
  'crguezl',          'casiano',         'alu0100698688',
...  'ilopezpl',         'alu0101330105',   'alu0101051420'
]

Here is the machine profile:

[~/.../tecnologia/tribunales(main)]$ system_profiler SPSoftwareDataType SPHardwareDataType
Software:

    System Software Overview:

      System Version: macOS 12.4 (21F79)
      Kernel Version: Darwin 21.5.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled

Hardware:

    Hardware Overview:

      Model Name: MacBook Air
      Model Identifier: MacBookAir7,2
      Processor Name: Dual-Core Intel Core i5
      Processor Speed: 1,6 GHz
      Number of Processors: 1
      Total Number of Cores: 2
      L2 Cache (per Core): 256 KB
      L3 Cache: 3 MB
      Hyper-Threading Technology: Enabled
      Memory: 8 GB
      System Firmware Version: 430.120.6.0.0
      OS Loader Version: 540.120.3~6

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.