博客 / 詳情

返回

使用任意 git 倉庫初始化項目 - `Code Recycle`

  • 為了方便開發,一般初始化項目時都會使用 git 上的模板倉庫
  • 想了解某個項目的功能時,可能會去運行這個倉庫下的某個實例
  • 或者倉庫下某個文件夾內提供了一些文件模板用來限定一些模塊的初始化
  • 上面三種場景,我們都需要拉取倉庫,但是有時候只需要拉取倉庫的一部分,這時候不妨使用Code Recycle,通過幾行配置進行自定義拉取

全部拉取

changeList:
  - type: copy
    from: https://github.com/maximegris/angular-electron.git
    to: ./ae
    source: git

部分拉取

changeList:
  - type: copy
    from: 
      url: https://github.com/microsoft/vscode-extension-samples.git
      match:
        - /l10n-sample
      output: /l10n-sample
    to: ./l10n
    source: git

拉取模板生成

module.exports = async (util, rule, host, injector) => {
  let list = await util.changeList([
    {
      type: 'copy',
      source: 'git',
      from: {
        url: 'https://github.com/angular/angular-cli.git',
        match: '/packages/schematics/angular/directive/files',
        output: '/packages/schematics/angular/directive/files',
      },
      pathTemplate: '@angular-devkit',
      contentTemplate: '@angular-devkit',
      pathTemplateSuffix: '.template',
      templateContext: { name: 'hello', standalone: true, selector: 'hello', 'if-flat': (input) => '' },
      to: './hello-directive'
    },
  ]);
  await util.updateChangeList(list);
};

更多?

  • 工具目前支持CLIVSCode Extension進行執行,腳本支持yaml/js/ts
  • 您可以查看文檔瞭解更多
  • 如果您想看更多的實例,可以訪問倉庫查看並運行
  • 如果您已經感興趣,那麼可以快速開始
user avatar peter-wilson 頭像 yilezhiming 頭像 iymxpc3k 頭像 alogy 頭像 zpfei 頭像 lfaith 頭像 maogexiaodi 頭像 yumiko_5c088de8aa1fe 頭像 delai 頭像 yzbao 頭像 bbqzhiyoufanshu 頭像 opentiny 頭像
20 位用戶收藏了這個故事!

發佈 評論

Some HTML is okay.