idea-note 0.0.2

1 minute read

idea-note 0.0.2版本发布,主要完成了Git加密同步和一些代码优化。

加密同步

存储路径更改

为了实现加密同步,需要两个单独的目录,分别由IDEA_LOCALIDEA_REMOTE来指定

  • IDEA_LOCAL

    用来存储note明文,创建、修改、浏览、查询等操作都将在该目录下完成,默认路径为$HOME/.idea/local

  • IDEA_REMOTE

    用来存储note密文,采用AES 256进行加密,主要用来与远端进行同步,默认路径为$HOME/.idea/remote,目前CLI只支持Git同步

同步流程

  1. 用户执行git-sync 命令
      $ idea git-sync
    
  2. 同步远端加密文件到本地
      cd $IDEA_REMOTE && git pull
    
  3. 加密最近修改文件

    目前idea-note使用时间戳来判断文件是否被修改过,$IDEA_LOCAL/version.md的时间戳被用来记录上次同步的时间,凡是上次同步之后修改的文件都会被加密到IDEA_REMOTE的对应目录下且添加后缀.enc

    加密算法为AES 256,每次同步都会要求用户输入加密密码并尝试解密远端的$IDEA_REMOTE/version.md.enc,如果解密失败报密码错误。

  4. 解密远端新增文件

    IDEA_REMOTE有但IDEA_LOCAL没有的文件解密到IDEA_LOCAL对应的目录并去掉后缀.enc

  5. 同步本地加密文件到远端
      cd $IDEA_REMOTE && git add . && git commit -m "sync" && git push 
    

帮助信息

将帮助信息分层,每个命令提供自己的帮助信息,

$ idea help
$ idea <command> help

最新的帮助信息如下

$ idea help
usage: idea <command> [<args>]

COMMANDS
  open              create a new note or open the existion note
  git-sync          flush all the notes to git
  ls                list all the notes in 3 days
  search <pattern>  serach all the notes which match the given pattern
$ idea open help
open [--local <value>] [<note name>]

DESCRIPTION
  1. If the note name is not given, create a new note with random name.
  2. If the note name is given and the note exists, open the corresponding note.
  3. If the note name is given but the note does not exists, open a new note with the given name.

OPTIONS
  --local   Specify the local notes directory explicitly, will use environment variable IDEA_LOCAL if missing.
$ idea git-sync help
git-sync [--local <value>] [--remote <value>]

DESCRIPTION
  The workflow of git sync
    1. Featch the latest notes from remote repo by git pull
    2. Encrypt the notes which is newer than the version.md in local directory, then copy them to the corresponding remote directory
    3. Decrypt the notes which don't exist in local directory, then copy them to the corresponding local directory

OPTIONS
  --local   Specify the local notes directory explicitly, will use environment variable IDEA_LOCAL if missing.
  --remote  Specify the remote notes directory explicitly, will use environment variable IDEA_REMOTE if missing.
$ idea ls help
ls [--local <value>]

DESCRIPTION
  Print all the content of notes created in 3 days.

OPTIONS
  --local   Specify the local notes directory explicitly, will use environment variable IDEA_LOCAL if missing.
$ idea search help
search [--local <value>] <pattern>

DESCRIPTION
  Print all the notes which contain the given pattern.

OPTIONS
  --local   Specify the local notes directory explicitly, will use environment variable IDEA_LOCAL if missing.

Updated:

Comments