load-proto
TypeScript icon, indicating that this package has built-in type declarations

2.2.4 • Public • Published

load-proto

Load proto file from gitlab, and convert to protobufjs' Root

Example

import { loadProto } from "load-proto";

const token = process.argv[2];

loadProto({
  gitUrls: [
    {
      url: '[email protected]:ykcommon/ykproto.git',
      branch: 'master',
    },
    '[email protected]:2c/panther-proto.git',
    '[email protected]: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);
  })

Readme

Keywords

none

Package Sidebar

Install

npm i load-proto

Weekly Downloads

1

Version

2.2.4

License

MIT

Unpacked Size

37.4 kB

Total Files

13

Last publish

Collaborators

  • jinkerjiang
  • wangweianger