Skip to content

Commit

Permalink
Merge pull request #19 from restfulhead/main
Browse files Browse the repository at this point in the history
chore: trigger release
  • Loading branch information
restfulhead authored Mar 18, 2024
2 parents 3522fd7 + 97d6027 commit a74bfd1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ jobs:
rm -rf .git
else
echo "::notice title=Versioning of $PCKG_NAME skipped::No relevant changes detected."
exit 1
fi
cd $topdir
Expand Down
9 changes: 8 additions & 1 deletion packages/filter-by-workspace-path/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To start using this plugin, add it to your `.autorc` config, for example:
```json
{
"plugins": [
"@restfulhead/auto-plugin-filter-by-workspace-path",
["@restfulhead/auto-plugin-filter-by-workspace-path",{"npm":true}],
"npm",
]
}
Expand All @@ -22,6 +22,13 @@ directory, then the changelog will only include pull requests that contain files

However, carefully read the following caveats section.

## Supported Config

| Parameter | Description | Default |
| ----------------------- | ---------------------------------------------------------- | -------- |
| `npm` | Boolean to use NPM workspaces or not. In case you're using auto without NPM, specify `"npm": false`, this way the plugin will filter out changes outside of the current folder `auto` is run from. | `true` |


## Caveats

* Note that this plugin also omits commits that
Expand Down
25 changes: 21 additions & 4 deletions packages/filter-by-workspace-path/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,33 @@ function shouldOmitCommit(currentDir: string, currentWorkspace: string, commit:
}
}

export interface ProjectFilteringPluginOptions {
/** Path from the repo root to project we are filtering on */
npm: boolean
}

export default class FilterByWorkspacePathPlugin implements IPlugin {
/** The name of the plugin */
name = 'filter-by-workspace-path-plugin'

/** The options of the plugin */
readonly options: ProjectFilteringPluginOptions

/** Initialize the plugin with it's options */
constructor(options: ProjectFilteringPluginOptions = { npm: true }) {
this.options = options
}

apply(auto: Auto): void {
const currentDir = path.resolve('.')
const npmResult = execSync('npm ls --omit=dev --depth 1 -json', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] })
const workspaceDeps: any = JSON.parse(npmResult).dependencies
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
const currentWorkspace = workspaceDeps[Object.keys(workspaceDeps)[0] as any].resolved.substring(11)
let currentWorkspace = currentDir

if (this.options.npm) {
const npmResult = execSync('npm ls --omit=dev --depth 1 -json', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] })
const workspaceDeps: any = JSON.parse(npmResult).dependencies
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
currentWorkspace = workspaceDeps[Object.keys(workspaceDeps)[0] as any].resolved.substring(11)
}

auto.hooks.onCreateLogParse.tap(this.name, (logParse) => {
logParse.hooks.omitCommit.tap(this.name, (commit) =>
Expand Down

0 comments on commit a74bfd1

Please sign in to comment.