npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ali-oss-publish

v0.4.0

Published

a cli interface of publish resources to ali oss

Downloads

76

Readme

ali-oss-publish

badge:travis badge:npm-version badge:npm-downloads badge:issues badge:license

a cli interface of publish resources to ali-oss

Installation

yarn add ali-oss-publish

Api

publish: function(options: object[, cb: function(err: Error, stats: Stats)]): Promise

  • options: object: publish options
    • options.id: string: accessKeyId in ali oss, see ali-oss-options
    • options.secret: string: accessKeySecret in ali oss, see ali-oss-options
    • options.token: string: stsToken in ali oss, see ali-oss-options
    • options.region: string,: region in ali oss, see ali-oss-options
    • options.bucket: string,: bucket in ali oss, see ali-oss-options
    • options.entry = '.': string: entry point, defaults to "."
    • options.include: ?RegExp: match files will publish to ali oss
    • options.exclude: ?RegExp: match files will ignore to publish to ali oss
    • options.mime: ?(string|function(path: string): string|void): custom mime to all files, see ali-oss-put-file-options
    • options.meta: ?(object|function(path: string): object|void): custom meta to all files, see ali-oss-put-file-options
    • options.headers: ?(object|function(path: string): object|void): custom headers to all files, see ali-oss-put-file-options
    • options.rules = []: Array<object>: custom operations options for the match files, defaults to []
      • options.rules[].test: ?RegExp|boolean: match files or the test is true will apply custom operations
      • options.rules[].include: ?RegExp: match files will apply custom operations
      • options.rules[].exclude: ?RegExp: match files will ignore to apply custom operations
      • options.rules[].use: ?object: custom operations
        • options.rules[].use.mime: ?(string|function(path: string): string|void): custom mime to the match files, see ali-oss-put-file-options
        • options.rules[].use.meta: ?(object|function(path: string): object|void): custom meta to the match files, see ali-oss-put-file-options
        • options.rules[].use.headers: ?(object|function(path: string): object|void): custom headers to the match files, see ali-oss-put-file-options
    • options.output = '.': string: output path for publish to ali oss, defaults to "."
    • options.force: boolean: force remove the files that not in the publish entry
    • options.config: string: path to the config file, defaults to try load config from "ali-oss-publish.config.js" when config is not set
    • options.retry: ?number: retry times when encountered non-fatal errors
    • options.concurrency: ?number: concurrency for publish
  • cb = noop: function(err: Error[, stats: Stats]): callback function, defaults to noop
    • err: Error: fatal error
    • stats: Stats: publish stats
      • stats.message: string: message for stats
      • stats.type: ?string: type for stats
      • stats.index: ?number: concurrency index
      • stats.current: ?number: current step
      • stats.total: ?number: total step
      • stats.warnings: ?Array<string>: warnings for stats
      • stats.errors: ?Array<Error>: errors for stats
      • stats.hasProgress: function(): boolean: ensure whether has progress
      • stats.hasWarnings: function(): boolean: ensure whether has warnings
      • stats.hasErrors: function(): boolean: ensure whether has errors
  • Returns Promise: promise
const publish = require('ali-oss-publish')

publish({
  id: 'accessKeyId-in-ali-oss-options',
  secret: 'accessKeySecret-in-ali-oss-options',
  token: 'stsToken-in-ali-oss-options',
  region: 'region-in-ali-oss-options',
  bucket: 'bucket-in-ali-oss-options',
  entry: '/path/to/publish/files', // defaults to '.'
  include: /bin|cli|lib|index\.js$|\.md$/,
  exclude: /.DS_Store$/,
  mime: (filename) => {
    if (/\.md$/.test(filename)) {
      return 'text/markdown'
    }

    return undefined
  },
  meta: {
    ref: Date.now()
  },
  headers: {
    'Cache-Control': 'max-age=30672000'
  },
  rules: [{
    test: /(index\.html|service-worker\.js)$/,
    use: {
      headers: {
        'Cache-Control': 'no-cache'
      }
    }
  }],
  output: '/path/to/ali-oss/to/publish',
  config: '/path/to/config/file.js', // defaults to try load config from 'ali-oss-publish.config.js' when config is not set
  retry: 1,
  concurrency: 4,
  force: true
}, (err, stats) => {
  if (err) {
    console.error('ali-oss-publish encountered a fatal error.')
    console.error(err)

    process.exit(1)
  }

  if (stats.hasProgress()) {
    const {
      type,
      index,
      current,
      total,
      message
    } = stats

    console.log('[%s] [%s/%s] #%s: %s', type, current, total, index, message)
  } else {
    console.log(stats.message)
  }

  if (stats.hasWarnings()) {
    console.warn('ali-oss-publish encountered some warnings.')
    stats.warnings.forEach((x) => {
      console.warn(x)
    })
  }

  if (stats.hasErrors()) {
    console.error('ali-oss-publish encountered some errors.')
    stats.errors.forEach((x) => {
      console.error(x)
    })
  }
})

Cli

  Usage: ali-oss-publish [options]

  a cli interface of publish resources to ali oss

  Options:
    -V, --version                output the version number
    -i, --id <id>                accessKeyId in ali oss
    -s, --secret <secret>        accessKeySecret in ali oss
    -t, --token <token>          stsToken in ali oss
    -r, --region <region>        region in ali oss
    -b, --bucket <bucket>        bucket in ali oss
    -e, --entry <entry>          entry point, defaults to "."
    -o, --output <output>        output path for publish to ali oss, defaults to "."
    -c, --config <config>        path to the config file, defaults to try load config from "ali-oss-publish.config.js" when config is not set
    --retry <retry>              retry times when encountered non-fatal errors
    --concurrency <concurrency>  concurrency for publish
    --force                      force remove the files that not in the publish entry
    -h, --help                   display help for command

Environment

Env Name | Config Name ------------------------|------------- ALI_OSS_PUBLISH_ID | id ALI_OSS_PUBLISH_SECRET | secret ALI_OSS_PUBLISH_TOKEN | token ALI_OSS_PUBLISH_REGION | regin ALI_OSS_PUBLISH_BUCKET | bucket ALI_OSS_PUBLISH_ENTRY | entry ALI_OSS_PUBLISH_OUTPUT | output

Config File

module.exports = {
  // publish options
}

Options Override

EnvOptions < FileOptions < ParamsOptions