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

Extends don't work with custom providers #167

Open
baha96 opened this issue Jun 25, 2024 · 1 comment · May be fixed by #207
Open

Extends don't work with custom providers #167

baha96 opened this issue Jun 25, 2024 · 1 comment · May be fixed by #207
Labels
bug Something isn't working

Comments

@baha96
Copy link

baha96 commented Jun 25, 2024

Environment

Operating System: MacOs
Node Version: v20.3.1
Nuxt Version: 3.12.2
Nitro Version: v2.9.6
Package Manager: [email protected]

Reproduction

https://stackblitz.com/edit/github-cfzuw7?file=nuxt.config.ts

Describe the bug

https://github.com/unjs/giget?tab=readme-ov-file#custom-providers

const rainbow: TemplateProvider = input => {
  const repoUrl = `https://gitlab.com/baha96/${input}`
  const repoTarUrl =
    'https://gitlab.com/api/v4/projects/59118921/repository/archive.tar.gz?private_token=glpat-5G8Rh7rzKDq5XPDYYDou&sha=51555e794bd6f20f4afdd9aa966c7db063d3ee0f'

  return {
    name: 'rainbow',
    version: input,
    headers: {
      'Accept': 'application/octet-stream',
      'sec-fetch-mode': 'same-origin'
    },
    url: repoUrl,
    tar: repoTarUrl
  }
}

in nuxt.config

extends: [
      [
        'rainbow:test',
        {
          giget: {
            providers: { rainbow },
            force: true,
            forceClean: true,
            auth: 'glpat-5G8Rh7rzKDq5XPDYYDou'
          },
          auth: 'glpat-5G8Rh7rzKDq5XPDYYDou'
        }
      ]
]

After receiving a warning
[12:19:21 PM] WARN Cannot extend config from rainbow:test in /PhpstormProjects/app-nuxt-3

Did some research
In node_modules/c12/dist/shared/c12.cab0c9da.mjs and node_modules/c12/dist/shared/c12.24612422.cjs the files has a variable like this GIGET_PREFIXES

const GIGET_PREFIXES = [
  "gh:",
  "github:",
  "gitlab:",
  "bitbucket:",
  "https://",
  "http://"
];
if (GIGET_PREFIXES.some((prefix) => source.startsWith(prefix))) {
   ....
}

https://github.com/unjs/c12/blob/ed4ce55e2cf7c56dcb171c379285ab568948c3fc/src/loader.ts#L306

and due to the fact that the variable does not contain a custom provider, it does not work

Additional context

No response

Logs

No response

@Ayax0
Copy link

Ayax0 commented Nov 27, 2024

I have now also encountered this problem. As a temporary workaround, I have now done it so that instead of registering my own provider, I simply overwrite the gitlab provider, for example. However, this is a very unattractive solution. As stated here:

// TODO: Either expose from giget directly or redirect all non file:// protocols to giget
, my suggestion would be that every unknown provider or every provider that is not a file simply forwards to giget. this would solve the problem and you could also use custom providers.

@Ayax0 Ayax0 linked a pull request Dec 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants