UNPKG

@mornya/vessel

Version:

Creates/publishes a Node.js module with no build configuration.

1 lines 2.18 kB
var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},i=(Object.defineProperty(exports,"__esModule",{value:!0}),require("@mornya/cli-libs")),r=e(require("./login")),o=require("../cli");function PrepublishScript(e,r){this.option=e}PrepublishScript.prototype.run=function(){this.checkMinimumVersionProgress(),this.checkNpmRegistryProgress(),PrepublishScript.checkTaskProgress(),PrepublishScript.lintTaskProgress(),PrepublishScript.testTaskProgress(),PrepublishScript.loginTaskProgress()},PrepublishScript.prototype.checkMinimumVersionProgress=function(){var e;o.CLI.appPackageJson.vessel&&(i.Log.progress("Check required minimum version..."),e=null!=(e=o.CLI.appPackageJson.vessel.minVersion)?e:"0.0.0",i.Version.check(e,o.CLI.ownPackageJson.version)<0)&&(i.Log.failure('You have to upgrade the Vessel version to "'.concat(e,'" or higher for stable progress.')),process.exit(1))},PrepublishScript.prototype.checkNpmRegistryProgress=function(){i.Log.progress("Checking package version from registry...");var e=null!=(e=o.CLI.appPackageJson.name)?e:"",r=null!=(r=o.CLI.appPackageJson.version)?r:"",s="";i.Command.run("npm",["view",e,"version"],function(e){s=e},!1),s===r&&(i.Log.linefeed(),i.Log.bad('You have to change package version. Current is "'.concat(r,'".')),i.Log.info(['And it same to last published version "'.concat(i.chalk.green(s),'".'),"Open your package.json file in root of the project and change version string."]),i.Log.linefeed(),process.exit(1))},PrepublishScript.checkTaskProgress=function(){i.Command.run("npm",["run","check"])||(i.Log.failure('Failed to run pre-publish task with "check"!'),process.exit(1))},PrepublishScript.lintTaskProgress=function(){i.Command.run("npm",["run","lint"])||(i.Log.failure('Failed to run pre-publish task with "lint"!'),process.exit(1))},PrepublishScript.testTaskProgress=function(){i.Command.run("npm",["run","test"])||(i.Log.failure('Failed to run pre-publish task with "test"!'),process.exit(1))},PrepublishScript.loginTaskProgress=function(){new r.default({}).getLoginUsername()||(i.Log.failure('Failed to run pre-publish task with "login"!'),process.exit(1))},exports.default=PrepublishScript;