-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(semantic-release-plugin): Removed dependancy on commit analyzer
- Loading branch information
1 parent
51f4809
commit 4796955
Showing
6 changed files
with
86 additions
and
12 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
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
25 changes: 25 additions & 0 deletions
25
packages/semantic-release-plugin/src/semantic-release-plugin/load-parser-config.ts
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,25 @@ | ||
import importFrom from "import-from"; | ||
import { dirname } from "path"; | ||
import { getWorkspaceRoot } from "./utils"; | ||
|
||
export const loadParserConfig = async ( | ||
{ preset, config, parserOpts, presetConfig }, | ||
{ cwd } | ||
) => { | ||
let loadedConfig; | ||
const __dirname = dirname(getWorkspaceRoot()); | ||
|
||
if (preset) { | ||
const presetPackage = `conventional-changelog-${preset.toLowerCase()}`; | ||
loadedConfig = await ( | ||
importFrom.silent(__dirname, presetPackage) || | ||
importFrom(cwd, presetPackage) | ||
)(presetConfig); | ||
} else if (config) { | ||
loadedConfig = await ( | ||
importFrom.silent(__dirname, config) || importFrom(cwd, config) | ||
)(); | ||
} | ||
|
||
return { ...loadedConfig.parserOpts, ...parserOpts }; | ||
}; |
46 changes: 46 additions & 0 deletions
46
packages/semantic-release-plugin/src/semantic-release-plugin/load-release-rules.ts
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,46 @@ | ||
import importFrom from "import-from"; | ||
import { isUndefined } from "lodash"; | ||
import { dirname } from "node:path"; | ||
import { RELEASE_TYPES } from "../constants"; | ||
import { getWorkspaceRoot } from "./utils"; | ||
|
||
export const loadReleaseRules = async ({ releaseRules }, { cwd }) => { | ||
let loadedReleaseRules; | ||
const __dirname = dirname(getWorkspaceRoot()); | ||
|
||
if (releaseRules) { | ||
loadedReleaseRules = | ||
typeof releaseRules === "string" | ||
? importFrom.silent(__dirname, releaseRules) || | ||
importFrom(cwd, releaseRules) | ||
: releaseRules; | ||
|
||
if (!Array.isArray(loadedReleaseRules)) { | ||
throw new TypeError( | ||
'Error in commit-analyzer configuration: "releaseRules" must be an array of rules' | ||
); | ||
} | ||
|
||
loadedReleaseRules.forEach(rule => { | ||
if (!rule || isUndefined(rule.release)) { | ||
throw new Error( | ||
'Error in commit-analyzer configuration: rules must be an object with a "release" property' | ||
); | ||
} else if ( | ||
!RELEASE_TYPES.includes(rule.release) && | ||
rule.release !== null && | ||
rule.release !== false | ||
) { | ||
throw new Error( | ||
`Error in commit-analyzer configuration: "${ | ||
rule.release | ||
}" is not a valid release type. Valid values are: ${JSON.stringify( | ||
RELEASE_TYPES | ||
)}` | ||
); | ||
} | ||
}); | ||
} | ||
|
||
return loadedReleaseRules; | ||
}; |
9 changes: 9 additions & 0 deletions
9
packages/semantic-release-plugin/src/semantic-release-plugin/utils.ts
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,9 @@ | ||
import { findWorkspaceRoot } from "nx/src/utils/find-workspace-root"; | ||
|
||
export const getWorkspaceRoot = () => { | ||
const root = findWorkspaceRoot(process.cwd()); | ||
process.env.DEV_REPO_ROOT ??= root?.dir; | ||
process.env.NX_WORKSPACE_ROOT_PATH ??= root?.dir; | ||
|
||
return root?.dir; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.