Comparing version 4.0.4 to 4.0.5
@@ -83,2 +83,3 @@ module.exports = { | ||
'@typescript-eslint/no-use-before-define': 'off', | ||
'@typescript-eslint/no-non-null-assertion': 0, | ||
}, | ||
@@ -85,0 +86,0 @@ overrides: [ |
@@ -13,2 +13,8 @@ "use strict"; | ||
const prepareChangelogs = (env) => { | ||
var _a; | ||
if (!((_a = env.config) === null || _a === void 0 ? void 0 : _a.changelogPath)) { | ||
const errorMessage = '"config.changelogPath" attribute not found on env config object'; | ||
error(errorMessage); | ||
throw new Error(errorMessage); | ||
} | ||
if (!env.packages) { | ||
@@ -21,6 +27,13 @@ const errorMessage = '"packages" attribute not found on env config object'; | ||
const releasablePackages = get_releasable_packages_1.getReleasablePackages(clonePackages); | ||
if (!releasablePackages.length) { | ||
const errorMessage = 'No packages to be released found!'; | ||
error(errorMessage); | ||
throw new Error(errorMessage); | ||
} | ||
const changelogDate = `${get_week_number_1.getWeekNumber(new Date()).join('-')}`; | ||
const mainChangeLogPath = path_1.join(`${env.config.changelogPath}`, `rlsr-log-${changelogDate}.json`); | ||
env.mainChangelogPath = mainChangeLogPath; | ||
let mainChangeLogContent = { [changelogDate]: [] }; | ||
const mainChangelogPath = path_1.join(`${env.config.changelogPath}`, `rlsr-log-${changelogDate}.json`); | ||
const mainChangelogContent = { [changelogDate]: [] }; | ||
if (fs_1.existsSync(mainChangelogPath)) { | ||
Object.assign(mainChangelogContent, JSON.parse(fs_1.readFileSync(mainChangelogPath, 'utf8'))); | ||
} | ||
releasablePackages.forEach((packageName) => { | ||
@@ -39,17 +52,14 @@ const currentPackage = clonePackages[packageName]; | ||
} | ||
let changeLogContent = {}; | ||
const changelogContent = {}; | ||
if (fs_1.existsSync(changelogFile)) { | ||
changeLogContent = JSON.parse(fs_1.readFileSync(changelogFile, 'utf8')); | ||
Object.assign(changelogContent, JSON.parse(fs_1.readFileSync(changelogFile, 'utf8'))); | ||
} | ||
changeLogContent[version] = messages; | ||
changelogContent[version] = messages; | ||
log(`writing changelog messages for "${chalk_1.white(packageName)}" on ${chalk_1.white(version)}`); | ||
clonePackages[packageName] = { | ||
...ramda_1.clone(currentPackage), | ||
changelogs: changeLogContent, | ||
...currentPackage, | ||
changelogs: changelogContent, | ||
}; | ||
log(`writing main changelog messages for "${chalk_1.white(packageName)}" on ${chalk_1.white(version)}`); | ||
if (fs_1.existsSync(mainChangeLogPath)) { | ||
mainChangeLogContent = JSON.parse(fs_1.readFileSync(mainChangeLogPath, 'utf8')); | ||
} | ||
mainChangeLogContent[changelogDate].push({ | ||
mainChangelogContent[changelogDate].push({ | ||
package: packageName, | ||
@@ -59,7 +69,11 @@ version, | ||
}); | ||
env.changelog = mainChangeLogContent; | ||
}); | ||
return { ...env, packages: clonePackages }; | ||
return { | ||
...env, | ||
packages: clonePackages, | ||
mainChangelogPath, | ||
changelog: mainChangelogContent, | ||
}; | ||
}; | ||
exports.prepareChangelogs = prepareChangelogs; | ||
//# sourceMappingURL=prepare-changelogs.js.map |
@@ -13,6 +13,3 @@ "use strict"; | ||
// Fetch all packageJson' paths | ||
const packageJsonPaths = [ | ||
...glob_1.sync(`${env.appRoot}/package.json`), | ||
...glob_1.sync(`${env.appRoot}/!(node_modules)/**/package.json`), // and everything else | ||
]; | ||
const packageJsonPaths = glob_1.sync(`${env.appRoot}/**/package.json`).filter((packageJsonPath) => !packageJsonPath.includes('/node_modules/')); | ||
const packages = packageJsonPaths.reduce((accumulator, packageJsonPath) => { | ||
@@ -19,0 +16,0 @@ var _a, _b, _c, _d, _e; |
@@ -21,2 +21,6 @@ "use strict"; | ||
log(`${chalk_1.yellow(commitMessages.length)} relevant commits: ${commitMessages.filter(({ level }) => level === 'major').length} major / ${commitMessages.filter(({ level }) => level === 'minor').length} minor / ${commitMessages.filter(({ level }) => level === 'patch').length} patch`); | ||
if (!commitMessages.length) { | ||
log('No relevant commits found, stopping the script'); | ||
process.exit(0); | ||
} | ||
return { ...env, commitMessages }; | ||
@@ -23,0 +27,0 @@ }; |
@@ -16,3 +16,5 @@ "use strict"; | ||
}; | ||
const log = (level, section) => (...rest) => { | ||
const log = (level, section) => | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(...rest) => { | ||
// eslint-disable-next-line no-console | ||
@@ -19,0 +21,0 @@ console.log(`${levels[level]} ${chalk_1.dim('[' + section + ']')}`, ...rest); |
@@ -8,4 +8,4 @@ "use strict"; | ||
const ramda_1 = require("ramda"); | ||
const simple_git_1 = __importDefault(require("simple-git")); | ||
const logger_1 = require("../helpers/logger"); | ||
const simple_git_1 = __importDefault(require("simple-git")); | ||
const get_releasable_packages_1 = require("../helpers/get-releasable-packages"); | ||
@@ -12,0 +12,0 @@ const { log, error } = logger_1.logger('[persist] commit and tag packages'); |
{ | ||
"name": "rlsr", | ||
"version": "4.0.4", | ||
"version": "4.0.5", | ||
"description": "create npm releses and changelogs from a multi repo", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -13,3 +13,2 @@ import { existsSync, readFileSync } from 'fs'; | ||
PackageAfterDetermineVersion, | ||
PackageAfterPrepareChangelogs, | ||
PackageChangelog, | ||
@@ -28,2 +27,9 @@ MainChangelog, | ||
export const prepareChangelogs: Module = (env) => { | ||
if (!env.config?.changelogPath) { | ||
const errorMessage = | ||
'"config.changelogPath" attribute not found on env config object'; | ||
error(errorMessage); | ||
throw new Error(errorMessage); | ||
} | ||
if (!env.packages) { | ||
@@ -38,11 +44,23 @@ const errorMessage = '"packages" attribute not found on env config object'; | ||
if (!releasablePackages.length) { | ||
const errorMessage = 'No packages to be released found!'; | ||
error(errorMessage); | ||
throw new Error(errorMessage); | ||
} | ||
const changelogDate = `${getWeekNumber(new Date()).join('-')}`; | ||
const mainChangeLogPath = join( | ||
`${env.config!.changelogPath}`, | ||
const mainChangelogPath = join( | ||
`${env.config.changelogPath}`, | ||
`rlsr-log-${changelogDate}.json` | ||
); | ||
env.mainChangelogPath = mainChangeLogPath; | ||
let mainChangeLogContent: MainChangelog = { [changelogDate]: [] }; | ||
const mainChangelogContent: MainChangelog = { [changelogDate]: [] }; | ||
if (existsSync(mainChangelogPath)) { | ||
Object.assign( | ||
mainChangelogContent, | ||
JSON.parse(readFileSync(mainChangelogPath, 'utf8')) | ||
); | ||
} | ||
releasablePackages.forEach((packageName) => { | ||
@@ -52,2 +70,3 @@ const currentPackage = clonePackages[ | ||
] as PackageAfterDetermineVersion; | ||
log(`preparing changelog messages for ${white(packageName)} `); | ||
@@ -60,3 +79,2 @@ | ||
const relatedMessages: RelatedMessage[] = currentPackage.relatedMessages; | ||
const messages = [...pkgMessages, ...relatedMessages]; | ||
@@ -70,9 +88,12 @@ | ||
let changeLogContent: PackageChangelog = {}; | ||
const changelogContent: PackageChangelog = {}; | ||
if (existsSync(changelogFile)) { | ||
changeLogContent = JSON.parse(readFileSync(changelogFile, 'utf8')); | ||
Object.assign( | ||
changelogContent, | ||
JSON.parse(readFileSync(changelogFile, 'utf8')) | ||
); | ||
} | ||
changeLogContent[version] = messages; | ||
changelogContent[version] = messages; | ||
log( | ||
@@ -85,5 +106,5 @@ `writing changelog messages for "${white(packageName)}" on ${white( | ||
clonePackages[packageName] = { | ||
...clone(currentPackage), | ||
changelogs: changeLogContent, | ||
} as PackageAfterPrepareChangelogs; | ||
...currentPackage, | ||
changelogs: changelogContent, | ||
}; | ||
@@ -96,9 +117,3 @@ log( | ||
if (existsSync(mainChangeLogPath)) { | ||
mainChangeLogContent = JSON.parse( | ||
readFileSync(mainChangeLogPath, 'utf8') | ||
); | ||
} | ||
mainChangeLogContent![changelogDate].push({ | ||
mainChangelogContent[changelogDate].push({ | ||
package: packageName, | ||
@@ -108,6 +123,10 @@ version, | ||
}); | ||
env.changelog = mainChangeLogContent; | ||
}); | ||
return { ...env, packages: clonePackages }; | ||
return { | ||
...env, | ||
packages: clonePackages, | ||
mainChangelogPath, | ||
changelog: mainChangelogContent, | ||
}; | ||
}; |
@@ -16,6 +16,5 @@ import { sync as glob } from 'glob'; | ||
// Fetch all packageJson' paths | ||
const packageJsonPaths: string[] = [ | ||
...glob(`${env.appRoot}/package.json`), // the main project's | ||
...glob(`${env.appRoot}/!(node_modules)/**/package.json`), // and everything else | ||
]; | ||
const packageJsonPaths: string[] = glob( | ||
`${env.appRoot}/**/package.json` | ||
).filter((packageJsonPath) => !packageJsonPath.includes('/node_modules/')); | ||
@@ -22,0 +21,0 @@ const packages: Env['packages'] = packageJsonPaths.reduce( |
@@ -35,3 +35,8 @@ import { yellow } from 'chalk'; | ||
if (!commitMessages.length) { | ||
log('No relevant commits found, stopping the script'); | ||
process.exit(0); | ||
} | ||
return { ...env, commitMessages } as Env; | ||
}; |
@@ -18,2 +18,3 @@ import { red, yellow, dim, green } from 'chalk'; | ||
(level: 'debug' | 'log' | 'warn' | 'error', section: string) => | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(...rest: any[]) => { | ||
@@ -20,0 +21,0 @@ // eslint-disable-next-line no-console |
import { clone } from 'ramda'; | ||
import simpleGit from 'simple-git'; | ||
import type { Env, Module, PackageAfterPrepareChangelogs } from '../types'; | ||
import { logger } from '../helpers/logger'; | ||
import simpleGit from 'simple-git'; | ||
import { getReleasablePackages } from '../helpers/get-releasable-packages'; | ||
@@ -7,0 +9,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
289548
4710