Skip to content

Rewrite from ReasonML to TypeScript#45

Open
phillipj wants to merge 5 commits into
masterfrom
feature/ts-rewrite
Open

Rewrite from ReasonML to TypeScript#45
phillipj wants to merge 5 commits into
masterfrom
feature/ts-rewrite

Conversation

@phillipj
Copy link
Copy Markdown
Owner

@phillipj phillipj commented Dec 28, 2024

These changes are inspired by the fact that ReasonML was a very interesting learning experience years back and was a cool challenge, but as time as passed, the ReasonML aspect of this tool has severely held back external contributions.

Since the initial creator has stopped using GitLab the recent years, it's even more important for this project to be approachable by new collaborators, where TypeScript certainly opens up the possibilities a lot more.

Lots of help from our new AI companions, the .ts files are meant to be a direct translation of the old .re variants. Few nitpicky changes has been done after initial AI translation, let's see if it works in practice or not.

Help needed

My free free GitLab version prevents me from testing this; I got 403 responses from GitLab as the "blobs search" is not available under the free plan anymore.

❓ anyone have either an on-premise or paid plan and can help with happy path testing?

$ npm install -g gitlab-search@2.0.0-beta1

Closes #43

These changes are inspired by the fact that ReasonML was a very
interesting learning experience years back and was a cool challenge,
but as time as passed, the ReasonML aspect of this tool has severily
held back external contributions.

Since the initial creator has stopped using GitLab the recent years,
it's even more important for this project to be approachable by new
collaborators, where TypeScript certainly opens up the possibilities
a lot more.

Lots of help from our new AI companions, the .ts files are meant to be
a direct translation of the old .re variants. Few nitpicky changes has
been done after initial AI translation, let's see if it works in
practice or not.
Out with ReasonML build tools, in with corresponding TypeScript tools.
@phillipj phillipj added the help wanted Extra attention is needed label Dec 28, 2024
As discovered when publishing a new beta version:

```
npm WARN publish npm auto-corrected some errors in your package.json when publishing.  Please run "npm pkg fix" to address these errors.
npm WARN publish errors corrected:
npm WARN publish "bin" was converted to an object
npm WARN publish "repository" was changed from a string to an object
npm WARN publish "repository.url" was normalized to "git+https://github.com/phillipj/gitlab-search.git"
```

Changes were made by `npm pkg fix`.
@marsluca
Copy link
Copy Markdown

I have tested the script. The setup phase seems to be working correctly. The search seems not to be working. There are no errors, but I don't get any results when I try to search for something. I have tried the same query with the latest release of the ReasonML version; in this case, it works correctly.

TypeScript output:

root@df07f003af86:/# DEBUG=gitlab-search:* gitlab-search -g dir "include"
Requesting: GET https://<censured>/api/v4/groups/dir/projects?per_page=100
Using projects: <censured>
Requesting: GET https://<censured>/api/v4/projects/195434/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/167219/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/139404/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/133577/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/131016/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/123832/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/123392/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/117339/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/102554/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/94371/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/93916/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/90584/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/87718/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/87676/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/85375/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/83589/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/82583/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/80077/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/73601/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/63554/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/62832/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/61722/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/59924/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/56787/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/55357/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/55347/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/54481/search?scope=blobs&search=t 
Requesting: GET https://<censured>/api/v4/projects/52534/search?scope=blobs&search=t

@phillipj
Copy link
Copy Markdown
Owner Author

@marsluca much appreciated!

I've had trouble testing due to gitlab.com not allowing me to use the Search API. Since you dont get any obvious errors, I'd be curious to know if you have a specific subscription on gitlab.com, or use an on-premise instance? If on-premise, what version are you on?

Sorry for the stupid questions, I'm just looking for hints to know how I can test this myself as well (since I'm no longer an active Gitlab user these days).

@marsluca
Copy link
Copy Markdown

Thanks, @phillipj , for your quick reply. I have tested the script using GitLab Enterprise Edition v17.8.5-ee, which is hosted and managed by the company where I work. I don't know if, with the self-managed GitLab Community Edition, you can overcome your testing limitation: https://hub.docker.com/r/gitlab/gitlab-ce/

@oXidFoX
Copy link
Copy Markdown

oXidFoX commented Apr 15, 2025

GitLab Enterprise Edition v16.11.9-ee, self hosted, and node:16.14.2

i installed npm install -g gitlab-search@2.0.0-beta1, then did my setup, then performed a search with gitlab-search -f .gitlab-ci.yml repository
Curiously it matches all the letters "r", case insensitive, not the words "repository"

I often have this crash also (same search):

Something went wrong! AxiosError: Request failed with status code 500
    at settle (/usr/local/lib/node_modules/gitlab-search/dist/index.js:7526:12)
    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/gitlab-search/dist/index.js:8642:11)
    at IncomingMessage.emit (node:events:538:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
    at Axios.request (/usr/local/lib/node_modules/gitlab-search/dist/index.js:9752:41)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ERR_BAD_RESPONSE',
....

or sometimes this :

Something went wrong! AxiosError: Request failed with status code 429
    at settle (/usr/local/lib/node_modules/gitlab-search/dist/index.js:7526:12)
    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/gitlab-search/dist/index.js:8642:11)
    at IncomingMessage.emit (node:events:538:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
    at Axios.request (/usr/local/lib/node_modules/gitlab-search/dist/index.js:9752:41)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ERR_BAD_REQUEST',
....

if I search with debug activated, I don't have errors anymore, but still the same first letter search
DEBUG=gitlab-search:* gitlab-search -f .gitlab-ci.yml repository

Requesting: GET https://<censured>/api/v4/projects/12345/search?scope=blobs&search=r filename:.gitlab-ci.yml

Now, the fun part: the version 1.5.0 also give me often these errors. I mean, more than 50% of the time. I just have to retry until I have my result. So, the same search with 1.5.0 when crashing :

Something exploded! Error: Request failed with status code 500
    at createError (/usr/local/lib/node_modules/gitlab-search/dist/index.js:299:15)
    at settle (/usr/local/lib/node_modules/gitlab-search/dist/index.js:9153:12)
    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/gitlab-search/dist/index.js:11555:11)
    at IncomingMessage.emit (node:events:538:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
....

a few retries later (without changing anything), I have my correct results with 1.5.0, not just the first letter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anyone up for a Typescript rewrite?

3 participants