-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(verify-conditions): add verify-conditions step
- also add some more logging - move some checks about the pom.xml into verify-conditions - check for existence of maven-settings.xml file
- Loading branch information
1 parent
262bc8a
commit db2148c
Showing
7 changed files
with
116 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
module.exports = { | ||
prepare: require('./lib/prepare'), | ||
publish: require('./lib/publish'), | ||
verifyConditions: require('./lib/verify-conditions'), | ||
verifyRelease: require('./lib/verify-release') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
const AggregateError = require('aggregate-error') | ||
const fs = require('fs-extra') | ||
|
||
const {getError, getPomInfo, printVersion} = require('./util') | ||
|
||
/** | ||
* Verify that the maven project is properly setup to allow deployment to maven central | ||
*/ | ||
module.exports = async function verifyConditions (pluginConfig, context) { | ||
const {logger} = context | ||
printVersion(logger) | ||
|
||
// make sure pom.xml file is good to go | ||
logger.log('validating pom.xml') | ||
const pomXml = await getPomInfo(logger) | ||
validatePomXml(pomXml) | ||
logger.log('pom.xml validation successful') | ||
|
||
// make sure maven-settings file exists | ||
logger.log('validating maven-settings.xml') | ||
const stats = await fs.stat('./maven-settings.xml') | ||
|
||
if (!stats) { | ||
throw getError('ENOMAVENSETTINGS') | ||
} | ||
|
||
logger.log('validating maven-settings.xml') | ||
|
||
// HELP WANTED: do more validation of maven-settings.xml file and OSSRH login | ||
} | ||
|
||
/** | ||
* Validate that the contents of pom.xml appear to be setup properly | ||
*/ | ||
function validatePomXml (pomXml) { | ||
if (!pomXml) { | ||
throw getError('EREADPOMXML') | ||
} | ||
|
||
const pomValidationErrors = [] | ||
|
||
if (!pomXml.project) { | ||
pomValidationErrors.push(getError('ENOPOMPROJECT')) | ||
} else { | ||
if (!pomXml.project.groupId || pomXml.project.groupId.length === 0) { | ||
pomValidationErrors.push(getError('ENOPOMPROJECTGROUPID')) | ||
} | ||
if (!pomXml.project.artifactId || pomXml.project.artifactId.length === 0) { | ||
pomValidationErrors.push(getError('ENOPOMPROJECTARTIFACTID')) | ||
} | ||
// does the version need to be set if using semantic-release? | ||
if (!pomXml.project.version || !pomXml.project.version.length === 0) { | ||
pomValidationErrors.push(getError('ENOPOMPROJECTVERSION')) | ||
} | ||
} | ||
|
||
// HELP WANTED: validate more things in pom.xml file | ||
|
||
if (pomValidationErrors.length > 0) { | ||
throw new AggregateError(pomValidationErrors) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters