ionic-team / create-stencil

npm init stencil
https://stenciljs.com/
MIT License
50 stars 28 forks source link

feat(starter): allow on-prem github instances #358

Closed rwaskiewicz closed 11 months ago

rwaskiewicz commented 12 months ago

Pull request checklist

Please check if your PR fulfills the following requirements:

Pull request type

Please check the type of change your PR introduces: - [ ] Bugfix - [x] Feature - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior?

Users are unable to pull stater templates from on-prem instnaces of github

GitHub Issue Number: Supersedes https://github.com/ionic-team/create-stencil/pull/45 - thanks to @gfellerph for their work on this!

What is the new behavior?

add support for self hosted github repositories. when generating the url to download a starter from, check for the appropriate environment variables first.

there are two sources of configuration that are accepted - one at invocation time (the command line) and one in .npmrc. see the README changes in this commit for additional details.

Does this introduce a breaking change?

Testing

In addition to new unit tests, this can be manually tested

  1. Build the project - from the project root, npm ci && npm run build
  2. Link the project (so we can invoke it with npm init later) - from the project root, npm link
  3. Create a new directory somewhere where we don't care too much what happens to it, mkdir /tmp/on-prem-test
  4. Copy index.js from the root of the project to your new directory
  5. First, let's test command line invocation: stencil_self_hosted_url=https://your_self_hosted_github_repo.com node index.js component foo-bar. You should see an error like:
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'your_self_hosted_github_repo.com'
    }
  6. Next, let's test the .npmrc - delete index.js locally
  7. npm link create-stencil from your tmp dir
  8. Create an .npmrc: echo stencil_self_hosted_url=https://github. > .npmrc
  9. Run npm init stencil. Expect an error message like that in step 5

    Other information

rwaskiewicz commented 11 months ago

@tanner-reits @alicewriteswrongs can I get another round of reviews on this please? I rebased this atop the changes for checking if a starter exists or not and needed to do a smidge of rework