Skip to content

Commit

Permalink
fix(core): exclude external libs in getSourceFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
IKatsuba committed Sep 20, 2024
1 parent f99967c commit bf3f2c7
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 51 deletions.
5 changes: 1 addition & 4 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
}
}
],
"plugins": [
"prettier-plugin-packagejson",
"@ianvs/prettier-plugin-sort-imports"
],
"plugins": ["prettier-plugin-packagejson", "@ianvs/prettier-plugin-sort-imports"],
"importOrder": [
"<BUILTIN_MODULES>",
"<THIRD_PARTY_MODULES>",
Expand Down
48 changes: 48 additions & 0 deletions docs/src/app/code-of-conduct/page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Code of Conduct

As a community of developers, we strive to create a friendly, safe, and welcoming environment for
all, regardless of experience level, gender, gender identity and expression, sexual orientation,
disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior include:

- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit
permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are
expected to take appropriate and fair corrective action in response to any instances of unacceptable
behavior.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is
representing the project or its community.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting
the project team at [igor@katsuba.dev](mailto:igor@katsuba.dev) . All complaints will be reviewed
and investigated and will result in a response that is deemed necessary and appropriate to the
circumstances.

## Attribution

This Code of Conduct is adapted from the
[Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
54 changes: 53 additions & 1 deletion docs/src/app/coding-standards/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,56 @@ nextjs:
description: 'Learn about the coding standards of `mutates`.'
---

WIP
# Coding Standards

Welcome to the coding standards for the `mutates` project. This document outlines the guidelines and
best practices for contributing to the codebase.

## General Guidelines

- **Consistency**: Ensure that your code is consistent with the existing codebase.
- **Readability**: Write code that is easy to read and understand.
- **Documentation**: Document your code where necessary, especially for complex logic.

## Code Style

- **Indentation**: Use 2 spaces for indentation.
- **Line Length**: Limit lines to 100 characters.
- **Quotes**: Use single quotes for strings.
- **Semicolons**: Use semicolons at the end of statements.

## TypeScript Specific

- **Types**: Always define types for function parameters and return values.
- **Interfaces**: Prefer interfaces over type aliases for object shapes.
- **Enums**: Use enums for sets of related constants.

## Example

Here is an example of a well-formatted TypeScript function:

```typescript
function greet(name: string): string {
return `Hello, ${name}`;
}
```

## Linting and Formatting

We use ESLint and Prettier to enforce code style and formatting. Ensure that your code passes all
linting checks before submitting a pull request.

## Commit Messages

Follow the [Conventional Commits](https://www.conventionalcommits.org/) specification for commit
messages. This helps in automating the release process and generating changelogs.

## Additional Resources

For more detailed guidelines, refer to the following documents:

- [Contribution Guide](/contribution-guide)
- [Frequently Asked Questions](/frequently-asked-questions)
- [Troubleshooting](/troubleshooting)

Thank you for contributing to `mutates`!
82 changes: 81 additions & 1 deletion docs/src/app/contribution-guide/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,84 @@ nextjs:
description: How to contribute to the Mutates project.
---

WIP
# Contributing to Mutates

We're thrilled that you're interested in contributing to Mutates! This document provides guidelines
and information about how to contribute to our project.

## Getting Started

1. Fork the repository on GitHub.
2. Clone your fork locally:
```bash
git clone https://github.com/your-username/mutates.git
cd mutates
```
3. Install dependencies:
```bash
npm install
```
4. Create a branch for your contribution:
```bash
git checkout -b feature/your-feature-name
```

## Development Workflow

1. Make your changes in the appropriate package(s).
2. Write or update tests for your changes.
3. Ensure all tests pass:
```bash
nx affected --target=test
```
4. Update documentation if necessary.
5. Commit your changes with a clear and descriptive commit message.

## Pull Request Process

1. Push your changes to your fork on GitHub.
2. Open a pull request against the `main` branch of the Mutates repository.
3. Ensure your PR description clearly describes the problem and solution.
4. Link any relevant issues in the PR description.
5. Wait for review from maintainers.

## Coding Standards

- Follow the existing code style in the project.
- Use TypeScript for new code.
- Write clear, self-documenting code with appropriate comments where necessary.
- Ensure your code passes linting:
```bash
nx affected --target=lint
```

## Testing

- Write unit tests for new functionality.
- Ensure all existing tests pass before submitting a PR.
- Aim for high test coverage for new code.

## Documentation

- Update relevant documentation for any new features or changes.
- Use clear and concise language in documentation.
- Include code examples where appropriate.

## Reporting Issues

- Use the GitHub issue tracker to report bugs or suggest features.
- Clearly describe the issue, including steps to reproduce for bugs.
- Check if the issue has already been reported before creating a new one.

## Community and Conduct

- Be respectful and inclusive in all interactions.
- Follow our [Code of Conduct](CODE_OF_CONDUCT.md).
- Help others in the community when you can.

## Questions?

If you have any questions about contributing, feel free to open an issue for discussion or reach out
to the maintainers directly.

Thank you for contributing to Mutates! Your efforts help make this project better for everyone.
13 changes: 4 additions & 9 deletions docs/src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import Link from 'next/link'
import Link from 'next/link';

export default function NotFound() {
return (
<div className="min-w-0 max-w-2xl flex-auto px-4 py-16 lg:max-w-none lg:pl-8 lg:pr-0 xl:px-16">
<div className="flex h-full flex-col items-center justify-center text-center">
<p className="font-display text-sm font-medium text-slate-900 dark:text-white">
404
</p>
<p className="font-display text-sm font-medium text-slate-900 dark:text-white">404</p>
<h1 className="mt-3 font-display text-3xl tracking-tight text-slate-900 dark:text-white">
Page not found
</h1>
<p className="mt-2 text-sm text-slate-500 dark:text-slate-400">
Sorry, we couldn’t find the page you’re looking for.
</p>
<Link
href="/"
className="mt-8 text-sm font-medium text-slate-900 dark:text-white"
>
<Link href="/" className="mt-8 text-sm font-medium text-slate-900 dark:text-white">
Go back home
</Link>
</div>
</div>
)
);
}
6 changes: 3 additions & 3 deletions docs/src/app/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use client'
'use client';

import { ThemeProvider } from 'next-themes'
import { ThemeProvider } from 'next-themes';

export function Providers({ children }: { children: React.ReactNode }) {
return (
<ThemeProvider attribute="class" disableTransitionOnChange>
{children}
</ThemeProvider>
)
);
}
20 changes: 8 additions & 12 deletions docs/src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
import Link from 'next/link'
import clsx from 'clsx'
import clsx from 'clsx';
import Link from 'next/link';

const variantStyles = {
primary:
'rounded-full bg-sky-300 py-2 px-4 text-sm font-semibold text-slate-900 hover:bg-sky-200 focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-300/50 active:bg-sky-500',
secondary:
'rounded-full bg-slate-800 py-2 px-4 text-sm font-medium text-white hover:bg-slate-700 focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white/50 active:text-slate-400',
}
};

type ButtonProps = {
variant?: keyof typeof variantStyles
variant?: keyof typeof variantStyles;
} & (
| React.ComponentPropsWithoutRef<typeof Link>
| (React.ComponentPropsWithoutRef<'button'> & { href?: undefined })
)
);

export function Button({
variant = 'primary',
className,
...props
}: ButtonProps) {
className = clsx(variantStyles[variant], className)
export function Button({ variant = 'primary', className, ...props }: ButtonProps) {
className = clsx(variantStyles[variant], className);

return typeof props.href === 'undefined' ? (
<button className={className} {...props} />
) : (
<Link className={className} {...props} />
)
);
}
22 changes: 6 additions & 16 deletions docs/src/components/Fence.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
'use client'
'use client';

import { Fragment } from 'react'
import { Highlight } from 'prism-react-renderer'
import { Highlight } from 'prism-react-renderer';
import { Fragment } from 'react';

export function Fence({
children,
language,
}: {
children: string
language: string
}) {
export function Fence({ children, language }: { children: string; language: string }) {
return (
<Highlight
code={children.trimEnd()}
language={language}
theme={{ plain: {}, styles: [] }}
>
<Highlight code={children.trimEnd()} language={language} theme={{ plain: {}, styles: [] }}>
{({ className, style, tokens, getTokenProps }) => (
<pre className={className} style={style}>
<code>
Expand All @@ -33,5 +23,5 @@ export function Fence({
</pre>
)}
</Highlight>
)
);
}
6 changes: 3 additions & 3 deletions docs/src/components/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ function LogomarkPaths() {
<path d="M10.308 5L18 17.5 10.308 30 2.615 17.5 10.308 5z" />
<path d="M18 17.5L10.308 5h15.144l7.933 12.5M18 17.5h15.385L25.452 30H10.308L18 17.5z" />
</g>
)
);
}

export function Logomark(props: React.ComponentPropsWithoutRef<'svg'>) {
return (
<svg aria-hidden="true" viewBox="0 0 36 36" fill="none" {...props}>
<LogomarkPaths />
</svg>
)
);
}

export function Logo(props: React.ComponentPropsWithoutRef<'svg'>) {
Expand All @@ -21,5 +21,5 @@ export function Logo(props: React.ComponentPropsWithoutRef<'svg'>) {
<LogomarkPaths />
<path d="M55.96 26.2c-1.027 0-1.973-.173-2.84-.52a6.96 6.96 0 01-2.24-1.5 6.979 6.979 0 01-1.46-2.3c-.347-.893-.52-1.867-.52-2.92 0-1.027.18-1.973.54-2.84a6.71 6.71 0 011.52-2.28 6.922 6.922 0 012.3-1.52 7.48 7.48 0 012.86-.54c.667 0 1.32.093 1.96.28a6.12 6.12 0 011.78.78 5.7 5.7 0 011.4 1.24l-1.88 2.08a6.272 6.272 0 00-1-.82 3.728 3.728 0 00-1.08-.54 3.542 3.542 0 00-1.2-.2 4.14 4.14 0 00-1.62.32 3.991 3.991 0 00-1.3.9 4.197 4.197 0 00-.9 1.38 4.755 4.755 0 00-.32 1.78c0 .667.107 1.273.32 1.82.213.533.513.993.9 1.38.387.373.847.667 1.38.88.547.2 1.147.3 1.8.3a4.345 4.345 0 002.34-.68c.347-.213.653-.46.92-.74l1.46 2.34c-.32.36-.753.687-1.3.98a7.784 7.784 0 01-1.8.7c-.667.16-1.34.24-2.02.24zm6.99-.2l5.48-14h2.68l5.46 14h-3.08l-2.82-7.54c-.08-.213-.18-.487-.3-.82a922.595 922.595 0 00-.68-2.12 13.694 13.694 0 01-.24-.86l.54-.02c-.08.307-.174.627-.28.96-.094.32-.194.653-.3 1-.108.333-.22.66-.34.98-.12.32-.234.633-.34.94L65.91 26h-2.96zm2.54-2.94l.98-2.42h6.42l1 2.42h-8.4zm19.794 3.14c-1.026 0-1.973-.173-2.84-.52a6.96 6.96 0 01-2.24-1.5 6.98 6.98 0 01-1.46-2.3c-.346-.893-.52-1.867-.52-2.92 0-1.027.18-1.973.54-2.84a6.71 6.71 0 011.52-2.28 6.923 6.923 0 012.3-1.52 7.48 7.48 0 012.86-.54c.667 0 1.32.093 1.96.28a6.118 6.118 0 011.78.78c.547.347 1.014.76 1.4 1.24l-1.88 2.08a6.272 6.272 0 00-1-.82 3.728 3.728 0 00-1.08-.54 3.542 3.542 0 00-1.2-.2 4.14 4.14 0 00-1.62.32 3.992 3.992 0 00-1.3.9 4.197 4.197 0 00-.9 1.38 4.755 4.755 0 00-.32 1.78c0 .667.107 1.273.32 1.82.214.533.514.993.9 1.38.387.373.847.667 1.38.88.547.2 1.147.3 1.8.3a4.345 4.345 0 002.34-.68 4.53 4.53 0 00.92-.74l1.46 2.34c-.32.36-.753.687-1.3.98a7.784 7.784 0 01-1.8.7c-.666.16-1.34.24-2.02.24zm17.469-.2V12h3v14h-3zm-8.82 0V12h3v14h-3zm1.2-5.62l.02-2.72h9.14v2.72h-9.16zM110.402 26V12h9.46v2.64h-6.54v8.72h6.68V26h-9.6zm1.4-5.86v-2.56h7.1v2.56h-7.1zM122.437 26l5.48-14h2.68l5.46 14h-3.08l-2.82-7.54c-.08-.213-.18-.487-.3-.82l-.34-1.06-.34-1.06a14.73 14.73 0 01-.24-.86l.54-.02c-.08.307-.173.627-.28.96a63.3 63.3 0 01-.3 1c-.106.333-.22.66-.34.98-.12.32-.233.633-.34.94l-2.82 7.48h-2.96zm2.54-2.94l.98-2.42h6.42l1 2.42h-8.4zM139.023 26V12h5.74c1.027 0 1.953.173 2.78.52.84.333 1.56.813 2.16 1.44a6.097 6.097 0 011.4 2.2c.32.853.48 1.8.48 2.84 0 1.027-.16 1.973-.48 2.84a6.438 6.438 0 01-1.38 2.22 6.394 6.394 0 01-2.16 1.44c-.84.333-1.773.5-2.8.5h-5.74zm3-2.18l-.32-.52h2.96c.6 0 1.14-.1 1.62-.3.48-.213.887-.5 1.22-.86.347-.373.607-.827.78-1.36.173-.533.26-1.127.26-1.78a5.56 5.56 0 00-.26-1.76 3.595 3.595 0 00-.78-1.36 3.323 3.323 0 00-1.22-.86 3.948 3.948 0 00-1.62-.32h-3.02l.38-.48v9.6zM158.671 26l-5.58-14h3.18l2.92 7.58c.16.413.293.78.4 1.1.12.307.22.6.3.88.093.267.18.533.26.8.08.253.16.533.24.84l-.58.02c.107-.413.213-.793.32-1.14.107-.36.227-.733.36-1.12.133-.387.3-.847.5-1.38l2.76-7.58h3.16l-5.62 14h-2.62zm8.114 0l5.48-14h2.68l5.46 14h-3.08l-2.82-7.54c-.08-.213-.18-.487-.3-.82l-.34-1.06-.34-1.06a13.293 13.293 0 01-.24-.86l.54-.02c-.08.307-.173.627-.28.96a63.3 63.3 0 01-.3 1c-.107.333-.22.66-.34.98-.12.32-.233.633-.34.94l-2.82 7.48h-2.96zm2.54-2.94l.98-2.42h6.42l1 2.42h-8.4zM183.371 26V12h2.68l7.74 10.46h-.56c-.054-.413-.1-.813-.14-1.2l-.12-1.2c-.027-.413-.054-.833-.08-1.26-.014-.44-.027-.9-.04-1.38a56.825 56.825 0 01-.02-1.6V12h2.94v14h-2.72l-7.9-10.56.76.02c.066.693.12 1.287.16 1.78a36.623 36.623 0 01.18 2.2c.026.267.04.52.04.76.013.24.02.493.02.76V26h-2.94zm23.175.2c-1.027 0-1.973-.173-2.84-.52-.853-.36-1.6-.86-2.24-1.5a6.979 6.979 0 01-1.46-2.3c-.347-.893-.52-1.867-.52-2.92 0-1.027.18-1.973.54-2.84a6.71 6.71 0 011.52-2.28 6.919 6.919 0 012.3-1.52 7.48 7.48 0 012.86-.54c.667 0 1.32.093 1.96.28a6.12 6.12 0 011.78.78 5.7 5.7 0 011.4 1.24l-1.88 2.08a6.259 6.259 0 00-1-.82 3.721 3.721 0 00-1.08-.54 3.54 3.54 0 00-1.2-.2 4.14 4.14 0 00-1.62.32 3.991 3.991 0 00-1.3.9 4.206 4.206 0 00-.9 1.38 4.76 4.76 0 00-.32 1.78c0 .667.107 1.273.32 1.82.213.533.513.993.9 1.38.387.373.847.667 1.38.88.547.2 1.147.3 1.8.3a4.35 4.35 0 002.34-.68c.347-.213.653-.46.92-.74l1.46 2.34c-.32.36-.753.687-1.3.98a7.773 7.773 0 01-1.8.7c-.667.16-1.34.24-2.02.24zm8.649-.2V12h9.46v2.64h-6.54v8.72h6.68V26h-9.6zm1.4-5.86v-2.56h7.1v2.56h-7.1z" />
</svg>
)
);
}
8 changes: 6 additions & 2 deletions packages/core/src/lib/source-file/get-source-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import { getActiveProject } from '../project';
import { Pattern } from '../utils';

export function getSourceFiles(pattern?: Pattern): SourceFile[] {
return getActiveProject().getSourceFiles(pattern as string);
return getActiveProject()
.getSourceFiles(pattern as string)
.filter((file) => !file.isFromExternalLibrary());
}

export function getSourceFile(filePath: string): SourceFile | null {
return getActiveProject().getSourceFile(filePath) ?? null;
const file = getActiveProject().getSourceFile(filePath);

return file && !file.isFromExternalLibrary() ? file : null;
}

0 comments on commit bf3f2c7

Please sign in to comment.