Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

ali-oss-deploy-with-version

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ali-oss-deploy-with-version

deploy project dist to ali-oss with version. 将项目的打包输出文件夹文件输出到阿里云oss

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

ali-oss-deploy-with-version

Install

3 ways:

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

  • npm install --save-dev ali-oss-deploy-with-version

  • 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

Keywords

ali-oss deploy with version

FAQs

Package last updated on 02 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts