Node's Pretty Magical

    ali-oss-deploy-with-version

    0.0.4 • Public • Published

    ali-oss-deploy-with-version

    Install

    3 ways:

    1. clone this repo, and require ./index.js

    2. npm install --save-dev ali-oss-deploy-with-version

    3. yarn add --dev ali-oss-deploy-with-version

    Usage

    const deploy2OSS = require("ali-oss-deploy-with-version")
    const OSS = require("ali-oss")
    const path = require("path")
     
    const OSSClient = new OSS({
      region: "",
      bucket: "",
      accessKeyId: "",
      accessKeySecret: ""
    })
    const currentVersion = "20181106"
     
    deploy2OSS(OSSClient, {
      localFolderPath: path.resolve(__dirname, "../dist"),
      aliOSSBasePath: "/demo/",
      aliOSSFolderName: currentVersion,
      filesAlsoCopy2Base: [/\.html/],
      extendedFiles: [
        {
          filename: "info.json", // relative to aliOSSBasePath
          content: `{currentVersion:${currentVersion}}`
        },
        {
          filename: "test/index.txt",
          content: "hello world!"
        }
      ],
      rename(file) {
        if (/\.js$/.test(file)) {
          const dotIndex = file.lastIndexOf(".")
          return file.slice(0, dotIndex) + ".hash.js"
        }
      }
    }).then(isAllJobDoneSuccess => {
      if (isAllJobDoneSuccess) {
        console.log("xixixi")
      } else {
        // balabala
      }
    })

    local files:

    dist/
      |-- hello/
        |-- hi.js
      |-- index.html
      |-- index.js
    

    files deployed with version 20181106 on ali-oss:

    demo/
      |-- 20181106/
        |-- hello/
          |-- hi.js
        |-- index.html
        |-- index.js
      |-- test/
        |-- index.txt
      |-- index.html
      |-- info.json
    

    API

    deploy2OSS

    function deploy2OSS will return promise to recieve wheather all job done success.

    const deploy2OSS = require("../index")
    // Or require from package
    const deploy2OSS = require("ali-oss-deploy-with-version")
     
    deploy2OSS(aliOSSInstance, options).then(isAllJobDoneSuccess => {})

    aliOSSInstance:

    const OSS = require("ali-oss")
    const aliOSSInstance = new OSS({
      region: "",
      bucket: "",
      accessKeyId: "",
      accessKeySecret: ""
    })

    options:

    • localFolderPath: Mandatory.

    • aliOSSBasePath: Mandatory.

    • aliOSSFolderName: Optional.

    • filesAlsoCopy2Base: Optional. Array<RegExp>. Files matched RegExp will copy to aliOSSBaseFolder.

    • extendedFiles: Optional. Array<Object>. Define content will be created and upload to ali-oss.Each element has property filename and content.filename is path relative to aliOSSBasePath.

    • rename: Optional. A function that receive file path relative to localFolderPath and return a new file path.

    License

    MIT

    Install

    npm i ali-oss-deploy-with-version

    DownloadsWeekly Downloads

    8

    Version

    0.0.4

    License

    MIT

    Unpacked Size

    37.5 kB

    Total Files

    10

    Last publish

    Collaborators

    • microj