solidjs-community / solid-cli

A custom CLI built for Solid.
https://solid-cli.netlify.app/
MIT License
61 stars 11 forks source link

▲ Something went wrong #51

Closed a-x- closed 1 month ago

a-x- commented 2 months ago
npx create-solid my-scalper-app
bun create solid ./my-solid-app
yarn create solid ./my-solid-app

Select Is this a Solid-Start project? — YES

Apple M1 Pro, macOS Sonoma, MBP 2021
a-x- commented 2 months ago
Screenshot 2024-06-17 at 11 51 49
a-x- commented 2 months ago

Select Is this a Solid-Start project? — NO:

Screenshot 2024-06-17 at 11 51 41
Tommypop2 commented 2 months ago

Could you provide your node version? The CLI doesn't work with <=18 I believe.

a-x- commented 2 months ago

node --version
v18.19.1

Tommypop2 commented 2 months ago

Thanks! I'll be able to test soon and see what I find

Tommypop2 commented 2 months ago

I can't reproduce this on my end :( Windows: image Ubuntu: image

I unfortunately don't own a Mac so can't test on MacOS.

Would you be able to try npx @begit/cli solidjs/solid-start --subdir examples/basic basic-example on your system? It's possible that it's begit that's broken here. Also this will give you a working example to work from if the CLI doesn't currently work for you.

lakako commented 1 month ago

I meet same problem on ubuntu 24.04 , nodejs 20.

npx @begit/cli solidjs/solid-start --subdir examples/basic basic-exampl

TypeError: Cannot read properties of undefined (reading 'sha')
    at eh (file:///home/qwe/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/cli/dist/index.js:40:30698)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async rh (file:///home/qwe/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/cli/dist/index.js:40:30748)
    at async Wo (file:///home/qwe/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/cli/dist/index.js:40:31371)
    at async qo (file:///home/qwe/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/cli/dist/index.js:40:31454)
    at async Object.handler (file:///home/qwe/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/cli/dist/index.js:40:32135)
    at async Object.run (file:///home/qwe/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/cli/dist/index.js:34:677)
    at async Tn (file:///home/qwe/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/cli/dist/index.js:36:133)
    at async wr (file:///home/qwe/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/cli/dist/index.js:36:33)
    at async oh (file:///home/qwe/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/cli/dist/index.js:40:32238)

something goes wrong also happen on windows 11 with nodejs 20

Tommypop2 commented 1 month ago

Thanks for reproducing! Would you be able to try that same command again? I've just pushed an update to begit which should make the error messages much better.

lakako commented 1 month ago
 % npx @begit/cli solidjs/solid-start --subdir examples/basic basic-exampl
file:///home/xxx/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/core/dist/index.js:36
  return json[0].sha;
                 ^

TypeError: Cannot read properties of undefined (reading 'sha')
    at fetchLatestCommit (file:///home/xxx/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/core/dist/index.js:36:18)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async downloadToFile (file:///home/xxx/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/core/dist/index.js:40:16)
    at async downloadAndExtract (file:///home/xxx/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/core/dist/index.js:85:19)
    at async downloadRepo (file:///home/xxx/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/core/dist/index.js:93:5)
    at async Object.handler (file:///home/xxx/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/cli/dist/index.js:44:7)
    at async Object.run (/home/xxx/.npm/_npx/3afe89fd084d6a83/node_modules/cmd-ts/dist/cjs/command.js:154:30)
    at async runSafely (/home/xxx/.npm/_npx/3afe89fd084d6a83/node_modules/cmd-ts/dist/cjs/runner.js:26:24)
    at async run (/home/xxx/.npm/_npx/3afe89fd084d6a83/node_modules/cmd-ts/dist/cjs/runner.js:10:20)
    at async main (file:///home/xxx/.npm/_npx/3afe89fd084d6a83/node_modules/@begit/cli/dist/index.js:52:3)

Node.js v20.15.1
Tommypop2 commented 1 month ago

Thanks! Looks like the request retrieving the most recent commit's sha isn't returning the correct value. Does this link work for you? api.github.com/repos/tommypop2/begit/commits?per_page=1 It's basically the same thing that the CLI does under the hood to fetch the latest commit hash.

lakako commented 1 month ago

It will return 'API rate limit exceeded ' I have already add GITHUB_API_TOKEN environment variable.

https://github.com/Tommypop2/begit/blob/71549357966bacfcc2a372f9d57c7b51b906b2a0/packages/core/src/utils.ts#L29 https://github.com/Tommypop2/begit/blob/71549357966bacfcc2a372f9d57c7b51b906b2a0/packages/core/src/utils.ts#L43

Add GITHUB_API_TOKEN to header will fix this issue

https://docs.github.com/en/rest/authentication/authenticating-to-the-rest-api?apiVersion=2022-11-28

Tommypop2 commented 1 month ago

Ah, ok. Yeah I think I'll try using the to the GITHUB_API_TOKEN env variable on each request, and, if that fails, I'll resort to git ls-remote (degit actually does this by default)

Tommypop2 commented 1 month ago

@lakako I've just added support for the BEGIT_GH_API_KEY env variable to begit. Would you mind retrying the above begit command with this environment variable set. I opted to not use GITHUB_API_TOKEN because people might have this set with the intention of another program using it and I felt hooking into it could mean begit is making requests with an API key that the user doesn't want used for that purpose

aellerton commented 1 month ago

I’ve been seeing this “Something went wrong” error for a week at work. I’ve assumed it is to do with being behind a corporate proxy or a similar network/auth related issue, because that’s been an ongoing issue in various projects.

However, those network and auth issues are resolved, yet “pnpm create solid” with all default options fails with “Something went wrong” consistently.

Is there any way to turn on more verbose debugging or logging?

I tried the curl mentioned above and it returns valid json.

Thanks for any help!

lakako commented 1 month ago

Run npx @begit/cli@latest solidjs/solid-start --subdir examples/basic basic-exampl. the problem has gone.

but run 'pnpm create solid@latest' still cause ▲ Something went wrong

aellerton commented 1 month ago

That's interesting. When I run the npx command I get a trace that ultimately complains about a self signed certificate in the chain. That's highly likely because of the corporate environment I'm in, however all other network activity is fine, including plain curl with no environment variables.

Any ideas?

aellerton commented 1 month ago

I don't like it, but setting NODE_TLS_REJECT_UNAUTHORIZED=0 in the environment works around it.

Unsettling because everything else works with ssl fine, but a way forward.

I wonder if fetch is not using the machines certificate chain?

aellerton commented 1 month ago

OK, some success! The env var NODE_EXTRA_CA_CERTS needs to be set, in my case (unbuntu) to /etc/ssl/certs/ca-certificates.crt but your mileage may vary. With that set, things work.

Tommypop2 commented 1 month ago

@lakako I've just released a new version of create-solid, which uses the updated begit version, so it should resolve your issue :)

Tommypop2 commented 1 month ago

@aellerton Great things work now!! Do other CLI tools work properly with your setup without modification? I suspect it's where begit uses the github API to fetch the most recent commit hash, whereas tools like degit or tiged use git ls-remote and parse the stdout. I thought I fixed the incredibly vague "Something Went Wrong" error a while ago, but evidently I haven't :( I'll have to try fixing it again soon

lakako commented 1 month ago

@Tommypop2 It works fine. Thank you.

Tommypop2 commented 1 month ago

Closing this as everything seems to be resolved.