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

Bugfix: schema script directory #3174

Conversation

nullpointerexceptionkek
Copy link
Contributor

Linked Issue

Closes #3165

Description

The original regex matches the first skeleton-*, which can lead to incorrect matches (e.g., "next" instead of "svelte" in /home/louis/skeleton-next/.../skeleton-svelte/...). This update ensures it targets the correct package name (e.g., "svelte") by anchoring the match to /src/lib/components.

Changsets

Instructions: Changesets automate our changelog. If you modify files in /packages, run pnpm changeset in the root of the monorepo, follow the prompts, then commit the markdown file. Changes that add features should be minor while chores and bugfixes should be patch. Please prefix the changeset message with feat:, bugfix: or chore:.

Checklist

Please read and apply all contribution requirements.

  • This PR targets the dev branch (NEVER master)
  • Documentation reflects all relevant changes
  • Branch is prefixed with: docs/, feat/, chore/, bugfix/
  • Ensure Svelte and Typescript linting is current - run pnpm ci:check
  • Ensure Prettier linting is current - run pnpm format
  • All test cases are passing - run pnpm test
  • Includes a changeset (if relevant; see above)

Copy link

changeset-bot bot commented Jan 26, 2025

⚠️ No Changeset found

Latest commit: 54cb66a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jan 26, 2025

@nullpointerexceptionkek is attempting to deploy a commit to the Skeleton Labs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Jan 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
skeleton-docs ❌ Failed (Inspect) Jan 26, 2025 7:50pm

@@ -15,7 +15,7 @@ function toKebabCase(str: string) {

async function processFile(path: string): Promise<number> {
const component = basename(dirname(path));
const framework = path.match(/skeleton-([^/]+)/)?.[1];
const framework = path.match(/skeleton-([^/]+)(?=\/src\/lib\/components)/)?.[1];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Path:
    /home/louis/repos/skeleton-ui-dev/skeleton/sites/next.skeleton.dev/node_modules/@skeletonlabs/skeleton-react/src/lib/components/AppBar/types.ts
    Result: react

  2. Path:
    /projects/skeleton-core/src/lib/components/Button/types.ts
    Result: core

  3. Path:
    /var/www/skeleton-theme/src/lib/components/Card/types.ts
    Result: theme

  4. Path:
    /random/path/skeleton-next/node_modules/@skeletonlabs/skeleton-svelte/src/lib/components/Input/types.ts
    Result: svelte

  5. Path:
    /nested/directory/skeleton-test/skeleton-ui/src/lib/components/Modal/types.ts
    Result: ui

  6. Path:
    /path/to/skeleton-gg/skeleton-core/src/lib/components/Header/types.ts
    Result: core

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder instead of being more specific just only include the root from the project and no more (like the folder the project is in).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, after doing some testing I came up with:

	const component = basename(dirname(path));
	const matches = path.match(/skeleton-([^/]+)(?=\/|$)/g);
	const match = matches?.at(-1);
	const framework = match?.replace('skeleton-', '');
	if (!framework) {
		throw new Error(`Invalid framework path: ${path}`);
	}

This will match all skeleton-* appearances with the \g (global) flag.
Then grab the last match, using .at(-1), and remove the skeleton- bit, leaving the framework (if present).
If you agree with this solution please change your code in the PR and I'll merge it ASAP.

Copy link
Contributor

@Hugos68 Hugos68 left a comment

Choose a reason for hiding this comment

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

See my comment for an alternative (and more robust) solution.

@@ -15,7 +15,7 @@ function toKebabCase(str: string) {

async function processFile(path: string): Promise<number> {
const component = basename(dirname(path));
const framework = path.match(/skeleton-([^/]+)/)?.[1];
const framework = path.match(/skeleton-([^/]+)(?=\/src\/lib\/components)/)?.[1];
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, after doing some testing I came up with:

	const component = basename(dirname(path));
	const matches = path.match(/skeleton-([^/]+)(?=\/|$)/g);
	const match = matches?.at(-1);
	const framework = match?.replace('skeleton-', '');
	if (!framework) {
		throw new Error(`Invalid framework path: ${path}`);
	}

This will match all skeleton-* appearances with the \g (global) flag.
Then grab the last match, using .at(-1), and remove the skeleton- bit, leaving the framework (if present).
If you agree with this solution please change your code in the PR and I'll merge it ASAP.

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