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

Package Feature Detection #181

Merged
merged 22 commits into from
Jul 30, 2023
Merged

Package Feature Detection #181

merged 22 commits into from
Jul 30, 2023

Conversation

confused-Techie
Copy link
Member

@confused-Techie confused-Techie commented May 19, 2023

Requirements

  • Filling out the template is required.

  • All new code requires tests to ensure against regressions.

    • However, if your PR contains zero code changes, feel free to select the checkmark below to indicate so.
  • Have you ran tests against this code?

  • This PR contains zero code changes.

Description of the Change

The goal of this PR is to bring feature detection to the backend.
That will initially start off with the ./scripts/tools/feature-detection.js script that will preform feature detection on all currently published packages, then the code changes will implement the same behavior into the backend to be preformed once a package is published or a new version is published.


Feature Detection refers to checking a few different 'features' of a package on the repository. This includes the following:

  • Determining if a package provides snippets
  • Determining if a package is a grammar
  • Determining (if a grammar) what file types does this grammar support

This is mainly aimed at collecting the last part here, as once we know what file extensions are supported by any one grammar, we can then implement an endpoint or a filter that allows Pulsar to automatically search for a grammar for any file extension it finds it doesn't have support for.

The other parts of data being collected is purely a way to allow more badges to be applied to packages

@Daeraxa
Copy link
Member

Daeraxa commented May 19, 2023

Is it worth expanding this to autocomplete providers?

@confused-Techie
Copy link
Member Author

confused-Techie commented May 19, 2023

Is it worth expanding this to autocomplete providers?

Appreciate you checking up on this one, and I don't think we need to. Since any autocomplete information should be able to be on the package's package.json, so we don't have to collect it on this step. Since I'm pretty sure any package providing autocompletions has to do it through the service hub right? Which in that case we can actually already search for services, like if I wanted to find every package that provides autocompletions https://web.pulsar-edit.dev/packages?service=autocomplete.provider&serviceType=provided

scripts/tools/feature-detection.js Dismissed Show dismissed Hide dismissed
src/vcs_providers/github.js Fixed Show fixed Hide fixed
src/database.js Fixed Show fixed Hide fixed
src/main.js Fixed Show fixed Hide fixed
src/database.js Fixed Show fixed Hide fixed
src/database.js Fixed Show fixed Hide fixed
src/database.js Dismissed Show dismissed Hide dismissed
return { ok: true, content: command[0] };
}

async function getVersions(pointer) {

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused function getVersions.
return { ok: true, content: command };
}

async function getLatestVersion(pointer) {

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused function getLatestVersion.
return res;
}

function twirlTimer(control) {

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused function twirlTimer.
@confused-Techie confused-Techie marked this pull request as ready for review May 28, 2023 03:19
console.log(`Exiting any and all feature checks because we have hit our unused rate limit of ${UNUSED_RATE_LIMIT} with ${RATE_LIMIT_REMAINING} api hits left.`);
await sqlEnd();
process.exit(1);
} else {

Check warning

Code scanning / CodeQL

Unreachable statement Warning

This statement is unreachable.
@confused-Techie confused-Techie changed the title WIP: Package Feature Detection Package Feature Detection May 29, 2023
@confused-Techie
Copy link
Member Author

Finally getting back to this somewhat, for my own future reference have created the additional tables needed with:

ALTER TABLE versions ADD supported_languages VARCHAR(256) ARRAY
ALTER TABLE versions ADD has_snippets BOOLEAN NOT NULL DEFAULT FALSE
ALTER TABLE versions ADD has_grammar BOOLEAN NOT NULL DEFAULT FALSE

@confused-Techie
Copy link
Member Author

I know it has taken way too long, but I'd like to add, I've finished running feature detection for every currently existing package. This PR is now ready to be merged after a final review, and we can get this feature out.

@savetheclocktower
Copy link

Awesome. I'd love to see UI for this eventually — some sidebar or info box with a list of services provided/consumed, plus names and scope names of provided grammars, etc.

@confused-Techie confused-Techie merged commit bfbd32f into main Jul 30, 2023
6 checks passed
@confused-Techie confused-Techie deleted the backlog-feature-detection branch July 30, 2023 00:38
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.

3 participants