Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "depstr", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Bulk linking of packages and bulk updated for dependencies", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -37,2 +37,3 @@ import RainbowConfig from '@rainbow-industries/rainbow-config'; | ||
async update() { | ||
log.info('Staritng updater'); | ||
await this.loadConfig(); | ||
@@ -81,5 +82,8 @@ const localPackageMap = await this.collectLocalPackages(); | ||
log.info(`Found ${packagesToUpdate.size} packages: starting update`); | ||
for (const config of packagesToUpdate) { | ||
await this.updatePackage(config.path); | ||
} | ||
log.success(`Package update finished`); | ||
} | ||
@@ -93,2 +97,3 @@ | ||
async updatePackage(packagePath) { | ||
log.info(`Updating dependencies for package ${packagePath}`); | ||
const hasChanges = await this.hasChanges(packagePath); | ||
@@ -108,5 +113,9 @@ if (hasChanges) { | ||
await this.updateNPPMPackages(packagePath); | ||
await this.updateVersion(packagePath); | ||
await this.publish(packagePath); | ||
const hasUpdates = await this.updateNPPMPackages(packagePath); | ||
if (hasUpdates) { | ||
await this.updateVersion(packagePath); | ||
await this.publish(packagePath); | ||
} else { | ||
log.debug(`Nothign to update for package ${packagePath}`); | ||
} | ||
} | ||
@@ -118,3 +127,7 @@ | ||
async publish(packagePath) { | ||
await execute(`cd ${packagePath} && npm publish`); | ||
if (this.isDryRun) return; | ||
if (!process.argv.includes('--no-publish')) { | ||
log.info(`Publishing package ${packagePath}`); | ||
await execute(`cd ${packagePath} && npm publish`); | ||
} | ||
} | ||
@@ -126,3 +139,8 @@ | ||
async updateVersion(packagePath) { | ||
if (this.isDryRun) return; | ||
log.debug(`Increasing version of package`); | ||
await execute(`cd ${packagePath} && npm version ${this.version}`); | ||
log.debug('Pushing tags and commits to origin'); | ||
await execute(`cd ${packagePath} && git push origin develop`); | ||
@@ -138,5 +156,10 @@ await execute(`cd ${packagePath} && git push --tags`); | ||
async updateNPPMPackages(packagePath) { | ||
log.debug(`Updating dependencies for ${packagePath}`); | ||
if (!this.isDryRun) { | ||
if (!this.isDryRun) { | ||
log.debug('Pulling from origin'); | ||
await execute(`cd ${packagePath} && git pull origin develop`); | ||
log.debug(`Updating dependencies for ${packagePath}`); | ||
try { | ||
@@ -147,2 +170,12 @@ await execute(`cd ${packagePath} && rm -r node_modules`); | ||
await execute(`cd ${packagePath} && npm update`); | ||
const hasChanges = await this.hasChanges(packagePath); | ||
if (hasChanges) { | ||
log.debug('Committing package updates ...'); | ||
await execute(`cd ${packagePath} && git commit -am "chore: (depstr) update dependencies"`); | ||
} | ||
return hasChanges; | ||
} | ||
@@ -149,0 +182,0 @@ } |
15114
307