-
-
Notifications
You must be signed in to change notification settings - Fork 331
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
Bugfix: schema script directory #3174
Conversation
|
@nullpointerexceptionkek is attempting to deploy a commit to the Skeleton Labs Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -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]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
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
-
Path:
/projects/skeleton-core/src/lib/components/Button/types.ts
Result:core
-
Path:
/var/www/skeleton-theme/src/lib/components/Card/types.ts
Result:theme
-
Path:
/random/path/skeleton-next/node_modules/@skeletonlabs/skeleton-svelte/src/lib/components/Input/types.ts
Result:svelte
-
Path:
/nested/directory/skeleton-test/skeleton-ui/src/lib/components/Modal/types.ts
Result:ui
-
Path:
/path/to/skeleton-gg/skeleton-core/src/lib/components/Header/types.ts
Result:core
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this 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]; |
There was a problem hiding this comment.
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.
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
, runpnpm changeset
in the root of the monorepo, follow the prompts, then commit the markdown file. Changes that add features should beminor
while chores and bugfixes should bepatch
. Please prefix the changeset message withfeat:
,bugfix:
orchore:
.Checklist
Please read and apply all contribution requirements.
dev
branch (NEVERmaster
)docs/
,feat/
,chore/
,bugfix/
pnpm ci:check
pnpm format
pnpm test