Commit Graph

8 Commits

Author SHA1 Message Date
Julien P 98b90f1902
Add packagemanager prompt to pulumi new for nodejs ()
https://github.com/pulumi/pulumi/pull/16346 introduced the capability to
query the language runtime for additional prompts. We use this to let
the user pick a package manager among npm, yarn and pnpm during `pulumi
new` when using the nodejs runtime.

When there is no explicitly configured package manager, we re-use the
previous behaviour for determining the package manager (check
`PULUMI_PREFER_YARN` env variable, look for lock files).

Defaults to `npm` when running `new` in non-interactive mode.
2024-06-21 11:35:06 +00:00
Julien P 5ff35273d6
Fix merge failures ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

Fixes https://github.com/pulumi/pulumi/issues/15528

See https://github.com/pulumi/pulumi/pull/15540 &
https://github.com/pulumi/pulumi/pull/15531

Re-creating this as a PR with `ci/test` label so we can get it merged.

## Checklist

- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->

---------

Co-authored-by: Justin Van Patten <jvp@justinvp.com>
Co-authored-by: Anton Tayanovskyy <anton@pulumi.com>
Co-authored-by: Thomas Gummerer <t.gummerer@gmail.com>
2024-02-29 21:06:24 +00:00
Julien P 2a2d247755
Use pnpm as package manager if we find a pnpm-lock.yaml file ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

Initial support pnpm. Note that this does not support pnpm workspaces
yet.

This also does not handle passing the package manager through from
`pulumi new`. Once a user manually runs pnpm, creating a pnpm-lock.yaml,
we'll detect that and pnpm.

Fixes https://github.com/pulumi/pulumi/issues/15455

## Checklist

- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-02-21 13:41:21 +00:00
Abhinav Gupta c024a4013a
test(sdk/npm): Don't send command output to /dev/null
Sending all output to /dev/null makes debugging more difficult.
Send the command output to the testing.T logger
2023-05-26 14:12:29 -07:00
Abhinav Gupta 051a864dca
test(sdk/npm): Use subtests for install
Use subtests for NPM and Yarn install tests.
This will ensure that shared state is properly reset
between the cases.
2023-05-26 14:12:28 -07:00
Abhinav Gupta 88e4beaf19
test(sdk/npm): Use 'require' in chdir
chdir should not proceed if certain operations fail.
Use `require` instead of `assert` for those cases
so that test execution halts if they fail.
2023-05-26 14:12:28 -07:00
Abhinav Gupta f9deb7ab57
test(sdk/npm): Don't download from NPM or Yarn regstries
Tests that download from NPM or Yarn will be brittle, unsafe, and slow.
We don't need to hit these servers directly.

This change alters the package installation tests to
set up a local HTTP server that implements a subset of the
NPM Package Registry API [1] -- just enough to satisfy these tests.

  [1]: https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md

In the tests, we'll set `$HOME` to a new temporary directory and write
an `~/.npmrc` or `~/.yarnrc` requesting use of the local server as the
registry.

With this, the tests are entirely local. No external requests.
2023-05-26 14:12:23 -07:00
Robbie McKinstry 0251902d50
Abstract package manager behavior behind interface.
This PR moves the logic of `Install` and `Pack` behind an interface
for each of the supported package managers. We now dynamically dispatch
to an NPM implementation for NPM installation WLOG yarn.
2023-05-24 12:55:02 -04:00