bower PW deployment

bower PW deployment

Brief introduction

1, PW server: private-bower

2, package management: git

Listing Tools

  • nodejs
  • git
  • private-bower

installation

Installation nodejs

Has been installed nodejs can ignore this section

1, download packages nodejs

Open nodejs official website download page https://nodejs.org/en/download/. Right copy Linux Binaries (x64)the download link. Perform the following download and unzip

    cd ~
    #注意:当前下载版本为v10.15.3
    #下载
    wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz
    #解压
    xz -d node-v10.15.3-linux-x64.tar.xz
    #注意:xz 命令执行后node-v10.15.3-linux-x64.tar.xz被输出为node-v10.15.3-linux-x64.tar
    tar -xvf node-v10.15.3-linux-x64.tar
    #移动node程序文件夹到/opt/nodejs/v10
    mv ./node-v10.15.3-linux-x64 /opt/nodejs/v10

2, add nodejs path to$PATH

    #通过修改profile文件:
    vim /etc/profile
    #找到设置PATH的行
    /export PATH 
    #在export PATH之前,添加环境变量
    PATH=/opt/node/v10/bin:$PATH
    #保存
    #生效方法:系统重启
    #有效期限:永久有效
    #用户局限:对所有用户

    #执行以下命令使之立即生效
    source /etc/profile
    #或 执行点命令 
    /etc/profile

    #执行以下命令测试nodejs是否已经正确安装
    node --version

installationgit

    yum install -y git git-daemon

installationprivate-bower

    npm install -g private-bower

Configure private-bower

    cd /opt
    mkdir ./private-bower
    vi mybowerconfig.json

mybowerconfig.json sample configuration is as follows:

{
    "port": 5678,
    "registryFile": "/opt/private-bower/bowerRepository.json",
    "timeout": 144000,
    "public": {
        "disabled": false,
        "registry": "http://https://registry.bower.io",
        "registryFile": "/opt/private-bower/bowerRepositoryPublic.json",
        "whitelist": [],
        "blacklist": []
    },
    "authentication": {
        "enabled": false,
        "key": "password"
    },
    "repositoryCache": {
        "cachePrivate": false,
        "git": {
            "enabled": false,
            "cacheDirectory": "/opt/private-bower/gitRepoCache",
            "host": "localhost",
            "port": 6789,
            "publicAccessURL" : null,
            "refreshTimeout": 10
        },
        "svn": {
            "enabled": false,
            "cacheDirectory": "/opt/private-bower/svnRepoCache",
            "host": "localhost",
            "port": 7891,
            "publicAccessURL" : null,
            "refreshTimeout": 10
        }
    },
    "proxySettings" : {
        "enabled": false,
        "host": "proxy",
        "username": "name",
        "password" : "pass",
        "port": 8080,
        "tunnel": false
    },
    "log4js" : {
        "enabled": true,
        "configPath" : "/opt/private-bower/log4js.conf.json"
    }
}

mybowerconfig.jsonThe key configuration instructions

  • port: external network access port
  • registryFile: by bower register name xxxorder of registration records file bower package
  • log4js: configPath: Logging Configuration

log4js.conf.json Configuration

{
"appenders": [
    {
    "type": "dateFile",
    "filename": "private-bower.log",
    "pattern": "-yyyy-MM-dd",
    "alwaysIncludePattern": false
    },
    {
    "type": "console"
    }
],
"replaceConsole": true
}

Start private-bower

cd /opt/private-bower
private-bower --config ./mybowerconfig.json

Open ports

#以下代码为centos7
# 开放端口
firewall-cmd --zone=public --add-port=5678/tcp --permanent
# 更新规则
firewall-cmd --reload
# 启动|关闭|重新启动 防火墙,(注意:如果执行`firewall-cmd --reload`命令后仍无法访问则重启服务
systemctl [start|stop|restart] firewalld.service

Boot / registered as a service

slightly

private-bower test

1. Create a .bowerrcfile

Execute the following code (cmd) If you can not be created by the Explorer window at the command line

type null>.bowerrc

2, edit the following

 {"registry":"http://<bower私服ip地址>:5678"}

3, execute the following command to test the command line

bower search jquery

Create a bower package

Create a bower package needs to meet the following criteria

  • git: bower package dependency git repository, the public network may be selected GitHub, PW can build gitlab
  • tags git repository using a standard version number format: bower by reading identification tags bower git repository version number. The version number is recommended to use a standard version number format, xx.xx.xx[.xx]and supports vas a prefix version number. Effective tag such 1.1.0as: ,v1.1.1
  • git repository root directory contains bower.json: the file statement bower package of information

createbower.json

# 执行以下命令,根据提示输入即可
bower init

bower.jsonThe basic structure of the file

{
  "name": "bower_name",
  "authors": [
    "xxx"
  ],
  "description": "",
  "main": "",
  "license": "MIT",
  "homepage": "",
  "private": false,
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "test",
    "tests"
  ]
}

Create a git repository

The basic process
1, to create a warehouse
2, add bower.jsonfiles to the masterbranch root directory
3. Create warehouse tag

Sign bower package to PW

Containing .bowerrcopen a command line file directory and .bowerrcfile must contain definitions of PW

cd /d xxx  #xxx为包含.bowerrc文件的目录
bower register name xxx.git #xxx.git为bower包项目git地址

bower package recommendations

For projects only need to refer to the resources necessary to create a separate file can git branch for bower of publishing, you can also use the bower.jsonfile to configure the program to ignore.

E.g:

git repository created specifically for branch bower released, the branches contain only the necessary documents issued, excluding the original code files, examples, scripts. Create a tag when you create a tag in this branch only. As an example, in which the bower to bower branch pack release branch

  • master
    • src
    • dist
    • examples
    • bower.json
    • readme.md
  • bower
    • dist
    • bower.json
  • tags-> branch bower
    • 1.1.1
    • 1.1.2

Clients use

Creating Basic Configuration

It needs to be created by the project root directory bower Management Pack bower.jsonand .bowerrc.

1. Create.bowerrc

    #window环境下使用cmd创建
    type null>.bowerrc

Edit .bowerrcFile

{
  "registry": {
    "register": "http://<私服 IP or URL>:5678",
    "search": [
      "http://<私服 IP or URL>:5678",
      "https://registry.bower.io"
    ]
  },
  "directory": "wwwroot/lib"
}

Configuration instructions

  • registry: register: bower registered address register name xxx command
  • registry: search: search route package installed bower
  • directory: bower package placement path

2. Createbower.json

Created by bower init command bower.json. Add After you create dependenciesthe configuration node, which for application dependencies, dependencies are automatically downloaded when bower reduction. Configuration is as follows

{
  "name": "projectname",
  "authors": [
    "xxx"
  ],
  "description": "",
  "main": "",
  "license": "MIT",
  "homepage": "",
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "wwwroot/lib",
    "test",
    "tests"
  ],
  "dependencies": {
    "d3": "v5.9.2"
  }
}

Guess you like

Origin www.cnblogs.com/chiikin/p/11113439.html