1. #!/usr/bin/env node
    
  2. 
    
  3. 'use strict';
    
  4. 
    
  5. const commandLineArgs = require('command-line-args');
    
  6. const {splitCommaParams} = require('../utils');
    
  7. 
    
  8. const paramDefinitions = [
    
  9.   {
    
  10.     name: 'dry',
    
  11.     type: Boolean,
    
  12.     description: 'Dry run command without actually publishing to NPM.',
    
  13.     defaultValue: false,
    
  14.   },
    
  15.   {
    
  16.     name: 'tags',
    
  17.     type: String,
    
  18.     multiple: true,
    
  19.     description: 'NPM tags to point to the new release.',
    
  20.     defaultValue: ['untagged'],
    
  21.   },
    
  22.   {
    
  23.     name: 'skipPackages',
    
  24.     type: String,
    
  25.     multiple: true,
    
  26.     description: 'Packages to exclude from publishing',
    
  27.     defaultValue: [],
    
  28.   },
    
  29.   {
    
  30.     name: 'ci',
    
  31.     type: Boolean,
    
  32.     description: 'Run in automated environment, without interactive prompts.',
    
  33.     defaultValue: false,
    
  34.   },
    
  35. ];
    
  36. 
    
  37. module.exports = () => {
    
  38.   const params = commandLineArgs(paramDefinitions);
    
  39.   splitCommaParams(params.skipPackages);
    
  40.   splitCommaParams(params.tags);
    
  41.   params.tags.forEach(tag => {
    
  42.     switch (tag) {
    
  43.       case 'latest':
    
  44.       case 'canary':
    
  45.       case 'next':
    
  46.       case 'experimental':
    
  47.       case 'alpha':
    
  48.       case 'beta':
    
  49.       case 'rc':
    
  50.       case 'untagged':
    
  51.         break;
    
  52.       default:
    
  53.         console.error('Unsupported tag: "' + tag + '"');
    
  54.         process.exit(1);
    
  55.         break;
    
  56.     }
    
  57.   });
    
  58.   return params;
    
  59. };