Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add manifest path support to conditional reporter #206

Merged
merged 7 commits into from
Nov 18, 2024

Conversation

JakeLane
Copy link
Contributor

@JakeLane JakeLane commented Nov 13, 2024

Motivation

Add a configuration option to package.json so we can configure the path for the manifest. This is important as jira needs a separate directory for non-hashed file paths.

Changes

  • Add filename option to package.json
  • Added new eslint package based on eslint-plugin-monorepo which fixes the auto-fixer behaviour

Checklist

  • Existing or new tests cover this change

const getPackages = require('get-monorepo-packages');
const isInside = require('path-is-inside');
const minimatch = require('minimatch');
const _path = require('path');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it underscored?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was because the original creator wanted to use path as a variable 😅 .

I might just refactor the plugin to address the issues you mentioned

'' +
pkg.package.name +
(subPackagePath !== '.' ? '/' + subPackagePath : '');
const path = _path.parse(basePath).dir;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just parse once

message: `Import for monorepo package '${pkg.package.name}' should be absolute.`,
fix: (fixer) => {
const basePath =
'' +
Copy link
Contributor

@MonicaOlejniczak MonicaOlejniczak Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this?

return fixer.replaceText(
node,
"'" +
(name !== '.' && name !== 'index' ? path + '/' + name : path) +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(name !== '.' && name !== 'index' ? path + '/' + name : path) +
(name !== '.' && name !== 'index' ? `${path}/${name}` : path) +

|};

// Exported for testing
export async function getConfig({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/nit this can just be in its own file, then you don't need the comment and you can just read the reporter logic without worrying about config at a glance

logger: PluginLogger,
tracer: PluginTracer,
|}): Async<void> {
const {filename} = await getConfig(options);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only be retrieved on buildSuccess, otherwise it will slow down builds since reporter events are emitted all the time. Therefore, you can just have an early return when it's not a success event

@JakeLane JakeLane force-pushed the add-manifest-path-config-import-cond branch from 4ce44f6 to 2bf59de Compare November 14, 2024 06:06
@JakeLane JakeLane force-pushed the add-manifest-path-config-import-cond branch from eaf7f43 to 3382ddf Compare November 14, 2024 06:42
@JakeLane JakeLane merged commit 80c3a97 into main Nov 18, 2024
17 checks passed
@JakeLane JakeLane deleted the add-manifest-path-config-import-cond branch November 18, 2024 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants