# sls-gm

> sls-git-modeules

Latest version **1.1.1** (published 2018-01-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install sls-gm
pnpm add sls-gm
yarn add sls-gm
bun add sls-gm
```

Provides the command `sls-gm`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2018-01-09 |
| First published | 2018-01-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Known vulnerabilities | 0 (+4 in 3 direct dependencies) |
| Install scripts | no |
| Author | sailengsi |
| Maintainers | sailengsi |
| Keywords | git, module, modules, sls |

## Links

- npm: https://www.npmjs.com/package/sls-gm
- Repository: git@gitee.com:sailengsi/sls-git-modules
- npm.io page: https://npm.io/package/sls-gm

## Dependencies (10)

- [fs](https://npm.io/package/fs.md) ^0.0.1-security
- [ora](https://npm.io/package/ora.md) ^1.3.0
- [path](https://npm.io/package/path.md) ^0.12.7
- [chalk](https://npm.io/package/chalk.md) ^2.3.0
- [shelljs](https://npm.io/package/shelljs.md) ^0.7.8
- [inquirer](https://npm.io/package/inquirer.md) ^5.0.0
- [commander](https://npm.io/package/commander.md) ^2.12.2
- [git-clone](https://npm.io/package/git-clone.md) ^0.1.0
- [js-beautify](https://npm.io/package/js-beautify.md) ^1.7.5
- [download-git-repo](https://npm.io/package/download-git-repo.md) ^1.0.1

## Recent versions

- 1.1.1 (latest) — 2018-01-09
- 1.1.0 — 2018-01-09
- 1.0.9 — 2018-01-05
- 1.0.8 — 2018-01-03
- 1.0.7 — 2018-01-03
- 1.0.6 — 2018-01-03
- 1.0.5 — 2018-01-03
- 1.0.4 — 2018-01-03
- 1.0.3 — 2018-01-03
- 1.0.2 — 2018-01-02
- 1.0.1 — 2018-01-02
- 1.0.0 — 2018-01-02

## README

# sls-gm
基于Git仓库作为包的管理工具。

## **注意：使用之前，请务必先在项目根目录中的`.gitignore`中忽略目录`sls-git-modules`**

> 此工具还在开发中，先出使用文档，再进行开发，更有利于使用。

> 另外，此项目基本功能实现，功能还在内测，git还没有公开，请不要使用。

## 使用方式

### 安装
```bash
npm install sls-gm -g
```

### 初始化
```bash
sls-gm init
```
执行完上面命令，会在当前目录生成`sls-git-module.json`配置文件，内如如下：
```json
{
    "date": "2017-12-28T01:44:51.175Z",
    "modules": {
        "github": {
            "config": {
                "protocol": "http://",
                "host": "github.com"
            },
            "repos": []
        },
        "gitee": {
            "config": {
                "protocol": "https://",
                "host": "gitee.com"
            },
            "repos": []
        },
        "coding": {
            "config": {
                "protocol": "https://",
                "host": "git.coding.net"
            },
            "repos": []
        },
        "self_git_server_example": {
            "config": {
                "protocol": "https://",
                "host": "git.sailengsi.com"
            },
            "repos": []
        }
    }
}
```
`date`属性的值是通过`new Date()`出来，后续在每次安装Git包的时候也会更新此值。

`modules`属性是所有的包配置管理，通过生成的默认配置，就可以看出，这是支持多中git服务器配置。下面以`github`配置为例:

```bash
config.protocol // 服务器协议，默认为https://
config.host     // 服务器主机，git服务器地址
```
之所以支持多种git服务，是为了解决git多平台的兼容问题。

### 安装Git包的两种方式
#### 默认安装
```bash
sls-gm install namespaceName/repoName
```
默认安装采用的github(**后面会增加设置默认安装类型**)。

#### 通过指定git类型安装
```bash
sls-gm install namespaceName/repoName -t gitServerType
```
`gitServerType`这个值必须存在配置文件中modules中key中。

安装完包之后，会把此包写入配置文件`sls-git-module.json`，格式如下：
```bash
{
    "date": "2017-12-28T01:44:51.175Z",
    "modules": {
        "github": {
            "config": {
                "protocol": "http://",
                "host": "github.com"
            },
            "repos": [namespaceName/repoName]
        },
        ......
    }
}
```
`repos` 即是安装的所有仓库数组，此值之所以是 `namespaceName/repoName` 这种形式，是为了兼容在统一git平台中，不同用户下面有同样的仓库并存问题。

同时，会在当前目录创建 `sls-git-modules` 文件夹，在 `sls-git-modules` 目录下会安装仓库路径生成对应的目录，格式如下：
```bash
|----sls-git-modules
|    |    |----configGitHost
|    |    |    |----namespaceName
|    |    |    |    |----repoName
|    |    |    |    |    |----包中的源码...
```
之所以以这种格式，也是为了兼容。
#### 全部安装
```bash
sls-gm install
```


### 更新Git包的两种方式
#### 默认更新
```bash
sls-gm update namespaceName/repoName
```
#### 通过指定git类型更新
```bash
sls-gm update namespaceName/repoName -t gitServerType
```
#### 全部更新
```bash
sls-gm update
```


### 删除Git包的两种方式

> 删除包，执行下面的命令之后会先提示是否确认删除，默认Y（是）。

> 如果选择否，会提示已取消删除。

> 如果选择是，会接着让你选择是否从配置文件中移除，默认Y（是）。

#### 默认删除
```bash
sls-gm delete namespaceName/repoName
```
#### 通过指定git类型删除
```bash
sls-gm delete namespaceName/repoName -t gitServerType
```
#### 全部删除
```bash
sls-gm delete
```

---
_Source: https://npm.io/package/sls-gm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
