1.2.3 • Published 3 years ago

@huzan/hz-eagle v1.2.3

Weekly downloads
4
License
MIT
Repository
-
Last release
3 years ago

@huzan/hz-eagle(基于@huzan-umi3-plugins架构的前端代码共享方案)

Install

npm install --save @huzan/hz-eagle

commands

cross-env HZ_EAGLE_CONFIG_PATH=./.eagle.config.js //config path

Usage: hz-eagle <command> [options]

                sync      (-b=branch || -t=tag || -c=commitId) -f=[forceUpdate] -i=[init]
                update  
                copy
                remove    -c=[isCommit]
                check
                move      -o=[oldBaseCodePath]
                lint

option

// copy file option
//"notCover": true //是否不覆盖, "crateShadowFile" : true //使用影子文件

// @hz-sync-base-project-option-begin
// {"notCover": true, "crateShadowFile" : true}
// @hz-sync-base-project-option-end


"husky": {
    "hooks": {
        "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
        "pre-commit": "hz-eagle lint && npm run lint-staged"
    }
}

//.eagle.config.js
module.exports = {
    baseCodePath: '',
    gitlabUrl: '',
    token: '',
    projectId: '',
    copyCacheToSourceFilter: ({absFromPath,absToPath,path,}) => true,
    copySourceToSrcFilter: ({absFromPath,absToPath,path,}) => true,
    copyCacheToSourceGlobbyPatterns: ['**'],
    copyCacheToSourceGlobbyOption: {},
    hzSyncBaseProjectOptionExtnameRe: /\.(js|jsx|ts|tsx|less|css)$/,
    copySourceToSrcGlobbyPatterns: ['./src/**'],
    copySourceToSrcGlobbyOption: {},
}

//lint-staged.config.js
const {createFilterCopyFiles} = require('@huzan/hz-eagle')

const filterCopyFiles = createFilterCopyFiles()


module.exports = {
    '**/*': [
        async function lintFilesPath(files) {
            await filterCopyFiles(files)

            return `node ./scripts/lint-files-path.js ${files.join(' ')}`
        },
    ],
    '**/*.{js,jsx}': [
        async function lintJs(files) {
            await filterCopyFiles(files)

            return `hz-eslint --fix ${files.join(' ')}`
        },
        async function prettier(files) {
            await filterCopyFiles(files)

            return `hz-prettier --write ${files.join(' ')}`
        },
    ],
    '**/*.{css,less}': [
        async function lintStyle(files) {
            await filterCopyFiles(files)

            files.forEach((file) => file.replace('[', '\\[').replace(']', '\\]'))

            return `hz-stylelint --fix ${files.join(' ')}`
        },
        async function prettier(files) {
            await filterCopyFiles(files)

            return `hz-prettier --write ${files.join(' ')}`
        },
    ],
}

私有部署改造 前端代码共享方案

##前提条件

  • 1.所有的代码都由本公司人员开发。
  • 2.基础功能版本只维护一个版本。有3个分支dev,test,master。所有定制版本都是共享基础版本代码,向下兼容,定制版本更新只能共享到基础版本对应分支的最新代码。
  • 3.基础功能版本提供路由基本的配置。交互都一样,不能在基础版本二级菜单中加入地址版本页面。如果需要,单独在定制版本上开发,关闭基础版本的路由页面。
  • 4.定制版本上不能修改基础版本代码,使用影子文件引入。

License

MIT © LeoHuiyi