├── README.md ├── .gitignore ├── cli.js ├── index.js └── package.json /README.md: -------------------------------------------------------------------------------- 1 | # block-publish 2 | CLI tool to block directly using npm publish 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /nbproject/ 2 | /.idea/* 3 | *.tmlanguage.cache 4 | *.tmPreferences.cache 5 | *.stTheme.cache 6 | *.sublime-workspace 7 | *.sublime-project 8 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var checkEnvArg = require("./index"); 3 | var envArg = process.argv.splice(-1)[0].split("--")[1]; 4 | var finalArgument; 5 | 6 | if (envArg) { 7 | var envArgPair = process.argv.splice(-1)[0].split("--")[1].split("="); 8 | finalArgument = envArgPair[0] === "envName" ? envArgPair[1] : ""; 9 | } 10 | 11 | checkEnvArg(finalArgument); 12 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var DEFAULT_ENV_STRING = "ALLOW_PUBLISH"; 2 | 3 | function checkEvn(envString = DEFAULT_ENV_STRING) { 4 | if (!process.env[envString]) { 5 | console.log( 6 | `ERROR!!!\nDirect access to npm publish is blocked.\nPlease run a publish script like npm release:dev.` 7 | ); 8 | process.exit(1); 9 | } 10 | } 11 | 12 | module.exports = checkEvn; 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@builder.io/block-publish", 3 | "version": "1.1.2", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "prepublishOnly": "node cli.js", 8 | "test": "echo \"Error: no test specified\" && exit 1", 9 | "release": "ALLOW_PUBLISH=true npm publish" 10 | }, 11 | "author": "@builder.io", 12 | "license": "ISC", 13 | "bin": "cli.js" 14 | } 15 | --------------------------------------------------------------------------------