Git Product home page Git Product logo

projj's Introduction

Projj

Manage repository easily.

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Why?

How do you manage git repository?

Maybe you create a directory and clone to it. However if you want to clone repository that has same name? Or Do something in every directory like clean?

Projj provide a structure making it easy.

$BASE
|- github.com
|  `- popomore
|     `- projj
`- gitlab.com
   `- popomore
      `- projj

And you can DO everything in repository by Hook.

Feature

  • ✔︎ Add repository using projj add
  • ✔︎ Command Hook
  • ✘ Buildin Hook
  • ✔︎ Custom Hook
  • ✔︎ Run Hook in All Repositories
  • ✔︎ Git Support

Installation

Install projj globally.

$ npm i projj -g

Usage

Initialize

$ projj init

Set base directory which repositories will be cloned to, default is ~/projj.

You can change base directory in ~/.projj/config.json.

Add Repository

$ projj add [email protected]:popomore/projj.git

it's just like git clone, but the repository will be cached by projj. You can find all repositories in ~/.projj/cache.json

also support alias which could config at alias of ~/.projj/config.json:

$ projj add github://popomore/projj

Importing

If you have some repositories in ~/code, projj can import by projj import ~/code.

Or projj can import repositories from cache.json when you change laptop by projj import --cache

Find Repository

projj provide a easy way to find the location of your repositories.

$ projj find [repo]

You can set change_directory in ~/.projj/config.json to change directory automatically.

Sync

projj sync will check the repository in cache.json whether exists, the repository will be removed from cache if not exist.

Hook

Hook is flexible when manage repositories.

Command Hook

When run command like projj add, hook will be run. preadd that run before projj add, and postadd that run after projj add.

Config hook in ~/.projj/config.json

{
  "hooks": {
    "postadd": "cat package.json"
  }
}

Then will show the content of the package of repository.

Only support add now

Define Hook

You can define own hook.

{
  "hooks": {
    "hook_name": "command"
  }
}

For Example, define a hook to show package.

{
  "hooks": {
    "show_package": "cat package.json"
  }
}

Then you can use projj run show_package to run the hook in current directory.

Command can be used in $PATH, so you can use global node_modules like npm.

{
  "hooks": {
    "npm_install": "npm install"
  }
}

Write Hook

Write a command

// clean
#!/usr/bin/env node

'use strict';

const cp = require('child_process');
const cwd = process.cwd();
const config = JSON.parse(process.env.PROJJ_HOOK_CONFIG);
if (config.node_modules === true) {
  cp.spawn('rm', [ '-rf', 'node_modules' ]);
}

You can get PROJJ_HOOK_CONFIG from projj if you have defined in ~/.projj/config.json.

{
  "hooks": {
    "clean": "clean"
  },
  "clean": {
    "node_modules": true
  }
}

Run Hook

projj run clean in current directory.

projj runall clean in every repositories from cache.json

License

MIT

projj's People

Contributors

atian25 avatar dead-horse avatar diamondyuan avatar popomore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

projj's Issues

[feat request] 忽略大小写

在查找项目的时候是否可以不区分大小写。
或者加一个配置,配置为 true 的时候不区分大小写。

比如项目名字是 Saas 那么 输入 saas 也可以匹配到。

projj sync

If I use projj remove to remove a repository, it also will be removed in cache.json. But Someone don't? So use projj sync to check mapping.

  1. Mapping cache.json and directory
  2. Checking git url and directory

Feature

init

set the base directory of projj, for example ~/code

generator ~/.projj/config to store the config

add project

$ projj add [email protected]:popomore/projj.git

the structure will follow the git repo

BASEDIR
`- github.com
    `- popomore
        `- projj

hook

Edit the file ~/.projj/hook

buildin hook

The hook will be called when run buildin commander like projj add

  • postadd
  • preadd

custom hook

Define hook in ~/.projj/hook

clean = rm -rf node_modules

You can run projj run clean, it will remove node_modules in every project.

find 为什么要优先匹配 endsWith('/{keyword}') ?

比如我有 "abc" 和 "tiny-abc" 两个仓库,"abc" 是常用的关键字,但是 projj find abc 始终只能搜到 "abc"。

    const keys = Object.keys(yield this.cache.get());
    let matched = keys.filter(key => key.endsWith(repo.replace(/^\/?/, '/')));
    if (!matched.length) matched = keys.filter(key => key.indexOf(repo) >= 0);

我觉得搜索结果应该将所有命中的都返回,只是排序上可以有侧重。

Buildin hook

git_config_user

Add name and email of git config automaically.

configuration

{
  "hooks": {
    "postadd": "projj run git_config_user",
    "git_config_user": "git_config_user"
  },
  "git_config_user": {
    "github.com": {
      "name": "popomore",
      "email": "xxx"
    },
    "gitlab.com": {
      "name": "popomore2",
      "email": "xxx2"
    },
  }
}

clean

{
  "hooks": {
    "clean": "clean"
  }
}

projj runall clean

直接运行 bug

$ projj

  Usage:  [command] [options]


  Commands:

    *   See "More commands"

  Options:

    -h, --help     output usage information
    -V, --version  output the version number


/Users/popomore/.node/lib/node_modules/.projj_npminstall/node_modules/.1.0.0@common-bin/lib/command.js:15
    throw new Error('Must impl this method');
    ^

Error: Must impl this method
    at InitCommand.help (/Users/popomore/.node/lib/node_modules/.projj_npminstall/node_modules/.1.0.0@common-bin/lib/command.js:15:11)
    at Program.help (/Users/popomore/.node/lib/node_modules/.projj_npminstall/node_modules/.1.0.0@common-bin/lib/program.js:40:53)
    at Command.commander.on (/Users/popomore/.node/lib/node_modules/.projj_npminstall/node_modules/.1.0.0@common-bin/lib/run.js:22:13)
    at emitNone (events.js:86:13)
    at Command.emit (events.js:185:7)
    at Command.outputHelp (/Users/popomore/.node/lib/node_modules/.projj_npminstall/node_modules/.2.9.0@commander/index.js:1024:8)
    at Object.module.exports.Program [as run] (/Users/popomore/.node/lib/node_modules/.projj_npminstall/node_modules/.1.0.0@common-bin/lib/run.js:27:15)
    at Object.<anonymous> (/Users/popomore/.node/lib/node_modules/.projj_npminstall/node_modules/.1.0.0-alpha.2@projj/bin/projj.js:5:23)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)

在clone的时候加入进度条

能否在clone repo的时候加入进度条,优化下体验,在clone一些较大项目的时候,还以为电脑卡住了

可惜了

这么好用的工具,作者不怎么维护了,可惜了

projj import 的一个问题

如果使用 projj import 导入一个路径,这个路径下有一个非 git 的文件夹的话,会导致直接跳过所有项目, 直接走到consoleLogger.info('✨ Done'); 而没做任何导入

projj import

projj import .

  1. find all .git
  2. get giturl
  3. projj add giturl

MaxListenersExceededWarning: Possible EventEmitter memory leak detected

node -v v11.4.0
projj -V 1.4.1

复现方法 输入 projj

(node:10043) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 unpipe listeners added. Use emitter.setMaxListeners() to increase limit
(node:10043) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added. Use emitter.setMaxListeners() to increase limit
(node:10043) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:10043) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added. Use emitter.setMaxListeners() to increase limit
(node:10043) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 finish listeners added. Use emitter.setMaxListeners() to increase limit
(node:10043) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 unpipe listeners added. Use emitter.setMaxListeners() to increase limit
(node:10043) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added. Use emitter.setMaxListeners() to increase limit
(node:10043) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:10043) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added. Use emitter.setMaxListeners() to increase limit
(node:10043) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 finish listeners added. Use emitter.setMaxListeners() to increase limit

projj add 之后疑似跳转错误,先记录下

image

开启了自动 "change_directory": true,。之前是正常的,最近突然不正常了。

macOS Catalina 10.15.3 (19D76)

$ projj add [email protected]:hotoo/gitopen.git
✔︎  Start adding repository [email protected]:hotoo/gitopen.git
✔︎  Cloning into /Users/hotoo/workbench/github.com/hotoo/gitopen
✔︎  Change directory to /Users/hotoo/workbench/github.com/hotoo/gitopen
   38:45: syntax error: 预期是––µƒΩ·Œ≤,却找到±Í ∂∑˚。 (-2741)
   
✘  Run "sh -c [ `osascript  -e 'tell application "System Events"' -e 'set activeApp to name of first application process whose frontmost is true' -e 'end tell'` = "Terminal" ] && osascript  -e 'tell application "Terminal"' -e 'do script "cd /Users/hotoo/workbench/github.com/hotoo/gitopen"  in front window' -e 'end tell' >/dev/null || osascript  -e 'tell application "iTerm"' -e 'tell current session of current window' -e 'write text "cd /Users/hotoo/workbench/github.com/hotoo/gitopen"' -e 'end tell' -e 'end tell'" error, exit code 1

zsh中自动提示

find的时候能否自动补全记录的仓库名,增加一下这个feature?

projj list

result

✔︎  ├─ github.com
✔︎  │  └─ eggjs
✔︎  │     ├─ egg
✔︎  │     └─ egg-core
✔︎  └─ gitlab.com
✔︎     └─ eggjs
✔︎        ├─ egg-core
✔︎        └─ autod-egg

like yarn list

hook option

{
  "hooks": {
    "hookName": {
      "hook": "npm install",
      "match": "github.com/"
    }
  }
}

hook option can be an object

sync 无法做到真正的同步

目前 sync 命令只能删除 cache 中已经被移除的项目,但是如果有新增的项目无法增加,建议直接使用文件夹内的项目同步并重新生成 cache 文件

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.