Commit graph

4 commits

Author SHA1 Message Date
Ian Wahbe 3e2f36548e
[codegen/typescript] Call site defaults for plain Pulumi Object types (#8400)
* Add test case

* Fix tests

* Add test dependencies correctly

* Feed through error handling

* Include test output

* Get types to line up

* Add remaining test files

* Update changelog

* Correctly find type paths

* Handle transitive objects

* Handle required fields

* Add required+default test case

* Don't `<any>` cast known types.

* Add plain object to env-helper test

This test fails right now. My next problem is fixing it.

* Handle plain types

* Handle function inputs

* Fix the indentation

* Handle output types correctly

* Remove unnecessary `!`

* Add missing change to fix test

* Run tests with merge

* Merge in next _index.md diff

* Another attempt at _index.md

* Make module generation deterministic

* Fix docs generation

Credit to @praneetloke
2021-11-18 12:23:30 -08:00
James Nugent e6981898eb
Update package import handling for Node.js (#7474)
* Allow non-pulumi imports for Node.js

Currently the code generator is assuming that Node.js dependencies are
following a naming scheme that is prefixed with `pulumi/`. If this is
not the case the generated import statement is incorrect.

This commit adds a map `ProviderNameToModuleName` to the language
definition that allows you to map the name of the extracted provider of
a dependency to a module name that the generator now uses to create the
import statement.

* Prepend "pulumi" to import names in Node.js SDK

It is common when writing multi-language components to have a module
name which conflicts with a provider name. This can produce unusable
code, since you cannot simultaneously import a package as `aws` and have
a namespace `aws`, for example.

This commit makes this situation much less likely, by renaming the
imported identifier for providers to `pulumiX` where it would
previously have been `x`.

This has an unfortunate side effect of making the examples in the
documentation slightly uglier, since import statements for third-party
packages are now of the form `import * as pulumiAws from "@pulumi/aws"`.
I don't see a way to discern whether code generation is for SDKs vs
examples however, and short of plumbing that through, I don't see a way
around this, so test expectations are updated accordingly.

Co-authored-by: Ben Schiborr <bschiborr@apple.com>
2021-07-16 10:27:20 -07:00
Luke Hoban f4b0fa86fe
Don't mutate the opts argument in resource constructors in Node.js (#6321) 2021-02-13 05:10:59 +11:00
Justin Van Patten e86a69bedd
[codegen/nodejs] Emit externally referenced resources/types (#6225) 2021-01-29 16:52:00 -08:00