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

Implement single Command per multiple packages for latestVersion #168

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jo-chemla
Copy link

#167

Can install multiple packages within a single winget install command. The UI radio to toggle the singleCmd mode could be placed at another location

@mherrmann
Copy link
Collaborator

Thanks, but this gives an error.

image

image

@jo-chemla
Copy link
Author

jo-chemla commented Jul 11, 2024

Thanks for the feedback. Unfortunately I was blind-developing since

  • I did clone the repo and installed via npm i but this yielded react 16 vs 17 dependency conflict, so I had to npm i --legacy-peer-deps - see complete logs below
  • then npm run dev but hitting http://localhost:3000 yields error Oops! Could not fetch data from Winstall API. The console shows other errors, utils\fetchWinstallAPI.js (52:28) @ fetchWinstallAPI Error: TypeError: Only absolute URLs are supported - complete log below
  • so I also tried npm run build but resulted in many build errors - see complete logs below

It would be great if original authors/team could resolve these dev environment setup issues before anyone can contribute.

Complete logs collapsed

npm install
C:\Dev\Iconem\winstall>npm i
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR!   peer react@"^17.0.2 || ^18.0.0-0" from [email protected]
npm ERR!   node_modules/next
npm ERR!     next@"^12.0.8" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.13.1" from [email protected]
npm ERR! node_modules/react-dom
npm ERR!   react-dom@"16.13.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm run dev
C:\Dev\Iconem\winstall>npm run dev
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

> [email protected] dev
> next

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
> [PWA] PWA support is disabled
Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
  Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
event - compiled client and server successfully in 10.6s (211 modules)
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry

wait  - compiling / (client and server)...
event - compiled client and server successfully in 2.3s (362 modules)
Only absolute URLs are supported
Only absolute URLs are supported
wait  - compiling /api/auth/[...nextauth]...
event - compiled client and server successfully in 93 ms (338 modules)
[next-auth][warn][NEXTAUTH_URL]
https://next-auth.js.org/warnings#nextauth_url
[next-auth][warn][NO_SECRET]
https://next-auth.js.org/warnings#no_secret
wait  - compiling /apps...
event - compiled client and server successfully in 203 ms (333 modules)
wait  - compiling /apps (client and server)...
event - compiled client and server successfully in 128 ms (358 modules)
wait  - compiling /_error (client and server)...
event - compiled client and server successfully in 60 ms (359 modules)
error - utils\fetchWinstallAPI.js (52:28) @ fetchWinstallAPI
Error: TypeError: Only absolute URLs are supported
  50 |   }
  51 |
> 52 |   return { response, error };
     |                            ^
  53 | };
  54 |
  55 | module.exports = fetchWinstallAPI;
error - utils\fetchWinstallAPI.js (52:28) @ fetchWinstallAPI
Error: TypeError: Only absolute URLs are supported
  50 |   }
  51 |
> 52 |   return { response, error };
     |                            ^
  53 | };
  54 |
  55 | module.exports = fetchWinstallAPI;
wait  - compiling / (client and server)...
event - compiled client and server successfully in 52 ms (374 modules)
Only absolute URLs are supported
Only absolute URLs are supported
npm run build
C:\Dev\Iconem\winstall>npm run build
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

> [email protected] build
> next build

Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
  Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
info  - Checking validity of types
warn  - No ESLint configuration detected. Run next lint to begin setup
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
> [PWA] Compile server
> [PWA] Compile client (static)
> [PWA] Auto register service worker with: C:\Dev\Iconem\winstall\node_modules\next-pwa\register.js
> [PWA] Service worker: C:\Dev\Iconem\winstall\public\sw.js
> [PWA]   url: /sw.js
> [PWA]   scope: /
Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
info  - Creating an optimized production build
warn  - Compiled with warnings

./components/AppExport/ExportApps.js
Attempted import error: 'RadioConfig' is not exported from './AdvancedConfig' (imported as 'RadioConfig').

Import trace for requested module:
./pages/generate.js

./components/AppExport/ExportApps.js
Attempted import error: 'AdvancedConfig' is not exported from './AdvancedConfig' (imported as 'AdvancedConfig').

Import trace for requested module:
./pages/generate.js

./components/AppExport/ExportApps.js
Attempted import error: 'RadioConfig' is not exported from './AdvancedConfig' (imported as 'RadioConfig').

Import trace for requested module:
./pages/generate.js

./components/AppExport/ExportApps.js
Attempted import error: 'AdvancedConfig' is not exported from './AdvancedConfig' (imported as 'AdvancedConfig').

Import trace for requested module:
./pages/generate.js

info  - Collecting page data
[    ] info  - Generating static pages (0/13)
Error occurred prerendering page "/apps". Read more: https://nextjs.org/docs/messages/prerender-error
Error: TypeError: Only absolute URLs are supported
    at fetchWinstallAPI (C:\Dev\Iconem\winstall\.next\server\chunks\111.js:52:19)
    at async getStaticProps (C:\Dev\Iconem\winstall\.next\server\pages\apps.js:378:39)
    at async renderToHTML (C:\Dev\Iconem\winstall\node_modules\next\dist\server\render.js:438:20)
    at async C:\Dev\Iconem\winstall\node_modules\next\dist\export\worker.js:275:36
    at async Span.traceAsyncFn (C:\Dev\Iconem\winstall\node_modules\next\dist\trace\trace.js:75:20)

Error occurred prerendering page "/packs". Read more: https://nextjs.org/docs/messages/prerender-error
Error: TypeError: Only absolute URLs are supported
    at fetchWinstallAPI (C:\Dev\Iconem\winstall\.next\server\chunks\111.js:52:19)
    at async getStaticProps (C:\Dev\Iconem\winstall\.next\server\pages\packs.js:240:40)
    at async renderToHTML (C:\Dev\Iconem\winstall\node_modules\next\dist\server\render.js:438:20)
    at async C:\Dev\Iconem\winstall\node_modules\next\dist\export\worker.js:275:36
    at async Span.traceAsyncFn (C:\Dev\Iconem\winstall\node_modules\next\dist\trace\trace.js:75:20)
Only absolute URLs are supported
Only absolute URLs are supported
info  - Generating static pages (13/13)

> Build error occurred
Error: Export encountered errors on following paths:
        /apps
        /packs
    at C:\Dev\Iconem\winstall\node_modules\next\dist\export\index.js:500:19
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Span.traceAsyncFn (C:\Dev\Iconem\winstall\node_modules\next\dist\trace\trace.js:75:20)
    at async C:\Dev\Iconem\winstall\node_modules\next\dist\build\index.js:1005:17
    at async Span.traceAsyncFn (C:\Dev\Iconem\winstall\node_modules\next\dist\trace\trace.js:75:20)
    at async C:\Dev\Iconem\winstall\node_modules\next\dist\build\index.js:879:13
    at async Span.traceAsyncFn (C:\Dev\Iconem\winstall\node_modules\next\dist\trace\trace.js:75:20)
    at async Object.build [as default] (C:\Dev\Iconem\winstall\node_modules\next\dist\build\index.js:82:25)

@jo-chemla
Copy link
Author

Note after digging through fetchWinstallAPI.js, it seems that I'm simply missing env variables NEXT_PUBLIC_WINGET_API_BASE, NEXT_PUBLIC_WINGET_API_KEY, NEXT_PUBLIC_WINGET_API_SECRET and NEXT_OFFICIAL_PACKS_CREATOR. There are no indications on the repo as to where to get these from.

It seems that the latest builds which are served at winstall.app have diverged quite significantly from where this repo main branch is at. Has this happened after the winget.pro take-over? It's pretty hard to make PRs if the codebases are so much different and dev environment setup is not more explicit.

Anyway, I cheated a bit by setting set NEXT_PUBLIC_WINGET_API_BASE=https://winstall.app/_next/data/4u2-IVAjwkTP5DcjnoraW/, and managed to have my PR work - see screenshot. I still had to add two fixes for the PR to run:

  • Replace setApps(data); with setApps(data.pageProps.data); in pages\apps.js
  • Replace fetchWinstallAPI('/apps',, with fetchWinstallAPI('/apps.json', everywhere where needed (pages\apps.js, pages\index.js, pages\packs\create.js, pages\packs\edit.js, pages\sitemap.xml.js)

Gaining screen space using single command vs one command per package
image

Advanced config new UI parameter
image

@jo-chemla
Copy link
Author

Hi @mherrmann, just a quick ping, this PR for a single winget command for multiple packages can be merged if it's ok from your point-of-view!

@mherrmann
Copy link
Collaborator

I'm sorry, this is still giving (JSON decode) errors. I suspect the new errors are coming from your switch to to .json suffix. winstall.app does run on master. I understand this is all slow and painful to set up but I do not have time to dig deeper or provide better instructions. Sorry.

@jo-chemla
Copy link
Author

jo-chemla commented Sep 9, 2024

Thanks for getting back! Just re-run the whole stack to make sure everything works, and it went smoothly. The steps to reproduce - which could be avoided following little updates -

  • Get id of current web build by going to https://winstall.app/, then open the Network tab of chrome/firefox requests and look for https://winstall.app/_next/data/{build-id}
  • Pull my PR which is against master, npm i --legacy-peer-deps
  • set NEXT_PUBLIC_WINGET_API_BASE=https://winstall.app/_next/data/9WtphRTE4CwprWfIQ-M9Y
  • npm run dev then go to http://localhost:3000/apps select a bunch of apps, Generate Script and select the advanced-option Single command for multiple packages

This sequence of steps returns the above screen. Hope this makes sense!

@mherrmann
Copy link
Collaborator

I tried it in production and it produced the JSON decode errors I mentioned above.

@jo-chemla
Copy link
Author

jo-chemla commented Sep 9, 2024

Ok, that's weird. I'm trying to revert these 2 below commits from but then fetching http://localhost:3000/apps results error 500 visible in the following screen:

  • Replace setApps(data); with setApps(data.pageProps.data); in pages\apps.js
  • Replace fetchWinstallAPI('/apps',, with fetchWinstallAPI('/apps.json', everywhere where needed (pages\apps.js, pages\index.js, pages\packs\create.js, pages\packs\edit.js, pages\sitemap.xml.js)

image

Could it be that my process.env.NEXT_PUBLIC_WINGET_API_BASE is not the correct one? Or rather that auth header NEXT_PUBLIC_WINGET_API_KEY, NEXT_PUBLIC_WINGET_API_SECRET are incorrect and it returns wrong results.

EDIT: I've reverted these changes in the last commit if you want to test it in production/

…data)` to `setApps(data)`

 - Revert `/apps.json` to `/apps` endpoints
 - and `setApps(data.pageProps.data)` to `setApps(data)`
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