Commit Graph

30 Commits

Author SHA1 Message Date
Will Jones 26ff81961b
Improve TypeDocs for `sdk/nodejs/runtime` ()
This commit improves the TypeScript TypeDocs for `runtime` modules in
the NodeJS SDK. Specifically:

* It adds documentation to interfaces, properties, etc. that are missing
it.

* It transforms would-be TypeDoc comments erroneously written using
either `/*` (a single asterisk) or `//` (a normal line comment) to
actual TypeDoc comments.

* It standardises on TypeDoc's `{@link Name}` syntax for linking
identifiers, as opposed to the mixture of backticks and square brackets
we have today.

* It fixes typos and generally cleans up the formatting here and there,
as well as introducing more consistency where the same concepts crop up
in multiple places.
2024-07-15 11:27:47 +00:00
Justin Van Patten 62609a97a5
[sdk/nodejs] Allow missing package.json dependencies ()
Avoid an unhandled error when `dependencies` is missing from
`package.json` during closure serialization.

Fixes 
2024-06-21 10:04:12 +00:00
Julien P 3993499eed
Replace glob with fdir to avoid an indirect dependency on inflight. ()
# Description

https://security.snyk.io/vuln/SNYK-JS-INFLIGHT-6095116

Ref https://github.com/pulumi/customer-support/issues/1405

Snyk is flagging the `inflight` package. We pull this in via
`glob@8.1.0`. More recent versions of glob do not use the vulnerable
package, but we can't upgrade to those versions because of the
Typescript version we use. Instead, replace glob with fdir.

Note that we still pull in inflight via mocha, however that is a
devDependency and won't be included in user installations of pulumi.

To test, I ran:

```bash
cd sdks/nodejs
make build
cd bi
npm pack
```

Then I created a simple Pulumi Typescript program and installed the
packed file, and was able to run `./node_modules/.bin/tsc` successfully
(after adding @types/node@^17)

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
  - [ ] 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.
-->
- [ ] 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: Thomas Gummerer <t.gummerer@gmail.com>
2024-03-12 10:44:03 +00:00
Julien P 5a19d754d7
Fix codepaths computation when working dir is nested relative to package.json ()
# Description

When using `tsc` to precompile typescript in a monorepo, we need to work
relative to the location of `package.json`, not where the pulumi program
lives (which is usually nested further down).

## 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.
-->
- [ ] 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-03-08 16:16:47 +00:00
Julien P be0fe6b1a6
Replace deprecated read-package-tree with @npmcli/arborist ()
<!--- 
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.
-->

read-package-tree is deprecated. Additionally it has a dependency that
is flagged by security scanners.

<!--- 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/9129

Ref https://github.com/pulumi/pulumi/issues/12688

## 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. -->
2024-02-26 18:40:28 +00:00
Julien P 87b01bf35a
Handle workspaces in computeCodePaths ()
# Description

When we compute the code paths for function serialisation, we are not
handling yarn/npm workspace setups where the node_modules might be in a
different directory.

Fixes 
Fixes https://github.com/pulumi/pulumi/issues/2661
Fixes https://github.com/pulumi/pulumi/issues/7168
Fixes https://github.com/pulumi/pulumi/issues/3013

## 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-22 11:41:37 +00:00
Zaid Ajaj 4892fa1fd4
[sdk/nodejs] closure serializtion, lookup package.json from current directory up to parent directories ()
# Description

When using closure serialization, we lookup `package.json` inside of the
current working directory `.`. However, if users put their
`package.json` file in a parent directory and their pulumi program in a
child directory, then it can't find `package.json` and fails to create
inline lambdas.

This PR addresses the issue by looking up `package.json` starting from
the current working directory recursively up parent directories until it
finds the closest `package.json` file and uses that as the "root" of the
project from which the dependencies are inferred.

Fixes  

Didn't know how to write an integration test for this since the issue is
using pulumi/aws but locally testing these code changes succeed the
program.

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
  - [ ] 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: Fraser Waters <fraser@pulumi.com>
2023-08-25 17:01:20 +00:00
Robbie McKinstry 6ab4e11209
Remove unncessary nullish chaining operator. 2023-05-10 12:45:01 -04:00
Robbie McKinstry d6fd384e63
Eliminate unnecessary double negations.
This commit removes instances of prefix-!! where the value
would already be coerced into a boolean. It also removes
instances where the "optional chaining" operator (?.)
would suffice.
2023-05-09 18:35:59 -04:00
Robbie McKinstry 42870b5db2
Don't use the `delete` operator.
This commit replaces uses of `delete` with a safer option,
assigning undefined. `delete` has unexpected behavior and can harm perf.
2023-04-28 22:07:35 -04:00
Robbie McKinstry e05a3bd81c
Apply autoformat
This commit applies the Rome autoformatter to the Node SDK.
These changes are automatically produced. To reproduce these
changes, run `make format` from inside sdk/nodejs.
2023-04-28 18:27:10 -04:00
Robbie McKinstry e978311216
Enable ESModule interoperability 2022-09-20 10:34:00 -04:00
Liam White 6e3e17ef28
Enable workaround for Yarn workspaces for inline functions ()
See https://github.com/pulumi/pulumi/issues/2661\#issuecomment-939531284 for context.

Bascially, yarn workspaces rely on symlinks for monorepo-local packages.

I think this also resolves https://github.com/pulumi/pulumi/issues/2980

Signed-off-by: Liam White <liam@tetrate.io>
2021-10-25 10:13:09 -07:00
Horace Lee a92a005d68
Use ESlint instead of TSlint ()
Migrated TSlint configs to ESlint ones using [tslint-to-eslint-config](https://github.com/typescript-eslint/tslint-to-eslint-config) tool, and refined the configs to better match the current coding style.

Changes:
- [member-delimiter-style](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-delimiter-style.md#options) that as suggested default for type definition to be  with `semicolon`
- Indentation fixes that is enforced by [eslint-indent](https://eslint.org/docs/rules/indent#options)
- Added dependencies for ESlint with Typescript
- Removed TSlint
2021-08-10 11:31:59 -07:00
CyrusNajmabadi 7bdd590586
Add deprecation warnings. () 2019-07-30 15:51:44 -07:00
CyrusNajmabadi b509ff42f2
Deal with circularities in package structure when computing codepaths. () 2018-10-11 14:57:21 -07:00
CyrusNajmabadi 43674dcef5
Switch to upath so that all paths are in unix-format () 2018-10-03 12:06:55 -07:00
CyrusNajmabadi d305b30f21 Revert RunError behavior. Introduce new ResourceError for errors assiated with a resource. ()
* Revert RunError behavior.  Introduce new ResourceError for errors associated with a resource.

* Fix docs.

* Use resource error.

* Use ResourceError in more places.

* Use ResourceError in a few more places.

* Throw a resource error.

* Make required.

* Revert this.

* Lint.

* Only report errors once.

* Better comment.
2018-09-24 16:57:20 -07:00
CyrusNajmabadi 2b610ce577
Actually export type. () 2018-09-21 11:58:58 -07:00
CyrusNajmabadi 08bfb69f7b
Move to an options-bag for computeCodePaths. () 2018-09-21 11:29:05 -07:00
CyrusNajmabadi 0d6acebecd
Be resilient to encountering invalid data in a package.json file. () 2018-09-06 16:35:14 -07:00
Mikhail Shilkov 30fccc0773 computeCodePath won't find modules in an organization on Windows () 2018-09-05 22:07:21 -07:00
CyrusNajmabadi 193af7bda8
Simpler way of stating which dependencies need to be available at runtime. () 2018-09-05 16:18:31 -07:00
CyrusNajmabadi 9d0dc65f49
Provide helper to compute whihc sub-packages should be included even if we would exclude a higher package. () 2018-09-05 12:54:28 -07:00
CyrusNajmabadi 4dab630a1b
Fix issue where we were sometimes filtering out certain node modules innapropriately. () 2018-08-21 15:35:37 -07:00
Cyrus Najmabadi bee8bb8a78 Add a provider-level check as well to ensure we don't add the same file multiple times. 2018-08-16 13:12:56 -07:00
Cyrus Najmabadi 57a404d4cc Revert "Add a provider-level check as well to ensure we don't add the same file multiple times. ()"
This reverts commit f6cab57909.
2018-08-16 13:06:50 -07:00
CyrusNajmabadi f6cab57909
Add a provider-level check as well to ensure we don't add the same file multiple times. () 2018-08-16 10:41:54 -07:00
CyrusNajmabadi 5a52c1c080
Actually export function. () 2018-08-06 15:45:06 -04:00
CyrusNajmabadi 0614b1d052
Move node_module inclusion logic down to pulumi/pulumi so we can use it from both aws and azure. () 2018-08-06 14:12:19 -04:00