# load-proto

> Load proto file from gitlab, and convert to protobufjs' [Root](http://dcode.io/protobuf.js/Root.html)

Latest version **2.2.4** (published 2021-04-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install load-proto
pnpm add load-proto
yarn add load-proto
bun add load-proto
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.4 |
| Published | 2021-04-26 |
| First published | 2018-11-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 36.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | jinkerjiang, wangweianger |

## Links

- npm: https://www.npmjs.com/package/load-proto
- Repository: https://github.com/yunkeCN/load-proto
- Homepage: https://github.com/yunkeCN/load-proto#readme
- Issues: https://github.com/yunkeCN/load-proto/issues
- npm.io page: https://npm.io/package/load-proto

## Dependencies (5)

- [glob](https://npm.io/package/glob.md) ^7.1.3
- [lodash](https://npm.io/package/lodash.md) ^4.17.20
- [fs-extra](https://npm.io/package/fs-extra.md) ^7.0.0
- [load-git](https://npm.io/package/load-git.md) ^1.5.3
- [@yunke/protobufjs](https://npm.io/package/@yunke/protobufjs.md) ^1.0.6

## Recent versions

- 2.2.4 (latest) — 2021-04-26
- 2.2.3 — 2021-04-19
- 2.2.2 — 2021-03-09
- 2.2.1 — 2021-02-22
- 2.2.0 — 2021-02-22
- 2.1.6 — 2020-10-23
- 2.1.4 — 2020-09-29
- 2.1.3 — 2020-07-09
- 2.1.2 — 2020-06-18
- 2.1.1 — 2020-06-18
- 2.1.0 — 2020-06-02
- 2.0.6 — 2020-04-30
- 2.0.5 — 2019-08-08
- 2.0.4 — 2019-08-06
- 2.0.3 — 2019-07-30
- … 3 more at https://npm.io/package/load-proto/versions

## README

# load-proto

Load proto file from gitlab, and convert to protobufjs' [Root](http://dcode.io/protobuf.js/Root.html)

## Example

```typescript
import { loadProto } from "load-proto";

const token = process.argv[2];

loadProto({
  gitUrls: [
    {
      url: 'git@git.myscrm.cn:ykcommon/ykproto.git',
      branch: 'master',
    },
    'git@git.myscrm.cn:2c/panther-proto.git',
    'git@git.myscrm.cn:2c/thanos-third-proto.git',
  ],
  accessToken: token,
  branch: 'dev',
  resolvePath: (origin: string, target: string, rootDir: string) => {
    if (/^git\.myscrm\.cn\/golang\/common\/proto\/(google|common)\//.test(target)) {
      return `${rootDir}/git.myscrm.cn/ykcommon/ykproto/${target.replace(/^git\.myscrm\.cn\/golang\/common\/proto\//, '')}`;
    } else if (/^proto\/(common|google)\//.test(target)) {
      return `${rootDir}/git.myscrm.cn/ykcommon/ykproto/${target.replace(/^proto\//, '')}`;
    } else if (/^proto\//.test(target)) {
      return target.replace(/^proto\/([^\/]+)(.+)/, (_target, $1, $2) => {
        return `${rootDir}/git.myscrm.cn/2c/${$1.replace(/_/g, '-')}${$2}`;
      });
    } else if (/^(common|google\/api)\//.test(target)) {
      return `${rootDir}/git.myscrm.cn/ykcommon/ykproto/${target}`;
    }
    return null;
  },
})
  .then((root) => {
    console.info(root);
  })
```

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